Merge "Only display the bootable volume snapshots when creating instance"
This commit is contained in:
commit
eba5b0f88d
|
@ -52,6 +52,7 @@ SEC_GROUP_ROLE_PREFIX = \
|
|||
workflows.update_instance.INSTANCE_SEC_GROUP_SLUG + "_role_"
|
||||
AVAILABLE = api.cinder.VOLUME_STATE_AVAILABLE
|
||||
VOLUME_SEARCH_OPTS = dict(status=AVAILABLE, bootable=True)
|
||||
VOLUME_BOOTABLE_SEARCH_OPTS = dict(bootable=True)
|
||||
SNAPSHOT_SEARCH_OPTS = dict(status=AVAILABLE)
|
||||
|
||||
|
||||
|
@ -2109,9 +2110,12 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
|||
'ConfigDrive': 1,
|
||||
'ServerGroups': 1,
|
||||
})
|
||||
self.mock_volume_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS)
|
||||
self.mock_volume_list.assert_has_calls([
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS),
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_BOOTABLE_SEARCH_OPTS),
|
||||
])
|
||||
self.mock_volume_snapshot_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=SNAPSHOT_SEARCH_OPTS)
|
||||
|
@ -2275,9 +2279,12 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
|||
'ConfigDrive': 1,
|
||||
'ServerGroups': 1,
|
||||
})
|
||||
self.mock_volume_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS)
|
||||
self.mock_volume_list.assert_has_calls([
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS),
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_BOOTABLE_SEARCH_OPTS),
|
||||
])
|
||||
self.mock_volume_snapshot_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=SNAPSHOT_SEARCH_OPTS)
|
||||
|
@ -2383,9 +2390,12 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
|||
})
|
||||
self.mock_server_group_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest())
|
||||
self.mock_volume_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS)
|
||||
self.mock_volume_list.assert_has_calls([
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS),
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_BOOTABLE_SEARCH_OPTS),
|
||||
])
|
||||
self.mock_volume_snapshot_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=SNAPSHOT_SEARCH_OPTS)
|
||||
|
@ -2524,9 +2534,12 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
|||
'ConfigDrive': 1,
|
||||
'ServerGroups': 1,
|
||||
})
|
||||
self.mock_volume_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS)
|
||||
self.mock_volume_list.assert_has_calls([
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS),
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_BOOTABLE_SEARCH_OPTS),
|
||||
])
|
||||
self.mock_volume_snapshot_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=SNAPSHOT_SEARCH_OPTS)
|
||||
|
@ -2645,9 +2658,12 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
|||
})
|
||||
self.mock_server_group_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest())
|
||||
self.mock_volume_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS)
|
||||
self.mock_volume_list.assert_has_calls([
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS),
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_BOOTABLE_SEARCH_OPTS),
|
||||
])
|
||||
self.mock_volume_snapshot_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=SNAPSHOT_SEARCH_OPTS)
|
||||
|
@ -2743,9 +2759,12 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
|||
self._check_glance_image_list_detailed(count=5)
|
||||
self._check_neutron_network_and_port_list()
|
||||
self._check_nova_lists(flavor_count=3)
|
||||
self.mock_volume_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS)
|
||||
self.mock_volume_list.assert_has_calls([
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS),
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_BOOTABLE_SEARCH_OPTS),
|
||||
])
|
||||
self.mock_volume_snapshot_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=SNAPSHOT_SEARCH_OPTS)
|
||||
|
@ -2812,9 +2831,11 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
|||
'ServerGroups': True,
|
||||
})
|
||||
self.mock_server_group_list.return_value = []
|
||||
volumes = [v for v in self.cinder_volumes.list()
|
||||
if (getattr(v, 'bootable', 'false') == 'true')]
|
||||
snapshots = [v for v in self.cinder_volume_snapshots.list()
|
||||
if (v.status == AVAILABLE)]
|
||||
self.mock_volume_list.return_value = []
|
||||
self.mock_volume_list.return_value = volumes
|
||||
self.mock_volume_snapshot_list.return_value = snapshots
|
||||
self.mock_server_create.return_value = None
|
||||
self.mock_tenant_quota_usages.return_value = quota_usages
|
||||
|
@ -2854,9 +2875,12 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
|||
})
|
||||
self.mock_server_group_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest())
|
||||
self.mock_volume_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS)
|
||||
self.mock_volume_list.assert_has_calls([
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS),
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_BOOTABLE_SEARCH_OPTS),
|
||||
])
|
||||
self.mock_volume_snapshot_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=SNAPSHOT_SEARCH_OPTS)
|
||||
|
@ -3021,9 +3045,12 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
|||
'ConfigDrive': 1,
|
||||
'ServerGroups': 1,
|
||||
})
|
||||
self.mock_volume_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS)
|
||||
self.mock_volume_list.assert_has_calls([
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS),
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_BOOTABLE_SEARCH_OPTS),
|
||||
])
|
||||
self.mock_volume_snapshot_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=SNAPSHOT_SEARCH_OPTS)
|
||||
|
@ -3128,9 +3155,12 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
|||
'ConfigDrive': 1,
|
||||
'ServerGroups': 1,
|
||||
})
|
||||
self.mock_volume_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS)
|
||||
self.mock_volume_list.assert_has_calls([
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS),
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_BOOTABLE_SEARCH_OPTS),
|
||||
])
|
||||
self.mock_volume_snapshot_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=SNAPSHOT_SEARCH_OPTS)
|
||||
|
@ -3241,9 +3271,12 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
|||
'ConfigDrive': 1,
|
||||
'ServerGroups': 1,
|
||||
})
|
||||
self.mock_volume_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS)
|
||||
self.mock_volume_list.assert_has_calls([
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS),
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_BOOTABLE_SEARCH_OPTS),
|
||||
])
|
||||
self.mock_volume_snapshot_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=SNAPSHOT_SEARCH_OPTS)
|
||||
|
@ -3349,9 +3382,12 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
|||
})
|
||||
self.mock_server_group_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest())
|
||||
self.mock_volume_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS)
|
||||
self.mock_volume_list.assert_has_calls([
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS),
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_BOOTABLE_SEARCH_OPTS),
|
||||
])
|
||||
self.mock_volume_snapshot_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=SNAPSHOT_SEARCH_OPTS)
|
||||
|
@ -3444,9 +3480,12 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
|||
'ConfigDrive': 1,
|
||||
'ServerGroups': 1,
|
||||
})
|
||||
self.mock_volume_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS)
|
||||
self.mock_volume_list.assert_has_calls([
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS),
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_BOOTABLE_SEARCH_OPTS),
|
||||
])
|
||||
self.mock_volume_snapshot_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=SNAPSHOT_SEARCH_OPTS)
|
||||
|
@ -3633,9 +3672,12 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
|||
network_id=net.id,
|
||||
tenant_id=self.tenant.id)
|
||||
for net in self.networks.list()])
|
||||
self.mock_volume_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS)
|
||||
self.mock_volume_list.assert_has_calls([
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS),
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_BOOTABLE_SEARCH_OPTS),
|
||||
])
|
||||
self.mock_volume_snapshot_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=SNAPSHOT_SEARCH_OPTS)
|
||||
|
@ -3767,9 +3809,12 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
|||
self._check_neutron_network_and_port_list()
|
||||
self.mock_server_group_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest())
|
||||
self.mock_volume_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS)
|
||||
self.mock_volume_list.assert_has_calls([
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS),
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_BOOTABLE_SEARCH_OPTS),
|
||||
])
|
||||
self.mock_volume_snapshot_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=SNAPSHOT_SEARCH_OPTS)
|
||||
|
@ -4011,9 +4056,12 @@ class InstanceLaunchInstanceTests(InstanceTestBase,
|
|||
|
||||
self.mock_server_group_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest())
|
||||
self.mock_volume_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS)
|
||||
self.mock_volume_list.assert_has_calls([
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS),
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_BOOTABLE_SEARCH_OPTS),
|
||||
])
|
||||
self.mock_volume_snapshot_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(),
|
||||
search_opts=SNAPSHOT_SEARCH_OPTS)
|
||||
|
@ -4135,8 +4183,12 @@ class InstanceTests2(InstanceTestBase, InstanceTableTestMixin):
|
|||
html=True,
|
||||
msg_prefix="The default key pair was not selected.")
|
||||
|
||||
self.mock_volume_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(), search_opts=VOLUME_SEARCH_OPTS)
|
||||
self.mock_volume_list.assert_has_calls([
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_SEARCH_OPTS),
|
||||
mock.call(helpers.IsHttpRequest(),
|
||||
search_opts=VOLUME_BOOTABLE_SEARCH_OPTS),
|
||||
])
|
||||
self.mock_volume_snapshot_list.assert_called_once_with(
|
||||
helpers.IsHttpRequest(), search_opts=SNAPSHOT_SEARCH_OPTS)
|
||||
self._check_glance_image_list_detailed(count=5)
|
||||
|
|
|
@ -489,9 +489,12 @@ class SetInstanceDetailsAction(workflows.Action):
|
|||
try:
|
||||
if cinder.is_volume_service_enabled(request):
|
||||
available = api.cinder.VOLUME_STATE_AVAILABLE
|
||||
volumes = [v.id for v in cinder.volume_list(
|
||||
self.request, search_opts=dict(bootable=True))]
|
||||
snapshots = [self._get_volume_display_name(s)
|
||||
for s in cinder.volume_snapshot_list(
|
||||
self.request, search_opts=dict(status=available))]
|
||||
self.request, search_opts=dict(status=available))
|
||||
if s.volume_id in volumes]
|
||||
except Exception:
|
||||
exceptions.handle(self.request,
|
||||
_('Unable to retrieve list of volume '
|
||||
|
|
|
@ -678,8 +678,20 @@
|
|||
}
|
||||
|
||||
function onGetVolumeSnapshots(data) {
|
||||
cinderAPI.getVolumes({bootable: 1}).then(function (volumes) {
|
||||
onGetBootableVolumeSnapshots(volumes.data.items, data.data.items);
|
||||
});
|
||||
}
|
||||
|
||||
function onGetBootableVolumeSnapshots(bootableVolumes, volumeSnapshots) {
|
||||
var bootableVolumeIds = [];
|
||||
bootableVolumes.forEach(function(volume) {
|
||||
bootableVolumeIds.push(volume.id);
|
||||
});
|
||||
model.volumeSnapshots.length = 0;
|
||||
push.apply(model.volumeSnapshots, data.data.items);
|
||||
push.apply(model.volumeSnapshots, volumeSnapshots.filter(function (volumeSnapshot) {
|
||||
return bootableVolumeIds.indexOf(volumeSnapshot.volume_id) !== -1;
|
||||
}));
|
||||
addAllowedBootSource(
|
||||
model.volumeSnapshots,
|
||||
bootSourceTypes.VOLUME_SNAPSHOT,
|
||||
|
|
|
@ -229,7 +229,9 @@
|
|||
return deferred.promise;
|
||||
},
|
||||
getVolumeSnapshots: function() {
|
||||
var snapshots = [ { id: 'snap-1' }, { id: 'snap-2' } ];
|
||||
var snapshots = [ { id: 'snap-1', volume_id: 'vol-1' },
|
||||
{ id: 'snap-2', volume_id: 'vol-2' },
|
||||
{ id: 'snap-3', volume_id: 'vol-3' } ];
|
||||
|
||||
var deferred = $q.defer();
|
||||
deferred.resolve({ data: { items: snapshots } });
|
||||
|
@ -682,7 +684,8 @@
|
|||
expect(model.volumes.length).toBe(0);
|
||||
expect(model.volumes).toEqual([]);
|
||||
expect(model.volumeSnapshots.length).toBe(2);
|
||||
expect(model.volumeSnapshots).toEqual([{ id: 'snap-1' }, { id: 'snap-2' }]);
|
||||
expect(model.volumeSnapshots).toEqual([{ id: 'snap-1', volume_id: 'vol-1' },
|
||||
{ id: 'snap-2', volume_id: 'vol-2' }]);
|
||||
expect(model.allowedBootSources).toBeDefined();
|
||||
expect(model.allowedBootSources.length).toBe(3);
|
||||
expect(model.allowedBootSources).toContain(IMAGE);
|
||||
|
|
Loading…
Reference in New Issue