#!/bin/bash export OS_ENV="@globals.environment@" if [ "${OS_ENV}" == "dev" ]; then export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" fi source /etc/kolla/admin-openrc.sh EXIT_CODE=0 # search for broken ovs entry in DB for NODE in $(openstack compute service list -c Host -f value | sort -u); do OUTPUT=$(ssh ${NODE} docker exec openvswitch_vswitchd ovsdb-client dump | grep qvo | egrep -v "tag|mac" | cut -d "\"" -f2) for PORT in ${OUTPUT}; do printf "%-20s %s\n" "${NODE}" "${PORT}" EXIT_CODE=1 done done # Search for "No such device" OpenvSwitch ports for NODE in $(openstack compute service list -c Host -f value | sort -u); do OUTPUT="$(ssh ${NODE} docker exec -i openvswitch_vswitchd ovs-vsctl show | grep "No such device")" if [ -n "${OUTPUT}" ]; then echo "${NODE}" echo "${OUTPUT}" EXIT_CODE=1 fi done # search for unnecessary Open vSwitch interfaces on physical hosts for NODE in $(openstack compute service list -c Host -f value | sort -u); do for PORT_TOKEN in $(ssh ${NODE} brctl show | egrep "qvb|tap" | sed '$!N;/\n.*tap/d;P;D' | awk '{print substr($1,4,8)}'); do PORT_ID=$(openstack port list -c id -f value | grep ${PORT_TOKEN}) if [ -n "${PORT_ID}" ]; then SERVER_ID=$(openstack port show -c device_id -f value ${PORT_ID}) SERVER_STATUS=$(openstack server show -c status -f value ${SERVER_ID}) if [ "${SERVER_STATUS}" != "SHUTOFF" ] && [ "${SERVER_STATUS}" != "VERIFY_RESIZE" ]; then echo "NODE: ${NODE}" echo "PORT_TOKEN: ${PORT_TOKEN}" openstack server show -c name -c id -c project_id -c status ${SERVER_ID} EXIT_CODE=1 fi else echo "Obsolete port ${PORT_TOKEN} found on node ${NODE} (Port is no more avaiable in OpenStack DB and can by removed)" EXIT_CODE=1 fi done done # search for INACTIVE ports DB_PASS=$(grep neutron_database_password /etc/kolla/passwords.yml | cut -d " " -f2) PORT_IDS="$(mysql --host=db.service.i.example.com --password=${DB_PASS} --port=6033 --user=neutron --database=neutron -se "select port_id from ml2_port_bindings where status = 'INACTIVE'")" for PORT_ID in ${PORT_IDS}; do echo "INACTIVE port found in neutron DB: ${PORT_ID}" openstack port show ${PORT_ID} SERVER_ID=$(openstack port show 5d7a8442-fe7a-44bf-b7fe-c1a0147893bd -c device_id -f value) openstack server show ${SERVER_ID} PROJECT_ID=$(openstack server show ${SERVER_ID} -c project_id -f value) openstack project show ${PROJECT_ID} done # send notification echo exit ${EXIT_CODE}