def _blockdevicevolume_from_ebs_volume(ebs_volume):
 if ebs_volume.attachments:
  attached_to = unicode(ebs_volume.attachments[0]['InstanceId'])
 else:
  attached_to = None
 volume_dataset_id = _get_volume_tag(ebs_volume, DATASET_ID_LABEL)
 return BlockDeviceVolume(blockdevice_id=unicode(ebs_volume.id), size=int(GiB(ebs_volume.size).to_Byte().value), attached_to=attached_to, dataset_id=UUID(volume_dataset_id))

def _blockdevicevolume_from_ebs_volume ( ebs_volume ) : if ebs_volume . attachments : attached_to = unicode ( ebs_volume . attachments [ 0 ] [ 'InstanceId' ] ) else : attached_to = None volume_dataset_id = _get_volume_tag ( ebs_volume , DATASET_ID_LABEL ) return BlockDeviceVolume ( blockdevice_id = unicode ( ebs_volume . id ) , size = int ( GiB ( ebs_volume . size ) . to_Byte ( ) . value ) , attached_to = attached_to , dataset_id = UUID ( volume_dataset_id ) )
helper function to convert volume information from ebs format to flocker block device format .