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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
|
.. _dev-quickstart:
=====================
Developer Quick-Start
=====================
This is a quick walkthrough to get you started developing code for Ironic.
This assumes you are already familiar with submitting code reviews to
an OpenStack project.
The gate currently runs the unit tests under both
Python 2.7 and Python 3.4. It is strongly encouraged to run the unit tests
locally under one, the other, or both prior to submitting a patch.
.. seealso::
http://docs.openstack.org/infra/manual/developers.html#development-workflow
Install prerequisites (for python 2.7):
- Ubuntu/Debian::
sudo apt-get install python-dev libssl-dev python-pip libmysqlclient-dev libxml2-dev libxslt-dev libpq-dev git git-review libffi-dev gettext ipmitool psmisc graphviz
- Fedora 21/RHEL7/CentOS7::
sudo yum install python-devel openssl-devel python-pip mysql-devel libxml2-devel libxslt-devel postgresql-devel git git-review libffi-devel gettext ipmitool psmisc graphviz gcc
- Fedora 22 or higher::
sudo dnf install python-devel openssl-devel python-pip mysql-devel libxml2-devel libxslt-devel postgresql-devel git git-review libffi-devel gettext ipmitool psmisc graphviz gcc
If using RHEL and yum reports "No package python-pip available" and "No
package git-review available", use the EPEL software repository.
Instructions can be found at `<http://fedoraproject.org/wiki/EPEL/FAQ#howtouse>`_.
- openSUSE/SLE 12::
sudo zypper install git git-review libffi-devel libmysqlclient-devel libopenssl-devel libxml2-devel libxslt-devel postgresql-devel python-devel python-nose python-pip gettext-runtime psmisc
Graphviz is only needed for generating the state machine diagram. To install it
on openSUSE or SLE 12, see
`<http://software.opensuse.org/download.html?project=graphics&package=graphviz-plugins>`_.
Using Python 3.4:
Follow the instructions above to install prerequisites and on:
- Fedora 21/RHEL7/CentOS7::
sudo yum install python3-devel
- Fedora 22 higher::
sudo dnf install python3-devel
Install these on all distros::
sudo easy_install nose
sudo pip install virtualenv setuptools-git flake8 tox testrepository
You may need to explicitly upgrade virtualenv if you've installed the one
from your OS distribution and it is too old (tox will complain). You can
upgrade it individually, if you need to::
sudo pip install -U virtualenv
Ironic source code should be pulled directly from git::
# from your home or source directory
cd ~
git clone https://git.openstack.org/openstack/ironic
cd ironic
Set up a local environment for development and testing should be done with tox::
# create a virtualenv for development
tox -evenv --notest
Activate the virtual environment whenever you want to work in it.
All further commands in this section should be run with the venv active::
source .tox/venv/bin/activate
All unit tests should be run using tox. To run Ironic's entire test suite::
# run all tests (unit under both py27 and py34, and pep8)
tox
To run the unit tests under py27 and also run the pep8 tests::
# run all tests (unit under py27 and pep8)
tox -epy27 -epep8
To run the unit tests under py34 and also run the pep8 tests::
# run all tests (unit under py34 and pep8)
tox -epy34 -epep8
To run a specific test, use a positional argument for the unit tests::
# run a specific test for Python 2.7
tox -epy27 -- test_conductor
You may pass options to the test programs using positional arguments::
# run all the Python 2.7 unit tests (in parallel!)
tox -epy27 -- --parallel
To run only the pep8/flake8 syntax and style checks::
tox -epep8
When you're done, deactivate the virtualenv::
deactivate
===============================
Exercising the Services Locally
===============================
If you would like to exercise the Ironic services in isolation within a local
virtual environment, you can do this without starting any other OpenStack
services. For example, this is useful for rapidly prototyping and debugging
interactions over the RPC channel, testing database migrations, and so forth.
Step 1: System Dependencies
---------------------------
There are two ways you may use to install the required system dependencies:
Manually, or by using the included Vagrant file.
Option 1: Manual Install
########################
#. Install a few system prerequisites::
# install rabbit message broker
# Ubuntu/Debian:
sudo apt-get install rabbitmq-server
# Fedora 21/RHEL7/CentOS7:
sudo yum install rabbitmq-server
sudo systemctl start rabbitmq-server.service
# Fedora 22 or higher:
sudo dnf install rabbitmq-server
sudo systemctl start rabbitmq-server.service
# openSUSE/SLE 12:
sudo zypper install rabbitmq-server
sudo systemctl start rabbitmq-server.service
# optionally, install mysql-server
# Ubuntu/Debian:
# sudo apt-get install mysql-server
# Fedora 21/RHEL7/CentOS7:
# sudo yum install mariadb
# sudo systemctl start mariadb.service
# Fedora 22 or higher:
# sudo dnf install mariadb
# sudo systemctl start mariadb.service
# openSUSE/SLE 12:
# sudo zypper install mariadb
# sudo systemctl start mysql.service
#. Clone the ``Ironic`` repository and install it within a virtualenv::
# activate the virtualenv
cd ~
git clone https://git.openstack.org/openstack/ironic
cd ironic
tox -evenv --notest
source .tox/venv/bin/activate
# install ironic within the virtualenv
python setup.py develop
#. Create a configuration file within the ironic source directory::
# copy sample config and modify it as necessary
cp etc/ironic/ironic.conf.sample etc/ironic/ironic.conf.local
# disable auth since we are not running keystone here
sed -i "s/#auth_strategy=keystone/auth_strategy=noauth/" etc/ironic/ironic.conf.local
# Use the 'fake_ipmitool' test driver
sed -i "s/#enabled_drivers=pxe_ipmitool/enabled_drivers=fake_ipmitool/" etc/ironic/ironic.conf.local
# set a fake host name [useful if you want to test multiple services on the same host]
sed -i "s/#host=.*/host=test-host/" etc/ironic/ironic.conf.local
# turn off the periodic sync_power_state task, to avoid getting NodeLocked exceptions
sed -i "s/#sync_power_state_interval=60/sync_power_state_interval=-1/" etc/ironic/ironic.conf.local
#. Initialize the ironic database (optional)::
# ironic defaults to storing data in ./ironic/ironic.sqlite
# If using MySQL, you need to create the initial database
mysql -u root -e "create schema ironic"
# and switch the DB connection from sqlite to something else, eg. mysql
sed -i "s/#connection=.*/connection=mysql:\/\/root@localhost\/ironic/" etc/ironic/ironic.conf.local
At this point, you can continue to Step 2.
Option 2: Vagrant, VirtualBox, and Ansible
##########################################
This option requires `virtualbox <https://www.virtualbox.org//>`_,
`vagrant <http://www.vagrantup.com/downloads>`_, and
`ansible <http://www.ansible.com/home>`_. You may install these using your
favorite package manager, or by downloading from the provided links.
Next, run vagrant::
vagrant up
This will create a VM available to your local system at `192.168.99.11`,
will install all the necessary service dependencies,
and configure some default users. It will also generate
`./etc/ironic/ironic.conf.local` preconfigured for local dev work.
We recommend you compare and familiarize yourself with the settings in
`./etc/ironic/ironic.conf.sample` so you can adjust it to meet your own needs.
Step 2: Start the API
---------------------
#. Activate the virtual environment created in the previous section to run
the API::
# switch to the ironic source (Not necessary if you followed Option 1)
cd ironic
# activate the virtualenv
source .tox/venv/bin/activate
# install ironic within the virtualenv
python setup.py develop
# This creates the database tables.
ironic-dbsync --config-file etc/ironic/ironic.conf.local create_schema
#. Start the API service in debug mode and watch its output::
# start the API service
ironic-api -v -d --config-file etc/ironic/ironic.conf.local
Step 3: Install the Client
--------------------------
#. Clone the ``python-ironicclient`` repository and install it within a
virtualenv::
# from your home or source directory
cd ~
git clone https://git.openstack.org/openstack/python-ironicclient
cd python-ironicclient
tox -evenv --notest
source .tox/venv/bin/activate
#. Export some ENV vars so the client will connect to the local services
that you'll start in the next section::
export OS_AUTH_TOKEN=fake-token
export IRONIC_URL=http://localhost:6385/
Step 4: Start the Conductor Service
-----------------------------------
Open one more window (or screen session), again activate the venv, and then
start the conductor service and watch its output::
# activate the virtualenv
cd ironic
source .tox/venv/bin/activate
# start the conductor service
ironic-conductor -v -d --config-file etc/ironic/ironic.conf.local
You should now be able to interact with Ironic via the python client (installed
in Step 3) and observe both services' debug outputs in the other two
windows. This is a good way to test new features or play with the functionality
without necessarily starting DevStack.
To get started, list the available commands and resources::
# get a list of available commands
ironic help
# get the list of drivers currently supported by the available conductor(s)
ironic driver-list
# get a list of nodes (should be empty at this point)
ironic node-list
Here is an example walkthrough of creating a node::
MAC="aa:bb:cc:dd:ee:ff" # replace with the MAC of a data port on your node
IPMI_ADDR="1.2.3.4" # replace with a real IP of the node BMC
IPMI_USER="admin" # replace with the BMC's user name
IPMI_PASS="pass" # replace with the BMC's password
# enroll the node with the "fake" deploy driver and the "ipmitool" power driver
# Note that driver info may be added at node creation time with "-i"
NODE=$(ironic node-create -d fake_ipmitool -i ipmi_address=$IPMI_ADDR -i ipmi_username=$IPMI_USER | grep ' uuid ' | awk '{print $4}')
# driver info may also be added or updated later on
ironic node-update $NODE add driver_info/ipmi_password=$IPMI_PASS
# add a network port
ironic port-create -n $NODE -a $MAC
# view the information for the node
ironic node-show $NODE
# request that the node's driver validate the supplied information
ironic node-validate $NODE
# you have now enrolled a node sufficiently to be able to control
# its power state from ironic!
ironic node-set-power-state $NODE on
If you make some code changes and want to test their effects, install
again with "python setup.py develop", stop the services with Ctrl-C,
and restart them.
================================
Deploying Ironic with DevStack
================================
DevStack may be configured to deploy Ironic, setup Nova to use the Ironic
driver and provide hardware resources (network, baremetal compute nodes)
using a combination of OpenVSwitch and libvirt. It is highly recommended
to deploy on an expendable virtual machine and not on your personal work
station. Deploying Ironic with DevStack requires a machine running Ubuntu
14.04 (or later) or Fedora 20 (or later).
.. seealso::
http://docs.openstack.org/developer/devstack/
Devstack will no longer create the user 'stack' with the desired
permissions, but does provide a script to perform the task::
git clone https://github.com/openstack-dev/devstack.git devstack
sudo ./devstack/tools/create-stack-user.sh
Switch to the stack user and clone DevStack::
sudo su stack
cd ~
git clone https://github.com/openstack-dev/devstack.git devstack
Create devstack/local.conf with minimal settings required to enable Ironic.
Note that Ironic under devstack can only support running *either* the PXE
or the agent driver, not both. The default is the PXE driver.::
cd devstack
cat >local.conf <<END
[[local|localrc]]
# Credentials
ADMIN_PASSWORD=password
DATABASE_PASSWORD=password
RABBIT_PASSWORD=password
SERVICE_PASSWORD=password
SERVICE_TOKEN=password
# Enable Ironic API and Ironic Conductor
enable_service ironic
enable_service ir-api
enable_service ir-cond
# Enable Neutron which is required by Ironic and disable nova-network.
disable_service n-net
disable_service n-novnc
enable_service q-svc
enable_service q-agt
enable_service q-dhcp
enable_service q-l3
enable_service q-meta
enable_service neutron
# Disable Horizon
disable_service horizon
# Disable Heat
disable_service heat h-api h-api-cfn h-api-cw h-eng
# Disable Cinder
disable_service cinder c-sch c-api c-vol
# Create 3 virtual machines to pose as Ironic's baremetal nodes.
IRONIC_VM_COUNT=3
IRONIC_VM_SSH_PORT=22
IRONIC_BAREMETAL_BASIC_OPS=True
# The parameters below represent the minimum possible values to create
# functional nodes.
IRONIC_VM_SPECS_RAM=1024
IRONIC_VM_SPECS_DISK=10
# Size of the ephemeral partition in GB. Use 0 for no ephemeral partition.
IRONIC_VM_EPHEMERAL_DISK=0
VIRT_DRIVER=ironic
# By default, DevStack creates a 10.0.0.0/24 network for instances.
# If this overlaps with the hosts network, you may adjust with the
# following.
NETWORK_GATEWAY=10.1.0.1
FIXED_RANGE=10.1.0.0/24
FIXED_NETWORK_SIZE=256
# Log all output to files
LOGFILE=$HOME/devstack.log
LOGDIR=$HOME/logs
IRONIC_VM_LOG_DIR=$HOME/ironic-bm-logs
END
If running with the agent driver (instead of PXE driver), add these additional
settings to local.conf::
cat >>local.conf <<END
# Agent driver requires swift with tempurls
# Enable swift services
enable_service s-proxy
enable_service s-object
enable_service s-container
enable_service s-account
# Enable tempurls and set credentials
SWIFT_HASH=password
SWIFT_TEMPURL_KEY=password
SWIFT_ENABLE_TEMPURLS=True
# Enable agent driver
IRONIC_ENABLED_DRIVERS=fake,agent_ssh,agent_ipmitool
IRONIC_DEPLOY_DRIVER=agent_ssh
# To build your own IPA ramdisk from source, set this to True
IRONIC_BUILD_DEPLOY_RAMDISK=False
END
Run stack.sh::
./stack.sh
Source credentials, create a key, and spawn an instance::
source ~/devstack/openrc
# query the image id of the default cirros image
image=$(nova image-list | egrep "$DEFAULT_IMAGE_NAME"'[^-]' | awk '{ print $2 }')
# create keypair
ssh-keygen
nova keypair-add default --pub-key ~/.ssh/id_rsa.pub
# spawn instance
nova boot --flavor baremetal --image $image --key-name default testing
.. note::
Because devstack create multiple networks, we need to pass an additional parameter
``--nic net-id`` to the nova boot command when using the admin account, for example::
net_id=$(neutron net-list | egrep "$PRIVATE_NETWORK_NAME"'[^-]' | awk '{ print $2 }')
nova boot --flavor baremetal --nic net-id=$net_id --image $image --key-name default testing
As the demo tenant, you should now see a Nova instance building::
nova list
+--------------------------------------+---------+--------+------------+-------------+----------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+---------+--------+------------+-------------+----------+
| a2c7f812-e386-4a22-b393-fe1802abd56e | testing | BUILD | spawning | NOSTATE | |
+--------------------------------------+---------+--------+------------+-------------+----------+
Nova will be interfacing with Ironic conductor to spawn the node. On the
Ironic side, you should see an Ironic node associated with this Nova instance.
It should be powered on and in a 'wait call-back' provisioning state::
# Note that 'ironic' calls must be made with admin credentials
. ~/devstack/openrc admin admin
ironic node-list
+--------------------------------------+--------------------------------------+-------------+--------------------+
| UUID | Instance UUID | Power State | Provisioning State |
+--------------------------------------+--------------------------------------+-------------+--------------------+
| 9e592cbe-e492-4e4f-bf8f-4c9e0ad1868f | None | power off | None |
| ec0c6384-cc3a-4edf-b7db-abde1998be96 | None | power off | None |
| 4099e31c-576c-48f8-b460-75e1b14e497f | a2c7f812-e386-4a22-b393-fe1802abd56e | power on | wait call-back |
+--------------------------------------+--------------------------------------+-------------+--------------------+
At this point, Ironic conductor has called to libvirt via SSH to power on a
virtual machine, which will PXE + TFTP boot from the conductor node and
progress through the Ironic provisioning workflow. One libvirt domain should
be active now::
sudo virsh list --all
Id Name State
----------------------------------------------------
2 baremetalbrbm_2 running
- baremetalbrbm_0 shut off
- baremetalbrbm_1 shut off
This provisioning process may take some time depending on the performance of
the host system, but Ironic should eventually show the node as having an
'active' provisioning state::
ironic node-list
+--------------------------------------+--------------------------------------+-------------+--------------------+
| UUID | Instance UUID | Power State | Provisioning State |
+--------------------------------------+--------------------------------------+-------------+--------------------+
| 9e592cbe-e492-4e4f-bf8f-4c9e0ad1868f | None | power off | None |
| ec0c6384-cc3a-4edf-b7db-abde1998be96 | None | power off | None |
| 4099e31c-576c-48f8-b460-75e1b14e497f | a2c7f812-e386-4a22-b393-fe1802abd56e | power on | active |
+--------------------------------------+--------------------------------------+-------------+--------------------+
This should also be reflected in the Nova instance state, which at this point
should be ACTIVE, Running and an associated private IP::
# Note that 'nova' calls must be made with the credentials of the demo tenant
. ~/devstack/openrc demo demo
nova list
+--------------------------------------+---------+--------+------------+-------------+------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+---------+--------+------------+-------------+------------------+
| a2c7f812-e386-4a22-b393-fe1802abd56e | testing | ACTIVE | - | Running | private=10.1.0.4 |
+--------------------------------------+---------+--------+------------+-------------+------------------+
The server should now be accessible via SSH::
ssh cirros@10.1.0.4
$
================================
Building developer documentation
================================
If you would like to build the documentation locally, eg. to test your
documentation changes before uploading them for review, run these
commands to build the documentation set::
# activate your development virtualenv
source .tox/venv/bin/activate
# build the docs
tox -edocs
Now use your browser to open the top-level index.html located at::
ironic/doc/build/html/index.html
|