Skip to content
Snippets Groups Projects
Commit 3f7bfa6d authored by Georgios Katsikas's avatar Georgios Katsikas
Browse files

Device/Monitoring component:

- device: added environemnt variable to prevent loading drivers other than emulated
- monitoring: set environment variable to force loading only emulated driver during unitary tests of monitoring
parent de07e72e
No related branches found
No related tags found
2 merge requests!54Release 2.0.0,!4Compute component:
......@@ -12,15 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
from common.DeviceTypes import DeviceTypeEnum
from ..driver_api.FilterFields import FilterFieldEnum, ORM_DeviceDriverEnum
from .emulated.EmulatedDriver import EmulatedDriver
from .openconfig.OpenConfigDriver import OpenConfigDriver
from .transport_api.TransportApiDriver import TransportApiDriver
from .p4.p4_driver import P4Driver
from .microwave.IETFApiDriver import IETFApiDriver
DRIVERS = [
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
DRIVERS.append(
(EmulatedDriver, [
{
# Driver==unspecified & no device type specified => use Emulated
......@@ -38,32 +41,47 @@ DRIVERS = [
ORM_DeviceDriverEnum.TRANSPORT_API
],
}
]),
(OpenConfigDriver, [
{
# Real Packet Router, specifying OpenConfig Driver => use OpenConfigDriver
FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.PACKET_ROUTER,
FilterFieldEnum.DRIVER : ORM_DeviceDriverEnum.OPENCONFIG,
}
]),
(TransportApiDriver, [
{
# Real OLS, specifying TAPI Driver => use TransportApiDriver
FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.OPEN_LINE_SYSTEM,
FilterFieldEnum.DRIVER : ORM_DeviceDriverEnum.TRANSPORT_API,
}
]),
(P4Driver, [
{
# Real P4 Switch, specifying P4 Driver => use P4Driver
FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.P4_SWITCH,
FilterFieldEnum.DRIVER : ORM_DeviceDriverEnum.P4,
}
]),
(IETFApiDriver, [
{
FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.MICROVAWE_RADIO_SYSTEM,
FilterFieldEnum.DRIVER : ORM_DeviceDriverEnum.IETF_NETWORK_TOPOLOGY,
}
]),
]
]))
if LOAD_ALL_DEVICE_DRIVERS:
from .openconfig.OpenConfigDriver import OpenConfigDriver # pylint: disable=wrong-import-position
DRIVERS.append(
(OpenConfigDriver, [
{
# Real Packet Router, specifying OpenConfig Driver => use OpenConfigDriver
FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.PACKET_ROUTER,
FilterFieldEnum.DRIVER : ORM_DeviceDriverEnum.OPENCONFIG,
}
]))
if LOAD_ALL_DEVICE_DRIVERS:
from .transport_api.TransportApiDriver import TransportApiDriver # pylint: disable=wrong-import-position
DRIVERS.append(
(TransportApiDriver, [
{
# Real OLS, specifying TAPI Driver => use TransportApiDriver
FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.OPTICAL_LINE_SYSTEM,
FilterFieldEnum.DRIVER : ORM_DeviceDriverEnum.TRANSPORT_API,
}
]))
if LOAD_ALL_DEVICE_DRIVERS:
from .p4.p4_driver import P4Driver # pylint: disable=wrong-import-position
DRIVERS.append(
(P4Driver, [
{
# Real P4 Switch, specifying P4 Driver => use P4Driver
FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.P4_SWITCH,
FilterFieldEnum.DRIVER : ORM_DeviceDriverEnum.P4,
}
]))
if LOAD_ALL_DEVICE_DRIVERS:
from .microwave.IETFApiDriver import IETFApiDriver # pylint: disable=wrong-import-position
DRIVERS.append(
(IETFApiDriver, [
{
FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.MICROVAWE_RADIO_SYSTEM,
FilterFieldEnum.DRIVER : ORM_DeviceDriverEnum.IETF_NETWORK_TOPOLOGY,
}
]))
......@@ -5,10 +5,10 @@ fastcache==1.1.0
#opencensus[stackdriver]
#google-cloud-profiler
#numpy
Jinja2==3.0.3
ncclient==0.6.13
p4runtime==1.3.0
paramiko==2.9.2
#Jinja2==3.0.3
#ncclient==0.6.13
#p4runtime==1.3.0
#paramiko==2.9.2
influx-line-protocol==0.1.4
python-dateutil==2.8.2
python-json-logger==2.0.2
......
......@@ -32,8 +32,11 @@ from device.client.DeviceClient import DeviceClient
from device.service.DeviceService import DeviceService
from device.service.driver_api.DriverFactory import DriverFactory
from device.service.driver_api.DriverInstanceCache import DriverInstanceCache
from device.service.drivers import DRIVERS
os.environ['DEVICE_EMULATED_ONLY'] = 'TRUE'
from device.service.drivers import DRIVERS # pylint: disable=wrong-import-position
# pylint: disable=wrong-import-position
from monitoring.client.MonitoringClient import MonitoringClient
from common.proto import context_pb2, monitoring_pb2
from common.proto.kpi_sample_types_pb2 import KpiSampleType
......
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