Fix create snapshot API in Huawei driver

Since "Migrate share" have been merged, The share['id']
is not consistent with share['name']. So can not use 'share_name'
in create_share API and use 'share_id' in create_snapshot API at
the same time. Now change snapshot['share']['share_id']
to snapshot['share_name'] in create_snapshot API.

Change-Id: Ieedda9318762ba2c683788f023a87728d7287504
Closes-Bug: #1494614
This commit is contained in:
zhongjun 2015-09-11 15:29:05 +08:00
parent b1f06b6b8b
commit 037fc4bbee
3 changed files with 5 additions and 10 deletions

View File

@ -194,10 +194,9 @@ class V3StorageConnection(driver.HuaweiBase):
snap_name = snapshot['id']
share_proto = snapshot['share']['share_proto']
share_name = self.helper._get_share_name_by_id(
snapshot['share']['share_id'])
share_url_type = self.helper._get_share_url_type(share_proto)
share = self.helper._get_share_by_name(share_name, share_url_type)
share = self.helper._get_share_by_name(snapshot['share_name'],
share_url_type)
if not share:
err_msg = _('Can not create snapshot,'
@ -216,9 +215,7 @@ class V3StorageConnection(driver.HuaweiBase):
LOG.debug("Delete a snapshot.")
snap_name = snapshot['id']
share_name = self.helper._get_share_name_by_id(
snapshot['share']['share_id'])
sharefsid = self.helper._get_fsid_by_name(share_name)
sharefsid = self.helper._get_fsid_by_name(snapshot['share_name'])
if sharefsid is None:
LOG.warning(_LW('Delete snapshot share id %s fs has been '

View File

@ -612,10 +612,6 @@ class RestHelper(object):
share_path = "/" + share_name.replace("-", "_") + "/"
return share_path
def _get_share_name_by_id(self, share_id):
share_name = "share_" + share_id
return share_name
def _get_share_name_by_export_location(self, export_location, share_proto):
export_location_split = None
share_name = None

View File

@ -563,6 +563,7 @@ class HuaweiShareDriverTestCase(test.TestCase):
'display_name': 'snapshot',
'name': 'fake_snapshot_name',
'size': 1,
'share_name': 'share_fake_uuid',
'share': {
'share_name': 'share_fake_uuid',
'share_id': 'fake_uuid',
@ -576,6 +577,7 @@ class HuaweiShareDriverTestCase(test.TestCase):
'display_name': 'snapshot',
'name': 'fake_snapshot_name',
'size': 1,
'share_name': 'share_fake_uuid',
'share': {
'share_name': 'share_fake_uuid',
'share_id': 'fake_uuid',