github.com/mwhudson/juju@v0.0.0-20160512215208-90ff01f3497f/provider/cloudsigma/environcaps.go (about) 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 constraints.VirtType, 40 } 41 42 // ConstraintsValidator returns a Validator instance which 43 // is used to validate and merge constraints. 44 func (env *environ) ConstraintsValidator() (constraints.Validator, error) { 45 validator := constraints.NewValidator() 46 validator.RegisterUnsupported(unsupportedConstraints) 47 supportedArches, err := env.SupportedArchitectures() 48 if err != nil { 49 return nil, err 50 } 51 validator.RegisterVocabulary(constraints.Arch, supportedArches) 52 return validator, nil 53 } 54 55 // SupportNetworks returns whether the environment has support to 56 // specify networks for services and machines. 57 func (env *environ) SupportNetworks() bool { 58 return false 59 } 60 61 // SupportsUnitAssignment returns an error which, if non-nil, indicates 62 // that the environment does not support unit placement. If the environment 63 // does not support unit placement, then machines may not be created 64 // without units, and units cannot be placed explcitly. 65 func (env *environ) SupportsUnitPlacement() error { 66 return errors.NotImplementedf("SupportsUnitPlacement") 67 }