Support passing manage_boot argument in Python API

Excluded from CLI due to unclear use case.

Change-Id: Ifc102bf40c4b10c77147dea599636963186a97fa
Depends-On: Id3585bd32138a069dfcfc0ab04ee4f5f10f0a5ea
Story: #1528920
Task: #11756
This commit is contained in:
Dmitry Tantsur 2016-07-08 13:24:54 +02:00
parent 519475f94a
commit cdf16e6bcd
3 changed files with 22 additions and 4 deletions

View File

@ -84,11 +84,18 @@ class TestIntrospect(BaseTest):
def test(self, mock_req):
self.get_client().introspect(self.uuid)
mock_req.assert_called_once_with(
'post', '/introspection/%s' % self.uuid)
'post', '/introspection/%s' % self.uuid,
params={})
def test_invalid_input(self, mock_req):
self.assertRaises(TypeError, self.get_client().introspect, 42)
def test_manage_boot(self, mock_req):
self.get_client().introspect(self.uuid, manage_boot=False)
mock_req.assert_called_once_with(
'post', '/introspection/%s' % self.uuid,
params={'manage_boot': '0'})
@mock.patch.object(http.BaseClient, 'request')
class TestReprocess(BaseTest):

View File

@ -26,7 +26,7 @@ from ironic_inspector_client.common.i18n import _
DEFAULT_API_VERSION = (1, 0)
"""Server API version used by default."""
MAX_API_VERSION = (1, 8)
MAX_API_VERSION = (1, 13)
"""Maximum API version this client was designed to work with.
This does not mean that other versions won't work at all - the server might
@ -88,10 +88,13 @@ class ClientV1(http.BaseClient):
super(ClientV1, self).__init__(**kwargs)
self.rules = RulesAPI(self.request)
def introspect(self, uuid):
def introspect(self, uuid, manage_boot=None):
"""Start introspection for a node.
:param uuid: node UUID or name
:param manage_boot: whether to manage boot during introspection of
this node. If it is None (the default), then this argument is not
passed to API and the server default is used instead.
:raises: :py:class:`ironic_inspector_client.ClientError` on error
reported from a server
:raises: :py:class:`ironic_inspector_client.VersionNotSupported` if
@ -102,7 +105,11 @@ class ClientV1(http.BaseClient):
raise TypeError(
_("Expected string for uuid argument, got %r") % uuid)
self.request('post', '/introspection/%s' % uuid)
params = {}
if manage_boot is not None:
params['manage_boot'] = str(int(manage_boot))
self.request('post', '/introspection/%s' % uuid, params=params)
def reprocess(self, uuid):
"""Reprocess stored introspection data.

View File

@ -0,0 +1,4 @@
---
features:
- Adds Python library support for passing ``manage_boot``
to the introspection API.