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:
parent
36275be1c1
commit
83864a25e2
cinderclient
@ -130,8 +130,7 @@ class GroupsTest(utils.TestCase):
|
||||
'create-from-src': {
|
||||
'description': None,
|
||||
'name': 'group',
|
||||
'group_snapshot_id': '5678',
|
||||
'source_group_id': None
|
||||
'group_snapshot_id': '5678'
|
||||
}
|
||||
}
|
||||
cs.assert_called('POST', '/groups/action',
|
||||
@ -145,8 +144,7 @@ class GroupsTest(utils.TestCase):
|
||||
'create-from-src': {
|
||||
'description': None,
|
||||
'name': 'group',
|
||||
'source_group_id': '5678',
|
||||
'group_snapshot_id': None
|
||||
'source_group_id': '5678'
|
||||
}
|
||||
}
|
||||
cs.assert_called('POST', '/groups/action',
|
||||
|
@ -679,9 +679,12 @@ class ShellTest(utils.TestCase):
|
||||
@ddt.unpack
|
||||
def test_group_create_from_src(self, grp_snap_id, src_grp_id, src):
|
||||
expected = {'create-from-src': {'name': 'test-1',
|
||||
'description': 'test-1-desc',
|
||||
'group_snapshot_id': grp_snap_id,
|
||||
'source_group_id': src_grp_id}}
|
||||
'description': 'test-1-desc'}}
|
||||
if grp_snap_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 '
|
||||
'group-create-from-src --name test-1 '
|
||||
'--description test-1-desc ')
|
||||
|
@ -111,10 +111,20 @@ class GroupManager(base.ManagerWithFind):
|
||||
:param project_id: Project id derived from context
|
||||
: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,
|
||||
'description': description,
|
||||
'group_snapshot_id': group_snapshot_id,
|
||||
'source_group_id': source_group_id, }}
|
||||
create_key: create_value}}
|
||||
|
||||
self.run_hooks('modify_body_for_action', body,
|
||||
'create-from-src')
|
||||
|
Loading…
x
Reference in New Issue
Block a user