Loading src/device/client/DeviceClient.py +10 −2 Viewed Changes for src/device/client/DeviceClient.py: 10 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -15,12 +15,12 @@ import grpc, logging from common.Constants import ServiceNameEnum from common.Settings import get_service_host, get_service_port_grpc from common.proto.context_pb2 import Device, DeviceConfig, DeviceId, Empty from common.proto.context_pb2 import Device, DeviceConfig, DeviceId, Empty, MyConfig, MyConfigId from common.proto.device_pb2 import MonitoringSettings from common.proto.device_pb2_grpc import DeviceServiceStub from common.tools.client.RetryDecorator import retry, delay_exponential from common.tools.grpc.Tools import grpc_message_to_json_string from common.proto.openconfig_device_pb2_grpc import OpenConfigServiceStub LOGGER = logging.getLogger(__name__) MAX_RETRIES = 15 DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) Loading @@ -34,12 +34,14 @@ class DeviceClient: LOGGER.debug('Creating channel to {:s}...'.format(str(self.endpoint))) self.channel = None self.stub = None self.openconfig_stub=None self.connect() LOGGER.debug('Channel created') def connect(self): self.channel = grpc.insecure_channel(self.endpoint) self.stub = DeviceServiceStub(self.channel) self.openconfig_stub=OpenConfigServiceStub(self.channel) def close(self): if self.channel is not None: self.channel.close() Loading Loading @@ -80,3 +82,9 @@ class DeviceClient: response = self.stub.MonitorDeviceKpi(request) LOGGER.debug('MonitorDeviceKpi result: {:s}'.format(grpc_message_to_json_string(response))) return response def ConfigureOpticalDevice(self, request : MyConfig) -> MyConfigId: LOGGER.debug('ConfigureOpticalDevice request: {:s}'.format(grpc_message_to_json_string(request))) response = self.openconfig_stub.ConfigureOpticalDevice(request) LOGGER.debug('ConfigureOpticalDevice result: {:s}'.format(grpc_message_to_json_string(response))) return response src/device/service/driver_api/DriverInstanceCache.py +5 −0 Viewed Changes for src/device/service/driver_api/DriverInstanceCache.py: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -52,7 +52,12 @@ class DriverInstanceCache: driver_class = self._driver_factory.get_driver_class(**filter_fields) MSG = 'Driver({:s}) selected for device({:s}) with filter_fields({:s})...' LOGGER.info(MSG.format(str(driver_class.__name__), str(device_uuid), str(filter_fields))) if driver_class.__name__ == "OCDriver": driver_instance : _Driver = driver_class(address, port, device_uuid=device_uuid, **settings) else: driver_instance : _Driver = driver_class(address, port, **settings) self._device_uuid__to__driver_instance[device_uuid] = driver_instance return driver_instance Loading src/device/service/drivers/oc_driver/templates/Interfaces/__init__.py 0 → 100644 +14 −0 Viewed Changes for src/device/service/drivers/oc_driver/templates/Interfaces/__init__.py: 14 added lines, 0 removed lines. Original line number Diff line number Diff line # 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. src/device/service/drivers/oc_driver/templates/Interfaces/interfaces.py 0 → 100644 +43 −0 Viewed Changes for src/device/service/drivers/oc_driver/templates/Interfaces/interfaces.py: 43 added lines, 0 removed lines. Original line number Diff line number Diff line # 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 def interface_template (interface_data:dict) : data={"name":"eth0","ip":"192.168.1.1","prefix-length":'24'} doc, tag, text = Doc().tagtext() with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"): with tag('interfaces', xmlns="http://openconfig.net/yang/interfaces"): with tag('interface'): with tag('name'):text(interface_data['name']) with tag('config'): with tag('name'):text(interface_data['name']) with tag("enabled"):text(interface_data["enabled"]) with tag('ipv4',xmlns="http://openconfig.net/yang/interfaces/ip") : with tag("addresses"): with tag("address"): with tag('ip'):text(interface_data["ip"]) with tag('config'): with tag('ip'):text(interface_data["ip"]) with tag('prefix-length'):text(interface_data["prefix-length"]) result = indent( doc.getvalue(), indentation = ' '*2, newline = '\r\n' ) logging.info("interfaces %s",result) return result No newline at end of file src/device/service/drivers/oc_driver/templates/VPN/__init__.py 0 → 100644 +14 −0 Viewed Changes for src/device/service/drivers/oc_driver/templates/VPN/__init__.py: 14 added lines, 0 removed lines. Original line number Diff line number Diff line # 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. Loading
src/device/client/DeviceClient.py +10 −2 Viewed Changes for src/device/client/DeviceClient.py: 10 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -15,12 +15,12 @@ import grpc, logging from common.Constants import ServiceNameEnum from common.Settings import get_service_host, get_service_port_grpc from common.proto.context_pb2 import Device, DeviceConfig, DeviceId, Empty from common.proto.context_pb2 import Device, DeviceConfig, DeviceId, Empty, MyConfig, MyConfigId from common.proto.device_pb2 import MonitoringSettings from common.proto.device_pb2_grpc import DeviceServiceStub from common.tools.client.RetryDecorator import retry, delay_exponential from common.tools.grpc.Tools import grpc_message_to_json_string from common.proto.openconfig_device_pb2_grpc import OpenConfigServiceStub LOGGER = logging.getLogger(__name__) MAX_RETRIES = 15 DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) Loading @@ -34,12 +34,14 @@ class DeviceClient: LOGGER.debug('Creating channel to {:s}...'.format(str(self.endpoint))) self.channel = None self.stub = None self.openconfig_stub=None self.connect() LOGGER.debug('Channel created') def connect(self): self.channel = grpc.insecure_channel(self.endpoint) self.stub = DeviceServiceStub(self.channel) self.openconfig_stub=OpenConfigServiceStub(self.channel) def close(self): if self.channel is not None: self.channel.close() Loading Loading @@ -80,3 +82,9 @@ class DeviceClient: response = self.stub.MonitorDeviceKpi(request) LOGGER.debug('MonitorDeviceKpi result: {:s}'.format(grpc_message_to_json_string(response))) return response def ConfigureOpticalDevice(self, request : MyConfig) -> MyConfigId: LOGGER.debug('ConfigureOpticalDevice request: {:s}'.format(grpc_message_to_json_string(request))) response = self.openconfig_stub.ConfigureOpticalDevice(request) LOGGER.debug('ConfigureOpticalDevice result: {:s}'.format(grpc_message_to_json_string(response))) return response
src/device/service/driver_api/DriverInstanceCache.py +5 −0 Viewed Changes for src/device/service/driver_api/DriverInstanceCache.py: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -52,7 +52,12 @@ class DriverInstanceCache: driver_class = self._driver_factory.get_driver_class(**filter_fields) MSG = 'Driver({:s}) selected for device({:s}) with filter_fields({:s})...' LOGGER.info(MSG.format(str(driver_class.__name__), str(device_uuid), str(filter_fields))) if driver_class.__name__ == "OCDriver": driver_instance : _Driver = driver_class(address, port, device_uuid=device_uuid, **settings) else: driver_instance : _Driver = driver_class(address, port, **settings) self._device_uuid__to__driver_instance[device_uuid] = driver_instance return driver_instance Loading
src/device/service/drivers/oc_driver/templates/Interfaces/__init__.py 0 → 100644 +14 −0 Viewed Changes for src/device/service/drivers/oc_driver/templates/Interfaces/__init__.py: 14 added lines, 0 removed lines. Original line number Diff line number Diff line # 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.
src/device/service/drivers/oc_driver/templates/Interfaces/interfaces.py 0 → 100644 +43 −0 Viewed Changes for src/device/service/drivers/oc_driver/templates/Interfaces/interfaces.py: 43 added lines, 0 removed lines. Original line number Diff line number Diff line # 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 def interface_template (interface_data:dict) : data={"name":"eth0","ip":"192.168.1.1","prefix-length":'24'} doc, tag, text = Doc().tagtext() with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"): with tag('interfaces', xmlns="http://openconfig.net/yang/interfaces"): with tag('interface'): with tag('name'):text(interface_data['name']) with tag('config'): with tag('name'):text(interface_data['name']) with tag("enabled"):text(interface_data["enabled"]) with tag('ipv4',xmlns="http://openconfig.net/yang/interfaces/ip") : with tag("addresses"): with tag("address"): with tag('ip'):text(interface_data["ip"]) with tag('config'): with tag('ip'):text(interface_data["ip"]) with tag('prefix-length'):text(interface_data["prefix-length"]) result = indent( doc.getvalue(), indentation = ' '*2, newline = '\r\n' ) logging.info("interfaces %s",result) return result No newline at end of file
src/device/service/drivers/oc_driver/templates/VPN/__init__.py 0 → 100644 +14 −0 Viewed Changes for src/device/service/drivers/oc_driver/templates/VPN/__init__.py: 14 added lines, 0 removed lines. Original line number Diff line number Diff line # 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.