Allow specification of working directory via constructor argument and related cleanup
Change-Id: Ifc73371c920d1d4e47b1fa04e57de5aebd2a6b40
This commit is contained in:
1 parent
c32a07be3e
commit
a169f5702e
5 files changed
+18
-9
No files matched your search
@@ -80,7 +80,7 @@ def run():
|
||||
|
||||
# Start ping server
|
||||
info("Starting pings...\n")
|
||||
pingserver_log = open("/tmp/minindn/c/ndnpingserver.log", "w")
|
||||
pingserver_log = open("{}/c/ndnpingserver.log".format(ndn.workDir), "w")
|
||||
getPopen(ndn.net["c"], "ndnpingserver {}".format(PREFIX), stdout=pingserver_log,\
|
||||
stderr=pingserver_log)
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ if __name__ == '__main__':
|
||||
time.sleep(300)
|
||||
|
||||
totalUpdates = int(host.cmd('grep -r Update {}/*/psync.logs | wc -l'
|
||||
.format(args.workDir)))
|
||||
.format(ndn.workDir)))
|
||||
|
||||
expectedUpdates = (maxUpdatesPerUserPrefixPerNode *
|
||||
len(ndn.net.hosts) * (len(ndn.net.hosts) - 1) * numUserPrefixesPerNode)
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
"""
|
||||
This example demonstrates the functionality of the Traffic generator. It consists of a traffic
|
||||
server and client. The server will listen for interest on the prefix specified in the server
|
||||
configuration file. The client will send a designated number of interests to the server and
|
||||
configuration file. The client will send a designated number of interests to the server and
|
||||
get the data back.
|
||||
More details on traffic generator here: https://github.com/named-data/ndn-traffic-generator
|
||||
"""
|
||||
@@ -91,8 +91,8 @@ if __name__ == '__main__':
|
||||
# lets make node "a" as a traffic-server node, and node "c" as a traffic-client node
|
||||
server = ndn.net['a']
|
||||
client = ndn.net['c']
|
||||
serverConf = '{}/{}/server-conf'.format(ndn.args.workDir, server.name)
|
||||
clientConf = '{}/{}/client-conf'.format(ndn.args.workDir, client.name)
|
||||
serverConf = '{}/{}/server-conf'.format(ndn.workDir, server.name)
|
||||
clientConf = '{}/{}/client-conf'.format(ndn.workDir, client.name)
|
||||
|
||||
copyExistentFile(server, possibleServerConfPath, serverConf)
|
||||
copyExistentFile(server, possibleClientConfPath, clientConf)
|
||||
|
||||
+6
-2
@@ -55,7 +55,7 @@ class Minindn(object):
|
||||
resultDir = None
|
||||
|
||||
def __init__(self, parser=argparse.ArgumentParser(), topo=None, topoFile=None, noTopo=False,
|
||||
link=TCLink, **mininetParams):
|
||||
link=TCLink, workDir=None, **mininetParams):
|
||||
"""
|
||||
Create MiniNDN object
|
||||
:param parser: Parent parser of Mini-NDN parser
|
||||
@@ -70,7 +70,11 @@ class Minindn(object):
|
||||
self.parser = Minindn.parseArgs(parser)
|
||||
self.args = self.parser.parse_args()
|
||||
|
||||
Minindn.workDir = os.path.abspath(self.args.workDir)
|
||||
if not workDir:
|
||||
Minindn.workDir = os.path.abspath(self.args.workDir)
|
||||
else:
|
||||
Minindn.workDir = os.path.abspath(workDir)
|
||||
|
||||
Minindn.resultDir = self.args.resultDir
|
||||
|
||||
if not topoFile:
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
# along with Mini-NDN, e.g., in COPYING.md file.
|
||||
# If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import argparse
|
||||
import sys
|
||||
import configparser
|
||||
@@ -36,7 +37,7 @@ from minindn.minindn import Minindn
|
||||
|
||||
class MinindnWifi(Minindn):
|
||||
""" Class for handling default args, Mininet-wifi object and home directories """
|
||||
def __init__(self, parser=argparse.ArgumentParser(), topo=None, topoFile=None, noTopo=False, link=WirelessLink, **mininetParams):
|
||||
def __init__(self, parser=argparse.ArgumentParser(), topo=None, topoFile=None, noTopo=False, link=WirelessLink, workDir=None, **mininetParams):
|
||||
"""Create Mini-NDN-Wifi object
|
||||
parser: Parent parser of Mini-NDN-Wifi parser (use to specify experiment arguments)
|
||||
topo: Mininet topo object (optional)
|
||||
@@ -48,7 +49,11 @@ class MinindnWifi(Minindn):
|
||||
self.parser = self.parseArgs(parser)
|
||||
self.args = self.parser.parse_args()
|
||||
|
||||
Minindn.workDir = self.args.workDir
|
||||
if not workDir:
|
||||
Minindn.workDir = os.path.abspath(self.args.workDir)
|
||||
else:
|
||||
Minindn.workDir = os.path.abspath(workDir)
|
||||
|
||||
Minindn.resultDir = self.args.resultDir
|
||||
|
||||
self.topoFile = None
|
||||
|
||||
Reference in new issue
Block a user