#!/bin/bash
URL=http://192.168.0.17:8774/v2
tenantID=e7ffc374e7d844579b5e69ec05a0457a
token=bdd3d382afd342b197c56914ff885c27
GetInstanceID ()
{
curl -X GET -H "X-Auth-Token: $token" ${URL}/${tenantID}/servers/detail \
| python -mjson.tool |grep -B1 -w "image" |grep id |awk '{print $2}' |cut -d '"' -f2
}
AddSnapshot ()
{
curl -X POST -H "Content-Type: application/json" -d '{
"createImage": {
"name": "snap-'$1'"
}
}' -H "X-Auth-Token: $token" $URL/${tenantID}/servers/${2}/action | python -mjson.tool
}
instanceid=`GetInstanceID`
i=1
for id in $instanceid
do
AddSnapshot $i $id
(( i=i+1 ))
done
URL=http://192.168.0.17:8774/v2
tenantID=e7ffc374e7d844579b5e69ec05a0457a
token=bdd3d382afd342b197c56914ff885c27
GetInstanceID ()
{
curl -X GET -H "X-Auth-Token: $token" ${URL}/${tenantID}/servers/detail \
| python -mjson.tool |grep -B1 -w "image" |grep id |awk '{print $2}' |cut -d '"' -f2
}
AddSnapshot ()
{
curl -X POST -H "Content-Type: application/json" -d '{
"createImage": {
"name": "snap-'$1'"
}
}' -H "X-Auth-Token: $token" $URL/${tenantID}/servers/${2}/action | python -mjson.tool
}
instanceid=`GetInstanceID`
i=1
for id in $instanceid
do
AddSnapshot $i $id
(( i=i+1 ))
done