From d0917cd14b94ce13fd92237490efb5722761eda4 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Sun, 19 Nov 2017 18:34:24 -0500 Subject: [PATCH] Remove hard-coded policy choices for creating a server group The hard-coded choices for the server group policy make it impossible to create a server group with the soft-affinity or soft-anti-affinity policy rules which were added in compute API microversion 2.15. This removes the hard-coded choices so that the policy is restricted on the server side rather than the client side. Change-Id: Ib3dc39422ac1015872d56ae2fdeddf0f29613494 Closes-Bug: #1732938 --- openstackclient/compute/v2/server_group.py | 5 +++-- openstackclient/tests/unit/compute/v2/test_server_group.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/openstackclient/compute/v2/server_group.py b/openstackclient/compute/v2/server_group.py index c6e2161f60..c49a552f2c 100644 --- a/openstackclient/compute/v2/server_group.py +++ b/openstackclient/compute/v2/server_group.py @@ -55,11 +55,12 @@ class CreateServerGroup(command.ShowOne): parser.add_argument( '--policy', metavar='', - choices=['affinity', 'anti-affinity'], default='affinity', help=_("Add a policy to " "('affinity' or 'anti-affinity', " - "default to 'affinity')") + "defaults to 'affinity'). Specify --os-compute-api-version " + "2.15 or higher for the 'soft-affinity' or " + "'soft-anti-affinity' policy.") ) return parser diff --git a/openstackclient/tests/unit/compute/v2/test_server_group.py b/openstackclient/tests/unit/compute/v2/test_server_group.py index 088497da30..dc924e2421 100644 --- a/openstackclient/tests/unit/compute/v2/test_server_group.py +++ b/openstackclient/tests/unit/compute/v2/test_server_group.py @@ -63,11 +63,11 @@ class TestServerGroupCreate(TestServerGroup): def test_server_group_create(self): arglist = [ - '--policy', 'anti-affinity', + '--policy', 'soft-anti-affinity', 'affinity_group', ] verifylist = [ - ('policy', 'anti-affinity'), + ('policy', 'soft-anti-affinity'), ('name', 'affinity_group'), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist)