Skip to content
Snippets Groups Projects
Commit 188b2586 authored by Mohammad Ismaeel's avatar Mohammad Ismaeel
Browse files

Seperate Create Opticalband Msgs

parent 15584d15
No related branches found
No related tags found
2 merge requests!294Release TeraFlowSDN 4.0,!284Resolve: "(CNIT) Multi-Granular Optical Nodes and Optical Transpoders management"
...@@ -86,9 +86,10 @@ class OpenConfigServicer(DeviceServiceServicer): ...@@ -86,9 +86,10 @@ class OpenConfigServicer(DeviceServiceServicer):
device = get_device( device = get_device(
context_client, device_uuid, rw_copy=True, include_endpoints=True, include_components=False, context_client, device_uuid, rw_copy=True, include_endpoints=True, include_components=False,
include_config_rules=False) include_config_rules=False)
LOGGER.info(f"device is {device}")
if device is None: if device is None:
raise NotFoundException('Device', device_uuid, extra_details='loading in ConfigureDevice') raise NotFoundException('Device', device_uuid, extra_details='loading in ConfigureDevice')
LOGGER.info(f"device is {device.name}")
resources,conditions=extract_resources(config=config,device=device) resources,conditions=extract_resources(config=config,device=device)
LOGGER.info(f"from openconfigservicer {resources} and conditions {conditions}") LOGGER.info(f"from openconfigservicer {resources} and conditions {conditions}")
driver : _Driver = get_driver(self.driver_instance_cache, device) driver : _Driver = get_driver(self.driver_instance_cache, device)
...@@ -169,9 +170,10 @@ class OpenConfigServicer(DeviceServiceServicer): ...@@ -169,9 +170,10 @@ class OpenConfigServicer(DeviceServiceServicer):
device = get_device( device = get_device(
context_client, device_uuid, rw_copy=True, include_endpoints=True, include_components=False, context_client, device_uuid, rw_copy=True, include_endpoints=True, include_components=False,
include_config_rules=False) include_config_rules=False)
LOGGER.info(f"device is {device}")
if device is None: if device is None:
raise NotFoundException('Device', device_uuid, extra_details='loading in ConfigureDevice') raise NotFoundException('Device', device_uuid, extra_details='loading in ConfigureDevice')
LOGGER.info(f"device is {device.name}")
resources,conditions=extract_resources(config=config,device=device) resources,conditions=extract_resources(config=config,device=device)
LOGGER.info(f" Disable resources from openconfigservicer {resources} and conditions {conditions}") LOGGER.info(f" Disable resources from openconfigservicer {resources} and conditions {conditions}")
driver : _Driver = get_driver(self.driver_instance_cache, device) driver : _Driver = get_driver(self.driver_instance_cache, device)
......
...@@ -240,47 +240,48 @@ def create_optical_band (resources) : ...@@ -240,47 +240,48 @@ def create_optical_band (resources) :
unwanted_keys=['destination_port','source_port','channel_namespace','frequency','optical-band-parent','handled_flow'] unwanted_keys=['destination_port','source_port','channel_namespace','frequency','optical-band-parent','handled_flow']
config,ports,index= filter_config(resources,unwanted_keys=unwanted_keys) config,ports,index= filter_config(resources,unwanted_keys=unwanted_keys)
logging.info(f"SSSSSSSSSSSSSSS {ports}") logging.info(f"SSSSSSSSSSSSSSS {ports}")
doc, tag, text = Doc().tagtext()
#with tag('config'): #with tag('config'):
with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"): n = 0
with tag('wavelength-router', xmlns="http://openconfig.net/yang/wavelength-router"): for flow in ports:
with tag('optical-bands',xmlns="http://flex-scale-project.eu/yang/flex-scale-mg-on"): doc, tag, text = Doc().tagtext()
n = 0 with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"):
with tag('wavelength-router', xmlns="http://openconfig.net/yang/wavelength-router"):
for flow in ports: with tag('optical-bands',xmlns="http://flex-scale-project.eu/yang/flex-scale-mg-on"):
#with tag('optical-band', operation="create"):
src,dest=flow
logging.info(f"SSSSSSSSSSSSSSS {src}, {dest}") #with tag('optical-band', operation="create"):
with tag('optical-band'): src,dest=flow
if index is not None: logging.info(f"SSSSSSSSSSSSSSS {src}, {dest}")
with tag('index'):text(str(int(index)+n)) with tag('optical-band'):
with tag('config'): if index is not None:
#if index is not None:
# with tag('index'):text(str(int(index)+i))
for resource in config:
if resource['resource_key'] == "index":
with tag('index'):text(str(int(index)+n)) with tag('index'):text(str(int(index)+n))
else:
with tag(resource['resource_key']):text(resource['value'])
with tag('admin-status'):text('ENABLED')
#with tag('fiber-parent'):text(ports['destination_port'] if 'destination_port' in ports else ports['source_port'])
if dest is not None and dest != '0':
with tag('dest'):
with tag('config'): with tag('config'):
with tag('port-name'):text(dest) #if index is not None:
if src is not None and src !='0': # with tag('index'):text(str(int(index)+i))
with tag('source'): for resource in config:
with tag('config'): if resource['resource_key'] == "index":
with tag('port-name'):text(src) with tag('index'):text(str(int(index)+n))
n +=1 else:
with tag(resource['resource_key']):text(resource['value'])
with tag('admin-status'):text('ENABLED')
#with tag('fiber-parent'):text(ports['destination_port'] if 'destination_port' in ports else ports['source_port'])
if dest is not None and dest != '0':
with tag('dest'):
with tag('config'):
with tag('port-name'):text(dest)
if src is not None and src !='0':
with tag('source'):
with tag('config'):
with tag('port-name'):text(src)
n +=1
result = indent(
doc.getvalue(), result = indent(
indentation = ' '*2, doc.getvalue(),
newline = '' indentation = ' '*2,
) newline = ''
results.append(result) )
results.append(result)
return results return results
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment