Skip to content

Instantly share code, notes, and snippets.

@cpswan
Created March 18, 2015 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpswan/e1fbc6dcb381e40eede2 to your computer and use it in GitHub Desktop.
Save cpswan/e1fbc6dcb381e40eede2 to your computer and use it in GitHub Desktop.
Create and retrieve a snapshot from a VNS3 manager
#!/bin/bash
command -v curl >/dev/null 2>&1 || { echo "This script requires curl, but it's not installed. Aborting." >&2; exit 1; }
MGRIP=10.0.0.10
APIPW=pa55Word
SNAPSHOTJSON=`curl -k -X POST -u api:$APIPW https://$MGRIP:8000/api/snapshots`
SNAPSHOTNAME=$(echo $SNAPSHOTJSON | grep -Po '"response":{.*?[^\\]"' | awk '{split($0,a,"{"); print a[2]}' )
curl -k -X GET -H 'Content-Type: application/json' https://api:$APIPW@$MGRIP:8000/api/snapshots/${SNAPSHOTNAME//\"} -o ${SNAPSHOTNAME//\"}
echo "Created and retrieved $SNAPSHOTNAME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment