From 52f0c20fa08d2f5d87607a7af63c4c5d09248599 Mon Sep 17 00:00:00 2001 From: Robert Latta <robert.latta@geant.org> Date: Tue, 21 Apr 2020 09:32:47 +0000 Subject: [PATCH] removed otrs stuff for separate commit --- inventory_provider/db/ims_data.py | 123 ------------------------------ 1 file changed, 123 deletions(-) diff --git a/inventory_provider/db/ims_data.py b/inventory_provider/db/ims_data.py index cee29568..9438aebe 100644 --- a/inventory_provider/db/ims_data.py +++ b/inventory_provider/db/ims_data.py @@ -110,126 +110,3 @@ def lookup_pop_info(ds, hostname): def get_interface_info(ds): yield from ds.get_all_entities('InternalPort') yield from ds.get_all_entities('Port') - - -def otrs_get_customer_company_rows(ds): - yield ['customer_id', 'name', 'street', 'zip', 'city', 'country', 'url', - 'comments'] - all_cus_comps = set() - for customer in ds.get_all_entities('Customer'): - all_cus_comps.add(customer['Name']) - yield [customer['Name'].replace(' ', ''), customer['Name'], - '', '', '','', '', ''] - for vendor in ds.get_all_entities('Vendor'): - if vendor['Name'] not in all_cus_comps: - all_cus_comps.add(vendor['Name']) - yield [vendor['Name'].replace(' ', ''), vendor['Name'], - '', '', '', '', '', ''] - - -# TODO - check the rules for validation once model has been confirmed -def _is_valid_customer(cus): - if not cus['email']: - return False - return True - - -def otrs_get_customer_contacts(ds): - - def _get_customer_id2(t): - if t['Id'] == 3 or t['Name'] == 'EU NREN': - return 'OTRS-GEANT-NREN' - return '' - - for customer in ds.get_all_entities( - 'Customer', - [ - ims.CUSTOMER_PROPERTIES['CustomerRelatedContacts'], - ims.CUSTOMER_PROPERTIES['CustomerType'] - ]): - - if customer['CustomerRelatedContacts']: - - for contact in customer['CustomerRelatedContacts']: - t_customer_user = OrderedDict({ - 'email': contact['Contact']['Mail'], - 'username': contact['Contact']['Mail'], # TODO if tal_id is going to be present use that # noqa - 'customer_id': customer['Name'].replace(' ', ''), - 'customer_id_2': - _get_customer_id2(customer['CustomerType']), - 'title': '', - 'firstname': contact['Contact']['Name'], - 'lastname': - ' '.join(filter(None, [ - contact['Contact']['InFix'], - contact['Contact']['LastName'] - ])), - 'phone': '', - 'fax': '', - 'mobile': '', - 'street': '', - 'zip': '', - 'city': '', - 'country': '', - 'comments': '', - }) - if not _is_valid_customer(t_customer_user): - continue - if contact['Contact']['IsGroup']: - t_customer_user['comments'] = \ - 'Organisation imported as a user' - - yield t_customer_user - - -def otrs_get_vendor_contacts(ds): - - for vrc in ds.get_all_entities( - 'VendorRelatedContact', - [ - ims.VENDOR_RELATED_CONTACT_PROPERTIES['Vendor'], - ims.VENDOR_RELATED_CONTACT_PROPERTIES['Contact'] - ]): - t_customer_user = OrderedDict({ - 'email': vrc['Contact']['Mail'], - 'username': vrc['Contact']['Mail'], # TODO if tal_id is going to be present use that # noqa - 'customer_id': vrc['Vendor']['Name'].replace(' ', ''), - 'customer_id_2': '', - 'title': '', - 'firstname': vrc['Contact']['Name'], - 'lastname': - ' '.join(filter(None, [ - vrc['Contact']['InFix'], - vrc['Contact']['LastName'] - ])), - 'phone': '', - 'fax': '', - 'mobile': '', - 'street': '', - 'zip': '', - 'city': '', - 'country': '', - 'comments': '', - }) - if not _is_valid_customer(t_customer_user): - continue - if vrc['Contact']['IsGroup']: - t_customer_user['comments'] = \ - 'Organisation imported as a user' - - yield t_customer_user - - -def otrs_get_customer_users_rows(ds): - yield ['email', 'username', 'customer_id', 'customer_id_2', 'title', - 'firstname', 'lastname', 'phone', 'fax', 'mobile', 'street', 'zip', - 'city', 'country', 'comments'] - - def get_all_cus_user_rows(): - yield from otrs_get_customer_contacts(ds) - yield from otrs_get_vendor_contacts(ds) - - sorted_cus = sorted(get_all_cus_user_rows(), key=lambda x: x['email']) - # this will be used to prioritisation - for cu in sorted_cus: - yield list(cu.values()) -- GitLab