Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/boto/ec2/address.py @ 0:d30785e31577 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author | guerler |
---|---|
date | Fri, 31 Jul 2020 00:18:57 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d30785e31577 |
---|---|
1 # Copyright (c) 2006-2009 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 from boto.ec2.ec2object import EC2Object | |
24 | |
25 | |
26 class Address(EC2Object): | |
27 """ | |
28 Represents an EC2 Elastic IP Address | |
29 | |
30 :ivar public_ip: The Elastic IP address. | |
31 :ivar instance_id: The instance the address is associated with (if any). | |
32 :ivar domain: Indicates whether the address is a EC2 address or a VPC address (standard|vpc). | |
33 :ivar allocation_id: The allocation ID for the address (VPC addresses only). | |
34 :ivar association_id: The association ID for the address (VPC addresses only). | |
35 :ivar network_interface_id: The network interface (if any) that the address is associated with (VPC addresses only). | |
36 :ivar network_interface_owner_id: The owner IID (VPC addresses only). | |
37 :ivar private_ip_address: The private IP address associated with the Elastic IP address (VPC addresses only). | |
38 """ | |
39 | |
40 def __init__(self, connection=None, public_ip=None, instance_id=None): | |
41 super(Address, self).__init__(connection) | |
42 self.connection = connection | |
43 self.public_ip = public_ip | |
44 self.instance_id = instance_id | |
45 self.domain = None | |
46 self.allocation_id = None | |
47 self.association_id = None | |
48 self.network_interface_id = None | |
49 self.network_interface_owner_id = None | |
50 self.private_ip_address = None | |
51 | |
52 def __repr__(self): | |
53 return 'Address:%s' % self.public_ip | |
54 | |
55 def endElement(self, name, value, connection): | |
56 if name == 'publicIp': | |
57 self.public_ip = value | |
58 elif name == 'instanceId': | |
59 self.instance_id = value | |
60 elif name == 'domain': | |
61 self.domain = value | |
62 elif name == 'allocationId': | |
63 self.allocation_id = value | |
64 elif name == 'associationId': | |
65 self.association_id = value | |
66 elif name == 'networkInterfaceId': | |
67 self.network_interface_id = value | |
68 elif name == 'networkInterfaceOwnerId': | |
69 self.network_interface_owner_id = value | |
70 elif name == 'privateIpAddress': | |
71 self.private_ip_address = value | |
72 else: | |
73 setattr(self, name, value) | |
74 | |
75 def release(self, dry_run=False): | |
76 """ | |
77 Free up this Elastic IP address. | |
78 :see: :meth:`boto.ec2.connection.EC2Connection.release_address` | |
79 """ | |
80 if self.allocation_id: | |
81 return self.connection.release_address( | |
82 allocation_id=self.allocation_id, | |
83 dry_run=dry_run) | |
84 else: | |
85 return self.connection.release_address( | |
86 public_ip=self.public_ip, | |
87 dry_run=dry_run | |
88 ) | |
89 | |
90 delete = release | |
91 | |
92 def associate(self, instance_id=None, network_interface_id=None, private_ip_address=None, allow_reassociation=False, dry_run=False): | |
93 """ | |
94 Associate this Elastic IP address with a currently running instance. | |
95 :see: :meth:`boto.ec2.connection.EC2Connection.associate_address` | |
96 """ | |
97 if self.allocation_id: | |
98 return self.connection.associate_address( | |
99 instance_id=instance_id, | |
100 public_ip=self.public_ip, | |
101 allocation_id=self.allocation_id, | |
102 network_interface_id=network_interface_id, | |
103 private_ip_address=private_ip_address, | |
104 allow_reassociation=allow_reassociation, | |
105 dry_run=dry_run | |
106 ) | |
107 return self.connection.associate_address( | |
108 instance_id=instance_id, | |
109 public_ip=self.public_ip, | |
110 network_interface_id=network_interface_id, | |
111 private_ip_address=private_ip_address, | |
112 allow_reassociation=allow_reassociation, | |
113 dry_run=dry_run | |
114 ) | |
115 | |
116 def disassociate(self, dry_run=False): | |
117 """ | |
118 Disassociate this Elastic IP address from a currently running instance. | |
119 :see: :meth:`boto.ec2.connection.EC2Connection.disassociate_address` | |
120 """ | |
121 if self.association_id: | |
122 return self.connection.disassociate_address( | |
123 association_id=self.association_id, | |
124 dry_run=dry_run | |
125 ) | |
126 else: | |
127 return self.connection.disassociate_address( | |
128 public_ip=self.public_ip, | |
129 dry_run=dry_run | |
130 ) |