import json
import libcloud.security
import libcloud.compute.providers
import libcloud.compute.types
from libcloud.compute.deployment import MultiStepDeployment, ScriptDeployment, SSHKeyDeployment
import os.path
import random, string


def namegen(length):
  return ''.join(random.choice(string.lowercase) for i in range(length))

# Import username and API key from a separate JSON file
creds = json.loads(open('creds.json').read())

# Don't verify the SSL cert. USE AT YOUR OWN RISK
libcloud.security.VERIFY_SSL_CERT = True

# Create a connection to the Chicago Rackspace endpoint
RackspaceProvider = libcloud.compute.providers.get_driver(libcloud.compute.types.Provider.RACKSPACE_NOVA_ORD)
driver = RackspaceProvider(creds['user'], creds['key'],
    ex_force_auth_url='https://identity.api.rackspacecloud.com/v2.0/',
		    ex_force_auth_version='2.0')

images = driver.list_images() # Get a list of images
sizes = driver.list_sizes() # Get a list of server sizes
size = [s for s in sizes if s.ram == 1024][0] # We want a 1GB server
image = [i for i in images if i.name == "Fedora 19 (Schrodinger's Cat)"][0] # We want the Fedora 

# Push our SSH key to /root/.ssh/authorized_keys
install_key = SSHKeyDeployment(open(os.path.expanduser("~/.ssh/id_rsa.pub")).read())

# Run the puppet install script
install_puppet = ScriptDeployment(open(os.path.expanduser("deploy-puppet.sh")).read())

# Multiple-step deployment that installs our SSH key and Puppet
multideploy = MultiStepDeployment([install_key, install_puppet])

# Creates our new server, runs deployment steps.
node = driver.deploy_node(name=namegen(10), image=image, size=size, deploy=multideploy)

@@ -30,22 +30,64 @@
 ecurity%0A
-import
+from libcloud.compute.types import Provider%0Afrom
  libclou
@@ -105,16 +105,34 @@
 roviders
+ import get_driver
 %0Aimport 
@@ -639,278 +639,101 @@
 int%0A
-RackspaceProvider = libcloud.compute.providers.get_driver(libcloud.compute.types.Provider.RACKSPACE_NOVA_ORD)%0Adriver = RackspaceProvider(creds%5B'user'%5D, creds%5B'key'%5D,%0A    ex_force_auth_url='https://identity.api.rackspacecloud.com/v2.0/',%0A%09%09    ex_force_auth_version='2.0'
+driver = get_driver(Provider.RACKSPACE)%0Ars = driver(creds%5B'user'%5D, creds%5B'key'%5D, region=%22dfw%22
 )%0A%0Ai
@@ -736,30 +736,26 @@
 )%0A%0Aimages = 
-drive
 r
+s
 .list_images
@@ -788,22 +788,18 @@
 sizes = 
-drive
 r
+s
 .list_si
@@ -954,29 +954,21 @@
 ora 
-19 (Schrodinger's Cat
+20 (Heisenbug
 )%22%5D%5B
@@ -1431,21 +1431,40 @@
 ps.%0A
+hostname = namegen(10)%0A
 node = 
-drive
 r
+s
 .dep
@@ -1534,8 +1534,48 @@
 deploy)%0A
+print %22Hostname: %22, hostname, %22 built.%22%0A

update 0.14 api and use F20