diff options
author | Dmitry Tantsur <dtantsur@protonmail.com> | 2019-12-05 12:47:55 +0100 |
---|---|---|
committer | Julia Kreger <juliaashleykreger@gmail.com> | 2019-12-13 00:34:46 +0000 |
commit | fd064a4f6b64e7e683bc9f578e359a7c0ac5f4dc (patch) | |
tree | 17d2b5b472a7398a2db02bdf061fdcd165d25295 /ironic/conductor | |
parent | 7a7e9689a3c6c85912f3756bab5fc0536ae59f53 (diff) | |
download | ironic-fd064a4f6b64e7e683bc9f578e359a7c0ac5f4dc.tar.gz |
Correct power state handling for managed in-band inspection
Do not try to configure networks when powered on, unless it's a node
with a SmartNIC, in which case do power on before configuring networks.
A new helper is created based on existing code in agent.py.
Change-Id: I3a8fab7a39b604ed17a690fa9c31b3cd1dbdc6a7
Story: #1528920
Task: #37753
Diffstat (limited to 'ironic/conductor')
-rw-r--r-- | ironic/conductor/utils.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ironic/conductor/utils.py b/ironic/conductor/utils.py index 2ba02f89e..5e213c5f4 100644 --- a/ironic/conductor/utils.py +++ b/ironic/conductor/utils.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +import contextlib import datetime import time @@ -831,6 +832,20 @@ def restore_power_state_if_needed(task, power_state_to_restore): node_power_action(task, power_state_to_restore) +@contextlib.contextmanager +def power_state_for_network_configuration(task): + """Handle the power state for a node reconfiguration. + + Powers the node on if and only if it has a Smart NIC port. Yields for + the actual reconfiguration, then restores the power state. + + :param task: A TaskManager object. + """ + previous = power_on_node_if_needed(task) + yield task + restore_power_state_if_needed(task, previous) + + def build_configdrive(node, configdrive): """Build a configdrive from provided meta_data, network_data and user_data. |