Skip to content

Instantly share code, notes, and snippets.

@mpontillo
Created March 28, 2017 01:26
Show Gist options
  • Save mpontillo/4be4217274c12a5e33543aff745390f8 to your computer and use it in GitHub Desktop.
Save mpontillo/4be4217274c12a5e33543aff745390f8 to your computer and use it in GitHub Desktop.
Get all BMC IP addresses and which nodes use them from the MAAS database.
#!/bin/bash
cat << EOF | sudo -u postgres psql -P pager=off maasdb 2> /dev/null
SELECT
sip.ip "bmc_ip",
node.hostname AS "machine_hostname",
bmc.power_type
FROM maasserver_bmc bmc
LEFT OUTER JOIN maasserver_staticipaddress sip
ON sip.id = bmc.ip_address_id
LEFT OUTER JOIN maasserver_node node
ON bmc.id = node.bmc_id
WHERE bmc.ip_address_id IS NOT NULL
ORDER BY sip.ip;
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment