OLD | NEW |
1 # Copyright (c) 2009 Mitch Garnaat http://garnaat.org/ | 1 # Copyright (c) 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 class BlockDeviceType(object): | 23 class BlockDeviceType(object): |
24 | 24 |
25 def __init__(self, connection=None): | 25 def __init__(self, |
| 26 connection=None, |
| 27 ephemeral_name=None, |
| 28 no_device=False, |
| 29 volume_id=None, |
| 30 snapshot_id=None, |
| 31 status=None, |
| 32 attach_time=None, |
| 33 delete_on_termination=False, |
| 34 size=None): |
26 self.connection = connection | 35 self.connection = connection |
27 self.ephemeral_name = None | 36 self.ephemeral_name = ephemeral_name |
28 self.no_device = False | 37 self.no_device = no_device |
29 self.volume_id = None | 38 self.volume_id = volume_id |
30 self.snapshot_id = None | 39 self.snapshot_id = snapshot_id |
31 self.status = None | 40 self.status = status |
32 self.attach_time = None | 41 self.attach_time = attach_time |
33 self.delete_on_termination = False | 42 self.delete_on_termination = delete_on_termination |
34 self.size = None | 43 self.size = size |
35 | 44 |
36 def startElement(self, name, attrs, connection): | 45 def startElement(self, name, attrs, connection): |
37 pass | 46 pass |
38 | 47 |
39 def endElement(self, name, value, connection): | 48 def endElement(self, name, value, connection): |
40 if name =='volumeId': | 49 if name =='volumeId': |
41 self.volume_id = value | 50 self.volume_id = value |
42 elif name == 'virtualName': | 51 elif name == 'virtualName': |
43 self.ephemeral_name = value | 52 self.ephemeral_name = value |
44 elif name =='NoDevice': | 53 elif name =='NoDevice': |
(...skipping 19 matching lines...) Expand all Loading... |
64 | 73 |
65 class BlockDeviceMapping(dict): | 74 class BlockDeviceMapping(dict): |
66 | 75 |
67 def __init__(self, connection=None): | 76 def __init__(self, connection=None): |
68 dict.__init__(self) | 77 dict.__init__(self) |
69 self.connection = connection | 78 self.connection = connection |
70 self.current_name = None | 79 self.current_name = None |
71 self.current_value = None | 80 self.current_value = None |
72 | 81 |
73 def startElement(self, name, attrs, connection): | 82 def startElement(self, name, attrs, connection): |
74 if name == 'ebs': | 83 if name == 'ebs' or name == 'virtualName': |
75 self.current_value = BlockDeviceType(self) | 84 self.current_value = BlockDeviceType(self) |
76 return self.current_value | 85 return self.current_value |
77 | 86 |
78 def endElement(self, name, value, connection): | 87 def endElement(self, name, value, connection): |
79 if name == 'device' or name == 'deviceName': | 88 if name == 'device' or name == 'deviceName': |
80 self.current_name = value | 89 self.current_name = value |
81 elif name == 'item': | 90 elif name == 'item': |
82 self[self.current_name] = self.current_value | 91 self[self.current_name] = self.current_value |
83 | 92 |
84 def build_list_params(self, params, prefix=''): | 93 def build_list_params(self, params, prefix=''): |
85 i = 1 | 94 i = 1 |
86 for dev_name in self: | 95 for dev_name in self: |
87 pre = '%sBlockDeviceMapping.%d' % (prefix, i) | 96 pre = '%sBlockDeviceMapping.%d' % (prefix, i) |
88 params['%s.DeviceName' % pre] = dev_name | 97 params['%s.DeviceName' % pre] = dev_name |
89 block_dev = self[dev_name] | 98 block_dev = self[dev_name] |
90 if block_dev.ephemeral_name: | 99 if block_dev.ephemeral_name: |
91 params['%s.VirtualName' % pre] = block_dev.ephemeral_name | 100 params['%s.VirtualName' % pre] = block_dev.ephemeral_name |
92 else: | 101 else: |
93 if block_dev.no_device: | 102 if block_dev.no_device: |
94 params['%s.Ebs.NoDevice' % pre] = 'true' | 103 params['%s.Ebs.NoDevice' % pre] = 'true' |
95 if block_dev.snapshot_id: | 104 if block_dev.snapshot_id: |
96 params['%s.Ebs.SnapshotId' % pre] = block_dev.snapshot_id | 105 params['%s.Ebs.SnapshotId' % pre] = block_dev.snapshot_id |
97 if block_dev.size: | 106 if block_dev.size: |
98 params['%s.Ebs.VolumeSize' % pre] = block_dev.size | 107 params['%s.Ebs.VolumeSize' % pre] = block_dev.size |
99 if block_dev.delete_on_termination: | 108 if block_dev.delete_on_termination: |
100 params['%s.Ebs.DeleteOnTermination' % pre] = 'true' | 109 params['%s.Ebs.DeleteOnTermination' % pre] = 'true' |
101 else: | 110 else: |
102 params['%s.Ebs.DeleteOnTermination' % pre] = 'false' | 111 params['%s.Ebs.DeleteOnTermination' % pre] = 'false' |
103 i += 1 | 112 i += 1 |
OLD | NEW |