Loading src/common/tools/object_factory/Device.py +2 −1 Original line number Diff line number Diff line Loading @@ -90,7 +90,8 @@ def json_device_microwave_disabled( drivers : List[Dict] = DEVICE_MICROWAVE_DRIVERS ): return json_device( device_uuid, DEVICE_MICROWAVE_TYPE, DEVICE_DISABLED, endpoints=endpoints, config_rules=config_rules, drivers=drivers) device_uuid, DEVICE_MICROWAVE_TYPE, DEVICE_DISABLED, endpoints=endpoints, config_rules=config_rules, drivers=drivers) def json_device_p4_disabled( device_uuid : str, endpoints : List[Dict] = [], config_rules : List[Dict] = [], Loading src/device/service/drivers/microwave/IETFApiDriver.py +3 −5 Original line number Diff line number Diff line Loading @@ -65,7 +65,6 @@ class IETFApiDriver(_Driver): results.extend(config_getter(self.__ietf_root, resource_key, self.__timeout)) return results def SetConfig(self, resources: List[Tuple[str, Any]]) -> List[Union[bool, Exception]]: results = [] if len(resources) == 0: Loading @@ -86,7 +85,6 @@ class IETFApiDriver(_Driver): results.extend(data) return results def DeleteConfig(self, resources: List[Tuple[str, Any]]) -> List[Union[bool, Exception]]: results = [] if len(resources) == 0: return results Loading @@ -98,15 +96,15 @@ class IETFApiDriver(_Driver): return results def SubscribeState(self, subscriptions : List[Tuple[str, float, float]]) -> List[Union[bool, Exception]]: # TODO: TAPI does not support monitoring by now # TODO: IETF API Driver does not support monitoring by now return [False for _ in subscriptions] def UnsubscribeState(self, subscriptions : List[Tuple[str, float, float]]) -> List[Union[bool, Exception]]: # TODO: TAPI does not support monitoring by now # TODO: IETF API Driver does not support monitoring by now return [False for _ in subscriptions] def GetState( self, blocking=False, terminate : Optional[threading.Event] = None ) -> Iterator[Tuple[float, str, Any]]: # TODO: TAPI does not support monitoring by now # TODO: IETF API Driver does not support monitoring by now return [] src/device/service/drivers/microwave/Tools.py +56 −82 Original line number Diff line number Diff line Loading @@ -22,21 +22,28 @@ def find_key(resource, key): return json.loads(resource[1])[key] # this function exports only the endpoints which are not already involved in a microwave physical link def isAnExportableEndpoint(node, termination_point_id, links): def is_exportable_endpoint(node, termination_point_id, links): # for each link we check if the endpoint (termination_point_id) is already used by an existing link for link in links: src = link['source'] dest = link['destination'] if dest['dest-node'] == node and dest['dest-tp'] == termination_point_id: return False elif src['source-node'] == node and src['source-tp'] == termination_point_id: if src['source-node'] == node and src['source-tp'] == termination_point_id: return False return True def config_getter(root_url, resource_key, timeout): # getting endpoints url = '{:s}/nmswebs/restconf/data/ietf-network:networks/network=SIAE-ETH-TOPOLOGY?fields=ietf-network-topology:link(link-id;destination(dest-node;dest-tp);source(source-node;source-tp));node(node-id;ietf-network-topology:termination-point(tp-id;ietf-te-topology:te/name)))'.format(root_url) network_name = 'SIAE-ETH-TOPOLOGY' FIELDS = ''.join([ 'ietf-network-topology:', 'link(link-id;destination(dest-node;dest-tp);source(source-node;source-tp));', 'node(node-id;ietf-network-topology:termination-point(tp-id;ietf-te-topology:te/name)))', ]) URL_TEMPLATE = '{:s}/nmswebs/restconf/data/ietf-network:networks/network={:s}?fields={:s}' url = URL_TEMPLATE.format(root_url, network_name, FIELDS) result = [] try: response = requests.get(url, timeout=timeout, verify=False) Loading @@ -47,21 +54,18 @@ def config_getter(root_url, resource_key, timeout): result.append((resource_key, e)) else: context = json.loads(response.content) if resource_key == RESOURCE_ENDPOINTS: if not (context.get('ietf-network:network') is None): network_instance = context['ietf-network:network'] if not (network_instance.get('ietf-network-topology:link') is None): links = network_instance['ietf-network-topology:link'] network_instance = context.get('ietf-network:network', {}) links = network_instance.get('ietf-network-topology:link', []) for sip in network_instance['node']: tp = sip['ietf-network-topology:termination-point'] node_id = sip['node-id'] for te in tp: tp_id = te['tp-id'] if isAnExportableEndpoint(node_id, tp_id, links): result.append(('/endpoints/endpoint[{:s}:{:s}]'.format(node_id,tp_id), {'uuid': tp_id, 'type': te['ietf-te-topology:te']['name']})) if not is_exportable_endpoint(node_id, tp_id, links): continue resource_key = '/endpoints/endpoint[{:s}:{:s}]'.format(node_id,tp_id) resource_value = {'uuid': tp_id, 'type': te['ietf-te-topology:te']['name']} result.append((resource_key, resource_value)) # getting created services url = '{:s}/nmswebs/restconf/data/ietf-eth-tran-service:etht-svc'.format(root_url) Loading @@ -74,76 +78,47 @@ def config_getter(root_url, resource_key, timeout): result.append((resource_key, e)) else: context = json.loads(response.content) if resource_key == RESOURCE_ENDPOINTS: if not (context.get('ietf-eth-tran-service:etht-svc') is None): etht_service = context['ietf-eth-tran-service:etht-svc'] if not (etht_service.get('etht-svc-instances') is None): service_instances = etht_service['etht-svc-instances'] etht_service = context.get('ietf-eth-tran-service:etht-svc', {}) service_instances = etht_service.get('etht-svc-instances', []) for service in service_instances: service_name = service['etht-svc-name'] result.append(('/services/service[{:s}]'.format(service_name), {'uuid': service_name, 'type': service['etht-svc-type']})) resource_key = '/services/service[{:s}]'.format(service_name) resource_value = {'uuid': service_name, 'type': service['etht-svc-type']} result.append((resource_key, resource_value)) return result def create_connectivity_service( root_url, timeout, uuid, node_id_src, tp_id_src, node_id_dst, tp_id_dst, vlan_id): url = '{:s}/nmswebs/restconf/data/ietf-eth-tran-service:etht-svc'.format(root_url) headers = {'content-type': 'application/json'} data = {} data = { "etht-svc-instances": [ 'etht-svc-instances': [ { "etht-svc-name": uuid, "etht-svc-type": "ietf-eth-tran-types:p2p-svc", "etht-svc-end-points": [ 'etht-svc-name': uuid, 'etht-svc-type': 'ietf-eth-tran-types:p2p-svc', 'etht-svc-end-points': [ { "etht-svc-access-points": [ { "access-node-id": node_id_src, "access-ltp-id": tp_id_src, "access-point-id": "1" } 'etht-svc-access-points': [ {'access-node-id': node_id_src, 'access-ltp-id': tp_id_src, 'access-point-id': '1'} ], "outer-tag": { "vlan-value": vlan_id, "tag-type": "ietf-eth-tran-types:classify-c-vlan" 'outer-tag': {'vlan-value': vlan_id, 'tag-type': 'ietf-eth-tran-types:classify-c-vlan'}, 'etht-svc-end-point-name': '{:s}:{:s}'.format(str(node_id_src), str(tp_id_src)), 'service-classification-type': 'ietf-eth-tran-types:vlan-classification' }, "etht-svc-end-point-name": node_id_src+':'+str(tp_id_src), "service-classification-type": "ietf-eth-tran-types:vlan-classification" }, { "etht-svc-access-points": [ { "access-node-id": node_id_dst, "access-ltp-id": tp_id_dst, "access-point-id": "2" } 'etht-svc-access-points': [ {'access-node-id': node_id_dst, 'access-ltp-id': tp_id_dst, 'access-point-id': '2'} ], "outer-tag": { "vlan-value": vlan_id, "tag-type": "ietf-eth-tran-types:classify-c-vlan" }, "etht-svc-end-point-name": node_id_dst+':'+str(tp_id_dst), "service-classification-type": "ietf-eth-tran-types:vlan-classification" 'outer-tag': {'vlan-value': vlan_id, 'tag-type': 'ietf-eth-tran-types:classify-c-vlan'}, 'etht-svc-end-point-name': '{:s}:{:s}'.format(str(node_id_dst), str(tp_id_dst)), 'service-classification-type': 'ietf-eth-tran-types:vlan-classification' } ] } ] } results = [] try: LOGGER.info('Connectivity service {:s}: {:s}'.format(str(uuid), str(data))) Loading @@ -159,7 +134,6 @@ def create_connectivity_service( results.append(response.status_code == 201) return results def delete_connectivity_service(root_url, timeout, uuid): url = '{:s}/nmswebs/restconf/data/ietf-eth-tran-service:etht-svc/etht-svc-instances={:s}' url = url.format(root_url, uuid) Loading src/device/tests/Device_Microwave_Template.py +11 −11 File changed.Contains only whitespace changes. Show changes Loading
src/common/tools/object_factory/Device.py +2 −1 Original line number Diff line number Diff line Loading @@ -90,7 +90,8 @@ def json_device_microwave_disabled( drivers : List[Dict] = DEVICE_MICROWAVE_DRIVERS ): return json_device( device_uuid, DEVICE_MICROWAVE_TYPE, DEVICE_DISABLED, endpoints=endpoints, config_rules=config_rules, drivers=drivers) device_uuid, DEVICE_MICROWAVE_TYPE, DEVICE_DISABLED, endpoints=endpoints, config_rules=config_rules, drivers=drivers) def json_device_p4_disabled( device_uuid : str, endpoints : List[Dict] = [], config_rules : List[Dict] = [], Loading
src/device/service/drivers/microwave/IETFApiDriver.py +3 −5 Original line number Diff line number Diff line Loading @@ -65,7 +65,6 @@ class IETFApiDriver(_Driver): results.extend(config_getter(self.__ietf_root, resource_key, self.__timeout)) return results def SetConfig(self, resources: List[Tuple[str, Any]]) -> List[Union[bool, Exception]]: results = [] if len(resources) == 0: Loading @@ -86,7 +85,6 @@ class IETFApiDriver(_Driver): results.extend(data) return results def DeleteConfig(self, resources: List[Tuple[str, Any]]) -> List[Union[bool, Exception]]: results = [] if len(resources) == 0: return results Loading @@ -98,15 +96,15 @@ class IETFApiDriver(_Driver): return results def SubscribeState(self, subscriptions : List[Tuple[str, float, float]]) -> List[Union[bool, Exception]]: # TODO: TAPI does not support monitoring by now # TODO: IETF API Driver does not support monitoring by now return [False for _ in subscriptions] def UnsubscribeState(self, subscriptions : List[Tuple[str, float, float]]) -> List[Union[bool, Exception]]: # TODO: TAPI does not support monitoring by now # TODO: IETF API Driver does not support monitoring by now return [False for _ in subscriptions] def GetState( self, blocking=False, terminate : Optional[threading.Event] = None ) -> Iterator[Tuple[float, str, Any]]: # TODO: TAPI does not support monitoring by now # TODO: IETF API Driver does not support monitoring by now return []
src/device/service/drivers/microwave/Tools.py +56 −82 Original line number Diff line number Diff line Loading @@ -22,21 +22,28 @@ def find_key(resource, key): return json.loads(resource[1])[key] # this function exports only the endpoints which are not already involved in a microwave physical link def isAnExportableEndpoint(node, termination_point_id, links): def is_exportable_endpoint(node, termination_point_id, links): # for each link we check if the endpoint (termination_point_id) is already used by an existing link for link in links: src = link['source'] dest = link['destination'] if dest['dest-node'] == node and dest['dest-tp'] == termination_point_id: return False elif src['source-node'] == node and src['source-tp'] == termination_point_id: if src['source-node'] == node and src['source-tp'] == termination_point_id: return False return True def config_getter(root_url, resource_key, timeout): # getting endpoints url = '{:s}/nmswebs/restconf/data/ietf-network:networks/network=SIAE-ETH-TOPOLOGY?fields=ietf-network-topology:link(link-id;destination(dest-node;dest-tp);source(source-node;source-tp));node(node-id;ietf-network-topology:termination-point(tp-id;ietf-te-topology:te/name)))'.format(root_url) network_name = 'SIAE-ETH-TOPOLOGY' FIELDS = ''.join([ 'ietf-network-topology:', 'link(link-id;destination(dest-node;dest-tp);source(source-node;source-tp));', 'node(node-id;ietf-network-topology:termination-point(tp-id;ietf-te-topology:te/name)))', ]) URL_TEMPLATE = '{:s}/nmswebs/restconf/data/ietf-network:networks/network={:s}?fields={:s}' url = URL_TEMPLATE.format(root_url, network_name, FIELDS) result = [] try: response = requests.get(url, timeout=timeout, verify=False) Loading @@ -47,21 +54,18 @@ def config_getter(root_url, resource_key, timeout): result.append((resource_key, e)) else: context = json.loads(response.content) if resource_key == RESOURCE_ENDPOINTS: if not (context.get('ietf-network:network') is None): network_instance = context['ietf-network:network'] if not (network_instance.get('ietf-network-topology:link') is None): links = network_instance['ietf-network-topology:link'] network_instance = context.get('ietf-network:network', {}) links = network_instance.get('ietf-network-topology:link', []) for sip in network_instance['node']: tp = sip['ietf-network-topology:termination-point'] node_id = sip['node-id'] for te in tp: tp_id = te['tp-id'] if isAnExportableEndpoint(node_id, tp_id, links): result.append(('/endpoints/endpoint[{:s}:{:s}]'.format(node_id,tp_id), {'uuid': tp_id, 'type': te['ietf-te-topology:te']['name']})) if not is_exportable_endpoint(node_id, tp_id, links): continue resource_key = '/endpoints/endpoint[{:s}:{:s}]'.format(node_id,tp_id) resource_value = {'uuid': tp_id, 'type': te['ietf-te-topology:te']['name']} result.append((resource_key, resource_value)) # getting created services url = '{:s}/nmswebs/restconf/data/ietf-eth-tran-service:etht-svc'.format(root_url) Loading @@ -74,76 +78,47 @@ def config_getter(root_url, resource_key, timeout): result.append((resource_key, e)) else: context = json.loads(response.content) if resource_key == RESOURCE_ENDPOINTS: if not (context.get('ietf-eth-tran-service:etht-svc') is None): etht_service = context['ietf-eth-tran-service:etht-svc'] if not (etht_service.get('etht-svc-instances') is None): service_instances = etht_service['etht-svc-instances'] etht_service = context.get('ietf-eth-tran-service:etht-svc', {}) service_instances = etht_service.get('etht-svc-instances', []) for service in service_instances: service_name = service['etht-svc-name'] result.append(('/services/service[{:s}]'.format(service_name), {'uuid': service_name, 'type': service['etht-svc-type']})) resource_key = '/services/service[{:s}]'.format(service_name) resource_value = {'uuid': service_name, 'type': service['etht-svc-type']} result.append((resource_key, resource_value)) return result def create_connectivity_service( root_url, timeout, uuid, node_id_src, tp_id_src, node_id_dst, tp_id_dst, vlan_id): url = '{:s}/nmswebs/restconf/data/ietf-eth-tran-service:etht-svc'.format(root_url) headers = {'content-type': 'application/json'} data = {} data = { "etht-svc-instances": [ 'etht-svc-instances': [ { "etht-svc-name": uuid, "etht-svc-type": "ietf-eth-tran-types:p2p-svc", "etht-svc-end-points": [ 'etht-svc-name': uuid, 'etht-svc-type': 'ietf-eth-tran-types:p2p-svc', 'etht-svc-end-points': [ { "etht-svc-access-points": [ { "access-node-id": node_id_src, "access-ltp-id": tp_id_src, "access-point-id": "1" } 'etht-svc-access-points': [ {'access-node-id': node_id_src, 'access-ltp-id': tp_id_src, 'access-point-id': '1'} ], "outer-tag": { "vlan-value": vlan_id, "tag-type": "ietf-eth-tran-types:classify-c-vlan" 'outer-tag': {'vlan-value': vlan_id, 'tag-type': 'ietf-eth-tran-types:classify-c-vlan'}, 'etht-svc-end-point-name': '{:s}:{:s}'.format(str(node_id_src), str(tp_id_src)), 'service-classification-type': 'ietf-eth-tran-types:vlan-classification' }, "etht-svc-end-point-name": node_id_src+':'+str(tp_id_src), "service-classification-type": "ietf-eth-tran-types:vlan-classification" }, { "etht-svc-access-points": [ { "access-node-id": node_id_dst, "access-ltp-id": tp_id_dst, "access-point-id": "2" } 'etht-svc-access-points': [ {'access-node-id': node_id_dst, 'access-ltp-id': tp_id_dst, 'access-point-id': '2'} ], "outer-tag": { "vlan-value": vlan_id, "tag-type": "ietf-eth-tran-types:classify-c-vlan" }, "etht-svc-end-point-name": node_id_dst+':'+str(tp_id_dst), "service-classification-type": "ietf-eth-tran-types:vlan-classification" 'outer-tag': {'vlan-value': vlan_id, 'tag-type': 'ietf-eth-tran-types:classify-c-vlan'}, 'etht-svc-end-point-name': '{:s}:{:s}'.format(str(node_id_dst), str(tp_id_dst)), 'service-classification-type': 'ietf-eth-tran-types:vlan-classification' } ] } ] } results = [] try: LOGGER.info('Connectivity service {:s}: {:s}'.format(str(uuid), str(data))) Loading @@ -159,7 +134,6 @@ def create_connectivity_service( results.append(response.status_code == 201) return results def delete_connectivity_service(root_url, timeout, uuid): url = '{:s}/nmswebs/restconf/data/ietf-eth-tran-service:etht-svc/etht-svc-instances={:s}' url = url.format(root_url, uuid) Loading
src/device/tests/Device_Microwave_Template.py +11 −11 File changed.Contains only whitespace changes. Show changes