diff options
author | Zuul <zuul@review.opendev.org> | 2022-08-03 17:59:13 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2022-08-03 17:59:13 +0000 |
commit | 31215bbae9d18f315cf3b50600508908b4cfec9d (patch) | |
tree | 1c3a837d8ed6caf2ee1fd90c52519c59560a0593 | |
parent | 77354cacbc2f105a90a8305c199dfdea8b7026b8 (diff) | |
parent | 2fefb077c83dba9ee583f3897d3365adbad59984 (diff) | |
download | ironic-31215bbae9d18f315cf3b50600508908b4cfec9d.tar.gz |
Merge "Fix prepare ramdisk for 'wait' states" into bugfix/19.0
-rw-r--r-- | ironic/drivers/modules/ilo/boot.py | 18 | ||||
-rw-r--r-- | ironic/drivers/modules/irmc/boot.py | 8 | ||||
-rw-r--r-- | ironic/drivers/modules/redfish/boot.py | 9 | ||||
-rw-r--r-- | ironic/drivers/utils.py | 21 |
4 files changed, 25 insertions, 31 deletions
diff --git a/ironic/drivers/modules/ilo/boot.py b/ironic/drivers/modules/ilo/boot.py index 60e0c3a25..6c9af4781 100644 --- a/ironic/drivers/modules/ilo/boot.py +++ b/ironic/drivers/modules/ilo/boot.py @@ -376,14 +376,7 @@ class IloVirtualMediaBoot(base.BootInterface): """ node = task.node - # NOTE(TheJulia): If this method is being called by something - # aside from deployment, clean and rescue, 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 not in (states.DEPLOYING, - states.CLEANING, - states.RESCUING, - states.INSPECTING): + if not driver_utils.need_prepare_ramdisk(node): return prepare_node_for_deploy(task) @@ -976,14 +969,7 @@ class IloUefiHttpsBoot(base.BootInterface): :raises: IloOperationError, if some operation on iLO failed. """ node = task.node - # NOTE(TheJulia): If this method is being called by something - # aside from deployment, clean and rescue, 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 not in (states.DEPLOYING, - states.CLEANING, - states.RESCUING, - states.INSPECTING): + if not driver_utils.need_prepare_ramdisk(node): return prepare_node_for_deploy(task) diff --git a/ironic/drivers/modules/irmc/boot.py b/ironic/drivers/modules/irmc/boot.py index 99e5bbc79..6e2c4a40d 100644 --- a/ironic/drivers/modules/irmc/boot.py +++ b/ironic/drivers/modules/irmc/boot.py @@ -971,13 +971,7 @@ class IRMCVirtualMediaBoot(base.BootInterface, IRMCVolumeBootMixIn): :raises: IRMCOperationError, if some operation on iRMC fails. """ - # NOTE(TheJulia): If this method is being called by something - # aside from deployment, clean and rescue, 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 not in (states.DEPLOYING, - states.CLEANING, - states.RESCUING): + if not driver_utils.need_prepare_ramdisk(task.node): return # NOTE(tiendc): Before deploying, we need to backup BIOS config diff --git a/ironic/drivers/modules/redfish/boot.py b/ironic/drivers/modules/redfish/boot.py index 75ddb51cb..b708ff725 100644 --- a/ironic/drivers/modules/redfish/boot.py +++ b/ironic/drivers/modules/redfish/boot.py @@ -488,14 +488,7 @@ class RedfishVirtualMediaBoot(base.BootInterface): operation failed on the node. """ node = task.node - # NOTE(TheJulia): If this method is being called by something - # aside from deployment, clean and rescue, 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 not in (states.DEPLOYING, - states.CLEANING, - states.RESCUING, - states.INSPECTING): + if not driver_utils.need_prepare_ramdisk(node): return d_info = _parse_driver_info(node) diff --git a/ironic/drivers/utils.py b/ironic/drivers/utils.py index 55b18542b..2ac50130c 100644 --- a/ironic/drivers/utils.py +++ b/ironic/drivers/utils.py @@ -23,6 +23,7 @@ from oslo_utils import timeutils from ironic.common import exception from ironic.common.i18n import _ +from ironic.common import states from ironic.common import swift from ironic.conductor import utils from ironic.drivers import base @@ -452,3 +453,23 @@ def get_agent_kernel_ramdisk(node, mode='deploy', deprecated_prefix=None): def get_agent_iso(node, mode='deploy', deprecated_prefix=None): """Get the agent ISO image.""" return get_field(node, f'{mode}_iso', deprecated_prefix) + + +def need_prepare_ramdisk(node): + """Check if node needs preparing ramdisk + + :param node: Node to check for + :returns: True if need to prepare ramdisk, otherwise False + """ + # NOTE(TheJulia): If current node provisioning is something aside from + # deployment, clean, rescue or inspect 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. + return node.provision_state in (states.DEPLOYING, + states.DEPLOYWAIT, + states.CLEANING, + states.CLEANWAIT, + states.RESCUING, + states.RESCUEWAIT, + states.INSPECTING, + states.INSPECTWAIT) |