From dd0d4aa78aa33a08618817e545af148b5631f48e Mon Sep 17 00:00:00 2001 From: saacg Date: Wed, 22 Mar 2017 09:25:40 -0400 Subject: [PATCH 1/4] added hardware_services directory --- lib/hardware_services/hardware_service.py | 17 +++++++++++++++++ lib/hardware_services/hil_driver.py | 0 lib/hardware_services/quads_default_driver.py | 0 3 files changed, 17 insertions(+) create mode 100644 lib/hardware_services/hardware_service.py create mode 100644 lib/hardware_services/hil_driver.py create mode 100644 lib/hardware_services/quads_default_driver.py diff --git a/lib/hardware_services/hardware_service.py b/lib/hardware_services/hardware_service.py new file mode 100644 index 000000000..54aa39dd9 --- /dev/null +++ b/lib/hardware_services/hardware_service.py @@ -0,0 +1,17 @@ +# EC528 change +# +# This will be an abstract class (perhaps can use abc) that will serve as a generic interface +# for QUADS to interact with its hardware. It will allow QUADS to substitute different hardware +# isolation services while making minimal changes to the current implementation of QUADS. + +# This class will declare methods corresponding to the functions defined in lib/libquads.py so that QUADS can +# retain its normal workflow and command options. Once implemented, integration with a new hardware isolation +# service will only require writing a driver that inherits from this class and overwrites its methods with +# its service-specific behavior. + +# The hardware service used can be specified at runtime (by changing a single parameter in the conf/quads.yml file). +# A user will specify the name of the service, which will be read in and used as a key in a dictionary (location tbd +# - perhaps in libquads.py, or its own "class mapper" class?) that maps superclass to subclass. +# Duck typing will be used to dynamically assign to a variable in libquads.py a concrete instance of the specified +# subclass (using the "class mapper" dictionary). The quads library will thus be decoupled from any knowledge of +# the specific hardware service being used, as it can now make calls based on this generic interface. diff --git a/lib/hardware_services/hil_driver.py b/lib/hardware_services/hil_driver.py new file mode 100644 index 000000000..e69de29bb diff --git a/lib/hardware_services/quads_default_driver.py b/lib/hardware_services/quads_default_driver.py new file mode 100644 index 000000000..e69de29bb From cbc574343098b635858d2aae2db7baa88d2932a2 Mon Sep 17 00:00:00 2001 From: saacg Date: Wed, 22 Mar 2017 09:44:34 -0400 Subject: [PATCH 2/4] initial design proposal for decoupling quads from juniper --- lib/hardware_services/hardware_service.py | 18 ++++++++++++++++++ lib/hardware_services/hil_driver.py | 2 ++ lib/hardware_services/quads_default_driver.py | 2 ++ 3 files changed, 22 insertions(+) diff --git a/lib/hardware_services/hardware_service.py b/lib/hardware_services/hardware_service.py index 54aa39dd9..82c607955 100644 --- a/lib/hardware_services/hardware_service.py +++ b/lib/hardware_services/hardware_service.py @@ -15,3 +15,21 @@ # Duck typing will be used to dynamically assign to a variable in libquads.py a concrete instance of the specified # subclass (using the "class mapper" dictionary). The quads library will thus be decoupled from any knowledge of # the specific hardware service being used, as it can now make calls based on this generic interface. + + +# abstract methods to be overwritten by concrete subclasses: +# note: these are only examples and do not describe the actual prototypes + + +# remove_host(): +# remove_cloud(): +# update_host(): +# update_cloud(): +# move_hosts(): +# list_hosts(): +# list_clouds(): + +# this list may need to expand to accommodate for scheduling behavior, but for now we assume that scheduling +# be able to continue with minimal changes (only thing that this will change is where QUADS pulls its data from) + +# assuming for now that scheduling services will not have to be diff --git a/lib/hardware_services/hil_driver.py b/lib/hardware_services/hil_driver.py index e69de29bb..e8c20b3cd 100644 --- a/lib/hardware_services/hil_driver.py +++ b/lib/hardware_services/hil_driver.py @@ -0,0 +1,2 @@ +# this class will inherit from hardware_service.py and overwrite all of its methods +# with hil-specific behaviors - mostly through api calls to the HIL server diff --git a/lib/hardware_services/quads_default_driver.py b/lib/hardware_services/quads_default_driver.py index e69de29bb..6e50daf3e 100644 --- a/lib/hardware_services/quads_default_driver.py +++ b/lib/hardware_services/quads_default_driver.py @@ -0,0 +1,2 @@ +# this class will inherit from hardware_service.py and overwrite all of its methods +# with the current quads behavior (calling scripts that interface with juniper switches) From 86ca38b100e9397eeb4156fe7fe38e183cf7ff27 Mon Sep 17 00:00:00 2001 From: saacg Date: Thu, 23 Mar 2017 09:36:53 -0400 Subject: [PATCH 3/4] Changed name of quads_default_driver.py to juniper_driver.py, added mock_driver.py, which will be for testing without hardware, and moved all drivers into new subdirectory, hardware_drivers --- lib/hardware_services/{ => hardware_drivers}/hil_driver.py | 0 .../juniper_driver.py} | 0 lib/hardware_services/hardware_drivers/mock_driver.py | 1 + 3 files changed, 1 insertion(+) rename lib/hardware_services/{ => hardware_drivers}/hil_driver.py (100%) rename lib/hardware_services/{quads_default_driver.py => hardware_drivers/juniper_driver.py} (100%) create mode 100644 lib/hardware_services/hardware_drivers/mock_driver.py diff --git a/lib/hardware_services/hil_driver.py b/lib/hardware_services/hardware_drivers/hil_driver.py similarity index 100% rename from lib/hardware_services/hil_driver.py rename to lib/hardware_services/hardware_drivers/hil_driver.py diff --git a/lib/hardware_services/quads_default_driver.py b/lib/hardware_services/hardware_drivers/juniper_driver.py similarity index 100% rename from lib/hardware_services/quads_default_driver.py rename to lib/hardware_services/hardware_drivers/juniper_driver.py diff --git a/lib/hardware_services/hardware_drivers/mock_driver.py b/lib/hardware_services/hardware_drivers/mock_driver.py new file mode 100644 index 000000000..b022ef0b7 --- /dev/null +++ b/lib/hardware_services/hardware_drivers/mock_driver.py @@ -0,0 +1 @@ +# inherits from hardware_service.py and overwrites methods. This is a mock driver for testing purposes and will not be attached to any specific hardware From fc78970ba4dca2af8a7810051008d73e3e6581ce Mon Sep 17 00:00:00 2001 From: saacg Date: Thu, 23 Mar 2017 09:46:09 -0400 Subject: [PATCH 4/4] removed extra line in hardware_service.py --- lib/hardware_services/hardware_service.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/hardware_services/hardware_service.py b/lib/hardware_services/hardware_service.py index 82c607955..57cf10bef 100644 --- a/lib/hardware_services/hardware_service.py +++ b/lib/hardware_services/hardware_service.py @@ -1,7 +1,7 @@ # EC528 change # # This will be an abstract class (perhaps can use abc) that will serve as a generic interface -# for QUADS to interact with its hardware. It will allow QUADS to substitute different hardware +# for QUADS to interact with and isolate its hardware. It will allow QUADS to substitute different hardware # isolation services while making minimal changes to the current implementation of QUADS. # This class will declare methods corresponding to the functions defined in lib/libquads.py so that QUADS can @@ -30,6 +30,4 @@ # list_clouds(): # this list may need to expand to accommodate for scheduling behavior, but for now we assume that scheduling -# be able to continue with minimal changes (only thing that this will change is where QUADS pulls its data from) - -# assuming for now that scheduling services will not have to be +# will be able to continue with minimal changes (only thing that this will change is where QUADS pulls its data from)