volume.py (ec2-api-12.0.0) | : | volume.py (ec2-api-13.0.0) | ||
---|---|---|---|---|
skipping to change at line 36 | skipping to change at line 36 | |||
LOG = logging.getLogger(__name__) | LOG = logging.getLogger(__name__) | |||
"""Volume related API implementation | """Volume related API implementation | |||
""" | """ | |||
Validator = common.Validator | Validator = common.Validator | |||
def create_volume(context, availability_zone=None, size=None, | def create_volume(context, availability_zone=None, size=None, | |||
snapshot_id=None, volume_type=None, iops=None, | snapshot_id=None, volume_type=None, iops=None, | |||
encrypted=None, kms_key_id=None): | encrypted=None, kms_key_id=None, client_token=None): | |||
if client_token: | ||||
result = describe_volumes(context, | ||||
filter=[{'name': 'client-token', | ||||
'value': [client_token]}]) | ||||
if result['volumeSet']: | ||||
if len(result['volumeSet']) > 1: | ||||
LOG.error('describe_volumes returns %s ' | ||||
'volumes, but 1 is expected.', | ||||
len(result['volumeSet'])) | ||||
LOG.error('Requested client token: %s', client_token) | ||||
LOG.error('Result: %s', result) | ||||
return result['volumeSet'][0] | ||||
if snapshot_id is not None: | if snapshot_id is not None: | |||
snapshot = ec2utils.get_db_item(context, snapshot_id) | snapshot = ec2utils.get_db_item(context, snapshot_id) | |||
os_snapshot_id = snapshot['os_id'] | os_snapshot_id = snapshot['os_id'] | |||
else: | else: | |||
os_snapshot_id = None | os_snapshot_id = None | |||
cinder = clients.cinder(context) | cinder = clients.cinder(context) | |||
with common.OnCrashCleaner() as cleaner: | with common.OnCrashCleaner() as cleaner: | |||
os_volume = cinder.volumes.create( | os_volume = cinder.volumes.create( | |||
size, snapshot_id=os_snapshot_id, volume_type=volume_type, | size, snapshot_id=os_snapshot_id, volume_type=volume_type, | |||
skipping to change at line 116 | skipping to change at line 130 | |||
# NOTE(andrey-mp) Don't delete item from DB until it disappears from Cloud | # NOTE(andrey-mp) Don't delete item from DB until it disappears from Cloud | |||
# It will be deleted by describer in the future | # It will be deleted by describer in the future | |||
return True | return True | |||
class VolumeDescriber(common.TaggableItemsDescriber): | class VolumeDescriber(common.TaggableItemsDescriber): | |||
KIND = 'vol' | KIND = 'vol' | |||
SORT_KEY = 'volumeId' | SORT_KEY = 'volumeId' | |||
FILTER_MAP = { | FILTER_MAP = { | |||
'availability-zone': 'availabilityZone', | 'availability-zone': 'availabilityZone', | |||
'client-token': 'clientToken', | ||||
'create-time': 'createTime', | 'create-time': 'createTime', | |||
'encrypted': 'encrypted', | 'encrypted': 'encrypted', | |||
'size': 'size', | 'size': 'size', | |||
'snapshot-id': 'snapshotId', | 'snapshot-id': 'snapshotId', | |||
'status': 'status', | 'status': 'status', | |||
'volume-id': 'volumeId', | 'volume-id': 'volumeId', | |||
'volume-type': 'volumeType', | 'volume-type': 'volumeType', | |||
'attachment.delete-on-termination': | 'attachment.delete-on-termination': | |||
['attachmentSet', 'deleteOnTermination'], | ['attachmentSet', 'deleteOnTermination'], | |||
'attachment.device': ['attachmentSet', 'device'], | 'attachment.device': ['attachmentSet', 'device'], | |||
End of changes. 2 change blocks. | ||||
1 lines changed or deleted | 16 lines changed or added |