baremetal: Add Node boot_device methods
Add Node.get_node_boot_device and Node. get_node_supported_boot_devices. These were both missing previously. Change-Id: Ie13ea2e50691298888fac37b6261d0a1d69fb8f1 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
397562bc42
commit
d1384a98f7
@ -17,7 +17,9 @@ Node Operations
|
|||||||
.. autoclass:: openstack.baremetal.v1._proxy.Proxy
|
.. autoclass:: openstack.baremetal.v1._proxy.Proxy
|
||||||
:noindex:
|
:noindex:
|
||||||
:members: nodes, create_node, find_node, get_node, update_node, patch_node, delete_node,
|
:members: nodes, create_node, find_node, get_node, update_node, patch_node, delete_node,
|
||||||
set_node_provision_state, set_node_boot_device, set_node_boot_mode,
|
set_node_provision_state, get_node_boot_device,
|
||||||
|
set_node_boot_device, get_node_supported_boot_devices,
|
||||||
|
set_node_boot_mode,
|
||||||
set_node_secure_boot, inject_nmi_to_node, wait_for_nodes_provision_state,
|
set_node_secure_boot, inject_nmi_to_node, wait_for_nodes_provision_state,
|
||||||
set_node_power_state, wait_for_node_power_state,
|
set_node_power_state, wait_for_node_power_state,
|
||||||
wait_for_node_reservation, validate_node, set_node_maintenance,
|
wait_for_node_reservation, validate_node, set_node_maintenance,
|
||||||
|
@ -411,6 +411,16 @@ class Proxy(proxy.Proxy):
|
|||||||
wait=wait, timeout=timeout,
|
wait=wait, timeout=timeout,
|
||||||
deploy_steps=deploy_steps)
|
deploy_steps=deploy_steps)
|
||||||
|
|
||||||
|
def get_node_boot_device(self, node):
|
||||||
|
"""Get node boot device
|
||||||
|
|
||||||
|
:param node: The value can be the name or ID of a node or a
|
||||||
|
:class:`~openstack.baremetal.v1.node.Node` instance.
|
||||||
|
:return: The node boot device
|
||||||
|
"""
|
||||||
|
res = self._get_resource(_node.Node, node)
|
||||||
|
return res.get_boot_device()
|
||||||
|
|
||||||
def set_node_boot_device(self, node, boot_device, persistent=False):
|
def set_node_boot_device(self, node, boot_device, persistent=False):
|
||||||
"""Set node boot device
|
"""Set node boot device
|
||||||
|
|
||||||
@ -424,6 +434,16 @@ class Proxy(proxy.Proxy):
|
|||||||
res = self._get_resource(_node.Node, node)
|
res = self._get_resource(_node.Node, node)
|
||||||
return res.set_boot_device(self, boot_device, persistent=persistent)
|
return res.set_boot_device(self, boot_device, persistent=persistent)
|
||||||
|
|
||||||
|
def get_node_supported_boot_devices(self, node):
|
||||||
|
"""Get supported boot devices for node
|
||||||
|
|
||||||
|
:param node: The value can be the name or ID of a node or a
|
||||||
|
:class:`~openstack.baremetal.v1.node.Node` instance.
|
||||||
|
:return: The node boot device
|
||||||
|
"""
|
||||||
|
res = self._get_resource(_node.Node, node)
|
||||||
|
return res.get_supported_boot_devices()
|
||||||
|
|
||||||
def set_node_boot_mode(self, node, target):
|
def set_node_boot_mode(self, node, target):
|
||||||
"""Make a request to change node's boot mode
|
"""Make a request to change node's boot mode
|
||||||
|
|
||||||
|
@ -862,6 +862,26 @@ class Node(_common.ListMixin, resource.Resource):
|
|||||||
.format(node=self.id))
|
.format(node=self.id))
|
||||||
exceptions.raise_from_response(response, error_message=msg)
|
exceptions.raise_from_response(response, error_message=msg)
|
||||||
|
|
||||||
|
def get_boot_device(self, session):
|
||||||
|
session = self._get_session(session)
|
||||||
|
version = self._get_microversion(session, action='fetch')
|
||||||
|
request = self._prepare_request(requires_id=True)
|
||||||
|
request.url = utils.urljoin(request.url, 'management', 'boot_device')
|
||||||
|
|
||||||
|
response = session.get(
|
||||||
|
request.url,
|
||||||
|
headers=request.headers,
|
||||||
|
microversion=version,
|
||||||
|
retriable_status_codes=_common.RETRIABLE_STATUS_CODES,
|
||||||
|
)
|
||||||
|
|
||||||
|
msg = "Failed to get boot device for node {node}".format(
|
||||||
|
node=self.id,
|
||||||
|
)
|
||||||
|
exceptions.raise_from_response(response, error_message=msg)
|
||||||
|
|
||||||
|
return response.json()
|
||||||
|
|
||||||
def set_boot_device(self, session, boot_device, persistent=False):
|
def set_boot_device(self, session, boot_device, persistent=False):
|
||||||
"""Set node boot device
|
"""Set node boot device
|
||||||
|
|
||||||
@ -886,6 +906,31 @@ class Node(_common.ListMixin, resource.Resource):
|
|||||||
.format(node=self.id))
|
.format(node=self.id))
|
||||||
exceptions.raise_from_response(response, error_message=msg)
|
exceptions.raise_from_response(response, error_message=msg)
|
||||||
|
|
||||||
|
def get_supported_boot_devices(self, session):
|
||||||
|
session = self._get_session(session)
|
||||||
|
version = self._get_microversion(session, action='fetch')
|
||||||
|
request = self._prepare_request(requires_id=True)
|
||||||
|
request.url = utils.urljoin(
|
||||||
|
request.url,
|
||||||
|
'management',
|
||||||
|
'boot_device',
|
||||||
|
'supported',
|
||||||
|
)
|
||||||
|
|
||||||
|
response = session.get(
|
||||||
|
request.url,
|
||||||
|
headers=request.headers,
|
||||||
|
microversion=version,
|
||||||
|
retriable_status_codes=_common.RETRIABLE_STATUS_CODES,
|
||||||
|
)
|
||||||
|
|
||||||
|
msg = "Failed to get supported boot devices for node {node}".format(
|
||||||
|
node=self.id,
|
||||||
|
)
|
||||||
|
exceptions.raise_from_response(response, error_message=msg)
|
||||||
|
|
||||||
|
return response.json()
|
||||||
|
|
||||||
def set_boot_mode(self, session, target):
|
def set_boot_mode(self, session, target):
|
||||||
"""Make a request to change node's boot mode
|
"""Make a request to change node's boot mode
|
||||||
|
|
||||||
|
@ -769,15 +769,24 @@ class TestNodeMaintenance(base.TestCase):
|
|||||||
|
|
||||||
@mock.patch.object(node.Node, 'fetch', lambda self, session: self)
|
@mock.patch.object(node.Node, 'fetch', lambda self, session: self)
|
||||||
@mock.patch.object(exceptions, 'raise_from_response', mock.Mock())
|
@mock.patch.object(exceptions, 'raise_from_response', mock.Mock())
|
||||||
class TestNodeSetBootDevice(base.TestCase):
|
class TestNodeBootDevice(base.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestNodeSetBootDevice, self).setUp()
|
super().setUp()
|
||||||
self.node = node.Node(**FAKE)
|
self.node = node.Node(**FAKE)
|
||||||
self.session = mock.Mock(spec=adapter.Adapter,
|
self.session = mock.Mock(spec=adapter.Adapter,
|
||||||
default_microversion='1.1')
|
default_microversion='1.1')
|
||||||
|
|
||||||
def test_node_set_boot_device(self):
|
def test_get_boot_device(self):
|
||||||
|
self.node.get_boot_device(self.session)
|
||||||
|
self.session.get.assert_called_once_with(
|
||||||
|
'nodes/%s/management/boot_device' % self.node.id,
|
||||||
|
headers=mock.ANY,
|
||||||
|
microversion=mock.ANY,
|
||||||
|
retriable_status_codes=_common.RETRIABLE_STATUS_CODES,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_set_boot_device(self):
|
||||||
self.node.set_boot_device(self.session, 'pxe', persistent=False)
|
self.node.set_boot_device(self.session, 'pxe', persistent=False)
|
||||||
self.session.put.assert_called_once_with(
|
self.session.put.assert_called_once_with(
|
||||||
'nodes/%s/management/boot_device' % self.node.id,
|
'nodes/%s/management/boot_device' % self.node.id,
|
||||||
@ -785,6 +794,15 @@ class TestNodeSetBootDevice(base.TestCase):
|
|||||||
headers=mock.ANY, microversion=mock.ANY,
|
headers=mock.ANY, microversion=mock.ANY,
|
||||||
retriable_status_codes=_common.RETRIABLE_STATUS_CODES)
|
retriable_status_codes=_common.RETRIABLE_STATUS_CODES)
|
||||||
|
|
||||||
|
def test_get_supported_boot_devices(self):
|
||||||
|
self.node.get_supported_boot_devices(self.session)
|
||||||
|
self.session.get.assert_called_once_with(
|
||||||
|
'nodes/%s/management/boot_device/supported' % self.node.id,
|
||||||
|
headers=mock.ANY,
|
||||||
|
microversion=mock.ANY,
|
||||||
|
retriable_status_codes=_common.RETRIABLE_STATUS_CODES,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@mock.patch.object(utils, 'pick_microversion', lambda session, v: v)
|
@mock.patch.object(utils, 'pick_microversion', lambda session, v: v)
|
||||||
@mock.patch.object(node.Node, 'fetch', lambda self, session: self)
|
@mock.patch.object(node.Node, 'fetch', lambda self, session: self)
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Adds ``get_boot_device`` and ``get_supported_boot_devices`` to
|
||||||
|
``openstack.baremetal.v1.Node``.
|
||||||
|
- |
|
||||||
|
Adds ``get_node_boot_device`` and ``get_node_supported_boot_devices``
|
||||||
|
to the baremetal Proxy.
|
Loading…
Reference in New Issue
Block a user