export OS_ENV=dev export SERVER_ID=$1 # search for VM by name if [ ${#SERVER_ID} -ne 36 ]; then RESULT="$(openstack server list --all --name ${SERVER_ID})" if [ $(echo "${RESULT}" | wc -l) -eq 5 ]; then SERVER_ID=$(echo "${RESULT}" | tail -2 | head -1 | cut -d " " -f2) else echo "No VM with name ${SERVER_ID}) found, similar VMs:" echo "${RESULT}" exit 0 fi fi RESULT=$(openstack server show ${SERVER_ID} -f value -c id) if [ -z "${RESULT}" ]; then echo "Server UUID ${SERVER_ID} not found" exit 0 fi echo -e "\e[34mVM:" openstack server show -c name -c id -c addresses -c OS-EXT-SRV-ATTR:host -c status ${SERVER_ID} echo -e "\n\e[34mProject:" PROJECT_ID=$(openstack server show -c project_id -f value ${SERVER_ID}) openstack project show -c id -c name -c description ${PROJECT_ID} echo -e "\n\e[34mDomain:" DOMAIN_ID=$(openstack project show -c domain_id -f value ${PROJECT_ID}) openstack domain show -c id -c name -c description ${DOMAIN_ID} echo -e "\n\e[34mServer:" openstack server show ${SERVER_ID} echo -e "\n\e[34mConsole:" openstack console url show ${SERVER_ID} echo -e "\n\e[34mEvents:" openstack server event list ${SERVER_ID} echo -e "\n\e[34mMigrations:" openstack server migration list --server ${SERVER_ID} --sort-column 'Updated At' echo -e "\n\e[34mVM Port(s):" #nova interface-list ${SERVER_ID} openstack port list --server ${SERVER_ID} --long PORT_IDS=$(openstack port list --server ${SERVER_ID} -c id -f value) for PORT_ID in ${PORT_IDS}; do NETWORK_ID=$(openstack port show ${PORT_ID} -c network_id -f value) NETWORK_NAME=$(openstack network show ${NETWORK_ID} -c name -f value) echo -e "\n+++++ Start network ${NETWORK_NAME} +++++" echo -e "\n\e[34mNetwork:" openstack network show ${NETWORK_ID} echo -e "\n\e[34mSubnet:" SUBNET_IDS=$(openstack subnet list --network ${NETWORK_ID} -c ID -f value) for SUBNET_ID in ${SUBNET_IDS}; do openstack subnet show ${SUBNET_ID} done echo -e "\n\e[34mNetwork ports:" openstack port list --network ${NETWORK_ID} echo -e "\n\e[34mSecurity group(s):" #SECURITY_GROUP_IDS="$(openstack port show ${PORT_ID} -c security_group_ids -f json | jq -r .security_group_ids[])" # workaround for old OSC #SECURITY_GROUP_IDS="$(openstack port show ${PORT_ID} -c security_group_ids -f json | jq -r .security_group_ids | tr ',' '\n')" SECURITY_GROUP_IDS=$(openstack port show ${PORT_ID} -c security_group_ids -f json | jq -r '.security_group_ids[]') for SECURITY_GROUP_ID in ${SECURITY_GROUP_IDS}; do openstack security group show ${SECURITY_GROUP_ID} echo done echo -e "\e[34mRouter(s):" ROUTER_PORT_ID=$(openstack port list --network ${NETWORK_ID} --device-owner network:ha_router_replicated_interface -c id -f value) ROUTER_ID=$(openstack port show ${ROUTER_PORT_ID} -c device_id -f value) openstack router show ${ROUTER_ID} -c id -c name -c routes echo -e "\nRouter ports:" openstack network agent list --router ${ROUTER_ID} --long --sort-column 'HA State' ROUTER_HOSTS=$(openstack network agent list --router ${ROUTER_ID} --long --sort-column 'HA State' -c Host -f value) for ROUTER_HOST in ${ROUTER_HOSTS}; do echo "ssh -t ${ROUTER_HOST} sudo ip netns exec qrouter-${ROUTER_ID} bash" ssh ${ROUTER_HOST} sudo ip netns exec qrouter-${ROUTER_ID} ip a | sed -n '/BROADCAST/,$p' | egrep -v "inet6|valid_lft" echo done echo -e "\e[34mDHCP/DNS:" DHCP_PORT_IDS=$(openstack port list --network ${NETWORK_ID} --device-owner network:dhcp -c id -f value) for DHCP_PORT_ID in ${DHCP_PORT_IDS}; do DHCP_HOST=$(openstack port show ${DHCP_PORT_ID} -c binding_host_id -f value) echo "ssh -t ${DHCP_HOST} sudo ip netns exec qdhcp-${NETWORK_ID} bash" ssh ${DHCP_HOST} sudo ip netns exec qdhcp-${NETWORK_ID} ip a | sed -n '/BROADCAST/,$p' | egrep -v "inet6|valid_lft" echo done echo "+++++ END network ${NETWORK_NAME} +++++" done