Fix iRMC vmedia deploy failure due to already attached image
This patch fixes an agent_irmc bug which which doesn't detach virtual cd and fd at the end of deploy process. And also this patch adds detach virtual cd and fd calls before attach calls so that proper images can be attached. Closes-Bug: #1497799 Change-Id: Ifb975123de0f273952941e070e0a7cd9ef6925a0
This commit is contained in:
parent
cd32fa5421
commit
38da9d5cbc
@ -21,7 +21,6 @@ from oslo_utils import importutils
|
||||
from ironic.common import exception
|
||||
from ironic.common.i18n import _
|
||||
from ironic.drivers import base
|
||||
from ironic.drivers.modules import agent
|
||||
from ironic.drivers.modules import ipmitool
|
||||
from ironic.drivers.modules.irmc import deploy
|
||||
from ironic.drivers.modules.irmc import management
|
||||
@ -71,4 +70,4 @@ class IRMCVirtualMediaAgentDriver(base.BaseDriver):
|
||||
self.deploy = deploy.IRMCVirtualMediaAgentDeploy()
|
||||
self.console = ipmitool.IPMIShellinaboxConsole()
|
||||
self.management = management.IRMCManagement()
|
||||
self.vendor = agent.AgentVendorInterface()
|
||||
self.vendor = deploy.IRMCVirtualMediaAgentVendorInterface()
|
||||
|
@ -370,6 +370,9 @@ def setup_vmedia_for_boot(task, bootable_iso_filename, parameters=None):
|
||||
LOG.info(_LI("Setting up node %s to boot from virtual media"),
|
||||
task.node.uuid)
|
||||
|
||||
_detach_virtual_cd(task.node)
|
||||
_detach_virtual_fd(task.node)
|
||||
|
||||
if parameters:
|
||||
floppy_image_filename = _prepare_floppy_image(task, parameters)
|
||||
_attach_virtual_fd(task.node, floppy_image_filename)
|
||||
@ -909,3 +912,17 @@ class VendorPassthru(agent_base_vendor.BaseAgentVendor):
|
||||
self._configure_vmedia_boot(task, root_uuid)
|
||||
|
||||
self.reboot_and_finish_deploy(task)
|
||||
|
||||
|
||||
class IRMCVirtualMediaAgentVendorInterface(agent.AgentVendorInterface):
|
||||
"""Interface for vendor passthru related actions."""
|
||||
|
||||
def reboot_to_instance(self, task, **kwargs):
|
||||
node = task.node
|
||||
LOG.debug('Preparing to reboot to instance for node %s',
|
||||
node.uuid)
|
||||
|
||||
_cleanup_vmedia_boot(task)
|
||||
|
||||
super(IRMCVirtualMediaAgentVendorInterface,
|
||||
self).reboot_to_instance(task, **kwargs)
|
||||
|
@ -518,7 +518,13 @@ class IRMCDeployPrivateMethodsTestCase(db_base.DbTestCase):
|
||||
autospec=True)
|
||||
@mock.patch.object(irmc_deploy, '_prepare_floppy_image', spec_set=True,
|
||||
autospec=True)
|
||||
@mock.patch.object(irmc_deploy, '_detach_virtual_fd', spec_set=True,
|
||||
autospec=True)
|
||||
@mock.patch.object(irmc_deploy, '_detach_virtual_cd', spec_set=True,
|
||||
autospec=True)
|
||||
def test_setup_vmedia_for_boot_with_parameters(self,
|
||||
_detach_virtual_cd_mock,
|
||||
_detach_virtual_fd_mock,
|
||||
_prepare_floppy_image_mock,
|
||||
_attach_virtual_fd_mock,
|
||||
_attach_virtual_cd_mock):
|
||||
@ -529,6 +535,9 @@ class IRMCDeployPrivateMethodsTestCase(db_base.DbTestCase):
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
irmc_deploy.setup_vmedia_for_boot(task, iso_filename, parameters)
|
||||
|
||||
_detach_virtual_cd_mock.assert_called_once_with(task.node)
|
||||
_detach_virtual_fd_mock.assert_called_once_with(task.node)
|
||||
_prepare_floppy_image_mock.assert_called_once_with(task,
|
||||
parameters)
|
||||
_attach_virtual_fd_mock.assert_called_once_with(task.node,
|
||||
@ -537,13 +546,22 @@ class IRMCDeployPrivateMethodsTestCase(db_base.DbTestCase):
|
||||
iso_filename)
|
||||
|
||||
@mock.patch.object(irmc_deploy, '_attach_virtual_cd', autospec=True)
|
||||
@mock.patch.object(irmc_deploy, '_detach_virtual_fd', spec_set=True,
|
||||
autospec=True)
|
||||
@mock.patch.object(irmc_deploy, '_detach_virtual_cd', spec_set=True,
|
||||
autospec=True)
|
||||
def test_setup_vmedia_for_boot_without_parameters(
|
||||
self,
|
||||
_detach_virtual_cd_mock,
|
||||
_detach_virtual_fd_mock,
|
||||
_attach_virtual_cd_mock):
|
||||
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
irmc_deploy.setup_vmedia_for_boot(task, 'bootable_iso_filename')
|
||||
|
||||
_detach_virtual_cd_mock.assert_called_once_with(task.node)
|
||||
_detach_virtual_fd_mock.assert_called_once_with(task.node)
|
||||
_attach_virtual_cd_mock.assert_called_once_with(
|
||||
task.node,
|
||||
'bootable_iso_filename')
|
||||
@ -1492,3 +1510,27 @@ class VendorPassthruTestCase(db_base.DbTestCase):
|
||||
efi_system_part_uuid='efi-system-part-uuid')
|
||||
reboot_and_finish_deploy_mock.assert_called_once_with(
|
||||
mock.ANY, task)
|
||||
|
||||
|
||||
class IRMCVirtualMediaAgentVendorInterfaceTestCase(db_base.DbTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(IRMCVirtualMediaAgentVendorInterfaceTestCase, self).setUp()
|
||||
mgr_utils.mock_the_extension_manager(driver="agent_irmc")
|
||||
self.node = obj_utils.create_test_node(
|
||||
self.context, driver='agent_irmc', driver_info=INFO_DICT)
|
||||
|
||||
@mock.patch.object(agent.AgentVendorInterface, 'reboot_to_instance',
|
||||
spec_set=True, autospec=True)
|
||||
@mock.patch.object(irmc_deploy, '_cleanup_vmedia_boot', autospec=True)
|
||||
def test_reboot_to_instance(self,
|
||||
_cleanup_vmedia_boot_mock,
|
||||
agent_reboot_to_instance_mock):
|
||||
kwargs = {}
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=False) as task:
|
||||
task.driver.vendor.reboot_to_instance(task, **kwargs)
|
||||
|
||||
_cleanup_vmedia_boot_mock.assert_called_once_with(task)
|
||||
agent_reboot_to_instance_mock.assert_called_once_with(
|
||||
mock.ANY, task, **kwargs)
|
||||
|
@ -84,7 +84,8 @@ class IRMCVirtualMediaAgentTestCase(testtools.TestCase):
|
||||
irmc.ipmitool.IPMIShellinaboxConsole)
|
||||
self.assertIsInstance(driver.management,
|
||||
irmc.management.IRMCManagement)
|
||||
self.assertIsInstance(driver.vendor, irmc.agent.AgentVendorInterface)
|
||||
self.assertIsInstance(driver.vendor,
|
||||
irmc.deploy.IRMCVirtualMediaAgentVendorInterface)
|
||||
|
||||
@mock.patch.object(irmc.importutils, 'try_import')
|
||||
def test___init___try_import_exception(self, mock_try_import):
|
||||
|
Loading…
Reference in New Issue
Block a user