Using OpenStack Baremetal

Before working with the Bare Metal service, you’ll need to create a connection to your OpenStack cloud by following the Connect user guide. This will provide you with the conn variable used in the examples below.

The primary resource of the Bare Metal service is the node.

Below are a few usage examples. For a reference to all the available methods, see Baremetal API.

CRUD operations

List Nodes

A node is a bare metal machine.

def list_nodes(conn):
    print("List Nodes:")

    for node in conn.baremetal.nodes():
        print(node)

Full example: baremetal resource list

Provisioning operations

Provisioning actions are the main way to manipulate the nodes. See Bare Metal service states documentation for details.

Manage and inspect Node

Managing a node in the enroll provision state validates the management (IPMI, Redfish, etc) credentials and moves the node to the manageable state. Managing a node in the available state moves it to the manageable state. In this state additional actions, such as configuring RAID or inspecting, are available.

Inspecting a node detects its properties by either talking to its BMC or by booting a special ramdisk.

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)

Full example: baremetal provisioning

Provide Node

Providing a node in the manageable provision state makes it available for deployment.

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)

Full example: baremetal provisioning