~ubuntu-branches/ubuntu/wily/juju-core/wily

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/provider/cloudsigma/environcaps.go

  • Committer: Package Import Robot
  • Author(s): Curtis C. Hovey
  • Date: 2015-09-22 15:27:01 UTC
  • mfrom: (1.1.36)
  • Revision ID: package-import@ubuntu.com-20150922152701-lzq2yhn2uaahrdqu
Tags: 1.24.6-0ubuntu1
* New upstream release (LP: #1481556).
* d/copyright updated for Juju 1.24.6 (Last verified commit changes).
* d/tests/* Run tests with upstart when Juju version before 1.23.
* Prefer gccgo-5 for ppc64el and arm64 in build-deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2015 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
package cloudsigma
 
5
 
 
6
import (
 
7
        "github.com/juju/errors"
 
8
 
 
9
        "github.com/juju/juju/constraints"
 
10
        "github.com/juju/juju/environs/imagemetadata"
 
11
        "github.com/juju/juju/environs/simplestreams"
 
12
        "github.com/juju/juju/provider/common"
 
13
)
 
14
 
 
15
func (env *environ) SupportedArchitectures() ([]string, error) {
 
16
        env.archMutex.Lock()
 
17
        defer env.archMutex.Unlock()
 
18
        if env.supportedArchitectures != nil {
 
19
                return env.supportedArchitectures, nil
 
20
        }
 
21
        logger.Debugf("Getting supported architectures from simplestream.")
 
22
        cloudSpec, err := env.Region()
 
23
        if err != nil {
 
24
                return nil, err
 
25
        }
 
26
        imageConstraint := imagemetadata.NewImageConstraint(simplestreams.LookupParams{
 
27
                CloudSpec: cloudSpec,
 
28
                Stream:    env.Config().ImageStream(),
 
29
        })
 
30
        env.supportedArchitectures, err = common.SupportedArchitectures(env, imageConstraint)
 
31
        logger.Debugf("Supported architectures: %v", env.supportedArchitectures)
 
32
        return env.supportedArchitectures, err
 
33
}
 
34
 
 
35
var unsupportedConstraints = []string{
 
36
        constraints.Container,
 
37
        constraints.InstanceType,
 
38
        constraints.Tags,
 
39
}
 
40
 
 
41
// ConstraintsValidator returns a Validator instance which
 
42
// is used to validate and merge constraints.
 
43
func (env *environ) ConstraintsValidator() (constraints.Validator, error) {
 
44
        validator := constraints.NewValidator()
 
45
        validator.RegisterUnsupported(unsupportedConstraints)
 
46
        supportedArches, err := env.SupportedArchitectures()
 
47
        if err != nil {
 
48
                return nil, err
 
49
        }
 
50
        validator.RegisterVocabulary(constraints.Arch, supportedArches)
 
51
        return validator, nil
 
52
}
 
53
 
 
54
// SupportNetworks returns whether the environment has support to
 
55
// specify networks for services and machines.
 
56
func (env *environ) SupportNetworks() bool {
 
57
        return false
 
58
}
 
59
 
 
60
// SupportsUnitAssignment returns an error which, if non-nil, indicates
 
61
// that the environment does not support unit placement. If the environment
 
62
// does not support unit placement, then machines may not be created
 
63
// without units, and units cannot be placed explcitly.
 
64
func (env *environ) SupportsUnitPlacement() error {
 
65
        return errors.NotImplementedf("SupportsUnitPlacement")
 
66
}