forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
environ_policy.go
69 lines (51 loc) · 1.94 KB
/
environ_policy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
// +build go1.3
package lxd
import (
"github.com/juju/errors"
"github.com/juju/utils/arch"
"github.com/juju/juju/constraints"
"github.com/juju/juju/environs"
)
// PrecheckInstance verifies that the provided series and constraints
// are valid for use in creating an instance in this environment.
func (env *environ) PrecheckInstance(args environs.PrecheckInstanceParams) error {
if _, err := env.parsePlacement(args.Placement); err != nil {
return errors.Trace(err)
}
if args.Constraints.HasInstanceType() {
return errors.Errorf("LXD does not support instance types (got %q)", *args.Constraints.InstanceType)
}
return nil
}
var unsupportedConstraints = []string{
constraints.Cores,
constraints.CpuPower,
//TODO(ericsnow) Add constraints.Mem as unsupported?
constraints.InstanceType,
constraints.Tags,
constraints.VirtType,
}
// ConstraintsValidator returns a Validator value which is used to
// validate and merge constraints.
func (env *environ) ConstraintsValidator() (constraints.Validator, error) {
validator := constraints.NewValidator()
// Register conflicts.
// We don't have any conflicts to register.
// Register unsupported constraints.
validator.RegisterUnsupported(unsupportedConstraints)
// Register the constraints vocab.
// TODO(natefinch): This is only correct so long as the lxd is running on
// the local machine. If/when we support a remote lxd environment, we'll
// need to change this to match the arch of the remote machine.
validator.RegisterVocabulary(constraints.Arch, []string{arch.HostArch()})
// TODO(ericsnow) Get this working...
//validator.RegisterVocabulary(constraints.Container, supportedContainerTypes)
return validator, nil
}
// SupportNetworks returns whether the environment has support to
// specify networks for applications and machines.
func (env *environ) SupportNetworks() bool {
return false
}