diff options
author | Alexandru Avadanii <Alexandru.Avadanii@enea.com> | 2017-11-24 18:53:16 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-11-24 18:53:16 +0000 |
commit | f0d5de1c3ccb8f422f51e63f14a113ee1a39e270 (patch) | |
tree | 8c49d73918e4f23d77c2ac4989dd7d5fce0a6ad9 /mcp/config/states | |
parent | de2f8a2d26d3a47b41e2e4a27400bb245b465ece (diff) | |
parent | 544fa286cf4397941ca8627117479d7f4c6d9f28 (diff) |
Merge "ci/deploy.sh: Add new `-E` arg for env erase" into stable/euphrates
Diffstat (limited to 'mcp/config/states')
-rwxr-xr-x | mcp/config/states/maas | 12 | ||||
-rwxr-xr-x | mcp/config/states/virtual_control_plane | 15 |
2 files changed, 27 insertions, 0 deletions
diff --git a/mcp/config/states/maas b/mcp/config/states/maas index eea3e0ef6..7ccf0188e 100755 --- a/mcp/config/states/maas +++ b/mcp/config/states/maas @@ -8,6 +8,7 @@ ############################################################################## CI_DEBUG=${CI_DEBUG:-0}; [[ "${CI_DEBUG}" =~ (false|0) ]] || set -x +ERASE_ENV=${ERASE_ENV:-0} # shellcheck disable=SC1090 source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/lib.sh" @@ -52,6 +53,17 @@ function maas_fixup() { return 0 } +# Optionally destroy MaaS machines from a previous run +if [ "${ERASE_ENV}" -gt 1 ]; then + dnodes=$(salt 'mas01*' --out yaml state.apply maas.machines.status | \ + grep -Pzo '\s+system_id: \K.+\n') + for node_system_id in ${dnodes}; do + salt -C 'mas01*' state.apply maas.machines.delete \ + pillar="{'system_id': '${node_system_id}'}" + sleep 30 + done +fi + # MaaS rack/region controller, node commissioning salt -C 'mas01*' cmd.run "add-apt-repository ppa:maas/stable" diff --git a/mcp/config/states/virtual_control_plane b/mcp/config/states/virtual_control_plane index cfd5e421c..c355126f7 100755 --- a/mcp/config/states/virtual_control_plane +++ b/mcp/config/states/virtual_control_plane @@ -8,10 +8,25 @@ ############################################################################## CI_DEBUG=${CI_DEBUG:-0}; [[ "${CI_DEBUG}" =~ (false|0) ]] || set -x +ERASE_ENV=${ERASE_ENV:-0} # shellcheck disable=SC1090 source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/lib.sh" +# Optionally destroy VCP VMs from a previous run +if [ "${ERASE_ENV}" -eq 1 ]; then + kvm_vms=$(salt --out yaml 'kvm*' virt.list_domains | \ + sed -e 's/- //g' -e 's/:.*$//g') + for line in ${kvm_vms}; do + if [[ "${line}" =~ ^kvm ]]; then + kvm_node=${line} + elif [ -n "${kvm_node}" ]; then + salt "${kvm_node}" virt.purge dirs=True "${line}" || true + fi + done +fi + +# KVM, compute node prereqs (libvirt first), VCP deployment # patch the networking module for Debian based distros debian_ip_source=/usr/lib/python2.7/dist-packages/salt/modules/debian_ip.py salt -C 'kvm* or cmp*' file.line $debian_ip_source \ |