This removes all of the ironic code from the devstack tree, in favor of
the devstack plugin in Ironic's tree.
Depends-On: I659e3de5c64df798441798ff48ba5c9c0506585a
Depends-On: I2c52bc014f1b0dbc6b0ae22a4deb4132b4c28621
Change-Id: I5125fce295c79600781469c2f48bea80e7600081
... | ... |
@@ -174,7 +174,6 @@ Scripts |
174 | 174 |
* `lib/heat <lib/heat.html>`__ |
175 | 175 |
* `lib/horizon <lib/horizon.html>`__ |
176 | 176 |
* `lib/infra <lib/infra.html>`__ |
177 |
-* `lib/ironic <lib/ironic.html>`__ |
|
178 | 177 |
* `lib/keystone <lib/keystone.html>`__ |
179 | 178 |
* `lib/ldap <lib/ldap.html>`__ |
180 | 179 |
* `lib/neutron-legacy <lib/neutron-legacy.html>`__ |
... | ... |
@@ -189,7 +188,6 @@ Scripts |
189 | 189 |
* `clean.sh <clean.sh.html>`__ |
190 | 190 |
* `run\_tests.sh <run_tests.sh.html>`__ |
191 | 191 |
|
192 |
-* `extras.d/50-ironic.sh <extras.d/50-ironic.sh.html>`__ |
|
193 | 192 |
* `extras.d/60-ceph.sh <extras.d/60-ceph.sh.html>`__ |
194 | 193 |
* `extras.d/70-tuskar.sh <extras.d/70-tuskar.sh.html>`__ |
195 | 194 |
* `extras.d/80-tempest.sh <extras.d/80-tempest.sh.html>`__ |
... | ... |
@@ -30,6 +30,8 @@ The following are plugins that exist for official OpenStack projects. |
30 | 30 |
+------------------+---------------------------------------------+--------------------+ |
31 | 31 |
|gnocchi |git://git.openstack.org/openstack/gnocchi | metric | |
32 | 32 |
+------------------+---------------------------------------------+--------------------+ |
33 |
+|ironic |git://git.openstack.org/openstack/ironic | baremetal | |
|
34 |
++------------------+---------------------------------------------+--------------------+ |
|
33 | 35 |
|magnum |git://git.openstack.org/openstack/magnum | | |
34 | 36 |
+------------------+---------------------------------------------+--------------------+ |
35 | 37 |
|manila |git://git.openstack.org/openstack/manila | file shares | |
36 | 38 |
deleted file mode 100644 |
... | ... |
@@ -1,50 +0,0 @@ |
1 |
-# ironic.sh - Devstack extras script to install ironic |
|
2 |
- |
|
3 |
-# NOTE(jroll) this is used for the transition to a devstack plugin in |
|
4 |
-# the ironic tree. |
|
5 |
-IRONIC_USING_PLUGIN=$(trueorfalse False IRONIC_USING_PLUGIN) |
|
6 |
-if [[ "$IRONIC_USING_PLUGIN" == "True" ]] ; then |
|
7 |
- return 0 |
|
8 |
-fi |
|
9 |
- |
|
10 |
-if is_service_enabled ir-api ir-cond; then |
|
11 |
- if [[ "$1" == "source" ]]; then |
|
12 |
- # Initial source |
|
13 |
- source $TOP_DIR/lib/ironic |
|
14 |
- elif [[ "$1" == "stack" && "$2" == "install" ]]; then |
|
15 |
- echo_summary "Installing Ironic" |
|
16 |
- install_ironic |
|
17 |
- install_ironicclient |
|
18 |
- cleanup_ironic |
|
19 |
- elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then |
|
20 |
- echo_summary "Configuring Ironic" |
|
21 |
- configure_ironic |
|
22 |
- |
|
23 |
- if is_service_enabled key; then |
|
24 |
- create_ironic_accounts |
|
25 |
- fi |
|
26 |
- |
|
27 |
- elif [[ "$1" == "stack" && "$2" == "extra" ]]; then |
|
28 |
- # Initialize ironic |
|
29 |
- init_ironic |
|
30 |
- |
|
31 |
- # Start the ironic API and ironic taskmgr components |
|
32 |
- echo_summary "Starting Ironic" |
|
33 |
- start_ironic |
|
34 |
- |
|
35 |
- if [[ "$IRONIC_BAREMETAL_BASIC_OPS" = "True" ]]; then |
|
36 |
- prepare_baremetal_basic_ops |
|
37 |
- fi |
|
38 |
- fi |
|
39 |
- |
|
40 |
- if [[ "$1" == "unstack" ]]; then |
|
41 |
- stop_ironic |
|
42 |
- if [[ "$IRONIC_BAREMETAL_BASIC_OPS" = "True" ]]; then |
|
43 |
- cleanup_baremetal_basic_ops |
|
44 |
- fi |
|
45 |
- fi |
|
46 |
- |
|
47 |
- if [[ "$1" == "clean" ]]; then |
|
48 |
- cleanup_ironic |
|
49 |
- fi |
|
50 |
-fi |
51 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,12 +0,0 @@ |
1 |
-Listen %PUBLICPORT% |
|
2 |
- |
|
3 |
-<VirtualHost *:%PUBLICPORT%> |
|
4 |
- DocumentRoot "%HTTPROOT%" |
|
5 |
- <Directory "%HTTPROOT%"> |
|
6 |
- Options Indexes FollowSymLinks |
|
7 |
- AllowOverride None |
|
8 |
- Order allow,deny |
|
9 |
- Allow from all |
|
10 |
- Require all granted |
|
11 |
- </Directory> |
|
12 |
-</VirtualHost> |
13 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,19 +0,0 @@ |
1 |
-docker.io |
|
2 |
-ipmitool |
|
3 |
-iptables |
|
4 |
-ipxe |
|
5 |
-libguestfs0 |
|
6 |
-libvirt-bin |
|
7 |
-open-iscsi |
|
8 |
-openssh-client |
|
9 |
-openvswitch-datapath-dkms |
|
10 |
-openvswitch-switch |
|
11 |
-python-libguestfs |
|
12 |
-python-libvirt |
|
13 |
-qemu |
|
14 |
-qemu-kvm |
|
15 |
-qemu-utils |
|
16 |
-sgabios |
|
17 |
-syslinux |
|
18 |
-tftpd-hpa |
|
19 |
-xinetd |
... | ... |
@@ -954,6 +954,15 @@ function get_endpoint_url { |
954 | 954 |
-c URL -f value) |
955 | 955 |
} |
956 | 956 |
|
957 |
+# check if we are using ironic with hardware |
|
958 |
+# TODO(jroll) this is a kludge left behind when ripping ironic code |
|
959 |
+# out of tree, as it is used by nova and neutron. |
|
960 |
+# figure out a way to refactor nova/neutron code to eliminate this |
|
961 |
+function is_ironic_hardware { |
|
962 |
+ is_service_enabled ironic && [[ -n "${IRONIC_DEPLOY_DRIVER##*_ssh}" ]] && return 0 |
|
963 |
+ return 1 |
|
964 |
+} |
|
965 |
+ |
|
957 | 966 |
|
958 | 967 |
# Package Functions |
959 | 968 |
# ================= |
... | ... |
@@ -1764,7 +1773,7 @@ function run_phase { |
1764 | 1764 |
# white listed elements in tree. We want these to move out |
1765 | 1765 |
# over time as well, but they are in tree, so we need to |
1766 | 1766 |
# manage that. |
1767 |
- local exceptions="50-ironic.sh 60-ceph.sh 80-tempest.sh" |
|
1767 |
+ local exceptions="60-ceph.sh 80-tempest.sh" |
|
1768 | 1768 |
local extra |
1769 | 1769 |
extra=$(basename $extra_plugin_file_name) |
1770 | 1770 |
if [[ ! ( $exceptions =~ "$extra" ) ]]; then |
... | ... |
@@ -1952,7 +1961,6 @@ function is_service_enabled { |
1952 | 1952 |
[[ ${service} == n-cpu-* && ${ENABLED_SERVICES} =~ "n-cpu" ]] && enabled=0 |
1953 | 1953 |
[[ ${service} == "nova" && ${ENABLED_SERVICES} =~ "n-" ]] && enabled=0 |
1954 | 1954 |
[[ ${service} == "glance" && ${ENABLED_SERVICES} =~ "g-" ]] && enabled=0 |
1955 |
- [[ ${service} == "ironic" && ${ENABLED_SERVICES} =~ "ir-" ]] && enabled=0 |
|
1956 | 1955 |
[[ ${service} == "neutron" && ${ENABLED_SERVICES} =~ "q-" ]] && enabled=0 |
1957 | 1956 |
[[ ${service} == "trove" && ${ENABLED_SERVICES} =~ "tr-" ]] && enabled=0 |
1958 | 1957 |
[[ ${service} == "swift" && ${ENABLED_SERVICES} =~ "s-" ]] && enabled=0 |
1959 | 1958 |
deleted file mode 100644 |
... | ... |
@@ -1,874 +0,0 @@ |
1 |
-#!/bin/bash |
|
2 |
-# |
|
3 |
-# lib/ironic |
|
4 |
-# Functions to control the configuration and operation of the **Ironic** service |
|
5 |
- |
|
6 |
-# Dependencies: |
|
7 |
-# |
|
8 |
-# - ``functions`` file |
|
9 |
-# - ``DEST``, ``DATA_DIR``, ``STACK_USER`` must be defined |
|
10 |
-# - ``SERVICE_{TENANT_NAME|PASSWORD}`` must be defined |
|
11 |
-# - ``SERVICE_HOST`` |
|
12 |
-# - ``KEYSTONE_TOKEN_FORMAT`` must be defined |
|
13 |
- |
|
14 |
-# ``stack.sh`` calls the entry points in this order: |
|
15 |
-# |
|
16 |
-# - install_ironic |
|
17 |
-# - install_ironicclient |
|
18 |
-# - init_ironic |
|
19 |
-# - start_ironic |
|
20 |
-# - stop_ironic |
|
21 |
-# - cleanup_ironic |
|
22 |
- |
|
23 |
-# Save trace and pipefail settings |
|
24 |
-_XTRACE_IRONIC=$(set +o | grep xtrace) |
|
25 |
-_PIPEFAIL_IRONIC=$(set +o | grep pipefail) |
|
26 |
-set +o xtrace |
|
27 |
-set +o pipefail |
|
28 |
- |
|
29 |
-# NOTE(jroll) this is used for the transition to a devstack plugin in |
|
30 |
-# the ironic tree. |
|
31 |
-IRONIC_USING_PLUGIN=$(trueorfalse False IRONIC_USING_PLUGIN) |
|
32 |
-if [[ "$IRONIC_USING_PLUGIN" == "True" ]] ; then |
|
33 |
- return 0 |
|
34 |
-fi |
|
35 |
- |
|
36 |
-# Defaults |
|
37 |
-# -------- |
|
38 |
- |
|
39 |
-# Set up default directories |
|
40 |
-GITDIR["python-ironicclient"]=$DEST/python-ironicclient |
|
41 |
-GITDIR["ironic-lib"]=$DEST/ironic-lib |
|
42 |
- |
|
43 |
-IRONIC_DIR=$DEST/ironic |
|
44 |
-IRONIC_PYTHON_AGENT_DIR=$DEST/ironic-python-agent |
|
45 |
-IRONIC_DATA_DIR=$DATA_DIR/ironic |
|
46 |
-IRONIC_STATE_PATH=/var/lib/ironic |
|
47 |
-IRONIC_AUTH_CACHE_DIR=${IRONIC_AUTH_CACHE_DIR:-/var/cache/ironic} |
|
48 |
-IRONIC_CONF_DIR=${IRONIC_CONF_DIR:-/etc/ironic} |
|
49 |
-IRONIC_CONF_FILE=$IRONIC_CONF_DIR/ironic.conf |
|
50 |
-IRONIC_ROOTWRAP_CONF=$IRONIC_CONF_DIR/rootwrap.conf |
|
51 |
-IRONIC_POLICY_JSON=$IRONIC_CONF_DIR/policy.json |
|
52 |
- |
|
53 |
-# Deploy callback timeout can be changed from its default (1800), if required. |
|
54 |
-IRONIC_CALLBACK_TIMEOUT=${IRONIC_CALLBACK_TIMEOUT:-} |
|
55 |
- |
|
56 |
-# Deploy to hardware platform |
|
57 |
-IRONIC_HW_NODE_CPU=${IRONIC_HW_NODE_CPU:-1} |
|
58 |
-IRONIC_HW_NODE_RAM=${IRONIC_HW_NODE_RAM:-512} |
|
59 |
-IRONIC_HW_NODE_DISK=${IRONIC_HW_NODE_DISK:-10} |
|
60 |
-IRONIC_HW_EPHEMERAL_DISK=${IRONIC_HW_EPHEMERAL_DISK:-0} |
|
61 |
-# The file is composed of multiple lines, each line includes four field |
|
62 |
-# separated by white space: IPMI address, MAC address, IPMI username |
|
63 |
-# and IPMI password. |
|
64 |
-# |
|
65 |
-# 192.168.110.107 00:1e:67:57:50:4c root otc123 |
|
66 |
-IRONIC_IPMIINFO_FILE=${IRONIC_IPMIINFO_FILE:-$IRONIC_DATA_DIR/hardware_info} |
|
67 |
- |
|
68 |
-# Set up defaults for functional / integration testing |
|
69 |
-IRONIC_NODE_UUID=${IRONIC_NODE_UUID:-`uuidgen`} |
|
70 |
-IRONIC_SCRIPTS_DIR=${IRONIC_SCRIPTS_DIR:-$TOP_DIR/tools/ironic/scripts} |
|
71 |
-IRONIC_TEMPLATES_DIR=${IRONIC_TEMPLATES_DIR:-$TOP_DIR/tools/ironic/templates} |
|
72 |
-IRONIC_BAREMETAL_BASIC_OPS=$(trueorfalse False IRONIC_BAREMETAL_BASIC_OPS) |
|
73 |
-IRONIC_ENABLED_DRIVERS=${IRONIC_ENABLED_DRIVERS:-fake,pxe_ssh,pxe_ipmitool} |
|
74 |
-IRONIC_SSH_USERNAME=${IRONIC_SSH_USERNAME:-`whoami`} |
|
75 |
-IRONIC_SSH_TIMEOUT=${IRONIC_SSH_TIMEOUT:-15} |
|
76 |
-IRONIC_SSH_KEY_DIR=${IRONIC_SSH_KEY_DIR:-$IRONIC_DATA_DIR/ssh_keys} |
|
77 |
-IRONIC_SSH_KEY_FILENAME=${IRONIC_SSH_KEY_FILENAME:-ironic_key} |
|
78 |
-IRONIC_KEY_FILE=${IRONIC_KEY_FILE:-$IRONIC_SSH_KEY_DIR/$IRONIC_SSH_KEY_FILENAME} |
|
79 |
-IRONIC_SSH_VIRT_TYPE=${IRONIC_SSH_VIRT_TYPE:-virsh} |
|
80 |
-IRONIC_TFTPBOOT_DIR=${IRONIC_TFTPBOOT_DIR:-$IRONIC_DATA_DIR/tftpboot} |
|
81 |
-IRONIC_TFTPSERVER_IP=${IRONIC_TFTPSERVER_IP:-$HOST_IP} |
|
82 |
-IRONIC_VM_SSH_PORT=${IRONIC_VM_SSH_PORT:-22} |
|
83 |
-IRONIC_VM_SSH_ADDRESS=${IRONIC_VM_SSH_ADDRESS:-$HOST_IP} |
|
84 |
-IRONIC_VM_COUNT=${IRONIC_VM_COUNT:-1} |
|
85 |
-IRONIC_VM_SPECS_CPU=${IRONIC_VM_SPECS_CPU:-1} |
|
86 |
-IRONIC_VM_SPECS_RAM=${IRONIC_VM_SPECS_RAM:-512} |
|
87 |
-IRONIC_VM_SPECS_DISK=${IRONIC_VM_SPECS_DISK:-10} |
|
88 |
-IRONIC_VM_EPHEMERAL_DISK=${IRONIC_VM_EPHEMERAL_DISK:-0} |
|
89 |
-IRONIC_VM_EMULATOR=${IRONIC_VM_EMULATOR:-/usr/bin/qemu-system-x86_64} |
|
90 |
-IRONIC_VM_NETWORK_BRIDGE=${IRONIC_VM_NETWORK_BRIDGE:-brbm} |
|
91 |
-IRONIC_VM_NETWORK_RANGE=${IRONIC_VM_NETWORK_RANGE:-192.0.2.0/24} |
|
92 |
-IRONIC_VM_MACS_CSV_FILE=${IRONIC_VM_MACS_CSV_FILE:-$IRONIC_DATA_DIR/ironic_macs.csv} |
|
93 |
-IRONIC_AUTHORIZED_KEYS_FILE=${IRONIC_AUTHORIZED_KEYS_FILE:-$HOME/.ssh/authorized_keys} |
|
94 |
- |
|
95 |
-# By default, baremetal VMs will console output to file. |
|
96 |
-IRONIC_VM_LOG_CONSOLE=${IRONIC_VM_LOG_CONSOLE:-True} |
|
97 |
-IRONIC_VM_LOG_DIR=${IRONIC_VM_LOG_DIR:-$IRONIC_DATA_DIR/logs/} |
|
98 |
- |
|
99 |
-# Use DIB to create deploy ramdisk and kernel. |
|
100 |
-IRONIC_BUILD_DEPLOY_RAMDISK=$(trueorfalse True IRONIC_BUILD_DEPLOY_RAMDISK) |
|
101 |
-# If not use DIB, these files are used as deploy ramdisk/kernel. |
|
102 |
-# (The value must be an absolute path) |
|
103 |
-IRONIC_DEPLOY_RAMDISK=${IRONIC_DEPLOY_RAMDISK:-} |
|
104 |
-IRONIC_DEPLOY_KERNEL=${IRONIC_DEPLOY_KERNEL:-} |
|
105 |
-IRONIC_DEPLOY_ELEMENT=${IRONIC_DEPLOY_ELEMENT:-deploy-ironic} |
|
106 |
- |
|
107 |
-IRONIC_AGENT_KERNEL_URL=${IRONIC_AGENT_KERNEL_URL:-http://tarballs.openstack.org/ironic-python-agent/coreos/files/coreos_production_pxe.vmlinuz} |
|
108 |
-IRONIC_AGENT_RAMDISK_URL=${IRONIC_AGENT_RAMDISK_URL:-http://tarballs.openstack.org/ironic-python-agent/coreos/files/coreos_production_pxe_image-oem.cpio.gz} |
|
109 |
- |
|
110 |
-# Which deploy driver to use - valid choices right now |
|
111 |
-# are ``pxe_ssh``, ``pxe_ipmitool``, ``agent_ssh`` and ``agent_ipmitool``. |
|
112 |
-IRONIC_DEPLOY_DRIVER=${IRONIC_DEPLOY_DRIVER:-pxe_ssh} |
|
113 |
- |
|
114 |
-# TODO(agordeev): replace 'ubuntu' with host distro name getting |
|
115 |
-IRONIC_DEPLOY_FLAVOR=${IRONIC_DEPLOY_FLAVOR:-ubuntu $IRONIC_DEPLOY_ELEMENT} |
|
116 |
- |
|
117 |
-# Support entry points installation of console scripts |
|
118 |
-IRONIC_BIN_DIR=$(get_python_exec_prefix) |
|
119 |
- |
|
120 |
-# Ironic connection info. Note the port must be specified. |
|
121 |
-IRONIC_SERVICE_PROTOCOL=http |
|
122 |
-IRONIC_SERVICE_PORT=${IRONIC_SERVICE_PORT:-6385} |
|
123 |
-IRONIC_HOSTPORT=${IRONIC_HOSTPORT:-$SERVICE_HOST:$IRONIC_SERVICE_PORT} |
|
124 |
- |
|
125 |
-# Enable iPXE |
|
126 |
-IRONIC_IPXE_ENABLED=$(trueorfalse False IRONIC_IPXE_ENABLED) |
|
127 |
-IRONIC_HTTP_DIR=${IRONIC_HTTP_DIR:-$IRONIC_DATA_DIR/httpboot} |
|
128 |
-IRONIC_HTTP_SERVER=${IRONIC_HTTP_SERVER:-$HOST_IP} |
|
129 |
-IRONIC_HTTP_PORT=${IRONIC_HTTP_PORT:-8088} |
|
130 |
- |
|
131 |
-# NOTE(lucasagomes): This flag is used to differentiate the nodes that |
|
132 |
-# uses IPA as their deploy ramdisk from nodes that uses the agent_* drivers |
|
133 |
-# (which also uses IPA but depends on Swift Temp URLs to work). At present, |
|
134 |
-# all drivers that uses the iSCSI approach for their deployment supports |
|
135 |
-# using both, IPA or bash ramdisks for the deployment. In the future we |
|
136 |
-# want to remove the support for the bash ramdisk in favor of IPA, once |
|
137 |
-# we get there this flag can be removed, and all conditionals that uses |
|
138 |
-# it should just run by default. |
|
139 |
-IRONIC_DEPLOY_DRIVER_ISCSI_WITH_IPA=$(trueorfalse False IRONIC_DEPLOY_DRIVER_ISCSI_WITH_IPA) |
|
140 |
- |
|
141 |
-# get_pxe_boot_file() - Get the PXE/iPXE boot file path |
|
142 |
-function get_pxe_boot_file { |
|
143 |
- local relpath=syslinux/pxelinux.0 |
|
144 |
- if [[ "$IRONIC_IPXE_ENABLED" == "True" ]] ; then |
|
145 |
- relpath=ipxe/undionly.kpxe |
|
146 |
- fi |
|
147 |
- |
|
148 |
- local pxe_boot_file |
|
149 |
- if is_ubuntu; then |
|
150 |
- pxe_boot_file=/usr/lib/$relpath |
|
151 |
- elif is_fedora || is_suse; then |
|
152 |
- pxe_boot_file=/usr/share/$relpath |
|
153 |
- fi |
|
154 |
- |
|
155 |
- echo $pxe_boot_file |
|
156 |
-} |
|
157 |
- |
|
158 |
-# PXE boot image |
|
159 |
-IRONIC_PXE_BOOT_IMAGE=${IRONIC_PXE_BOOT_IMAGE:-$(get_pxe_boot_file)} |
|
160 |
- |
|
161 |
- |
|
162 |
-# Functions |
|
163 |
-# --------- |
|
164 |
- |
|
165 |
-# Test if any Ironic services are enabled |
|
166 |
-# is_ironic_enabled |
|
167 |
-function is_ironic_enabled { |
|
168 |
- [[ ,${ENABLED_SERVICES} =~ ,"ir-" ]] && return 0 |
|
169 |
- return 1 |
|
170 |
-} |
|
171 |
- |
|
172 |
-function is_ironic_hardware { |
|
173 |
- is_ironic_enabled && [[ -n "${IRONIC_DEPLOY_DRIVER##*_ssh}" ]] && return 0 |
|
174 |
- return 1 |
|
175 |
-} |
|
176 |
- |
|
177 |
-function is_deployed_by_agent { |
|
178 |
- [[ -z "${IRONIC_DEPLOY_DRIVER%%agent*}" ]] && return 0 |
|
179 |
- return 1 |
|
180 |
-} |
|
181 |
- |
|
182 |
-function is_deployed_with_ipa_ramdisk { |
|
183 |
- is_deployed_by_agent || [[ "$IRONIC_DEPLOY_DRIVER_ISCSI_WITH_IPA" == "True" ]] && return 0 |
|
184 |
- return 1 |
|
185 |
-} |
|
186 |
- |
|
187 |
-# install_ironic() - Collect source and prepare |
|
188 |
-function install_ironic { |
|
189 |
- # make sure all needed service were enabled |
|
190 |
- local req_services="key" |
|
191 |
- if [[ "$VIRT_DRIVER" == "ironic" ]]; then |
|
192 |
- req_services+=" nova glance neutron" |
|
193 |
- fi |
|
194 |
- for srv in $req_services; do |
|
195 |
- if ! is_service_enabled "$srv"; then |
|
196 |
- die $LINENO "$srv should be enabled for Ironic." |
|
197 |
- fi |
|
198 |
- done |
|
199 |
- |
|
200 |
- if use_library_from_git "ironic-lib"; then |
|
201 |
- git_clone_by_name "ironic-lib" |
|
202 |
- setup_dev_lib "ironic-lib" |
|
203 |
- fi |
|
204 |
- |
|
205 |
- git_clone $IRONIC_REPO $IRONIC_DIR $IRONIC_BRANCH |
|
206 |
- setup_develop $IRONIC_DIR |
|
207 |
- |
|
208 |
- if [[ "$IRONIC_IPXE_ENABLED" == "True" ]] ; then |
|
209 |
- install_apache_wsgi |
|
210 |
- fi |
|
211 |
-} |
|
212 |
- |
|
213 |
-# install_ironicclient() - Collect sources and prepare |
|
214 |
-function install_ironicclient { |
|
215 |
- if use_library_from_git "python-ironicclient"; then |
|
216 |
- git_clone_by_name "python-ironicclient" |
|
217 |
- setup_dev_lib "python-ironicclient" |
|
218 |
- sudo install -D -m 0644 -o $STACK_USER {${GITDIR["python-ironicclient"]}/tools/,/etc/bash_completion.d/}ironic.bash_completion |
|
219 |
- else |
|
220 |
- # nothing actually "requires" ironicclient, so force instally from pypi |
|
221 |
- pip_install_gr python-ironicclient |
|
222 |
- fi |
|
223 |
-} |
|
224 |
- |
|
225 |
-# _cleanup_ironic_apache_wsgi() - Remove wsgi files, disable and remove apache vhost file |
|
226 |
-function _cleanup_ironic_apache_wsgi { |
|
227 |
- sudo rm -rf $IRONIC_HTTP_DIR |
|
228 |
- disable_apache_site ironic |
|
229 |
- sudo rm -f $(apache_site_config_for ironic) |
|
230 |
- restart_apache_server |
|
231 |
-} |
|
232 |
- |
|
233 |
-# _config_ironic_apache_wsgi() - Set WSGI config files of Ironic |
|
234 |
-function _config_ironic_apache_wsgi { |
|
235 |
- local ironic_apache_conf |
|
236 |
- ironic_apache_conf=$(apache_site_config_for ironic) |
|
237 |
- sudo cp $FILES/apache-ironic.template $ironic_apache_conf |
|
238 |
- sudo sed -e " |
|
239 |
- s|%PUBLICPORT%|$IRONIC_HTTP_PORT|g; |
|
240 |
- s|%HTTPROOT%|$IRONIC_HTTP_DIR|g; |
|
241 |
- " -i $ironic_apache_conf |
|
242 |
- enable_apache_site ironic |
|
243 |
-} |
|
244 |
- |
|
245 |
-# cleanup_ironic() - Remove residual data files, anything left over from previous |
|
246 |
-# runs that would need to clean up. |
|
247 |
-function cleanup_ironic { |
|
248 |
- sudo rm -rf $IRONIC_AUTH_CACHE_DIR $IRONIC_CONF_DIR |
|
249 |
-} |
|
250 |
- |
|
251 |
-# configure_ironic_dirs() - Create all directories required by Ironic and |
|
252 |
-# associated services. |
|
253 |
-function configure_ironic_dirs { |
|
254 |
- sudo install -d -o $STACK_USER $IRONIC_CONF_DIR $STACK_USER $IRONIC_DATA_DIR \ |
|
255 |
- $IRONIC_STATE_PATH $IRONIC_TFTPBOOT_DIR $IRONIC_TFTPBOOT_DIR/pxelinux.cfg |
|
256 |
- sudo chown -R $STACK_USER:$LIBVIRT_GROUP $IRONIC_TFTPBOOT_DIR |
|
257 |
- |
|
258 |
- if [[ "$IRONIC_IPXE_ENABLED" == "True" ]] ; then |
|
259 |
- sudo install -d -o $STACK_USER -g $LIBVIRT_GROUP $IRONIC_HTTP_DIR |
|
260 |
- fi |
|
261 |
- |
|
262 |
- if [ ! -f $IRONIC_PXE_BOOT_IMAGE ]; then |
|
263 |
- die $LINENO "PXE boot file $IRONIC_PXE_BOOT_IMAGE not found." |
|
264 |
- fi |
|
265 |
- |
|
266 |
- # Copy PXE binary |
|
267 |
- if [[ "$IRONIC_IPXE_ENABLED" == "True" ]] ; then |
|
268 |
- cp $IRONIC_PXE_BOOT_IMAGE $IRONIC_TFTPBOOT_DIR |
|
269 |
- else |
|
270 |
- # Syslinux >= 5.00 pxelinux.0 binary is not "stand-alone" anymore, |
|
271 |
- # it depends on some c32 modules to work correctly. |
|
272 |
- # More info: http://www.syslinux.org/wiki/index.php/Library_modules |
|
273 |
- cp -aR $(dirname $IRONIC_PXE_BOOT_IMAGE)/*.{c32,0} $IRONIC_TFTPBOOT_DIR |
|
274 |
- fi |
|
275 |
-} |
|
276 |
- |
|
277 |
-# configure_ironic() - Set config files, create data dirs, etc |
|
278 |
-function configure_ironic { |
|
279 |
- configure_ironic_dirs |
|
280 |
- |
|
281 |
- # Copy over ironic configuration file and configure common parameters. |
|
282 |
- cp $IRONIC_DIR/etc/ironic/ironic.conf.sample $IRONIC_CONF_FILE |
|
283 |
- iniset $IRONIC_CONF_FILE DEFAULT debug True |
|
284 |
- inicomment $IRONIC_CONF_FILE DEFAULT log_file |
|
285 |
- iniset $IRONIC_CONF_FILE database connection `database_connection_url ironic` |
|
286 |
- iniset $IRONIC_CONF_FILE DEFAULT state_path $IRONIC_STATE_PATH |
|
287 |
- iniset $IRONIC_CONF_FILE DEFAULT use_syslog $SYSLOG |
|
288 |
- # Configure Ironic conductor, if it was enabled. |
|
289 |
- if is_service_enabled ir-cond; then |
|
290 |
- configure_ironic_conductor |
|
291 |
- fi |
|
292 |
- |
|
293 |
- # Configure Ironic API, if it was enabled. |
|
294 |
- if is_service_enabled ir-api; then |
|
295 |
- configure_ironic_api |
|
296 |
- fi |
|
297 |
- |
|
298 |
- # Format logging |
|
299 |
- if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then |
|
300 |
- setup_colorized_logging $IRONIC_CONF_FILE DEFAULT tenant user |
|
301 |
- fi |
|
302 |
- |
|
303 |
- if [[ "$IRONIC_IPXE_ENABLED" == "True" ]]; then |
|
304 |
- _config_ironic_apache_wsgi |
|
305 |
- fi |
|
306 |
-} |
|
307 |
- |
|
308 |
-# configure_ironic_api() - Is used by configure_ironic(). Performs |
|
309 |
-# API specific configuration. |
|
310 |
-function configure_ironic_api { |
|
311 |
- iniset $IRONIC_CONF_FILE DEFAULT auth_strategy keystone |
|
312 |
- iniset $IRONIC_CONF_FILE oslo_policy policy_file $IRONIC_POLICY_JSON |
|
313 |
- |
|
314 |
- # TODO(Yuki Nishiwaki): This is a temporary work-around until Ironic is fixed(bug#1422632). |
|
315 |
- # These codes need to be changed to use the function of configure_auth_token_middleware |
|
316 |
- # after Ironic conforms to the new auth plugin. |
|
317 |
- iniset $IRONIC_CONF_FILE keystone_authtoken identity_uri $KEYSTONE_AUTH_URI |
|
318 |
- iniset $IRONIC_CONF_FILE keystone_authtoken auth_uri $KEYSTONE_SERVICE_URI/v2.0 |
|
319 |
- iniset $IRONIC_CONF_FILE keystone_authtoken admin_user ironic |
|
320 |
- iniset $IRONIC_CONF_FILE keystone_authtoken admin_password $SERVICE_PASSWORD |
|
321 |
- iniset $IRONIC_CONF_FILE keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME |
|
322 |
- iniset $IRONIC_CONF_FILE keystone_authtoken cafile $SSL_BUNDLE_FILE |
|
323 |
- iniset $IRONIC_CONF_FILE keystone_authtoken signing_dir $IRONIC_AUTH_CACHE_DIR/api |
|
324 |
- |
|
325 |
- iniset_rpc_backend ironic $IRONIC_CONF_FILE |
|
326 |
- iniset $IRONIC_CONF_FILE api port $IRONIC_SERVICE_PORT |
|
327 |
- |
|
328 |
- cp -p $IRONIC_DIR/etc/ironic/policy.json $IRONIC_POLICY_JSON |
|
329 |
-} |
|
330 |
- |
|
331 |
-# configure_ironic_conductor() - Is used by configure_ironic(). |
|
332 |
-# Sets conductor specific settings. |
|
333 |
-function configure_ironic_conductor { |
|
334 |
- cp $IRONIC_DIR/etc/ironic/rootwrap.conf $IRONIC_ROOTWRAP_CONF |
|
335 |
- cp -r $IRONIC_DIR/etc/ironic/rootwrap.d $IRONIC_CONF_DIR |
|
336 |
- local ironic_rootwrap |
|
337 |
- ironic_rootwrap=$(get_rootwrap_location ironic) |
|
338 |
- local rootwrap_isudoer_cmd="$ironic_rootwrap $IRONIC_CONF_DIR/rootwrap.conf *" |
|
339 |
- |
|
340 |
- # Set up the rootwrap sudoers for ironic |
|
341 |
- local tempfile |
|
342 |
- tempfile=`mktemp` |
|
343 |
- echo "$STACK_USER ALL=(root) NOPASSWD: $rootwrap_isudoer_cmd" >$tempfile |
|
344 |
- chmod 0440 $tempfile |
|
345 |
- sudo chown root:root $tempfile |
|
346 |
- sudo mv $tempfile /etc/sudoers.d/ironic-rootwrap |
|
347 |
- |
|
348 |
- iniset $IRONIC_CONF_FILE DEFAULT rootwrap_config $IRONIC_ROOTWRAP_CONF |
|
349 |
- iniset $IRONIC_CONF_FILE DEFAULT enabled_drivers $IRONIC_ENABLED_DRIVERS |
|
350 |
- iniset $IRONIC_CONF_FILE conductor api_url $IRONIC_SERVICE_PROTOCOL://$HOST_IP:$IRONIC_SERVICE_PORT |
|
351 |
- if [[ -n "$IRONIC_CALLBACK_TIMEOUT" ]]; then |
|
352 |
- iniset $IRONIC_CONF_FILE conductor deploy_callback_timeout $IRONIC_CALLBACK_TIMEOUT |
|
353 |
- fi |
|
354 |
- iniset $IRONIC_CONF_FILE pxe tftp_server $IRONIC_TFTPSERVER_IP |
|
355 |
- iniset $IRONIC_CONF_FILE pxe tftp_root $IRONIC_TFTPBOOT_DIR |
|
356 |
- iniset $IRONIC_CONF_FILE pxe tftp_master_path $IRONIC_TFTPBOOT_DIR/master_images |
|
357 |
- |
|
358 |
- local pxe_params="" |
|
359 |
- if [[ "$IRONIC_VM_LOG_CONSOLE" == "True" ]] ; then |
|
360 |
- pxe_params+="nofb nomodeset vga=normal console=ttyS0" |
|
361 |
- if is_deployed_with_ipa_ramdisk; then |
|
362 |
- pxe_params+=" systemd.journald.forward_to_console=yes" |
|
363 |
- fi |
|
364 |
- fi |
|
365 |
- # When booting with less than 1GB, we need to switch from default tmpfs |
|
366 |
- # to ramfs for ramdisks to decompress successfully. |
|
367 |
- if (is_ironic_hardware && [[ "$IRONIC_HW_NODE_RAM" -lt 1024 ]]) || |
|
368 |
- (! is_ironic_hardware && [[ "$IRONIC_VM_SPECS_RAM" -lt 1024 ]]); then |
|
369 |
- pxe_params+=" rootfstype=ramfs" |
|
370 |
- fi |
|
371 |
- if [[ -n "$pxe_params" ]]; then |
|
372 |
- iniset $IRONIC_CONF_FILE pxe pxe_append_params "$pxe_params" |
|
373 |
- fi |
|
374 |
- |
|
375 |
- # Set these options for scenarios in which the agent fetches the image |
|
376 |
- # directly from glance, and don't set them where the image is pushed |
|
377 |
- # over iSCSI. |
|
378 |
- if is_deployed_by_agent; then |
|
379 |
- if [[ "$SWIFT_ENABLE_TEMPURLS" == "True" ]] ; then |
|
380 |
- iniset $IRONIC_CONF_FILE glance swift_temp_url_key $SWIFT_TEMPURL_KEY |
|
381 |
- else |
|
382 |
- die $LINENO "SWIFT_ENABLE_TEMPURLS must be True to use agent_ssh driver in Ironic." |
|
383 |
- fi |
|
384 |
- iniset $IRONIC_CONF_FILE glance swift_endpoint_url http://${HOST_IP}:${SWIFT_DEFAULT_BIND_PORT:-8080} |
|
385 |
- iniset $IRONIC_CONF_FILE glance swift_api_version v1 |
|
386 |
- local tenant_id |
|
387 |
- tenant_id=$(get_or_create_project $SERVICE_TENANT_NAME default) |
|
388 |
- iniset $IRONIC_CONF_FILE glance swift_account AUTH_${tenant_id} |
|
389 |
- iniset $IRONIC_CONF_FILE glance swift_container glance |
|
390 |
- iniset $IRONIC_CONF_FILE glance swift_temp_url_duration 3600 |
|
391 |
- iniset $IRONIC_CONF_FILE agent heartbeat_timeout 30 |
|
392 |
- fi |
|
393 |
- |
|
394 |
- # FIXME: this really needs to be tested in the gate. |
|
395 |
- # For now, any test using the agent ramdisk should skip cleaning |
|
396 |
- # because it is too slow to run in the gate. |
|
397 |
- iniset $IRONIC_CONF_FILE agent agent_erase_devices_priority 0 |
|
398 |
- |
|
399 |
- if [[ "$IRONIC_IPXE_ENABLED" == "True" ]] ; then |
|
400 |
- local pxebin |
|
401 |
- pxebin=`basename $IRONIC_PXE_BOOT_IMAGE` |
|
402 |
- iniset $IRONIC_CONF_FILE pxe ipxe_enabled True |
|
403 |
- iniset $IRONIC_CONF_FILE pxe pxe_config_template '\$pybasedir/drivers/modules/ipxe_config.template' |
|
404 |
- iniset $IRONIC_CONF_FILE pxe pxe_bootfile_name $pxebin |
|
405 |
- iniset $IRONIC_CONF_FILE pxe http_root $IRONIC_HTTP_DIR |
|
406 |
- iniset $IRONIC_CONF_FILE pxe http_url "http://$IRONIC_HTTP_SERVER:$IRONIC_HTTP_PORT" |
|
407 |
- fi |
|
408 |
-} |
|
409 |
- |
|
410 |
-# create_ironic_cache_dir() - Part of the init_ironic() process |
|
411 |
-function create_ironic_cache_dir { |
|
412 |
- # Create cache dir |
|
413 |
- sudo mkdir -p $IRONIC_AUTH_CACHE_DIR/api |
|
414 |
- sudo chown $STACK_USER $IRONIC_AUTH_CACHE_DIR/api |
|
415 |
- rm -f $IRONIC_AUTH_CACHE_DIR/api/* |
|
416 |
- sudo mkdir -p $IRONIC_AUTH_CACHE_DIR/registry |
|
417 |
- sudo chown $STACK_USER $IRONIC_AUTH_CACHE_DIR/registry |
|
418 |
- rm -f $IRONIC_AUTH_CACHE_DIR/registry/* |
|
419 |
-} |
|
420 |
- |
|
421 |
-# create_ironic_accounts() - Set up common required ironic accounts |
|
422 |
- |
|
423 |
-# Tenant User Roles |
|
424 |
-# ------------------------------------------------------------------ |
|
425 |
-# service ironic admin # if enabled |
|
426 |
-function create_ironic_accounts { |
|
427 |
- |
|
428 |
- # Ironic |
|
429 |
- if [[ "$ENABLED_SERVICES" =~ "ir-api" ]]; then |
|
430 |
- # Get ironic user if exists |
|
431 |
- |
|
432 |
- # NOTE(Shrews): This user MUST have admin level privileges! |
|
433 |
- create_service_user "ironic" "admin" |
|
434 |
- |
|
435 |
- if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then |
|
436 |
- |
|
437 |
- get_or_create_service "ironic" "baremetal" "Ironic baremetal provisioning service" |
|
438 |
- get_or_create_endpoint "baremetal" \ |
|
439 |
- "$REGION_NAME" \ |
|
440 |
- "$IRONIC_SERVICE_PROTOCOL://$IRONIC_HOSTPORT" \ |
|
441 |
- "$IRONIC_SERVICE_PROTOCOL://$IRONIC_HOSTPORT" \ |
|
442 |
- "$IRONIC_SERVICE_PROTOCOL://$IRONIC_HOSTPORT" |
|
443 |
- fi |
|
444 |
- fi |
|
445 |
-} |
|
446 |
- |
|
447 |
- |
|
448 |
-# init_ironic() - Initialize databases, etc. |
|
449 |
-function init_ironic { |
|
450 |
- # Save private network as cleaning network |
|
451 |
- local cleaning_network_uuid |
|
452 |
- cleaning_network_uuid=$(neutron net-list | grep private | get_field 1) |
|
453 |
- iniset $IRONIC_CONF_FILE neutron cleaning_network_uuid ${cleaning_network_uuid} |
|
454 |
- |
|
455 |
- # (Re)create ironic database |
|
456 |
- recreate_database ironic |
|
457 |
- |
|
458 |
- # Migrate ironic database |
|
459 |
- $IRONIC_BIN_DIR/ironic-dbsync --config-file=$IRONIC_CONF_FILE |
|
460 |
- |
|
461 |
- create_ironic_cache_dir |
|
462 |
-} |
|
463 |
- |
|
464 |
-# _ironic_bm_vm_names() - Generates list of names for baremetal VMs. |
|
465 |
-function _ironic_bm_vm_names { |
|
466 |
- local idx |
|
467 |
- local num_vms |
|
468 |
- num_vms=$(($IRONIC_VM_COUNT - 1)) |
|
469 |
- for idx in $(seq 0 $num_vms); do |
|
470 |
- echo "baremetal${IRONIC_VM_NETWORK_BRIDGE}_${idx}" |
|
471 |
- done |
|
472 |
-} |
|
473 |
- |
|
474 |
-# start_ironic() - Start running processes, including screen |
|
475 |
-function start_ironic { |
|
476 |
- # Start Ironic API server, if enabled. |
|
477 |
- if is_service_enabled ir-api; then |
|
478 |
- start_ironic_api |
|
479 |
- fi |
|
480 |
- |
|
481 |
- # Start Ironic conductor, if enabled. |
|
482 |
- if is_service_enabled ir-cond; then |
|
483 |
- start_ironic_conductor |
|
484 |
- fi |
|
485 |
- |
|
486 |
- # Start Apache if iPXE is enabled |
|
487 |
- if [[ "$IRONIC_IPXE_ENABLED" == "True" ]] ; then |
|
488 |
- restart_apache_server |
|
489 |
- fi |
|
490 |
-} |
|
491 |
- |
|
492 |
-# start_ironic_api() - Used by start_ironic(). |
|
493 |
-# Starts Ironic API server. |
|
494 |
-function start_ironic_api { |
|
495 |
- run_process ir-api "$IRONIC_BIN_DIR/ironic-api --config-file=$IRONIC_CONF_FILE" |
|
496 |
- echo "Waiting for ir-api ($IRONIC_HOSTPORT) to start..." |
|
497 |
- if ! timeout $SERVICE_TIMEOUT sh -c "while ! wget --no-proxy -q -O- $IRONIC_SERVICE_PROTOCOL://$IRONIC_HOSTPORT; do sleep 1; done"; then |
|
498 |
- die $LINENO "ir-api did not start" |
|
499 |
- fi |
|
500 |
-} |
|
501 |
- |
|
502 |
-# start_ironic_conductor() - Used by start_ironic(). |
|
503 |
-# Starts Ironic conductor. |
|
504 |
-function start_ironic_conductor { |
|
505 |
- run_process ir-cond "$IRONIC_BIN_DIR/ironic-conductor --config-file=$IRONIC_CONF_FILE" |
|
506 |
- # TODO(romcheg): Find a way to check whether the conductor has started. |
|
507 |
-} |
|
508 |
- |
|
509 |
-# stop_ironic() - Stop running processes |
|
510 |
-function stop_ironic { |
|
511 |
- stop_process ir-api |
|
512 |
- stop_process ir-cond |
|
513 |
- |
|
514 |
- # Cleanup the WSGI files |
|
515 |
- if [[ "$IRONIC_IPXE_ENABLED" == "True" ]] ; then |
|
516 |
- _cleanup_ironic_apache_wsgi |
|
517 |
- fi |
|
518 |
-} |
|
519 |
- |
|
520 |
-function create_ovs_taps { |
|
521 |
- local ironic_net_id |
|
522 |
- ironic_net_id=$(neutron net-list | grep private | get_field 1) |
|
523 |
- |
|
524 |
- # Work around: No netns exists on host until a Neutron port is created. We |
|
525 |
- # need to create one in Neutron to know what netns to tap into prior to the |
|
526 |
- # first node booting. |
|
527 |
- local port_id |
|
528 |
- port_id=$(neutron port-create private | grep " id " | get_field 2) |
|
529 |
- |
|
530 |
- # intentional sleep to make sure the tag has been set to port |
|
531 |
- sleep 10 |
|
532 |
- |
|
533 |
- local tapdev |
|
534 |
- tapdev=$(sudo ip netns exec qdhcp-${ironic_net_id} ip link list | grep " tap" | cut -d':' -f2 | cut -d'@' -f1 | cut -b2-) |
|
535 |
- local tag_id |
|
536 |
- tag_id=$(sudo ovs-vsctl show |grep ${tapdev} -A1 -m1 | grep tag | cut -d':' -f2 | cut -b2-) |
|
537 |
- |
|
538 |
- # make sure veth pair is not existing, otherwise delete its links |
|
539 |
- sudo ip link show ovs-tap1 && sudo ip link delete ovs-tap1 |
|
540 |
- sudo ip link show brbm-tap1 && sudo ip link delete brbm-tap1 |
|
541 |
- # create veth pair for future interconnection between br-int and brbm |
|
542 |
- sudo ip link add brbm-tap1 type veth peer name ovs-tap1 |
|
543 |
- sudo ip link set dev brbm-tap1 up |
|
544 |
- sudo ip link set dev ovs-tap1 up |
|
545 |
- |
|
546 |
- sudo ovs-vsctl -- --if-exists del-port ovs-tap1 -- add-port br-int ovs-tap1 tag=$tag_id |
|
547 |
- sudo ovs-vsctl -- --if-exists del-port brbm-tap1 -- add-port $IRONIC_VM_NETWORK_BRIDGE brbm-tap1 |
|
548 |
- |
|
549 |
- # Remove the port needed only for workaround. |
|
550 |
- neutron port-delete $port_id |
|
551 |
- |
|
552 |
- # Finally, share the fixed tenant network across all tenants. This allows the host |
|
553 |
- # to serve TFTP to a single network namespace via the tap device created above. |
|
554 |
- neutron net-update $ironic_net_id --shared true |
|
555 |
-} |
|
556 |
- |
|
557 |
-function create_bridge_and_vms { |
|
558 |
- # Call libvirt setup scripts in a new shell to ensure any new group membership |
|
559 |
- sudo su $STACK_USER -c "$IRONIC_SCRIPTS_DIR/setup-network" |
|
560 |
- if [[ "$IRONIC_VM_LOG_CONSOLE" == "True" ]] ; then |
|
561 |
- local log_arg="$IRONIC_VM_LOG_DIR" |
|
562 |
- else |
|
563 |
- local log_arg="" |
|
564 |
- fi |
|
565 |
- local vm_name |
|
566 |
- for vm_name in $(_ironic_bm_vm_names); do |
|
567 |
- sudo su $STACK_USER -c "$IRONIC_SCRIPTS_DIR/create-node $vm_name \ |
|
568 |
- $IRONIC_VM_SPECS_CPU $IRONIC_VM_SPECS_RAM $IRONIC_VM_SPECS_DISK \ |
|
569 |
- amd64 $IRONIC_VM_NETWORK_BRIDGE $IRONIC_VM_EMULATOR \ |
|
570 |
- $log_arg" >> $IRONIC_VM_MACS_CSV_FILE |
|
571 |
- done |
|
572 |
- create_ovs_taps |
|
573 |
-} |
|
574 |
- |
|
575 |
-function wait_for_nova_resources { |
|
576 |
- # After nodes have been enrolled, we need to wait for both ironic and |
|
577 |
- # nova's periodic tasks to populate the resource tracker with available |
|
578 |
- # nodes and resources. Wait up to 2 minutes for a given resource before |
|
579 |
- # timing out. |
|
580 |
- local resource=$1 |
|
581 |
- local expected_count=$2 |
|
582 |
- local i |
|
583 |
- echo_summary "Waiting 2 minutes for Nova resource tracker to pick up $resource >= $expected_count" |
|
584 |
- for i in $(seq 1 120); do |
|
585 |
- if [ $(nova hypervisor-stats | grep " $resource " | get_field 2) -ge $expected_count ]; then |
|
586 |
- return 0 |
|
587 |
- fi |
|
588 |
- sleep 1 |
|
589 |
- done |
|
590 |
- die $LINENO "Timed out waiting for Nova hypervisor-stats $resource >= $expected_count" |
|
591 |
-} |
|
592 |
- |
|
593 |
-function enroll_nodes { |
|
594 |
- local chassis_id |
|
595 |
- chassis_id=$(ironic chassis-create -d "ironic test chassis" | grep " uuid " | get_field 2) |
|
596 |
- |
|
597 |
- if ! is_ironic_hardware; then |
|
598 |
- local ironic_node_cpu=$IRONIC_VM_SPECS_CPU |
|
599 |
- local ironic_node_ram=$IRONIC_VM_SPECS_RAM |
|
600 |
- local ironic_node_disk=$IRONIC_VM_SPECS_DISK |
|
601 |
- local ironic_ephemeral_disk=$IRONIC_VM_EPHEMERAL_DISK |
|
602 |
- local ironic_hwinfo_file=$IRONIC_VM_MACS_CSV_FILE |
|
603 |
- local node_options="\ |
|
604 |
- -i deploy_kernel=$IRONIC_DEPLOY_KERNEL_ID \ |
|
605 |
- -i deploy_ramdisk=$IRONIC_DEPLOY_RAMDISK_ID \ |
|
606 |
- -i ssh_virt_type=$IRONIC_SSH_VIRT_TYPE \ |
|
607 |
- -i ssh_address=$IRONIC_VM_SSH_ADDRESS \ |
|
608 |
- -i ssh_port=$IRONIC_VM_SSH_PORT \ |
|
609 |
- -i ssh_username=$IRONIC_SSH_USERNAME \ |
|
610 |
- -i ssh_key_filename=$IRONIC_KEY_FILE" |
|
611 |
- else |
|
612 |
- local ironic_node_cpu=$IRONIC_HW_NODE_CPU |
|
613 |
- local ironic_node_ram=$IRONIC_HW_NODE_RAM |
|
614 |
- local ironic_node_disk=$IRONIC_HW_NODE_DISK |
|
615 |
- local ironic_ephemeral_disk=$IRONIC_HW_EPHEMERAL_DISK |
|
616 |
- if [[ -z "${IRONIC_DEPLOY_DRIVER##*_ipmitool}" ]]; then |
|
617 |
- local ironic_hwinfo_file=$IRONIC_IPMIINFO_FILE |
|
618 |
- fi |
|
619 |
- fi |
|
620 |
- |
|
621 |
- local total_nodes=0 |
|
622 |
- local total_cpus=0 |
|
623 |
- while read hardware_info; do |
|
624 |
- if ! is_ironic_hardware; then |
|
625 |
- local mac_address=$hardware_info |
|
626 |
- elif [[ -z "${IRONIC_DEPLOY_DRIVER##*_ipmitool}" ]]; then |
|
627 |
- local ipmi_address |
|
628 |
- ipmi_address=$(echo $hardware_info |awk '{print $1}') |
|
629 |
- local mac_address |
|
630 |
- mac_address=$(echo $hardware_info |awk '{print $2}') |
|
631 |
- local ironic_ipmi_username |
|
632 |
- ironic_ipmi_username=$(echo $hardware_info |awk '{print $3}') |
|
633 |
- local ironic_ipmi_passwd |
|
634 |
- ironic_ipmi_passwd=$(echo $hardware_info |awk '{print $4}') |
|
635 |
- # Currently we require all hardware platform have same CPU/RAM/DISK info |
|
636 |
- # in future, this can be enhanced to support different type, and then |
|
637 |
- # we create the bare metal flavor with minimum value |
|
638 |
- local node_options="-i ipmi_address=$ipmi_address -i ipmi_password=$ironic_ipmi_passwd\ |
|
639 |
- -i ipmi_username=$ironic_ipmi_username" |
|
640 |
- node_options+=" -i deploy_kernel=$IRONIC_DEPLOY_KERNEL_ID" |
|
641 |
- node_options+=" -i deploy_ramdisk=$IRONIC_DEPLOY_RAMDISK_ID" |
|
642 |
- fi |
|
643 |
- |
|
644 |
- # First node created will be used for testing in ironic w/o glance |
|
645 |
- # scenario, so we need to know its UUID. |
|
646 |
- local standalone_node_uuid="" |
|
647 |
- if [ $total_nodes -eq 0 ]; then |
|
648 |
- standalone_node_uuid="--uuid $IRONIC_NODE_UUID" |
|
649 |
- fi |
|
650 |
- |
|
651 |
- local node_id |
|
652 |
- node_id=$(ironic node-create $standalone_node_uuid\ |
|
653 |
- --chassis_uuid $chassis_id \ |
|
654 |
- --driver $IRONIC_DEPLOY_DRIVER \ |
|
655 |
- --name node-$total_nodes \ |
|
656 |
- -p cpus=$ironic_node_cpu\ |
|
657 |
- -p memory_mb=$ironic_node_ram\ |
|
658 |
- -p local_gb=$ironic_node_disk\ |
|
659 |
- -p cpu_arch=x86_64 \ |
|
660 |
- $node_options \ |
|
661 |
- | grep " uuid " | get_field 2) |
|
662 |
- |
|
663 |
- ironic port-create --address $mac_address --node $node_id |
|
664 |
- |
|
665 |
- total_nodes=$((total_nodes+1)) |
|
666 |
- total_cpus=$((total_cpus+$ironic_node_cpu)) |
|
667 |
- done < $ironic_hwinfo_file |
|
668 |
- |
|
669 |
- local adjusted_disk |
|
670 |
- adjusted_disk=$(($ironic_node_disk - $ironic_ephemeral_disk)) |
|
671 |
- nova flavor-create --ephemeral $ironic_ephemeral_disk baremetal auto $ironic_node_ram $adjusted_disk $ironic_node_cpu |
|
672 |
- |
|
673 |
- nova flavor-key baremetal set "cpu_arch"="x86_64" |
|
674 |
- |
|
675 |
- if [ "$VIRT_DRIVER" == "ironic" ]; then |
|
676 |
- wait_for_nova_resources "count" $total_nodes |
|
677 |
- wait_for_nova_resources "vcpus" $total_cpus |
|
678 |
- fi |
|
679 |
-} |
|
680 |
- |
|
681 |
-function configure_iptables { |
|
682 |
- # enable tftp natting for allowing connections to HOST_IP's tftp server |
|
683 |
- sudo modprobe nf_conntrack_tftp |
|
684 |
- sudo modprobe nf_nat_tftp |
|
685 |
- # explicitly allow DHCP - packets are occasionally being dropped here |
|
686 |
- sudo iptables -I INPUT -p udp --dport 67:68 --sport 67:68 -j ACCEPT || true |
|
687 |
- # nodes boot from TFTP and callback to the API server listening on $HOST_IP |
|
688 |
- sudo iptables -I INPUT -d $HOST_IP -p udp --dport 69 -j ACCEPT || true |
|
689 |
- sudo iptables -I INPUT -d $HOST_IP -p tcp --dport $IRONIC_SERVICE_PORT -j ACCEPT || true |
|
690 |
- if is_deployed_by_agent; then |
|
691 |
- # agent ramdisk gets instance image from swift |
|
692 |
- sudo iptables -I INPUT -d $HOST_IP -p tcp --dport ${SWIFT_DEFAULT_BIND_PORT:-8080} -j ACCEPT || true |
|
693 |
- fi |
|
694 |
- |
|
695 |
- if [[ "$IRONIC_IPXE_ENABLED" == "True" ]] ; then |
|
696 |
- sudo iptables -I INPUT -d $HOST_IP -p tcp --dport $IRONIC_HTTP_PORT -j ACCEPT || true |
|
697 |
- fi |
|
698 |
-} |
|
699 |
- |
|
700 |
-function configure_tftpd { |
|
701 |
- # stop tftpd and setup serving via xinetd |
|
702 |
- stop_service tftpd-hpa || true |
|
703 |
- [ -f /etc/init/tftpd-hpa.conf ] && echo "manual" | sudo tee /etc/init/tftpd-hpa.override |
|
704 |
- sudo cp $IRONIC_TEMPLATES_DIR/tftpd-xinetd.template /etc/xinetd.d/tftp |
|
705 |
- sudo sed -e "s|%TFTPBOOT_DIR%|$IRONIC_TFTPBOOT_DIR|g" -i /etc/xinetd.d/tftp |
|
706 |
- |
|
707 |
- # setup tftp file mapping to satisfy requests at the root (booting) and |
|
708 |
- # /tftpboot/ sub-dir (as per deploy-ironic elements) |
|
709 |
- echo "r ^([^/]) $IRONIC_TFTPBOOT_DIR/\1" >$IRONIC_TFTPBOOT_DIR/map-file |
|
710 |
- echo "r ^(/tftpboot/) $IRONIC_TFTPBOOT_DIR/\2" >>$IRONIC_TFTPBOOT_DIR/map-file |
|
711 |
- |
|
712 |
- chmod -R 0755 $IRONIC_TFTPBOOT_DIR |
|
713 |
- restart_service xinetd |
|
714 |
-} |
|
715 |
- |
|
716 |
-function configure_ironic_ssh_keypair { |
|
717 |
- if [[ ! -d $HOME/.ssh ]]; then |
|
718 |
- mkdir -p $HOME/.ssh |
|
719 |
- chmod 700 $HOME/.ssh |
|
720 |
- fi |
|
721 |
- if [[ ! -e $IRONIC_KEY_FILE ]]; then |
|
722 |
- if [[ ! -d $(dirname $IRONIC_KEY_FILE) ]]; then |
|
723 |
- mkdir -p $(dirname $IRONIC_KEY_FILE) |
|
724 |
- fi |
|
725 |
- echo -e 'n\n' | ssh-keygen -q -t rsa -P '' -f $IRONIC_KEY_FILE |
|
726 |
- fi |
|
727 |
- cat $IRONIC_KEY_FILE.pub | tee -a $IRONIC_AUTHORIZED_KEYS_FILE |
|
728 |
-} |
|
729 |
- |
|
730 |
-function ironic_ssh_check { |
|
731 |
- local key_file=$1 |
|
732 |
- local floating_ip=$2 |
|
733 |
- local port=$3 |
|
734 |
- local default_instance_user=$4 |
|
735 |
- local active_timeout=$5 |
|
736 |
- if ! timeout $active_timeout sh -c "while ! ssh -p $port -o StrictHostKeyChecking=no -i $key_file ${default_instance_user}@$floating_ip echo success; do sleep 1; done"; then |
|
737 |
- die $LINENO "server didn't become ssh-able!" |
|
738 |
- fi |
|
739 |
-} |
|
740 |
- |
|
741 |
-function configure_ironic_auxiliary { |
|
742 |
- configure_ironic_ssh_keypair |
|
743 |
- ironic_ssh_check $IRONIC_KEY_FILE $IRONIC_VM_SSH_ADDRESS $IRONIC_VM_SSH_PORT $IRONIC_SSH_USERNAME $IRONIC_SSH_TIMEOUT |
|
744 |
-} |
|
745 |
- |
|
746 |
-function build_ipa_coreos_ramdisk { |
|
747 |
- echo "Building ironic-python-agent deploy ramdisk" |
|
748 |
- local kernel_path=$1 |
|
749 |
- local ramdisk_path=$2 |
|
750 |
- git_clone $IRONIC_PYTHON_AGENT_REPO $IRONIC_PYTHON_AGENT_DIR $IRONIC_PYTHON_AGENT_BRANCH |
|
751 |
- cd $IRONIC_PYTHON_AGENT_DIR |
|
752 |
- imagebuild/coreos/build_coreos_image.sh |
|
753 |
- cp imagebuild/coreos/UPLOAD/coreos_production_pxe_image-oem.cpio.gz $ramdisk_path |
|
754 |
- cp imagebuild/coreos/UPLOAD/coreos_production_pxe.vmlinuz $kernel_path |
|
755 |
- sudo rm -rf UPLOAD |
|
756 |
- cd - |
|
757 |
-} |
|
758 |
- |
|
759 |
-# build deploy kernel+ramdisk, then upload them to glance |
|
760 |
-# this function sets ``IRONIC_DEPLOY_KERNEL_ID``, ``IRONIC_DEPLOY_RAMDISK_ID`` |
|
761 |
-function upload_baremetal_ironic_deploy { |
|
762 |
- declare -g IRONIC_DEPLOY_KERNEL_ID IRONIC_DEPLOY_RAMDISK_ID |
|
763 |
- echo_summary "Creating and uploading baremetal images for ironic" |
|
764 |
- |
|
765 |
- # install diskimage-builder |
|
766 |
- if [[ $(type -P ramdisk-image-create) == "" ]]; then |
|
767 |
- pip_install_gr "diskimage-builder" |
|
768 |
- fi |
|
769 |
- |
|
770 |
- if [ -z "$IRONIC_DEPLOY_KERNEL" -o -z "$IRONIC_DEPLOY_RAMDISK" ]; then |
|
771 |
- local IRONIC_DEPLOY_KERNEL_PATH=$TOP_DIR/files/ir-deploy-$IRONIC_DEPLOY_DRIVER.kernel |
|
772 |
- local IRONIC_DEPLOY_RAMDISK_PATH=$TOP_DIR/files/ir-deploy-$IRONIC_DEPLOY_DRIVER.initramfs |
|
773 |
- else |
|
774 |
- local IRONIC_DEPLOY_KERNEL_PATH=$IRONIC_DEPLOY_KERNEL |
|
775 |
- local IRONIC_DEPLOY_RAMDISK_PATH=$IRONIC_DEPLOY_RAMDISK |
|
776 |
- fi |
|
777 |
- |
|
778 |
- if [ ! -e "$IRONIC_DEPLOY_RAMDISK_PATH" -o ! -e "$IRONIC_DEPLOY_KERNEL_PATH" ]; then |
|
779 |
- # files don't exist, need to build them |
|
780 |
- if [ "$IRONIC_BUILD_DEPLOY_RAMDISK" = "True" ]; then |
|
781 |
- # we can build them only if we're not offline |
|
782 |
- if [ "$OFFLINE" != "True" ]; then |
|
783 |
- if is_deployed_with_ipa_ramdisk; then |
|
784 |
- build_ipa_coreos_ramdisk $IRONIC_DEPLOY_KERNEL_PATH $IRONIC_DEPLOY_RAMDISK_PATH |
|
785 |
- else |
|
786 |
- ramdisk-image-create $IRONIC_DEPLOY_FLAVOR \ |
|
787 |
- -o $TOP_DIR/files/ir-deploy-$IRONIC_DEPLOY_DRIVER |
|
788 |
- fi |
|
789 |
- else |
|
790 |
- die $LINENO "Deploy kernel+ramdisk files don't exist and cannot be build in OFFLINE mode" |
|
791 |
- fi |
|
792 |
- else |
|
793 |
- if is_deployed_with_ipa_ramdisk; then |
|
794 |
- # download the agent image tarball |
|
795 |
- wget "$IRONIC_AGENT_KERNEL_URL" -O $IRONIC_DEPLOY_KERNEL_PATH |
|
796 |
- wget "$IRONIC_AGENT_RAMDISK_URL" -O $IRONIC_DEPLOY_RAMDISK_PATH |
|
797 |
- else |
|
798 |
- die $LINENO "Deploy kernel+ramdisk files don't exist and their building was disabled explicitly by IRONIC_BUILD_DEPLOY_RAMDISK" |
|
799 |
- fi |
|
800 |
- fi |
|
801 |
- fi |
|
802 |
- |
|
803 |
- local token |
|
804 |
- token=$(openstack token issue -c id -f value) |
|
805 |
- die_if_not_set $LINENO token "Keystone fail to get token" |
|
806 |
- |
|
807 |
- # load them into glance |
|
808 |
- IRONIC_DEPLOY_KERNEL_ID=$(openstack \ |
|
809 |
- --os-token $token \ |
|
810 |
- --os-url $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT \ |
|
811 |
- image create \ |
|
812 |
- $(basename $IRONIC_DEPLOY_KERNEL_PATH) \ |
|
813 |
- --public --disk-format=aki \ |
|
814 |
- --container-format=aki \ |
|
815 |
- < $IRONIC_DEPLOY_KERNEL_PATH | grep ' id ' | get_field 2) |
|
816 |
- IRONIC_DEPLOY_RAMDISK_ID=$(openstack \ |
|
817 |
- --os-token $token \ |
|
818 |
- --os-url $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT \ |
|
819 |
- image create \ |
|
820 |
- $(basename $IRONIC_DEPLOY_RAMDISK_PATH) \ |
|
821 |
- --public --disk-format=ari \ |
|
822 |
- --container-format=ari \ |
|
823 |
- < $IRONIC_DEPLOY_RAMDISK_PATH | grep ' id ' | get_field 2) |
|
824 |
-} |
|
825 |
- |
|
826 |
-function prepare_baremetal_basic_ops { |
|
827 |
- if ! is_ironic_hardware; then |
|
828 |
- configure_ironic_auxiliary |
|
829 |
- fi |
|
830 |
- upload_baremetal_ironic_deploy |
|
831 |
- if ! is_ironic_hardware; then |
|
832 |
- create_bridge_and_vms |
|
833 |
- fi |
|
834 |
- enroll_nodes |
|
835 |
- configure_tftpd |
|
836 |
- configure_iptables |
|
837 |
-} |
|
838 |
- |
|
839 |
-function cleanup_baremetal_basic_ops { |
|
840 |
- rm -f $IRONIC_VM_MACS_CSV_FILE |
|
841 |
- if [ -f $IRONIC_KEY_FILE ]; then |
|
842 |
- local key |
|
843 |
- key=$(cat $IRONIC_KEY_FILE.pub) |
|
844 |
- # remove public key from authorized_keys |
|
845 |
- grep -v "$key" $IRONIC_AUTHORIZED_KEYS_FILE > temp && mv temp $IRONIC_AUTHORIZED_KEYS_FILE |
|
846 |
- chmod 0600 $IRONIC_AUTHORIZED_KEYS_FILE |
|
847 |
- fi |
|
848 |
- sudo rm -rf $IRONIC_DATA_DIR $IRONIC_STATE_PATH |
|
849 |
- |
|
850 |
- local vm_name |
|
851 |
- for vm_name in $(_ironic_bm_vm_names); do |
|
852 |
- sudo su $STACK_USER -c "$IRONIC_SCRIPTS_DIR/cleanup-node $vm_name $IRONIC_VM_NETWORK_BRIDGE" |
|
853 |
- done |
|
854 |
- |
|
855 |
- sudo rm -rf /etc/xinetd.d/tftp /etc/init/tftpd-hpa.override |
|
856 |
- restart_service xinetd |
|
857 |
- sudo iptables -D INPUT -d $HOST_IP -p udp --dport 69 -j ACCEPT || true |
|
858 |
- sudo iptables -D INPUT -d $HOST_IP -p tcp --dport $IRONIC_SERVICE_PORT -j ACCEPT || true |
|
859 |
- if is_deployed_by_agent; then |
|
860 |
- # agent ramdisk gets instance image from swift |
|
861 |
- sudo iptables -D INPUT -d $HOST_IP -p tcp --dport ${SWIFT_DEFAULT_BIND_PORT:-8080} -j ACCEPT || true |
|
862 |
- fi |
|
863 |
- sudo rmmod nf_conntrack_tftp || true |
|
864 |
- sudo rmmod nf_nat_tftp || true |
|
865 |
-} |
|
866 |
- |
|
867 |
-# Restore xtrace + pipefail |
|
868 |
-$_XTRACE_IRONIC |
|
869 |
-$_PIPEFAIL_IRONIC |
|
870 |
- |
|
871 |
-# Tell emacs to use shell-script-mode |
|
872 |
-## Local variables: |
|
873 |
-## mode: shell-script |
|
874 |
-## End: |
... | ... |
@@ -225,10 +225,6 @@ HEAT_BRANCH=${HEAT_BRANCH:-master} |
225 | 225 |
HORIZON_REPO=${HORIZON_REPO:-${GIT_BASE}/openstack/horizon.git} |
226 | 226 |
HORIZON_BRANCH=${HORIZON_BRANCH:-master} |
227 | 227 |
|
228 |
-# baremetal provisioning service |
|
229 |
-IRONIC_REPO=${IRONIC_REPO:-${GIT_BASE}/openstack/ironic.git} |
|
230 |
-IRONIC_BRANCH=${IRONIC_BRANCH:-master} |
|
231 |
- |
|
232 | 228 |
# unified auth system (manages accounts/tokens) |
233 | 229 |
KEYSTONE_REPO=${KEYSTONE_REPO:-${GIT_BASE}/openstack/keystone.git} |
234 | 230 |
KEYSTONE_BRANCH=${KEYSTONE_BRANCH:-master} |
... | ... |
@@ -298,6 +294,8 @@ GITBRANCH["python-heatclient"]=${HEATCLIENT_BRANCH:-master} |
298 | 298 |
# ironic client |
299 | 299 |
GITREPO["python-ironicclient"]=${IRONICCLIENT_REPO:-${GIT_BASE}/openstack/python-ironicclient.git} |
300 | 300 |
GITBRANCH["python-ironicclient"]=${IRONICCLIENT_BRANCH:-master} |
301 |
+# ironic plugin is out of tree, but nova uses it. set GITDIR here. |
|
302 |
+GITDIR["python-ironicclient"]=$DEST/python-ironicclient |
|
301 | 303 |
|
302 | 304 |
# the base authentication plugins that clients use to authenticate |
303 | 305 |
GITREPO["keystoneauth"]=${KEYSTONEAUTH_REPO:-${GIT_BASE}/openstack/keystoneauth.git} |
... | ... |
@@ -484,6 +482,8 @@ GITBRANCH["os-brick"]=${OS_BRICK_BRANCH:-master} |
484 | 484 |
# ironic common lib |
485 | 485 |
GITREPO["ironic-lib"]=${IRONIC_LIB_REPO:-${GIT_BASE}/openstack/ironic-lib.git} |
486 | 486 |
GITBRANCH["ironic-lib"]=${IRONIC_LIB_BRANCH:-master} |
487 |
+# this doesn't exist in a lib file, so set it here |
|
488 |
+GITDIR["ironic-lib"]=$DEST/ironic-lib |
|
487 | 489 |
|
488 | 490 |
|
489 | 491 |
################## |
490 | 492 |
deleted file mode 100755 |
... | ... |
@@ -1,25 +0,0 @@ |
1 |
-#!/usr/bin/env bash |
|
2 |
- |
|
3 |
-# **cleanup-nodes** |
|
4 |
- |
|
5 |
-# Cleans up baremetal poseur nodes and volumes created during ironic setup |
|
6 |
-# Assumes calling user has proper libvirt group membership and access. |
|
7 |
- |
|
8 |
-set -exu |
|
9 |
- |
|
10 |
-LIBVIRT_STORAGE_POOL=${LIBVIRT_STORAGE_POOL:-"default"} |
|
11 |
-LIBVIRT_CONNECT_URI=${LIBVIRT_CONNECT_URI:-"qemu:///system"} |
|
12 |
- |
|
13 |
-NAME=$1 |
|
14 |
-NETWORK_BRIDGE=$2 |
|
15 |
- |
|
16 |
-export VIRSH_DEFAULT_CONNECT_URI=$LIBVIRT_CONNECT_URI |
|
17 |
- |
|
18 |
-VOL_NAME="$NAME.qcow2" |
|
19 |
-virsh list | grep -q $NAME && virsh destroy $NAME |
|
20 |
-virsh list --inactive | grep -q $NAME && virsh undefine $NAME |
|
21 |
- |
|
22 |
-if virsh pool-list | grep -q $LIBVIRT_STORAGE_POOL ; then |
|
23 |
- virsh vol-list $LIBVIRT_STORAGE_POOL | grep -q $VOL_NAME && |
|
24 |
- virsh vol-delete $VOL_NAME --pool $LIBVIRT_STORAGE_POOL |
|
25 |
-fi |
26 | 1 |
deleted file mode 100755 |
... | ... |
@@ -1,93 +0,0 @@ |
1 |
-#!/usr/bin/env python |
|
2 |
- |
|
3 |
-import argparse |
|
4 |
-import os.path |
|
5 |
- |
|
6 |
-import libvirt |
|
7 |
- |
|
8 |
-templatedir = os.path.join(os.path.dirname(os.path.dirname(__file__)), |
|
9 |
- 'templates') |
|
10 |
- |
|
11 |
- |
|
12 |
-CONSOLE_LOG = """ |
|
13 |
- <serial type='file'> |
|
14 |
- <source path='%(console_log)s'/> |
|
15 |
- <target port='0'/> |
|
16 |
- <alias name='serial0'/> |
|
17 |
- </serial> |
|
18 |
- <serial type='pty'> |
|
19 |
- <source path='/dev/pts/49'/> |
|
20 |
- <target port='1'/> |
|
21 |
- <alias name='serial1'/> |
|
22 |
- </serial> |
|
23 |
- <console type='file'> |
|
24 |
- <source path='%(console_log)s'/> |
|
25 |
- <target type='serial' port='0'/> |
|
26 |
- <alias name='serial0'/> |
|
27 |
- </console> |
|
28 |
-""" |
|
29 |
- |
|
30 |
- |
|
31 |
-def main(): |
|
32 |
- parser = argparse.ArgumentParser( |
|
33 |
- description="Configure a kvm virtual machine for the seed image.") |
|
34 |
- parser.add_argument('--name', default='seed', |
|
35 |
- help='the name to give the machine in libvirt.') |
|
36 |
- parser.add_argument('--image', |
|
37 |
- help='Use a custom image file (must be qcow2).') |
|
38 |
- parser.add_argument('--engine', default='qemu', |
|
39 |
- help='The virtualization engine to use') |
|
40 |
- parser.add_argument('--arch', default='i686', |
|
41 |
- help='The architecture to use') |
|
42 |
- parser.add_argument('--memory', default='2097152', |
|
43 |
- help="Maximum memory for the VM in KB.") |
|
44 |
- parser.add_argument('--cpus', default='1', |
|
45 |
- help="CPU count for the VM.") |
|
46 |
- parser.add_argument('--bootdev', default='hd', |
|
47 |
- help="What boot device to use (hd/network).") |
|
48 |
- parser.add_argument('--network', default="brbm", |
|
49 |
- help='The libvirt network name to use') |
|
50 |
- parser.add_argument('--libvirt-nic-driver', default='e1000', |
|
51 |
- help='The libvirt network driver to use') |
|
52 |
- parser.add_argument('--console-log', |
|
53 |
- help='File to log console') |
|
54 |
- parser.add_argument('--emulator', default=None, |
|
55 |
- help='Path to emulator bin for vm template') |
|
56 |
- args = parser.parse_args() |
|
57 |
- with file(templatedir + '/vm.xml', 'rb') as f: |
|
58 |
- source_template = f.read() |
|
59 |
- params = { |
|
60 |
- 'name': args.name, |
|
61 |
- 'imagefile': args.image, |
|
62 |
- 'engine': args.engine, |
|
63 |
- 'arch': args.arch, |
|
64 |
- 'memory': args.memory, |
|
65 |
- 'cpus': args.cpus, |
|
66 |
- 'bootdev': args.bootdev, |
|
67 |
- 'network': args.network, |
|
68 |
- 'nicdriver': args.libvirt_nic_driver, |
|
69 |
- 'emulator': args.emulator, |
|
70 |
- } |
|
71 |
- |
|
72 |
- if args.emulator: |
|
73 |
- params['emulator'] = args.emulator |
|
74 |
- else: |
|
75 |
- if os.path.exists("/usr/bin/kvm"): # Debian |
|
76 |
- params['emulator'] = "/usr/bin/kvm" |
|
77 |
- elif os.path.exists("/usr/bin/qemu-kvm"): # Redhat |
|
78 |
- params['emulator'] = "/usr/bin/qemu-kvm" |
|
79 |
- |
|
80 |
- if args.console_log: |
|
81 |
- params['bios_serial'] = "<bios useserial='yes'/>" |
|
82 |
- params['console_log'] = CONSOLE_LOG % {'console_log': args.console_log} |
|
83 |
- else: |
|
84 |
- params['bios_serial'] = '' |
|
85 |
- params['console_log'] = '' |
|
86 |
- libvirt_template = source_template % params |
|
87 |
- conn = libvirt.open("qemu:///system") |
|
88 |
- |
|
89 |
- a = conn.defineXML(libvirt_template) |
|
90 |
- print ("Created machine %s with UUID %s" % (args.name, a.UUIDString())) |
|
91 |
- |
|
92 |
-if __name__ == '__main__': |
|
93 |
- main() |
94 | 1 |
deleted file mode 100755 |
... | ... |
@@ -1,79 +0,0 @@ |
1 |
-#!/usr/bin/env bash |
|
2 |
- |
|
3 |
-# **create-nodes** |
|
4 |
- |
|
5 |
-# Creates baremetal poseur nodes for ironic testing purposes |
|
6 |
- |
|
7 |
-set -ex |
|
8 |
- |
|
9 |
-# Keep track of the DevStack directory |
|
10 |
-TOP_DIR=$(cd $(dirname "$0")/.. && pwd) |
|
11 |
- |
|
12 |
-NAME=$1 |
|
13 |
-CPU=$2 |
|
14 |
-MEM=$(( 1024 * $3 )) |
|
15 |
-# Extra G to allow fuzz for partition table : flavor size and registered size |
|
16 |
-# need to be different to actual size. |
|
17 |
-DISK=$(( $4 + 1)) |
|
18 |
- |
|
19 |
-case $5 in |
|
20 |
- i386) ARCH='i686' ;; |
|
21 |
- amd64) ARCH='x86_64' ;; |
|
22 |
- *) echo "Unsupported arch $4!" ; exit 1 ;; |
|
23 |
-esac |
|
24 |
- |
|
25 |
-BRIDGE=$6 |
|
26 |
-EMULATOR=$7 |
|
27 |
-LOGDIR=$8 |
|
28 |
- |
|
29 |
-LIBVIRT_NIC_DRIVER=${LIBVIRT_NIC_DRIVER:-"e1000"} |
|
30 |
-LIBVIRT_STORAGE_POOL=${LIBVIRT_STORAGE_POOL:-"default"} |
|
31 |
-LIBVIRT_CONNECT_URI=${LIBVIRT_CONNECT_URI:-"qemu:///system"} |
|
32 |
- |
|
33 |
-export VIRSH_DEFAULT_CONNECT_URI=$LIBVIRT_CONNECT_URI |
|
34 |
- |
|
35 |
-if ! virsh pool-list --all | grep -q $LIBVIRT_STORAGE_POOL; then |
|
36 |
- virsh pool-define-as --name $LIBVIRT_STORAGE_POOL dir --target /var/lib/libvirt/images >&2 |
|
37 |
- virsh pool-autostart $LIBVIRT_STORAGE_POOL >&2 |
|
38 |
- virsh pool-start $LIBVIRT_STORAGE_POOL >&2 |
|
39 |
-fi |
|
40 |
- |
|
41 |
-pool_state=$(virsh pool-info $LIBVIRT_STORAGE_POOL | grep State | awk '{ print $2 }') |
|
42 |
-if [ "$pool_state" != "running" ] ; then |
|
43 |
- [ ! -d /var/lib/libvirt/images ] && sudo mkdir /var/lib/libvirt/images |
|
44 |
- virsh pool-start $LIBVIRT_STORAGE_POOL >&2 |
|
45 |
-fi |
|
46 |
- |
|
47 |
-if [ -n "$LOGDIR" ] ; then |
|
48 |
- mkdir -p "$LOGDIR" |
|
49 |
-fi |
|
50 |
- |
|
51 |
-PREALLOC= |
|
52 |
-if [ -f /etc/debian_version ]; then |
|
53 |
- PREALLOC="--prealloc-metadata" |
|
54 |
-fi |
|
55 |
- |
|
56 |
-if [ -n "$LOGDIR" ] ; then |
|
57 |
- VM_LOGGING="--console-log $LOGDIR/${NAME}_console.log" |
|
58 |
-else |
|
59 |
- VM_LOGGING="" |
|
60 |
-fi |
|
61 |
-VOL_NAME="${NAME}.qcow2" |
|
62 |
- |
|
63 |
-if ! virsh list --all | grep -q $NAME; then |
|
64 |
- virsh vol-list --pool $LIBVIRT_STORAGE_POOL | grep -q $VOL_NAME && |
|
65 |
- virsh vol-delete $VOL_NAME --pool $LIBVIRT_STORAGE_POOL >&2 |
|
66 |
- virsh vol-create-as $LIBVIRT_STORAGE_POOL ${VOL_NAME} ${DISK}G --format qcow2 $PREALLOC >&2 |
|
67 |
- volume_path=$(virsh vol-path --pool $LIBVIRT_STORAGE_POOL $VOL_NAME) |
|
68 |
- # Pre-touch the VM to set +C, as it can only be set on empty files. |
|
69 |
- sudo touch "$volume_path" |
|
70 |
- sudo chattr +C "$volume_path" || true |
|
71 |
- $TOP_DIR/scripts/configure-vm \ |
|
72 |
- --bootdev network --name $NAME --image "$volume_path" \ |
|
73 |
- --arch $ARCH --cpus $CPU --memory $MEM --libvirt-nic-driver $LIBVIRT_NIC_DRIVER \ |
|
74 |
- --emulator $EMULATOR --network $BRIDGE $VM_LOGGING >&2 |
|
75 |
- |
|
76 |
-fi |
|
77 |
- |
|
78 |
-# echo mac |
|
79 |
-virsh dumpxml $NAME | grep "mac address" | head -1 | cut -d\' -f2 |
80 | 1 |
deleted file mode 100755 |
... | ... |
@@ -1,28 +0,0 @@ |
1 |
-#!/usr/bin/env bash |
|
2 |
- |
|
3 |
-# **setup-network** |
|
4 |
- |
|
5 |
-# Setups openvswitch libvirt network suitable for |
|
6 |
-# running baremetal poseur nodes for ironic testing purposes |
|
7 |
- |
|
8 |
-set -exu |
|
9 |
- |
|
10 |
-LIBVIRT_CONNECT_URI=${LIBVIRT_CONNECT_URI:-"qemu:///system"} |
|
11 |
- |
|
12 |
-# Keep track of the DevStack directory |
|
13 |
-TOP_DIR=$(cd $(dirname "$0")/.. && pwd) |
|
14 |
-BRIDGE_SUFFIX=${1:-''} |
|
15 |
-BRIDGE_NAME=brbm$BRIDGE_SUFFIX |
|
16 |
- |
|
17 |
-export VIRSH_DEFAULT_CONNECT_URI="$LIBVIRT_CONNECT_URI" |
|
18 |
- |
|
19 |
-# Only add bridge if missing |
|
20 |
-(sudo ovs-vsctl list-br | grep ${BRIDGE_NAME}$) || sudo ovs-vsctl add-br ${BRIDGE_NAME} |
|
21 |
- |
|
22 |
-# Remove bridge before replacing it. |
|
23 |
-(virsh net-list | grep "${BRIDGE_NAME} ") && virsh net-destroy ${BRIDGE_NAME} |
|
24 |
-(virsh net-list --inactive | grep "${BRIDGE_NAME} ") && virsh net-undefine ${BRIDGE_NAME} |
|
25 |
- |
|
26 |
-virsh net-define <(sed s/brbm/$BRIDGE_NAME/ $TOP_DIR/templates/brbm.xml) |
|
27 |
-virsh net-autostart ${BRIDGE_NAME} |
|
28 |
-virsh net-start ${BRIDGE_NAME} |
7 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,14 +0,0 @@ |
1 |
-service tftp |
|
2 |
-{ |
|
3 |
- protocol = udp |
|
4 |
- port = 69 |
|
5 |
- socket_type = dgram |
|
6 |
- wait = yes |
|
7 |
- user = root |
|
8 |
- server = /usr/sbin/in.tftpd |
|
9 |
- server_args = -v -v -v -v -v --map-file %TFTPBOOT_DIR%/map-file %TFTPBOOT_DIR% |
|
10 |
- disable = no |
|
11 |
- # This is a workaround for Fedora, where TFTP will listen only on |
|
12 |
- # IPv6 endpoint, if IPv4 flag is not used. |
|
13 |
- flags = IPv4 |
|
14 |
-} |
15 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,49 +0,0 @@ |
1 |
-<domain type='%(engine)s'> |
|
2 |
- <name>%(name)s</name> |
|
3 |
- <memory unit='KiB'>%(memory)s</memory> |
|
4 |
- <vcpu>%(cpus)s</vcpu> |
|
5 |
- <os> |
|
6 |
- <type arch='%(arch)s' machine='pc-1.0'>hvm</type> |
|
7 |
- <boot dev='%(bootdev)s'/> |
|
8 |
- <bootmenu enable='no'/> |
|
9 |
- %(bios_serial)s |
|
10 |
- </os> |
|
11 |
- <features> |
|
12 |
- <acpi/> |
|
13 |
- <apic/> |
|
14 |
- <pae/> |
|
15 |
- </features> |
|
16 |
- <clock offset='utc'/> |
|
17 |
- <on_poweroff>destroy</on_poweroff> |
|
18 |
- <on_reboot>restart</on_reboot> |
|
19 |
- <on_crash>restart</on_crash> |
|
20 |
- <devices> |
|
21 |
- <emulator>%(emulator)s</emulator> |
|
22 |
- <disk type='file' device='disk'> |
|
23 |
- <driver name='qemu' type='qcow2' cache='writeback'/> |
|
24 |
- <source file='%(imagefile)s'/> |
|
25 |
- <target dev='vda' bus='virtio'/> |
|
26 |
- <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> |
|
27 |
- </disk> |
|
28 |
- <controller type='ide' index='0'> |
|
29 |
- <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> |
|
30 |
- </controller> |
|
31 |
- <interface type='network'> |
|
32 |
- <source network='%(network)s'/> |
|
33 |
- <virtualport type='openvswitch'/> |
|
34 |
- <model type='%(nicdriver)s'/> |
|
35 |
- <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> |
|
36 |
- </interface> |
|
37 |
- <input type='mouse' bus='ps2'/> |
|
38 |
- <graphics type='vnc' port='-1' autoport='yes'/> |
|
39 |
- <video> |
|
40 |
- <model type='cirrus' vram='9216' heads='1'/> |
|
41 |
- <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> |
|
42 |
- </video> |
|
43 |
- %(console_log)s |
|
44 |
- <memballoon model='virtio'> |
|
45 |
- <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> |
|
46 |
- </memballoon> |
|
47 |
- </devices> |
|
48 |
-</domain> |
|
49 |
- |