Skip to content

Instantly share code, notes, and snippets.

@christophchamp
Created March 26, 2014 11: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 christophchamp/9781341 to your computer and use it in GitHub Desktop.
Save christophchamp/9781341 to your computer and use it in GitHub Desktop.
Remove a Rackspace Cloud Network from a Cloud Server
# SEE: http://docs.rackspace.com/networks/api/v2/cn-devguide/content/delete_virt_interface_api.html
USERNAME=<REDACTED> # This is your Rackspace account's username
API_KEY=<REDACTED> # This is your Rackspace account's API Key
ACCOUNT=<REDACTED> # This is your Rackspace account number
REGION=dfw # Or, "iad", "ord", "lon", "syd", "hkg"
# Authenticate to obtain your 24-hour valid token:
TOKEN=`curl -s -XPOST https://identity.api.rackspacecloud.com/v2.0/tokens -d'{"auth":{"RAX-KSKEY:apiKeyCredentials":{"username":"'$USERNAME'","apiKey":"'$API_KEY'"}}}' -H"Content-type:application/json" | python -c 'import sys,json;data=json.loads(sys.stdin.read());print data["access"]["token"]["id"]'`
# First list out the networks attached to your Cloud Server:
INSTANCE_ID=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee # Your Cloud Server's ID
curl -X GET https://$REGION.servers.api.rackspacecloud.com/v2/$ACCOUNT/servers/$INSTANCE_ID/os-virtual-interfacesv2 \
-H "X-Auth-Project-Id: $ACCOUNT" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "X-Auth-Token: $TOKEN" | python -m json.tool
# Grab the interface ID (_not_ the network ID) and use it to remove the Cloud Network from the Cloud Server:
INTERFACE_ID=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
curl -X DELETE https://$REGION.servers.api.rackspacecloud.com/v2/$ACCOUNT/servers/$INSTANCE_ID/os-virtual-interfacesv2/$INTERFACE_ID \
-H "X-Auth-Project-Id: $ACCOUNT" \
-H "Content-Type: application/json" \
-H "X-Auth-Token: $TOKEN"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment