Adding omf generic resource manager, and change attributes for omf node
authorLucia Guevgeozian Odizzio <lucia.guevgeozian_odizzio@inria.fr>
Tue, 1 Oct 2013 16:32:52 +0000 (18:32 +0200)
committerLucia Guevgeozian Odizzio <lucia.guevgeozian_odizzio@inria.fr>
Tue, 1 Oct 2013 16:32:52 +0000 (18:32 +0200)
src/nepi/resources/omf/node.py
src/nepi/resources/omf/omf_resource.py [new file with mode: 0644]

index 1421078..b6b65ef 100644 (file)
 from nepi.execution.resource import ResourceManager, clsinit, ResourceState, \
         reschedule_delay
 from nepi.execution.attribute import Attribute, Flags 
-
+from nepi.resources.omf.omf_resource import ResourceGateway, OMFResource
 from nepi.resources.omf.omf_api import OMFAPIFactory
 
 import time
 
 
 @clsinit
-class OMFNode(ResourceManager):
+class OMFNode(OMFResource):
     """
     .. class:: Class Args :
       
@@ -54,38 +54,8 @@ class OMFNode(ResourceManager):
 
         """
         hostname = Attribute("hostname", "Hostname of the machine")
-        cpu = Attribute("cpu", "CPU of the node")
-        ram = Attribute("ram", "RAM of the node")
-        xmppSlice = Attribute("xmppSlice","Name of the slice",
-                flags = Flags.Credential)
-        xmppHost = Attribute("xmppHost", "Xmpp Server",
-                flags = Flags.Credential)
-        xmppPort = Attribute("xmppPort", "Xmpp Port",
-                flags = Flags.Credential)
-        xmppPassword = Attribute("xmppPassword", "Xmpp Port",
-                flags = Flags.Credential)
-
-        host = Attribute("host", "Hostname of the machine",
-                flags = Flags.Filter)
-        gateway = Attribute("gateway", "Gateway",
-                flags = Flags.Filter)
-        granularity = Attribute("granularity", "Granularity of the reservation time",
-                flags = Flags.Filter)
-        hardware_type = Attribute("hardware_type", "Hardware type of the machine",
-                flags = Flags.Filter)
 
         cls._register_attribute(hostname)
-        cls._register_attribute(ram)
-        cls._register_attribute(cpu)
-        cls._register_attribute(xmppSlice)
-        cls._register_attribute(xmppHost)
-        cls._register_attribute(xmppPort)
-        cls._register_attribute(xmppPassword)
-
-        cls._register_attribute(host)
-        cls._register_attribute(gateway)
-        cls._register_attribute(granularity)
-        cls._register_attribute(hardware_type)
 
     # XXX: We don't necessary need to have the credentials at the 
     # moment we create the RM
diff --git a/src/nepi/resources/omf/omf_resource.py b/src/nepi/resources/omf/omf_resource.py
new file mode 100644 (file)
index 0000000..f6a473a
--- /dev/null
@@ -0,0 +1,63 @@
+#
+#    NEPI, a framework to manage network experiments
+#    Copyright (C) 2013 INRIA
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Julien Tribino <julien.tribino@inria.fr>
+#         Lucia Guevgeozian <lucia.guevgeozian_odizzio@inria.fr>
+
+from nepi.execution.attribute import Attribute, Flags, Types
+from nepi.execution.resource import ResourceManager, clsinit_copy, ResourceState, \
+        reschedule_delay
+
+class ResourceGateway:
+    """
+    Dictionary used to set OMF gateway depending on Testbed information.
+    """
+    TestbedtoGateway = dict({
+        "wilabt" : "ops.wilab2.ilabt.iminds.be",
+        "nitos" : "??.??.??",
+        "nicta" : "??.??.??",
+    })
+
+@clsinit_copy
+class OMFResource(ResourceManager):
+    """
+    Generic resource gathering XMPP credential information and common methods
+    for OMF nodes, channels, applications, etc.
+    """
+    _rtype = "OMFResource"
+
+    @classmethod
+    def _register_attributes(cls):
+
+        xmppSlice = Attribute("xmppSlice","Name of the slice", 
+            flags = Flags.Credential)
+        xmppHost = Attribute("xmppHost", "Xmpp Server",
+            flags = Flags.Credential)
+        xmppPort = Attribute("xmppPort", "Xmpp Port",
+            flags = Flags.Credential)
+        xmppPassword = Attribute("xmppPassword", "Xmpp Password",
+                flags = Flags.Credential)
+
+        cls._register_attribute(xmppSlice)
+        cls._register_attribute(xmppHost)
+        cls._register_attribute(xmppPort)
+        cls._register_attribute(xmppPassword)
+
+    def __init__(self, ec, guid):
+        super(OMFResource, self).__init__(ec, guid)
+        pass
+