OLD | NEW |
1 # Copyright (c) 2009 Reza Lotun http://reza.lotun.name/ | 1 # Copyright (c) 2009 Reza Lotun http://reza.lotun.name/ |
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 class Instance(object): | 23 class Instance(object): |
24 def __init__(self, connection=None): | 24 def __init__(self, connection=None): |
25 self.connection = connection | 25 self.connection = connection |
26 self.instance_id = '' | 26 self.instance_id = None |
| 27 self.health_status = None |
| 28 self.launch_config_name = None |
27 self.lifecycle_state = None | 29 self.lifecycle_state = None |
28 self.availability_zone = '' | 30 self.availability_zone = None |
| 31 self.group_name = None |
29 | 32 |
30 def __repr__(self): | 33 def __repr__(self): |
31 return 'Instance:%s' % self.instance_id | 34 r = 'Instance<id:%s, state:%s, health:%s' % (self.instance_id, |
| 35 self.lifecycle_state, |
| 36 self.health_status) |
| 37 if self.group_name: |
| 38 r += ' group:%s' % self.group_name |
| 39 r += '>' |
| 40 return r |
32 | 41 |
33 def startElement(self, name, attrs, connection): | 42 def startElement(self, name, attrs, connection): |
34 return None | 43 return None |
35 | 44 |
36 def endElement(self, name, value, connection): | 45 def endElement(self, name, value, connection): |
37 if name == 'InstanceId': | 46 if name == 'InstanceId': |
38 self.instance_id = value | 47 self.instance_id = value |
| 48 elif name == 'HealthStatus': |
| 49 self.health_status = value |
| 50 elif name == 'LaunchConfigurationName': |
| 51 self.launch_config_name = value |
39 elif name == 'LifecycleState': | 52 elif name == 'LifecycleState': |
40 self.lifecycle_state = value | 53 self.lifecycle_state = value |
41 elif name == 'AvailabilityZone': | 54 elif name == 'AvailabilityZone': |
42 self.availability_zone = value | 55 self.availability_zone = value |
| 56 elif name == 'AutoScalingGroupName': |
| 57 self.group_name = value |
43 else: | 58 else: |
44 setattr(self, name, value) | 59 setattr(self, name, value) |
45 | 60 |
46 | |
OLD | NEW |