in source/msam/chalicelib/connections.py [0:0]
def mediaconnect_flow_mediaconnect_flow_ddb_items():
"""
Identify and format MediaConnect Flow to another MediaConnect Flow for cache storage.
"""
items = []
connection_type = "mediaconnect-flow-mediaconnect-flow"
try:
# get MediaConnect flows
mediaconnect_flows_cached = cache.cached_by_service(
"mediaconnect-flow")
for outer_flow in mediaconnect_flows_cached:
outer_flow_data = json.loads(outer_flow["data"])
# process each flow for entitlement
try:
if outer_flow_data["Source"]["EntitlementArn"]:
config = {
"from": outer_flow_data["Source"]["EntitlementArn"],
"to": outer_flow_data["FlowArn"],
"scheme": "ENTITLEMENT"
}
items.append(
connection_to_ddb_item(
outer_flow_data["Source"]["EntitlementArn"],
outer_flow_data["FlowArn"], connection_type,
config))
except Exception as error:
# print(error)
pass
# also, process each flow against each of the same set of flows for regular IP push (standard)
outer_flow_egress_ip = outer_flow_data["EgressIp"]
# check this egress ip against all the output IPs of each of the flows
for inner_flow in mediaconnect_flows_cached:
inner_flow_data = json.loads(inner_flow["data"])
for flow_output in inner_flow_data["Outputs"]:
try:
if flow_output["Destination"] == outer_flow_egress_ip:
config = {
"from":
inner_flow_data["FlowArn"],
"to":
outer_flow_data["FlowArn"],
"scheme":
flow_output["Transport"]["Protocol"].upper()
}
items.append(
connection_to_ddb_item(
inner_flow_data["FlowArn"],
outer_flow_data["FlowArn"],
connection_type, config))
except Exception as error:
# print(error)
pass
except ClientError as error:
print(error)
return items