diff --git a/src/nbi/.gitlab-ci.yml b/src/nbi/.gitlab-ci.yml index 0b12f9f08b9705ce51f7ff36f0446d9c83c85bbd..7d98e61603bd3001f8f6ae418adad77a419b8371 100644 --- a/src/nbi/.gitlab-ci.yml +++ b/src/nbi/.gitlab-ci.yml @@ -56,7 +56,7 @@ unit_test nbi: - sleep 5 - docker ps -a - docker logs $IMAGE_NAME - - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" + - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py $IMAGE_NAME/tests/test_ietf_network.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: diff --git a/src/nbi/service/rest_server/nbi_plugins/ietf_network/ComposeNode.py b/src/nbi/service/rest_server/nbi_plugins/ietf_network/ComposeNode.py index e400399612cdeeedf9fd51798407ce573ff988dd..3f000f2d896977724328eb456edac7d62eb68b94 100644 --- a/src/nbi/service/rest_server/nbi_plugins/ietf_network/ComposeNode.py +++ b/src/nbi/service/rest_server/nbi_plugins/ietf_network/ComposeNode.py @@ -12,12 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging from common.proto.context_pb2 import Device from .bindings.networks.network.node import node from .ComposeTermPoint import compose_term_point from .NameMapping import NameMappings from .NetworkTypeEnum import NetworkTypeEnum +LOGGER = logging.getLogger(__name__) + NODE_NAME_MAPPINGS = { '10.0.10.1': 'OA', '10.0.20.1': 'P', @@ -28,9 +31,11 @@ NODE_NAME_MAPPINGS = { def compose_node( ietf_node_obj : node, device : Device, name_mappings : NameMappings, network_type : NetworkTypeEnum ) -> None: + device_name = device.name + LOGGER.warning('network_type={:s} device_name={:s}'.format(str(network_type.value), str(device_name))) + name_mappings.store_device_name(device) - device_name = device.name ietf_node_obj.te_node_id = device_name ietf_node_obj.te._set_oper_status('up') diff --git a/src/nbi/service/rest_server/nbi_plugins/ietf_network/ComposeTermPoint.py b/src/nbi/service/rest_server/nbi_plugins/ietf_network/ComposeTermPoint.py index 9ac03c3e7ab5574be7b4cb53511e2960b2c4bd12..1533a9c0dcae2586652f7e3ebd787e9b43172ae1 100644 --- a/src/nbi/service/rest_server/nbi_plugins/ietf_network/ComposeTermPoint.py +++ b/src/nbi/service/rest_server/nbi_plugins/ietf_network/ComposeTermPoint.py @@ -17,20 +17,32 @@ from .bindings.networks.network.node.termination_point import termination_point from .NameMapping import NameMappings from .NetworkTypeEnum import NetworkTypeEnum -TP_NAME_MAPPINGS = { - (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.10.1', '200'): '1-1-1-1-1', - (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.10.1', '500'): '1-1-1-1-1', - (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.10.1', '501'): '1-1-1-1-1', +MAPPINGS_TE_NAME = { + (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.10.1', '200'): '1-1-1-1-1', + (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.10.1', '500'): '1-1-1-1-1', + (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.10.1', '501'): '1-1-1-1-1', - (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.20.1', '500'): '1-1-1-1-1', - (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.20.1', '501'): '1-1-1-1-1', + (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.20.1', '500'): '1-1-1-1-1', + (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.20.1', '501'): '1-1-1-1-1', - (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.30.1', '200'): '1-1-1-1-1', - (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.30.1', '500'): '1-1-1-1-1', - (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.30.1', '501'): '1-1-1-1-1', + (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.30.1', '200'): '1-1-1-1-1', + (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.30.1', '500'): '1-1-1-1-1', + (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.30.1', '501'): '1-1-1-1-1', - (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.40.1', '500'): '1-1-1-1-1', - (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.40.1', '501'): '1-1-1-1-1', + (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.40.1', '500'): '1-1-1-1-1', + (NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.40.1', '501'): '1-1-1-1-1', + + (NetworkTypeEnum.TE_ETH_TRAN_TOPOLOGY, '10.0.10.1', '200'): 'endpoint:111', + (NetworkTypeEnum.TE_ETH_TRAN_TOPOLOGY, '10.0.10.1', '500'): 'endpoint:111', + (NetworkTypeEnum.TE_ETH_TRAN_TOPOLOGY, '10.0.10.1', '501'): 'endpoint:111', + + (NetworkTypeEnum.TE_ETH_TRAN_TOPOLOGY, '10.0.30.1', '200'): '172.10.33.254', + (NetworkTypeEnum.TE_ETH_TRAN_TOPOLOGY, '10.0.30.1', '500'): 'endpoint:111', + (NetworkTypeEnum.TE_ETH_TRAN_TOPOLOGY, '10.0.30.1', '501'): 'endpoint:111', +} + +MAPPINGS_TE_TP_ID = { + (NetworkTypeEnum.TE_ETH_TRAN_TOPOLOGY, '10.0.10.1', '200'): '128.32.33.254', } def compose_term_point( @@ -42,11 +54,11 @@ def compose_term_point( device_name = device.name endpoint_name = endpoint.name - ietf_tp_obj.te_tp_id = endpoint_name + ietf_tp_obj.te_tp_id = MAPPINGS_TE_TP_ID.get((network_type, device_name, endpoint_name), endpoint_name) ietf_tp_obj.te._set_oper_status('up') ietf_tp_obj.te.admin_status = 'up' - ietf_tp_obj.te.name = TP_NAME_MAPPINGS.get((network_type, device_name, endpoint_name), endpoint_name) + ietf_tp_obj.te.name = MAPPINGS_TE_NAME.get((network_type, device_name, endpoint_name), endpoint_name) if network_type == NetworkTypeEnum.TE_ETH_TRAN_TOPOLOGY: ietf_if_sw_cap = ietf_tp_obj.te.interface_switching_capability.add( diff --git a/src/nbi/service/rest_server/nbi_plugins/ietf_network/ManualFixes.py b/src/nbi/service/rest_server/nbi_plugins/ietf_network/ManualFixes.py index a5f27adaffc6e7d03cb600936d1bb73e36d4d755..778fea586b284f83fa2f9759ddac8a070b100796 100644 --- a/src/nbi/service/rest_server/nbi_plugins/ietf_network/ManualFixes.py +++ b/src/nbi/service/rest_server/nbi_plugins/ietf_network/ManualFixes.py @@ -39,7 +39,8 @@ def manual_fixes(json_response : Dict) -> None: if json_node['node-id'] in {'10.0.10.1', '10.0.30.1'}: if network_type == NetworkTypeEnum.TE_ETH_TRAN_TOPOLOGY: if 'ietf-eth-te-topology:eth-svc' in json_tp: - json_tp['ietf-eth-te-topology:eth-svc']['client-facing'] = True + client_facing = json_tp['tp-id'] == '200' + json_tp['ietf-eth-te-topology:eth-svc']['client-facing'] = client_facing json_tp_te = json_tp.get('ietf-te-topology:te', {}) diff --git a/src/nbi/tests/test_ietf_network.py b/src/nbi/tests/test_ietf_network.py index 9dad96ebb773094cc89466c5b4c885b4c83d2850..a8b8124376814cef4d51b9197f1d581f862a06ba 100644 --- a/src/nbi/tests/test_ietf_network.py +++ b/src/nbi/tests/test_ietf_network.py @@ -28,7 +28,7 @@ from .PrepareTestScenario import ( # pylint: disable=unused-import LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) -DESCRIPTOR_FILE = 'nbi/tests/data/topology_dummy.json' +DESCRIPTOR_FILE = 'nbi/tests/data/topology-dummy.json' TARGET_DATA_FILE = 'nbi/tests/data/test-ietf-network.json' JSON_ADMIN_CONTEXT_ID = json_context_id(DEFAULT_CONTEXT_NAME) @@ -81,7 +81,9 @@ def test_rest_get_networks(nbi_service_rest : RestServer): # pylint: disable=red URL = '/restconf/data/ietf-network:networks' retrieved_data = do_rest_request(URL, logger=LOGGER, expected_status_codes={200}) sort_data(retrieved_data) - sort_data(target_data ) + LOGGER.warning('retrieved_data={:s}'.format(json.dumps(retrieved_data, sort_keys=True))) + sort_data(target_data) + LOGGER.warning('target_data={:s}'.format(json.dumps(target_data, sort_keys=True))) diff_data = deepdiff.DeepDiff(target_data, retrieved_data) LOGGER.error('Differences:\n{:s}'.format(str(diff_data.pretty()))) assert len(diff_data) == 0