summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGhanshyam Mann <gmann@ghanshyammann.com>2019-08-13 20:30:24 +0000
committerMatt Riedemann <mriedem.os@gmail.com>2019-08-20 13:08:16 +0000
commit0e873a2d5a69d559299da4c403a5c17cf8a70462 (patch)
treece93c3b52c704b8d909ca3b3729fef623b8dea7a
parente281368c9679b385ecfb05737e614a05a9bab291 (diff)
downloadpython-novaclient-0e873a2d5a69d559299da4c403a5c17cf8a70462.tar.gz
Microversion 2.75 - Multiple API cleanup changes
Add support microversion 2.75 which implement multiple API cleanup changes. 1. Making server representation always consistent among all APIs returning the complete server representation. - Test cases added. 2. Change the default return value of ``swap`` field from the empty string to 0 (integer) in flavor APIs. - Test cases added. Nova side path: https://review.opendev.org/#/c/666889/ Change-Id: Iec2cfc629dffd53178ef88a31fcd16a3f32e2e27 Partial-Implements: blueprint api-consistency-cleanup
-rw-r--r--novaclient/__init__.py2
-rw-r--r--novaclient/tests/functional/v2/test_flavor.py72
-rw-r--r--novaclient/tests/functional/v2/test_servers.py41
-rw-r--r--novaclient/tests/unit/v2/test_shell.py1
-rw-r--r--releasenotes/notes/microversion-v2_75-ea7fa3ba1396edea.yaml18
5 files changed, 133 insertions, 1 deletions
diff --git a/novaclient/__init__.py b/novaclient/__init__.py
index fb9a485e..fc031f18 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.74")
+API_MAX_VERSION = api_versions.APIVersion("2.75")
diff --git a/novaclient/tests/functional/v2/test_flavor.py b/novaclient/tests/functional/v2/test_flavor.py
new file mode 100644
index 00000000..1458f0b5
--- /dev/null
+++ b/novaclient/tests/functional/v2/test_flavor.py
@@ -0,0 +1,72 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from novaclient.tests.functional import base
+
+
+class TestFlavorNovaClientV274(base.TenantTestBase):
+ """Functional tests for flavors"""
+
+ COMPUTE_API_VERSION = "2.74"
+ # NOTE(gmann): Before microversion 2.75, default value of 'swap' field is
+ # returned as empty string.
+ SWAP_DEFAULT = ""
+
+ def _create_flavor(self, swap=None):
+ flv_name = self.name_generate()
+ cmd = 'flavor-create %s auto 512 1 1'
+ if swap:
+ cmd = cmd + (' --swap %s' % swap)
+ out = self.nova(cmd % flv_name)
+ self.addCleanup(self.nova, 'flavor-delete %s' % flv_name)
+ return out, flv_name
+
+ def test_create_flavor_with_no_swap(self):
+ out, _ = self._create_flavor()
+ self.assertEqual(
+ self.SWAP_DEFAULT,
+ self._get_column_value_from_single_row_table(out, "Swap"))
+
+ def test_update_flavor_with_no_swap(self):
+ _, flv_name = self._create_flavor()
+ out = self.nova('flavor-update %s new-description' % flv_name)
+ self.assertEqual(
+ self.SWAP_DEFAULT,
+ self._get_column_value_from_single_row_table(out, "Swap"))
+
+ def test_show_flavor_with_no_swap(self):
+ _, flv_name = self._create_flavor()
+ out = self.nova('flavor-show %s' % flv_name)
+ self.assertEqual(self.SWAP_DEFAULT,
+ self._get_value_from_the_table(out, "swap"))
+
+ def test_list_flavor_with_no_swap(self):
+ self._create_flavor()
+ out = self.nova('flavor-list')
+ self.assertEqual(
+ self.SWAP_DEFAULT,
+ self._get_column_value_from_single_row_table(out, "Swap"))
+
+ def test_create_flavor_with_swap(self):
+ out, _ = self._create_flavor(swap=10)
+ self.assertEqual(
+ '10',
+ self._get_column_value_from_single_row_table(out, "Swap"))
+
+
+class TestFlavorNovaClientV275(TestFlavorNovaClientV274):
+ """Functional tests for flavors"""
+
+ COMPUTE_API_VERSION = "2.75"
+ # NOTE(gmann): Since microversion 2.75, default value of 'swap' field is
+ # returned as 0.
+ SWAP_DEFAULT = '0'
diff --git a/novaclient/tests/functional/v2/test_servers.py b/novaclient/tests/functional/v2/test_servers.py
index 47fb9e06..030f0f27 100644
--- a/novaclient/tests/functional/v2/test_servers.py
+++ b/novaclient/tests/functional/v2/test_servers.py
@@ -343,3 +343,44 @@ class TestInterfaceAttach(base.ClientTestBase):
self.assertEqual(
self.network.id,
self._get_value_from_the_table(output, 'net_id'))
+
+
+class TestServeRebuildV274(base.ClientTestBase):
+
+ COMPUTE_API_VERSION = '2.74'
+ REBUILD_FIELDS = ["OS-DCF:diskConfig", "accessIPv4", "accessIPv6",
+ "adminPass", "created", "description",
+ "flavor", "hostId", "id", "image", "key_name",
+ "locked", "locked_reason", "metadata", "name",
+ "progress", "server_groups", "status", "tags",
+ "tenant_id", "trusted_image_certificates", "updated",
+ "user_data", "user_id"]
+
+ def test_rebuild(self):
+ server = self._create_server()
+ output = self.nova("rebuild %s %s" % (server.id, self.image.name))
+ for field in self.REBUILD_FIELDS:
+ self.assertIn(field, output)
+
+
+class TestServeRebuildV275(TestServeRebuildV274):
+
+ COMPUTE_API_VERSION = '2.75'
+ REBUILD_FIELDS_V275 = ['OS-EXT-AZ:availability_zone', 'config_drive',
+ 'OS-EXT-SRV-ATTR:host',
+ 'OS-EXT-SRV-ATTR:hypervisor_hostname',
+ 'OS-EXT-SRV-ATTR:instance_name',
+ 'OS-EXT-SRV-ATTR:hostname',
+ 'OS-EXT-SRV-ATTR:kernel_id',
+ 'OS-EXT-SRV-ATTR:launch_index',
+ 'OS-EXT-SRV-ATTR:ramdisk_id',
+ 'OS-EXT-SRV-ATTR:reservation_id',
+ 'OS-EXT-SRV-ATTR:root_device_name',
+ 'host_status',
+ 'OS-SRV-USG:launched_at',
+ 'OS-SRV-USG:terminated_at',
+ 'OS-EXT-STS:task_state', 'OS-EXT-STS:vm_state',
+ 'OS-EXT-STS:power_state', 'security_groups',
+ 'os-extended-volumes:volumes_attached']
+
+ REBUILD_FIELDS = TestServeRebuildV274.REBUILD_FIELDS + REBUILD_FIELDS_V275
diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py
index 801ac43c..cbadfdd5 100644
--- a/novaclient/tests/unit/v2/test_shell.py
+++ b/novaclient/tests/unit/v2/test_shell.py
@@ -4275,6 +4275,7 @@ class ShellTest(utils.TestCase):
71, # There are no version-wrapped shell method changes for this.
72, # There are no version-wrapped shell method changes for this.
74, # There are no version-wrapped shell method changes for this.
+ 75, # 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_75-ea7fa3ba1396edea.yaml b/releasenotes/notes/microversion-v2_75-ea7fa3ba1396edea.yaml
new file mode 100644
index 00000000..e1993f9d
--- /dev/null
+++ b/releasenotes/notes/microversion-v2_75-ea7fa3ba1396edea.yaml
@@ -0,0 +1,18 @@
+---
+features:
+ - |
+ Added support for `microversion 2.75`_. The following changes were made:
+
+ - Return all fields of ``server`` in ``nova rebuild`` command which are
+ returned in ``nova show``. Both command will return the same set of
+ fields of ``server`` representation.
+
+ - Default return value of ``swap`` field will be 0 (integer) in below
+ commands:
+
+ - ``nova flavor-list``
+ - ``nova flavor-show``
+ - ``nova flavor-create``
+ - ``nova flavor-update``
+
+ .. _microversion 2.75: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id67