Skip to content

Commit

Permalink
These providers are flexible in their support of images for different…
Browse files Browse the repository at this point in the history
… architectures. Let's not constraint on architectures.
  • Loading branch information
anastasiamac committed Aug 19, 2016
1 parent bc97562 commit b5243d1
Show file tree
Hide file tree
Showing 17 changed files with 23 additions and 101 deletions.
8 changes: 3 additions & 5 deletions provider/cloudsigma/environ.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/altoros/gosigma"
"github.com/juju/errors"
"github.com/juju/utils/arch"

"github.com/juju/juju/constraints"
"github.com/juju/juju/environs"
Expand Down Expand Up @@ -140,9 +139,8 @@ func (env *environ) MetadataLookupParams(region string) (*simplestreams.Metadata
env.lock.Lock()
defer env.lock.Unlock()
return &simplestreams.MetadataLookupParams{
Region: region,
Endpoint: gosigma.ResolveEndpoint(region),
Architectures: arch.AllSupportedArches,
Series: config.PreferredSeries(env.ecfg),
Region: region,
Endpoint: gosigma.ResolveEndpoint(region),
Series: config.PreferredSeries(env.ecfg),
}, nil
}
9 changes: 0 additions & 9 deletions provider/cloudsigma/environcaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
package cloudsigma

import (
"github.com/juju/utils/arch"

"github.com/juju/juju/constraints"
)

Expand All @@ -16,18 +14,11 @@ var unsupportedConstraints = []string{
constraints.VirtType,
}

// This is provided to avoid double hard-coding
// of provider specific architecture for
// use in constraints validator and metadata lookup params
// (used to validate images).
var providerSupportedArchitectures = []string{arch.AMD64}

// ConstraintsValidator returns a Validator instance which
// is used to validate and merge constraints.
func (env *environ) ConstraintsValidator() (constraints.Validator, error) {
validator := constraints.NewValidator()
validator.RegisterUnsupported(unsupportedConstraints)
validator.RegisterVocabulary(constraints.Arch, providerSupportedArchitectures)
return validator, nil
}

Expand Down
4 changes: 2 additions & 2 deletions provider/common/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func Bootstrap(ctx environs.BootstrapContext, env environs.Environ, args environ
return bsResult, nil
}

// BootstrapInstance creates a new instance with the series and architecture
// of its choice, constrained to those of the available tools, and
// BootstrapInstance creates a new instance with the series of its choice,
// constrained to those of the available tools, and
// returns the instance result, series, and a function that
// must be called to finalize the bootstrap process by transferring
// the tools and installing the initial Juju controller.
Expand Down
6 changes: 0 additions & 6 deletions provider/dummy/environs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
//
// The DNS name of instances is the same as the Id,
// with ".dns" appended.
//
// To avoid enumerating all possible series and architectures,
// any series or architecture with the prefix "unknown" is
// treated as bad when starting a new instance.
package dummy

import (
Expand All @@ -36,7 +32,6 @@ import (
"github.com/juju/schema"
gitjujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
"github.com/juju/utils/arch"
"github.com/juju/utils/series"
gc "gopkg.in/check.v1"
"gopkg.in/juju/environschema.v1"
Expand Down Expand Up @@ -907,7 +902,6 @@ func (e *environ) ConstraintsValidator() (constraints.Validator, error) {
validator := constraints.NewValidator()
validator.RegisterUnsupported([]string{constraints.CpuPower, constraints.VirtType})
validator.RegisterConflicts([]string{constraints.InstanceType}, []string{constraints.Mem})
validator.RegisterVocabulary(constraints.Arch, []string{arch.AMD64, arch.ARM64, arch.I386})
return validator, nil
}

Expand Down
13 changes: 3 additions & 10 deletions provider/ec2/environ.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/juju/errors"
"github.com/juju/retry"
"github.com/juju/utils"
"github.com/juju/utils/arch"
"github.com/juju/utils/clock"
"gopkg.in/amz.v3/ec2"
"gopkg.in/amz.v3/s3"
Expand Down Expand Up @@ -150,18 +149,13 @@ var unsupportedConstraints = []string{
constraints.VirtType,
}

// This is provided to avoid double hard-coding of provider specific architecture for
// use in constraints validator and metadata lookup params (used to validate images).
var providerSupportedArchitectures = []string{arch.AMD64, arch.I386}

// ConstraintsValidator is defined on the Environs interface.
func (e *environ) ConstraintsValidator() (constraints.Validator, error) {
validator := constraints.NewValidator()
validator.RegisterConflicts(
[]string{constraints.InstanceType},
[]string{constraints.Mem, constraints.CpuCores, constraints.CpuPower})
validator.RegisterUnsupported(unsupportedConstraints)
validator.RegisterVocabulary(constraints.Arch, providerSupportedArchitectures)
instTypeNames := make([]string, len(allInstanceTypes))
for i, itype := range allInstanceTypes {
instTypeNames[i] = itype.Name
Expand Down Expand Up @@ -297,10 +291,9 @@ func (e *environ) MetadataLookupParams(region string) (*simplestreams.MetadataLo
return nil, err
}
return &simplestreams.MetadataLookupParams{
Series: config.PreferredSeries(e.ecfg()),
Region: cloudSpec.Region,
Endpoint: cloudSpec.Endpoint,
Architectures: providerSupportedArchitectures,
Series: config.PreferredSeries(e.ecfg()),
Region: cloudSpec.Region,
Endpoint: cloudSpec.Endpoint,
}, nil
}

Expand Down
5 changes: 1 addition & 4 deletions provider/ec2/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1159,10 +1159,7 @@ func (t *localServerSuite) TestConstraintsValidatorVocab(c *gc.C) {
env := t.Prepare(c)
validator, err := env.ConstraintsValidator()
c.Assert(err, jc.ErrorIsNil)
cons := constraints.MustParse("arch=ppc64el")
_, err = validator.Validate(cons)
c.Assert(err, gc.ErrorMatches, "invalid constraint value: arch=ppc64el\nvalid values are: \\[amd64 i386\\]")
cons = constraints.MustParse("instance-type=foo")
cons := constraints.MustParse("instance-type=foo")
_, err = validator.Validate(cons)
c.Assert(err, gc.ErrorMatches, "invalid constraint value: instance-type=foo\nvalid values are:.*")
}
Expand Down
5 changes: 2 additions & 3 deletions provider/ec2/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,8 @@ func (p environProvider) MetadataLookupParams(region string) (*simplestreams.Met
return nil, fmt.Errorf("unknown region %q", region)
}
return &simplestreams.MetadataLookupParams{
Region: region,
Endpoint: ec2Region.EC2Endpoint,
Architectures: providerSupportedArchitectures,
Region: region,
Endpoint: ec2Region.EC2Endpoint,
}, nil
}

Expand Down
3 changes: 0 additions & 3 deletions provider/gce/environ_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package gce

import (
"github.com/juju/errors"
"github.com/juju/utils/arch"

"github.com/juju/juju/constraints"
)
Expand Down Expand Up @@ -60,8 +59,6 @@ func (env *environ) ConstraintsValidator() (constraints.Validator, error) {

// vocab

validator.RegisterVocabulary(constraints.Arch, []string{arch.AMD64})

instTypeNames := make([]string, len(allInstanceTypes))
for i, itype := range allInstanceTypes {
instTypeNames[i] = itype.Name
Expand Down
15 changes: 0 additions & 15 deletions provider/gce/environ_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package gce_test
import (
"github.com/juju/errors"
jc "github.com/juju/testing/checkers"
"github.com/juju/utils/arch"
"github.com/juju/utils/series"
gc "gopkg.in/check.v1"

Expand Down Expand Up @@ -133,10 +132,6 @@ func (s *environPolSuite) TestConstraintsValidator(c *gc.C) {
unsupported, err := validator.Validate(cons)
c.Assert(err, jc.ErrorIsNil)
c.Check(unsupported, gc.HasLen, 0)

arm64 := arch.ARM64
_, err = validator.Validate(constraints.Value{Arch: &arm64})
c.Assert(err, gc.ErrorMatches, "invalid constraint value: arch=arm64\nvalid values are: \\[amd64\\]")
}

func (s *environPolSuite) TestConstraintsValidatorEmpty(c *gc.C) {
Expand All @@ -160,16 +155,6 @@ func (s *environPolSuite) TestConstraintsValidatorUnsupported(c *gc.C) {
c.Check(unsupported, jc.SameContents, []string{"tags", "virt-type"})
}

func (s *environPolSuite) TestConstraintsValidatorVocabArch(c *gc.C) {
validator, err := s.Env.ConstraintsValidator()
c.Assert(err, jc.ErrorIsNil)

cons := constraints.MustParse("arch=ppc64el")
_, err = validator.Validate(cons)

c.Check(err, gc.ErrorMatches, "invalid constraint value: arch=ppc64el\nvalid values are:.*")
}

func (s *environPolSuite) TestConstraintsValidatorVocabInstType(c *gc.C) {
validator, err := s.Env.ConstraintsValidator()
c.Assert(err, jc.ErrorIsNil)
Expand Down
7 changes: 3 additions & 4 deletions provider/joyent/environ.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,9 @@ func (env *joyentEnviron) MetadataLookupParams(region string) (*simplestreams.Me
region = env.cloud.Region
}
return &simplestreams.MetadataLookupParams{
Series: config.PreferredSeries(env.Ecfg()),
Region: region,
Endpoint: env.cloud.Endpoint,
Architectures: providerSupportedArchitectures,
Series: config.PreferredSeries(env.Ecfg()),
Region: region,
Endpoint: env.cloud.Endpoint,
}, nil
}

Expand Down
5 changes: 0 additions & 5 deletions provider/joyent/environ_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,10 @@ var unsupportedConstraints = []string{
constraints.VirtType,
}

// This is provided to avoid double hard-coding of provider specific architecture for
// use in constraints validator and metadata lookup params (used to validate images).
var providerSupportedArchitectures = []string{"amd64"}

// ConstraintsValidator is defined on the Environs interface.
func (env *joyentEnviron) ConstraintsValidator() (constraints.Validator, error) {
validator := constraints.NewValidator()
validator.RegisterUnsupported(unsupportedConstraints)
validator.RegisterVocabulary(constraints.Arch, providerSupportedArchitectures)
packages, err := env.compute.cloudapi.ListPackages(nil)
if err != nil {
return nil, err
Expand Down
5 changes: 1 addition & 4 deletions provider/joyent/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,7 @@ func (s *localServerSuite) TestConstraintsValidatorVocab(c *gc.C) {
env := s.Prepare(c)
validator, err := env.ConstraintsValidator()
c.Assert(err, jc.ErrorIsNil)
cons := constraints.MustParse("arch=ppc64el")
_, err = validator.Validate(cons)
c.Assert(err, gc.ErrorMatches, "invalid constraint value: arch=ppc64el\nvalid values are:.*")
cons = constraints.MustParse("instance-type=foo")
cons := constraints.MustParse("instance-type=foo")
_, err = validator.Validate(cons)
c.Assert(err, gc.ErrorMatches, "invalid constraint value: instance-type=foo\nvalid values are:.*")
}
3 changes: 1 addition & 2 deletions provider/joyent/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ func (p joyentProvider) MetadataLookupParams(region string) (*simplestreams.Meta
return nil, errors.Errorf("region must be specified")
}
return &simplestreams.MetadataLookupParams{
Region: region,
Architectures: providerSupportedArchitectures,
Region: region,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion provider/openstack/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (p EnvironProvider) Validate(cfg, old *config.Config) (valid *config.Config
msg := fmt.Sprintf(
"Config attribute %q (%v) is deprecated and ignored.\n"+
"Your cloud provider should have set up image metadata to provide the correct image id\n"+
"for your chosen series and archietcure. If this is a private Openstack deployment without\n"+
"for your chosen series and architecture. If this is a private Openstack deployment without\n"+
"existing image metadata, please run 'juju-metadata help' to see how suitable image"+
"metadata can be generated.",
"default-image-id", defaultImageId)
Expand Down
2 changes: 1 addition & 1 deletion provider/openstack/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ func (s *localServerSuite) TestConstraintsMerge(c *gc.C) {
consB := constraints.MustParse("instance-type=m1.small")
cons, err := validator.Merge(consA, consB)
c.Assert(err, jc.ErrorIsNil)
c.Assert(cons, gc.DeepEquals, constraints.MustParse("instance-type=m1.small"))
c.Assert(cons, gc.DeepEquals, constraints.MustParse("arch=amd64 instance-type=m1.small"))
}

func (s *localServerSuite) TestFindImageInstanceConstraint(c *gc.C) {
Expand Down
18 changes: 5 additions & 13 deletions provider/openstack/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/juju/errors"
"github.com/juju/loggo"
"github.com/juju/utils"
"github.com/juju/utils/arch"
"github.com/juju/version"
"gopkg.in/goose.v1/cinder"
"gopkg.in/goose.v1/client"
Expand Down Expand Up @@ -137,8 +136,7 @@ func (p EnvironProvider) MetadataLookupParams(region string) (*simplestreams.Met
return nil, errors.Errorf("region must be specified")
}
return &simplestreams.MetadataLookupParams{
Region: region,
Architectures: providerSupportedArchitectures,
Region: region,
}, nil
}

Expand Down Expand Up @@ -364,18 +362,13 @@ var unsupportedConstraints = []string{
constraints.CpuPower,
}

// This is provided to avoid double hard-coding of provider specific architecture for
// use in constraints validator and metadata lookup params (used to validate images).
var providerSupportedArchitectures = arch.AllSupportedArches

// ConstraintsValidator is defined on the Environs interface.
func (e *Environ) ConstraintsValidator() (constraints.Validator, error) {
validator := constraints.NewValidator()
validator.RegisterConflicts(
[]string{constraints.InstanceType},
[]string{constraints.Mem, constraints.Arch, constraints.RootDisk, constraints.CpuCores})
[]string{constraints.Mem, constraints.RootDisk, constraints.CpuCores})
validator.RegisterUnsupported(unsupportedConstraints)
validator.RegisterVocabulary(constraints.Arch, providerSupportedArchitectures)
novaClient := e.nova()
flavors, err := novaClient.ListFlavorsDetail()
if err != nil {
Expand Down Expand Up @@ -1381,10 +1374,9 @@ func (e *Environ) MetadataLookupParams(region string) (*simplestreams.MetadataLo
return nil, err
}
return &simplestreams.MetadataLookupParams{
Series: config.PreferredSeries(e.ecfg()),
Region: cloudSpec.Region,
Endpoint: cloudSpec.Endpoint,
Architectures: arch.AllSupportedArches,
Series: config.PreferredSeries(e.ecfg()),
Region: cloudSpec.Region,
Endpoint: cloudSpec.Endpoint,
}, nil
}

Expand Down
14 changes: 0 additions & 14 deletions provider/vsphere/environ_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
package vsphere

import (
"github.com/juju/utils/arch"

"github.com/juju/juju/constraints"
)

Expand All @@ -27,23 +25,11 @@ var unsupportedConstraints = []string{
constraints.VirtType,
}

// This is provided to avoid double hard-coding of provider specific architecture for
// use in constraints validator and metadata lookup params (used to validate images).
var providerSupportedArchitectures = arch.AllSupportedArches

// ConstraintsValidator returns a Validator value which is used to
// validate and merge constraints.
func (env *environ) ConstraintsValidator() (constraints.Validator, error) {
validator := constraints.NewValidator()

// unsupported

validator.RegisterUnsupported(unsupportedConstraints)

// vocab

validator.RegisterVocabulary(constraints.Arch, providerSupportedArchitectures)

return validator, nil
}

Expand Down

0 comments on commit b5243d1

Please sign in to comment.