From ec44a7a655b7e7babe989d036337fcaa2d776f5d Mon Sep 17 00:00:00 2001 From: ismaeel <mohammad.ismaael@cnit.it> Date: Wed, 23 Oct 2024 04:12:36 +0000 Subject: [PATCH] API for configuring openroadm --- .context.log.swn | Bin 24576 -> 0 bytes .context.log.swo | Bin 16384 -> 0 bytes .context.log.swp | Bin 40960 -> 0 bytes proto/context.proto | 3 + src/context/service/database/OpticalConfig.py | 10 +- .../OpticalConfig/OpticalConfigModel.py | 14 +- .../models/OpticalConfig/RoadmModel.py | 12 +- src/device/service/Tools.py | 132 ++++++++----- .../service/drivers/oc_driver/OCDriver.py | 16 +- .../oc_driver/templates/VPN/openroadm.py | 187 ++++++++++++++++++ .../templates/descovery_tool/open_roadm.py | 89 +++++++-- src/tests/ofc24/r_t.sh | 0 src/webui/service/opticalconfig/routes.py | 114 ++++++++++- .../templates/opticalconfig/details.html | 32 +++ test.py | 172 ++++++++++------ 15 files changed, 620 insertions(+), 161 deletions(-) delete mode 100644 .context.log.swn delete mode 100644 .context.log.swo delete mode 100644 .context.log.swp create mode 100644 src/device/service/drivers/oc_driver/templates/VPN/openroadm.py mode change 100644 => 100755 src/tests/ofc24/r_t.sh diff --git a/.context.log.swn b/.context.log.swn deleted file mode 100644 index 438f657217b971861a154b8bd3b81b1b02507337..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 24576 zcmeI3Pj1^r6vo-~KTxMldjUpWs0Bn>A|;#R&Z*<nfGxL{(grXLf+9yY5s_3#%86mP z-E^5{cfCSy&>o@aHQFO|**8NDMaiNl&jg4Cj00L0XTHbB-wfY36qP~ahy6oYud5RL zd?rb+AN)6Lf1peEtM{aM7~#F8KhRIP@JhQ$KS9S$+}V!9(WV{vF?to(N5NUSRP+!8 z1OaXW8<M6r8#v6Dm51^dpFib}C;|uqf`A|(2nYg#fFK|U2m*q@`Vff6_oSa8-Fs=u zAEmGF%)P#wzJEV`{WyK4`_s4LMGz1K1OY)n5D)|e0YN|z5CjAPK|l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context.log.swo deleted file mode 100644 index 49a59c9ed538de8fd9541463916ab80290aed960..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeHO-EQ1O6gEG-;HL#q5QwYkw$c`9?e)LCmMUmSTSaP9m9*tzwX$aI*~E0$UTklY zRR~C2Rfq@R0eA!McmQ628!ouuiYMT|6gX$r-elbko1{@C&^VfSea@USXTCXeGRJ4r zRqw9cAg-cIaJ?)^!-t>u<U6i(|H3IL?`23`ctJmTbFi?R^f7d7V&@=F`^_MUbGDr; z{bYTysOTXO5C}Xr0;eTI*Hlz<zIKkBedW$$YZM9u0s;YnfIvVXAP^7;2m}NI0)hVy z0{QTa^a+^zbYb$@;{H_S{&#UbThL#v@c%0KFBJ4QD*T59|5QOgU*Z2*(SNbRe^B8! zD*QhRKD@%<7f*8FQ#p^{3;t^b|DEDq@_#G%Zx-}2Gb;JN7W~r%KdH$7Qt;0d^p7h1 zpDX;&D*T@c{)+|uiwggl;<;R>FDv}wQQQOq0s(=5KtLcM5D*9m1Ox&C0fB%(Kp-#| z0UAoukC5c9Vqyu&bD96&e@T*>&>lcS`xUfX(7uM`*MRmNB&i$FUWfJ#B>W?27odIn zyd-@JO@sEsbCQ(8%L3GUqfA=oS|Eu39|YREs++Rv$ZCtIEl;&P-EJ6et3y^+uio^^ zuY6=I-HZaJgfypJnla_(FpmP-e>aJH(Yi;&kcDK1=3`gV-l->(o}dYO`lC@4);&^J zHQQ=wR!<I0$B`}Dc4g}5OzxVF%R<+sMxfUlq#kV0IA(o6rURA@X~0l;BhQCkvzZK8 zJW;E}EN_l!yxz=NI*4N0mqUgIqY4&>!z7CH3`E=Yom%<KZK-)=r-nxH4^bSlZTM6x zhLx?_?(QxsIhvS#JTd2ZVlEf!fR&R;?*my6OlHI4;v!o;LzTOh4scs6utVC@ZKH*g z%f~~GYq3;vp3*oQCICiS-|a{T_=tNn9|;mz|FMr_0pxf?pyv!(YfSOapi6tF)=Sxk zBUtM(N@y+3R`J4qIZ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ozBEU2{ErXg#(-ZgunYN$qUziupbV5P0BgW1TORyTm7wRF|cbV~*Lz9Nf{ zMHXaZRf*ST{7G%b=d~GBsVOQdo0M3PaAlQOSmsxn9tZH5)O$fa(sWGMU|n4f1I?DL zuw}_mo}{wfVm;Te!_Z+)6`-;ni7y6VM&-L8UT1{Yz}0HpVb=g(3L`FaN@Ix8KTJlo AJpcdz diff --git a/.context.log.swp b/.context.log.swp deleted file mode 100644 index 5d3a8a7bc4f452de1e9db725e83fcbdbfbf83580..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 40960 zcmeHQORQwMSuR3&69OT#pv9slLAn!BzGM5?=lIkHWk?2%m<LSvfJAFl_}D%@S99;J zrmF5Fqo&CMHfZ)p0Ra+X0}(4&0AYp10x3bP*|Ew7u>is|Jic@4{I2SHOjUK)Om|;= zTkfhlKKAkd+2{A~|6y1B=U#fHZ%$<oe?Qpkz4n!tYxaieJ@cC%>CNhCb9Lt*?qly< z?7Xe_E4cCb=4LmWoImfzm$UH2+3ETC&hDb=j)Xu$;875`n$^sF?2Swc-c<AHPd(fJ z;ZMBrC^e?C34w$_LLecK5J(6l1QG%XfrP+QhQRFZ$9rEwn?KUE`_tX$x2=5sZ}<01 zcm2m!^8csH|73T)T*?2Q?l+ZxWhMVxEA>|^`Tw<2{})#B|8ph(y_Nj`SgHSaSMvY8 z%m2>q`k$=i|67+&xcqsSPxt@pO8!?@^1s>Tf1<no7c2Sy(&ZDbf79jD^ZvQZf3Ca! zPb>M~zViD<SCHD*Wv7pXKtdoPkPt`+Bm@!y34w$_LLecK5cq$Jfc3rJAA|PW&3X~` ze_H>4?c=@PuOWR3>AfH5^*)O92OsP8N~EuUf3Nq;NI#DBci-3R{W_9C`o{P6dcT46 zd8EI@g8!G0{_(qez28Q<f%Mnk)$6^8^i3>Ee;?^tq`&=+Uhhjt-}-2;_Z6g{K>8~z zX1@-F#7(58UB5t!;HRsPZc8o|<C;m)7i!4Mp)v!Vm2dW6diBNEh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8*QmbCFwU6oU4SI6-Had{f&pQnL)ny=}=n_H>4)f zlL>5Udc>SEsHsFORj@E-5K#+F7nNBk!N_h(_eO$akGA!1IchI2X*6}R_vzZUqpvL; z>bQ2)p4lTDdhL{u_BctXTX!80wEX17;f6%l8o`8P1bnq8BEa2nqx=QDv5%;(h<7YY zy%&{^ans4g%hZ<IiugfvuOS}x&^~NIeDBl3R>wG@K!C+DMj3H9Mszxesk0(B)N6!i z?5ubvLBBBE#a@ZEQ>l1wTkZXxyK&>j7UJ`LkAGVwe(j;LVFX7cj^K#+#6hyT!C*_V zb|R8+Ab_GplaO1m^Z5J*>}|vCFuK=<+dey!Z9!bq@jZL7mc<JmA&C&gZjM=mR)jtx z9dih;SeW3VzSxO0bte^EbZcA1HpG`s(%Q0<^D<*wLp<zZINE}^B4*x-2DZj|Pz%YR z!bwb*R~LPbz_|6lZS&&$R(V~v7u%2cbx~`{Y#!grr41P3;9S}oIZp1~Cd6O?%bOq5 zkXznDnTFr;md9~$M>n&j4VL44w!958y*f+VAkQ7swu(gW+w~vFXu2Lwa}PV3;A2H{ z@RCeHJ-xgcRb-3{FPFH1wumDUFFDm0x8YtwIF8Qc9l(hviiOkSg6l20FA@)3-dlXm z6!)Y4!{ALsJ)uf(0HH?{10hWB8PT@Df?%W?7ac`)MwwuNK2;lKqxf3JxoQsW_7{-O zliae>TQq~76`M@7(I?Ti==9j~j=0#(1Q*pAZzSB->4*c3po=uOWwsMY2L(RNeD#0b C^hlBb diff --git a/proto/context.proto b/proto/context.proto index 03ecd459a..64a015265 100644 --- a/proto/context.proto +++ b/proto/context.proto @@ -560,6 +560,9 @@ message Location { oneof location { string region = 1; GPS_Position gps_position = 2; + + string interface=3; + string circuit_pack=4; } } diff --git a/src/context/service/database/OpticalConfig.py b/src/context/service/database/OpticalConfig.py index b370375d3..e3248d8bd 100644 --- a/src/context/service/database/OpticalConfig.py +++ b/src/context/service/database/OpticalConfig.py @@ -207,7 +207,7 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): ) LOGGER.info(f"added OpticalConfig_data {OpticalConfig_data}") - LOGGER.info(f"added channels {channels}") + LOGGER.info(f"added interfaces {interfaces}") def callback(session:Session)->bool: stmt = insert(OpticalConfigModel).values(OpticalConfig_data) @@ -260,7 +260,7 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): stmt = stmt.on_conflict_do_update( index_elements=[RoadmTypeModel.roadm_uuid], set_=dict( - circuits=stmt.excluded.circuits + opticalconfig_uuid=stmt.excluded.opticalconfig_uuid ) ) stmt = stmt.returning(RoadmTypeModel.roadm_uuid) @@ -298,14 +298,14 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): stmt = stmt.on_conflict_do_update( index_elements=[RoadmTypeModel.roadm_uuid], set_=dict( - interfaces=stmt.excluded.interfaces + opticalconfig_uuid=stmt.excluded.opticalconfig_uuid ) ) stmt = stmt.returning(RoadmTypeModel.roadm_uuid) roadm_id = session.execute(stmt).fetchone() - if len(interface) >0 : - stmt = insert(ORInterfaceModel).values(interface) + if len(interfaces) >0 : + stmt = insert(ORInterfaceModel).values(interfaces) stmt = stmt.on_conflict_do_update( index_elements=[ORInterfaceModel.interface_uuid ], set_=dict( diff --git a/src/context/service/database/models/OpticalConfig/OpticalConfigModel.py b/src/context/service/database/models/OpticalConfig/OpticalConfigModel.py index 515a21a85..eafafaa7c 100644 --- a/src/context/service/database/models/OpticalConfig/OpticalConfigModel.py +++ b/src/context/service/database/models/OpticalConfig/OpticalConfigModel.py @@ -64,9 +64,17 @@ class OpticalConfigModel(_Base): obj['trasponder_uuid']=channels['trasponder_uuid'] if 'trasponder_uuid' in channels else None if self.type =="optical-roadm" : - channels=[roadms.dump() for roadms in self.roadms ][0] - obj['channels']=channels['channels'] if 'channels' in channels else None - obj['roadm_uuid']=channels['roadm_uuid'] if 'roadm_uuid' in channels else None + dev=[roadms.dump() for roadms in self.roadms ][0] + + obj['channels']=dev['channels'] if 'channels' in dev else None + obj['roadm_uuid']=dev['roadm_uuid'] if 'roadm_uuid' in dev else None + + if self.type =="openroadm" : + dev=[roadms.dump() for roadms in self.roadms ][0] + + obj['interfaces']=dev['interfaces'] if 'interfaces' in dev else None + obj['roadm_uuid']=dev['roadm_uuid'] if 'roadm_uuid' in dev else None + logging.info(f"optical_config_model {obj}") diff --git a/src/context/service/database/models/OpticalConfig/RoadmModel.py b/src/context/service/database/models/OpticalConfig/RoadmModel.py index 6d1ec19fa..52e831e73 100644 --- a/src/context/service/database/models/OpticalConfig/RoadmModel.py +++ b/src/context/service/database/models/OpticalConfig/RoadmModel.py @@ -14,7 +14,7 @@ # limitations under the License. import json , logging -from sqlalchemy import Column, String, Integer , ForeignKey, Boolean +from sqlalchemy import Column, String, Integer , ForeignKey, Boolean , Float from sqlalchemy.dialects.postgresql import ARRAY from sqlalchemy.orm import relationship from context.service.database.models._Base import _Base @@ -27,8 +27,8 @@ class RoadmTypeModel (_Base): __tablename__ = 'roadm_type' roadm_uuid = Column(String, primary_key=True) - channels = relationship("ChannelModel") - interfaces = relationship ("ORInterfaceModel") + channels = relationship("ChannelModel") + interfaces = relationship ("ORInterfaceModel") opticalconfig_uuid = Column(ForeignKey('optical_config.opticalconfig_uuid', ondelete='CASCADE' ),index=True ,nullable=False) opticalconfig = relationship('OpticalConfigModel', back_populates='roadms') @@ -39,10 +39,12 @@ class RoadmTypeModel (_Base): } def dump (self): + i=[interface.dump() for interface in self.interfaces] + logging.info(f"roamd_type_model {i}") return { "channels" : [channel.dump() for channel in self.channels], "roadm_uuid" : self.dump_id(), - "interfaces" :[] + "interfaces" :[interface.dump() for interface in self.interfaces] } class ChannelModel(_Base): @@ -92,7 +94,7 @@ class ORInterfaceModel (_Base): circuit_pack_name = Column(String,nullable=True) port = Column(String,nullable=True) interface_list = Column(String ,nullable=True) - frequency = Column(Integer ,nullable=True) + frequency = Column(Float ,nullable=True) width = Column(Integer ,nullable=True) roadm_uuid = Column(ForeignKey('roadm_type.roadm_uuid', ondelete='CASCADE' ),nullable=False) diff --git a/src/device/service/Tools.py b/src/device/service/Tools.py index 68a65d1ba..c4d4efb8f 100644 --- a/src/device/service/Tools.py +++ b/src/device/service/Tools.py @@ -465,6 +465,7 @@ def get_edit_target(device : Device, is_opticalband : bool) -> str: if is_opticalband: return 'optical-band' if device.device_type == DeviceTypeEnum.OPTICAL_ROADM._value_: return 'media-channel' + if device.device_type == DeviceTypeEnum.OPEN_ROADM._value_: return 'network-media-channel' return 'optical-channel' def is_key_existed(key : str, keys_dic = dict, key_name_to_use = None) -> dict: @@ -481,63 +482,86 @@ def is_key_existed(key : str, keys_dic = dict, key_name_to_use = None) -> dict: def extract_resources(config : dict, device : Device) -> list[list[dict],dict]: conditions = {} resources:list[dict] = [] - resources.append(is_key_existed('channel_namespace', config)) - resources.append(is_key_existed('add_transceiver', config)) is_opticalband = config.get('is_opticalband', False) - conditions['is_opticalband'] = is_opticalband conditions['edit_type'] = get_edit_target(device, is_opticalband) - - if 'flow' in config: - #for tuple_value in config['flow'][device.name]: - source_vals = [] - dest_vals = [] - handled_flow=[] - for tuple_value in config['flow']: - source_port = None - destination_port = None - source_port_uuid, destination_port_uuid = tuple_value - if source_port_uuid != '0': - src_endpoint_obj = get_endpoint_matching(device, source_port_uuid) - source_port = src_endpoint_obj.name - source_vals.append(source_port) - if destination_port_uuid != '0': - dst_endpoint_obj = get_endpoint_matching(device, destination_port_uuid) - destination_port = dst_endpoint_obj.name - dest_vals.append(destination_port) - handled_flow.append((source_port,destination_port)) - resources.append({'resource_key': 'source_port', 'value': source_vals}) - resources.append({'resource_key': 'destination_port', 'value': dest_vals }) - resources.append({'resource_key':'handled_flow','value':handled_flow}) - if 'new_config' in config: - lower_frequency = None - upper_frequency = None - resources.append(is_key_existed('target-output-power', keys_dic=config['new_config'])) - resources.append(is_key_existed('frequency', keys_dic=config['new_config'])) - resources.append(is_key_existed('operational-mode', keys_dic=config['new_config'])) - resources.append(is_key_existed('line-port', keys_dic=config['new_config'])) - resources.append(is_key_existed('status', keys_dic=config['new_config'] , key_name_to_use="admin-state")) - resources.append(is_key_existed('band_type', keys_dic=config['new_config'], key_name_to_use='name')) - resources.append(is_key_existed('ob_id', keys_dic=config['new_config'], key_name_to_use='optical-band-parent')) - #resources.append(is_key_existed('name', keys_dic=config['new_config'], key_name_to_use='channel_name')) - if not is_opticalband: + - if 'frequency' in config['new_config'] and 'band' in config['new_config'] and conditions['edit_type'] == 'media-channel': - if config['new_config']['frequency'] is not None and config['new_config']['band'] is not None: - lower_frequency = int(int(config['new_config']['frequency']) - (int(config['new_config']['band'])/2)+1) - upper_frequency = int(int(config['new_config']['frequency']) + (int(config['new_config']['band'])/2)) - - - resources.append(is_key_existed('flow_id', keys_dic=config['new_config'], key_name_to_use='index')) - #resources.append({'resource_key':'index','value':config['new_config']['flow_id'] if 'flow_id' in config['new_config'] else None}) - else: - - lower_frequency = config['new_config']['low-freq'] if 'low-freq' in config['new_config'] else None - upper_frequency = config['new_config']['up-freq' ] if 'up-freq' in config['new_config'] else None - + if device.device_type == DeviceTypeEnum.OPEN_ROADM._value_ : + ports_dic=is_key_existed('ports',keys_dic=config['new_config']) + interfaces_list=[] + config_type= is_key_existed('config_type', keys_dic=config['new_config']) + resources.append(config_type) + resources.append(is_key_existed('administrative-state', keys_dic=config['new_config'])) + resources.append(is_key_existed('frequency', keys_dic=config['new_config'])) + resources.append(is_key_existed('width', keys_dic=config['new_config'])) + for port in ports_dic["value"]: + circuit_pack_dic=is_key_existed('supporting-circuit-pack-name', keys_dic=port) + interface_list=is_key_existed('supporting-interface-list', keys_dic=port) + supporting_port=is_key_existed('supporting-port', keys_dic=port) + interfaces_list.append([ + circuit_pack_dic, + interface_list, + supporting_port]) + + resources.append({'resource_key':'interfaces','value':interfaces_list}) + + + else : + resources.append(is_key_existed('channel_namespace', config)) + resources.append(is_key_existed('add_transceiver', config)) + + conditions['is_opticalband'] = is_opticalband + if 'flow' in config: + #for tuple_value in config['flow'][device.name]: + source_vals = [] + dest_vals = [] + handled_flow=[] + for tuple_value in config['flow']: + source_port = None + destination_port = None + source_port_uuid, destination_port_uuid = tuple_value + if source_port_uuid != '0': + src_endpoint_obj = get_endpoint_matching(device, source_port_uuid) + source_port = src_endpoint_obj.name + source_vals.append(source_port) + if destination_port_uuid != '0': + dst_endpoint_obj = get_endpoint_matching(device, destination_port_uuid) + destination_port = dst_endpoint_obj.name + dest_vals.append(destination_port) + handled_flow.append((source_port,destination_port)) + resources.append({'resource_key': 'source_port', 'value': source_vals}) + resources.append({'resource_key': 'destination_port', 'value': dest_vals }) + resources.append({'resource_key':'handled_flow','value':handled_flow}) + if 'new_config' in config: + lower_frequency = None + upper_frequency = None + resources.append(is_key_existed('target-output-power', keys_dic=config['new_config'])) + resources.append(is_key_existed('frequency', keys_dic=config['new_config'])) + resources.append(is_key_existed('operational-mode', keys_dic=config['new_config'])) + resources.append(is_key_existed('line-port', keys_dic=config['new_config'])) + resources.append(is_key_existed('status', keys_dic=config['new_config'] , key_name_to_use="admin-state")) + resources.append(is_key_existed('band_type', keys_dic=config['new_config'], key_name_to_use='name')) + resources.append(is_key_existed('ob_id', keys_dic=config['new_config'], key_name_to_use='optical-band-parent')) + #resources.append(is_key_existed('name', keys_dic=config['new_config'], key_name_to_use='channel_name')) + if not is_opticalband: + + if 'frequency' in config['new_config'] and 'band' in config['new_config'] and conditions['edit_type'] == 'media-channel': + if config['new_config']['frequency'] is not None and config['new_config']['band'] is not None: + lower_frequency = int(int(config['new_config']['frequency']) - (int(config['new_config']['band'])/2)+1) + upper_frequency = int(int(config['new_config']['frequency']) + (int(config['new_config']['band'])/2)) + - resources.append(is_key_existed('ob_id', keys_dic=config['new_config'], key_name_to_use='index')) - #resources.append({'resource_key':'index','value':config['new_config']['ob_id'] if 'ob_id' in config['new_config'] else None}) - resources.append({'resource_key': 'lower-frequency', 'value': lower_frequency}) - resources.append({'resource_key': 'upper-frequency', 'value': upper_frequency}) + resources.append(is_key_existed('flow_id', keys_dic=config['new_config'], key_name_to_use='index')) + #resources.append({'resource_key':'index','value':config['new_config']['flow_id'] if 'flow_id' in config['new_config'] else None}) + else: + + lower_frequency = config['new_config']['low-freq'] if 'low-freq' in config['new_config'] else None + upper_frequency = config['new_config']['up-freq' ] if 'up-freq' in config['new_config'] else None + + + resources.append(is_key_existed('ob_id', keys_dic=config['new_config'], key_name_to_use='index')) + #resources.append({'resource_key':'index','value':config['new_config']['ob_id'] if 'ob_id' in config['new_config'] else None}) + resources.append({'resource_key': 'lower-frequency', 'value': lower_frequency}) + resources.append({'resource_key': 'upper-frequency', 'value': upper_frequency}) return [resources, conditions] diff --git a/src/device/service/drivers/oc_driver/OCDriver.py b/src/device/service/drivers/oc_driver/OCDriver.py index 8959178b8..3d0078c85 100644 --- a/src/device/service/drivers/oc_driver/OCDriver.py +++ b/src/device/service/drivers/oc_driver/OCDriver.py @@ -41,6 +41,9 @@ from common.proto.context_pb2 import ( from .templates.descovery_tool.transponders import transponder_values_extractor from .templates.descovery_tool.roadms import roadm_values_extractor ,extract_media_channels from .templates.descovery_tool.open_roadm import openroadm_values_extractor +from .templates.VPN.openroadm import network_media_channel_handler + + DEBUG_MODE = False logging.getLogger('ncclient.manager').setLevel(logging.DEBUG if DEBUG_MODE else logging.WARNING) logging.getLogger('ncclient.transport.ssh').setLevel(logging.DEBUG if DEBUG_MODE else logging.WARNING) @@ -130,7 +133,6 @@ class NetconfSessionHandler: self, config, target='running', default_operation=None, test_option=None, error_option=None, format='xml' # pylint: disable=redefined-builtin ): - response = None with self.__lock: @@ -164,7 +166,8 @@ def edit_config( ): str_method = 'DeleteConfig' if delete else 'SetConfig' results = [] - + + logging.info(f"commmit per rule {commit_per_rule}") str_config_messages=[] if str_method == 'SetConfig': if (conditions['edit_type']=='optical-channel'): @@ -172,7 +175,12 @@ def edit_config( str_config_messages = edit_optical_channel(resources) elif (conditions['edit_type']=='optical-band'): #roadm optical-band - str_config_messages = create_optical_band(resources) + str_config_messages = create_optical_band(resources) + + elif (conditions['edit_type']=='network-media-channel'): + commit_per_rule=True + #openroadm network media channel + str_config_messages = network_media_channel_handler(resources) else : #roadm media-channel str_config_messages=create_media_channel_v2(resources) @@ -196,7 +204,7 @@ def edit_config( for str_config_message in str_config_messages: # configuration of the received templates if str_config_message is None: raise UnsupportedResourceKeyException("CONFIG") - + result= netconf_handler.edit_config( # configure the device config=str_config_message, target=target, default_operation=default_operation, test_option=test_option, error_option=error_option, format=format) diff --git a/src/device/service/drivers/oc_driver/templates/VPN/openroadm.py b/src/device/service/drivers/oc_driver/templates/VPN/openroadm.py new file mode 100644 index 000000000..f960c3d63 --- /dev/null +++ b/src/device/service/drivers/oc_driver/templates/VPN/openroadm.py @@ -0,0 +1,187 @@ +# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +from yattag import Doc, indent +import logging +from .common import seperate_port_config ,filter_config +from decimal import Decimal + + + +create_mc_err= ''' + <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> +<org-openroadm-device xmlns="http://org/openroadm/device"> + <interface> + <name>MC-TTP-DEG2-RX-193.3</name> + <description>Media-Channel-TTP-193.3THz-degree-2-in</description> + <type>openROADM-if:mediaChannelTrailTerminationPoint</type> + <administrative-state>inService</administrative-state> + <supporting-circuit-pack-name>DEG2-AMPRX</supporting-circuit-pack-name> + <supporting-port>DEG2-AMPRX-IN</supporting-port> + <supporting-interface-list>OMS-DEG2-TTP-RX</supporting-interface-list> + <mc-ttp xmlns="http://org/openroadm/media-channel-interfaces"> + <min-freq>193.25</min-freq> + <max-freq>193.35</max-freq> + </mc-ttp> + </interface> + <interface> + <name>MC-TTP-DEG2-TX-193.3</name> + <description>Media-Channel-TTP-193.3THz-degree-2-out</description> + <type>openROADM-if:mediaChannelTrailTerminationPoint</type> + <administrative-state>inService</administrative-state> + <supporting-circuit-pack-name>DEG2-AMPTX</supporting-circuit-pack-name> + <supporting-port>DEG2-AMPTX-OUT</supporting-port> + <supporting-interface-list>OMS-DEG2-TTP-TX</supporting-interface-list> + <mc-ttp xmlns="http://org/openroadm/media-channel-interfaces"> + <min-freq>193.25</min-freq> + <max-freq>193.35</max-freq> + </mc-ttp> + </interface> +</org-openroadm-device> + + +</config> + +''' + +def define_interface_name (type:str,interface_list:str,freq:int)->str: + interface_str = interface_list.split('-') + port_rank='' + port_type='' + if (len(interface_str)==4): + port_rank=interface_str[1] + port_type=interface_str[3] + elif (len(interface_str)==5): + port_rank=interface_str[2] + port_type=interface_str[3] + else : + port_rank=interface_list + port_type=interface_list+'type' + + + return f'{type.upper()}-{port_rank}-{port_type}-{freq}' + + + +def create_media_channel (resources): + + frequency_dict=next((r for r in resources if r['resource_key']== 'frequency'),None) + width_dict=next((r for r in resources if r['resource_key']== 'width'),None) + interfaces_lists =next((r for r in resources if r['resource_key']== 'interfaces'),None) + administrative_state= next((r for r in resources if r['resource_key']== 'administrative-state'),None) + min_freq= int(Decimal(frequency_dict["value"])*1000) - (int(width_dict["value"])/2) + max_freq = int(Decimal(frequency_dict["value"])*1000) + (int(width_dict["value"])/2) + #config,_,_ = filter_config(resources=resources,unwanted_keys=unwanted_keys) + + or_device_ns="http://org/openroadm/device" + or_interface_ns="http://org/openroadm/interfaces" + + results=[] + logging.info(f"from openroadm mc {resources}") + doc, tag, text = Doc().tagtext() + with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"): + with tag('org-openroadm-device', ('xmlns',or_device_ns)): + + for interface in interfaces_lists["value"]: + port = next((r for r in interface if r['resource_key']=='supporting-port'),None) + circuit_pack =next((r for r in interface if r['resource_key']=='supporting-circuit-pack-name'),None) + interface_list = next((r for r in interface if r['resource_key']=='supporting-interface-list'),None) + mc_name = define_interface_name('mc-ttp',interface_list['value'],frequency_dict['value']) + interface.append({'resource_key':'mc_name','value':mc_name}) + with tag('interface'): + + with tag('name'):text(mc_name) + with tag('description'):text(f'Media-channel-{frequency_dict["value"]}THz') + with tag('type'):text("openROADM-if:mediaChannelTrailTerminationPoint") + with tag('administrative-state'):text(administrative_state["value"]) + with tag('supporting-circuit-pack-name'):text(circuit_pack["value"]) + with tag('supporting-port'):text(port["value"]) + with tag('supporting-interface-list'):text(interface_list["value"]) + with tag('mc-ttp',xmlns="http://org/openroadm/media-channel-interfaces"): + with tag('max-freq'):text(max_freq) + with tag('min-freq'):text(min_freq) + + + + result = indent( + doc.getvalue(), + indentation = ' '*2, + newline = '' + ) + results.append(result) + logging.info(f"from openroadm mc results {results}") + return [results,resources] + + + + +def create_network_media_channel (resources): + + logging.info(f"nmc resources {resources}") + + unwanted_keys= ['max-freq','min-freq'] + #config,_,_ = filter_config(resources=resources,unwanted_keys=unwanted_keys) + + or_device_ns="http://org/openroadm/device" + frequency_dict=next((r for r in resources if r['resource_key']== 'frequency'),None) + width_dict=next((r for r in resources if r['resource_key']== 'width'),None) + interfaces_lists =next((r for r in resources if r['resource_key']== 'interfaces'),None) + administrative_state= next((r for r in resources if r['resource_key']== 'administrative-state'),None) + + + results=[] + doc, tag, text = Doc().tagtext() + with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"): + with tag('org-openroadm-device', ('xmlns',or_device_ns)): + for interface in interfaces_lists["value"]: + port = next((r for r in interface if r['resource_key']=='supporting-port'),None) + circuit_pack =next((r for r in interface if r['resource_key']=='supporting-circuit-pack-name'),None) + interface_list = next((r for r in interface if r['resource_key']=='mc_name'),None) + nmc_name = define_interface_name('nmc-ctp',interface_list['value'],frequency_dict['value']) + + with tag('interface'): + + with tag('name'):text(nmc_name) + with tag('description'):text(f'Media-channel-{frequency_dict["value"]}THz') + with tag('type'):text("openROADM-if:networkMediaChannelConnectionTerminationPoint") + with tag('administrative-state'):text(administrative_state["value"]) + with tag('supporting-circuit-pack-name'):text(circuit_pack["value"]) + with tag('supporting-port'):text(port["value"]) + with tag('supporting-interface-list'):text(interface_list["value"]) + with tag('nmc-ctp',xmlns="http://org/openroadm/network-media-channel-interfaces"): + with tag('frequency'):text(frequency_dict['value']) + with tag('width'):text(width_dict['value']) + + + + result = indent( + doc.getvalue(), + indentation = ' '*2, + newline = '' + ) + results.append(result) + logging.info(f"nmc message {results}") + return results + + +def network_media_channel_handler (resources): + unwanted_keys=["config_type"] + config,_,_ = filter_config(resources=resources,unwanted_keys=unwanted_keys) + mc_list,resources_updated= create_media_channel(resources=config) + nmc_list= create_network_media_channel(resources=resources_updated) + mc_list.extend(nmc_list) + + return mc_list diff --git a/src/device/service/drivers/oc_driver/templates/descovery_tool/open_roadm.py b/src/device/service/drivers/oc_driver/templates/descovery_tool/open_roadm.py index 337207072..3c4b099a0 100644 --- a/src/device/service/drivers/oc_driver/templates/descovery_tool/open_roadm.py +++ b/src/device/service/drivers/oc_driver/templates/descovery_tool/open_roadm.py @@ -17,7 +17,8 @@ import re,logging import json import lxml.etree as ET from typing import Collection, Dict, Any - +from common.proto.context_pb2 import Location +from decimal import Decimal def extract_roadm_circuits_pack (xml_data:str): @@ -112,8 +113,9 @@ def extract_openroadm_info(xml_data:str): def extract_openroadm_interface (xml_data:str): + or_config=[] or_interfaces=[] - + xml_bytes = xml_data.encode("utf-8") root = ET.fromstring(xml_bytes) # with open('xml.log', 'w') as f: @@ -122,24 +124,38 @@ def extract_openroadm_interface (xml_data:str): namespace = {'oc': "http://org/openroadm/device" , 'mc':"http://org/openroadm/media-channel-interfaces" - ,'nmc':"http://org/openroadm/network-media-channel-interfaces"} + ,'nmc':"http://org/openroadm/network-media-channel-interfaces" + ,'or-type':'http://org/openroadm/interfaces'} interfaces = root.findall('.//oc:interface',namespace) for interface in interfaces : mc = interface.find('.//mc:mc-ttp',namespace) name = interface.find('.//oc:name',namespace) description = interface.find('.//oc:description',namespace) - type='' + type=interface.find('.//oc:type',namespace) administrative_state=interface.find('.//oc:administrative-state',namespace) circuit_pack_name=interface.find('.//oc:supporting-circuit-pack-name',namespace) port=interface.find('.//oc:supporting-port',namespace) interface_list =interface.find('.//oc:supporting-interface-list',namespace) - + or_interfaces.append({ + 'interface_list':name.text if name is not None else None, + 'administrative_state':administrative_state.text if administrative_state is not None else None, + 'circuit_pack_name':circuit_pack_name.text if circuit_pack_name is not None else None, + 'port':port.text if port is not None else None , + 'type':type.text if type is not None else None + }) if mc is not None : print (mc) - frequency = mc.find('.//mc:min-freq',namespace) - width=mc.find('.//mc:width',namespace) + frequency=None + width=None + min_frequency = mc.find('.//mc:min-freq',namespace) + max_frequency = mc.find('.//mc:max-freq',namespace) + if min_frequency is not None and max_frequency is not None: + frequency = (Decimal(max_frequency.text) + Decimal(min_frequency.text) )/2 + width = int(( Decimal(max_frequency.text) - Decimal(min_frequency.text)) * 1000) + + mc= { 'name':name.text if name is not None else None, 'description':description.text if description is not None else None , @@ -148,13 +164,15 @@ def extract_openroadm_interface (xml_data:str): 'circuit_pack_name':circuit_pack_name.text if circuit_pack_name is not None else None, 'port':port.text if port is not None else None , 'interface_list': interface_list.text if interface_list is not None else None, - 'frequency': frequency.text if frequency is not None else None, - 'width':width.text if width is not None else None + 'frequency': str(frequency), + 'width':width } - or_interfaces.append(mc) + or_config.append(mc) else : nmc = interface.find('.//nmc:nmc-ctp',namespace) + + if nmc is not None : frequency = nmc.find('.//nmc:frequency',namespace) width=nmc.find('.//nmc:width',namespace) @@ -169,26 +187,65 @@ def extract_openroadm_interface (xml_data:str): 'frequency': frequency.text if frequency is not None else None, 'width':width.text if width is not None else None } - or_interfaces.append(nmc) - return or_interfaces + or_config.append(nmc) + logging.info(f"or_config for or {or_config}") + return [or_interfaces,or_config] def openroadm_values_extractor (data_xml:str,resource_keys:list,dic:dict): ports_result=[] openroadm_info= extract_openroadm_info(data_xml) circuits_list = extract_roadm_circuits_pack(data_xml) - interfaces = extract_openroadm_interface(data_xml) + interfaces,config = extract_openroadm_interface(data_xml) dic["openroadm_info"]=openroadm_info dic["circuits"]=circuits_list - dic['interfaces']=interfaces + dic['interfaces']=config for circuit in circuits_list : - + circuit_name=circuit['circuit_name'] + location = Location() + location.circuit_pack=circuit_name for port in circuit['ports']: if port is not None and 'port_name' in port : resource_key = '/endpoints/endpoint[{:s}]'.format(port["port_name"]) - resource_value = {'uuid': port["port_name"], 'type':port["port_qual"] if "port_qual" in port else None} + resource_value = {'uuid': port["port_name"] + , 'type':port["port_qual"] if "port_qual" in port else None, + 'location':{"circuit_pack":location.circuit_pack} + } ports_result.append((resource_key, resource_value)) + for interface in interfaces: + existed=False + circuit_name=interface['circuit_pack_name'] + interface_list=interface['interface_list'] + + location_interface=f'{interface_list}/{circuit_name}' + port = interface["port"] + type = interface['type'] + if port is not None: + for i , (key,value) in enumerate(ports_result): + if value['uuid'] == port: + new_value = value + merged_interface=None + if 'interface' in value['location']: + merged_interface= f"{value['location']['interface']},{location_interface}" + if merged_interface is not None : + new_value['location']={"interface":merged_interface} + else : + new_value['location']={"interface":location_interface} + + ports_result[i]= (key,new_value ) + existed=True + break + + if not existed: + resource_key = '/endpoints/endpoint[{:s}]'.format(port) + resource_value = {'uuid': f'{port}' + , 'type':type , + 'location':{"interface":location_interface} + } + ports_result.append((resource_key, resource_value)) + + return [dic,ports_result] diff --git a/src/tests/ofc24/r_t.sh b/src/tests/ofc24/r_t.sh old mode 100644 new mode 100755 diff --git a/src/webui/service/opticalconfig/routes.py b/src/webui/service/opticalconfig/routes.py index ace59d670..1b60bff1b 100644 --- a/src/webui/service/opticalconfig/routes.py +++ b/src/webui/service/opticalconfig/routes.py @@ -10,7 +10,7 @@ from slice.client.SliceClient import SliceClient from .forms import UpdateDeviceForm ,AddTrancseiver ,UpdateInterfaceForm ,UpdateStatusForm from common.tools.context_queries.OpticalConfig import opticalconfig_get_uuid , device_get_uuid - +from common.DeviceTypes import DeviceTypeEnum opticalconfig = Blueprint('opticalconfig', __name__,url_prefix="/opticalconfig") context_client = ContextClient() @@ -41,11 +41,15 @@ def home() : value=json.loads(configs.config) if type(configs.config)==str else configs.config config_type = value["type"] - if ('channels' in value): - - - channels_num=len(value['channels']) - value["channels_number"]=channels_num + if config_type != DeviceTypeEnum.OPEN_ROADM._value_ : + if ('channels' in value): + + + value["channels_number"]=len(value['channels']) + + else : + if ('interfaces' in value) : + value["channels_number"]=len(value['interfaces']) # value['operationalMode']=value['operational-mode'] # value['targetOutputPower']=value['target-output-power'] value['opticalconfig_id']=configs.opticalconfig_id @@ -82,7 +86,7 @@ def show_details(config_uuid): device_name= config["device_name"] config_type = config["type"] - if config_type == 'optical-transponder': + if config_type == DeviceTypeEnum.OPTICAL_TRANSPONDER._value_: LOGGER.info("config details from show detail %s",config) @@ -100,7 +104,7 @@ def show_details(config_uuid): device_details.append(new_config) - if config_type == 'optical-roadm': + if config_type == DeviceTypeEnum.OPTICAL_ROADM._value_: LOGGER.info("config details from show detail %s",config) @@ -119,7 +123,24 @@ def show_details(config_uuid): new_config['optical_band_parent']= channel['optical_band_parent'] if 'optical_band_parent' in channel else '' new_config['channel_index']= channel['channel_index'] if 'channel_index' in channel else '' - device_details.append(new_config) + device_details.append(new_config) + if config_type == DeviceTypeEnum.OPEN_ROADM._value_: + if 'interfaces' in config : + for interface in config["interfaces"]: + new_config={} + new_config["name"]=interface["name"] if "name" in interface else '' + new_config["administrative_state"]=interface[ "administrative_state"] + new_config["circuit_pack_name"]=interface["circuit_pack_name"] + new_config["port"]=interface["port"] + new_config["interface_list"]=interface["interface_list"] + new_config["frequency"]=interface["frequency"] + new_config["width"]=interface[ "width"] + new_config["type"]=interface["type"] + + device_details.append(new_config) + + + LOGGER.info("device details %s",device_details) return render_template('opticalconfig/details.html', device=device_details,config_id=config_uuid,device_name=device_name,type=config_type) @@ -360,6 +381,81 @@ def update_status (config_uuid,channel_name): flash(f'Problem updating the device. {e}', 'danger') return render_template('opticalconfig/update_status.html',form=form , channel_name=channel_name, submit_text='Update Device Status') + + +@opticalconfig.route('/configure_openroadm', methods=['POST']) +def update_openroadm () : + + if (request.method == 'POST'): + ports_list= [] + data = request.get_json() + LOGGER.info(f"data {data}") + devices=data.get('devices') + LOGGER.info(f"devices {devices}") + myResponse =[] + status_code='' + config={} + target_interface={} + for device in devices : + frequency = device.get("frequency") + width= device.get("width") + ports=device.get('ports') + device_name=device.get("device_name") + LOGGER.info(f"device from post {device}") + target_interface["frequency"]=frequency + target_interface["width"]=width + target_interface["administrative-state"]="inService" + target_interface["config_type"]=device.get("config_type") + + + if (device_name): + + opticalconfig_uuid = opticalconfig_get_uuid(device_name=device_name) + opticalconfigId=OpticalConfigId() + opticalconfigId.opticalconfig_uuid=opticalconfig_uuid + context_client.connect() + opticalconfig = context_client.SelectOpticalConfig(opticalconfigId) + context_client.close() + config =json.loads(opticalconfig.config) + for port in ports : + ports_list.append({ + "supporting-circuit-pack-name":port["circuit_pack"], + 'supporting-interface-list':port["interface_list"], + 'supporting-port':port["port"] + }) + target_interface["ports"]=ports_list + config["new_config"]=target_interface + opticalconfig.config =json.dumps(config) + try: + device_client.connect() + device_client.ConfigureOpticalDevice(opticalconfig) + device_client.close() + + myResponse.append(f"device {device_name} port {port} is updated successfully") + status_code = 200 + + + except Exception as e: # pylint: disable=broad-except + + myResponse.append(f"Problem updating the device. {e}") + status_code = 500 + break + + + + else : + + myResponse.append(f"requested device {device_name} is not existed") + status_code = 400 + break + + + + response=make_response(f'{myResponse}') + response.status_code=status_code + + return response + \ No newline at end of file diff --git a/src/webui/service/templates/opticalconfig/details.html b/src/webui/service/templates/opticalconfig/details.html index e1d009efd..08c22db84 100644 --- a/src/webui/service/templates/opticalconfig/details.html +++ b/src/webui/service/templates/opticalconfig/details.html @@ -83,6 +83,38 @@ {% endfor %} </tbody> </table> + {% elif type == 'openroadm' %} + + <table class="table table-striped table-hover"> + <thead> + <tr> + <th scope="col"> name</th> + <th scope="col"> type</th> + <th scope="col">administrative state</th> + <th scope="col">circuit pack name</th> + <th scope="col">port</th> + <th scope="col">interface list</th> + <th scope="col">frequency</th> + <th scope="col">width</th> + </tr> + </thead> + <tbody> + + {% for channel in device %} + <tr style="background-color:{%if channel.status == 'DISABLED' %} gray {% endif %};"> + <td>{{channel.name}}</td> + <td>{{channel.type}}</td> + <td>{{channel.administrative_state}}</td> + <td> {{channel.circuit_pack_name}}</td> + <td>{{channel.port}}</td> + <td>{{channel.interface_list}}</td> + <td> {{channel.frequency}}</td> + <td> {{channel.width}}</td> + </tr> + {% endfor %} + </tbody> + </table> + {%else%} <table class="table table-striped table-hover"> <thead> diff --git a/test.py b/test.py index 4a5d82ee8..9595e5bb8 100644 --- a/test.py +++ b/test.py @@ -5,31 +5,48 @@ import re from typing import Optional, Union from uuid import UUID, uuid4, uuid5 import logging +from decimal import Decimal + + +create_mc_test = ''' +<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> +<org-openroadm-device xmlns="http://org/openroadm/device" xmlns:openROADM-if="http://org/openroadm/interfaces"> +<interface> <name>MC-TTP-DEG1-RX-193.3</name> <description>Media-channel-193.3THz</description> +<type>openROADM-if:mediaChannelTrailTerminationPoint</type> <administrative-state>inService</administrative-state> +<supporting-circuit-pack-name>DEG1-AMPTX</supporting-circuit-pack-name> <supporting-port>DEG1-AMPTX-OUT</supporting-port> +<supporting-interface-list>OMS-DEG1-TTP-RX</supporting-interface-list> <mc-ttp xmlns="http://org/openroadm/media-channel-interfaces"> +<max-freq>193350.0</max-freq> <min-freq>193250.0</min-freq> </mc-ttp> </interface> <interface> <name>MC-TTP-DEG1-TX-193.3</name> +<description>Media-channel-193.3THz</description> <type>openROADM-if:mediaChannelTrailTerminationPoint</type> +<administrative-state>inService</administrative-state> <supporting-circuit-pack-name>DEG1-AMPRX</supporting-circuit-pack-name> +<supporting-port>DEG1-AMPRX-IN</supporting-port> <supporting-interface-list>OMS-DEG1-TTP-TX</supporting-interface-list> +<mc-ttp xmlns="http://org/openroadm/media-channel-interfaces"> +<max-freq>193350.0</max-freq> <min-freq>193250.0</min-freq> </mc-ttp> </interface> </org-openroadm-device></config> +''' create_mc_err= ''' <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> -<org-openroadm-device xmlns="http://org/openroadm/device" xmlns:openROADM-if="http://org/openroadm/interfaces"> +<org-openroadm-device xmlns="http://org/openroadm/device"> <interface> - <name>MC-TTP-DEG1-RX-193.3</name> - <description>Media-Channel-TTP-193.3THz-degree-1-in</description> + <name>MC-TTP-DEG2-RX-193.3</name> + <description>Media-Channel-TTP-193.3THz-degree-2-in</description> <type>openROADM-if:mediaChannelTrailTerminationPoint</type> <administrative-state>inService</administrative-state> - <supporting-circuit-pack-name>DEG1-AMPRX</supporting-circuit-pack-name> - <supporting-port>DEG1-AMPRX-IN</supporting-port> - <supporting-interface-list>OMS-DEG1-TTP-RX</supporting-interface-list> + <supporting-circuit-pack-name>DEG2-AMPRX</supporting-circuit-pack-name> + <supporting-port>DEG2-AMPRX-IN</supporting-port> + <supporting-interface-list>OMS-DEG2-TTP-RX</supporting-interface-list> <mc-ttp xmlns="http://org/openroadm/media-channel-interfaces"> <min-freq>193.25</min-freq> <max-freq>193.35</max-freq> </mc-ttp> </interface> <interface> - <name>MC-TTP-DEG1-TX-193.3</name> - <description>Media-Channel-TTP-193.3THz-degree-1-out</description> + <name>MC-TTP-DEG2-TX-193.3</name> + <description>Media-Channel-TTP-193.3THz-degree-2-out</description> <type>openROADM-if:mediaChannelTrailTerminationPoint</type> <administrative-state>inService</administrative-state> - <supporting-circuit-pack-name>DEG1-AMPTX</supporting-circuit-pack-name> - <supporting-port>DEG1-AMPTX-OUT</supporting-port> - <supporting-interface-list>OMS-DEG1-TTP-TX</supporting-interface-list> + <supporting-circuit-pack-name>DEG2-AMPTX</supporting-circuit-pack-name> + <supporting-port>DEG2-AMPTX-OUT</supporting-port> + <supporting-interface-list>OMS-DEG2-TTP-TX</supporting-interface-list> <mc-ttp xmlns="http://org/openroadm/media-channel-interfaces"> <min-freq>193.25</min-freq> <max-freq>193.35</max-freq> @@ -42,28 +59,31 @@ create_mc_err= ''' ''' -create_srg = ''' + +create_nmc = ''' <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> - <org-openroadm-device xmlns="http://org/openroadm/device"> + <org-openroadm-device xmlns="http://org/openroadm/device"> <interface> - <name>SRG1-PP01-TX-193.3</name> - <description>Network-Media-Channel-CTP-193.3THz-srg-1-out</description> + <name>NMC-CTP-DEG2-TX-193.3</name> + <description>Network-Media-Channel-CTP-193.3THz-degree-2-out</description> <type>openROADM-if:networkMediaChannelConnectionTerminationPoint</type> <administrative-state>inService</administrative-state> - <supporting-circuit-pack-name>SRG1-WSS</supporting-circuit-pack-name> - <supporting-port>SRG1-OUT1</supporting-port> + <supporting-circuit-pack-name>DEG2-AMPTX</supporting-circuit-pack-name> + <supporting-interface-list>MC-TTP-DEG2-TX-193.3</supporting-interface-list> + <supporting-port>DEG2-AMPTX-OUT</supporting-port> <nmc-ctp xmlns="http://org/openroadm/network-media-channel-interfaces"> <frequency>193.30</frequency> <width>100</width> </nmc-ctp> </interface> <interface> - <name>SRG1-PP01-RX-193.3</name> - <description>Network-Media-Channel-CTP-193.3THz-srg-1-in</description> + <name>NMC-CTP-DEG2-RX-193.3</name> + <description>Network-Media-Channel-CTP-193.3THz-degree-2-in</description> <type>openROADM-if:networkMediaChannelConnectionTerminationPoint</type> <administrative-state>inService</administrative-state> - <supporting-circuit-pack-name>SRG1-WSS</supporting-circuit-pack-name> - <supporting-port>SRG1-IN1</supporting-port> + <supporting-circuit-pack-name>DEG2-AMPRX</supporting-circuit-pack-name> + <supporting-port>DEG2-AMPRX-IN</supporting-port> + <supporting-interface-list>MC-TTP-DEG2-RX-193.3</supporting-interface-list> <nmc-ctp xmlns="http://org/openroadm/network-media-channel-interfaces"> <frequency>193.30</frequency> <width>100</width> @@ -71,34 +91,32 @@ create_srg = ''' </interface> </org-openroadm-device> - - </config> + ''' -create_nmc = ''' + +create_srg = ''' <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> - <org-openroadm-device xmlns="http://org/openroadm/device"> + <org-openroadm-device xmlns="http://org/openroadm/device"> <interface> - <name>NMC-CTP-DEG1-TX-193.3</name> - <description>Network-Media-Channel-CTP-193.3THz-degree-1-out</description> + <name>SRG1-PP01-TX-193.3</name> + <description>Network-Media-Channel-CTP-193.3THz-srg-1-out</description> <type>openROADM-if:networkMediaChannelConnectionTerminationPoint</type> <administrative-state>inService</administrative-state> - <supporting-circuit-pack-name>DEG1-AMPTX</supporting-circuit-pack-name> - <supporting-interface-list>MC-TTP-DEG1-TX-193.3</supporting-interface-list> - <supporting-port>DEG1-AMPTX-OUT</supporting-port> + <supporting-circuit-pack-name>SRG1-WSS</supporting-circuit-pack-name> + <supporting-port>SRG1-OUT1</supporting-port> <nmc-ctp xmlns="http://org/openroadm/network-media-channel-interfaces"> <frequency>193.30</frequency> <width>100</width> </nmc-ctp> </interface> <interface> - <name>NMC-CTP-DEG1-RX-193.3</name> - <description>Network-Media-Channel-CTP-193.3THz-degree-1-in</description> + <name>SRG1-PP01-RX-193.3</name> + <description>Network-Media-Channel-CTP-193.3THz-srg-1-in</description> <type>openROADM-if:networkMediaChannelConnectionTerminationPoint</type> <administrative-state>inService</administrative-state> - <supporting-circuit-pack-name>DEG1-AMPRX</supporting-circuit-pack-name> - <supporting-port>DEG1-AMPRX-IN</supporting-port> - <supporting-interface-list>MC-TTP-DEG1-RX-193.3</supporting-interface-list> + <supporting-circuit-pack-name>SRG1-WSS</supporting-circuit-pack-name> + <supporting-port>SRG1-IN1</supporting-port> <nmc-ctp xmlns="http://org/openroadm/network-media-channel-interfaces"> <frequency>193.30</frequency> <width>100</width> @@ -106,11 +124,13 @@ create_nmc = ''' </interface> </org-openroadm-device> -</config> + +</config> ''' + create_connec= ''' <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <org-openroadm-device xmlns="http://org/openroadm/device"> @@ -130,22 +150,11 @@ create_connec= ''' </config> ''' -device = { - 'host':'172.17.0.2', # IP address or hostname of the remote machine '172.17.0.2' - 'port': 830, # SSH port (default: 22) - 'username': 'openroadm', # SSH username - 'password': 'openroadm', # SSH password - 'device_params': {'name': 'default'}, - 'hostkey_verify':False, - "allow_agent":False - ,"look_for_keys":False -} - - def extract_openroadm_interface (xml_data:str): + or_config=[] or_interfaces=[] - + xml_bytes = xml_data.encode("utf-8") root = ET.fromstring(xml_bytes) # with open('xml.log', 'w') as f: @@ -154,20 +163,27 @@ def extract_openroadm_interface (xml_data:str): namespace = {'oc': "http://org/openroadm/device" , 'mc':"http://org/openroadm/media-channel-interfaces" - ,'nmc':"http://org/openroadm/network-media-channel-interfaces"} + ,'nmc':"http://org/openroadm/network-media-channel-interfaces" + ,'or-type':'http://org/openroadm/interfaces'} interfaces = root.findall('.//oc:interface',namespace) for interface in interfaces : mc = interface.find('.//mc:mc-ttp',namespace) name = interface.find('.//oc:name',namespace) description = interface.find('.//oc:description',namespace) - type='' + type=interface.find('.//oc:type',namespace) administrative_state=interface.find('.//oc:administrative-state',namespace) circuit_pack_name=interface.find('.//oc:supporting-circuit-pack-name',namespace) port=interface.find('.//oc:supporting-port',namespace) interface_list =interface.find('.//oc:supporting-interface-list',namespace) - + or_interfaces.append({ + 'interface_list':name.text if name is not None else None, + 'administrative_state':administrative_state.text if administrative_state is not None else None, + 'circuit_pack_name':circuit_pack_name.text if circuit_pack_name is not None else None, + 'port':port.text if port is not None else None , + 'type':type.text if type is not None else None + }) if mc is not None : print (mc) frequency = mc.find('.//mc:min-freq',namespace) @@ -183,7 +199,7 @@ def extract_openroadm_interface (xml_data:str): 'frequency': frequency.text if frequency is not None else None, 'width':width.text if width is not None else None } - or_interfaces.append(mc) + or_config.append(mc) else : nmc = interface.find('.//nmc:nmc-ctp',namespace) @@ -201,26 +217,51 @@ def extract_openroadm_interface (xml_data:str): 'frequency': frequency.text if frequency is not None else None, 'width':width.text if width is not None else None } - or_interfaces.append(nmc) - return or_interfaces - - - + or_config.append(nmc) + + return [or_interfaces,or_config] + + + + + + +device = { + 'host':'172.17.0.2', # IP address or hostname of the remote machine '172.17.0.2' + 'port': 830, # SSH port (default: 22) + 'username': 'openroadm', # SSH username + 'password': 'openroadm', # SSH password + 'device_params': {'name': 'default'}, + 'hostkey_verify':False, + + + "force_running": False, + + "look_for_keys": False, + "allow_agent": False, + "commit_per_rule": False, +} + + + if __name__ == '__main__': + - with manager.connect(host=device['host'] - ,port=device['port'] + with manager.connect( host=device['host'] + ,port=device['port'] ,username=device['username'] ,password=device['password'] ,hostkey_verify=device['hostkey_verify'] ,allow_agent=device['allow_agent'] ,look_for_keys=device['look_for_keys']) as m : - #edit_result = m.edit_config (target="running",config=create_nmc ) + edit_result = m.edit_config (target="running",config=create_mc_test ) result = m.get_config (source="running").data_xml - interfaces=extract_roadm_interface(result) - print(interfaces) + #interfaces,config = extract_openroadm_interface(result) + #print (interfaces) + #interfaces=extract_roadm_interface(result) + #print(interfaces) # optical_band_namespaces="http://flex-scale-project.eu/yang/flex-scale-mg-on" #namespaces={"oc":"http://openconfig.net/yang/wavelength-router"} #obj=extract_media_channels(result,namespaces) @@ -233,8 +274,9 @@ if __name__ == '__main__': #print(f"optical_bands {obj1}") #print(f"circuits {circuits}") - # with open("xml.log","w") as f: - # print (result,file=f) + with open("xml.log","w") as f: + print (result,file=f) + -- GitLab