Working on automatic generation of ns-3 RMs
authorAlina Quereilhac <alina.quereilhac@inria.fr>
Fri, 31 Jan 2014 10:25:41 +0000 (11:25 +0100)
committerAlina Quereilhac <alina.quereilhac@inria.fr>
Fri, 31 Jan 2014 10:25:41 +0000 (11:25 +0100)
src/nepi/resources/linux/ns3/ns3simulator.py [moved from src/nepi/resources/linux/ns3/simulator.py with 92% similarity]
src/nepi/resources/ns3/ns3simulator.py
src/nepi/resources/ns3/resource_manager_generator.py [moved from src/nepi/resources/ns3/rm_creator.py with 94% similarity]
src/nepi/resources/ns3/templates/resource_manager_template.txt [moved from src/nepi/resources/ns3/templates/rm_template.txt with 87% similarity]
test/resources/linux/ns3/ns3client.py [moved from test/resources/ns3/linuxns3client.py with 99% similarity]

similarity index 92%
rename from src/nepi/resources/linux/ns3/simulator.py
rename to src/nepi/resources/linux/ns3/ns3simulator.py
index 82d4bca..4c605f7 100644 (file)
@@ -24,13 +24,14 @@ from nepi.execution.resource import ResourceManager, clsinit_copy, \
 from nepi.resources.linux.application import LinuxApplication
 from nepi.resources.linux.node import OSType
 from nepi.util.timefuncs import tnow, tdiffsec
-from nepi.resources.ns3.simulator import NS3Simulator
+from nepi.resources.ns3.ns3simulator import NS3Simulator
+from nepi.resources.linux.ns3.ns3client import LinuxNS3Client
 
 import os
 
 @clsinit_copy
 class LinuxNS3Simulator(LinuxApplication, NS3Simulator):
-    _rtype = "LinuxSimulator"
+    _rtype = "LinuxNS3Simulator"
 
     @classmethod
     def _register_attributes(cls):
@@ -38,33 +39,17 @@ class LinuxNS3Simulator(LinuxApplication, NS3Simulator):
             "Sets the CCND_MAX_RTE_MICROSEC environmental variable. ",
             flags = Flags.ExecReadOnly)
 
-        keystore = Attribute("keyStoreDirectory",
-            "Sets the CCND_KEYSTORE_DIRECTORY environmental variable. ",
-            flags = Flags.ExecReadOnly)
-
         cls._register_attribute(debug)
-        cls._register_attribute(port)
-
-    @classmethod
-    def _register_traces(cls):
-        log = Trace("log", "CCND log output")
-        status = Trace("status", "ccndstatus output")
-
-        cls._register_trace(log)
-        cls._register_trace(status)
 
     def __init__(self, ec, guid):
-        super(LinuxCCND, self).__init__(ec, guid)
-        self._home = "ccnd-%s" % self.guid
-        self._version = "ccnx"
+        super(LinuxApplication, self).__init__(ec, guid)
+        super(NS3Simulator, self).__init__()
 
-    @property
-    def version(self):
-        return self._version
+        self._home = "ns3-simu-%s" % self.guid
+        
+        # TODO: Create socket!!
+        self._client = LinuxNS3Client(socket_name)
 
-    @property
-    def path(self):
-        return "PATH=$PATH:${BIN}/%s/" % self.version 
 
     def do_deploy(self):
         if not self.node or self.node.state < ResourceState.READY:
index 4013a3c..1c557e7 100644 (file)
@@ -18,7 +18,6 @@
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
 class NS3Simulator(object):
-
     @property
     def client(self):
         return self._client
similarity index 94%
rename from src/nepi/resources/ns3/rm_creator.py
rename to src/nepi/resources/ns3/resource_manager_generator.py
index 786f457..c01180e 100644 (file)
@@ -53,12 +53,15 @@ def create_ns3_rms():
         rtype = tid.GetName()
         category = tid.GetGroupName()
 
+        base_class_import = "from nepi.resources.ns3.ns3base import NS3Base"
+        base_clas = "NS3Base"
         classname = rtype.replace("ns3::", "NS3").replace("::","")
         uncamm_rtype = re.sub('([a-z])([A-Z])', r'\1-\2', rtype).lower()
         short_rtype = uncamm_rtype.replace("::","-")
 
         d = os.path.dirname(os.path.realpath(__file__))
-        ftemp = open(os.path.join(d, "templates", "rm_template.txt"), "r")
+        ftemp = open(os.path.join(d, "templates", "resource_manager_template.txt"), "r")
         template = ftemp.read()
         ftemp.close()
 
@@ -67,6 +70,8 @@ def create_ns3_rms():
                 replace("<RTYPE>", rtype). \
                 replace("<ATTRIBUTES>", attributes). \
                 replace("<TRACES>", traces). \
+                replace("<BASE_CLASS_IMPORT>", base_class_import). \
+                replace("<BASE_CLASS>", base_class). \
                 replace("<SHORT-RTYPE>", short_rtype)
 
         fname = uncamm_rtype.replace('ns3::', ''). \
@@ -20,10 +20,10 @@ from nepi.execution.attribute import Attribute, Flags, Types
 from nepi.execution.trace import Trace, TraceAttr
 from nepi.execution.resource import ResourceManager, clsinit_copy, \
         ResourceState, reschedule_delay
-from nepi.resources.ns3.ns3_base import NS3Base
+<BASE_CLASS_IMPORT>
 
 @clsinit_copy
-class <CLASS_NAME>(NS3Base):
+class <CLASS_NAME>(<BASE_CLASS>):
     _rtype = "<RTYPE>"
 
     @classmethod
@@ -37,10 +37,3 @@ class <CLASS_NAME>(NS3Base):
     def __init__(self, ec, guid):
         super(<CLASS_NAME>, self).__init__(ec, guid)
         self._home = "<SHORT-RTYPE>-%s" % self.guid
-        # TODO!
-        self._version = None
-
-    @property
-    def version(self):
-        return self._version
-
similarity index 99%
rename from test/resources/ns3/linuxns3client.py
rename to test/resources/linux/ns3/ns3client.py
index 207e437..404fc5d 100644 (file)
@@ -31,7 +31,7 @@
 
 
 from nepi.resources.ns3.ns3server import run_server
-from nepi.resources.ns3.linuxns3client import LinuxNS3Client
+from nepi.resources.linux.ns3.ns3client import LinuxNS3Client
 
 import os
 import threading