From 56dd23d0744cc60a3a900356c590266ca23686d7 Mon Sep 17 00:00:00 2001 From: Alexandru Avadanii Date: Sat, 9 Sep 2017 03:09:18 +0200 Subject: log.sh: Collect /var/log from cluster nodes Bring back parameter `-L`, which is already passed by releng deploy script. Since we need to enable file_recv on salt master, do so by adding a new class in , which will be inherited by all scenario reclass models. JIRA: FUEL-288 Change-Id: I9b649315984fb8580b63883d0e06c1e1efd11057 Signed-off-by: Alexandru Avadanii --- ci/deploy.sh | 13 ++++---- .../virtual-mcp-ocata-common/infra/config.yml | 4 +++ .../virtual-mcp-ocata-odl-router/infra/config.yml | 1 + .../virtual-mcp-ocata-ovs-dpdk/infra/config.yml | 1 + .../cluster/virtual-mcp-ocata-ovs/infra/config.yml | 1 + mcp/scripts/log.sh | 35 ++++++++++++++++++++++ mcp/scripts/salt.sh | 2 -- 7 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 mcp/reclass/classes/cluster/virtual-mcp-ocata-common/infra/config.yml create mode 100755 mcp/scripts/log.sh diff --git a/ci/deploy.sh b/ci/deploy.sh index 4b64000e1..90558396e 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 @@ -208,8 +210,7 @@ do TARGET_LAB=${OPTARG} ;; L) - notify '' 3 "${OPTION}"; continue - DEPLOY_LOG="-log ${OPTARG}" + DEPLOY_LOG="${OPTARG}" ;; p) TARGET_POD=${OPTARG} @@ -339,6 +340,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/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..b7f8985b7 --- /dev/null +++ b/mcp/reclass/classes/cluster/virtual-mcp-ocata-common/infra/config.yml @@ -0,0 +1,4 @@ +parameters: + salt: + master: + file_recv: true 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..39edab299 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 @@ -11,6 +11,7 @@ classes: - 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: 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..56cfa6ed9 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 @@ -10,6 +10,7 @@ classes: - 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: 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..1cfded091 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 @@ -10,6 +10,7 @@ classes: - 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: 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" -- cgit 1.2.3-korg