From 3b28cfbb7075e5101eff542971f2e5b691d1ef75 Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Fri, 17 Jul 2015 12:53:19 +0000 Subject: [PATCH 01/26] Add revert function lib --- octane/lib/revert.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 octane/lib/revert.sh diff --git a/octane/lib/revert.sh b/octane/lib/revert.sh new file mode 100644 index 00000000..f56f7265 --- /dev/null +++ b/octane/lib/revert.sh @@ -0,0 +1,60 @@ +# vim: syntax=sh +REVERT_PATH="$(readlink -e "$BASH_SOURCE")" +OCTANE_PATH="$(readlink -e "$(dirname "$REVERT_PATH")/..")" + +## functions + +revert_prepare_osd_upgrade () { + local env_id + local cic_node + [ -z "$1" ] && die "No node ID provided, exiting" + env_id=$(get_env_by_node $1) + cic_node=$(list_nodes $env_id 'controller' | head -1) + [ -z "$(ssh root@$cic_node ceph health | grep HEALTH_OK)" ] && \ + die "Ceph cluster is unhealthy, exiting" + ssh root@$ctrl ceph osd unset noout + revert_pman_udate_node node-$1 +} + +revert_prepare_fuel () { + revert_prepare_osd_upgrade + revert_patch_fuel_components puppet + revert_all_patches +} + +revert_deployment_tasks() { + [ -z "$1" ] && die "No environment ID provided, exiting" + [ -d "$FUEL_CACHE" ] && + [ -d "${FUEL_CACHE}/cluster_$1" ] && + cp -pR "${FUEL_CACHE}/cluster_$1.orig" "${FUEL_CACHE}/cluster_$1" +} + +restore_default_gateway() { + [ -z "$1" ] && die "No node ID provided, exiting" + local env_id=$(get_env_by_node $1) + local nodefile=$(ls ${FUEL_CACHE}/deployment_${env_id}/*_$1.yaml | head -1) + local gw_ip=$(python -c "import yaml; +with open('"${nodefile}"') as f: + config = yaml.safe_load(f) + ints = config['network_scheme']['endpoints'] + print ints['br-ex']['gateway']") + ssh root@node-$1 "ip route delete default; + ip route add default via $gw_ip" + done +} + +revert_patch_fuel_components() { + local cmp + [ -z "$1" ] && die "No component name provided, exiting" + for cmp in "$@"; + do + [ -d "$PATCH_DIR/$cmp" ] || die "No dir for component $cmp, exiting" + pushd "$PATCH_DIR/$cmp" + [ -x "./revert.sh" ] && ./revert.sh + popd + done +} + +function revert_all_patches() { + PATCH_EXTRA_ARGS="-R" patch_all_containers +} From ea5e8e512b19663dc91bc480cd714f999a437a80 Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Fri, 17 Jul 2015 12:55:43 +0000 Subject: [PATCH 02/26] Uninstall octane fuelclient --- octane/lib/docker.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/octane/lib/docker.sh b/octane/lib/docker.sh index 9ec680f5..8d0fc808 100644 --- a/octane/lib/docker.sh +++ b/octane/lib/docker.sh @@ -106,6 +106,11 @@ function install_octane_fuelclient() { pip install -U ${OCTANE_FUELCLIENT} } +function uninstall_octane_fuelclient() { + local OCTANE_FUELCLIENT="${CWD}/../octane_fuelclient" + pip uninstall ${OCTANE_FUELCLIENT} +} + function patch_all_containers() { docker_patch astute /usr/lib64/ruby/gems/2.1.0/gems/astute-6.1.0/lib/astute ${CWD}/docker/astute/resources/deploy_actions.rb.patch shell_container astute supervisorctl restart astute @@ -113,9 +118,3 @@ function patch_all_containers() { docker_patch nailgun /usr/lib/python2.6/site-packages/nailgun/volumes ${CWD}/docker/nailgun/resources/manager.py.patch docker_patch nailgun / ${CWD}/../octane_nailgun/tools/urls.py.patch } - -function revert_all_patches() { - PATCH_EXTRA_ARGS="-R" patch_all_containers -} - - From 8b38dc36497f9d18e781649226172172bf28e80c Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Fri, 17 Jul 2015 12:59:32 +0000 Subject: [PATCH 03/26] Backup deployment tasks to restore in revert stage --- octane/lib/functions.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/octane/lib/functions.sh b/octane/lib/functions.sh index 541dc386..b49b737b 100644 --- a/octane/lib/functions.sh +++ b/octane/lib/functions.sh @@ -53,6 +53,13 @@ upload_deployment_info() { fuel deployment --env $1 --upload --dir $FUEL_CACHE } +backup_deployment_tasks() { + [ -z "$1" ] && die "No environment ID provided, exiting" + [ -d "$FUEL_CACHE" ] && + [ -d "${FUEL_CACHE}/cluster_$1" ] && + cp -pR "${FUEL_CACHE}/cluster_$1" "${FUEL_CACHE}/cluster_$1.orig" +} + upload_deployment_tasks() { [ -z "$1" ] && die "No environment ID provided, exiting" [ -d "$FUEL_CACHE" ] && From c0559fd7c36c6db99659bd2c58d7c85d9d5d87c1 Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Fri, 17 Jul 2015 13:04:08 +0000 Subject: [PATCH 04/26] restore gw fixup --- octane/lib/functions.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/octane/lib/functions.sh b/octane/lib/functions.sh index b49b737b..8acdadaf 100644 --- a/octane/lib/functions.sh +++ b/octane/lib/functions.sh @@ -497,6 +497,7 @@ upgrade_node() { ;; esac done + restore_default_gateway $2 } upgrade_cics() { From fca782dd8521ce155b46e63301060643802717a4 Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Fri, 17 Jul 2015 13:04:38 +0000 Subject: [PATCH 05/26] Add cleanup-fuel command to octane script --- octane/bin/octane | 4 ++++ octane/lib/functions.sh | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/octane/bin/octane b/octane/bin/octane index 3c864461..e813db22 100755 --- a/octane/bin/octane +++ b/octane/bin/octane @@ -22,6 +22,7 @@ upgrade-node ENV_ID to Management and Public networks cleanup ENV_ID - delete data about original environment from upgraded OpenStack cloud +cleanup-fuel - revert changes on the Fuel Master help - display this message and exit" } @@ -68,6 +69,9 @@ case $1 in cleanup_nova_services $2 cleanup_neutron_services $2 ;; + cleanup-fuel) + cleanup_fuel + ;; help) usage ;; diff --git a/octane/lib/functions.sh b/octane/lib/functions.sh index 8acdadaf..6d2e4b11 100644 --- a/octane/lib/functions.sh +++ b/octane/lib/functions.sh @@ -604,3 +604,7 @@ delete_fuel_resources() { | tr \"='\" ' ' | awk '{print \$3}') \$(. openrc; \\ keystone endpoint-list | egrep ':5000' | awk '{print \$6}')" } + +cleanup_fuel() { + revert_prepare_fuel +} From 104d69a9882be61105ceb93ef215579ef42edecf Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Fri, 17 Jul 2015 18:38:04 +0000 Subject: [PATCH 06/26] Use revert.sh library in script env --- octane/bin/env | 1 + 1 file changed, 1 insertion(+) diff --git a/octane/bin/env b/octane/bin/env index 9e1a9e54..503d601a 100644 --- a/octane/bin/env +++ b/octane/bin/env @@ -19,3 +19,4 @@ export PATCH_DIR="$CWD/patches" . ${LIBPATH}/patch.sh . ${LIBPATH}/docker.sh . ${LIBPATH}/ceph.sh +. ${LIBPATH}/revert.sh From 23179a643fd332df6977ae55e6871749b861cda3 Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Fri, 17 Jul 2015 19:06:44 +0000 Subject: [PATCH 07/26] [docs] Add 'cleanup-fuel' command to README file --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ad9e620d..02c1e3c9 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ Repeat this process until all nodes are reassigned from 5.1.1 to 6.1 environment ## Finish upgrade -### Cleanup 6.1 environment +### Clean up 6.1 environment Run Octane script with 'cleanup' command to delete pending services data from state database. @@ -154,3 +154,12 @@ state database. ``` [root@fuel bin]# ./octane cleanup ``` + +### Clean up the Fuel Master node + +Run 'cleanup-fuel' command to revert all changes made to components of the Fuel +installer and uninstall temporary packages. + +``` +[root@fuel bin]# ./octane cleanup-fuel +``` From 39f45455b6ee718d91a1ce07c1f5bea6850e5ba9 Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Wed, 29 Jul 2015 11:19:51 +0000 Subject: [PATCH 08/26] Retry update of nova service tenant ID in neutron server config --- octane/lib/functions.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/octane/lib/functions.sh b/octane/lib/functions.sh index 2ca7bbf9..d50b5997 100644 --- a/octane/lib/functions.sh +++ b/octane/lib/functions.sh @@ -581,15 +581,19 @@ upgrade_ceph() { } neutron_update_admin_tenant_id() { - local cic_node - local tenant_id + local tenant_id='' [ -z "$1" ] && die "No env ID provided, exiting" cic_node=$(list_nodes $1 controller | head -1) - tenant_id=$(ssh root@$cic_node ". openrc; keystone tenant-get services" \ - | awk -F\| '$2 ~ /id/{print $3}' | tr -d \ ) + while [ -z "$tenant_id" ]; do + tenant_id=$(ssh root@$cic_node ". openrc; +keystone tenant-get services \ +| awk -F\| '$2 ~ /id/{print $3}' | tr -d \ ") + sleep 3 + done list_nodes $1 controller | xargs -I{} ssh root@{} \ - "sed -re 's/^(nova_admin_tenant_id )=.*/\1 = $tenant_id/' -i /etc/neutron/neutron.conf; - restart neutron-server" + "sed -re 's/^(nova_admin_tenant_id )=.*/\1 = $tenant_id/' \ +-i /etc/neutron/neutron.conf; +restart neutron-server" } cleanup_nova_services() { From cdb7de6a6cc8d4d27abf893b5dc0547bff9a325f Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Thu, 30 Jul 2015 10:11:02 +0000 Subject: [PATCH 09/26] Improve logic to wait for migration of all VMs --- octane/bin/host_evacuation.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/octane/bin/host_evacuation.sh b/octane/bin/host_evacuation.sh index 014620e8..a270a837 100755 --- a/octane/bin/host_evacuation.sh +++ b/octane/bin/host_evacuation.sh @@ -20,12 +20,19 @@ nova service-list | grep -q 'nova-compute.*enabled' || { exit 3 } -nova list --host $1 | grep ' ACTIVE ' | cut -d\| -f3 | sed -r 's/(^[ ]+?|[ ]+?$)//g' | xargs -tI% nova live-migration % - while :; do - VMS=$(nova list --host $1 | wc -l) - if [ $VMS -eq 4 ]; then - break + VMS=$(nova list --host $1 | grep -i ' active ' | wc -l) + if [ $VMS -ne 0 ]; then + for VM in $(nova list --host $1 | grep ' ACTIVE ' \ + | cut -d\| -f3 | sed -r 's/(^[ ]+?|[ ]+?$)//g'); do + nova live-migration $VM + done + else + VMS=$(nova list --host $1 | grep -i ' migrating ' | wc -l) + if [ $VMS -ne 0 ]; then + sleep 30 + else + echo "All VMs migrated" && exit 0 + fi fi - sleep 30 done From 34dab55733de4fffd9d6911f10ab34d14366488b Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Wed, 29 Jul 2015 16:34:07 +0000 Subject: [PATCH 10/26] Set proper ownership on ceph.conf after mktmp --- octane/lib/ceph.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/octane/lib/ceph.sh b/octane/lib/ceph.sh index c985bf68..530d0f22 100644 --- a/octane/lib/ceph.sh +++ b/octane/lib/ceph.sh @@ -148,7 +148,7 @@ prepare_ceph_osd_upgrade() { ssh root@$node sh -c "' f=\$(mktemp) awk -f /dev/stdin /etc/ceph/ceph.conf > \$f - mv \$f /etc/ceph/ceph.conf + chmod 644 \$f && mv \$f /etc/ceph/ceph.conf '" < Date: Thu, 30 Jul 2015 14:38:16 +0000 Subject: [PATCH 11/26] Escape awk vars in function to update neutron config with service tenant id --- octane/lib/functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/octane/lib/functions.sh b/octane/lib/functions.sh index d50b5997..0fc25b51 100644 --- a/octane/lib/functions.sh +++ b/octane/lib/functions.sh @@ -587,7 +587,7 @@ neutron_update_admin_tenant_id() { while [ -z "$tenant_id" ]; do tenant_id=$(ssh root@$cic_node ". openrc; keystone tenant-get services \ -| awk -F\| '$2 ~ /id/{print $3}' | tr -d \ ") +| awk -F\| '\$2 ~ /id/{print \$3}' | tr -d \ ") sleep 3 done list_nodes $1 controller | xargs -I{} ssh root@{} \ From 8741b82ad6f171de91e2902f970c3bfc1e40323c Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Fri, 31 Jul 2015 08:32:33 +0000 Subject: [PATCH 12/26] Delete obsolete revert prepare osd upgrade function --- octane/lib/revert.sh | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/octane/lib/revert.sh b/octane/lib/revert.sh index f56f7265..b9c71585 100644 --- a/octane/lib/revert.sh +++ b/octane/lib/revert.sh @@ -4,20 +4,7 @@ OCTANE_PATH="$(readlink -e "$(dirname "$REVERT_PATH")/..")" ## functions -revert_prepare_osd_upgrade () { - local env_id - local cic_node - [ -z "$1" ] && die "No node ID provided, exiting" - env_id=$(get_env_by_node $1) - cic_node=$(list_nodes $env_id 'controller' | head -1) - [ -z "$(ssh root@$cic_node ceph health | grep HEALTH_OK)" ] && \ - die "Ceph cluster is unhealthy, exiting" - ssh root@$ctrl ceph osd unset noout - revert_pman_udate_node node-$1 -} - revert_prepare_fuel () { - revert_prepare_osd_upgrade revert_patch_fuel_components puppet revert_all_patches } From ecb1239e52d53543f379dcb739ae25129265dcc1 Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Fri, 31 Jul 2015 08:43:57 +0000 Subject: [PATCH 13/26] Typo 'done' without loop in lib/revert.sh --- octane/lib/revert.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/octane/lib/revert.sh b/octane/lib/revert.sh index b9c71585..1188d81d 100644 --- a/octane/lib/revert.sh +++ b/octane/lib/revert.sh @@ -27,7 +27,6 @@ with open('"${nodefile}"') as f: print ints['br-ex']['gateway']") ssh root@node-$1 "ip route delete default; ip route add default via $gw_ip" - done } revert_patch_fuel_components() { From 0b8d7a9bb6c3ce1528d2585f35ca1cb18b970af0 Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Fri, 31 Jul 2015 11:20:11 +0000 Subject: [PATCH 14/26] Determine original gw based on backup information --- octane/lib/revert.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/octane/lib/revert.sh b/octane/lib/revert.sh index 1188d81d..08773312 100644 --- a/octane/lib/revert.sh +++ b/octane/lib/revert.sh @@ -19,7 +19,7 @@ revert_deployment_tasks() { restore_default_gateway() { [ -z "$1" ] && die "No node ID provided, exiting" local env_id=$(get_env_by_node $1) - local nodefile=$(ls ${FUEL_CACHE}/deployment_${env_id}/*_$1.yaml | head -1) + local nodefile=$(ls ${FUEL_CACHE}/deployment_${env_id}.orig/*_$1.yaml | head -1) local gw_ip=$(python -c "import yaml; with open('"${nodefile}"') as f: config = yaml.safe_load(f) From 5706f02c08cfa1dc5d175b7b88fc72be66ab9da4 Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Fri, 31 Jul 2015 13:34:35 +0000 Subject: [PATCH 15/26] Restore default gw only for primary contorller in 6.1 --- octane/lib/functions.sh | 6 ++++-- octane/lib/revert.sh | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/octane/lib/functions.sh b/octane/lib/functions.sh index 374bb242..317b404e 100644 --- a/octane/lib/functions.sh +++ b/octane/lib/functions.sh @@ -512,7 +512,9 @@ upgrade_node_postdeploy() { ;; esac done - restore_default_gateway $2 + if [ "$3" =~ isolated ]; then + restore_default_gateway $2 + fi } upgrade_node() { @@ -534,7 +536,7 @@ upgrade_node() { done env_action $env deploy "$@" for n in $@; do - upgrade_node_postdeploy $env $n + upgrade_node_postdeploy $env $n $isolated done } diff --git a/octane/lib/revert.sh b/octane/lib/revert.sh index 08773312..fa2040ea 100644 --- a/octane/lib/revert.sh +++ b/octane/lib/revert.sh @@ -25,6 +25,8 @@ with open('"${nodefile}"') as f: config = yaml.safe_load(f) ints = config['network_scheme']['endpoints'] print ints['br-ex']['gateway']") + [ -z "$gw_ip" ] && return + [[ "$gw_ip" =~ none ]] && return ssh root@node-$1 "ip route delete default; ip route add default via $gw_ip" } From ecac7a51695c012c93e7ad38ed7562f57a400108 Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Sun, 2 Aug 2015 18:49:40 +0000 Subject: [PATCH 16/26] Set admin tenant id in neutron config in post-deploy stage on contollers --- octane/lib/functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/octane/lib/functions.sh b/octane/lib/functions.sh index 317b404e..f181e957 100644 --- a/octane/lib/functions.sh +++ b/octane/lib/functions.sh @@ -509,6 +509,7 @@ upgrade_node_postdeploy() { unset_osd_noout $1 ;; controller) + neutron_update_admin_tenant_id $1 ;; esac done @@ -559,7 +560,6 @@ upgrade_cics() { do create_patch_ports $2 $br_name done - neutron_update_admin_tenant_id $2 list_nodes $1 compute | xargs -I{} ${BINPATH}/upgrade-nova-compute.sh {} } From afbcb5c25c12a21fb0e1aad4bce182820c9392e2 Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Mon, 3 Aug 2015 09:15:02 +0000 Subject: [PATCH 17/26] Store ID of the service tenant in global var --- octane/bin/env | 1 + octane/lib/functions.sh | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/octane/bin/env b/octane/bin/env index 503d601a..44296ad4 100644 --- a/octane/bin/env +++ b/octane/bin/env @@ -10,6 +10,7 @@ export BINPATH="$CWD/bin" export LIBPATH="$CWD/lib" export HELPER_PATH="$CWD/helpers" export PATCH_DIR="$CWD/patches" +export SERVICE_TENANT_ID="" . ${LIBPATH}/utils.sh . ${LIBPATH}/nailgundb.sh diff --git a/octane/lib/functions.sh b/octane/lib/functions.sh index f181e957..b99efbaf 100644 --- a/octane/lib/functions.sh +++ b/octane/lib/functions.sh @@ -25,9 +25,22 @@ clone_env() { set_cobbler_provision $seed_id upload_cluster_settings $seed_id } > /dev/null +#Required for updating tenant ID in Neutron config on 6.1 + get_service_tenant_id $1 echo $seed_id } +get_service_tenant_id() { + [ -z "$1" ] && die "No environment ID provided, exiting" + local cic_node=$(list_nodes $1 controller | head -1) + SERVICE_TENANT_ID=$(ssh root@$cic_node ". openrc; +keystone tenant-get services \ +| awk -F\| '\$2 ~ /id/{print \$3}' | tr -d \ ") + [ -z "$SERVICE_TENANT_ID" ] && + die "Cannot determine service tenant ID for env $1, exiting" +} + + get_deployment_info() { local cmd # Download deployment config from Fuel master for environment ENV to subdir in @@ -594,14 +607,8 @@ neutron_update_admin_tenant_id() { local tenant_id='' [ -z "$1" ] && die "No env ID provided, exiting" cic_node=$(list_nodes $1 controller | head -1) - while [ -z "$tenant_id" ]; do - tenant_id=$(ssh root@$cic_node ". openrc; -keystone tenant-get services \ -| awk -F\| '\$2 ~ /id/{print \$3}' | tr -d \ ") - sleep 3 - done list_nodes $1 controller | xargs -I{} ssh root@{} \ - "sed -re 's/^(nova_admin_tenant_id )=.*/\1 = $tenant_id/' \ + "sed -re 's/^(nova_admin_tenant_id )=.*/\1 = $SERVICE_TENANT_ID/' \ -i /etc/neutron/neutron.conf; restart neutron-server" } From e7006dccd380e8d3616b7f4b84aaa8394848eab3 Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Mon, 3 Aug 2015 11:35:50 +0000 Subject: [PATCH 18/26] Export service tenant id var --- octane/lib/functions.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/octane/lib/functions.sh b/octane/lib/functions.sh index b99efbaf..18cae47e 100644 --- a/octane/lib/functions.sh +++ b/octane/lib/functions.sh @@ -38,6 +38,7 @@ keystone tenant-get services \ | awk -F\| '\$2 ~ /id/{print \$3}' | tr -d \ ") [ -z "$SERVICE_TENANT_ID" ] && die "Cannot determine service tenant ID for env $1, exiting" + export SERVICE_TENANT_ID } From 6cb46c53f0743a2b6bc3024f3f0b9ef2bfaaa1a4 Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Wed, 5 Aug 2015 12:27:49 +0000 Subject: [PATCH 19/26] Support for tagged interfaces when restore patch ports --- octane/helpers/transformations.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/octane/helpers/transformations.py b/octane/helpers/transformations.py index 4f8a466b..44064b3f 100644 --- a/octane/helpers/transformations.py +++ b/octane/helpers/transformations.py @@ -125,15 +125,24 @@ def lnx_add_port(actions, bridge): def ovs_add_patch_ports(actions, bridge): for action in actions: if (action.get("action") == "add-patch" and - bridge in action.get("bridges")): - bridges = action.get("bridges") + bridge in action.get("bridges", [])): + bridges = action.get("bridges", []) + tags = action.get("tags", ["", ""]) + trunks = action.get("trunks", []) + for tag in tags: + tag = "tag={0}".format(str(tag)) if tag + trunk_str = ",".join(trunks) + if trunk_str: + trunk_param = "trunks=[{0}]".format(trunk_str) if bridges: - return ["ovs-vsctl add-port {0} {0}--{1} " + return ["ovs-vsctl add-port {0} {0}--{1} {3} {4}" "-- set interface {0}--{1} type=patch " - "options:peer={1}--{0}".format(bridges[0], bridges[1]), - "ovs-vsctl add-port {1} {1}--{0} " + "options:peer={1}--{0}" + .format(bridges[0], bridges[1], tags[0], trunk_param), + "ovs-vsctl add-port {1} {1}--{0} {3} {4}" "-- set interface {1}--{0} type=patch " - "options:peer={0}--{1}".format(bridges[0], bridges[1])] + "options:peer={0}--{1}" + .format(bridges[0], bridges[1], tags[1], trunk_param)] def main(): From 21967caea38994e8a1f3cf589386e501fa4d560c Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Wed, 5 Aug 2015 13:19:13 +0000 Subject: [PATCH 20/26] Check that arg is equal 'isolated', not includes it in post-deploy for controller --- octane/lib/functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/octane/lib/functions.sh b/octane/lib/functions.sh index 18cae47e..927efa50 100644 --- a/octane/lib/functions.sh +++ b/octane/lib/functions.sh @@ -527,7 +527,7 @@ upgrade_node_postdeploy() { ;; esac done - if [ "$3" =~ isolated ]; then + if [ "$3" == "isolated" ]]; then restore_default_gateway $2 fi } From f4de3330ad8901d199f200813dce1ed399431456 Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Thu, 6 Aug 2015 13:03:38 +0000 Subject: [PATCH 21/26] Extra bracket typo --- octane/lib/functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/octane/lib/functions.sh b/octane/lib/functions.sh index 927efa50..e3f9c7e9 100644 --- a/octane/lib/functions.sh +++ b/octane/lib/functions.sh @@ -527,7 +527,7 @@ upgrade_node_postdeploy() { ;; esac done - if [ "$3" == "isolated" ]]; then + if [ "$3" == "isolated" ]; then restore_default_gateway $2 fi } From 5f67a6484ee9bbf30b944c2170a7e458cc373879 Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Thu, 6 Aug 2015 14:21:02 +0000 Subject: [PATCH 22/26] Syntax error in if statement --- octane/helpers/transformations.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/octane/helpers/transformations.py b/octane/helpers/transformations.py index 44064b3f..b9e65c5b 100644 --- a/octane/helpers/transformations.py +++ b/octane/helpers/transformations.py @@ -130,7 +130,8 @@ def ovs_add_patch_ports(actions, bridge): tags = action.get("tags", ["", ""]) trunks = action.get("trunks", []) for tag in tags: - tag = "tag={0}".format(str(tag)) if tag + if tag: + tag = "tag={0}".format(str(tag)) trunk_str = ",".join(trunks) if trunk_str: trunk_param = "trunks=[{0}]".format(trunk_str) From 1f3a8495a4e7e01f57e3ed3076494978aec09f67 Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Thu, 6 Aug 2015 20:11:51 +0000 Subject: [PATCH 23/26] Cache service tenant id to update neutron config --- octane/lib/functions.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/octane/lib/functions.sh b/octane/lib/functions.sh index e3f9c7e9..5f5b1708 100644 --- a/octane/lib/functions.sh +++ b/octane/lib/functions.sh @@ -25,20 +25,23 @@ clone_env() { set_cobbler_provision $seed_id upload_cluster_settings $seed_id } > /dev/null -#Required for updating tenant ID in Neutron config on 6.1 - get_service_tenant_id $1 echo $seed_id } get_service_tenant_id() { - [ -z "$1" ] && die "No environment ID provided, exiting" - local cic_node=$(list_nodes $1 controller | head -1) - SERVICE_TENANT_ID=$(ssh root@$cic_node ". openrc; + [ -z "$1" ] && die "No node ID provided, exiting" + local env=$(get_env_by_node $1) + local filename="${FUEL_CACHE}/env-${env}-service-tenant-id" + if [ -f "$filename" ]; then + SERVICE_TENANT_ID=$(cat $filename) + else + SERVICE_TENANT_ID=$(ssh root@$(get_host_ip_by_node_id $1) ". openrc; keystone tenant-get services \ | awk -F\| '\$2 ~ /id/{print \$3}' | tr -d \ ") + fi [ -z "$SERVICE_TENANT_ID" ] && - die "Cannot determine service tenant ID for env $1, exiting" - export SERVICE_TENANT_ID + die "Cannot determine service tenant ID for node $1, exiting" + echo $SERVICE_TENANT_ID > $filename } @@ -441,6 +444,8 @@ cleanup_compute_upgrade() { prepare_controller_upgrade() { [ -z "$1" ] && die "No 6.0 env and node ID provided, exiting" [ -z "$2" ] && die "No node ID provided, exiting" + #Required for updating tenant ID in Neutron config on 6.1 + get_service_tenant_id $1 } upgrade_node_preprovision() { From 5f92160237f2afd15ac694d36032d5c631622f6e Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Fri, 7 Aug 2015 08:19:59 +0000 Subject: [PATCH 24/26] Pass node ID to get tenant id function --- octane/lib/functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/octane/lib/functions.sh b/octane/lib/functions.sh index 5f5b1708..9671d6d8 100644 --- a/octane/lib/functions.sh +++ b/octane/lib/functions.sh @@ -445,7 +445,7 @@ prepare_controller_upgrade() { [ -z "$1" ] && die "No 6.0 env and node ID provided, exiting" [ -z "$2" ] && die "No node ID provided, exiting" #Required for updating tenant ID in Neutron config on 6.1 - get_service_tenant_id $1 + get_service_tenant_id $2 } upgrade_node_preprovision() { From 2272d24056d5ca4f0947ebdaafeffa25f6eb159d Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Fri, 7 Aug 2015 09:38:14 +0000 Subject: [PATCH 25/26] Pass numbers of routers and servers as optional args --- octane/tests/generate_test_nets.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/octane/tests/generate_test_nets.py b/octane/tests/generate_test_nets.py index 2fa00eea..b27debfd 100644 --- a/octane/tests/generate_test_nets.py +++ b/octane/tests/generate_test_nets.py @@ -129,9 +129,13 @@ if __name__ == '__main__': help='admin tenant') parser.add_argument('keystone_url', metavar='', type=str, help='Keystone url') + parser.add_argument('--num-routers', type=int, default=3, + help='Number of routers') + parser.add_argument('--num-servers', type=int, default=5, + help='Number of servers') args = parser.parse_args() generator = TestResourcesGenerator(args.username, args.password, args.tenant_name, args.keystone_url) - generator.infra_generator(3, 5) + generator.infra_generator(args.num_routers, args.num_servers) From 34b2133f39b5a4407d31f97daa68264d774b23df Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Fri, 7 Aug 2015 13:50:47 +0000 Subject: [PATCH 26/26] Random names to router, network and server in test resource generator --- octane/tests/generate_test_nets.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/octane/tests/generate_test_nets.py b/octane/tests/generate_test_nets.py index b27debfd..67b24ad3 100644 --- a/octane/tests/generate_test_nets.py +++ b/octane/tests/generate_test_nets.py @@ -1,3 +1,4 @@ +import random import neutronclient.neutron.client import keystoneclient.v2_0.client as ksclient from novaclient import client as nova @@ -105,12 +106,13 @@ class TestResourcesGenerator(object): image_id = self.nova.images.list()[0].id print flavor.id, image_id for net in xrange(networks_count): - router = self._create_router("testrouter{0}".format(net)) - network = self._create_network("testnet{0}".format(net)) + name = random.randint(0x000000, 0xffffff) + router = self._create_router("testrouter{0}".format(name)) + network = self._create_network("testnet{0}".format(name)) subnet = self._create_subnet(network, "12.0.{0}.0/24".format(net)) self._uplink_subnet_to_router(router, subnet) for vm in xrange(vms_per_net): - server = self._create_server("testserver{0}{1}".format(net, + server = self._create_server("testserver{0}-{1}".format(name, vm), image_id, flavor.id,