diff --git a/src/device/service/drivers/oc_driver/OCDriver.py b/src/device/service/drivers/oc_driver/OCDriver.py index bfe3d4b2fe60f05bcea42d7315eb4dc61f141690..08289d71d144a109755002fe9dbdc68b4071713f 100644 --- a/src/device/service/drivers/oc_driver/OCDriver.py +++ b/src/device/service/drivers/oc_driver/OCDriver.py @@ -28,9 +28,9 @@ from device.service.driver_api._Driver import _Driver from .templates import compose_config, cli_compose_config, ufi_interface, cisco_interface from .templates.VPN.common import seperate_port_config from .templates.VPN.roadms import ( - create_optical_band, disable_media_channel, delete_optical_band, create_media_channel + create_optical_band, disable_media_channel, delete_optical_band, create_media_channel, ) -from .templates.VPN.transponder import edit_optical_channel, change_optical_channel_status +from .templates.VPN.transponder import edit_optical_channel, change_optical_channel_status, disable_optical_channel from .RetryDecorator import retry from context.client.ContextClient import ContextClient from common.proto.context_pb2 import OpticalConfig @@ -177,7 +177,8 @@ def edit_config( # Device type is Transponder if (conditions['edit_type'] == "optical-channel"): _,ports,_=seperate_port_config(resources) - str_config_messages=change_optical_channel_status(state="DISABLED",ports=ports) + #str_config_messages=change_optical_channel_status(state="DISABLED",ports=ports) + str_config_messages=disable_optical_channel(ports=ports) # Device type is Roadm elif (conditions['edit_type']=='optical-band'): diff --git a/src/device/service/drivers/oc_driver/templates/VPN/transponder.py b/src/device/service/drivers/oc_driver/templates/VPN/transponder.py index 6b0afc8d58ceda5a35dbe231d08ef71df9f0a66c..e3aeeeabe839fc567eaaea6e651f1a36c077b0ec 100644 --- a/src/device/service/drivers/oc_driver/templates/VPN/transponder.py +++ b/src/device/service/drivers/oc_driver/templates/VPN/transponder.py @@ -109,6 +109,49 @@ def create_optical_channel(resources:list[dict],ports:list[dict],config:list[dic return results +def disable_optical_channel(ports:list[dict] ): + + # unwanted_keys=['bidir','source_port','destination_port','handled_flow','name','channel_namespace','admin-state' + # ,'optical-band-parent'] + results =[] + port_val = "" + if 'destination_port' in ports and ports['destination_port'][0] is not None: + port_val = ports['destination_port'][0] + else: + port_val = ports['source_port'][0] + + doc, tag, text = Doc().tagtext() + #with tag('config'): + with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"): + with tag('components', xmlns="http://openconfig.net/yang/platform"): + with tag('component'): + with tag('name'):text("channel-{}".format(port_val)) + with tag('config'): + with tag('name'):text("channel-{}".format(port_val)) + with tag('optical-channel',xmlns="http://openconfig.net/yang/terminal-device"): + with tag('config'): + with tag('frequency'):text('199000000') + with tag('target-output-power'):text('-40') + with tag('operational-mode'):text('0') + with tag('terminal-device', xmlns="http://openconfig.net/yang/terminal-device"): + with tag('logical-channels'): + with tag('channel'): + with tag('index'):text("{}".format(port_val)) + with tag('config'): + with tag('index'):text("{}".format(port_val)) + with tag('admin-state'):text("DISABLED") + result = indent( + doc.getvalue(), + indentation = ' '*2, + newline = '' + ) + results.append(result) + + + return results + + + def change_optical_channel_status (state:str,ports:list[dict]) : port_val="" if 'destination_port' in ports and ports['destination_port'][0] is not None: @@ -139,6 +182,7 @@ def change_optical_channel_status (state:str,ports:list[dict]) : return results + def edit_optical_channel (resources:list[dict]): unwanted_keys=['destination_port','source_port','channel_namespace' diff --git a/src/device/service/drivers/oc_driver/templates/discovery_tool/transponders.py b/src/device/service/drivers/oc_driver/templates/discovery_tool/transponders.py index 65e737d6aa942e59333136699fe1902df5b98a70..5b25d3b6176157c8507e3aecc96dd636de5f733d 100644 --- a/src/device/service/drivers/oc_driver/templates/discovery_tool/transponders.py +++ b/src/device/service/drivers/oc_driver/templates/discovery_tool/transponders.py @@ -107,8 +107,11 @@ def extract_channels_based_on_channelnamespace (xml_data:str,channel_namespace:s # Extract and print the component names for component in component_names: - component_name = component.find('namespace:name', namespace).text - channels.append({"index":component_name}) + component_name = component.find('namespace:name', namespace).text + #fix for ofc2025 demo with HHI transceiver + #if "transceiver" not in component_name and "port" not in component_name: + if "channel" in component_name: + channels.append({"index":component_name}) else : namespaces = { 'wr': 'http://openconfig.net/yang/wavelength-router', @@ -305,6 +308,7 @@ def extract_ports_based_on_type (xml_data:str): root = ET.fromstring(xml_bytes) namespace = {'oc': 'http://openconfig.net/yang/platform', 'typex': 'http://openconfig.net/yang/platform-types'} ports = [] + ''' components = root.findall(".//oc:state[oc:type]",namespace) for component in components: type_ele = component.find(".//oc:type",namespace) @@ -315,6 +319,18 @@ def extract_ports_based_on_type (xml_data:str): port_index=name_element.text.split("-")[1] port = (port_name,port_index) ports.append(port) + ''' + optical_channel_namespaces = { + 'ns': 'urn:ietf:params:xml:ns:netconf:base:1.0', + 'oc': 'http://openconfig.net/yang/platform', + } + components = root.findall('.//oc:component',namespaces=optical_channel_namespaces) + for component in components: + name=component.find('.//oc:name',optical_channel_namespaces).text + if "port" in name: + port_index=name.split("-")[1] + port = (name,port_index) + ports.append(port) return ports def transponder_values_extractor(data_xml:str,resource_keys:list,dic:dict): @@ -327,6 +343,7 @@ def transponder_values_extractor(data_xml:str,resource_keys:list,dic:dict): channel_names= extract_channels_based_on_channelnamespace(xml_data=data_xml,channel_namespace=channel_namespace,is_opticalband=is_opticalband) ports = extract_ports_based_on_type(data_xml) + logging.info(f"OFC25---- {channel_names}, {ports}") optical_channels_params=[] ports_result=[] interfaces=[] diff --git a/src/service/service/ServiceServiceServicerImpl.py b/src/service/service/ServiceServiceServicerImpl.py index a316c70c48bfc068371045f1635a484404dfaec3..19a9e3dcabfec386150eaa9124a3e56aa2910c16 100644 --- a/src/service/service/ServiceServiceServicerImpl.py +++ b/src/service/service/ServiceServiceServicerImpl.py @@ -276,7 +276,10 @@ class ServiceServiceServicerImpl(ServiceServiceServicer): ports = [] for endpoint_id in service.service_endpoint_ids: endpoint_device_uuid = endpoint_id.device_id.device_uuid.uuid - endpoint_device_name = device_names[endpoint_device_uuid] + if "." in endpoint_device_uuid: + endpoint_device_name = endpoint_device_uuid + else: + endpoint_device_name = device_names[endpoint_device_uuid] devs.append(endpoint_device_name) ports.append(endpoint_id.endpoint_uuid.uuid) src = devs[0]