def extract_host(host, level='backend', default_pool_name=False):
 if (host is None):
  msg = _('volume is not assigned to a host')
  raise exception.InvalidVolume(reason=msg)
 if (level == 'host'):
  hst = host.split('#')[0]
  return hst.split('@')[0]
 elif (level == 'backend'):
  return host.split('#')[0]
 elif (level == 'pool'):
  lst = host.split('#')
  if (len(lst) == 2):
   return lst[1]
  elif (default_pool_name is True):
   return DEFAULT_POOL_NAME
  else:
   return None

def extract_host ( host , level = 'backend' , default_pool_name = False ) : if ( host is None ) : msg = _ ( 'volume is not assigned to a host' ) raise exception . InvalidVolume ( reason = msg ) if ( level == 'host' ) : hst = host . split ( '#' ) [ 0 ] return hst . split ( '@' ) [ 0 ] elif ( level == 'backend' ) : return host . split ( '#' ) [ 0 ] elif ( level == 'pool' ) : lst = host . split ( '#' ) if ( len ( lst ) == 2 ) : return lst [ 1 ] elif ( default_pool_name is True ) : return DEFAULT_POOL_NAME else : return None
extract host .