~ubuntu-branches/ubuntu/trusty/juju-core/trusty

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/provider/azure/instancetype.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-03-24 16:05:44 UTC
  • mfrom: (1.1.20)
  • Revision ID: package-import@ubuntu.com-20140324160544-g8lsfufby18d5fj4
Tags: 1.17.6-0ubuntu1
* New upstream point release, including fixes for:
  - br0 not bought up by cloud-init with MAAS provider (LP: #1271144).
  - ppc64el enablement for juju/lxc (LP: #1273769).
  - juju userdata should not restart networking (LP: #1248283).
  - error detecting hardware characteristics (LP: #1276909).
  - juju instances not including the default security group (LP: #1129720).
  - juju bootstrap does not honor https_proxy (LP: #1240260).
* d/control,rules: Drop BD on bash-completion, install bash-completion
  direct from upstream source code.
* d/rules: Set HOME prior to generating man pages.
* d/control: Drop alternative dependency on mongodb-server; juju now only
  works on trusty with juju-mongodb.

Show diffs side-by-side

added added

removed removed

Lines of Context:
121
121
// this setting.
122
122
var signedImageDataOnly = true
123
123
 
124
 
// fetchImageMetadata is a pointer to the imagemetadata.Fetch function.  It's
125
 
// only needed as an injection point where tests can substitute fakes.
126
 
var fetchImageMetadata = imagemetadata.Fetch
127
 
 
128
124
// findMatchingImages queries simplestreams for OS images that match the given
129
125
// requirements.
130
126
//
142
138
                return nil, err
143
139
        }
144
140
        indexPath := simplestreams.DefaultIndexPath
145
 
        images, err := fetchImageMetadata(sources, indexPath, constraint, signedImageDataOnly)
 
141
        images, _, err := imagemetadata.Fetch(sources, indexPath, constraint, signedImageDataOnly)
146
142
        if len(images) == 0 || errors.IsNotFoundError(err) {
147
143
                return nil, fmt.Errorf("no OS images found for location %q, series %q, architectures %q (and endpoint: %q)", location, series, arches, endpoint)
148
144
        } else if err != nil {
161
157
        return instances.InstanceType{
162
158
                Id:       roleSize.Name,
163
159
                Name:     roleSize.Name,
164
 
                Arches:   architectures,
165
160
                CpuCores: roleSize.CpuCores,
166
161
                Mem:      roleSize.Mem,
167
162
                RootDisk: roleSize.OSDiskSpaceVirt,
168
163
                Cost:     roleSize.Cost,
169
 
                VType:    &vtype,
 
164
                VirtType: &vtype,
170
165
                CpuPower: &cpuPower,
171
166
                // tags are not currently supported by azure
172
167
        }
174
169
 
175
170
// listInstanceTypes describes the available instance types based on a
176
171
// description in gwacl's terms.
177
 
func listInstanceTypes(roleSizes []gwacl.RoleSize) []instances.InstanceType {
 
172
func listInstanceTypes(env *azureEnviron, roleSizes []gwacl.RoleSize) ([]instances.InstanceType, error) {
 
173
        arches, err := env.SupportedArchitectures()
 
174
        if err != nil {
 
175
                return nil, err
 
176
        }
178
177
        types := make([]instances.InstanceType, len(roleSizes))
179
178
        for index, roleSize := range roleSizes {
180
179
                types[index] = newInstanceType(roleSize)
 
180
                types[index].Arches = arches
181
181
        }
182
 
        return types
 
182
        return types, nil
183
183
}
184
184
 
185
185
// findInstanceSpec returns the InstanceSpec that best satisfies the supplied
186
186
// InstanceConstraint.
187
 
func findInstanceSpec(env *azureEnviron, constraint instances.InstanceConstraint) (*instances.InstanceSpec, error) {
 
187
func findInstanceSpec(env *azureEnviron, constraint *instances.InstanceConstraint) (*instances.InstanceSpec, error) {
188
188
        constraint.Constraints = defaultToBaselineSpec(constraint.Constraints)
189
189
        imageData, err := findMatchingImages(env, constraint.Region, constraint.Series, constraint.Arches)
190
190
        if err != nil {
191
191
                return nil, err
192
192
        }
193
193
        images := instances.ImageMetadataToImages(imageData)
194
 
        instanceTypes := listInstanceTypes(gwacl.RoleSizes)
195
 
        return instances.FindInstanceSpec(images, &constraint, instanceTypes)
 
194
        instanceTypes, err := listInstanceTypes(env, gwacl.RoleSizes)
 
195
        if err != nil {
 
196
                return nil, err
 
197
        }
 
198
        return instances.FindInstanceSpec(images, constraint, instanceTypes)
196
199
}