~tribaal/txaws/xss-hardening

« back to all changes in this revision

Viewing changes to txaws/ec2/client.py

  • Committer: Duncan McGreggor
  • Date: 2009-10-06 18:34:35 UTC
  • mfrom: (33.1.5 444124-describe-zones)
  • Revision ID: duncan@canonical.com-20091006183435-el9j4wdv2229l63f
Merged 444124-describe-zones [r=therve] [f=444124]

Added support for getting a list of availability zones.

Show diffs side-by-side

added added

removed removed

Lines of Context:
677
677
            results.append((address, instance_id))
678
678
        return results
679
679
 
 
680
    def describe_availability_zones(self, names=None):
 
681
        zone_names = None
 
682
        if names:
 
683
            zone_names = dict([("ZoneName.%d" % (i+1), name)
 
684
                                for i, name in enumerate(names)])
 
685
        query = self.query_factory("DescribeAvailabilityZones", self.creds,
 
686
                                   self.endpoint, zone_names)
 
687
        d = query.submit()
 
688
        return d.addCallback(self._parse_describe_availability_zones)
 
689
        
 
690
    def _parse_describe_availability_zones(self, xml_bytes):
 
691
        results = []
 
692
        root = XML(xml_bytes)
 
693
        for zone_data in root.find("availabilityZoneInfo"):
 
694
            zone_name = zone_data.findtext("zoneName")
 
695
            zone_state = zone_data.findtext("zoneState")
 
696
            results.append(model.AvailabilityZone(zone_name, zone_state))
 
697
        return results
 
698
 
680
699
 
681
700
class Query(object):
682
701
    """A query that may be submitted to EC2."""