Merge "Let Nova to pick availability zone if more than 1"

This commit is contained in:
Jenkins 2016-12-08 23:08:06 +00:00 committed by Gerrit Code Review
commit f54339f316
3 changed files with 14 additions and 5 deletions

View File

@ -27,7 +27,7 @@
<select ng-if="model.availabilityZones.length !== 0"
class="form-control"
id="availability-zone"
ng-options="zone for zone in model.availabilityZones"
ng-options="zone.value as zone.label for zone in model.availabilityZones"
ng-model="model.newInstanceSpec.availability_zone">
</select>
</div>

View File

@ -331,13 +331,22 @@
return zone.zoneState && zone.zoneState.available;
})
.map(function (zone) {
return zone.zoneName;
return {label: zone.zoneName, value: zone.zoneName};
})
);
if (model.availabilityZones.length > 0) {
model.newInstanceSpec.availability_zone = model.availabilityZones[0];
if (model.availabilityZones.length === 1) {
model.newInstanceSpec.availability_zone = model.availabilityZones[0].value;
} else if (model.availabilityZones.length > 1) {
// There are 2 or more; allow ability for nova scheduler to pick,
// and make that the default.
model.availabilityZones.unshift({
label: gettext("Any Availability Zone"),
value: ""
});
model.newInstanceSpec.availability_zone = model.availabilityZones[0].value;
}
}
// Flavors

View File

@ -408,7 +408,7 @@
expect(model.images.length).toBe(2);
expect(model.imageSnapshots.length).toBe(2);
expect(model.availabilityZones.length).toBe(2);
expect(model.availabilityZones.length).toBe(3); // 2 + 1 for 'nova pick'
expect(model.flavors.length).toBe(2);
expect(model.keypairs.length).toBe(2);
expect(model.securityGroups.length).toBe(2);