Merge "Add API check for server_groups.create"

This commit is contained in:
Zuul 2020-09-30 20:35:00 +00:00 committed by Gerrit Code Review
commit 3902efc292
2 changed files with 28 additions and 2 deletions

View File

@ -68,9 +68,13 @@ class CreateServerGroup(command.ShowOne):
def take_action(self, parsed_args):
compute_client = self.app.client_manager.compute
info = {}
policy_arg = {'policies': [parsed_args.policy]}
if compute_client.api_version >= api_versions.APIVersion("2.64"):
policy_arg = {'policy': parsed_args.policy}
server_group = compute_client.server_groups.create(
name=parsed_args.name,
policies=[parsed_args.policy])
name=parsed_args.name, **policy_arg)
info.update(server_group._info)
columns = _get_columns(info)

View File

@ -108,6 +108,28 @@ class TestServerGroupCreate(TestServerGroup):
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
def test_server_group_create_v264(self):
self.app.client_manager.compute.api_version = api_versions.APIVersion(
'2.64')
arglist = [
'--policy', 'soft-anti-affinity',
'affinity_group',
]
verifylist = [
('policy', 'soft-anti-affinity'),
('name', 'affinity_group'),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.server_groups_mock.create.assert_called_once_with(
name=parsed_args.name,
policy=parsed_args.policy,
)
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
class TestServerGroupDelete(TestServerGroup):