diff options
-rw-r--r-- | boto/ec2/instance.py | 3 | ||||
-rw-r--r-- | boto/ec2/securitygroup.py | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/boto/ec2/instance.py b/boto/ec2/instance.py index 7ea3a0b0..0f36e46f 100644 --- a/boto/ec2/instance.py +++ b/boto/ec2/instance.py @@ -340,6 +340,7 @@ class Group: def __init__(self, parent=None): self.id = None + self.name = None def startElement(self, name, attrs, connection): return None @@ -347,6 +348,8 @@ class Group: def endElement(self, name, value, connection): if name == 'groupId': self.id = value + elif name == 'groupName': + self.name = value else: setattr(self, name, value) diff --git a/boto/ec2/securitygroup.py b/boto/ec2/securitygroup.py index f39b3aaa..be5f8809 100644 --- a/boto/ec2/securitygroup.py +++ b/boto/ec2/securitygroup.py @@ -222,10 +222,19 @@ class SecurityGroup(TaggedEC2Object): return sg def instances(self): + """ + Find all of the current instances that are running within this + security group. + + :rtype: list of :class:`boto.ec2.instance.Instance` + :return: A list of Instance objects + """ + # It would be more efficient to do this with filters now + # but not all services that implement EC2 API support filters. instances = [] rs = self.connection.get_all_instances() for reservation in rs: - uses_group = [g.id for g in reservation.groups if g.id == self.name] + uses_group = [g.name for g in reservation.groups if g.name == self.name] if uses_group: instances.extend(reservation.instances) return instances |