diff --git a/Changelog.md b/Changelog.md index eafddd432753310d8eb89e9aadd5c4288e48c7db..60c9f4cbd6ded2aa9535fb68b5b23756c4301152 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,9 +2,15 @@ All notable changes to this project will be documented in this file. +## [0.51] - 2020-08-20 +- POL1-137: add remaining service categories and test vectors + +## [0.50] - 2020-08-14 +- performance improvment for /poller/services + ## [0.49] - 2020-08-13 -- performance improvement /data/interfaces -- refactored a new method for testability +- performance improvement for /data/interfaces +- refactored service category sorting for better testability ## [0.48] - 2020-07-02 - recover update gracefully in case of Kombu exceptions diff --git a/inventory_provider/routes/classifier.py b/inventory_provider/routes/classifier.py index 2043dacedc8835a2e2f8153f6d3f10a275acb3e5..1673e80744ec617f0cd2c120f751dc5416a70f76 100644 --- a/inventory_provider/routes/classifier.py +++ b/inventory_provider/routes/classifier.py @@ -176,6 +176,13 @@ def get_juniper_link_info(source_equipment, interface): 'ipv4': [], 'ipv6': [] } + bundle_members = r.get( + 'netconf-interface-bundles:%s:%s' % (source_equipment, interface)) + if bundle_members: + result['interface']['bundle_members'] = \ + json.loads(bundle_members.decode('utf-8')) + else: + result['interface']['bundle_members'] = [] def _related_services(): for related in related_interfaces(source_equipment, interface): diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index e23a132fe3e3617be2f66f2b6c1b275954ef8ee9..995574e749edb2e800108b400c64878c663b0611 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -691,31 +691,40 @@ class PollerServiceCategory(str, enum.Enum): MDVPN = 'mdvpn' LHCONE_CUST = 'lhcone_cust' LHCONE_PEER = 'lhcone_peer' - L2_Circuits = 'l2_circuits' + L2_CIRCUITS = 'l2_circuits' + AUTOMATED_L2_CIRCUITS = 'automated_l2_circuits' IAS = 'ias' RE_CUST = 're_cust' RE_PEER = 're_peer' - BACKBONE = 'backbone' def _classify_interface(ifc): + if ifc['description'].startswith('SRV_MDVPN CUSTOMER'): yield PollerServiceCategory.MDVPN + if 'LHCONE' in ifc['description'] \ and 'SRV_L3VPN CUSTOMER' in ifc['description']: yield PollerServiceCategory.LHCONE_CUST + if 'LHCONE' in ifc['description'] \ and 'SRV_L3VPN RE' in ifc['description']: yield PollerServiceCategory.LHCONE_PEER - if 'SRV_L2CIRCUIT' in ifc['description'] \ - and 'SRV_L3VPN' in ifc['description']: - yield PollerServiceCategory.L2_Circuits + + if 'SRV_L2CIRCUIT' in ifc['description']: + yield PollerServiceCategory.L2_CIRCUITS + + if 'SRV_GCS' in ifc['description']: + yield PollerServiceCategory.AUTOMATED_L2_CIRCUITS + if 'PHY CUSTOMER' in ifc['description'] \ - and 'LAG CUSTOMER' in ifc['description'] \ - and 'SRV_GLOBAL CUSTOMER' in ifc['description']: + or 'LAG CUSTOMER' in ifc['description'] \ + or 'SRV_GLOBAL CUSTOMER' in ifc['description']: yield PollerServiceCategory.RE_CUST + if 'SRV_GLOBAL RE_INTERCONNECT' in ifc['description']: yield PollerServiceCategory.RE_PEER + if 'SRV_IAS CUSTOMER' in ifc['description']: yield PollerServiceCategory.IAS diff --git a/setup.py b/setup.py index fb9c8d229035a703a4b6243f7b29d24810e9f437..529b3fb4a46cbe5add42d6e53395e457388e3b05 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='inventory-provider', - version="0.50", + version="0.51", author='GEANT', author_email='swd@geant.org', description='Dashboard inventory provider', diff --git a/test/test_classifier_routes.py b/test/test_classifier_routes.py index f9ccb307cf73f69972e7b4e165402480447f3b5c..4afac35968354d664183242e34654c3907e18cab 100644 --- a/test/test_classifier_routes.py +++ b/test/test_classifier_routes.py @@ -65,7 +65,8 @@ JUNIPER_LINK_METADATA_DEFINITIONS = { }, # TODO: check what's changed: added to make tests pass - 'bundle': {"type": "array"} + 'bundle': {"type": "array"}, + 'bundle_members': {"type": "array"} }, "required": ["name", "description", "ipv4", "ipv6"], "additionalProperties": False @@ -203,7 +204,8 @@ def test_juniper_link_info_not_found(client): 'description': '', 'ipv4': [], 'ipv6': [], - 'bundle': [] + 'bundle': [], + 'bundle_members': [] }, 'locations': [{ 'a': { diff --git a/test/test_worker_utils.py b/test/test_worker_utils.py index 3ad3f358f7291e86f34be5dc26338bdc1468dbf6..da4adbdd61b6ae92a57f5bc02d0b99d23066acdb 100644 --- a/test/test_worker_utils.py +++ b/test/test_worker_utils.py @@ -65,16 +65,22 @@ def test_build_interface_services(mocked_worker_module): assert type in ('mdvpn', 'lhcone_peer', 're_peer', + 're_cust', 'ias', 'lhcone', - 'lhcone_cust') + 'lhcone_cust', + 'l2_circuits', + 'automated_l2_circuits') expected_seen_types = set(['mdvpn', 'lhcone_peer', 're_peer', + 're_cust', 'ias', 'lhcone', - 'lhcone_cust']) + 'lhcone_cust', + 'l2_circuits', + 'automated_l2_circuits']) assert seen_types == expected_seen_types @@ -127,15 +133,46 @@ def test_build_subnet_db(mocked_worker_module): # ... seems the method is not yet ready for testing @pytest.mark.parametrize('description,expected_categories', [ [ - 'SRV_L3VPN CUSTOMER ESNET LHCONE SRF9928635 | ASN293 | GEN-EEX-ESNET-LHCONE', # noqa + 'SRV_MDVPN CUSTOMER SANET SRF9939441 | VPN-Proxy to NREN CE', + { + worker.PollerServiceCategory.MDVPN + } + ], + [ + 'SRV_L3VPN CUSTOMER ESNET LHCONE SRF9928635 | ASN293 | GEN-EEX', { worker.PollerServiceCategory.LHCONE_CUST } ], [ - 'SRV_MDVPN CUSTOMER SANET SRF9939441 | VPN-Proxy to NREN CE', + 'SRV_L3VPN RE KREONET LHCONE SRF17072 | ASN17579', { - worker.PollerServiceCategory.MDVPN + worker.PollerServiceCategory.LHCONE_PEER + } + ], + [ + 'SRV_IAS CUSTOMER ACONET SRF9947199 IASPS | ASN1853', + { + worker.PollerServiceCategory.IAS + } + ], + [ + 'SRV_GLOBAL CUSTOMER HBKU SRF18085 | ASN34945|', + { + worker.PollerServiceCategory.RE_CUST + } + ], + [ + 'SRV_GLOBAL RE_INTERCONNECT HBKU SRF18085 | ASN34945|', + { + worker.PollerServiceCategory.RE_PEER + } + ], + [ + 'SRV_MDVPN CUSTOMER LHCONE SRV_L3VPN CUSTOMER SRF18085 | ASN34945|', + { + worker.PollerServiceCategory.MDVPN, + worker.PollerServiceCategory.LHCONE_CUST } ] ])