I would appreciate if someone could explain to me why for
BaseEC2NodeDriver.list_locations() the name parameter is set to
availability_zone rather than availability_zone.name?

    def list_locations(self):
        locations = []
        for index, availability_zone in \
                enumerate(self.ex_list_availability_zones()):
                    locations.append(EC2NodeLocation(
                        index, availability_zone, self.country, self,
                        availability_zone)
                    )
        return locations

And the to make the confusion complete, at least for me, in __repr__ the
code outputs self.availability_zone.name for the availability_zone where I
would expect self.availability_zone.


class EC2NodeLocation(NodeLocation):
    def __init__(self, id, name, country, driver, availability_zone):
        super(EC2NodeLocation, self).__init__(id, name, country, driver)
        self.availability_zone = availability_zone

    def __repr__(self):
        return (('<EC2NodeLocation: id=%s, name=%s, country=%s, '
                 'availability_zone=%s driver=%s>')
                % (self.id, self.name, self.country,
                   self.availability_zone.name, self.driver.name))

It does not seem to make much sense to me how it is and it is actually
rather cumbersome to use. In my application I am creating a node using
default location since I cannot specify the location for create_node
(unless I am missing something).

After that I want to create a volume for which I must specify the location
otherwise AWS EC2 will reject it (the code of BaseEC2NodeDriver in
incorrect in allowing location=None). For that purpose I need to query my
node for its location with mynode.extra['availability']. However, I cannot
use that value for create_volume() because it expects a Location object.

Now I have either manually create a Location object with a nested
availability_zone object for which I have to set the name attribute.
Alternatively, I have to use list_locations() and then iterate through the
list to find the one with the name I am looking for but not using the name
attribute but using availability_zone.name.

Thanks,
Rudi

Reply via email to