Failback on Nova APIs when Ironic one fails for powering on/off overcloud nodes
Change-Id: Id142abb8db1a0708e33d63c21f14ba2a05c184dd
This commit is contained in:
parent
d95374c4ed
commit
3f569d368e
@ -21,3 +21,5 @@ get_ironic_client = _client.get_ironic_client
|
|||||||
power_off_node = _node.power_off_node
|
power_off_node = _node.power_off_node
|
||||||
power_on_node = _node.power_on_node
|
power_on_node = _node.power_on_node
|
||||||
IronicNodeType = _node.IronicNodeType
|
IronicNodeType = _node.IronicNodeType
|
||||||
|
WaitForNodePowerStateError = _node.WaitForNodePowerStateError
|
||||||
|
WaitForNodePowerStateTimeout = _node.WaitForNodePowerStateTimeout
|
||||||
|
@ -73,12 +73,16 @@ def power_on_overcloud_node(server: typing.Union[nova.ServerType]):
|
|||||||
session = _undercloud.undercloud_keystone_session()
|
session = _undercloud.undercloud_keystone_session()
|
||||||
node_id = getattr(server, 'OS-EXT-SRV-ATTR:hypervisor_hostname',
|
node_id = getattr(server, 'OS-EXT-SRV-ATTR:hypervisor_hostname',
|
||||||
None)
|
None)
|
||||||
if node_id is None:
|
if node_id is not None:
|
||||||
|
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)
|
client = nova.get_nova_client(session=session)
|
||||||
nova.activate_server(client=client, server=server)
|
nova.activate_server(client=client, server=server)
|
||||||
else:
|
|
||||||
client = ironic.get_ironic_client(session=session)
|
|
||||||
ironic.power_on_node(client=client, node=node_id)
|
|
||||||
|
|
||||||
|
|
||||||
def power_off_overcloud_node(server: typing.Union[nova.ServerType]) \
|
def power_off_overcloud_node(server: typing.Union[nova.ServerType]) \
|
||||||
@ -86,12 +90,16 @@ def power_off_overcloud_node(server: typing.Union[nova.ServerType]) \
|
|||||||
session = _undercloud.undercloud_keystone_session()
|
session = _undercloud.undercloud_keystone_session()
|
||||||
node_id = getattr(server, 'OS-EXT-SRV-ATTR:hypervisor_hostname',
|
node_id = getattr(server, 'OS-EXT-SRV-ATTR:hypervisor_hostname',
|
||||||
None)
|
None)
|
||||||
if node_id is None:
|
if node_id is not None:
|
||||||
|
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)
|
client = nova.get_nova_client(session=session)
|
||||||
nova.shutoff_server(client=client, server=server)
|
nova.shutoff_server(client=client, server=server)
|
||||||
else:
|
|
||||||
client = ironic.get_ironic_client(session=session)
|
|
||||||
ironic.power_off_node(client=client, node=node_id)
|
|
||||||
|
|
||||||
|
|
||||||
def overcloud_ssh_client(hostname=None, ip_version=None, network_name=None,
|
def overcloud_ssh_client(hostname=None, ip_version=None, network_name=None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user