From 20fee68b1bedd71c5be0098f15fc988bc50aa96e Mon Sep 17 00:00:00 2001 From: Eric MacDonald Date: Sun, 17 Mar 2019 15:36:15 -0400 Subject: [PATCH] Change collect to use /etc/platform/openrc The collect tool is failing to source the openrc file needed to execute system commands to get inventory. The openrc file has been moved to /etc/platform but collect expects it to be in /etc/nova. This update changes collect to source openrc from /etc/platform in collect_utils and avoids needless sourcing of that same file multiple times from the other collect scripts. All collect scripts source collect_utils. The update also removes reference to the also recently removed keyring which is also breaking collect in the very same way. Test Plan: Run collect on individual hosts Run collect all Change-Id: I75ff6d3cb8f25a9d0dca182837c7d1b4854896d9 Closes-Bug: 1820421 Signed-off-by: Eric MacDonald --- tools/collector/centos/build_srpm.data | 2 +- tools/collector/scripts/collect | 23 ----------------- tools/collector/scripts/collect_host | 11 -------- .../collector/scripts/collect_mask_passwords | 1 - tools/collector/scripts/collect_utils | 25 ++++++++++--------- 5 files changed, 14 insertions(+), 48 deletions(-) diff --git a/tools/collector/centos/build_srpm.data b/tools/collector/centos/build_srpm.data index 51df01b6..16277404 100644 --- a/tools/collector/centos/build_srpm.data +++ b/tools/collector/centos/build_srpm.data @@ -1,2 +1,2 @@ SRC_DIR="scripts" -TIS_PATCH_VER=26 +TIS_PATCH_VER=27 diff --git a/tools/collector/scripts/collect b/tools/collector/scripts/collect index febd1868..758e377e 100755 --- a/tools/collector/scripts/collect +++ b/tools/collector/scripts/collect @@ -85,29 +85,6 @@ fi # pull in common utils and environment source /usr/local/sbin/collect_utils -# get the host type -nodetype="" -subfunction="" -PLATFORM_CONF=/etc/platform/platform.conf -if [ -e ${PLATFORM_CONF} ] ; then - source ${PLATFORM_CONF} -fi - -ACTIVE=false -if [ "${nodetype}" == "controller" ] ; then - KEYRING_PATH="/opt/platform/.keyring" - if [ -e ${KEYRING_PATH} ] ; then - CRED=`find /opt/platform/.keyring -name .CREDENTIAL` - if [ ! -z "${CRED}" ] ; then - NOVAOPENRC="/etc/nova/openrc" - if [ -e ${NOVAOPENRC} ] ; then - ACTIVE=true - source ${NOVAOPENRC} 2>/dev/null 1>/dev/null - fi - fi - fi -fi - function clean_up() { `reset` diff --git a/tools/collector/scripts/collect_host b/tools/collector/scripts/collect_host index 63596984..3016b1b3 100755 --- a/tools/collector/scripts/collect_host +++ b/tools/collector/scripts/collect_host @@ -13,17 +13,6 @@ # source /usr/local/sbin/collect_utils -KEYRING_PATH="/opt/platform/.keyring" -if [ -e ${KEYRING_PATH} ] ; then - CRED=`find /opt/platform/.keyring -name .CREDENTIAL` - if [ ! -z "${CRED}" ] ; then - NOVAOPENRC="/etc/nova/openrc" - if [ -e ${NOVAOPENRC} ] ; then - source ${NOVAOPENRC} 2>/dev/null 1>/dev/null - fi - fi -fi - # # parse input parameters # diff --git a/tools/collector/scripts/collect_mask_passwords b/tools/collector/scripts/collect_mask_passwords index 1bdd34cb..5cda3426 100644 --- a/tools/collector/scripts/collect_mask_passwords +++ b/tools/collector/scripts/collect_mask_passwords @@ -63,7 +63,6 @@ done find ${COLLECT_NAME_DIR} -name server-cert.pem | xargs --no-run-if-empty rm -f rm -rf ${COLLECT_NAME_DIR}/var/extra/platform/config/*/ssh_config -rm -f ${COLLECT_NAME_DIR}/var/extra/platform/.keyring/*/python_keyring/crypted_pass.cfg rm -f ${COLLECT_NAME_DIR}/var/extra/platform/puppet/*/hieradata/secure*.yaml # Mask user passwords in sysinv db dump diff --git a/tools/collector/scripts/collect_utils b/tools/collector/scripts/collect_utils index fc8ac0a6..66c9a3ac 100755 --- a/tools/collector/scripts/collect_utils +++ b/tools/collector/scripts/collect_utils @@ -55,18 +55,6 @@ MIN_PERCENT_SPACE_REQUIRED=75 COLLECT_LOG=/var/log/collect.log COLLECT_ERROR_LOG=/tmp/collect_error.log -# Load up the nova openrc file if its possible -KEYRING_PATH="/opt/platform/.keyring" -if [ -e ${KEYRING_PATH} ] ; then - CRED=`find /opt/platform/.keyring -name .CREDENTIAL` - if [ ! -z "${CRED}" ] ; then - NOVAOPENRC="/etc/nova/openrc" - if [ -e ${NOVAOPENRC} ] ; then - ACTIVE=true - source ${NOVAOPENRC} 2>/dev/null 1>/dev/null - fi - fi -fi # get the node and subfunction types nodetype="" @@ -84,6 +72,19 @@ fi NODETYPE=$nodetype SUBFUNCTION=$subfunction +ACTIVE=false +if [ "$NODETYPE" == "controller" ] ; then + # get local host activity state + OPENRC="/etc/platform/openrc" + if [ -e "${OPENRC}" ] ; then + rc=`source ${OPENRC}` + if [ "$rc" == "" ] ; then + ACTIVE=true + fi + fi +fi + + # Setup an expect command completion file. # This is used to force serialization of expect # sequences and highlight command completion