diff options
17 files changed, 125 insertions, 213 deletions
diff --git a/ci/deploy.sh b/ci/deploy.sh index e592f8820..36056c8b0 100755 --- a/ci/deploy.sh +++ b/ci/deploy.sh @@ -33,7 +33,7 @@ $(notify "$(basename "$0"): Deploy the Fuel@OPNFV MCP stack" 3) $(notify "USAGE:" 2) $(basename "$0") -b base-uri -l lab-name -p pod-name -s deploy-scenario \\ [-B PXE Bridge [-B Mgmt Bridge [-B Internal Bridge [-B Public Bridge]]]] \\ - [-S storage-dir] + [-S storage-dir] [-L /path/to/log/file.tar.gz] $(notify "OPTIONS:" 2) -b Base-uri for the stack-configuration structure @@ -43,6 +43,7 @@ $(notify "OPTIONS:" 2) -p Pod-name -s Deploy-scenario short-name -S Storage dir for VM images + -L Deployment log path and file name $(notify "DISABLED OPTIONS (not yet supported with MCP):" 3) -d (disabled) Dry-run @@ -50,7 +51,6 @@ $(notify "DISABLED OPTIONS (not yet supported with MCP):" 3) -f (disabled) Deploy on existing Salt master -F (disabled) Do only create a Salt master -i (disabled) iso url - -L (disabled) Deployment log path and file name -T (disabled) Timeout, in minutes, for the deploy. $(notify "Description:" 2) @@ -75,6 +75,7 @@ $(notify "Input parameters to the build script are:" 2) while "mcpcontrol" is used to provision the infrastructure VMs only. The default is 'pxebr'. -h Print this message and exit +-L Deployment log path and name, eg. -L /home/jenkins/job.log.tar.gz -l Lab name as defined in the configuration directory, e.g. lf -p POD name as defined in the configuration directory, e.g. pod-1 -s Deployment-scenario, this points to a short deployment scenario name, which @@ -86,7 +87,6 @@ $(notify "Disabled input parameters (not yet supported with MCP):" 3) -f (disabled) Deploy on existing Salt master -e (disabled) Do not launch environment deployment -F (disabled) Do only create a Salt master --L (disabled) Deployment log path and name, eg. -L /home/jenkins/job.log.tar.gz -T (disabled) Timeout, in minutes, for the deploy. It defaults to using the DEPLOY_TIMEOUT environment variable when defined. -i (disabled) .iso image to be deployed (needs to be provided in a URI @@ -141,8 +141,10 @@ URI_REGEXP='(file|https?|ftp)://.*' export SSH_KEY=${SSH_KEY:-"/var/lib/opnfv/mcp.rsa"} export SALT_MASTER=${SALT_MASTER_IP:-192.168.10.100} +export SALT_MASTER_USER=${SALT_MASTER_USER:-ubuntu} export MAAS_IP=${MAAS_IP:-192.168.10.3} export SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ${SSH_KEY}" +export SSH_SALT="${SALT_MASTER_USER}@${SALT_MASTER}" # Variables below are disabled for now, to be re-introduced or removed later set +x @@ -184,7 +186,7 @@ do if [ -n "${bridge}" ]; then OPNFV_BRIDGES[${OPNFV_BRIDGE_IDX}]="${bridge}" fi - OPNFV_BRIDGE_IDX=$[OPNFV_BRIDGE_IDX + 1] + OPNFV_BRIDGE_IDX=$((OPNFV_BRIDGE_IDX + 1)) done IFS=${OIFS} ;; @@ -208,8 +210,7 @@ do TARGET_LAB=${OPTARG} ;; L) - notify '' 3 "${OPTION}"; continue - DEPLOY_LOG="-log ${OPTARG}" + DEPLOY_LOG="${OPTARG}" ;; p) TARGET_POD=${OPTARG} @@ -346,6 +347,8 @@ for state in "${cluster_states[@]}"; do sudo "/root/fuel/mcp/config/states/${state} || true" done +./log.sh "${DEPLOY_LOG}" + popd > /dev/null # diff --git a/mcp/config/states/dpdk b/mcp/config/states/dpdk index c1ec07e27..ad435630c 100755 --- a/mcp/config/states/dpdk +++ b/mcp/config/states/dpdk @@ -2,7 +2,7 @@ set -x salt -I 'nova:compute' system.reboot -while true; do salt -I 'nova:compute' test.ping | fgrep -q 'Not connected' || break; done +while true; do salt -I 'nova:compute' test.ping | grep -Fq 'Not connected' || break; done salt -I 'nova:compute' state.sls linux.network # switch to UCA repos since fuel-infra packages have bugs diff --git a/mcp/config/states/maas b/mcp/config/states/maas index 710ec0e82..db0bd3fe6 100755 --- a/mcp/config/states/maas +++ b/mcp/config/states/maas @@ -3,10 +3,12 @@ set -x function wait_for() { local total_attempts=$1; shift - local cmdstr=$@ + local cmdstr=$* local sleep_time=10 echo "[NOTE] Waiting for cmd to return success: ${cmdstr}" + # shellcheck disable=SC2034 for attempt in $(seq "${total_attempts}"); do + # shellcheck disable=SC2015 eval "${cmdstr}" && break || true echo -n '.'; sleep "${sleep_time}" done @@ -17,8 +19,10 @@ function maas_fixup() { local statuscmd="salt 'mas01*' --out yaml state.apply maas.machines.status" wait_for 180 "${statuscmd} | tee /dev/stderr | " \ "grep -Eq '((Deployed|Ready): 5|status:Failed|status:Allocated)'" + # shellcheck disable=SC2155 local statusout=$(eval "${statuscmd}") + # shellcheck disable=SC2155 local fcnodes=$(echo "${statusout}" | \ grep -Po '(?<=system_id:)(.*)(?=,status:Failed commissioning)') for node_system_id in ${fcnodes}; do @@ -30,6 +34,7 @@ function maas_fixup() { return 1 fi + # shellcheck disable=SC2155 local fdnodes=$(echo "${statusout}" | \ grep -Po '(?<=system_id:)(.*)(?=,status:(Failed deployment|Allocated))') for node_system_id in ${fdnodes}; do @@ -106,4 +111,4 @@ wait_for 10 "! salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' state.apply linux,ntp | "tee /dev/stderr | fgrep -q 'Not connected'" wait_for 10 "salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' ssh.set_auth_key ${SUDO_USER} \ - $(awk 'NR==1{print $2}' $(eval echo ~${SUDO_USER}/.ssh/authorized_keys))" + $(awk 'NR==1{print $2}' "$(eval echo "~${SUDO_USER}/.ssh/authorized_keys")")" diff --git a/mcp/patches/patch.sh b/mcp/patches/patch.sh index aac0017b2..6cd65fd10 100755 --- a/mcp/patches/patch.sh +++ b/mcp/patches/patch.sh @@ -2,7 +2,7 @@ if [ -r "$1" ]; then while IFS=': ' read -r p_dest p_file; do - [[ "${p_dest}" =~ "$2" ]] && \ + [[ "${p_dest}" =~ $2 ]] && \ patch -fd "${p_dest}" -p1 < "/root/fuel/mcp/patches/${p_file}" done < "$1" fi diff --git a/mcp/reclass/classes/cluster/virtual-mcp-ocata-common/infra/config.yml b/mcp/reclass/classes/cluster/virtual-mcp-ocata-common/infra/config.yml new file mode 100644 index 000000000..a5fc3b1d3 --- /dev/null +++ b/mcp/reclass/classes/cluster/virtual-mcp-ocata-common/infra/config.yml @@ -0,0 +1,64 @@ +classes: +- service.git.client +- system.linux.system.single +- system.linux.system.repo.mcp.salt +- system.salt.master.api +- system.salt.master.pkg +- system.reclass.storage.salt +- system.salt.minion.ca.salt_master +- system.salt.minion.cert.proxy +- system.mysql.client.single +- system.reclass.storage.system.openstack_compute_multi +- system.reclass.storage.system.openstack_gateway_single +parameters: + _param: + openstack_control_node01_hostname: ctl01 + reclass_data_repository: local + salt_master_environment_repository: "https://github.com/tcpcloud" + salt_master_environment_revision: master + reclass_config_master: 192.168.10.100 + single_address: 172.16.10.100 + salt_master_host: 127.0.0.1 + salt_master_base_environment: prd + salt_minion_ca_host: ${linux:network:fqdn} + salt_api_password_hash: "$6$sGnRlxGf$al5jMCetLP.vfI/fTl3Z0N7Za1aeiexL487jAtyRABVfT3NlwZxQGVhO7S1N8OwS/34VHYwZQA8lkXwKMN/GS1" + linux: + network: + interface: + ens4: + enabled: true + type: eth + proto: static + address: ${_param:single_address} + netmask: 255.255.255.0 + salt: + master: + file_recv: true + reclass: + storage: + data_source: + engine: local + node: + openstack_control_node01: + name: ${_param:openstack_control_node01_hostname} + domain: ${_param:cluster_domain} + classes: + - cluster.${_param:cluster_name}.openstack.control + params: + linux_system_codename: xenial + salt_master_host: ${_param:reclass_config_master} + single_address: ${_param:openstack_control_node01_address} + openstack_compute_node01: + params: + single_address: 172.16.10.105 + tenant_address: 10.1.0.105 + external_address: 10.16.0.105 + openstack_compute_node02: + params: + single_address: 172.16.10.106 + tenant_address: 10.1.0.106 + external_address: 10.16.0.106 + openstack_gateway_node01: + params: + tenant_address: 10.1.0.110 + external_address: 10.16.0.110 diff --git a/mcp/reclass/classes/cluster/virtual-mcp-ocata-odl-router/infra/init.yml b/mcp/reclass/classes/cluster/virtual-mcp-ocata-common/infra/init.yml index 9140bd0bc..9140bd0bc 100644 --- a/mcp/reclass/classes/cluster/virtual-mcp-ocata-odl-router/infra/init.yml +++ b/mcp/reclass/classes/cluster/virtual-mcp-ocata-common/infra/init.yml diff --git a/mcp/reclass/classes/cluster/virtual-mcp-ocata-odl-router/infra/config.yml b/mcp/reclass/classes/cluster/virtual-mcp-ocata-odl-router/infra/config.yml index 63e58a24b..c66ba2a9c 100644 --- a/mcp/reclass/classes/cluster/virtual-mcp-ocata-odl-router/infra/config.yml +++ b/mcp/reclass/classes/cluster/virtual-mcp-ocata-odl-router/infra/config.yml @@ -1,69 +1,14 @@ classes: -- service.git.client -- system.linux.system.single -- system.linux.system.repo.mcp.salt -- system.salt.master.api -- system.salt.master.pkg -- system.reclass.storage.salt -- system.salt.minion.ca.salt_master -- system.salt.minion.cert.proxy -- system.mysql.client.single -- system.reclass.storage.system.openstack_compute_multi -- system.reclass.storage.system.openstack_gateway_single - system.reclass.storage.system.opendaylight_control_single +- cluster.virtual-mcp-ocata-common.infra.config - cluster.virtual-mcp-ocata-odl-router parameters: - _param: - openstack_control_node01_hostname: ctl01 - reclass_data_repository: local - salt_master_environment_repository: "https://github.com/tcpcloud" - salt_master_environment_revision: master - reclass_config_master: 192.168.10.100 - single_address: 172.16.10.100 - salt_master_host: 127.0.0.1 - salt_master_base_environment: prd - salt_minion_ca_host: ${linux:network:fqdn} - salt_api_password_hash: "$6$sGnRlxGf$al5jMCetLP.vfI/fTl3Z0N7Za1aeiexL487jAtyRABVfT3NlwZxQGVhO7S1N8OwS/34VHYwZQA8lkXwKMN/GS1" - linux: - network: - interface: - ens4: - enabled: true - type: eth - proto: static - address: ${_param:single_address} - netmask: 255.255.255.0 reclass: storage: - data_source: - engine: local node: - openstack_control_node01: - name: ${_param:openstack_control_node01_hostname} - domain: ${_param:cluster_domain} - classes: - - cluster.${_param:cluster_name}.openstack.control - params: - linux_system_codename: xenial - salt_master_host: ${_param:reclass_config_master} - single_address: ${_param:openstack_control_node01_address} - openstack_compute_node01: - params: - single_address: 172.16.10.105 - tenant_address: 10.1.0.105 - external_address: 10.16.0.105 - openstack_compute_node02: - params: - single_address: 172.16.10.106 - tenant_address: 10.1.0.106 - external_address: 10.16.0.106 - openstack_gateway_node01: - params: - tenant_address: 10.1.0.110 - external_address: 10.16.0.110 opendaylight_control_node01: classes: - cluster.${_param:cluster_name}.opendaylight.control params: linux_system_codename: xenial - single_address: 172.16.10.111 + single_address: ${_param:opendaylight_service_host} diff --git a/mcp/reclass/classes/cluster/virtual-mcp-ocata-odl-router/init.yml b/mcp/reclass/classes/cluster/virtual-mcp-ocata-odl-router/init.yml index 954a7a189..e0311de55 100644 --- a/mcp/reclass/classes/cluster/virtual-mcp-ocata-odl-router/init.yml +++ b/mcp/reclass/classes/cluster/virtual-mcp-ocata-odl-router/init.yml @@ -1,7 +1,7 @@ classes: - system.linux.system.single - cluster.virtual-mcp-ocata-common.init_options -- cluster.virtual-mcp-ocata-odl-router.infra +- cluster.virtual-mcp-ocata-common.infra - cluster.virtual-mcp-ocata-odl-router.openstack parameters: diff --git a/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs-dpdk/infra/config.yml b/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs-dpdk/infra/config.yml index 864c71daa..87a42105f 100644 --- a/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs-dpdk/infra/config.yml +++ b/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs-dpdk/infra/config.yml @@ -1,66 +1,15 @@ classes: -- service.git.client -- system.linux.system.single -- system.linux.system.repo.mcp.salt -- system.salt.master.api -- system.salt.master.pkg -- system.reclass.storage.salt -- system.salt.minion.ca.salt_master -- system.salt.minion.cert.proxy -- system.mysql.client.single -- system.reclass.storage.system.openstack_compute_multi -- system.reclass.storage.system.openstack_gateway_single +- cluster.virtual-mcp-ocata-common.infra.config - cluster.virtual-mcp-ocata-ovs-dpdk parameters: - _param: - openstack_control_node01_hostname: ctl01 - reclass_data_repository: local - salt_master_environment_repository: "https://github.com/tcpcloud" - salt_master_environment_revision: master - reclass_config_master: 192.168.10.100 - single_address: 172.16.10.100 - salt_master_host: 127.0.0.1 - salt_master_base_environment: prd - salt_minion_ca_host: ${linux:network:fqdn} - salt_api_password_hash: "$6$sGnRlxGf$al5jMCetLP.vfI/fTl3Z0N7Za1aeiexL487jAtyRABVfT3NlwZxQGVhO7S1N8OwS/34VHYwZQA8lkXwKMN/GS1" - linux: - network: - interface: - ens4: - enabled: true - type: eth - proto: static - address: ${_param:single_address} - netmask: 255.255.255.0 reclass: storage: - data_source: - engine: local node: - openstack_control_node01: - name: ${_param:openstack_control_node01_hostname} - domain: ${_param:cluster_domain} - classes: - - cluster.${_param:cluster_name}.openstack.control - params: - linux_system_codename: xenial - salt_master_host: ${_param:reclass_config_master} - single_address: ${_param:openstack_control_node01_address} openstack_compute_node01: params: - single_address: 172.16.10.105 - tenant_address: 10.1.0.105 - external_address: 10.16.0.105 dpdk0_name: ens5 dpdk0_pci: '"0000:00:05.0"' openstack_compute_node02: params: - single_address: 172.16.10.106 - tenant_address: 10.1.0.106 - external_address: 10.16.0.106 dpdk0_name: ens5 dpdk0_pci: '"0000:00:05.0"' - openstack_gateway_node01: - params: - tenant_address: 10.1.0.110 - external_address: 10.16.0.110 diff --git a/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs-dpdk/infra/init.yml b/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs-dpdk/infra/init.yml deleted file mode 100644 index 9140bd0bc..000000000 --- a/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs-dpdk/infra/init.yml +++ /dev/null @@ -1,14 +0,0 @@ -parameters: - linux: - network: - host: - cfg01: - address: ${_param:infra_config_address} - names: - - cfg01 - - cfg01.${_param:cluster_domain} - cfg: - address: ${_param:infra_config_address} - names: - - cfg - - cfg.${_param:cluster_domain} diff --git a/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs-dpdk/init.yml b/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs-dpdk/init.yml index 4626fd6c3..77e238057 100644 --- a/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs-dpdk/init.yml +++ b/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs-dpdk/init.yml @@ -1,7 +1,7 @@ classes: - system.linux.system.single - cluster.virtual-mcp-ocata-common.init_options -- cluster.virtual-mcp-ocata-ovs-dpdk.infra +- cluster.virtual-mcp-ocata-common.infra - cluster.virtual-mcp-ocata-ovs-dpdk.openstack parameters: diff --git a/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs/infra/config.yml b/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs/infra/config.yml index 97730b1fd..c366ec502 100644 --- a/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs/infra/config.yml +++ b/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs/infra/config.yml @@ -1,62 +1,3 @@ classes: -- service.git.client -- system.linux.system.single -- system.linux.system.repo.mcp.salt -- system.salt.master.api -- system.salt.master.pkg -- system.reclass.storage.salt -- system.salt.minion.ca.salt_master -- system.salt.minion.cert.proxy -- system.mysql.client.single -- system.reclass.storage.system.openstack_compute_multi -- system.reclass.storage.system.openstack_gateway_single +- cluster.virtual-mcp-ocata-common.infra.config - cluster.virtual-mcp-ocata-ovs -parameters: - _param: - openstack_control_node01_hostname: ctl01 - reclass_data_repository: local - salt_master_environment_repository: "https://github.com/tcpcloud" - salt_master_environment_revision: master - reclass_config_master: 192.168.10.100 - single_address: 172.16.10.100 - salt_master_host: 127.0.0.1 - salt_master_base_environment: prd - salt_minion_ca_host: ${linux:network:fqdn} - salt_api_password_hash: "$6$sGnRlxGf$al5jMCetLP.vfI/fTl3Z0N7Za1aeiexL487jAtyRABVfT3NlwZxQGVhO7S1N8OwS/34VHYwZQA8lkXwKMN/GS1" - linux: - network: - interface: - ens4: - enabled: true - type: eth - proto: static - address: ${_param:single_address} - netmask: 255.255.255.0 - reclass: - storage: - data_source: - engine: local - node: - openstack_control_node01: - name: ${_param:openstack_control_node01_hostname} - domain: ${_param:cluster_domain} - classes: - - cluster.${_param:cluster_name}.openstack.control - params: - linux_system_codename: xenial - salt_master_host: ${_param:reclass_config_master} - single_address: ${_param:openstack_control_node01_address} - openstack_compute_node01: - params: - single_address: 172.16.10.105 - tenant_address: 10.1.0.105 - external_address: 10.16.0.105 - openstack_compute_node02: - params: - single_address: 172.16.10.106 - tenant_address: 10.1.0.106 - external_address: 10.16.0.106 - openstack_gateway_node01: - params: - tenant_address: 10.1.0.110 - external_address: 10.16.0.110 diff --git a/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs/infra/init.yml b/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs/infra/init.yml deleted file mode 100644 index 9140bd0bc..000000000 --- a/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs/infra/init.yml +++ /dev/null @@ -1,14 +0,0 @@ -parameters: - linux: - network: - host: - cfg01: - address: ${_param:infra_config_address} - names: - - cfg01 - - cfg01.${_param:cluster_domain} - cfg: - address: ${_param:infra_config_address} - names: - - cfg - - cfg.${_param:cluster_domain} diff --git a/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs/init.yml b/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs/init.yml index 86c0cf50d..34dca1f5f 100644 --- a/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs/init.yml +++ b/mcp/reclass/classes/cluster/virtual-mcp-ocata-ovs/init.yml @@ -1,7 +1,7 @@ classes: - system.linux.system.single - cluster.virtual-mcp-ocata-common.init_options -- cluster.virtual-mcp-ocata-ovs.infra +- cluster.virtual-mcp-ocata-common.infra - cluster.virtual-mcp-ocata-ovs.openstack parameters: diff --git a/mcp/scripts/lib.sh b/mcp/scripts/lib.sh index 94a9bd3c3..e123e5231 100644 --- a/mcp/scripts/lib.sh +++ b/mcp/scripts/lib.sh @@ -141,7 +141,7 @@ start_vms() { # start vms for node in "${vnodes[@]}"; do virsh start "${node}" - sleep $[RANDOM%5+1] + sleep $((RANDOM%5+1)) done } diff --git a/mcp/scripts/log.sh b/mcp/scripts/log.sh new file mode 100755 index 000000000..1ae0953af --- /dev/null +++ b/mcp/scripts/log.sh @@ -0,0 +1,35 @@ +#!/bin/bash +############################################################################## +# Copyright (c) 2017 Mirantis Inc., Enea AB and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +# +# Collect /var/log from all cluster nodes via Salt Master +# + +DEPLOY_LOG=$1 +OPNFV_TMP_LOG="opnfv_fuel_logs" + +[ -n "${DEPLOY_LOG}" ] || exit 0 + +# ssh to cfg01 +# shellcheck disable=SC2086,2087 +ssh ${SSH_OPTS} "${SSH_SALT}" bash -s << LOG_COLLECT_END + sudo -i + + echo salt -C '*' cp.push_dir /var/log upload_path='${OPNFV_TMP_LOG}' + salt -C '*' cp.push_dir /var/log upload_path='${OPNFV_TMP_LOG}' + + cd /var/cache/salt/master/minions && \ + find */files/${OPNFV_TMP_LOG}/ | \ + xargs tar czf \$(eval echo \~\${SUDO_USER}/${OPNFV_TMP_LOG}.tar.gz) \ + --transform 's|/files/${OPNFV_TMP_LOG}||' +LOG_COLLECT_END + +# shellcheck disable=SC2086 +scp ${SSH_OPTS} "${SSH_SALT}:${OPNFV_TMP_LOG}.tar.gz" "${DEPLOY_LOG}" +# shellcheck disable=SC2086,2029 +ssh ${SSH_OPTS} "${SSH_SALT}" rm -f "${OPNFV_TMP_LOG}.tar.gz" diff --git a/mcp/scripts/salt.sh b/mcp/scripts/salt.sh index 4fa54ab1c..174471e91 100755 --- a/mcp/scripts/salt.sh +++ b/mcp/scripts/salt.sh @@ -11,8 +11,6 @@ # F_GIT_ROOT=$(git rev-parse --show-toplevel) -SALT_MASTER_USER=${SALT_MASTER_USER:-ubuntu} -SSH_SALT="${SALT_MASTER_USER}@${SALT_MASTER}" OPNFV_TMP_DIR="/home/${SALT_MASTER_USER}/fuel" OPNFV_FUEL_DIR="/root/fuel" |