Created
March 26, 2014 11:36
-
-
Save christophchamp/9781341 to your computer and use it in GitHub Desktop.
Remove a Rackspace Cloud Network from a Cloud Server
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
# 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