ironic: Add trigger crash dump support to ironic driver
This patch adds a new method "trigger_crash_dump" to Ironic virt driver. Ironic supports this feature since Ironic API version 1.29. It also requires python-ironicclient >= 1.11.0. Change-Id: I33812abbff919e5e477334c3bc46309491d14b6a Implements: blueprint inject-nmi-ironic Co-Authored-By: Tang Chen <chen.tang@easystack.cn> Co-Authored-By: xiexs <xiexs@cn.fujitsu.com> Depends-On: Iac112b82bab9cdf8a383879f9424cb368df741d6
This commit is contained in:
parent
c7b46c4778
commit
b1556c2009
@ -667,7 +667,7 @@ driver-impl-libvirt-lxc=missing
|
||||
driver-impl-libvirt-xen=missing
|
||||
driver-impl-vmware=missing
|
||||
driver-impl-hyperv=missing
|
||||
driver-impl-ironic=missing
|
||||
driver-impl-ironic=complete
|
||||
driver-impl-libvirt-vz-vm=missing
|
||||
driver-impl-libvirt-vz-ct=missing
|
||||
|
||||
|
@ -72,7 +72,7 @@ class IronicClientWrapperTestCase(test.NoDBTestCase):
|
||||
expected = {'session': 'session',
|
||||
'max_retries': CONF.ironic.api_max_retries,
|
||||
'retry_interval': CONF.ironic.api_retry_interval,
|
||||
'os_ironic_api_version': '1.28',
|
||||
'os_ironic_api_version': '1.29',
|
||||
'ironic_url': None}
|
||||
mock_ir_cli.assert_called_once_with(1, **expected)
|
||||
|
||||
|
@ -1339,6 +1339,29 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
||||
self.driver.reboot(self.ctx, instance, None, None)
|
||||
mock_sp.assert_called_once_with(node.uuid, 'reboot')
|
||||
|
||||
@mock.patch.object(ironic_driver.IronicDriver,
|
||||
'_validate_instance_and_node')
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'inject_nmi')
|
||||
def test_trigger_crash_dump(self, mock_nmi, fake_validate):
|
||||
node = ironic_utils.get_test_node()
|
||||
fake_validate.return_value = node
|
||||
instance = fake_instance.fake_instance_obj(self.ctx,
|
||||
node=node.uuid)
|
||||
self.driver.trigger_crash_dump(instance)
|
||||
mock_nmi.assert_called_once_with(node.uuid)
|
||||
|
||||
@mock.patch.object(ironic_driver.IronicDriver,
|
||||
'_validate_instance_and_node')
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'inject_nmi')
|
||||
def test_trigger_crash_dump_error(self, mock_nmi, fake_validate):
|
||||
node = ironic_utils.get_test_node()
|
||||
fake_validate.return_value = node
|
||||
mock_nmi.side_effect = ironic_exception.BadRequest()
|
||||
instance = fake_instance.fake_instance_obj(self.ctx,
|
||||
node=node.uuid)
|
||||
self.assertRaises(ironic_exception.BadRequest,
|
||||
self.driver.trigger_crash_dump, instance)
|
||||
|
||||
@mock.patch.object(loopingcall, 'FixedIntervalLoopingCall')
|
||||
@mock.patch.object(ironic_driver.IronicDriver,
|
||||
'_validate_instance_and_node')
|
||||
|
@ -142,6 +142,9 @@ class FakeNodeClient(object):
|
||||
def vif_detach(self, node_uuid, port_id):
|
||||
pass
|
||||
|
||||
def inject_nmi(self, node_uuid):
|
||||
pass
|
||||
|
||||
|
||||
class FakeClient(object):
|
||||
|
||||
|
@ -32,7 +32,7 @@ ironic = None
|
||||
IRONIC_GROUP = nova.conf.ironic.ironic_group
|
||||
|
||||
# The API version required by the Ironic driver
|
||||
IRONIC_API_VERSION = (1, 28)
|
||||
IRONIC_API_VERSION = (1, 29)
|
||||
|
||||
|
||||
class IronicClientWrapper(object):
|
||||
|
@ -1035,6 +1035,24 @@ class IronicDriver(virt_driver.ComputeDriver):
|
||||
LOG.info(_LI('Successfully powered on Ironic node %s'),
|
||||
node.uuid, instance=instance)
|
||||
|
||||
def trigger_crash_dump(self, instance):
|
||||
"""Trigger crash dump mechanism on the given instance.
|
||||
|
||||
Stalling instances can be triggered to dump the crash data. How the
|
||||
guest OS reacts in details, depends on the configuration of it.
|
||||
|
||||
:param instance: The instance where the crash dump should be triggered.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
LOG.debug('Trigger crash dump called for instance', instance=instance)
|
||||
node = self._validate_instance_and_node(instance)
|
||||
|
||||
self.ironicclient.call("node.inject_nmi", node.uuid)
|
||||
|
||||
LOG.info(_LI('Successfully triggered crash dump into Ironic node %s'),
|
||||
node.uuid, instance=instance)
|
||||
|
||||
def refresh_security_group_rules(self, security_group_id):
|
||||
"""Refresh security group rules from data store.
|
||||
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- Adds trigger crash dump support to ironic virt driver. This feature
|
||||
requires the Ironic service to support API version 1.29 or later.
|
||||
It also requires python-ironicclient >= 1.11.0.
|
Loading…
x
Reference in New Issue
Block a user