-function list_files () {
- local ip=$1
- local folder=$2
- ${SSH} ${ip} "sudo find /etc > /tmp/find.etc.txt"
- ${SSH} ${ip} "sudo find /opt/stack > /tmp/find.opt.stack.txt"
- ${SSH} ${ip} "sudo find /var > /tmp/find2.txt"
- ${SSH} ${ip} "sudo find /var > /tmp/find.var.txt"
- rsync --rsync-path="sudo rsync" --list-only -arvhe ssh ${ip}:/etc/ > ${folder}/rsync.etc.txt
- rsync --rsync-path="sudo rsync" --list-only -arvhe ssh ${ip}:/opt/stack/ > ${folder}/rsync.opt.stack.txt
- rsync --rsync-path="sudo rsync" --list-only -arvhe ssh ${ip}:/var/ > ${folder}/rsync.var.txt
- scp ${ip}:/tmp/find.etc.txt ${folder}
- scp ${ip}:/tmp/find.opt.stack.txt ${folder}
- scp ${ip}:/tmp/find2.txt ${folder}
- scp ${ip}:/tmp/find.var.txt ${folder}
+function collect_files() {
+ local -r ip=$1
+ local -r folder=$2
+ finddir=/tmp/finder
+ ${SSH} ${ip} "mkdir -p ${finddir}"
+ ${SSH} ${ip} "sudo find /etc > ${finddir}/find.etc.txt"
+ ${SSH} ${ip} "sudo find /opt/stack > ${finddir}/find.opt.stack.txt"
+ ${SSH} ${ip} "sudo find /var > ${finddir}/find2.txt"
+ ${SSH} ${ip} "sudo find /var > ${finddir}/find.var.txt"
+ ${SSH} ${ip} "sudo tar -cf - -C /tmp finder | xz -T 0 > /tmp/find.tar.xz"
+ scp ${ip}:/tmp/find.tar.xz ${folder}
+ mkdir -p ${finddir}
+ rsync --rsync-path="sudo rsync" --list-only -arvhe ssh ${ip}:/etc/ > ${finddir}/rsync.etc.txt
+ rsync --rsync-path="sudo rsync" --list-only -arvhe ssh ${ip}:/opt/stack/ > ${finddir}/rsync.opt.stack.txt
+ rsync --rsync-path="sudo rsync" --list-only -arvhe ssh ${ip}:/var/ > ${finddir}/rsync.var.txt
+ tar -cf - -C /tmp finder | xz -T 0 > /tmp/rsync.tar.xz
+ cp /tmp/rsync.tar.xz ${folder}
+}
+
+# List of extra services to extract from journalctl
+# Add new services on a separate line, in alpha order, add \ at the end
+extra_services_cntl=" \
+ dnsmasq.service \
+ httpd.service \
+ libvirtd.service \
+ openvswitch.service \
+ ovs-vswitchd.service \
+ ovsdb-server.service \
+ rabbitmq-server.service \
+"
+
+extra_services_cmp=" \
+ libvirtd.service \
+ openvswitch.service \
+ ovs-vswitchd.service \
+ ovsdb-server.service \
+"
+
+# Collect the logs for the openstack services
+# First get all the services started by devstack which would have devstack@ as a prefix
+# Next get all the extra services
+function collect_openstack_logs() {
+ local -r ip=${1}
+ local -r folder=${2}
+ local -r node_type=${3}
+ local oslogs="${folder}/oslogs"
+
+ printf "collect_openstack_logs for ${node_type} node: ${ip} into ${oslogs}\n"
+ rm -rf ${oslogs}
+ mkdir -p ${oslogs}
+ # There are always some logs in /opt/stack/logs and this also covers the
+ # pre-queens branches which always use /opt/stack/logs
+ rsync -avhe ssh ${ip}:/opt/stack/logs/* ${oslogs} # rsync to prevent copying of symbolic links
+
+ # Starting with queens break out the logs from journalctl
+ if [ "${OPENSTACK_BRANCH}" = "stable/queens" ]; then
+ cat > ${WORKSPACE}/collect_openstack_logs.sh << EOF
+extra_services_cntl="${extra_services_cntl}"
+extra_services_cmp="${extra_services_cmp}"
+
+function extract_from_journal() {
+ local -r services=\${1}
+ local -r folder=\${2}
+ local -r node_type=\${3}
+ printf "extract_from_journal folder: \${folder}, services: \${services}\n"
+ for service in \${services}; do
+ # strip anything before @ and anything after .
+ # devstack@g-api.service will end as g-api
+ service_="\${service#*@}"
+ service_="\${service_%.*}"
+ sudo journalctl -u "\${service}" > "\${folder}/\${service_}.log"
+ done