Deployment vmedia operations to run when cleaning

The virtual media operations in task.driver.boot.prepare_ramdisk()
should be performed while the provision state of the node is
in 'cleaning'.

Change-Id: I4f563586523ea6e4a5a630c5fe44f70fe473bdf8
Closes-Bug: #1570283
This commit is contained in:
Aparna 2016-04-18 11:06:31 +00:00
parent 6fdefdf6e3
commit b12d184b73
5 changed files with 48 additions and 14 deletions

View File

@ -295,10 +295,11 @@ class IloVirtualMediaBoot(base.BootInterface):
node = task.node
# NOTE(TheJulia): If this method is being called by something
# aside from a deployment, such as conductor takeover, we should
# treat this as a no-op and move on otherwise we would modify
# aside from deployment and clean, such as conductor takeover, we
# should treat this as a no-op and move on otherwise we would modify
# the state of the node due to virtual media operations.
if node.provision_state != states.DEPLOYING:
if (node.provision_state != states.DEPLOYING and
node.provision_state != states.CLEANING):
return
# Clear ilo_boot_iso if it's a glance image to force recreate

View File

@ -604,10 +604,11 @@ class IRMCVirtualMediaBoot(base.BootInterface):
"""
# NOTE(TheJulia): If this method is being called by something
# aside from a deployment, such as conductor takeover, we should
# treat this as a no-op and move on otherwise we would modify
# aside from deployment and clean, such as conductor takeover, we
# should treat this as a no-op and move on otherwise we would modify
# the state of the node due to virtual media operations.
if task.node.provision_state != states.DEPLOYING:
if (task.node.provision_state != states.DEPLOYING and
task.node.provision_state != states.CLEANING):
return
deploy_nic_mac = deploy_utils.get_single_nic_with_vif_port_id(task)

View File

@ -502,8 +502,8 @@ class IloVirtualMediaBootTestCase(db_base.DbTestCase):
@mock.patch.object(service_utils, 'is_glance_image', spec_set=True,
autospec=True)
def test_prepare_ramdisk_not_deploying(self, mock_is_image):
"""Ensure ramdisk build operations are blocked when not deploying"""
def test_prepare_ramdisk_not_deploying_not_cleaning(self, mock_is_image):
"""Ensure deploy ops are blocked when not deploying and not cleaning"""
for state in states.STABLE_STATES:
mock_is_image.reset_mock()
@ -534,6 +534,25 @@ class IloVirtualMediaBootTestCase(db_base.DbTestCase):
self.assertEqual('http://mybootiso',
self.node.instance_info['ilo_boot_iso'])
def test_prepare_ramdisk_glance_image_cleaning(self):
self.node.provision_state = states.CLEANING
self.node.save()
self._test_prepare_ramdisk(
ilo_boot_iso='swift:abcdef',
image_source='6b2f0c0c-79e8-4db6-842e-43c9764204af')
self.node.refresh()
self.assertNotIn('ilo_boot_iso', self.node.instance_info)
def test_prepare_ramdisk_not_a_glance_image_cleaning(self):
self.node.provision_state = states.CLEANING
self.node.save()
self._test_prepare_ramdisk(
ilo_boot_iso='http://mybootiso',
image_source='http://myimage')
self.node.refresh()
self.assertEqual('http://mybootiso',
self.node.instance_info['ilo_boot_iso'])
@mock.patch.object(manager_utils, 'node_set_boot_device', spec_set=True,
autospec=True)
@mock.patch.object(ilo_common, 'setup_vmedia_for_boot', spec_set=True,

View File

@ -900,14 +900,13 @@ class IRMCVirtualMediaBootTestCase(db_base.DbTestCase):
spec_set=True, autospec=True)
@mock.patch.object(deploy_utils, 'get_single_nic_with_vif_port_id',
spec_set=True, autospec=True)
def test_prepare_ramdisk(self,
get_single_nic_with_vif_port_id_mock,
_setup_deploy_iso_mock):
def _test_prepare_ramdisk(self,
get_single_nic_with_vif_port_id_mock,
_setup_deploy_iso_mock):
instance_info = self.node.instance_info
instance_info['irmc_boot_iso'] = 'glance://abcdef'
instance_info['image_source'] = '6b2f0c0c-79e8-4db6-842e-43c9764204af'
self.node.instance_info = instance_info
self.node.provision_state = states.DEPLOYING
self.node.save()
ramdisk_params = {'a': 'b'}
@ -924,10 +923,20 @@ class IRMCVirtualMediaBootTestCase(db_base.DbTestCase):
self.assertEqual('glance://abcdef',
self.node.instance_info['irmc_boot_iso'])
def test_prepare_ramdisk_glance_image_deploying(self):
self.node.provision_state = states.DEPLOYING
self.node.save()
self._test_prepare_ramdisk()
def test_prepare_ramdisk_glance_image_cleaning(self):
self.node.provision_state = states.CLEANING
self.node.save()
self._test_prepare_ramdisk()
@mock.patch.object(irmc_boot, '_setup_deploy_iso', spec_set=True,
autospec=True)
def test_prepare_ramdisk_not_deploying(self, mock_is_image):
"""Ensure ramdisk build operations are blocked when not deploying"""
def test_prepare_ramdisk_not_deploying_not_cleaning(self, mock_is_image):
"""Ensure deploy ops are blocked when not deploying and not cleaning"""
for state in states.STABLE_STATES:
mock_is_image.reset_mock()

View File

@ -0,0 +1,4 @@
---
fixes:
-Fixes the issue of not attaching virtual media during cleaning operation
for vmedia based drivers.