From 4b0e922489532434f0968647886021542b77cece Mon Sep 17 00:00:00 2001 From: Alina Quereilhac Date: Thu, 26 Sep 2013 15:03:08 +0200 Subject: [PATCH] Adding help and background class atrributes to ResourceManager --- src/nepi/execution/resource.py | 28 +++++++++++++++++++ src/nepi/resources/all/collector.py | 6 ++-- src/nepi/resources/linux/application.py | 3 ++ src/nepi/resources/linux/channel.py | 2 ++ src/nepi/resources/linux/interface.py | 2 ++ src/nepi/resources/linux/node.py | 3 ++ src/nepi/resources/linux/udptunnel.py | 3 ++ src/nepi/resources/planetlab/node.py | 3 ++ .../resources/planetlab/openvswitch/ovs.py | 5 ++-- .../planetlab/openvswitch/ovsport.py | 5 ++-- src/nepi/resources/planetlab/tap.py | 2 ++ src/nepi/resources/planetlab/tun.py | 2 ++ 12 files changed, 58 insertions(+), 6 deletions(-) diff --git a/src/nepi/execution/resource.py b/src/nepi/execution/resource.py index 95e31ff9..a9087aec 100644 --- a/src/nepi/execution/resource.py +++ b/src/nepi/execution/resource.py @@ -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()) diff --git a/src/nepi/resources/all/collector.py b/src/nepi/resources/all/collector.py index 6101cdd8..812a9392 100644 --- a/src/nepi/resources/all/collector.py +++ b/src/nepi/resources/all/collector.py @@ -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): diff --git a/src/nepi/resources/linux/application.py b/src/nepi/resources/linux/application.py index f9c46c82..4f4b64ea 100644 --- a/src/nepi/resources/linux/application.py +++ b/src/nepi/resources/linux/application.py @@ -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): diff --git a/src/nepi/resources/linux/channel.py b/src/nepi/resources/linux/channel.py index 679a36d3..2ed5c014 100644 --- a/src/nepi/resources/linux/channel.py +++ b/src/nepi/resources/linux/channel.py @@ -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) diff --git a/src/nepi/resources/linux/interface.py b/src/nepi/resources/linux/interface.py index f5f7025d..26a1549e 100644 --- a/src/nepi/resources/linux/interface.py +++ b/src/nepi/resources/linux/interface.py @@ -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): diff --git a/src/nepi/resources/linux/node.py b/src/nepi/resources/linux/node.py index d71d21f7..b50d7fad 100644 --- a/src/nepi/resources/linux/node.py +++ b/src/nepi/resources/linux/node.py @@ -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): diff --git a/src/nepi/resources/linux/udptunnel.py b/src/nepi/resources/linux/udptunnel.py index 1d23736c..82f01393 100644 --- a/src/nepi/resources/linux/udptunnel.py +++ b/src/nepi/resources/linux/udptunnel.py @@ -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): diff --git a/src/nepi/resources/planetlab/node.py b/src/nepi/resources/planetlab/node.py index 55464d3b..3cd5b548 100644 --- a/src/nepi/resources/planetlab/node.py +++ b/src/nepi/resources/planetlab/node.py @@ -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() diff --git a/src/nepi/resources/planetlab/openvswitch/ovs.py b/src/nepi/resources/planetlab/openvswitch/ovs.py index e8b8011e..bffc61ef 100644 --- a/src/nepi/resources/planetlab/openvswitch/ovs.py +++ b/src/nepi/resources/planetlab/openvswitch/ovs.py @@ -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) diff --git a/src/nepi/resources/planetlab/openvswitch/ovsport.py b/src/nepi/resources/planetlab/openvswitch/ovsport.py index 426ad970..d3e9d799 100644 --- a/src/nepi/resources/planetlab/openvswitch/ovsport.py +++ b/src/nepi/resources/planetlab/openvswitch/ovsport.py @@ -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 diff --git a/src/nepi/resources/planetlab/tap.py b/src/nepi/resources/planetlab/tap.py index 411eb514..c4867b2d 100644 --- a/src/nepi/resources/planetlab/tap.py +++ b/src/nepi/resources/planetlab/tap.py @@ -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): diff --git a/src/nepi/resources/planetlab/tun.py b/src/nepi/resources/planetlab/tun.py index 8d66210b..cdd3a3b5 100644 --- a/src/nepi/resources/planetlab/tun.py +++ b/src/nepi/resources/planetlab/tun.py @@ -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) -- 2.43.0