OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2009-2010 Mitch Garnaat http://garnaat.org/ |
| 2 # |
| 3 # Permission is hereby granted, free of charge, to any person obtaining a |
| 4 # copy of this software and associated documentation files (the |
| 5 # "Software"), to deal in the Software without restriction, including |
| 6 # without limitation the rights to use, copy, modify, merge, publish, dis- |
| 7 # tribute, sublicense, and/or sell copies of the Software, and to permit |
| 8 # persons to whom the Software is furnished to do so, subject to the fol- |
| 9 # lowing conditions: |
| 10 # |
| 11 # The above copyright notice and this permission notice shall be included |
| 12 # in all copies or substantial portions of the Software. |
| 13 # |
| 14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- |
| 16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT |
| 17 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 18 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 20 # IN THE SOFTWARE. |
| 21 |
| 22 """ |
| 23 Represents a Route Table |
| 24 """ |
| 25 |
| 26 from boto.ec2.ec2object import TaggedEC2Object |
| 27 from boto.resultset import ResultSet |
| 28 |
| 29 class RouteTable(TaggedEC2Object): |
| 30 |
| 31 def __init__(self, connection=None): |
| 32 TaggedEC2Object.__init__(self, connection) |
| 33 self.id = None |
| 34 self.vpc_id = None |
| 35 self.routes = [] |
| 36 self.associations = [] |
| 37 |
| 38 def __repr__(self): |
| 39 return 'RouteTable:%s' % self.id |
| 40 |
| 41 def startElement(self, name, attrs, connection): |
| 42 result = super(RouteTable, self).startElement(name, attrs, connection) |
| 43 |
| 44 if result is not None: |
| 45 # Parent found an interested element, just return it |
| 46 return result |
| 47 |
| 48 if name == 'routeSet': |
| 49 self.routes = ResultSet([('item', Route)]) |
| 50 return self.routes |
| 51 elif name == 'associationSet': |
| 52 self.associations = ResultSet([('item', RouteAssociation)]) |
| 53 return self.associations |
| 54 else: |
| 55 return None |
| 56 |
| 57 def endElement(self, name, value, connection): |
| 58 if name == 'routeTableId': |
| 59 self.id = value |
| 60 elif name == 'vpcId': |
| 61 self.vpc_id = value |
| 62 else: |
| 63 setattr(self, name, value) |
| 64 |
| 65 class Route(object): |
| 66 def __init__(self, connection=None): |
| 67 self.destination_cidr_block = None |
| 68 self.gateway_id = None |
| 69 self.instance_id = None |
| 70 self.state = None |
| 71 |
| 72 def __repr__(self): |
| 73 return 'Route:%s' % self.destination_cidr_block |
| 74 |
| 75 def startElement(self, name, attrs, connection): |
| 76 return None |
| 77 |
| 78 def endElement(self, name, value, connection): |
| 79 if name == 'destinationCidrBlock': |
| 80 self.destination_cidr_block = value |
| 81 elif name == 'gatewayId': |
| 82 self.gateway_id = value |
| 83 elif name == 'instanceId': |
| 84 self.instance_id = value |
| 85 elif name == 'state': |
| 86 self.state = value |
| 87 |
| 88 class RouteAssociation(object): |
| 89 def __init__(self, connection=None): |
| 90 self.id = None |
| 91 self.route_table_id = None |
| 92 self.subnet_id = None |
| 93 self.main = False |
| 94 |
| 95 def __repr__(self): |
| 96 return 'RouteAssociation:%s' % self.id |
| 97 |
| 98 def startElement(self, name, attrs, connection): |
| 99 return None |
| 100 |
| 101 def endElement(self, name, value, connection): |
| 102 if name == 'routeTableAssociationId': |
| 103 self.id = value |
| 104 elif name == 'routeTableId': |
| 105 self.route_table_id = value |
| 106 elif name == 'subnetId': |
| 107 self.subnet_id = value |
| 108 elif name == 'main': |
| 109 self.main = value == 'true' |
OLD | NEW |