| OLD | NEW |
| 1 # Copyright (c) 2006-2009 Mitch Garnaat http://garnaat.org/ | 1 # Copyright (c) 2006-2009 Mitch Garnaat http://garnaat.org/ |
| 2 # | 2 # |
| 3 # Permission is hereby granted, free of charge, to any person obtaining a | 3 # Permission is hereby granted, free of charge, to any person obtaining a |
| 4 # copy of this software and associated documentation files (the | 4 # copy of this software and associated documentation files (the |
| 5 # "Software"), to deal in the Software without restriction, including | 5 # "Software"), to deal in the Software without restriction, including |
| 6 # without limitation the rights to use, copy, modify, merge, publish, dis- | 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 | 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- | 8 # persons to whom the Software is furnished to do so, subject to the fol- |
| 9 # lowing conditions: | 9 # lowing conditions: |
| 10 # | 10 # |
| 11 # The above copyright notice and this permission notice shall be included | 11 # The above copyright notice and this permission notice shall be included |
| 12 # in all copies or substantial portions of the Software. | 12 # in all copies or substantial portions of the Software. |
| 13 # | 13 # |
| 14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | 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- | 15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- |
| 16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | 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, | 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, | 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 | 19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 20 # IN THE SOFTWARE. | 20 # IN THE SOFTWARE. |
| 21 | 21 |
| 22 """ | 22 """ |
| 23 Represents an EC2 Elastic IP Address | 23 Represents an EC2 Elastic IP Address |
| 24 """ | 24 """ |
| 25 | 25 |
| 26 from boto.ec2.ec2object import EC2Object | 26 from boto.ec2.ec2object import EC2Object |
| 27 | 27 |
| 28 class Address(EC2Object): | 28 class Address(EC2Object): |
| 29 | 29 |
| 30 def __init__(self, connection=None, public_ip=None, instance_id=None): | 30 def __init__(self, connection=None, public_ip=None, instance_id=None): |
| 31 EC2Object.__init__(self, connection) | 31 EC2Object.__init__(self, connection) |
| 32 self.connection = connection | 32 self.connection = connection |
| 33 self.public_ip = public_ip | 33 self.public_ip = public_ip |
| 34 self.instance_id = instance_id | 34 self.instance_id = instance_id |
| 35 self.domain = None |
| 36 self.allocation_id = None |
| 37 self.association_id = None |
| 35 | 38 |
| 36 def __repr__(self): | 39 def __repr__(self): |
| 37 return 'Address:%s' % self.public_ip | 40 return 'Address:%s' % self.public_ip |
| 38 | 41 |
| 39 def endElement(self, name, value, connection): | 42 def endElement(self, name, value, connection): |
| 40 if name == 'publicIp': | 43 if name == 'publicIp': |
| 41 self.public_ip = value | 44 self.public_ip = value |
| 42 elif name == 'instanceId': | 45 elif name == 'instanceId': |
| 43 self.instance_id = value | 46 self.instance_id = value |
| 47 elif name == 'domain': |
| 48 self.domain = value |
| 49 elif name == 'allocationId': |
| 50 self.allocation_id = value |
| 51 elif name == 'associationId': |
| 52 self.association_id = value |
| 44 else: | 53 else: |
| 45 setattr(self, name, value) | 54 setattr(self, name, value) |
| 46 | 55 |
| 47 def release(self): | 56 def release(self): |
| 48 return self.connection.release_address(self.public_ip) | 57 return self.connection.release_address(self.public_ip) |
| 49 | 58 |
| 50 delete = release | 59 delete = release |
| 51 | 60 |
| 52 def associate(self, instance_id): | 61 def associate(self, instance_id): |
| 53 return self.connection.associate_address(instance_id, self.public_ip) | 62 return self.connection.associate_address(instance_id, self.public_ip) |
| 54 | 63 |
| 55 def disassociate(self): | 64 def disassociate(self): |
| 56 return self.connection.disassociate_address(self.public_ip) | 65 return self.connection.disassociate_address(self.public_ip) |
| 57 | 66 |
| 58 | 67 |
| OLD | NEW |