Add API tests for the reset_interfaces parameter
Depends-On: https://review.openstack.org/582951
Change-Id: Idd2c1a0104a0d0e349ccdc0599825b7492a94ba5
Story: #2002868
Task: #22829
diff --git a/ironic_tempest_plugin/services/baremetal/base.py b/ironic_tempest_plugin/services/baremetal/base.py
index e1c1d71..46c0a2f 100644
--- a/ironic_tempest_plugin/services/baremetal/base.py
+++ b/ironic_tempest_plugin/services/baremetal/base.py
@@ -85,7 +85,8 @@
return json.loads(object_str)
- def _get_uri(self, resource_name, uuid=None, permanent=False):
+ def _get_uri(self, resource_name, uuid=None, permanent=False,
+ params=None):
"""Get URI for a specific resource or object.
:param resource_name: The name of the REST resource, e.g., 'nodes'.
@@ -94,10 +95,15 @@
"""
prefix = self.uri_prefix if not permanent else ''
+ if params:
+ params = '?' + '&'.join('%s=%s' % tpl for tpl in params.items())
+ else:
+ params = ''
- return '{pref}/{res}{uuid}'.format(pref=prefix,
- res=resource_name,
- uuid='/%s' % uuid if uuid else '')
+ return '{pref}/{res}{uuid}{params}'.format(
+ pref=prefix, res=resource_name,
+ uuid='/%s' % uuid if uuid else '',
+ params=params)
def _make_patch(self, allowed_attributes, **kwargs):
"""Create a JSON patch according to RFC 6902.
@@ -229,16 +235,17 @@
self.expected_success(expected_status, resp.status)
return resp, body
- def _patch_request(self, resource, uuid, patch_object):
+ def _patch_request(self, resource, uuid, patch_object, params=None):
"""Update specified object with JSON-patch.
:param resource: The name of the REST resource, e.g., 'nodes'.
:param uuid: The unique identifier of an object in UUID format.
+ :param params: query parameters to pass.
:returns: A tuple with the server response and the serialized patched
object.
"""
- uri = self._get_uri(resource, uuid)
+ uri = self._get_uri(resource, uuid, params=params)
patch_body = json.dumps(patch_object)
resp, body = self.patch(uri, body=patch_body)
diff --git a/ironic_tempest_plugin/services/baremetal/v1/json/baremetal_client.py b/ironic_tempest_plugin/services/baremetal/v1/json/baremetal_client.py
index 25420bc..b31b433 100644
--- a/ironic_tempest_plugin/services/baremetal/v1/json/baremetal_client.py
+++ b/ironic_tempest_plugin/services/baremetal/v1/json/baremetal_client.py
@@ -410,6 +410,11 @@
:return: A tuple with the server response and the updated node.
"""
+ if 'reset_interfaces' in kwargs:
+ params = {'reset_interfaces': str(kwargs.pop('reset_interfaces'))}
+ else:
+ params = {}
+
node_attributes = ('properties/cpu_arch',
'properties/cpus',
'properties/local_gb',
@@ -423,7 +428,7 @@
if not patch:
patch = self._make_patch(node_attributes, **kwargs)
- return self._patch_request('nodes', uuid, patch)
+ return self._patch_request('nodes', uuid, patch, params=params)
@base.handle_errors
def update_chassis(self, uuid, **kwargs):