From: Alina Quereilhac Date: Fri, 31 Jan 2014 10:25:41 +0000 (+0100) Subject: Working on automatic generation of ns-3 RMs X-Git-Tag: nepi-3.1.0~120^2~19 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=3ea891e182293a3e39358192c66856a0f9e15329;p=nepi.git Working on automatic generation of ns-3 RMs --- diff --git a/src/nepi/resources/linux/ns3/simulator.py b/src/nepi/resources/linux/ns3/ns3simulator.py similarity index 92% rename from src/nepi/resources/linux/ns3/simulator.py rename to src/nepi/resources/linux/ns3/ns3simulator.py index 82d4bca6..4c605f72 100644 --- a/src/nepi/resources/linux/ns3/simulator.py +++ b/src/nepi/resources/linux/ns3/ns3simulator.py @@ -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: diff --git a/src/nepi/resources/ns3/ns3simulator.py b/src/nepi/resources/ns3/ns3simulator.py index 4013a3cd..1c557e7b 100644 --- a/src/nepi/resources/ns3/ns3simulator.py +++ b/src/nepi/resources/ns3/ns3simulator.py @@ -18,7 +18,6 @@ # Author: Alina Quereilhac class NS3Simulator(object): - @property def client(self): return self._client diff --git a/src/nepi/resources/ns3/rm_creator.py b/src/nepi/resources/ns3/resource_manager_generator.py similarity index 94% rename from src/nepi/resources/ns3/rm_creator.py rename to src/nepi/resources/ns3/resource_manager_generator.py index 786f4571..c01180ed 100644 --- a/src/nepi/resources/ns3/rm_creator.py +++ b/src/nepi/resources/ns3/resource_manager_generator.py @@ -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). \ replace("", attributes). \ replace("", traces). \ + replace("", base_class_import). \ + replace("", base_class). \ replace("", short_rtype) fname = uncamm_rtype.replace('ns3::', ''). \ diff --git a/src/nepi/resources/ns3/templates/rm_template.txt b/src/nepi/resources/ns3/templates/resource_manager_template.txt similarity index 87% rename from src/nepi/resources/ns3/templates/rm_template.txt rename to src/nepi/resources/ns3/templates/resource_manager_template.txt index 08447c8f..c3b6a582 100644 --- a/src/nepi/resources/ns3/templates/rm_template.txt +++ b/src/nepi/resources/ns3/templates/resource_manager_template.txt @@ -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 + @clsinit_copy -class (NS3Base): +class (): _rtype = "" @classmethod @@ -37,10 +37,3 @@ class (NS3Base): def __init__(self, ec, guid): super(, self).__init__(ec, guid) self._home = "-%s" % self.guid - # TODO! - self._version = None - - @property - def version(self): - return self._version - diff --git a/test/resources/ns3/linuxns3client.py b/test/resources/linux/ns3/ns3client.py similarity index 99% rename from test/resources/ns3/linuxns3client.py rename to test/resources/linux/ns3/ns3client.py index 207e4378..404fc5d2 100644 --- a/test/resources/ns3/linuxns3client.py +++ b/test/resources/linux/ns3/ns3client.py @@ -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