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/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 } ] ])