-def connect_xpdr_to_rdm_request(payload: dict):
- url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links"
- payload_prefix = {'rfc8040': '', 'draft-bierman02': 'networkutils:'}
- data = {
- payload_prefix[RESTCONF_VERSION] + "input": {
- payload_prefix[RESTCONF_VERSION] + "links-input": {
- payload_prefix[RESTCONF_VERSION] + "xpdr-node": payload['xpdr-node'],
- payload_prefix[RESTCONF_VERSION] + "xpdr-num": payload['xpdr-num'],
- payload_prefix[RESTCONF_VERSION] + "network-num": payload['network-num'],
- payload_prefix[RESTCONF_VERSION] + "rdm-node": payload['rdm-node'],
- payload_prefix[RESTCONF_VERSION] + "srg-num": payload['srg-num'],
- payload_prefix[RESTCONF_VERSION] + "termination-point-num": payload['termination-point-num']
- }
- }
- }
- return post_request(url, data)
-
-
-def connect_rdm_to_xpdr_request(payload: dict):
- url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links"
- payload_prefix = {'rfc8040': '', 'draft-bierman02': 'networkutils:'}
- data = {
- payload_prefix[RESTCONF_VERSION] + "input": {
- payload_prefix[RESTCONF_VERSION] + "links-input": {
- payload_prefix[RESTCONF_VERSION] + "xpdr-node": payload['xpdr-node'],
- payload_prefix[RESTCONF_VERSION] + "xpdr-num": payload['xpdr-num'],
- payload_prefix[RESTCONF_VERSION] + "network-num": payload['network-num'],
- payload_prefix[RESTCONF_VERSION] + "rdm-node": payload['rdm-node'],
- payload_prefix[RESTCONF_VERSION] + "srg-num": payload['srg-num'],
- payload_prefix[RESTCONF_VERSION] + "termination-point-num": payload['termination-point-num']
- }
- }
- }
- return post_request(url, data)
+def get_ordm_serv_list_request():
+ url = {'rfc8040': '{}/data/org-openroadm-service:service-list?content=nonconfig',
+ 'draft-bierman02': '{}/operational/org-openroadm-service:service-list/'}
+ response = get_request(url[RESTCONF_VERSION])
+ res = response.json()
+ return_key = {'rfc8040': 'org-openroadm-service:service-list',
+ 'draft-bierman02': 'service-list'}
+ if return_key[RESTCONF_VERSION] in res.keys():
+ response_attribute = res[return_key[RESTCONF_VERSION]]
+ else:
+ response_attribute = res['errors']['error'][0]
+ return {'status_code': response.status_code,
+ 'service-list': response_attribute}
+
+
+def get_ordm_serv_list_attr_request(attribute: str, value: str):
+ url = {'rfc8040': '{}/data/org-openroadm-service:service-list/{}={}?content=nonconfig',
+ 'draft-bierman02': '{}/operational/org-openroadm-service:service-list/{}/{}'}
+ if RESTCONF_VERSION == 'rfc8040':
+ format_args = ('{}', attribute, value)
+ else:
+ format_args = ('{}', attribute, value)
+ response = get_request(url[RESTCONF_VERSION].format(*format_args))
+ res = response.json()
+ return_key = {'rfc8040': 'org-openroadm-service:' + attribute,
+ 'draft-bierman02': attribute}
+ if return_key[RESTCONF_VERSION] in res.keys():
+ response_attribute = res[return_key[RESTCONF_VERSION]]
+ else:
+ response_attribute = res['errors']['error'][0]
+ return {'status_code': response.status_code,
+ attribute: response_attribute}
+
+
+def get_serv_path_list_attr(attribute: str, value: str):
+ url = {'rfc8040': '{}/data/transportpce-service-path:service-path-list/{}={}?content=nonconfig',
+ 'draft-bierman02': '{}/operational/transportpce-service-path:service-path-list/{}/{}'}
+ response = get_request(url[RESTCONF_VERSION].format('{}', attribute, value))
+ res = response.json()
+ return_key = {'rfc8040': 'transportpce-service-path:' + attribute,
+ 'draft-bierman02': attribute}
+ if return_key[RESTCONF_VERSION] in res.keys():
+ response_attribute = res[return_key[RESTCONF_VERSION]]
+ else:
+ response_attribute = res['errors']['error'][0]
+ return {'status_code': response.status_code,
+ attribute: response_attribute}