f87df98a96
Several collect plugins were using the 'sm-query service' with 'management-ip' as the target service to determine if the host collect is running on is the active controller. sm-query service management-ip Unfortunately, a recent update changed the name of the 'management-ip' service. This change lead to that query always returning a 'disabled' status. This update changes to use 'sm-query service-group controller-services' instead of a specific service query that might change again in the future. It also migrates the replicated is_service_active function to the collect_utils file making it common and reusable by all aspects of collect. This function was renamed to 'is_controller_active' because it's no longer representing the activity state of a particular service. Test Plan: PASS: Verify 'sysinv' plugin creates var/extra/inventory.info file on active controller. sysinv CLI command output. PASS: Verify 'fm' plugin creates var/extra/alarm.info file on active controller. FM alarm and event listings. PASS: Verify 'ceph' plugin creates var/extra/ceph.info file on active controller with 'ceph df' output content. PASS: Verify 'dc' plugin creates var/extra/distributed_cloud.info file on active controller of a system controller or subcloud. Closes-Bug: 2070496 Change-Id: I9989708f1d87a5ef312129cfe3ede8c862764cb0 Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
104 lines
3.5 KiB
Bash
Executable File
104 lines
3.5 KiB
Bash
Executable File
#! /bin/bash
|
|
#
|
|
# Copyright (c) 2013-2022 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
|
|
# Loads Up Utilities and Commands Variables
|
|
source /usr/local/sbin/collect_parms
|
|
source /usr/local/sbin/collect_utils
|
|
|
|
SERVICE="inventory"
|
|
LOGFILE="${extradir}/${SERVICE}.info"
|
|
INVENTORY=${4}
|
|
|
|
function collect_inventory {
|
|
is_active_controller
|
|
if [ "$?" = "0" ] ; then
|
|
exit 0
|
|
fi
|
|
echo "${hostname}: System Inventory ..: ${LOGFILE}"
|
|
|
|
HOSTNAMES=$(system host-list --nowrap | grep '[0-9]' | cut -d '|' -f 3 | tr -d ' ')
|
|
if [[ -z ${HOSTNAMES} || ${HOSTNAMES} != *"controller"* ]]; then
|
|
echo "Failed to get system host-list" > $LOGFILE
|
|
exit 0
|
|
fi
|
|
|
|
# These go into the SERVICE.info file
|
|
delimiter ${LOGFILE} "system show"
|
|
system show 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
|
|
|
delimiter ${LOGFILE} "system host-list"
|
|
system host-list 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
|
|
|
delimiter ${LOGFILE} "system datanetwork-list"
|
|
system datanetwork-list 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
|
|
|
delimiter ${LOGFILE} "system service-list"
|
|
system service-list 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
|
|
|
# delimiter ${LOGFILE} "vm-topology"
|
|
# timeout 60 vm-topology --show all 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
|
|
|
delimiter ${LOGFILE} "system network-list"
|
|
system network-list 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
|
|
|
for host in ${HOSTNAMES}; do
|
|
delimiter ${LOGFILE} "system host-show ${host}"
|
|
system host-show 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
|
|
|
delimiter ${LOGFILE} "system host-port-list ${host}"
|
|
system host-port-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
|
|
|
delimiter ${LOGFILE} "system host-if-list ${host}"
|
|
system host-if-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
|
|
|
delimiter ${LOGFILE} "system interface-network-list ${host}"
|
|
system interface-network-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
|
|
|
delimiter ${LOGFILE} "system host-ethernet-port-list ${host}"
|
|
system host-ethernet-port-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
|
|
|
delimiter ${LOGFILE} "system host-cpu-list ${host}"
|
|
system host-cpu-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
|
|
|
delimiter ${LOGFILE} "system host-memory-list ${host}"
|
|
system host-memory-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
|
|
|
delimiter ${LOGFILE} "system host-label-list ${host}"
|
|
system host-label-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
|
|
|
delimiter ${LOGFILE} "system host-disk-list ${host}"
|
|
system host-disk-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
|
|
|
delimiter ${LOGFILE} "system host-stor-list ${host}"
|
|
system host-stor-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
|
|
|
delimiter ${LOGFILE} "system host-lvg-list ${host}"
|
|
system host-lvg-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
|
|
|
delimiter ${LOGFILE} "system host-pv-list ${host}"
|
|
system host-pv-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
|
done
|
|
}
|
|
|
|
###############################################################################
|
|
# Only Controller
|
|
###############################################################################
|
|
if [ "$nodetype" = "controller" ] ; then
|
|
|
|
if [ "${INVENTORY}" = true ] ; then
|
|
collect_inventory
|
|
fi
|
|
|
|
# copy /opt/platform to extra dir while filtering out the
|
|
# iso and lost+found dirs
|
|
rsync -a --exclude 'iso' --exclude 'lost+found' /opt/platform ${extradir}
|
|
fi
|
|
|
|
|
|
exit 0
|