def get_api_servers(context):
 api_servers = []
 api_servers_info = []
 if (CONF.glance_api_servers is None):
  info = CONF.glance_catalog_info
  try:
   (service_type, service_name, endpoint_type) = info.split(':')
  except ValueError:
   raise exception.InvalidConfigurationValue(_("Failed to parse the configuration option 'glance_catalog_info', must be in the form <service_type>:<service_name>:<endpoint_type>"))
  for entry in context.service_catalog:
   if (entry.get('type') == service_type):
    api_servers.append(entry.get('endpoints')[0].get(endpoint_type))
 else:
  for api_server in CONF.glance_api_servers:
   api_servers.append(api_server)
 for api_server in api_servers:
  if ('//' not in api_server):
   api_server = ('http://' + api_server)
  url = urllib.parse.urlparse(api_server)
  netloc = (url.netloc + url.path)
  use_ssl = (url.scheme == 'https')
  api_servers_info.append((netloc, use_ssl))
 random.shuffle(api_servers_info)
 return itertools.cycle(api_servers_info)

def get_api_servers ( context ) : api_servers = [ ] api_servers_info = [ ] if ( CONF . glance_api_servers is None ) : info = CONF . glance_catalog_info try : ( service_type , service_name , endpoint_type ) = info . split ( ':' ) except ValueError : raise exception . InvalidConfigurationValue ( _ ( "Failed to parse the configuration option 'glance_catalog_info', must be in the form <service_type>:<service_name>:<endpoint_type>" ) ) for entry in context . service_catalog : if ( entry . get ( 'type' ) == service_type ) : api_servers . append ( entry . get ( 'endpoints' ) [ 0 ] . get ( endpoint_type ) ) else : for api_server in CONF . glance_api_servers : api_servers . append ( api_server ) for api_server in api_servers : if ( '//' not in api_server ) : api_server = ( 'http://' + api_server ) url = urllib . parse . urlparse ( api_server ) netloc = ( url . netloc + url . path ) use_ssl = ( url . scheme == 'https' ) api_servers_info . append ( ( netloc , use_ssl ) ) random . shuffle ( api_servers_info ) return itertools . cycle ( api_servers_info )
return iterable over shuffled api servers .