Ashlesh Gawande | f5f304b | 2016-06-16 16:42:41 -0500 | [diff] [blame] | 1 | # -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | # |
Alexander Lane | 9944cf5 | 2018-05-17 12:16:50 -0500 | [diff] [blame] | 3 | # Copyright (C) 2015-2018, The University of Memphis, |
Ashlesh Gawande | f5f304b | 2016-06-16 16:42:41 -0500 | [diff] [blame] | 4 | # Arizona Board of Regents, |
| 5 | # Regents of the University of California. |
| 6 | # |
| 7 | # This file is part of Mini-NDN. |
| 8 | # See AUTHORS.md for a complete list of Mini-NDN authors and contributors. |
| 9 | # |
| 10 | # Mini-NDN is free software: you can redistribute it and/or modify |
| 11 | # it under the terms of the GNU General Public License as published by |
| 12 | # the Free Software Foundation, either version 3 of the License, or |
| 13 | # (at your option) any later version. |
| 14 | # |
| 15 | # Mini-NDN is distributed in the hope that it will be useful, |
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | # GNU General Public License for more details. |
| 19 | # |
| 20 | # You should have received a copy of the GNU General Public License |
| 21 | # along with Mini-NDN, e.g., in COPYING.md file. |
| 22 | # If not, see <http://www.gnu.org/licenses/>. |
| 23 | |
| 24 | from subprocess import call |
Ashlesh Gawande | 95789cc | 2017-02-27 12:38:04 -0600 | [diff] [blame] | 25 | from mininet.cli import CLI |
| 26 | import sys |
Alexander Lane | 4fa8881 | 2018-05-23 12:56:52 -0500 | [diff] [blame] | 27 | from os.path import isfile |
Ashlesh Gawande | f5f304b | 2016-06-16 16:42:41 -0500 | [diff] [blame] | 28 | |
| 29 | sshbase = [ 'ssh', '-q', '-t', '-i/home/mininet/.ssh/id_rsa' ] |
| 30 | scpbase = [ 'scp', '-i', '/home/mininet/.ssh/id_rsa' ] |
| 31 | devnull = open('/dev/null', 'w') |
| 32 | |
| 33 | def ssh(login, cmd): |
| 34 | rcmd = sshbase + [login, cmd] |
| 35 | call(rcmd, stdout=devnull, stderr=devnull) |
| 36 | |
| 37 | def scp(*args): |
| 38 | tmp = [] |
| 39 | for arg in args: |
| 40 | tmp.append(arg) |
| 41 | rcmd = scpbase + tmp |
| 42 | call(rcmd, stdout=devnull, stderr=devnull) |
Ashlesh Gawande | 95789cc | 2017-02-27 12:38:04 -0600 | [diff] [blame] | 43 | |
Alexander Lane | 4fa8881 | 2018-05-23 12:56:52 -0500 | [diff] [blame] | 44 | def copyExistentFile(node, fileList, destination): |
| 45 | for file in fileList: |
| 46 | if isfile(file): |
| 47 | node.cmd("cp {} {}".format(file, destination)) |
| 48 | break |
| 49 | if not isfile(destination): |
| 50 | fileName = destination.split("/")[-1] |
| 51 | raise IOError("{} not found in expected directory.".format(fileName)) |
| 52 | |
| 53 | |
Ashlesh Gawande | 95789cc | 2017-02-27 12:38:04 -0600 | [diff] [blame] | 54 | class MiniNDNCLI(CLI): |
| 55 | prompt = 'mini-ndn> ' |
| 56 | def __init__(self, mininet, stdin=sys.stdin, script=None): |
| 57 | CLI.__init__(self, mininet, stdin=sys.stdin, script=None) |
Ashlesh Gawande | 27b5e1b | 2018-08-06 17:47:15 -0500 | [diff] [blame] | 58 | |
| 59 | class ProgramOptions: |
| 60 | def __init__(self): |
| 61 | self.ctime = 60 |
| 62 | self.experimentName = None |
| 63 | self.nFaces = 3 |
| 64 | self.templateFile = "minindn.conf" |
| 65 | self.routingType = "link-state" |
| 66 | self.isNlsrEnabled = True |
| 67 | self.isCliEnabled = True |
| 68 | self.nlsrSecurity = False |
| 69 | self.nPings = 300 |
| 70 | self.testbed = False |
| 71 | self.workDir = "/tmp/minindn" |
| 72 | self.resultDir = None |
| 73 | self.pctTraffic = 1.0 |
| 74 | self.cluster = None |
| 75 | self.servers = None |
| 76 | self.guided = None |
| 77 | self.placer = None |
| 78 | self.tunnelType = None |
| 79 | self.faceType = "udp" |
| 80 | self.arguments = None |
| 81 | self.csSize = 65536 |
| 82 | self.strategy = "best-route" |