MAAS × LXD

13 · Dynamic Annotations

Dynamic annotations are computed columns you add with jq. They are great for dashboards and do not create drift.

Age in days

maas admin machines read | jq -r 'def age(d): ((now - (d | sub("\\.\\d+Z$"; "Z") | fromdate)) / 86400 | floor);
(["HOST","STATUS","AGEd","POOL","ZONE"] | (.,map(length*"-"))),
( .[] | [.hostname, .status_name, (age(.created)), .pool.name, .zone.name]) | @tsv' | column -t

Annotate SSH and DHCP

maas admin machines read | jq -r '(["HOST","SSH","DHCP","VLAN"] | (.,map(length*"-"))),
(.[] | [ .hostname,
          (if .enable_ssh then "yes" else "no" end),
          (if .boot_interface.links[0].mode=="DHCP" then "yes" else "no" end),
          (.boot_interface.vlan.name) ]) | @tsv' | column -t

Flag machines that need attention

maas admin machines read | jq -r '(["HOST","STATUS","ATTN"] | (.,map(length*"-"))),
(.[] | [.hostname, .status_name, (if (.status_name|IN("Failed commissioning","Failed deployment","Broken")) then "!" else "-" end)])
 | @tsv' | column -t