Skip to content

Instantly share code, notes, and snippets.

@mpontillo
Last active July 17, 2017 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mpontillo/94b227942fbcfc79dcad5124927ca9d9 to your computer and use it in GitHub Desktop.
Save mpontillo/94b227942fbcfc79dcad5124927ca9d9 to your computer and use it in GitHub Desktop.
List IP addresses allocated in MAAS.
SELECT
sip.ip,
CASE
WHEN sip.alloc_type = 0 THEN 'AUTO'
WHEN sip.alloc_type = 1 THEN 'STICKY'
WHEN sip.alloc_type = 4 THEN 'USER_RESERVED'
WHEN sip.alloc_type = 5 THEN 'DHCP'
WHEN sip.alloc_type = 6 THEN 'DISCOVERED'
ELSE CAST(sip.alloc_type as CHAR)
END "alloc_type",
subnet.cidr,
node.hostname,
iface.id AS "ifid",
iface.name AS "ifname",
iface.type AS "iftype",
iface.mac_address,
bmc.id,
bmc.power_type
FROM maasserver_staticipaddress sip
LEFT OUTER JOIN maasserver_subnet subnet
ON subnet.id = sip.subnet_id
LEFT OUTER JOIN maasserver_interface_ip_addresses ifip
ON sip.id = ifip.staticipaddress_id
LEFT OUTER JOIN maasserver_interface iface
ON iface.id = ifip.interface_id
LEFT OUTER JOIN maasserver_node node
ON iface.node_id = node.id
LEFT OUTER JOIN maasserver_bmc bmc
ON bmc.ip_address_id = sip.id
ORDER BY sip.ip;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment