Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Adding support for egress rules. Closes #355.
Browse files Browse the repository at this point in the history
  • Loading branch information
garnaat committed Oct 2, 2011
1 parent 2fb6aae commit 79b9ec0
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions boto/ec2/securitygroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def __init__(self, connection=None, owner_id=None,
self.name = name
self.description = description
self.vpc_id = None
self.rules = []
self.rules = IPPermissionsList()
self.rules_egress = IPPermissionsList()

def __repr__(self):
return 'SecurityGroup:%s' % self.name
Expand All @@ -45,9 +46,10 @@ def startElement(self, name, attrs, connection):
retval = TaggedEC2Object.startElement(self, name, attrs, connection)
if retval is not None:
return retval
if name == 'item':
self.rules.append(IPPermissions(self))
return self.rules[-1]
if name == 'ipPermissions':
return self.rules
elif name == 'ipPermissionsEgress':
return self.rules_egress
else:
return None

Expand Down Expand Up @@ -242,6 +244,17 @@ def instances(self):
instances.extend(reservation.instances)
return instances

class IPPermissionsList(list):

def startElement(self, name, attrs, connection):
if name == 'item':
self.append(IPPermissions(self))
return self[-1]
return None

def endElement(self, name, value, connection):
pass

class IPPermissions(object):

def __init__(self, parent=None):
Expand Down

0 comments on commit 79b9ec0

Please sign in to comment.