summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi NATSUME <natsume.takashi@lab.ntt.co.jp>2019-03-04 07:07:00 +0900
committerMatt Riedemann <mriedem.os@gmail.com>2019-03-04 12:00:22 -0500
commitb2cd7e12ccb65e67be0a0b01243d6f19f95e70e8 (patch)
tree1c282694755250656c0e7f9b04f67138793cefa5
parenta306395d745a60de679a4d95983786dd104bcefc (diff)
downloadpython-novaclient-b2cd7e12ccb65e67be0a0b01243d6f19f95e70e8.tar.gz
Microversion 2.71 - show server group
Add support microversion 2.71 which adds server group information in the output of the following commands. * nova show * nova rebuild The 'nova update' command does not output its result when it is successful. So there is no change for the command. The patch for microversion 2.71 in the nova side is I4a2a584df56ece7beb8b12c0ce9b0e6b30237120. Change-Id: Id324486b5ef32615881085cd46772aa55c245ac6 Implements: blueprint show-server-group
-rw-r--r--novaclient/__init__.py2
-rw-r--r--novaclient/tests/unit/v2/fakes.py7
-rw-r--r--novaclient/tests/unit/v2/test_shell.py51
-rw-r--r--releasenotes/notes/microversion-v2_71-a87b4bb4205c46e2.yaml10
4 files changed, 67 insertions, 3 deletions
diff --git a/novaclient/__init__.py b/novaclient/__init__.py
index bb0e53d1..5dc881d0 100644
--- a/novaclient/__init__.py
+++ b/novaclient/__init__.py
@@ -25,4 +25,4 @@ API_MIN_VERSION = api_versions.APIVersion("2.1")
# when client supported the max version, and bumped sequentially, otherwise
# the client may break due to server side new version may include some
# backward incompatible change.
-API_MAX_VERSION = api_versions.APIVersion("2.70")
+API_MAX_VERSION = api_versions.APIVersion("2.71")
diff --git a/novaclient/tests/unit/v2/fakes.py b/novaclient/tests/unit/v2/fakes.py
index 0f1857ff..a32e2258 100644
--- a/novaclient/tests/unit/v2/fakes.py
+++ b/novaclient/tests/unit/v2/fakes.py
@@ -618,8 +618,11 @@ class FakeSessionClient(base_client.SessionClient):
return (202, {}, self.get_servers_9012()[2])
def get_servers_1234(self, **kw):
- r = {'server': self.get_servers_detail()[2]['servers'][0]}
- return (200, {}, r)
+ server = self.get_servers_detail()[2]['servers'][0]
+ if self.api_version >= api_versions.APIVersion('2.71'):
+ server.update(
+ {'server_groups': ['a67359fb-d397-4697-88f1-f55e3ee7c499']})
+ return (200, {}, {'server': server})
def get_servers_1235(self, **kw):
r = {'server': self.get_servers_detail()[2]['servers'][0]}
diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py
index 778c74ac..3589ec5c 100644
--- a/novaclient/tests/unit/v2/test_shell.py
+++ b/novaclient/tests/unit/v2/test_shell.py
@@ -2028,6 +2028,36 @@ class ShellTest(utils.TestCase):
}, pos=3)
self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=4)
+ def test_rebuild_with_server_groups_in_response(self):
+ out = self.run_command('rebuild sample-server %s' % FAKE_UUID_1,
+ api_version='2.71')[0]
+ self.assert_called('GET', '/servers?name=sample-server', pos=0)
+ self.assert_called('GET', '/servers/1234', pos=1)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_1, pos=2)
+ self.assert_called('POST', '/servers/1234/action',
+ {'rebuild': {'imageRef': FAKE_UUID_1,
+ 'description': None,
+ }
+ }, pos=3)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=4)
+ self.assertIn('server_groups', out)
+ self.assertIn('a67359fb-d397-4697-88f1-f55e3ee7c499', out)
+
+ def test_rebuild_without_server_groups_in_response(self):
+ out = self.run_command('rebuild sample-server %s' % FAKE_UUID_1,
+ api_version='2.70')[0]
+ self.assert_called('GET', '/servers?name=sample-server', pos=0)
+ self.assert_called('GET', '/servers/1234', pos=1)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_1, pos=2)
+ self.assert_called('POST', '/servers/1234/action',
+ {'rebuild': {'imageRef': FAKE_UUID_1,
+ 'description': None,
+ }
+ }, pos=3)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=4)
+ self.assertNotIn('server_groups', out)
+ self.assertNotIn('a67359fb-d397-4697-88f1-f55e3ee7c499', out)
+
def test_start(self):
self.run_command('start sample-server')
self.assert_called('POST', '/servers/1234/action', {'os-start': None})
@@ -2180,6 +2210,26 @@ class ShellTest(utils.TestCase):
output, _ = self.run_command('show help')
self.assert_called('GET', '/servers/9014', pos=-6)
+ def test_show_with_server_groups_in_response(self):
+ # Starting microversion 2.71, the 'server_groups' is included
+ # in the output (the response).
+ out = self.run_command('show 1234', api_version='2.71')[0]
+ self.assert_called('GET', '/servers?name=1234', pos=0)
+ self.assert_called('GET', '/servers?name=1234', pos=1)
+ self.assert_called('GET', '/servers/1234', pos=2)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=3)
+ self.assertIn('server_groups', out)
+ self.assertIn('a67359fb-d397-4697-88f1-f55e3ee7c499', out)
+
+ def test_show_without_server_groups_in_response(self):
+ out = self.run_command('show 1234', api_version='2.70')[0]
+ self.assert_called('GET', '/servers?name=1234', pos=0)
+ self.assert_called('GET', '/servers?name=1234', pos=1)
+ self.assert_called('GET', '/servers/1234', pos=2)
+ self.assert_called('GET', '/v2/images/%s' % FAKE_UUID_2, pos=3)
+ self.assertNotIn('server_groups', out)
+ self.assertNotIn('a67359fb-d397-4697-88f1-f55e3ee7c499', out)
+
@mock.patch('novaclient.v2.shell.utils.print_dict')
def test_print_server(self, mock_print_dict):
self.run_command('show 5678')
@@ -4081,6 +4131,7 @@ class ShellTest(utils.TestCase):
# skipped when forming the detailed lists for embedded
# flavor information.
70, # There are no version-wrapped shell method changes for this.
+ 71, # There are no version-wrapped shell method changes for this.
])
versions_supported = set(range(0,
novaclient.API_MAX_VERSION.ver_minor + 1))
diff --git a/releasenotes/notes/microversion-v2_71-a87b4bb4205c46e2.yaml b/releasenotes/notes/microversion-v2_71-a87b4bb4205c46e2.yaml
new file mode 100644
index 00000000..7a4bf960
--- /dev/null
+++ b/releasenotes/notes/microversion-v2_71-a87b4bb4205c46e2.yaml
@@ -0,0 +1,10 @@
+---
+features:
+ - |
+ Added support for `microversion 2.71`_ which outputs the `server_groups`
+ field in the following commands:
+
+ * ``nova show``
+ * ``nova rebuild``
+
+ .. _microversion 2.71: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id64