This moves around a bunch of functionality and attempts to isolate setup
steps into discrete functions (new or existing), making them easier to
consume from outside of Devstack (ie, Grenade).
Change-Id: I480167dcc008506ec2fe8c412db4114b74496e60
| ... | ... |
@@ -102,6 +102,12 @@ function is_ironic_enabled {
|
| 102 | 102 |
|
| 103 | 103 |
# install_ironic() - Collect source and prepare |
| 104 | 104 |
function install_ironic {
|
| 105 |
+ # make sure all needed service were enabled |
|
| 106 |
+ for srv in nova glance key; do |
|
| 107 |
+ if ! is_service_enabled "$srv"; then |
|
| 108 |
+ die $LINENO "$srv should be enabled for Ironic." |
|
| 109 |
+ fi |
|
| 110 |
+ done |
|
| 105 | 111 |
git_clone $IRONIC_REPO $IRONIC_DIR $IRONIC_BRANCH |
| 106 | 112 |
setup_develop $IRONIC_DIR |
| 107 | 113 |
} |
| ... | ... |
@@ -119,11 +125,33 @@ function cleanup_ironic {
|
| 119 | 119 |
sudo rm -rf $IRONIC_AUTH_CACHE_DIR |
| 120 | 120 |
} |
| 121 | 121 |
|
| 122 |
-# configure_ironic() - Set config files, create data dirs, etc |
|
| 123 |
-function configure_ironic {
|
|
| 122 |
+# configure_ironic_dirs() - Create all directories required by Ironic and |
|
| 123 |
+# associated services. |
|
| 124 |
+function configure_ironic_dirs {
|
|
| 124 | 125 |
if [[ ! -d $IRONIC_CONF_DIR ]]; then |
| 125 | 126 |
sudo mkdir -p $IRONIC_CONF_DIR |
| 126 | 127 |
fi |
| 128 |
+ sudo mkdir -p $IRONIC_DATA_DIR |
|
| 129 |
+ sudo mkdir -p $IRONIC_STATE_PATH |
|
| 130 |
+ sudo mkdir -p $IRONIC_TFTPBOOT_DIR |
|
| 131 |
+ sudo chown -R $STACK_USER $IRONIC_DATA_DIR $IRONIC_STATE_PATH |
|
| 132 |
+ sudo chown -R $STACK_USER:$LIBVIRT_GROUP $IRONIC_TFTPBOOT_DIR |
|
| 133 |
+ if is_ubuntu; then |
|
| 134 |
+ local pxebin=/usr/lib/syslinux/pxelinux.0 |
|
| 135 |
+ elif is_fedora; then |
|
| 136 |
+ local pxebin=/usr/share/syslinux/pxelinux.0 |
|
| 137 |
+ fi |
|
| 138 |
+ if [ ! -f $pxebin ]; then |
|
| 139 |
+ die $LINENO "pxelinux.0 (from SYSLINUX) not found." |
|
| 140 |
+ fi |
|
| 141 |
+ |
|
| 142 |
+ cp $pxebin $IRONIC_TFTPBOOT_DIR |
|
| 143 |
+ mkdir -p $IRONIC_TFTPBOOT_DIR/pxelinux.cfg |
|
| 144 |
+} |
|
| 145 |
+ |
|
| 146 |
+# configure_ironic() - Set config files, create data dirs, etc |
|
| 147 |
+function configure_ironic {
|
|
| 148 |
+ configure_ironic_dirs |
|
| 127 | 149 |
sudo chown $STACK_USER $IRONIC_CONF_DIR |
| 128 | 150 |
|
| 129 | 151 |
# Copy over ironic configuration file and configure common parameters. |
| ... | ... |
@@ -147,10 +175,6 @@ function configure_ironic {
|
| 147 | 147 |
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then |
| 148 | 148 |
setup_colorized_logging $IRONIC_CONF_FILE DEFAULT |
| 149 | 149 |
fi |
| 150 |
- |
|
| 151 |
- if [[ "$IRONIC_BAREMETAL_BASIC_OPS" == "True" ]]; then |
|
| 152 |
- configure_ironic_auxiliary |
|
| 153 |
- fi |
|
| 154 | 150 |
} |
| 155 | 151 |
|
| 156 | 152 |
# configure_ironic_api() - Is used by configure_ironic(). Performs |
| ... | ... |
@@ -294,23 +318,33 @@ function is_ironic {
|
| 294 | 294 |
return 1 |
| 295 | 295 |
} |
| 296 | 296 |
|
| 297 |
-function configure_ironic_dirs {
|
|
| 298 |
- sudo mkdir -p $IRONIC_DATA_DIR |
|
| 299 |
- sudo mkdir -p $IRONIC_STATE_PATH |
|
| 300 |
- sudo mkdir -p $IRONIC_TFTPBOOT_DIR |
|
| 301 |
- sudo chown -R $STACK_USER $IRONIC_DATA_DIR $IRONIC_STATE_PATH |
|
| 302 |
- sudo chown -R $STACK_USER:$LIBVIRT_GROUP $IRONIC_TFTPBOOT_DIR |
|
| 303 |
- if is_ubuntu; then |
|
| 304 |
- local pxebin=/usr/lib/syslinux/pxelinux.0 |
|
| 305 |
- elif is_fedora; then |
|
| 306 |
- local pxebin=/usr/share/syslinux/pxelinux.0 |
|
| 307 |
- fi |
|
| 308 |
- if [ ! -f $pxebin ]; then |
|
| 309 |
- die $LINENO "pxelinux.0 (from SYSLINUX) not found." |
|
| 310 |
- fi |
|
| 297 |
+function create_ovs_taps {
|
|
| 298 |
+ local ironic_net_id=$(neutron net-list | grep private | get_field 1) |
|
| 311 | 299 |
|
| 312 |
- cp $pxebin $IRONIC_TFTPBOOT_DIR |
|
| 313 |
- mkdir -p $IRONIC_TFTPBOOT_DIR/pxelinux.cfg |
|
| 300 |
+ # Work around: No netns exists on host until a Neutron port is created. We |
|
| 301 |
+ # need to create one in Neutron to know what netns to tap into prior to the |
|
| 302 |
+ # first node booting. |
|
| 303 |
+ local port_id=$(neutron port-create private | grep " id " | get_field 2) |
|
| 304 |
+ |
|
| 305 |
+ # intentional sleep to make sure the tag has been set to port |
|
| 306 |
+ sleep 10 |
|
| 307 |
+ |
|
| 308 |
+ local tapdev=$(sudo ip netns exec qdhcp-${ironic_net_id} ip link list | grep tap | cut -d':' -f2 | cut -b2-)
|
|
| 309 |
+ local tag_id=$(sudo ovs-vsctl show |grep ${tapdev} -A1 -m1 | grep tag | cut -d':' -f2 | cut -b2-)
|
|
| 310 |
+ |
|
| 311 |
+ # make sure veth pair is not existing, otherwise delete its links |
|
| 312 |
+ sudo ip link show ovs-tap1 && sudo ip link delete ovs-tap1 |
|
| 313 |
+ sudo ip link show brbm-tap1 && sudo ip link delete brbm-tap1 |
|
| 314 |
+ # create veth pair for future interconnection between br-int and brbm |
|
| 315 |
+ sudo ip link add brbm-tap1 type veth peer name ovs-tap1 |
|
| 316 |
+ sudo ip link set dev brbm-tap1 up |
|
| 317 |
+ sudo ip link set dev ovs-tap1 up |
|
| 318 |
+ |
|
| 319 |
+ sudo ovs-vsctl -- --if-exists del-port ovs-tap1 -- add-port br-int ovs-tap1 tag=$tag_id |
|
| 320 |
+ sudo ovs-vsctl -- --if-exists del-port brbm-tap1 -- add-port $IRONIC_VM_NETWORK_BRIDGE brbm-tap1 |
|
| 321 |
+ |
|
| 322 |
+ # Remove the port needed only for workaround. |
|
| 323 |
+ neutron port-delete $port_id |
|
| 314 | 324 |
} |
| 315 | 325 |
|
| 316 | 326 |
function create_bridge_and_vms {
|
| ... | ... |
@@ -325,24 +359,13 @@ function create_bridge_and_vms {
|
| 325 | 325 |
$IRONIC_VM_SPECS_CPU $IRONIC_VM_SPECS_RAM $IRONIC_VM_SPECS_DISK \ |
| 326 | 326 |
amd64 $IRONIC_VM_COUNT $IRONIC_VM_NETWORK_BRIDGE $IRONIC_VM_EMULATOR \ |
| 327 | 327 |
$log_arg" >> $IRONIC_VM_MACS_CSV_FILE |
| 328 |
+ create_ovs_taps |
|
| 328 | 329 |
} |
| 329 | 330 |
|
| 330 | 331 |
function enroll_vms {
|
| 331 |
- |
|
| 332 | 332 |
local chassis_id=$(ironic chassis-create -d "ironic test chassis" | grep " uuid " | get_field 2) |
| 333 |
- local ironic_net_id=$(neutron net-list | grep private | get_field 1) |
|
| 334 | 333 |
local idx=0 |
| 335 |
- |
|
| 336 |
- # work around; need to know what netns neutron uses for private network. |
|
| 337 |
- # Without knowing how to interconnect the networks, PXE won't work properly |
|
| 338 |
- # for fake baremetal instances. The network should be configured prior all |
|
| 339 |
- # the instances operation. If we don't do this, the first port creation |
|
| 340 |
- # only happens in the middle of fake baremetal instance's spawning by nova, |
|
| 341 |
- # so we'll end up with unbootable fake baremetal VM due to broken PXE. |
|
| 342 |
- local port_id=$(neutron port-create private | grep " id " | get_field 2) |
|
| 343 |
- |
|
| 344 | 334 |
while read MAC; do |
| 345 |
- |
|
| 346 | 335 |
local node_id=$(ironic node-create --chassis_uuid $chassis_id --driver pxe_ssh \ |
| 347 | 336 |
-i pxe_deploy_kernel=$IRONIC_DEPLOY_KERNEL_ID \ |
| 348 | 337 |
-i pxe_deploy_ramdisk=$IRONIC_DEPLOY_RAMDISK_ID \ |
| ... | ... |
@@ -360,7 +383,6 @@ function enroll_vms {
|
| 360 | 360 |
ironic port-create --address $MAC --node_uuid $node_id |
| 361 | 361 |
|
| 362 | 362 |
idx=$((idx+1)) |
| 363 |
- |
|
| 364 | 363 |
done < $IRONIC_VM_MACS_CSV_FILE |
| 365 | 364 |
|
| 366 | 365 |
# create the nova flavor |
| ... | ... |
@@ -371,26 +393,6 @@ function enroll_vms {
|
| 371 | 371 |
# from the flavor after the completion of |
| 372 | 372 |
# https://blueprints.launchpad.net/ironic/+spec/add-node-instance-info |
| 373 | 373 |
nova flavor-key baremetal set "cpu_arch"="x86_64" "baremetal:deploy_kernel_id"="$IRONIC_DEPLOY_KERNEL_ID" "baremetal:deploy_ramdisk_id"="$IRONIC_DEPLOY_RAMDISK_ID" |
| 374 |
- |
|
| 375 |
- # intentional sleep to make sure the tag has been set to port |
|
| 376 |
- sleep 10 |
|
| 377 |
- local tapdev=$(sudo ip netns exec qdhcp-${ironic_net_id} ip link list | grep tap | cut -d':' -f2 | cut -b2-)
|
|
| 378 |
- local tag_id=$(sudo ovs-vsctl show |grep ${tapdev} -A1 -m1 | grep tag | cut -d':' -f2 | cut -b2-)
|
|
| 379 |
- |
|
| 380 |
- # make sure veth pair is not existing, otherwise delete its links |
|
| 381 |
- sudo ip link show ovs-tap1 && sudo ip link delete ovs-tap1 |
|
| 382 |
- sudo ip link show brbm-tap1 && sudo ip link delete brbm-tap1 |
|
| 383 |
- # create veth pair for future interconnection between br-int and brbm |
|
| 384 |
- sudo ip link add brbm-tap1 type veth peer name ovs-tap1 |
|
| 385 |
- sudo ip link set dev brbm-tap1 up |
|
| 386 |
- sudo ip link set dev ovs-tap1 up |
|
| 387 |
- |
|
| 388 |
- sudo ovs-vsctl -- --if-exists del-port ovs-tap1 -- add-port br-int ovs-tap1 tag=$tag_id |
|
| 389 |
- sudo ovs-vsctl -- --if-exists del-port brbm-tap1 -- add-port $IRONIC_VM_NETWORK_BRIDGE brbm-tap1 |
|
| 390 |
- |
|
| 391 |
- # Remove the port needed only for workaround. For additional info read the |
|
| 392 |
- # comment at the beginning of this function |
|
| 393 |
- neutron port-delete $port_id |
|
| 394 | 374 |
} |
| 395 | 375 |
|
| 396 | 376 |
function configure_iptables {
|
| ... | ... |
@@ -452,7 +454,6 @@ function ironic_ssh_check {
|
| 452 | 452 |
} |
| 453 | 453 |
|
| 454 | 454 |
function configure_ironic_auxiliary {
|
| 455 |
- configure_ironic_dirs |
|
| 456 | 455 |
configure_ironic_ssh_keypair |
| 457 | 456 |
ironic_ssh_check $IRONIC_SSH_KEY_DIR/$IRONIC_SSH_KEY_FILENAME $IRONIC_VM_SSH_ADDRESS $IRONIC_VM_SSH_PORT $IRONIC_SSH_USERNAME 10 |
| 458 | 457 |
} |
| ... | ... |
@@ -460,8 +461,11 @@ function configure_ironic_auxiliary {
|
| 460 | 460 |
# build deploy kernel+ramdisk, then upload them to glance |
| 461 | 461 |
# this function sets ``IRONIC_DEPLOY_KERNEL_ID``, ``IRONIC_DEPLOY_RAMDISK_ID`` |
| 462 | 462 |
function upload_baremetal_ironic_deploy {
|
| 463 |
- local token=$1 |
|
| 464 | 463 |
declare -g IRONIC_DEPLOY_KERNEL_ID IRONIC_DEPLOY_RAMDISK_ID |
| 464 |
+ echo_summary "Creating and uploading baremetal images for ironic" |
|
| 465 |
+ |
|
| 466 |
+ # install diskimage-builder |
|
| 467 |
+ git_clone $DIB_REPO $DIB_DIR $DIB_BRANCH |
|
| 465 | 468 |
|
| 466 | 469 |
if [ -z "$IRONIC_DEPLOY_KERNEL" -o -z "$IRONIC_DEPLOY_RAMDISK" ]; then |
| 467 | 470 |
local IRONIC_DEPLOY_KERNEL_PATH=$TOP_DIR/files/ir-deploy.kernel |
| ... | ... |
@@ -486,6 +490,9 @@ function upload_baremetal_ironic_deploy {
|
| 486 | 486 |
fi |
| 487 | 487 |
fi |
| 488 | 488 |
|
| 489 |
+ local token=$(keystone token-get | grep ' id ' | get_field 2) |
|
| 490 |
+ die_if_not_set $LINENO token "Keystone fail to get token" |
|
| 491 |
+ |
|
| 489 | 492 |
# load them into glance |
| 490 | 493 |
IRONIC_DEPLOY_KERNEL_ID=$(glance \ |
| 491 | 494 |
--os-auth-token $token \ |
| ... | ... |
@@ -504,35 +511,12 @@ function upload_baremetal_ironic_deploy {
|
| 504 | 504 |
} |
| 505 | 505 |
|
| 506 | 506 |
function prepare_baremetal_basic_ops {
|
| 507 |
- |
|
| 508 |
- # install diskimage-builder |
|
| 509 |
- git_clone $DIB_REPO $DIB_DIR $DIB_BRANCH |
|
| 510 |
- |
|
| 511 |
- # make sure all needed service were enabled |
|
| 512 |
- local srv |
|
| 513 |
- for srv in nova glance key neutron; do |
|
| 514 |
- if ! is_service_enabled "$srv"; then |
|
| 515 |
- die $LINENO "$srv should be enabled for ironic tests" |
|
| 516 |
- fi |
|
| 517 |
- done |
|
| 518 |
- |
|
| 519 |
- local token=$(keystone token-get | grep ' id ' | get_field 2) |
|
| 520 |
- die_if_not_set $LINENO token "Keystone fail to get token" |
|
| 521 |
- |
|
| 522 |
- echo_summary "Creating and uploading baremetal images for ironic" |
|
| 523 |
- |
|
| 524 |
- # build and upload separate deploy kernel & ramdisk |
|
| 525 |
- upload_baremetal_ironic_deploy $token |
|
| 526 |
- |
|
| 507 |
+ upload_baremetal_ironic_deploy |
|
| 527 | 508 |
create_bridge_and_vms |
| 528 | 509 |
enroll_vms |
| 529 | 510 |
configure_tftpd |
| 530 | 511 |
configure_iptables |
| 531 |
- |
|
| 532 |
- # restart nova-compute to ensure its resource tracking is up to |
|
| 533 |
- # date with newly enrolled nodes |
|
| 534 |
- stop_nova_compute || true |
|
| 535 |
- start_nova_compute |
|
| 512 |
+ configure_ironic_auxiliary |
|
| 536 | 513 |
} |
| 537 | 514 |
|
| 538 | 515 |
function cleanup_baremetal_basic_ops {
|
| ... | ... |
@@ -56,6 +56,9 @@ function configure_nova_hypervisor {
|
| 56 | 56 |
|
| 57 | 57 |
# install_nova_hypervisor() - Install external components |
| 58 | 58 |
function install_nova_hypervisor {
|
| 59 |
+ if ! is_service_enabled neutron; then |
|
| 60 |
+ die $LINENO "Neutron should be enabled for usage of the Ironic Nova driver." |
|
| 61 |
+ fi |
|
| 59 | 62 |
install_libvirt |
| 60 | 63 |
} |
| 61 | 64 |
|