Update overcloud shutdown procedure

Change-Id: If7ff784fc416bbce6305b321b7cf1d31de1197e4
This commit is contained in:
Federico Ressi 2021-09-23 10:19:11 +02:00
parent 2fb36cb5af
commit 0cc3216a4e
3 changed files with 37 additions and 31 deletions

View File

@ -118,8 +118,7 @@ def power_off_node(node: IronicNodeType,
f"(power state = '{node.power_state}').")
client.node.set_power_state(node.uuid,
state='off',
soft=soft,
timeout=timeout)
soft=soft)
return wait_for_node_power_state(node=node.uuid,
power_state='power off',
client=client,
@ -139,8 +138,8 @@ def power_on_node(node: IronicNodeType,
LOG.info(f"Power on baremetal node '{node.uuid}' "
f"(power_state='{node.power_state}').")
client.node.set_power_state(node_id=node.uuid, state='on')
client.node.set_power_state(node_id=node.uuid,
state='on')
return wait_for_node_power_state(node=node.uuid,
power_state='power on',
client=client,

View File

@ -348,7 +348,8 @@ def activate_server(server: ServerType,
client.servers.reboot(server.id, reboot_type='HARD')
return wait_for_server_status(server=server.id, status='ACTIVE',
client=client, timeout=timeout,
client=client,
timeout=timeout,
sleep_time=sleep_time)

View File

@ -15,7 +15,6 @@ from __future__ import absolute_import
import io
import os
import typing
from oslo_log import log
import six
@ -69,37 +68,44 @@ def find_overcloud_node(**params):
return nova.find_server(client=client, **params)
def power_on_overcloud_node(server: typing.Union[nova.ServerType]):
def power_on_overcloud_node(server: nova.ServerType,
timeout: tobiko.Seconds = 120.,
sleep_time: tobiko.Seconds = 5.):
session = _undercloud.undercloud_keystone_session()
node_id = getattr(server, 'OS-EXT-SRV-ATTR:hypervisor_hostname',
None)
if node_id is not None:
node = getattr(server, 'OS-EXT-SRV-ATTR:hypervisor_hostname',
None)
if node is None:
client = nova.get_nova_client(session=session)
nova.activate_server(client=client,
server=server,
timeout=timeout,
sleep_time=sleep_time)
else:
client = ironic.get_ironic_client(session=session)
try:
ironic.power_on_node(client=client, node=node_id)
return
except ironic.WaitForNodePowerStateError:
LOG.exception(f"Failed powering on Ironic node: '{node_id}'")
client = nova.get_nova_client(session=session)
nova.activate_server(client=client, server=server)
ironic.power_on_node(client=client,
node=node,
timeout=timeout,
sleep_time=sleep_time)
def power_off_overcloud_node(server: typing.Union[nova.ServerType]) \
-> nova.NovaServer:
def power_off_overcloud_node(server: nova.ServerType,
timeout: tobiko.Seconds = None,
sleep_time: tobiko.Seconds = None):
session = _undercloud.undercloud_keystone_session()
node_id = getattr(server, 'OS-EXT-SRV-ATTR:hypervisor_hostname',
None)
if node_id is not None:
node = getattr(server, 'OS-EXT-SRV-ATTR:hypervisor_hostname',
None)
if node is None:
client = nova.get_nova_client(session=session)
nova.shutoff_server(client=client,
server=server,
timeout=timeout,
sleep_time=sleep_time)
else:
client = ironic.get_ironic_client(session=session)
try:
ironic.power_off_node(client=client, node=node_id)
return
except ironic.WaitForNodePowerStateError:
LOG.exception(f"Failed powering off Ironic node: '{node_id}'")
client = nova.get_nova_client(session=session)
nova.shutoff_server(client=client, server=server)
ironic.power_off_node(client=client,
node=node,
timeout=timeout,
sleep_time=sleep_time)
def overcloud_ssh_client(hostname=None, ip_version=None, network_name=None,