Merge "IBM Storage - Fix vol create from snapshot in CG"
This commit is contained in:
commit
7c8901e764
@ -1876,7 +1876,8 @@ class XIVProxyTest(test.TestCase):
|
||||
|
||||
p.ibm_storage_cli.cmd.cg_snapshots_create.assert_called_once_with(
|
||||
cg=p._cg_name_from_cgsnapshot(cgsnap_group_obj),
|
||||
snap_group=p._group_name_from_cgsnapshot(cgsnap_group_obj))
|
||||
snap_group=p._group_name_from_cgsnapshot_id(
|
||||
cgsnap_group_obj['id']))
|
||||
|
||||
self.assertEqual('available', model_update['status'])
|
||||
|
||||
@ -1967,7 +1968,8 @@ class XIVProxyTest(test.TestCase):
|
||||
{}, cgsnap_group_obj, [])
|
||||
|
||||
p.ibm_storage_cli.cmd.snap_group_delete.assert_called_once_with(
|
||||
snap_group=p._group_name_from_cgsnapshot(cgsnap_group_obj))
|
||||
snap_group=p._group_name_from_cgsnapshot_id(
|
||||
cgsnap_group_obj['id']))
|
||||
|
||||
self.assertEqual('deleted', model_update['status'])
|
||||
|
||||
|
@ -960,7 +960,13 @@ class XIVProxy(proxy.IBMStorageProxy):
|
||||
"""create volume from snapshot."""
|
||||
|
||||
snapshot_size = float(snapshot['volume_size'])
|
||||
snapshot_name = snapshot['name']
|
||||
if not snapshot['group_snapshot_id']:
|
||||
snapshot_name = snapshot['name']
|
||||
else:
|
||||
groupname = self._group_name_from_cgsnapshot_id(
|
||||
snapshot['group_snapshot_id'])
|
||||
snapshot_name = self._volume_name_from_cg_snapshot(
|
||||
groupname, snapshot.volume_name)
|
||||
self._create_volume_from_snapshot(
|
||||
volume, snapshot_name, snapshot_size)
|
||||
|
||||
@ -1663,13 +1669,13 @@ class XIVProxy(proxy.IBMStorageProxy):
|
||||
'''
|
||||
return self._cg_name_from_id(cgsnapshot['group_id'])
|
||||
|
||||
def _group_name_from_cgsnapshot(self, cgsnapshot):
|
||||
def _group_name_from_cgsnapshot_id(self, cgsnapshot_id):
|
||||
'''Get storage Snaphost Group name from snapshot.
|
||||
|
||||
A utility method to translate from openstack cgsnapshot
|
||||
to Snapshot Group name on the storage
|
||||
'''
|
||||
return self._group_name_from_id(cgsnapshot['id'])
|
||||
return self._group_name_from_id(cgsnapshot_id)
|
||||
|
||||
def _volume_name_from_cg_snapshot(self, cgs, vol):
|
||||
# Note: The string is limited by the storage to 63 characters
|
||||
@ -1783,7 +1789,8 @@ class XIVProxy(proxy.IBMStorageProxy):
|
||||
raise
|
||||
created_volumes = []
|
||||
try:
|
||||
groupname = self._group_name_from_cgsnapshot(cgsnapshot)
|
||||
groupname = self._group_name_from_cgsnapshot_id(
|
||||
cgsnapshot['id'])
|
||||
for volume, source in zip(volumes, snapshots):
|
||||
vol_name = source.volume_name
|
||||
LOG.debug("Original volume: %(vol_name)s",
|
||||
@ -2037,7 +2044,7 @@ class XIVProxy(proxy.IBMStorageProxy):
|
||||
model_update = {'status': fields.GroupSnapshotStatus.AVAILABLE}
|
||||
|
||||
cgname = self._cg_name_from_cgsnapshot(cgsnapshot)
|
||||
groupname = self._group_name_from_cgsnapshot(cgsnapshot)
|
||||
groupname = self._group_name_from_cgsnapshot_id(cgsnapshot['id'])
|
||||
LOG.info("Creating snapshot %(group)s for CG %(cg)s.",
|
||||
{'group': groupname, 'cg': cgname})
|
||||
|
||||
@ -2110,7 +2117,7 @@ class XIVProxy(proxy.IBMStorageProxy):
|
||||
"""Deletes a CG snapshot."""
|
||||
|
||||
cgname = self._cg_name_from_cgsnapshot(cgsnapshot)
|
||||
groupname = self._group_name_from_cgsnapshot(cgsnapshot)
|
||||
groupname = self._group_name_from_cgsnapshot_id(cgsnapshot['id'])
|
||||
LOG.info("Deleting snapshot %(group)s for CG %(cg)s.",
|
||||
{'group': groupname, 'cg': cgname})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user