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 from boto.ec2.elb.healthcheck import HealthCheck | 22 from boto.ec2.elb.healthcheck import HealthCheck |
23 from boto.ec2.elb.listener import Listener | 23 from boto.ec2.elb.listener import Listener |
24 from boto.ec2.elb.listelement import ListElement | 24 from boto.ec2.elb.listelement import ListElement |
25 from boto.ec2.elb.policies import Policies | 25 from boto.ec2.elb.policies import Policies |
| 26 from boto.ec2.elb.securitygroup import SecurityGroup |
26 from boto.ec2.instanceinfo import InstanceInfo | 27 from boto.ec2.instanceinfo import InstanceInfo |
27 from boto.resultset import ResultSet | 28 from boto.resultset import ResultSet |
28 | 29 |
29 class LoadBalancer(object): | 30 class LoadBalancer(object): |
30 """ | 31 """ |
31 Represents an EC2 Load Balancer | 32 Represents an EC2 Load Balancer |
32 """ | 33 """ |
33 | 34 |
34 def __init__(self, connection=None, name=None, endpoints=None): | 35 def __init__(self, connection=None, name=None, endpoints=None): |
35 self.connection = connection | 36 self.connection = connection |
36 self.name = name | 37 self.name = name |
37 self.listeners = None | 38 self.listeners = None |
38 self.health_check = None | 39 self.health_check = None |
39 self.policies = None | 40 self.policies = None |
40 self.dns_name = None | 41 self.dns_name = None |
41 self.created_time = None | 42 self.created_time = None |
42 self.instances = None | 43 self.instances = None |
43 self.availability_zones = ListElement() | 44 self.availability_zones = ListElement() |
| 45 self.canonical_hosted_zone_name = None |
| 46 self.canonical_hosted_zone_name_id = None |
| 47 self.source_security_group = None |
44 | 48 |
45 def __repr__(self): | 49 def __repr__(self): |
46 return 'LoadBalancer:%s' % self.name | 50 return 'LoadBalancer:%s' % self.name |
47 | 51 |
48 def startElement(self, name, attrs, connection): | 52 def startElement(self, name, attrs, connection): |
49 if name == 'HealthCheck': | 53 if name == 'HealthCheck': |
50 self.health_check = HealthCheck(self) | 54 self.health_check = HealthCheck(self) |
51 return self.health_check | 55 return self.health_check |
52 elif name == 'ListenerDescriptions': | 56 elif name == 'ListenerDescriptions': |
53 self.listeners = ResultSet([('member', Listener)]) | 57 self.listeners = ResultSet([('member', Listener)]) |
54 return self.listeners | 58 return self.listeners |
55 elif name == 'AvailabilityZones': | 59 elif name == 'AvailabilityZones': |
56 return self.availability_zones | 60 return self.availability_zones |
57 elif name == 'Instances': | 61 elif name == 'Instances': |
58 self.instances = ResultSet([('member', InstanceInfo)]) | 62 self.instances = ResultSet([('member', InstanceInfo)]) |
59 return self.instances | 63 return self.instances |
60 elif name == 'Policies': | 64 elif name == 'Policies': |
61 self.policies = Policies(self) | 65 self.policies = Policies(self) |
62 return self.policies | 66 return self.policies |
| 67 elif name == 'SourceSecurityGroup': |
| 68 self.source_security_group = SecurityGroup() |
| 69 return self.source_security_group |
63 else: | 70 else: |
64 return None | 71 return None |
65 | 72 |
66 def endElement(self, name, value, connection): | 73 def endElement(self, name, value, connection): |
67 if name == 'LoadBalancerName': | 74 if name == 'LoadBalancerName': |
68 self.name = value | 75 self.name = value |
69 elif name == 'DNSName': | 76 elif name == 'DNSName': |
70 self.dns_name = value | 77 self.dns_name = value |
71 elif name == 'CreatedTime': | 78 elif name == 'CreatedTime': |
72 self.created_time = value | 79 self.created_time = value |
73 elif name == 'InstanceId': | 80 elif name == 'InstanceId': |
74 self.instances.append(value) | 81 self.instances.append(value) |
| 82 elif name == 'CanonicalHostedZoneName': |
| 83 self.canonical_hosted_zone_name = value |
| 84 elif name == 'CanonicalHostedZoneNameID': |
| 85 self.canonical_hosted_zone_name_id = value |
75 else: | 86 else: |
76 setattr(self, name, value) | 87 setattr(self, name, value) |
77 | 88 |
78 def enable_zones(self, zones): | 89 def enable_zones(self, zones): |
79 """ | 90 """ |
80 Enable availability zones to this Access Point. | 91 Enable availability zones to this Access Point. |
81 All zones must be in the same region as the Access Point. | 92 All zones must be in the same region as the Access Point. |
82 | 93 |
83 :type zones: string or List of strings | 94 :type zones: string or List of strings |
84 :param zones: The name of the zone(s) to add. | 95 :param zones: The name of the zone(s) to add. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 184 |
174 def create_cookie_stickiness_policy(self, cookie_expiration_period, policy_n
ame): | 185 def create_cookie_stickiness_policy(self, cookie_expiration_period, policy_n
ame): |
175 return self.connection.create_lb_cookie_stickiness_policy(cookie_expirat
ion_period, self.name, policy_name) | 186 return self.connection.create_lb_cookie_stickiness_policy(cookie_expirat
ion_period, self.name, policy_name) |
176 | 187 |
177 def create_app_cookie_stickiness_policy(self, name, policy_name): | 188 def create_app_cookie_stickiness_policy(self, name, policy_name): |
178 return self.connection.create_app_cookie_stickiness_policy(name, self.na
me, policy_name) | 189 return self.connection.create_app_cookie_stickiness_policy(name, self.na
me, policy_name) |
179 | 190 |
180 def set_listener_SSL_certificate(self, lb_port, ssl_certificate_id): | 191 def set_listener_SSL_certificate(self, lb_port, ssl_certificate_id): |
181 return self.connection.set_lb_listener_SSL_certificate(self.name, lb_por
t, ssl_certificate_id) | 192 return self.connection.set_lb_listener_SSL_certificate(self.name, lb_por
t, ssl_certificate_id) |
182 | 193 |
OLD | NEW |