Adding help and background class atrributes to ResourceManager
authorAlina Quereilhac <alina.quereilhac@inria.fr>
Thu, 26 Sep 2013 13:03:08 +0000 (15:03 +0200)
committerAlina Quereilhac <alina.quereilhac@inria.fr>
Thu, 26 Sep 2013 13:03:08 +0000 (15:03 +0200)
12 files changed:
src/nepi/execution/resource.py
src/nepi/resources/all/collector.py
src/nepi/resources/linux/application.py
src/nepi/resources/linux/channel.py
src/nepi/resources/linux/interface.py
src/nepi/resources/linux/node.py
src/nepi/resources/linux/udptunnel.py
src/nepi/resources/planetlab/node.py
src/nepi/resources/planetlab/openvswitch/ovs.py
src/nepi/resources/planetlab/openvswitch/ovsport.py
src/nepi/resources/planetlab/tap.py
src/nepi/resources/planetlab/tun.py

index 95e31ff..a9087ae 100644 (file)
@@ -83,9 +83,22 @@ def clsinit_copy(cls):
 # Decorator to invoke class initialization method
 @clsinit
 class ResourceManager(Logger):
+    """ Base clase for all ResourceManagers. 
+    
+    A ResourceManger is specific to a resource type (e.g. Node, 
+    Switch, Application, etc) on a specific backend (e.g. PlanetLab, 
+    OMF, etc).
+
+    The ResourceManager instances are responsible for interacting with
+    and controlling concrete (physical or virtual) resources in the 
+    experimental backends.
+    
+    """
     _rtype = "Resource"
     _attributes = None
     _traces = None
+    _help = None
+    _backend = None
 
     @classmethod
     def _register_attribute(cls, attr):
@@ -187,6 +200,21 @@ class ResourceManager(Logger):
         """
         return copy.deepcopy(cls._traces.values())
 
+    @classmethod
+    def get_help(cls):
+        """ Returns the description of the type of Resource
+
+        """
+        return cls._help
+
+    @classmethod
+    def get_backend(cls):
+        """ Returns the identified of the backend (i.e. testbed, environment)
+        for the Resource
+
+        """
+        return cls._backend
+
     def __init__(self, ec, guid):
         super(ResourceManager, self).__init__(self.rtype())
         
index 6101cdd..812a939 100644 (file)
@@ -37,11 +37,13 @@ class Collector(ResourceManager):
         :type ec: ExperimentController
         :param guid: guid of the RM
         :type guid: int
-        :param creds: Credentials to communicate with the rm (XmppClient)
-        :type creds: dict
 
     """
     _rtype = "Collector"
+    _help = "A Collector can be attached to a trace name on another " \
+        "ResourceManager and will retrieve and store the trace content " \
+        "in a local file at the end of the experiment"
+    _backend_type = "all"
 
     @classmethod
     def _register_attributes(cls):
index f9c46c8..4f4b64e 100644 (file)
@@ -82,6 +82,9 @@ class LinuxApplication(ResourceManager):
     """
 
     _rtype = "LinuxApplication"
+    _help = "Runs an application on a Linux host with a BASH command "
+    _backend_type = "linux"
+
 
     @classmethod
     def _register_attributes(cls):
index 679a36d..2ed5c01 100644 (file)
@@ -23,6 +23,8 @@ from nepi.execution.resource import ResourceManager, clsinit, ResourceState
 @clsinit
 class LinuxChannel(ResourceManager):
     _rtype = "LinuxChannel"
+    _help = "Represents a wireless channel on a network of Linux hosts"
+    _backend = "linux"
 
     def __init__(self, ec, guid):
         super(LinuxChannel, self).__init__(ec, guid)
index f5f7025..26a1549 100644 (file)
@@ -36,6 +36,8 @@ import time
 @clsinit
 class LinuxInterface(ResourceManager):
     _rtype = "LinuxInterface"
+    _help = "Controls network devices on Linux hosts through the ifconfig tool"
+    _backend = "linux"
 
     @classmethod
     def _register_attributes(cls):
index d71d21f..b50d7fa 100644 (file)
@@ -142,6 +142,9 @@ class LinuxNode(ResourceManager):
 
     """
     _rtype = "LinuxNode"
+    _help = "Controls Linux host machines ( either localhost or a host " \
+            "that can be accessed using a SSH key)"
+    _backend_type = "linux"
 
     @classmethod
     def _register_attributes(cls):
index 1d23736..82f0139 100644 (file)
@@ -31,6 +31,9 @@ import time
 @clsinit_copy
 class UdpTunnel(LinuxApplication):
     _rtype = "UdpTunnel"
+    _help = "Constructs a tunnel between two Linux endpoints using a UDP connection "
+    _backend = "linux"
+
 
     @classmethod
     def _register_attributes(cls):
index 55464d3..3cd5b54 100644 (file)
@@ -32,6 +32,9 @@ import threading
 @clsinit_copy
 class PlanetlabNode(LinuxNode):
     _rtype = "PlanetlabNode"
+    _help = "Controls a PlanetLab host accessible using a SSH key " \
+            "associated to a PlanetLab user account"
+    _backend = "planetlab"
 
     blacklist = list()
     provisionlist = list()
index e8b8011..bffc61e 100644 (file)
@@ -31,6 +31,9 @@ reschedule_delay = "0.5s"
 class OVSWitch(LinuxApplication):
     
     _rtype = "OVSWitch"
+    _help = "Runs an OpenVSwitch on a PlanetLab host"
+    _backend = "planetlab"
+
     _authorized_connections = ["PlanetlabNode", "OVSPort", "LinuxNode"]       
 
     @classmethod
@@ -58,8 +61,6 @@ class OVSWitch(LinuxApplication):
         :type ec: ExperimentController
         :param guid: guid of the RM
         :type guid: int
-        :param creds: Credentials to communicate with the rm 
-        :type creds: dict
     
         """
         super(OVSWitch, self).__init__(ec, guid)
index 426ad97..d3e9d79 100644 (file)
@@ -35,12 +35,13 @@ class OVSPort(LinuxApplication):
         :type ec: ExperimentController
         :param guid: guid of the RM
         :type guid: int
-        :param creds: Credentials to communicate with the rm 
-        :type creds: dict
 
     """
     
     _rtype = "OVSPort"
+    _help = "Runs an OpenVSwitch on a PlanetLab host"
+    _backend = "planetlab"
+
     _authorized_connections = ["OVSWitch", "Tunnel"]      
 
     @classmethod
index 411eb51..c4867b2 100644 (file)
@@ -36,6 +36,8 @@ PYTHON_VSYS_VERSION = "1.0"
 @clsinit_copy
 class PlanetlabTap(LinuxApplication):
     _rtype = "PlanetlabTap"
+    _help = "Creates a TAP device on a PlanetLab host"
+    _backend = "planetlab"
 
     @classmethod
     def _register_attributes(cls):
index 8d66210..cdd3a3b 100644 (file)
@@ -25,6 +25,8 @@ import os
 @clsinit_copy
 class PlanetlabTun(PlanetlabTap):
     _rtype = "PlanetlabTun"
+    _help = "Creates a TUN device on a PlanetLab host"
+    _backend = "planetlab"
 
     def __init__(self, ec, guid):
         super(PlanetlabTun, self).__init__(ec, guid)