def create_esh_volume(esh_driver, username, identity_uuid, name, size, description=None, metadata=None, snapshot=None, image=None, raise_exception=False): quota = get_quota(identity_uuid) try: check_over_storage_quota(username, identity_uuid, new_volume_size=size) except ValidationError as over_quota: raise exceptions.OverQuotaError( message=over_quota.message) if not has_storage_count_quota(esh_driver, quota, 1): raise exceptions.OverQuotaError( message="Maximum # of Storage Volumes Exceeded") # NOTE: Calling non-standard create_volume_obj so we know the ID # of newly created volume. Libcloud just returns 'True'... --Steve conn_kwargs = {'max_attempts': 1} success, esh_volume = esh_driver.create_volume( size=size, name=name, metadata=metadata, snapshot=snapshot, image=image, **conn_kwargs) if not success and raise_exception: raise exceptions.VolumeError("The volume failed to be created.") return success, esh_volume
def create_volume(esh_driver, identity_uuid, name, size, description=None, metadata=None, snapshot=None, image=None, raise_exception=False): quota = get_quota(identity_uuid) if not has_storage_quota(esh_driver, quota, size): raise exceptions.OverQuotaError( message="Maximum total size of Storage Volumes Exceeded") if not has_storage_count_quota(esh_driver, quota, 1): raise exceptions.OverQuotaError( message="Maximum # of Storage Volumes Exceeded") # NOTE: Calling non-standard create_volume_obj so we know the ID # of newly created volume. Libcloud just returns 'True'... --Steve success, esh_volume = esh_driver.create_volume(size=size, name=name, metadata=metadata, snapshot=snapshot, image=image) if not success and raise_exception: raise exceptions.VolumeError("The volume failed to be created.") return success, esh_volume
def create_snapshot( esh_driver, username, identity_uuid, name, volume, description=None, raise_exception=False ): if not volume: raise ValueError("Volume is required to create VolumeSnapshot") try: check_over_storage_quota( username, identity_uuid, new_snapshot_size=volume.size ) except ValidationError as over_quota: raise exceptions.OverQuotaError(message=over_quota.message) esh_ss = esh_driver._connection.ex_create_snapshot( volume_id=volume.id, display_name=name, display_description=description ) if not esh_ss and raise_exception: raise exceptions.VolumeError("The volume failed to be created.") return esh_ss