Skip to content
Snippets Groups Projects
Commit 742c0a3f authored by Shayan Hajipour's avatar Shayan Hajipour
Browse files

Merge branch 'feat/239-cttc-driver-required-to-interact-with-nce-controller'...

Merge branch 'feat/239-cttc-driver-required-to-interact-with-nce-controller' into camara-demo-integration
parents 9d257f35 307e5ba1
No related branches found
No related tags found
2 merge requests!359Release TeraFlowSDN 5.0,!321Resolve: "(CTTC) CAMARA Demo Integration tests"
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # Copyright 2022-2025 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
......
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # Copyright 2022-2025 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
......
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # Copyright 2022-2025 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
......
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # Copyright 2022-2025 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
...@@ -195,8 +195,10 @@ class NCEDriver(_Driver): ...@@ -195,8 +195,10 @@ class NCEDriver(_Driver):
self, resources: List[Tuple[str, Any]] self, resources: List[Tuple[str, Any]]
) -> List[Union[bool, Exception]]: ) -> List[Union[bool, Exception]]:
results = [] results = []
if len(resources) == 0: if len(resources) == 0:
return results return results
with self.__lock: with self.__lock:
for resource in resources: for resource in resources:
resource_key, resource_value = resource resource_key, resource_value = resource
...@@ -215,13 +217,14 @@ class NCEDriver(_Driver): ...@@ -215,13 +217,14 @@ class NCEDriver(_Driver):
try: try:
resource_value = json.loads(resource_value) resource_value = json.loads(resource_value)
if operation_type == "create": if operation_type == "create":
self.nce.create_app_flow(resource_value) self.nce.create_app_flow(resource_value)
elif operation_type == "delete": elif operation_type == "delete":
app_flow_name = resource_value["huawei-nce-app-flow:app-flows"][ app_flow_name = resource_value["huawei-nce-app-flow:app-flows"][
"app-flow" "app-flow"
][0]["app-name"] ][0]["app-name"]
self.nce.delete_app_flow(app_flow_name) self.nce.delete_app_flow(app_flow_name)
LOGGER.debug(f"app_flow_datamodel {resource_value}")
results.append((resource_key, True)) results.append((resource_key, True))
except Exception as e: # pylint: disable=broad-except except Exception as e: # pylint: disable=broad-except
LOGGER.exception( LOGGER.exception(
...@@ -244,10 +247,6 @@ class NCEDriver(_Driver): ...@@ -244,10 +247,6 @@ class NCEDriver(_Driver):
LOGGER.info("resource = {:s}".format(str(resource))) LOGGER.info("resource = {:s}".format(str(resource)))
resource_key, resource_value = resource resource_key, resource_value = resource
try: try:
# resource_value = json.loads(resource_value)
# service_uuid = resource_value["uuid"]
# if service_exists(self.__tfs_nbi_root, self.__auth, service_uuid):
# self.tac.delete_connectivity_service(service_uuid)
results.append((resource_key, True)) results.append((resource_key, True))
except Exception as e: # pylint: disable=broad-except except Exception as e: # pylint: disable=broad-except
LOGGER.exception( LOGGER.exception(
......
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # Copyright 2022-2025 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
...@@ -71,6 +71,7 @@ class NCEClient: ...@@ -71,6 +71,7 @@ class NCEClient:
app_url = self._nce_fan_url + "/app-flows/apps" app_url = self._nce_fan_url + "/app-flows/apps"
LOGGER.info(f'Creating app: {app_data} URL: {app_url}') LOGGER.info(f'Creating app: {app_data} URL: {app_url}')
requests.post(app_url, json=app_data, headers=HEADERS) requests.post(app_url, json=app_data, headers=HEADERS)
app_flow_data = { app_flow_data = {
"app-flow": app_flow_data["huawei-nce-app-flow:app-flows"]["app-flow"] "app-flow": app_flow_data["huawei-nce-app-flow:app-flows"]["app-flow"]
} }
...@@ -85,6 +86,7 @@ class NCEClient: ...@@ -85,6 +86,7 @@ class NCEClient:
app_url = self._nce_fan_url + f"/app-flows/apps/application={app_flow_name}" app_url = self._nce_fan_url + f"/app-flows/apps/application={app_flow_name}"
LOGGER.info(f'Deleting app: {app_flow_name} URL: {app_url}') LOGGER.info(f'Deleting app: {app_flow_name} URL: {app_url}')
requests.delete(app_url) requests.delete(app_url)
app_flow_url = self._nce_fan_url + f"/app-flows/app-flow={app_flow_name}" app_flow_url = self._nce_fan_url + f"/app-flows/app-flow={app_flow_name}"
LOGGER.info(f'Deleting app flow: {app_flow_name} URL: {app_flow_url}') LOGGER.info(f'Deleting app flow: {app_flow_name} URL: {app_flow_url}')
requests.delete(app_flow_url) requests.delete(app_flow_url)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment