Skip to content

Commit

Permalink
using the request endpoints -> response_endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
YufengXin committed Oct 22, 2024
1 parent 07689d1 commit 49fb3b7
Showing 1 changed file with 34 additions and 20 deletions.
54 changes: 34 additions & 20 deletions sdx_controller/handlers/connection_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,32 @@ def get_connection_status(db, service_id: str):
# See https://sdx-docs.readthedocs.io/en/latest/specs/provisioning-api-1.0.html#request-format-2
#

response = {}

domains = breakdown.get(service_id)
logger.info(f"domains for {service_id}: {domains.keys()}")

endpoints = list()
request_endpoints = []
response_endpoints = []

request = db.read_from_db("connections", service_id)
if not request:
logger.error(f"Can't find a connection request for {service_id}")
# TODO: we're in a strange state here. Should we panic?
else:
logger.info(f"Found request for {service_id}: {request}")
# We seem to have saved the original request in the form of a
# string into the DB, not a record.
request_dict = json.loads(request.get(service_id))
name = request_dict.get("name")
description = request_dict.get("description")
qos_metrics = request_dict.get("qos_metrics")
scheduling = request_dict.get("scheduling")
notifications = request_dict.get("notifications")
request_endpoints = request_dict.get("endpoints")
request_uni_a = request_endpoints[0]
request_uni_z = request_endpoints[1]

response = {}

for domain, breakdown in domains.items():
uni_a_port = breakdown.get("uni_a").get("port_id")
Expand All @@ -353,6 +373,12 @@ def get_connection_status(db, service_id: str):

endpoints.append(endpoint_a)

if request_uni_a.get("port_id") == uni_a_port:
response_endpoints.append(endpoint_a)

if request_uni_z.get("port_id") == uni_a_port:
response_endpoints.append(endpoint_a)

uni_z_port = breakdown.get("uni_z").get("port_id")
uni_z_vlan = breakdown.get("uni_z").get("tag").get("value")

Expand All @@ -363,30 +389,18 @@ def get_connection_status(db, service_id: str):

endpoints.append(endpoint_z)

if request_uni_a.get("port_id") == uni_z_port:
response_endpoints.append(endpoint_z)
if request_uni_z.get("port_id") == uni_z_port:
response_endpoints.append(endpoint_z)

# Find the name and description from the original connection
# request for this service_id.
name = "unknown"
description = "unknown"
qos_metrics = {}
scheduling = {}
notifications = {}
request_endpoints = []

request = db.read_from_db("connections", service_id)
if not request:
logger.error(f"Can't find a connection request for {service_id}")
# TODO: we're in a strange state here. Should we panic?
else:
logger.info(f"Found request for {service_id}: {request}")
# We seem to have saved the original request in the form of a
# string into the DB, not a record.
request_dict = json.loads(request.get(service_id))
name = request_dict.get("name")
description = request_dict.get("description")
qos_metrics = request_dict.get("qos_metrics")
scheduling = request_dict.get("scheduling")
notifications = request_dict.get("notifications")
request_endpoints = request_dict.get("endpoints")

# TODO: we're missing many of the attributes in the response here
# which have been specified in the provisioning spec, such as:
Expand All @@ -399,7 +413,7 @@ def get_connection_status(db, service_id: str):
"service_id": service_id,
"name": name,
"description": description,
"endpoints": request_endpoints,
"endpoints": response_endpoints,
"current_path": endpoints,
}
if qos_metrics:
Expand Down

0 comments on commit 49fb3b7

Please sign in to comment.