Created
August 29, 2017 21:57
-
-
Save mimizone/87bb8047f8cb81fdd513824d47ea5d2b to your computer and use it in GitHub Desktop.
list all drives serial numbers using MAAS and jq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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