diff --git a/src/device/Config.py b/src/device/Config.py index 1549d9811aa5d1c193a44ad45d0d7773236c0612..2e831a4054522db5206ad424483367a20be324b9 100644 --- a/src/device/Config.py +++ b/src/device/Config.py @@ -12,3 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. + +import os + +TRUE_VALUES = {'T', 'TRUE', 'YES', '1'} +DEVICE_EMULATED_ONLY = os.environ.get('DEVICE_EMULATED_ONLY') +LOAD_ALL_DEVICE_DRIVERS = (DEVICE_EMULATED_ONLY is None) or (DEVICE_EMULATED_ONLY.upper() not in TRUE_VALUES) diff --git a/src/device/service/DeviceService.py b/src/device/service/DeviceService.py index 908d133768984c9e4a29999d17c81779d50cfa76..0e1ce79f955607cceed2bb791e44ae547b5772f5 100644 --- a/src/device/service/DeviceService.py +++ b/src/device/service/DeviceService.py @@ -18,15 +18,12 @@ from common.Settings import get_service_port_grpc from common.proto.device_pb2_grpc import add_DeviceServiceServicer_to_server from common.proto.openconfig_device_pb2_grpc import add_OpenConfigServiceServicer_to_server from common.tools.service.GenericGrpcService import GenericGrpcService +from device.Config import LOAD_ALL_DEVICE_DRIVERS from .driver_api.DriverInstanceCache import DriverInstanceCache from .DeviceServiceServicerImpl import DeviceServiceServicerImpl from .monitoring.MonitoringLoops import MonitoringLoops from .OpenConfigServicer import OpenConfigServicer -TRUE_VALUES = {'T', 'TRUE', 'YES', '1'} -DEVICE_EMULATED_ONLY = os.environ.get('DEVICE_EMULATED_ONLY') -LOAD_ALL_DEVICE_DRIVERS = (DEVICE_EMULATED_ONLY is None) or (DEVICE_EMULATED_ONLY.upper() not in TRUE_VALUES) - # Custom gRPC settings # Multiple clients might keep connections alive waiting for RPC methods to be executed. # Requests needs to be serialized to ensure correct device configurations diff --git a/src/device/service/DeviceServiceServicerImpl.py b/src/device/service/DeviceServiceServicerImpl.py index 76fb6545430f4802d7d37c0c35a35a0539aa200e..5e5d7540c0ffbc860ba912cbbcacc637b7d790c5 100644 --- a/src/device/service/DeviceServiceServicerImpl.py +++ b/src/device/service/DeviceServiceServicerImpl.py @@ -31,7 +31,6 @@ from context.client.ContextClient import ContextClient from .driver_api._Driver import _Driver from .driver_api.DriverInstanceCache import DriverInstanceCache, get_driver from .monitoring.MonitoringLoops import MonitoringLoops -from .drivers.oc_driver.OCDriver import OCDriver from .ErrorMessages import ERROR_MISSING_DRIVER, ERROR_MISSING_KPI from .Tools import ( check_connect_rules, check_no_endpoints, compute_rules_to_add_delete, configure_rules, deconfigure_rules, diff --git a/src/device/service/drivers/__init__.py b/src/device/service/drivers/__init__.py index 1e8cff6052d840af2aa57ff22793380f06f16356..beb3db38e153445e48d61e3ad4ac5d514297a91d 100644 --- a/src/device/service/drivers/__init__.py +++ b/src/device/service/drivers/__init__.py @@ -15,12 +15,9 @@ import os from common.DeviceTypes import DeviceTypeEnum from common.proto.context_pb2 import DeviceDriverEnum +from device.Config import LOAD_ALL_DEVICE_DRIVERS from ..driver_api.FilterFields import FilterFieldEnum -TRUE_VALUES = {'T', 'TRUE', 'YES', '1'} -DEVICE_EMULATED_ONLY = os.environ.get('DEVICE_EMULATED_ONLY') -LOAD_ALL_DEVICE_DRIVERS = (DEVICE_EMULATED_ONLY is None) or (DEVICE_EMULATED_ONLY.upper() not in TRUE_VALUES) - DRIVERS = [] from .emulated.EmulatedDriver import EmulatedDriver # pylint: disable=wrong-import-position