Skip to content

Instantly share code, notes, and snippets.

@mimizone
Created August 29, 2017 21:57
Show Gist options
  • Save mimizone/87bb8047f8cb81fdd513824d47ea5d2b to your computer and use it in GitHub Desktop.
Save mimizone/87bb8047f8cb81fdd513824d47ea5d2b to your computer and use it in GitHub Desktop.
list all drives serial numbers using MAAS and jq
#!/bin/sh
PROFILE=ubuntu
API_KEY_FILE=~/maas.key
API_SERVER=172.30.72.130
MAAS_URL=http://$API_SERVER/MAAS/api/2.0
MACHINEID=hx7kdb
maas login $PROFILE $MAAS_URL - < $API_KEY_FILE
#simple output you can put in a sheet
maas $PROFILE machine read $MACHINEID | jq '.hostname, .system_id, (.blockdevice_set[] | .serial ) '
#json output
#maas $PROFILE machine read $MACHINEID | jq '{ hostname:.hostname, system_id:.system_id, blockdevice_set:[.blockdevice_set[] | {serial:.serial, name:.name, model:.model}]} '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment