Hi Rudiger,
The problem, as it turns out, is just the main loop.
On Oct 8, 2010, at 8:27 AM, Rudiger Wolf wrote:
> # 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
Here your match boolean is set to true if you see a Lucid Lynx image.
> if match:
The above conditional will match for every iteration from Lucid Lynx onward.
When you get to this
> node = conn.deploy_node(name='tttt-xxxxx', image=item, size=sizes[0],
> deploy=msd)
by the second time, you will try to deploy a node with the same name, and
Rackspace will come back with that error.
The quick fixes are:
- add a break right after 'print node', or
- get rid of the match variable altogether and nest it in the "if
item.name.find('Ubuntu 10.05 LTS') != -1
A more elegant way may be filtering the nodes (via list comprehension), and
using friendly string semantics as follows:
# retrieve available images and sizes
images = conn.list_images()
sizes = conn.list_sizes()
lynx = [image for image in images if 'Ubuntu 10.04 LTS' in image.name]
assert len(lynx) == 1, "There are more than one Lucid Lynx images!"
# [set up msd deployment stuff here]
node = conn.deploy_node(name="tttt-xxxxx", image=lynx[0], size=sizes[0],
deploy=msd)
Here, ('needle' in haystack) is functionally equivalent to
(haystack.find('needle') != -1), and secondly, the list comprehension is a
great alternative to:
images_ = []
for image in images_:
if 'Ubuntu 10.04 LTS' in image.name:
images_.append(image)
images = images_
> 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.
This bug may not have appeared earlier if:
- Ubuntu 10.04 LTS was the last item in the images list
- Rackspace allowed duplicate node names (unlikely)
- Heisenbug(??)
Hope that helps. Thanks for testing 0.4.0!
Cheers,
Jerry