unable to create group from src in cinderclient
According the api schema of cinder, create_group_from_src should only specify one of arguments from [group_snapshot_id, source_group_id]. Now cinderclient specified them both even if one of them is None. This patch fix this issue to just pass one argument. Change-Id: Idef51ab9a1452dd5eb3be4d4b6dca095a777d611 Closes-Bug: #1777555
This commit is contained in:
@@ -130,8 +130,7 @@ class GroupsTest(utils.TestCase):
|
|||||||
'create-from-src': {
|
'create-from-src': {
|
||||||
'description': None,
|
'description': None,
|
||||||
'name': 'group',
|
'name': 'group',
|
||||||
'group_snapshot_id': '5678',
|
'group_snapshot_id': '5678'
|
||||||
'source_group_id': None
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cs.assert_called('POST', '/groups/action',
|
cs.assert_called('POST', '/groups/action',
|
||||||
@@ -145,8 +144,7 @@ class GroupsTest(utils.TestCase):
|
|||||||
'create-from-src': {
|
'create-from-src': {
|
||||||
'description': None,
|
'description': None,
|
||||||
'name': 'group',
|
'name': 'group',
|
||||||
'source_group_id': '5678',
|
'source_group_id': '5678'
|
||||||
'group_snapshot_id': None
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cs.assert_called('POST', '/groups/action',
|
cs.assert_called('POST', '/groups/action',
|
||||||
|
@@ -679,9 +679,12 @@ class ShellTest(utils.TestCase):
|
|||||||
@ddt.unpack
|
@ddt.unpack
|
||||||
def test_group_create_from_src(self, grp_snap_id, src_grp_id, src):
|
def test_group_create_from_src(self, grp_snap_id, src_grp_id, src):
|
||||||
expected = {'create-from-src': {'name': 'test-1',
|
expected = {'create-from-src': {'name': 'test-1',
|
||||||
'description': 'test-1-desc',
|
'description': 'test-1-desc'}}
|
||||||
'group_snapshot_id': grp_snap_id,
|
if grp_snap_id:
|
||||||
'source_group_id': src_grp_id}}
|
expected['create-from-src']['group_snapshot_id'] = grp_snap_id
|
||||||
|
elif src_grp_id:
|
||||||
|
expected['create-from-src']['source_group_id'] = src_grp_id
|
||||||
|
|
||||||
cmd = ('--os-volume-api-version 3.14 '
|
cmd = ('--os-volume-api-version 3.14 '
|
||||||
'group-create-from-src --name test-1 '
|
'group-create-from-src --name test-1 '
|
||||||
'--description test-1-desc ')
|
'--description test-1-desc ')
|
||||||
|
@@ -111,10 +111,20 @@ class GroupManager(base.ManagerWithFind):
|
|||||||
:param project_id: Project id derived from context
|
:param project_id: Project id derived from context
|
||||||
:rtype: A dictionary containing Group metadata
|
:rtype: A dictionary containing Group metadata
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# NOTE(wanghao): According the API schema in cinder side, client
|
||||||
|
# should NOT specify the group_snapshot_id and source_group_id at
|
||||||
|
# same time, even one of them is None.
|
||||||
|
if group_snapshot_id:
|
||||||
|
create_key = 'group_snapshot_id'
|
||||||
|
create_value = group_snapshot_id
|
||||||
|
elif source_group_id:
|
||||||
|
create_key = 'source_group_id'
|
||||||
|
create_value = source_group_id
|
||||||
|
|
||||||
body = {'create-from-src': {'name': name,
|
body = {'create-from-src': {'name': name,
|
||||||
'description': description,
|
'description': description,
|
||||||
'group_snapshot_id': group_snapshot_id,
|
create_key: create_value}}
|
||||||
'source_group_id': source_group_id, }}
|
|
||||||
|
|
||||||
self.run_hooks('modify_body_for_action', body,
|
self.run_hooks('modify_body_for_action', body,
|
||||||
'create-from-src')
|
'create-from-src')
|
||||||
|
Reference in New Issue
Block a user