It is possible to create a set of resources using their descriptions in JSON or YAML format. It can be done in one of three ways:
Using OpenStackClient bare metal plugin CLI’s command openstack baremetal
create
:
$ openstack -h baremetal create
usage: openstack baremetal create [-h] <file> [<file> ...]
Create resources from files
positional arguments:
<file> File (.yaml or .json) containing descriptions of the
resources to create. Can be specified multiple times.
Using ironic CLI’s ironic create
command (deprecated, please use
openstack baremetal create
instead):
$ ironic help create
The "ironic" CLI is deprecated and will be removed in the S* release.
Please use the "openstack baremetal" CLI instead.
usage: ironic create <file> [<file> ...]
Create baremetal resources (chassis, nodes, port groups and ports). The
resources may be described in one or more JSON or YAML files. If any file
cannot be validated, no resources are created. An attempt is made to
create all the resources; those that could not be created are skipped
(with a corresponding error message).
Positional arguments:
<file> File (.yaml or .json) containing descriptions of the resources
to create. Can be specified multiple times.
Programmatically using the Python API:
ironicclient.v1.create_resources.
create_resources
(client, filenames)[source]Create resources using their JSON or YAML descriptions.
Parameters: |
|
---|---|
Raises: | ClientException if any operation during files processing/resource creation fails. |
The resources to be created can be described either in JSON or YAML. A file
ending with .json
is assumed to contain valid JSON, and a file ending with
.yaml
is assumed to contain valid YAML. Specifying a file with any other
extension leads to an error.
The resources that can be created are chassis, nodes, port groups and ports.
A chassis can contain nodes (and resources of nodes) definitions nested under
"nodes"
key. A node can contain port groups definitions nested under
"portgroups"
, and ports definitions under "ports"
keys. Ports can be
also nested under port groups in "ports"
key.
The schema used to validate the supplied data is the following:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Schema for ironic resources file",
"type": "object",
"properties": {
"chassis": {
"type": "array",
"items": {
"type": "object"
}
},
"nodes": {
"type": "array",
"items": {
"type": "object"
}
}
},
"additionalProperties": False
}
More detailed description of the creation process can be seen in the following sections.
Here is an example of the JSON file that can be passed to the create
command:
{
"chassis": [
{
"description": "chassis 3 in row 23",
"nodes": [
{
"name": "node-3",
"driver": "agent_ipmitool",
"portgroups": [
{
"name": "switch.cz7882.ports.1-2",
"ports": [
{
"address": "ff:00:00:00:00:00"
},
{
"address": "ff:00:00:00:00:01"
}
]
}
],
"ports": [
{
"address": "00:00:00:00:00:02"
},
{
"address": "00:00:00:00:00:03"
}
]
},
{
"name": "node-4",
"driver": "agent_ipmitool",
"ports": [
{
"address": "00:00:00:00:00:04"
},
{
"address": "00:00:00:00:00:01"
}
]
}
]
}
],
"nodes": [
{
"name": "node-5",
"driver": "pxe_ipmitool",
"chassis_uuid": "74d93e6e-7384-4994-a614-fd7b399b0785",
"ports": [
{
"address": "00:00:00:00:00:00"
}
]
},
{
"name": "node-6",
"driver": "pxe_ipmitool"
}
]
}
"nodes"
key inside chassis, "portgroups"
key inside nodes, "ports"
key inside nodes or portgroups), the top-level
resource is created first, followed by the sub-resources. For example, if a
chassis contains a list of nodes, the chassis will be created first followed
by the creation of each node. The same is true for ports and port groups
described within nodes.Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.