Fix log collection when VMs are created with non-default names

The change I4c9eec82882d94649ee0e6bdb7e2ce033c29e44a introduced the
ability to create VMs with user defined names. This change aligns
the VM log collection accordingly.

Change-Id: I8c4895a8f49749b6845a804b02ad64bc227ec3ec
Signed-off-by: Fatih Degirmenci <fatih.degirmenci@ericsson.com>
This commit is contained in:
Fatih Degirmenci 2016-08-31 21:10:24 +02:00
parent 33afbb5aae
commit a3706f0e49

View File

@ -12,9 +12,18 @@ LOG_LOCATION="${WORKSPACE:-${SCRIPT_HOME}/..}/logs"
echo "Making logs directory and collecting logs." echo "Making logs directory and collecting logs."
[ -d ${LOG_LOCATION} ] || mkdir -p ${LOG_LOCATION} [ -d ${LOG_LOCATION} ] || mkdir -p ${LOG_LOCATION}
sudo cp /var/log/libvirt/baremetal_logs/testvm[[:digit:]]_console.log ${LOG_LOCATION}
sudo chown $USER ${LOG_LOCATION}/testvm[[:digit:]]_console.log if [ -z "${TEST_VM_NODE_NAMES}" ]; then
sudo chmod o+r ${LOG_LOCATION}/testvm[[:digit:]]_console.log sudo cp /var/log/libvirt/baremetal_logs/testvm[[:digit:]]_console.log ${LOG_LOCATION}
sudo chown $USER ${LOG_LOCATION}/testvm[[:digit:]]_console.log
sudo chmod o+r ${LOG_LOCATION}/testvm[[:digit:]]_console.log
else
for TEST_VM_NODE_NAME in ${TEST_VM_NODE_NAMES}; do
sudo cp /var/log/libvirt/baremetal_logs/${TEST_VM_NODE_NAME}_console.log ${LOG_LOCATION}
sudo chown $USER ${LOG_LOCATION}/${TEST_VM_NODE_NAME}_console.log
sudo chmod o+r ${LOG_LOCATION}/${TEST_VM_NODE_NAME}_console.log
done
fi
dmesg &> ${LOG_LOCATION}/dmesg.log dmesg &> ${LOG_LOCATION}/dmesg.log
# NOTE(TheJulia): Netstat exits with error code 5 when --version is used. # NOTE(TheJulia): Netstat exits with error code 5 when --version is used.
sudo netstat -apn &> ${LOG_LOCATION}/netstat.log sudo netstat -apn &> ${LOG_LOCATION}/netstat.log