Ejemplo n.º 1
0
def getConfigRoutesForServers(servers:typing.List[dict], inst:TOSession) \
                                                               -> typing.Generator[str, None, None]:
    """
	Generates a list of routes to the config files for a given set of servers and a given traffic
	ops instance

	:param servers: a list of server objects
	:param inst: A valid, authenticated, and connected Traffic Ops instance
	:returns: A list of routes to config files for the ``servers``. These will be relative to the
		url of the ``inst``
	"""
    for server in servers:
        for file in inst.getServerConfigFiles(
                servername=server.hostName)[0].configFiles:
            if "apiUri" in file:
                yield file.apiUri
            else:
                logging.info(
                    "config file %s for server %s has non-API URI - skipping",
                    file.location, server.hostName)
Ejemplo n.º 2
0
def getConfigRoutesForServers(servers:typing.List[dict], inst:TOSession) \
                                                               -> typing.Generator[str, None, None]:
	"""
	Generates a list of routes to the config files for a given set of servers and a given traffic
	ops instance

	:param servers: a list of server objects
	:param inst: A valid, authenticated, and connected Traffic Ops instance
	:returns: A list of routes to config files for the ``servers``. These will be relative to the
		url of the ``inst``
	"""
	for server in servers:
		try:
			yield "/api/1.3/servers/%s/configfiles/ats" % server.hostName
			for file in inst.getServerConfigFiles(servername=server.hostName)[0].configFiles:
				if "apiUri" in file:
					yield file.apiUri
				else:
					logging.info("config file %s for server %s has non-API URI - skipping",
				                       file.location, server.hostName)
		except (AttributeError, UnicodeError, IndexError, KeyError, InvalidJSONError, OperationError) as e:
			logging.debug("%r", e, exc_info=True, stack_info=True)
			logging.error("Invalid API response for server %s config files: %s", server.hostName, e)