Skip to content
Snippets Groups Projects
Commit a8516fd1 authored by Release Webservice's avatar Release Webservice
Browse files

Finished release 0.94.

parents 07b9c9cd c05f8693
Branches
Tags 0.94
No related merge requests found
......@@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file.
## [0.94] - 2022-09-06
- DBOARD3-664: Added Planned Work email addresses to related-services
## [0.93] - 2022-09-05
- POL1-533: Changed services api to include services with SIDs defined on ports
- DBOARD3-663: Updated source for contact list in notifications
......
......@@ -106,7 +106,7 @@ def get_service_types(ds: IMS):
yield d['selection']
def get_customer_service_emails(ds: IMS):
def get_customer_tts_contacts(ds: IMS):
customer_contacts = defaultdict(set)
......@@ -121,6 +121,21 @@ def get_customer_service_emails(ds: IMS):
yield k, sorted(list(v))
def get_customer_planned_work_contacts(ds: IMS):
customer_contacts = defaultdict(set)
for x in ds.get_filtered_entities(
'customerrelatedcontact',
"contact.PlannedworkMail != ''",
CUSTOMER_RELATED_CONTACT_PROPERTIES['Contact']
):
customer_contacts[x['customerid']].add(
x['contact']['plannedworkmail'])
for k, v in customer_contacts.items():
yield k, sorted(list(v))
def get_circuit_related_customers(ds: IMS):
return_value = defaultdict(list)
......
......@@ -745,6 +745,7 @@ def _extract_ims_data(ims_api_url, ims_username, ims_password):
lg_routers = []
geant_nodes = []
customer_contacts = {}
planned_work_contacts = {}
circuit_ids_to_monitor = []
circuit_ids_and_sids = {}
additional_circuit_customers = {}
......@@ -772,7 +773,14 @@ def _extract_ims_data(ims_api_url, ims_username, ims_password):
def _populate_customer_contacts():
nonlocal customer_contacts
customer_contacts = \
{k: v for k, v in ims_data.get_customer_service_emails(ds=_ds())}
{k: v for k, v in ims_data.get_customer_tts_contacts(ds=_ds())}
@log_task_entry_and_exit
def _populate_customer_planned_work_contacts():
nonlocal planned_work_contacts
planned_work_contacts = \
{k: v for k, v in
ims_data.get_customer_planned_work_contacts(ds=_ds())}
@log_task_entry_and_exit
def _populate_circuit_ids_to_monitor():
......@@ -799,6 +807,8 @@ def _extract_ims_data(ims_api_url, ims_username, ims_password):
executor.submit(_populate_geant_nodes): 'geant_nodes',
executor.submit(_populate_lg_routers): 'lg_routers',
executor.submit(_populate_customer_contacts): 'customer_contacts',
executor.submit(_populate_customer_planned_work_contacts):
'planned_work_contacts',
executor.submit(_populate_circuit_ids_to_monitor):
'circuit_ids_to_monitor',
executor.submit(_populate_sids): 'sids',
......@@ -852,6 +862,7 @@ def _extract_ims_data(ims_api_url, ims_username, ims_password):
'locations': locations,
'lg_routers': lg_routers,
'customer_contacts': customer_contacts,
'planned_work_contacts': planned_work_contacts,
'circuit_ids_to_monitor': circuit_ids_to_monitor,
'circuit_ids_sids': circuit_ids_and_sids,
'additional_circuit_customers': additional_circuit_customers,
......@@ -865,6 +876,7 @@ def _extract_ims_data(ims_api_url, ims_username, ims_password):
def transform_ims_data(data):
locations = data['locations']
customer_contacts = data['customer_contacts']
planned_work_contacts = data['planned_work_contacts']
circuit_ids_to_monitor = data['circuit_ids_to_monitor']
additional_circuit_customers = data['additional_circuit_customers']
hierarchy = data['hierarchy']
......@@ -880,11 +892,16 @@ def transform_ims_data(data):
customer_ids.update(
[ac['id'] for ac in additional_circuit_customers.get(c['id'], [])]
)
return set().union(
tts_contacts = set().union(
*[customer_contacts.get(cid, []) for cid in customer_ids])
pw_contacts = set().union(
*[planned_work_contacts.get(cid, []) for cid in customer_ids])
return tts_contacts, pw_contacts
for d in hierarchy.values():
d['contacts'] = sorted(list(_get_circuit_contacts(d)))
c, ttc = _get_circuit_contacts(d)
d['contacts'] = sorted(list(c))
d['planned_work_contacts'] = sorted(list(ttc))
def _convert_to_bits(value, unit):
unit = unit.lower()
......@@ -940,7 +957,8 @@ def transform_ims_data(data):
'circuit_type': c['circuit-type'],
'service_type': c['product'],
'project': c['project'],
'contacts': c['contacts']
'contacts': c['contacts'],
'planned_work_contacts': c['planned_work_contacts']
}
if c['id'] in circuit_ids_to_monitor:
rs[c['id']]['status'] = c['status']
......@@ -1021,7 +1039,7 @@ def transform_ims_data(data):
circuits = port_id_services.get(details['port_id'], [])
for circ in circuits:
contacts = _get_circuit_contacts(circ)
contacts, pw_contacts = _get_circuit_contacts(circ)
circ['fibre-routes'] = []
for x in set(_get_fibre_routes(circ['id'])):
c = {
......@@ -1038,7 +1056,9 @@ def transform_ims_data(data):
# why were these removed?
# contacts.update(tlc.pop('contacts'))
contacts.update(tlc.get('contacts'))
pw_contacts.update(tlc.get('planned_work_contacts', []))
circ['contacts'] = sorted(list(contacts))
circ['planned_work_contacts'] = sorted(list(pw_contacts))
circ['calculated-speed'] = _get_speed(circ['id'])
_format_service(circ)
......
......@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name='inventory-provider',
version="0.93",
version="0.94",
author='GEANT',
author_email='swd@geant.org',
description='Dashboard inventory provider',
......
......@@ -21,9 +21,14 @@ def test_extract_ims_data(mocker):
return_value=['lg router 1', 'lg router 2']
)
mocker.patch(
'inventory_provider.tasks.worker.ims_data.get_customer_service_emails',
'inventory_provider.tasks.worker.ims_data.get_customer_tts_contacts',
return_value=[('123', 'CON A'), ('456', 'CON B')]
)
mocker.patch(
'inventory_provider.tasks.worker.ims_data.'
'get_customer_planned_work_contacts',
return_value=[('223', 'CON PW A'), ('556', 'CON PW B')]
)
mocker.patch(
'inventory_provider.tasks.worker.ims_data.get_monitored_circuit_ids',
return_value=[123, 456, 789]
......@@ -80,6 +85,8 @@ def test_extract_ims_data(mocker):
assert res['locations'] == {'loc_a': 'LOC A', 'loc_b': 'LOC B'}
assert res['lg_routers'] == ['lg router 1', 'lg router 2']
assert res['customer_contacts'] == {'123': 'CON A', '456': 'CON B'}
assert res['planned_work_contacts'] == \
{'223': 'CON PW A', '556': 'CON PW B'}
assert res['circuit_ids_to_monitor'] == [123, 456, 789]
assert res['additional_circuit_customers'] == \
[
......@@ -152,6 +159,11 @@ def test_transform_ims_data():
"cu_1_1": ["customer_1_1@a.org"]
}
planned_work_contacts = {
"cu_1": ["customer_1_PW@a.org"],
"cu_1_1": ["customer_1_1_PW@a.org"]
}
port_id_details = {
"port_id_1": [{
"equipment_name": "eq_a",
......@@ -320,6 +332,7 @@ def test_transform_ims_data():
data = {
"locations": locations,
"customer_contacts": customer_contacts,
"planned_work_contacts": planned_work_contacts,
"circuit_ids_to_monitor": ["sub_circuit_2"],
"additional_circuit_customers": additional_circuit_customer_ids,
"hierarchy": hierarchy,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment