Merge lp:~wallyworld/juju-core/amd64plz into lp:~go-bot/juju-core/trunk
Proposed by
Ian Booth
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Ian Booth | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 2675 | ||||
Proposed branch: | lp:~wallyworld/juju-core/amd64plz | ||||
Merge into: | lp:~go-bot/juju-core/trunk | ||||
Diff against target: |
138 lines (+65/-2) 4 files modified
environs/instances/image.go (+24/-1) environs/instances/image_test.go (+39/-0) provider/ec2/export_test.go (+1/-0) provider/ec2/image_test.go (+1/-1) |
||||
To merge this branch: | bzr merge lp:~wallyworld/juju-core/amd64plz | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+216977@code.launchpad.net |
Commit message
Always pick amd64 if it's an option
This branch takes lp:~natefinch/juju-core/045-amd64plz
and fixes some tests.
See https:/
Description of the change
Always pick amd64 if it's an option
This branch takes lp:~natefinch/juju-core/045-amd64plz
and fixes some tests.
See https:/
To post a comment you must log in.
Reviewers: mp+216977_ code.launchpad. net,
Message:
Please take a look.
Description:
Always pick amd64 if it's an option
This branch takes lp:~natefinch/juju-core/045-amd64plz /codereview. appspot. com/89900043/
and fixes some tests.
See https:/
https:/ /code.launchpad .net/~wallyworl d/juju- core/amd64plz/ +merge/ 216977
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/90720043/
Affected files (+67, -2 lines): instances/ image.go instances/ image_test. go ec2/export_ test.go ec2/image_ test.go
A [revision details]
M environs/
M environs/
M provider/
M provider/
Index: [revision details] 20140424033650- 9am3xzxfcelms2x 8
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: environs/ instances/ image.go instances/ image.go' instances/ image.go 2014-04-17 05:44:57 +0000 instances/ image.go 2014-04-24 04:56:36 +0000
=== modified file 'environs/
--- environs/
+++ environs/
@@ -8,6 +8,7 @@
"launchpad. net/juju- core/constraint s" net/juju- core/environs/ imagemetadata" net/juju- core/juju/ arch"
"launchpad.
+ "launchpad.
)
// InstanceConstraint constrains the possible instances that may be
@@ -78,14 +79,19 @@
return nil, fmt.Errorf("no instance types found matching
constraint: %s", ic)
}
+ specs := []*InstanceSpec{} itype, image}, nil itype, image})
for _, itype := range matchingTypes {
for _, image := range possibleImages {
if image.match(itype) {
- return &InstanceSpec{
+ specs = append(specs, &InstanceSpec{
}
}
}
+ if spec := preferredSpec( specs); spec != nil {
+ return spec, nil
+ }
+
names := make([]string, len(matchingTypes))
for i, itype := range matchingTypes {
names[i] = itype.Name
@@ -93,6 +99,23 @@
return nil, fmt.Errorf("no %q images in %s matching instance types %v",
ic.Series, ic.Region, names)
}
+// preferredSpec will if possible return a spec with arch matching that
+// of the host machine.
+func preferredSpec(specs []*InstanceSpec) *InstanceSpec {
+ if len(specs) > 1 {
+ hostArch := arch.HostArch()
+ for _, spec := range specs {
+ if spec.Image.Arch == hostArch {
+ return spec
+ }
+ }
+ }
+ if len(specs) > 0 {
+ return specs[0]
+ }
+ return nil
+}
+
// Image holds the attributes that vary amongst relevant images for
// a given series in a given region.
type Image struct {
Index: environs/ instances/ image_test. go instances/ image_test. go' instances/ image_test. go 2014-04-18 13:58:13 +0000 instances/ image_test. go 2014-04-23 21:04:24 +0000 net/juju- core/constraint s" net/juju- core/environs/ imagemetadata" net/juju- core/environs/ simplestreams" net/juju- core/juju/ arch" net/juju- core/testing/ testbase" net/juju- core/utils"
=== modified file 'environs/
--- environs/
+++ environs/
@@ -11,6 +11,7 @@
"launchpad.
"launchpad.
"launchpad.
+ "launchpad.
"launchpad.
"launchpad.
)
@@ -306,6 +307,44 @@
}
}
+func (s *imageSuite) TestPreferredSpec(c *gc.C) {
+ type prefTest struct {
+ desc string
+ specs []*Instan...