From: Alina Quereilhac Date: Thu, 30 Jan 2014 18:44:26 +0000 (+0100) Subject: re-arrenging ns-3 classes X-Git-Tag: nepi-3.1.0~120^2~20 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=e0dd7383a1241e77ba32efa6e6a3cec573b3757d;p=nepi.git re-arrenging ns-3 classes --- diff --git a/src/nepi/resources/ns3/linuxns3client.py b/src/nepi/resources/linux/ns3/ns3client.py similarity index 100% rename from src/nepi/resources/ns3/linuxns3client.py rename to src/nepi/resources/linux/ns3/ns3client.py diff --git a/src/nepi/resources/ns3/ns3_base.py b/src/nepi/resources/ns3/ns3base.py similarity index 100% rename from src/nepi/resources/ns3/ns3_base.py rename to src/nepi/resources/ns3/ns3base.py diff --git a/src/nepi/resources/ns3/ns3client.py b/src/nepi/resources/ns3/ns3client.py index b2257803..e3a203bd 100644 --- a/src/nepi/resources/ns3/ns3client.py +++ b/src/nepi/resources/ns3/ns3client.py @@ -17,14 +17,6 @@ # # Author: Alina Quereilhac -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 index 00000000..4013a3cd --- /dev/null +++ b/src/nepi/resources/ns3/ns3simulator.py @@ -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 . +# +# Author: Alina Quereilhac + +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() + diff --git a/src/nepi/resources/ns3/rm_creator.py b/src/nepi/resources/ns3/rm_creator.py index 3b3cb8d0..786f4571 100644 --- a/src/nepi/resources/ns3/rm_creator.py +++ b/src/nepi/resources/ns3/rm_creator.py @@ -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) \ @@ -159,4 +160,4 @@ def template_traces(ns3, tid): return traces if __name__ == "__main__": - dump_ns3_rms() + create_ns3_rms() diff --git a/src/nepi/resources/ns3/templates/attribute_template.txt b/src/nepi/resources/ns3/templates/attribute_template.txt index f34daa30..651496e5 100644 --- a/src/nepi/resources/ns3/templates/attribute_template.txt +++ b/src/nepi/resources/ns3/templates/attribute_template.txt @@ -1,7 +1,7 @@ = Attribute("", "", type = , - default = , + default = "", allowed = , range = , flags = )