Skip to content

Instantly share code, notes, and snippets.

@tomellis
Created May 7, 2013 11:13
Show Gist options
  • Save tomellis/5531894 to your computer and use it in GitHub Desktop.
Save tomellis/5531894 to your computer and use it in GitHub Desktop.
Get IP out of Rackspace cloud
#!/usr/bin/env python
import os
import sys
import logging
import pyrax
import pyrax.exceptions as exc
import exceptions
# Set loglevel
logging.basicConfig(level=logging.DEBUG)
# Authenticate to London Rackspace Cloud
conf = os.path.expanduser("creds")
pyrax.set_credential_file(conf, "LON")
# Set pointers to cloud services
cs = pyrax.cloudservers
def get_public_addr():
servers = cs.servers.list()
for server in servers:
print "Name: %s\n ID: %s\n Public IP: %s\n" % (server.name, server.id, server.accessIPv4)
get_public_addr()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment