IBM Storage - Fix vol create from snapshot in CG
running vol create from snapshot ID of vol that belongs to CG fails. The reason for this is the naming convention inside the storage which is different for regular volume snapshots and snapshots of volumes that result from cgsnapshot. Change-Id: Ibdfc0e09518f38e137b31faf5a386be3938af7d6 Closes-Bug: 1699056
This commit is contained in:
parent
75d875d75b
commit
c0dbe26602
@ -1799,7 +1799,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'])
|
||||
|
||||
@ -1890,7 +1891,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'])
|
||||
|
||||
|
@ -953,7 +953,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)
|
||||
|
||||
@ -1656,13 +1662,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
|
||||
@ -1776,7 +1782,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",
|
||||
@ -2030,7 +2037,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})
|
||||
|
||||
@ -2103,7 +2110,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…
x
Reference in New Issue
Block a user