File: create_command.rst

package info (click to toggle)
python-ironicclient 5.10.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,632 kB
  • sloc: python: 25,269; makefile: 22; sh: 8
file content (160 lines) | stat: -rw-r--r-- 5,817 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
===================================================
Creating the Bare Metal service resources from file
===================================================

It is possible to create a set of resources using their descriptions in JSON
or YAML format. It can be done in one of two ways:

1. 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.

2. Programmatically using the Python API:

   .. autofunction:: ironicclient.v1.create_resources.create_resources
      :noindex:

File containing Resource Descriptions
=====================================

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.

Examples
========

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": "ipmi",
                        "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"
                            }
                        ],
                        "driver_info": {
                            "ipmi_address": "192.168.1.23",
                            "ipmi_username": "BmcUsername",
                            "ipmi_password": "BmcPassword",
                        }
                    },
                    {
                        "name": "node-4",
                        "driver": "ipmi",
                        "ports": [
                            {
                                "address": "00:00:00:00:00:04"
                            },
                            {
                                "address": "00:00:00:00:00:01"
                            }
                        ]
                    }
                ]
            }
        ],
        "nodes": [
            {
                "name": "node-5",
                "driver": "ipmi",
                "chassis_uuid": "74d93e6e-7384-4994-a614-fd7b399b0785",
                "ports": [
                    {
                        "address": "00:00:00:00:00:00"
                    }
                ]
            },
            {
                "name": "node-6",
                "driver": "ipmi"
            }
        ]
    }

Creation Process
================

#. The client deserializes the files' contents and validates that the top-level
   dictionary in each of them contains only "chassis" and/or "nodes" keys,
   and their values are lists. The creation process is aborted if any failure
   is encountered in this stage. The rest of the validation is done by the
   ironic-api service.

#. Each resource is created via issuing a POST request (with the resource's
   dictionary representation in the body) to the ironic-api service. In the
   case of nested resources (``"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.

#. If a resource could not be created, it does not stop the entire process.
   Any sub-resources of the failed resource will not be created, but otherwise,
   the rest of the resources will be created if possible. Any failed resources
   will be mentioned in the response.