OLD | NEW |
1 # Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/ | 1 # Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/ |
2 # Copyright (c) 2010, Eucalyptus Systems, Inc. | 2 # Copyright (c) 2010, Eucalyptus Systems, Inc. |
3 # | 3 # |
4 # Permission is hereby granted, free of charge, to any person obtaining a | 4 # Permission is hereby granted, free of charge, to any person obtaining a |
5 # copy of this software and associated documentation files (the | 5 # copy of this software and associated documentation files (the |
6 # "Software"), to deal in the Software without restriction, including | 6 # "Software"), to deal in the Software without restriction, including |
7 # without limitation the rights to use, copy, modify, merge, publish, dis- | 7 # without limitation the rights to use, copy, modify, merge, publish, dis- |
8 # tribute, sublicense, and/or sell copies of the Software, and to permit | 8 # tribute, sublicense, and/or sell copies of the Software, and to permit |
9 # persons to whom the Software is furnished to do so, subject to the fol- | 9 # persons to whom the Software is furnished to do so, subject to the fol- |
10 # lowing conditions: | 10 # lowing conditions: |
11 # | 11 # |
12 # The above copyright notice and this permission notice shall be included | 12 # The above copyright notice and this permission notice shall be included |
13 # in all copies or substantial portions of the Software. | 13 # in all copies or substantial portions of the Software. |
14 # | 14 # |
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | 15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- | 16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- |
17 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | 17 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT |
18 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | 18 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
19 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 19 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | 20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
21 # IN THE SOFTWARE. | 21 # IN THE SOFTWARE. |
22 | 22 |
23 """ | 23 """ |
24 Represents an EC2 Elastic IP Snapshot | 24 Represents an EC2 Elastic Block Store Snapshot |
25 """ | 25 """ |
26 from boto.ec2.ec2object import TaggedEC2Object | 26 from boto.ec2.ec2object import TaggedEC2Object |
27 | 27 |
28 class Snapshot(TaggedEC2Object): | 28 class Snapshot(TaggedEC2Object): |
29 | 29 |
| 30 AttrName = 'createVolumePermission' |
| 31 |
30 def __init__(self, connection=None): | 32 def __init__(self, connection=None): |
31 TaggedEC2Object.__init__(self, connection) | 33 TaggedEC2Object.__init__(self, connection) |
32 self.id = None | 34 self.id = None |
33 self.volume_id = None | 35 self.volume_id = None |
34 self.status = None | 36 self.status = None |
35 self.progress = None | 37 self.progress = None |
36 self.start_time = None | 38 self.start_time = None |
37 self.owner_id = None | 39 self.owner_id = None |
38 self.volume_size = None | 40 self.volume_size = None |
39 self.description = None | 41 self.description = None |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 if len(rs) > 0: | 83 if len(rs) > 0: |
82 self._update(rs[0]) | 84 self._update(rs[0]) |
83 elif validate: | 85 elif validate: |
84 raise ValueError('%s is not a valid Snapshot ID' % self.id) | 86 raise ValueError('%s is not a valid Snapshot ID' % self.id) |
85 return self.progress | 87 return self.progress |
86 | 88 |
87 def delete(self): | 89 def delete(self): |
88 return self.connection.delete_snapshot(self.id) | 90 return self.connection.delete_snapshot(self.id) |
89 | 91 |
90 def get_permissions(self): | 92 def get_permissions(self): |
91 attrs = self.connection.get_snapshot_attribute(self.id, | 93 attrs = self.connection.get_snapshot_attribute(self.id, self.AttrName) |
92 attribute='createVolumePe
rmission') | |
93 return attrs.attrs | 94 return attrs.attrs |
94 | 95 |
95 def share(self, user_ids=None, groups=None): | 96 def share(self, user_ids=None, groups=None): |
96 return self.connection.modify_snapshot_attribute(self.id, | 97 return self.connection.modify_snapshot_attribute(self.id, |
97 'createVolumePermission
', | 98 self.AttrName, |
98 'add', | 99 'add', |
99 user_ids, | 100 user_ids, |
100 groups) | 101 groups) |
101 | 102 |
102 def unshare(self, user_ids=None, groups=None): | 103 def unshare(self, user_ids=None, groups=None): |
103 return self.connection.modify_snapshot_attribute(self.id, | 104 return self.connection.modify_snapshot_attribute(self.id, |
104 'createVolumePermission
', | 105 self.AttrName, |
105 'remove', | 106 'remove', |
106 user_ids, | 107 user_ids, |
107 groups) | 108 groups) |
108 | 109 |
109 def reset_permissions(self): | 110 def reset_permissions(self): |
110 return self.connection.reset_snapshot_attribute(self.id, 'createVolumePe
rmission') | 111 return self.connection.reset_snapshot_attribute(self.id, |
| 112 self.AttrName) |
111 | 113 |
112 class SnapshotAttribute: | 114 class SnapshotAttribute: |
113 | 115 |
114 def __init__(self, parent=None): | 116 def __init__(self, parent=None): |
115 self.snapshot_id = None | 117 self.snapshot_id = None |
116 self.attrs = {} | 118 self.attrs = {} |
117 | 119 |
118 def startElement(self, name, attrs, connection): | 120 def startElement(self, name, attrs, connection): |
119 return None | 121 return None |
120 | 122 |
(...skipping 10 matching lines...) Expand all Loading... |
131 self.attrs['user_ids'].append(value) | 133 self.attrs['user_ids'].append(value) |
132 else: | 134 else: |
133 self.attrs['user_ids'] = [value] | 135 self.attrs['user_ids'] = [value] |
134 elif name == 'snapshotId': | 136 elif name == 'snapshotId': |
135 self.snapshot_id = value | 137 self.snapshot_id = value |
136 else: | 138 else: |
137 setattr(self, name, value) | 139 setattr(self, name, value) |
138 | 140 |
139 | 141 |
140 | 142 |
OLD | NEW |