Dmitry Tantsur 5e4420763a Add set_provision_state and wait_for_provision_state for baremetal Node
This change adds set_provision_state and wait_for_provision_state
to openstack.baremetal.v1.Node, as well as set_node_provision_state
to the bare metal Proxy. Also adds wait_for_nodes_provision_state,
which is similar to Node.wait_for_provision_state but handles several
nodes at the same time, which is important for bulk operations.

The cloud's node_set_provision_state was updated to use the new calls.
As a nice side effect, it now supports all provision states and actions
up to the Queens release, as well as does proper microversioning.

Some documentation was written for the bare metal proxy.

Change-Id: I22a76c3623f4dd2cca0b2103cbd8b853d5cebb71
2018-07-17 13:58:43 +02:00

36 lines
1.4 KiB
Python

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Operations with the provision state in the Bare Metal service.
"""
from __future__ import print_function
def manage_and_inspect_node(conn, uuid):
node = conn.baremetal.find_node(uuid)
print('Before:', node.provision_state)
conn.baremetal.set_node_provision_state(node, 'manage')
conn.baremetal.wait_for_nodes_provision_state([node], 'manageable')
conn.baremetal.set_node_provision_state(node, 'inspect')
res = conn.baremetal.wait_for_nodes_provision_state([node], 'manageable')
print('After:', res[0].provision_state)
def provide_node(conn, uuid):
node = conn.baremetal.find_node(uuid)
print('Before:', node.provision_state)
conn.baremetal.set_node_provision_state(node, 'provide')
res = conn.baremetal.wait_for_nodes_provision_state([node], 'available')
print('After:', res[0].provision_state)