Beispiel #1
0
def getCRConfigs(A:TOSession, B:TOSession) -> typing.Generator[str, None, None]:
	"""
	Generates a list of routes to CRConfig files for all CDNs present in both A and B

	:param A: The first Traffic Ops instance
	:param B: The second Traffic Ops instance
	:returns: A list of routes to CRConfig files
	"""
	try:
		Acdns = A.get_cdns()[0]
		Bcdns = B.get_cdns()[0]
	except (UnicodeError, IndexError, KeyError, InvalidJSONError, OperationError) as e:
		logging.debug("%r", e, exc_info=True, stack_info=True)
		logging.critical("Unable to get CDN lists: %s", e)
		return

	cdns = {c.name for c in Acdns}.intersection({c.name for c in Bcdns})

	if not cdns:
		logging.error("The two instances have NO CDNs in common! This almost certainly means that "\
		              "you're not doing what you want to do")
		return

	for cdn in cdns:
		yield "/CRConfig-Snapshots/%s/CRConfig.json" % cdn
		yield "/api/1.3/cdns/%s/snapshot" % cdn
		yield "/api/1.3/cdns/%s/snapshot/new" % cdn
def getCRConfigs(A: TOSession,
                 B: TOSession) -> typing.Generator[str, None, None]:
    """
	Generates a list of routes to CRConfig files for all CDNs present in both A and B

	:param A: The first Traffic Ops instance
	:param B: The second Traffic Ops instance
	:returns: A list of routes to CRConfig files
	"""
    cdns = {c.name
            for c in A.get_cdns()[0]
            }.intersection({c.name
                            for c in B.get_cdns()[0]})

    if not cdns:
        logging.error("The two instances have NO CDNs in common! This almost certainly means that "\
                      "you're not doing what you want to do")
    yield from ["CRConfig-Snapshots/%s/CRConfig.json" % cdn for cdn in cdns]