1
// Copyright 2015 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
9
"github.com/juju/errors"
10
"github.com/juju/utils/arch"
12
"github.com/juju/juju/constraints"
15
// PrecheckInstance verifies that the provided series and constraints
16
// are valid for use in creating an instance in this environment.
17
func (env *environ) PrecheckInstance(series string, cons constraints.Value, placement string) error {
18
if _, err := env.parsePlacement(placement); err != nil {
19
return errors.Trace(err)
22
if cons.HasInstanceType() {
23
return errors.Errorf("LXD does not support instance types (got %q)", *cons.InstanceType)
29
var unsupportedConstraints = []string{
32
//TODO(ericsnow) Add constraints.Mem as unsupported?
33
constraints.InstanceType,
38
// ConstraintsValidator returns a Validator value which is used to
39
// validate and merge constraints.
40
func (env *environ) ConstraintsValidator() (constraints.Validator, error) {
41
validator := constraints.NewValidator()
43
// Register conflicts.
45
// We don't have any conflicts to register.
47
// Register unsupported constraints.
49
validator.RegisterUnsupported(unsupportedConstraints)
51
// Register the constraints vocab.
53
// TODO(natefinch): This is only correct so long as the lxd is running on
54
// the local machine. If/when we support a remote lxd environment, we'll
55
// need to change this to match the arch of the remote machine.
56
validator.RegisterVocabulary(constraints.Arch, []string{arch.HostArch()})
58
// TODO(ericsnow) Get this working...
59
//validator.RegisterVocabulary(constraints.Container, supportedContainerTypes)
64
// SupportNetworks returns whether the environment has support to
65
// specify networks for applications and machines.
66
func (env *environ) SupportNetworks() bool {