Merge "baremetal-introspection: allow fetching unprocessed data"
This commit is contained in:
@@ -86,17 +86,19 @@ class Proxy(proxy.Proxy):
|
|||||||
"""
|
"""
|
||||||
return self._get(_introspect.Introspection, introspection)
|
return self._get(_introspect.Introspection, introspection)
|
||||||
|
|
||||||
def get_introspection_data(self, introspection):
|
def get_introspection_data(self, introspection, processed=True):
|
||||||
"""Get introspection data.
|
"""Get introspection data.
|
||||||
|
|
||||||
:param introspection: The value can be the name or ID of an
|
:param introspection: The value can be the name or ID of an
|
||||||
introspection (matching bare metal node name or ID) or
|
introspection (matching bare metal node name or ID) or
|
||||||
an :class:`~.introspection.Introspection` instance.
|
an :class:`~.introspection.Introspection` instance.
|
||||||
|
:param processed: Whether to fetch the final processed data (the
|
||||||
|
default) or the raw unprocessed data as received from the ramdisk.
|
||||||
:returns: introspection data from the most recent successful run.
|
:returns: introspection data from the most recent successful run.
|
||||||
:rtype: dict
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
res = self._get_resource(_introspect.Introspection, introspection)
|
res = self._get_resource(_introspect.Introspection, introspection)
|
||||||
return res.get_data(self)
|
return res.get_data(self, processed=processed)
|
||||||
|
|
||||||
def abort_introspection(self, introspection, ignore_missing=True):
|
def abort_introspection(self, introspection, ignore_missing=True):
|
||||||
"""Abort an introspection.
|
"""Abort an introspection.
|
||||||
|
@@ -73,7 +73,7 @@ class Introspection(resource.Resource):
|
|||||||
.format(id=self.id))
|
.format(id=self.id))
|
||||||
exceptions.raise_from_response(response, error_message=msg)
|
exceptions.raise_from_response(response, error_message=msg)
|
||||||
|
|
||||||
def get_data(self, session):
|
def get_data(self, session, processed=True):
|
||||||
"""Get introspection data.
|
"""Get introspection data.
|
||||||
|
|
||||||
Note that the introspection data format is not stable and can vary
|
Note that the introspection data format is not stable and can vary
|
||||||
@@ -81,14 +81,20 @@ class Introspection(resource.Resource):
|
|||||||
|
|
||||||
:param session: The session to use for making this request.
|
:param session: The session to use for making this request.
|
||||||
:type session: :class:`~keystoneauth1.adapter.Adapter`
|
:type session: :class:`~keystoneauth1.adapter.Adapter`
|
||||||
|
:param processed: Whether to fetch the final processed data (the
|
||||||
|
default) or the raw unprocessed data as received from the ramdisk.
|
||||||
|
:type processed: bool
|
||||||
:returns: introspection data from the most recent successful run.
|
:returns: introspection data from the most recent successful run.
|
||||||
:rtype: dict
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
session = self._get_session(session)
|
session = self._get_session(session)
|
||||||
|
|
||||||
version = self._get_microversion_for(session, 'fetch')
|
version = (self._get_microversion_for(session, 'fetch')
|
||||||
|
if processed else '1.17')
|
||||||
request = self._prepare_request(requires_id=True)
|
request = self._prepare_request(requires_id=True)
|
||||||
request.url = utils.urljoin(request.url, 'data')
|
request.url = utils.urljoin(request.url, 'data')
|
||||||
|
if not processed:
|
||||||
|
request.url = utils.urljoin(request.url, 'unprocessed')
|
||||||
response = session.get(
|
response = session.get(
|
||||||
request.url, headers=request.headers, microversion=version)
|
request.url, headers=request.headers, microversion=version)
|
||||||
msg = ("Failed to fetch introspection data for node {id}"
|
msg = ("Failed to fetch introspection data for node {id}"
|
||||||
|
@@ -163,3 +163,12 @@ class TestGetData(base.TestCase):
|
|||||||
self.proxy, 'introspection/1234/data', 'GET',
|
self.proxy, 'introspection/1234/data', 'GET',
|
||||||
headers=mock.ANY, microversion=mock.ANY)
|
headers=mock.ANY, microversion=mock.ANY)
|
||||||
self.assertIs(data, mock_request.return_value.json.return_value)
|
self.assertIs(data, mock_request.return_value.json.return_value)
|
||||||
|
|
||||||
|
def test_get_unprocessed_data(self, mock_request):
|
||||||
|
mock_request.return_value.status_code = 200
|
||||||
|
data = self.proxy.get_introspection_data(self.introspection,
|
||||||
|
processed=False)
|
||||||
|
mock_request.assert_called_once_with(
|
||||||
|
self.proxy, 'introspection/1234/data/unprocessed', 'GET',
|
||||||
|
headers=mock.ANY, microversion='1.17')
|
||||||
|
self.assertIs(data, mock_request.return_value.json.return_value)
|
||||||
|
5
releasenotes/notes/unprocessed-2d75133911945869.yaml
Normal file
5
releasenotes/notes/unprocessed-2d75133911945869.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Supports fetching raw (unprocessed) introspection data from the bare metal
|
||||||
|
introspection service.
|
Reference in New Issue
Block a user