@@ -90,10 +90,10 @@ var jsonImagesContent = `
90
90
}
91
91
}
92
92
},
93
- "com.ubuntu.cloud:server:12.04:armhf ": {
93
+ "com.ubuntu.cloud:server:12.04:arm64 ": {
94
94
"release": "precise",
95
95
"version": "12.04",
96
- "arch": "armhf ",
96
+ "arch": "arm64 ",
97
97
"versions": {
98
98
"20121218": {
99
99
"items": {
@@ -116,7 +116,7 @@ var jsonImagesContent = `
116
116
"id": "ami-00000036"
117
117
}
118
118
},
119
- "pubname": "ubuntu-precise-12.04-armhf -server-20121218",
119
+ "pubname": "ubuntu-precise-12.04-arm64 -server-20121218",
120
120
"label": "release"
121
121
}
122
122
}
@@ -204,7 +204,7 @@ var jsonImagesContent = `
204
204
type instanceSpecTestParams struct {
205
205
desc string
206
206
region string
207
- arches [] string
207
+ arch string
208
208
stream string
209
209
constraints string
210
210
instanceTypes []InstanceType
@@ -215,11 +215,11 @@ type instanceSpecTestParams struct {
215
215
}
216
216
217
217
func (p * instanceSpecTestParams ) init () {
218
- if p .arches == nil {
219
- p .arches = [] string { "amd64" , "armhf" }
218
+ if p .arch == "" {
219
+ p .arch = "amd64"
220
220
}
221
221
if p .instanceTypes == nil {
222
- p .instanceTypes = []InstanceType {{Id : "1" , Name : "it-1" , Arches : [] string { "amd64" , "armhf" } }}
222
+ p .instanceTypes = []InstanceType {{Id : "1" , Name : "it-1" , Arch : "amd64" }}
223
223
p .instanceTypeId = "1"
224
224
p .instanceTypeName = "it-1"
225
225
}
@@ -232,43 +232,7 @@ var findInstanceSpecTests = []instanceSpecTestParams{
232
232
region : "test" ,
233
233
imageId : "ami-00000033" ,
234
234
instanceTypes : []InstanceType {
235
- {Id : "1" , Name : "it-1" , Arches : []string {"amd64" }, VirtType : & pv , Mem : 512 },
236
- },
237
- },
238
- {
239
- desc : "prefer amd64 over i386" ,
240
- region : "test" ,
241
- imageId : "ami-00000033" ,
242
- arches : []string {"amd64" , "i386" },
243
- instanceTypes : []InstanceType {
244
- {Id : "1" , Name : "it-1" , Arches : []string {"i386" , "amd64" }, VirtType : & pv , Mem : 512 },
245
- },
246
- },
247
- {
248
- desc : "prefer armhf over i386 (first alphabetical wins)" ,
249
- region : "test" ,
250
- imageId : "ami-00000034" ,
251
- arches : []string {"armhf" , "i386" },
252
- instanceTypes : []InstanceType {
253
- {Id : "1" , Name : "it-1" , Arches : []string {"armhf" , "i386" }, VirtType : & pv , Mem : 512 },
254
- },
255
- },
256
- {
257
- desc : "prefer ppc64el over i386 (64-bit trumps 32-bit, regardless of alphabetical order)" ,
258
- region : "test" ,
259
- imageId : "ami-b79b09b9" ,
260
- arches : []string {"ppc64el" , "i386" },
261
- instanceTypes : []InstanceType {
262
- {Id : "1" , Name : "it-1" , Arches : []string {"i386" , "ppc64el" }, VirtType : & pv , Mem : 512 },
263
- },
264
- },
265
- {
266
- desc : "prefer amd64 over arm64 (first 64-bit alphabetical wins)" ,
267
- region : "test" ,
268
- imageId : "ami-00000033" ,
269
- arches : []string {"arm64" , "amd64" },
270
- instanceTypes : []InstanceType {
271
- {Id : "1" , Name : "it-1" , Arches : []string {"arm64" , "amd64" }, VirtType : & pv , Mem : 512 },
235
+ {Id : "1" , Name : "it-1" , Arch : "amd64" , VirtType : & pv , Mem : 512 },
272
236
},
273
237
},
274
238
{
@@ -277,7 +241,7 @@ var findInstanceSpecTests = []instanceSpecTestParams{
277
241
stream : "released" ,
278
242
imageId : "ami-00000035" ,
279
243
instanceTypes : []InstanceType {
280
- {Id : "1" , Name : "it-1" , Arches : [] string { "amd64" } , VirtType : & hvm , Mem : 512 , CpuCores : 2 },
244
+ {Id : "1" , Name : "it-1" , Arch : "amd64" , VirtType : & hvm , Mem : 512 , CpuCores : 2 },
281
245
},
282
246
},
283
247
{
@@ -286,15 +250,15 @@ var findInstanceSpecTests = []instanceSpecTestParams{
286
250
stream : "daily" ,
287
251
imageId : "ami-10000035" ,
288
252
instanceTypes : []InstanceType {
289
- {Id : "1" , Name : "it-1" , Arches : [] string { "amd64" } , VirtType : & hvm , Mem : 512 , CpuCores : 2 },
253
+ {Id : "1" , Name : "it-1" , Arch : "amd64" , VirtType : & hvm , Mem : 512 , CpuCores : 2 },
290
254
},
291
255
},
292
256
{
293
257
desc : "multiple images exists in metadata, use most recent" ,
294
258
region : "test" ,
295
259
imageId : "ami-00000035" ,
296
260
instanceTypes : []InstanceType {
297
- {Id : "1" , Name : "it-1" , Arches : [] string { "amd64" } , VirtType : & hvm , Mem : 512 , CpuCores : 2 },
261
+ {Id : "1" , Name : "it-1" , Arch : "amd64" , VirtType : & hvm , Mem : 512 , CpuCores : 2 },
298
262
},
299
263
},
300
264
{
@@ -303,7 +267,7 @@ var findInstanceSpecTests = []instanceSpecTestParams{
303
267
constraints : "instance-type=" ,
304
268
imageId : "ami-00000033" ,
305
269
instanceTypes : []InstanceType {
306
- {Id : "1" , Name : "it-1" , Arches : [] string { "amd64" } , VirtType : & pv , Mem : 512 },
270
+ {Id : "1" , Name : "it-1" , Arch : "amd64" , VirtType : & pv , Mem : 512 },
307
271
},
308
272
},
309
273
{
@@ -312,34 +276,44 @@ var findInstanceSpecTests = []instanceSpecTestParams{
312
276
constraints : "instance-type=it-1" ,
313
277
imageId : "ami-00000035" ,
314
278
instanceTypes : []InstanceType {
315
- {Id : "1" , Name : "it-1" , Arches : []string {"amd64" }, VirtType : & hvm , Mem : 512 , CpuCores : 2 },
316
- {Id : "2" , Name : "it-2" , Arches : []string {"amd64" }, VirtType : & hvm , Mem : 1024 , CpuCores : 2 },
279
+ {Id : "1" , Name : "it-1" , Arch : "amd64" , VirtType : & hvm , Mem : 512 , CpuCores : 2 },
280
+ {Id : "2" , Name : "it-2" , Arch : "amd64" , VirtType : & hvm , Mem : 1024 , CpuCores : 2 },
281
+ },
282
+ },
283
+ {
284
+ desc : "use instance type non amd64 constraint" ,
285
+ region : "test" ,
286
+ arch : "ppc64el" ,
287
+ imageId : "ami-b79b09b9" ,
288
+ instanceTypes : []InstanceType {
289
+ {Id : "1" , Name : "it-1" , Arch : "amd64" , VirtType : & pv , Mem : 4096 , CpuCores : 2 , Cost : 1 },
290
+ {Id : "2" , Name : "it-2" , Arch : "ppc64el" , VirtType : & pv , Mem : 4096 , CpuCores : 2 , Cost : 2 },
317
291
},
318
292
},
319
293
{
320
294
desc : "instance type constraint, no matching instance types" ,
321
295
region : "test" ,
322
296
constraints : "instance-type=it-10" ,
323
297
instanceTypes : []InstanceType {
324
- {Id : "1" , Name : "it-1" , Arches : [] string { "amd64" } , VirtType : & hvm , Mem : 512 , CpuCores : 2 },
298
+ {Id : "1" , Name : "it-1" , Arch : "amd64" , VirtType : & hvm , Mem : 512 , CpuCores : 2 },
325
299
},
326
- err : `no instance types in test matching constraints "instance-type=it-10"` ,
300
+ err : `no instance types in test matching constraints "arch=amd64 instance-type=it-10"` ,
327
301
},
328
302
{
329
303
desc : "no image exists in metadata" ,
330
304
region : "invalid-region" ,
331
- err : `no metadata for "precise" images in invalid-region with arches \[ amd64 armhf\] ` ,
305
+ err : `no metadata for "precise" images in invalid-region with arch amd64` ,
332
306
},
333
307
{
334
308
desc : "no valid instance types" ,
335
309
region : "test" ,
336
310
instanceTypes : []InstanceType {},
337
- err : `no instance types in test matching constraints ""` ,
311
+ err : `no instance types in test matching constraints "arch=amd64 "` ,
338
312
},
339
313
{
340
314
desc : "no compatible instance types" ,
341
315
region : "arm-only" ,
342
- instanceTypes : []InstanceType {{Id : "1" , Name : "it-1" , Arches : [] string { "amd64" } , Mem : 2048 }},
316
+ instanceTypes : []InstanceType {{Id : "1" , Name : "it-1" , Arch : "amd64" , Mem : 2048 }},
343
317
err : `no "precise" images in arm-only matching instance types \[it-1\]` ,
344
318
},
345
319
}
@@ -351,7 +325,6 @@ func (s *imageSuite) TestFindInstanceSpec(c *gc.C) {
351
325
cons , err := imagemetadata .NewImageConstraint (simplestreams.LookupParams {
352
326
CloudSpec : simplestreams.CloudSpec {t .region , "ep" },
353
327
Releases : []string {"precise" },
354
- Arches : t .arches ,
355
328
Stream : t .stream ,
356
329
})
357
330
c .Assert (err , jc .ErrorIsNil )
@@ -376,7 +349,7 @@ func (s *imageSuite) TestFindInstanceSpec(c *gc.C) {
376
349
spec , err := FindInstanceSpec (images , & InstanceConstraint {
377
350
Series : "precise" ,
378
351
Region : t .region ,
379
- Arches : t . arches ,
352
+ Arch : t . arch ,
380
353
Constraints : imageCons ,
381
354
}, t .instanceTypes )
382
355
if t .err != "" {
@@ -404,30 +377,30 @@ var imageMatchtests = []struct {
404
377
}{
405
378
{
406
379
image : Image {Arch : "amd64" },
407
- itype : InstanceType {Arches : [] string { "amd64" } },
380
+ itype : InstanceType {Arch : "amd64" },
408
381
match : exactMatch ,
409
382
}, {
410
383
image : Image {Arch : "amd64" },
411
- itype : InstanceType {Arches : [] string { "amd64" , "armhf" } },
384
+ itype : InstanceType {Arch : "amd64" },
412
385
match : exactMatch ,
413
386
}, {
414
387
image : Image {Arch : "amd64" , VirtType : hvm },
415
- itype : InstanceType {Arches : [] string { "amd64" } , VirtType : & hvm },
388
+ itype : InstanceType {Arch : "amd64" , VirtType : & hvm },
416
389
match : exactMatch ,
417
390
}, {
418
- image : Image {Arch : "armhf " },
419
- itype : InstanceType {Arches : [] string { "amd64" } },
391
+ image : Image {Arch : "arm64 " },
392
+ itype : InstanceType {Arch : "amd64" },
420
393
}, {
421
394
image : Image {Arch : "amd64" , VirtType : hvm },
422
- itype : InstanceType {Arches : [] string { "amd64" } },
395
+ itype : InstanceType {Arch : "amd64" },
423
396
match : exactMatch ,
424
397
}, {
425
398
image : Image {Arch : "amd64" }, // no known virt type
426
- itype : InstanceType {Arches : [] string { "amd64" } , VirtType : & hvm },
399
+ itype : InstanceType {Arch : "amd64" , VirtType : & hvm },
427
400
match : partialMatch ,
428
401
}, {
429
402
image : Image {Arch : "amd64" , VirtType : "pv" },
430
- itype : InstanceType {Arches : [] string { "amd64" } , VirtType : & hvm },
403
+ itype : InstanceType {Arch : "amd64" , VirtType : & hvm },
431
404
match : nonMatch ,
432
405
},
433
406
}
@@ -484,15 +457,15 @@ func (*imageSuite) TestInstanceConstraintString(c *gc.C) {
484
457
ic := & InstanceConstraint {
485
458
Series : "precise" ,
486
459
Region : "region" ,
487
- Arches : [] string { "amd64" , "arm64" } ,
460
+ Arch : "amd64" ,
488
461
Constraints : imageCons ,
489
462
}
490
463
c .Assert (
491
464
ic .String (), gc .Equals ,
492
- "{region: region, series: precise, arches: [ amd64 arm64] , constraints: mem=4096M, storage: []}" )
465
+ "{region: region, series: precise, arch: amd64, constraints: mem=4096M, storage: []}" )
493
466
494
467
ic .Storage = []string {"ebs" , "ssd" }
495
468
c .Assert (
496
469
ic .String (), gc .Equals ,
497
- "{region: region, series: precise, arches: [ amd64 arm64] , constraints: mem=4096M, storage: [ebs ssd]}" )
470
+ "{region: region, series: precise, arch: amd64, constraints: mem=4096M, storage: [ebs ssd]}" )
498
471
}
0 commit comments