Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fetch port information from a TripleO overcloud Heat stack
#!/bin/bash
# This script will fetch IP addresses assigned to ports on servers belonging
# to a particular role in the overcloud Heat stack. It's not optimized for everyday
# use and takes a while to complete, as it makes many Heat queries. This does not include
# e.g. VIPs.
# Run this script for each role you are interested in. Example usage:
# $ source stackrc
# $ bash get-role-ports.sh overcloud Controller
set -euo pipefail
STACK="$1"
ROLE="$2"
ROLE_ID=$(openstack stack resource show -f json "$STACK" "$ROLE" | jq -r ".physical_resource_id")
HOST_IDS=$(openstack stack resource list -f json $ROLE_ID | jq -r ".[].physical_resource_id")
for HOST_ID in $HOST_IDS; do
NOVA_RES_NAME=$(openstack stack resource list -f json $HOST_ID | jq -r 'map(select(.resource_type | test("^OS::TripleO::.*Server$")))[0] | .resource_name')
HOSTNAME=$(openstack stack resource show -f json $HOST_ID $NOVA_RES_NAME | jq -r '.attributes.name')
PORT_RES_NAMES=$(openstack stack resource list -f json $HOST_ID | jq -r 'map(select(.resource_type | test("^OS::TripleO::.*::Ports::.*Port$"))) | .[].resource_name' | sort)
echo "$HOSTNAME"
for PORT_RES_NAME in $PORT_RES_NAMES; do
PORT_IP=$(openstack stack resource show -f json $HOST_ID $PORT_RES_NAME | jq -r '.attributes.ip_address')
echo " $PORT_RES_NAME $PORT_IP"
done
done
#!/bin/bash
# This script will fetch IP addresses assigned to ports on on the top-level of overcloud
# heat stack (e.g. VIPs). Example usage:
# $ source stackrc
# $ bash get-top-level-ports.sh overcloud
set -euo pipefail
STACK="$1"
PORT_RES_NAMES=$(openstack stack resource list -f json $STACK | jq -r 'map(select(.resource_type | test("Port$"))) | .[].resource_name' | sort)
for PORT_RES_NAME in $PORT_RES_NAMES; do
PORT_IP=$(openstack stack resource show -f json $STACK $PORT_RES_NAME | jq -r '.attributes.ip_address // .attributes.fixed_ips[0].ip_address')
echo "$PORT_RES_NAME $PORT_IP"
done
(undercloud) [stack@undercloud ~]$ ./get-top-level-ports.sh overcloud
ControlVirtualIP 192.168.24.9
InternalApiVirtualIP 172.16.2.10
PublicVirtualIP 172.20.0.13
RedisVirtualIP 172.16.2.12
StorageMgmtVirtualIP 172.16.3.6
StorageVirtualIP 172.16.1.12
(undercloud) [stack@undercloud ~]$ ./get-role-ports.sh overcloud Controller
overcloud-controller-1
ExternalPort 172.20.0.8
InternalApiPort 172.16.2.9
ManagementPort 192.168.24.17
StorageMgmtPort 172.16.3.10
StoragePort 172.16.1.10
TenantPort 172.16.0.9
overcloud-controller-0
ExternalPort 172.20.0.9
InternalApiPort 172.16.2.4
ManagementPort 192.168.24.10
StorageMgmtPort 172.16.3.11
StoragePort 172.16.1.9
TenantPort 172.16.0.11
overcloud-controller-2
ExternalPort 172.20.0.5
InternalApiPort 172.16.2.6
ManagementPort 192.168.24.12
StorageMgmtPort 172.16.3.7
StoragePort 172.16.1.7
TenantPort 172.16.0.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.