| 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: |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 """ | 77 """ |
| 78 Update the data associated with this volume by querying EC2. | 78 Update the data associated with this volume by querying EC2. |
| 79 | 79 |
| 80 :type validate: bool | 80 :type validate: bool |
| 81 :param validate: By default, if EC2 returns no data about the | 81 :param validate: By default, if EC2 returns no data about the |
| 82 volume the update method returns quietly. If | 82 volume the update method returns quietly. If |
| 83 the validate param is True, however, it will | 83 the validate param is True, however, it will |
| 84 raise a ValueError exception if no data is | 84 raise a ValueError exception if no data is |
| 85 returned from EC2. | 85 returned from EC2. |
| 86 """ | 86 """ |
| 87 rs = self.connection.get_all_volumes([self.id]) | 87 # Check the resultset since Eucalyptus ignores the volumeId param |
| 88 unfiltered_rs = self.connection.get_all_volumes([self.id]) |
| 89 rs = [ x for x in unfiltered_rs if x.id == self.id ] |
| 88 if len(rs) > 0: | 90 if len(rs) > 0: |
| 89 self._update(rs[0]) | 91 self._update(rs[0]) |
| 90 elif validate: | 92 elif validate: |
| 91 raise ValueError('%s is not a valid Volume ID' % self.id) | 93 raise ValueError('%s is not a valid Volume ID' % self.id) |
| 92 return self.status | 94 return self.status |
| 93 | 95 |
| 94 def delete(self): | 96 def delete(self): |
| 95 """ | 97 """ |
| 96 Delete this EBS volume. | 98 Delete this EBS volume. |
| 97 | 99 |
| 98 :rtype: bool | 100 :rtype: bool |
| 99 :return: True if successful | 101 :return: True if successful |
| 100 """ | 102 """ |
| 101 return self.connection.delete_volume(self.id) | 103 return self.connection.delete_volume(self.id) |
| 102 | 104 |
| 103 def attach(self, instance_id, device): | 105 def attach(self, instance_id, device): |
| 104 """ | 106 """ |
| 105 Attach this EBS volume to an EC2 instance. | 107 Attach this EBS volume to an EC2 instance. |
| 106 | 108 |
| 107 :type instance_id: str | 109 :type instance_id: str |
| 108 :param instance_id: The ID of the EC2 instance to which it will | 110 :param instance_id: The ID of the EC2 instance to which it will |
| 109 be attached. | 111 be attached. |
| 110 | 112 |
| 111 :type device: str | 113 :type device: str |
| 112 :param device: The device on the instance through which the | 114 :param device: The device on the instance through which the |
| 113 volume will be exposted (e.g. /dev/sdh) | 115 volume will be exposed (e.g. /dev/sdh) |
| 114 | 116 |
| 115 :rtype: bool | 117 :rtype: bool |
| 116 :return: True if successful | 118 :return: True if successful |
| 117 """ | 119 """ |
| 118 return self.connection.attach_volume(self.id, instance_id, device) | 120 return self.connection.attach_volume(self.id, instance_id, device) |
| 119 | 121 |
| 120 def detach(self, force=False): | 122 def detach(self, force=False): |
| 121 """ | 123 """ |
| 122 Detach this EBS volume from an EC2 instance. | 124 Detach this EBS volume from an EC2 instance. |
| 123 | 125 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 140 if self.attach_data: | 142 if self.attach_data: |
| 141 device = self.attach_data.device | 143 device = self.attach_data.device |
| 142 return self.connection.detach_volume(self.id, instance_id, device, force
) | 144 return self.connection.detach_volume(self.id, instance_id, device, force
) |
| 143 | 145 |
| 144 def create_snapshot(self, description=None): | 146 def create_snapshot(self, description=None): |
| 145 """ | 147 """ |
| 146 Create a snapshot of this EBS Volume. | 148 Create a snapshot of this EBS Volume. |
| 147 | 149 |
| 148 :type description: str | 150 :type description: str |
| 149 :param description: A description of the snapshot. Limited to 256 chara
cters. | 151 :param description: A description of the snapshot. Limited to 256 chara
cters. |
| 150 | 152 |
| 151 :rtype: bool | 153 :rtype: :class:`boto.ec2.snapshot.Snapshot` |
| 152 :return: True if successful | 154 :return: The created Snapshot object |
| 153 """ | 155 """ |
| 154 return self.connection.create_snapshot(self.id, description) | 156 return self.connection.create_snapshot(self.id, description) |
| 155 | 157 |
| 156 def volume_state(self): | 158 def volume_state(self): |
| 157 """ | 159 """ |
| 158 Returns the state of the volume. Same value as the status attribute. | 160 Returns the state of the volume. Same value as the status attribute. |
| 159 """ | 161 """ |
| 160 return self.status | 162 return self.status |
| 161 | 163 |
| 162 def attachment_state(self): | 164 def attachment_state(self): |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 self.instance_id = value | 220 self.instance_id = value |
| 219 elif name == 'status': | 221 elif name == 'status': |
| 220 self.status = value | 222 self.status = value |
| 221 elif name == 'attachTime': | 223 elif name == 'attachTime': |
| 222 self.attach_time = value | 224 self.attach_time = value |
| 223 elif name == 'device': | 225 elif name == 'device': |
| 224 self.device = value | 226 self.device = value |
| 225 else: | 227 else: |
| 226 setattr(self, name, value) | 228 setattr(self, name, value) |
| 227 | 229 |
| 230 class VolumeAttribute: |
| 231 |
| 232 def __init__(self, parent=None): |
| 233 self.id = None |
| 234 self._key_name = None |
| 235 self.attrs = {} |
| 236 |
| 237 def startElement(self, name, attrs, connection): |
| 238 if name == 'autoEnableIO': |
| 239 self._key_name = name |
| 240 return None |
| 241 |
| 242 def endElement(self, name, value, connection): |
| 243 if name == 'value': |
| 244 if value.lower() == 'true': |
| 245 self.attrs[self._key_name] = True |
| 246 else: |
| 247 self.attrs[self._key_name] = False |
| 248 elif name == 'volumeId': |
| 249 self.id = value |
| 250 else: |
| 251 setattr(self, name, value) |
| 252 |
| 253 |
| OLD | NEW |