Hi

I though I'd give 0.4.0 a try.

$ svn co https://svn.apache.org/repos/asf/incubator/libcloud/tags/0.4.0
$ sudo python setup.py install

then the following script

#!/usr/bin/python

from libcloud.types import Provider
from libcloud.providers import get_driver
from libcloud.deployment import MultiStepDeployment, ScriptDeployment, SSHKeyDeployment
import os

from pprint import pprint

RACKSPACE_USER = 'xxxxxx'
RACKSPACE_KEY = 'xxxxxxxxxxxxxxxxxxxxxxx'

Driver = get_driver(Provider.RACKSPACE)
conn = Driver(RACKSPACE_USER, RACKSPACE_KEY)

# retrieve available images and sizes
images = conn.list_images()
# [<NodeImage: id=3, name=Gentoo 2008.0, driver=Rackspace  ...>, ...]
sizes = conn.list_sizes()
# [<NodeSize: id=1, name=256 server, ram=256 ... driver=Rackspace ...>, ...]


match = None
for item in images:
    if item.name.find('Ubuntu 10.04 LTS') != -1:
        match = True
    if match:


        # read your public rackspace key in
sd = SSHKeyDeployment(open(os.path.expanduser("/home/rnwolf/.ssh/id_rsa_xxxxxx.pub")).read()) # a simple script to install puppet post boot, can be much more complicated.
        script = ScriptDeployment("apt-get install hello")
        # a task that first installs the ssh key, and then runs the script
        msd = MultiStepDeployment([sd, script])

        images = conn.list_images()
        sizes = conn.list_sizes()

        pprint(images)
        pprint(sizes)
# deploy_node takes the same base keyword arguments as create_node. node = conn.deploy_node(name='tttt-xxxxx', image=item, size=sizes[0], deploy=msd) # <Node: uuid=..., name=test, state=3, public_ip=['1.1.1.1'], provider=Rackspace ...>
        # the node is now booted, with your ssh key and package installed.
        print node



Gives me an error:

Traceback (most recent call last):
  File "create-rackspace-node.py", line 43, in <module>
node = conn.deploy_node(name='tttt-matt', image=item, size=sizes[0], deploy=msd) File "/usr/local/lib/python2.6/dist-packages/libcloud/base.py", line 656, in deploy_node
    node = self.create_node(**kwargs)
File "/usr/local/lib/python2.6/dist-packages/libcloud/drivers/rackspace.py", line 236, in create_node
    data=ET.tostring(server_elm))
File "/usr/local/lib/python2.6/dist-packages/libcloud/drivers/rackspace.py", line 154, in request
    method=method, headers=headers
File "/usr/local/lib/python2.6/dist-packages/libcloud/base.py", line 444, in request
    response = self.responseCls(self.connection.getresponse())
File "/usr/local/lib/python2.6/dist-packages/libcloud/base.py", line 165, in __init__
    raise Exception(self.parse_error())
Exception: 400 Bad Request 422 Unprocessable Entity: Server name already in use; com.rackspace.cloud.service.servers.CloudServersFault: Fault occured



The virtual server is actually created if I check via the manage.rackspacecloud.com control panel.

I don't know enough about the plumbing of the software but maybe I am doing something wrong... maybe the new libcloud library is a bug. The same script above worked for me previously.

I am using Python 2.6.6 on Ubuntu 10.10 RC.


Thanks
Rudiger


Reply via email to