def status_to_ec2_attach_status(volume):
 volume_status = volume.get('status')
 attach_status = volume.get('attach_status')
 if (volume_status in ('attaching', 'detaching')):
  ec2_attach_status = volume_status
 elif (attach_status in ('attached', 'detached')):
  ec2_attach_status = attach_status
 else:
  msg = (_('Unacceptable attach status:%s for ec2 API.') % attach_status)
  raise exception.Invalid(msg)
 return ec2_attach_status

def status_to_ec2_attach_status ( volume ) : volume_status = volume . get ( 'status' ) attach_status = volume . get ( 'attach_status' ) if ( volume_status in ( 'attaching' , 'detaching' ) ) : ec2_attach_status = volume_status elif ( attach_status in ( 'attached' , 'detached' ) ) : ec2_attach_status = attach_status else : msg = ( _ ( 'Unacceptable attach status:%s for ec2 API.' ) % attach_status ) raise exception . Invalid ( msg ) return ec2_attach_status
get the corresponding ec2 attachment state .