Loading src/nbi/service/sse_telemetry/create_subscription.py +35 −9 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ from common.proto.monitoring_pb2 import ( SSEMonitoringSubscriptionConfig, SSEMonitoringSubscriptionResponse, ) from common.tools.rest_conf.client.RestConfClient import RestConfClient from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from nbi.service._tools.Authentication import HTTP_AUTH Loading Loading @@ -71,32 +72,57 @@ class CreateSubscription(Resource): raise UnsupportedMediaType('JSON payload is required') LOGGER.debug('Received subscription request data: {:s}'.format(str(request_data))) rest_conf_client = RestConfClient( '10.254.0.9', port=8080, scheme='http', username='admin', password='admin', logger=logging.getLogger('RestConfClient') ) # break the request into its abstract components for telemetry subscription list_db_ids = list_identifiers(db) request_identifier = str( choice([x for x in range(1000, 10000) if x not in list_db_ids]) ) sub_subs = decompose_subscription(request_data) sub_subs = decompose_subscription(rest_conf_client, request_data) # subscribe to each component device_client = DeviceClient() context_client = ContextClient() for s in sub_subs: xpath = s['ietf-subscribed-notifications:input'][ xpath_filter = s['ietf-subscribed-notifications:input'][ 'ietf-yang-push:datastore-xpath-filter' ] SERVICE_ID = '' device_controller = get_controller_name(xpath, SERVICE_ID, context_client) if device_controller == Controllers.CONTROLLERLESS: xpath_filter_prefix = xpath_filter.split('/ietf-network-topology:link')[0] xpath_network = rest_conf_client.get(xpath_filter_prefix) if not xpath_network: MSG = 'Resource({:s} => {:s}) not found in SIMAP Server' raise Exception(MSG.format(str(xpath_filter), str(xpath_filter_prefix))) network_id = xpath_network['network-id'] controller_name_map = { 'e2e' : 'TFS-E2E', 'agg' : 'TFS-AGG', 'trans-pkt': 'TFS-IP', 'trans-opt': 'NCE-T', 'access' : 'NCE-FAN', } controller_name = controller_name_map.get(network_id) if controller_name is None: LOGGER.warning( 'Controllerless device detected, skipping subscription for: {:s}'.format(xpath) ) continue #SERVICE_ID = '' #device_controller = get_controller_name(xpath, SERVICE_ID, context_client) #if device_controller == Controllers.CONTROLLERLESS: # LOGGER.warning( # 'Controllerless device detected, skipping subscription for: {:s}'.format(xpath) # ) # continue s_req = SSEMonitoringSubscriptionConfig() s_req.device_id.device_uuid.uuid = device_controller.value #s_req.device_id.device_uuid.uuid = device_controller.value s_req.device_id.device_uuid.uuid = controller_name s_req.config_type = SSEMonitoringSubscriptionConfig.Subscribe s_req.uri = xpath s_req.uri = xpath_filter s_req.sampling_interval = s['ietf-subscribed-notifications:input'][ 'ietf-yang-push:periodic' ]['ietf-yang-push:period'] Loading @@ -105,7 +131,7 @@ class CreateSubscription(Resource): uuid=str(uuid4()), identifier=r.identifier, uri=r.uri, xpath=xpath, xpath=xpath_filter, status=True, main_subscription=False, main_subscription_id=request_identifier, Loading src/nbi/service/sse_telemetry/topology.py +1 −5 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ LOGGER = logging.getLogger(__name__) def decompose_subscription( rest_conf_client : RestConfClient, s : SubscribedNotificationsSchema ) -> List[SubscribedNotificationsSchema]: """ Loading @@ -89,11 +90,6 @@ def decompose_subscription( xpath_filter = input_data['ietf-yang-push:datastore-xpath-filter'] xpath_filter_2 = xpath_filter.replace('/simap-telemetry', '') rest_conf_client = RestConfClient( '10.254.0.9', port=8080, scheme='http', username='admin', password='admin', logger=logging.getLogger('RestConfClient') ) xpath_data = rest_conf_client.get(xpath_filter_2) if not xpath_data: MSG = 'Resource({:s} => {:s}) not found in SIMAP Server' Loading Loading
src/nbi/service/sse_telemetry/create_subscription.py +35 −9 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ from common.proto.monitoring_pb2 import ( SSEMonitoringSubscriptionConfig, SSEMonitoringSubscriptionResponse, ) from common.tools.rest_conf.client.RestConfClient import RestConfClient from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from nbi.service._tools.Authentication import HTTP_AUTH Loading Loading @@ -71,32 +72,57 @@ class CreateSubscription(Resource): raise UnsupportedMediaType('JSON payload is required') LOGGER.debug('Received subscription request data: {:s}'.format(str(request_data))) rest_conf_client = RestConfClient( '10.254.0.9', port=8080, scheme='http', username='admin', password='admin', logger=logging.getLogger('RestConfClient') ) # break the request into its abstract components for telemetry subscription list_db_ids = list_identifiers(db) request_identifier = str( choice([x for x in range(1000, 10000) if x not in list_db_ids]) ) sub_subs = decompose_subscription(request_data) sub_subs = decompose_subscription(rest_conf_client, request_data) # subscribe to each component device_client = DeviceClient() context_client = ContextClient() for s in sub_subs: xpath = s['ietf-subscribed-notifications:input'][ xpath_filter = s['ietf-subscribed-notifications:input'][ 'ietf-yang-push:datastore-xpath-filter' ] SERVICE_ID = '' device_controller = get_controller_name(xpath, SERVICE_ID, context_client) if device_controller == Controllers.CONTROLLERLESS: xpath_filter_prefix = xpath_filter.split('/ietf-network-topology:link')[0] xpath_network = rest_conf_client.get(xpath_filter_prefix) if not xpath_network: MSG = 'Resource({:s} => {:s}) not found in SIMAP Server' raise Exception(MSG.format(str(xpath_filter), str(xpath_filter_prefix))) network_id = xpath_network['network-id'] controller_name_map = { 'e2e' : 'TFS-E2E', 'agg' : 'TFS-AGG', 'trans-pkt': 'TFS-IP', 'trans-opt': 'NCE-T', 'access' : 'NCE-FAN', } controller_name = controller_name_map.get(network_id) if controller_name is None: LOGGER.warning( 'Controllerless device detected, skipping subscription for: {:s}'.format(xpath) ) continue #SERVICE_ID = '' #device_controller = get_controller_name(xpath, SERVICE_ID, context_client) #if device_controller == Controllers.CONTROLLERLESS: # LOGGER.warning( # 'Controllerless device detected, skipping subscription for: {:s}'.format(xpath) # ) # continue s_req = SSEMonitoringSubscriptionConfig() s_req.device_id.device_uuid.uuid = device_controller.value #s_req.device_id.device_uuid.uuid = device_controller.value s_req.device_id.device_uuid.uuid = controller_name s_req.config_type = SSEMonitoringSubscriptionConfig.Subscribe s_req.uri = xpath s_req.uri = xpath_filter s_req.sampling_interval = s['ietf-subscribed-notifications:input'][ 'ietf-yang-push:periodic' ]['ietf-yang-push:period'] Loading @@ -105,7 +131,7 @@ class CreateSubscription(Resource): uuid=str(uuid4()), identifier=r.identifier, uri=r.uri, xpath=xpath, xpath=xpath_filter, status=True, main_subscription=False, main_subscription_id=request_identifier, Loading
src/nbi/service/sse_telemetry/topology.py +1 −5 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ LOGGER = logging.getLogger(__name__) def decompose_subscription( rest_conf_client : RestConfClient, s : SubscribedNotificationsSchema ) -> List[SubscribedNotificationsSchema]: """ Loading @@ -89,11 +90,6 @@ def decompose_subscription( xpath_filter = input_data['ietf-yang-push:datastore-xpath-filter'] xpath_filter_2 = xpath_filter.replace('/simap-telemetry', '') rest_conf_client = RestConfClient( '10.254.0.9', port=8080, scheme='http', username='admin', password='admin', logger=logging.getLogger('RestConfClient') ) xpath_data = rest_conf_client.get(xpath_filter_2) if not xpath_data: MSG = 'Resource({:s} => {:s}) not found in SIMAP Server' Loading