Merge "ironic: Add trigger crash dump support to ironic driver"

This commit is contained in:
Jenkins 2017-01-31 19:10:18 +00:00 committed by Gerrit Code Review
commit 8c0b832dc4
7 changed files with 52 additions and 3 deletions

View File

@ -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

View File

@ -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)

View File

@ -1339,6 +1339,29 @@ class IronicDriverTestCase(test.NoDBTestCase):
self.driver.reboot(self.ctx, instance, None, 'HARD')
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')

View File

@ -165,6 +165,9 @@ class FakeNodeClient(object):
def vif_detach(self, node_uuid, port_id):
pass
def inject_nmi(self, node_uuid):
pass
class FakeClient(object):

View File

@ -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):

View File

@ -1117,6 +1117,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.

View File

@ -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.