Fix sourcing openrc in collect
The openrc file is being sourced in a short lived shell rather than in the shell of the sourcing code. As a result the environment created by the 'source' does not persist and the inventory request fails which prevents collect from learning/validating remote host names. This update corrects that and makes the code block involved in learning openrc variables a function call rather than inline whenever collect_utils is sourced. Test Plan: PASS: Verify collect all with no openrc already sourced PASS: Verify collect select hosts (same no pre-openrc) PASS: Verify collect self controller (same no pre-openrc) PASS: Verify collect of self on compute Change-Id: I41a097d9d751351f178a1366eb76dfb526c57b19 Closes-Bug: 1837412 Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
This commit is contained in:
parent
13ecf0f821
commit
41e60486af
@ -1,2 +1,2 @@
|
|||||||
SRC_DIR="scripts"
|
SRC_DIR="scripts"
|
||||||
TIS_PATCH_VER=27
|
TIS_PATCH_VER=28
|
||||||
|
@ -84,6 +84,7 @@ fi
|
|||||||
|
|
||||||
# pull in common utils and environment
|
# pull in common utils and environment
|
||||||
source /usr/local/sbin/collect_utils
|
source /usr/local/sbin/collect_utils
|
||||||
|
source_openrc_if_needed
|
||||||
|
|
||||||
function clean_up()
|
function clean_up()
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
# all collectors ; common and user defined.
|
# all collectors ; common and user defined.
|
||||||
#
|
#
|
||||||
source /usr/local/sbin/collect_utils
|
source /usr/local/sbin/collect_utils
|
||||||
|
source_openrc_if_needed
|
||||||
|
|
||||||
#
|
#
|
||||||
# parse input parameters
|
# parse input parameters
|
||||||
|
@ -55,34 +55,37 @@ MIN_PERCENT_SPACE_REQUIRED=75
|
|||||||
COLLECT_LOG=/var/log/collect.log
|
COLLECT_LOG=/var/log/collect.log
|
||||||
COLLECT_ERROR_LOG=/tmp/collect_error.log
|
COLLECT_ERROR_LOG=/tmp/collect_error.log
|
||||||
|
|
||||||
|
function source_openrc_if_needed
|
||||||
# get the node and subfunction types
|
{
|
||||||
nodetype=""
|
# get the node and subfunction types
|
||||||
subfunction=""
|
nodetype=""
|
||||||
PLATFORM_CONF=/etc/platform/platform.conf
|
subfunction=""
|
||||||
if [ -e ${PLATFORM_CONF} ] ; then
|
PLATFORM_CONF=/etc/platform/platform.conf
|
||||||
|
if [ -e ${PLATFORM_CONF} ] ; then
|
||||||
source ${PLATFORM_CONF}
|
source ${PLATFORM_CONF}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${nodetype}" != "controller" -a "${nodetype}" != "worker" -a "${nodetype}" != "storage" ] ; then
|
if [ "${nodetype}" != "controller" -a "${nodetype}" != "worker" -a "${nodetype}" != "storage" ] ; then
|
||||||
logger -t ${COLLECT_TAG} "could not identify nodetype ($nodetype)"
|
logger -t ${COLLECT_TAG} "could not identify nodetype ($nodetype)"
|
||||||
exit $FAIL_NODETYPE
|
exit $FAIL_NODETYPE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NODETYPE=$nodetype
|
NODETYPE=$nodetype
|
||||||
SUBFUNCTION=$subfunction
|
SUBFUNCTION=$subfunction
|
||||||
|
|
||||||
ACTIVE=false
|
ACTIVE=false
|
||||||
if [ "$NODETYPE" == "controller" ] ; then
|
if [ "$NODETYPE" == "controller" ] ; then
|
||||||
# get local host activity state
|
# get local host activity state
|
||||||
OPENRC="/etc/platform/openrc"
|
OPENRC="/etc/platform/openrc"
|
||||||
if [ -e "${OPENRC}" ] ; then
|
if [ -e "${OPENRC}" ] ; then
|
||||||
rc=`source ${OPENRC}`
|
OS_USERNAME=""
|
||||||
if [ "$rc" == "" ] ; then
|
source ${OPENRC}
|
||||||
|
if [ "${OS_USERNAME}" != "" ] ; then
|
||||||
ACTIVE=true
|
ACTIVE=true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Setup an expect command completion file.
|
# Setup an expect command completion file.
|
||||||
|
Loading…
Reference in New Issue
Block a user