re-arrenging ns-3 classes
authorAlina Quereilhac <alina.quereilhac@inria.fr>
Thu, 30 Jan 2014 18:44:26 +0000 (19:44 +0100)
committerAlina Quereilhac <alina.quereilhac@inria.fr>
Thu, 30 Jan 2014 18:44:26 +0000 (19:44 +0100)
src/nepi/resources/linux/ns3/ns3client.py [moved from src/nepi/resources/ns3/linuxns3client.py with 100% similarity]
src/nepi/resources/ns3/ns3base.py [moved from src/nepi/resources/ns3/ns3_base.py with 100% similarity]
src/nepi/resources/ns3/ns3client.py
src/nepi/resources/ns3/ns3simulator.py [new file with mode: 0644]
src/nepi/resources/ns3/rm_creator.py
src/nepi/resources/ns3/templates/attribute_template.txt

index b225780..e3a203b 100644 (file)
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
-import base64
-import cPickle
-import errno
-import socket
-from optparse import OptionParser, SUPPRESS_HELP
-
-from ns3server import NS3WrapperMessage
-
 class NS3Client(object):
     """ Common Interface for NS3 client classes """
     def __init__(self):
diff --git a/src/nepi/resources/ns3/ns3simulator.py b/src/nepi/resources/ns3/ns3simulator.py
new file mode 100644 (file)
index 0000000..4013a3c
--- /dev/null
@@ -0,0 +1,49 @@
+#
+#    NEPI, a framework to manage network experiments
+#    Copyright (C) 2014 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: Alina Quereilhac <alina.quereilhac@inria.fr>
+
+class NS3Simulator(object):
+
+    @property
+    def client(self):
+        return self._client
+
+    def create(self, clazzname, *args):
+        return self.client.create(clazzname, *args)
+
+    def invoke(self, uuid, operation, *args):
+        return self.client.invoke(uuid, operation, *args)
+
+    def set(self, uuid, name, value):
+        return self.client.set(uuid, name, value)
+
+    def get(self, uuid, name):
+        return self.client.get(uuid, name)
+
+    def trace(self, *args):
+        return self.client.trace(*args)
+
+    def start(self):
+        return self.client.start()
+
+    def stop(self, time = None):
+        return self.client.stop(time)
+
+    def shutdown(self):
+        return self.client.shutdown()
+
index 3b3cb8d..786f457 100644 (file)
@@ -22,7 +22,7 @@ from nepi.resources.ns3.ns3wrapper import load_ns3_module
 import os
 import re
 
-def dump_ns3_rms():
+def create_ns3_rms():
     ns3 = load_ns3_module()
 
     type_id = ns3.TypeId()
@@ -52,6 +52,7 @@ def dump_ns3_rms():
 
         rtype = tid.GetName()
         category = tid.GetGroupName()
+
         classname = rtype.replace("ns3::", "NS3").replace("::","")
         uncamm_rtype = re.sub('([a-z])([A-Z])', r'\1-\2', rtype).lower()
         short_rtype = uncamm_rtype.replace("::","-")
@@ -72,11 +73,11 @@ def dump_ns3_rms():
                 replace('::', ''). \
                 replace("-","_").lower() + ".py"
 
-        f = open(os.path.join(d, fname), "w")
-        print os.path.join(d, fname)
-        print template
+        #f = open(os.path.join(d, "classes", fname), "w")
+        #print os.path.join(d, fname)
+        #print template
         #f.write(template)
-        f.close()
+        #f.close()
 
 def template_attributes(ns3, tid): 
     d = os.path.dirname(os.path.realpath(__file__))
@@ -99,7 +100,7 @@ def template_attributes(ns3, tid):
 
         attr_name = attr_info.name
         checker = attr_info.checker
-        attr_help = attr_info.help
+        attr_help = attr_info.help.replace('"', '\\"').replace("'", "\\'")
         value = attr_info.initialValue
         attr_value = value.SerializeToString(checker)
         attr_allowed = "None"
@@ -149,7 +150,7 @@ def template_traces(ns3, tid):
     for i in xrange(trace_count):
         trace_info = tid.GetTraceSource(i)
         trace_name = trace_info.name
-        trace_help = trace_info.help
+        trace_help = trace_info.help.replace('"', '\\"').replace("'", "\\'")
 
         trace_id = trace_name.lower()
         traces += template.replace("<TRACE_ID>", trace_id) \
@@ -159,4 +160,4 @@ def template_traces(ns3, tid):
     return traces
 
 if __name__ == "__main__":
-    dump_ns3_rms()
+    create_ns3_rms()
index f34daa3..651496e 100644 (file)
@@ -1,7 +1,7 @@
         <ATTR_ID> = Attribute("<ATTR_NAME>",
             "<ATTR_HELP>",
             type = <ATTR_TYPE>,
-            default = <ATTR_DEFAULT>, 
+            default = "<ATTR_DEFAULT>",  
             allowed = <ATTR_ALLOWED>,
             range = <ATTR_RANGE>,    
             flags = <ATTR_FLAGS>)