sys.path.remove(text_tables_path)
import re
import termios
-import getpass
# The PCI device class for ETHERNET devices
ETHERNET_CLASS = "0200"
do_arg_actions()
if __name__ == "__main__":
- if getpass.getuser() != 'root':
+ if os.getuid() != 0:
print('Please run this program as root/with sudo')
exit(1)
main()
import traceback
from collections import defaultdict, OrderedDict
from distutils.util import strtobool
-import getpass
import subprocess
import platform
def main ():
try:
- if getpass.getuser() != 'root':
+ if os.getuid() != 0:
raise DpdkSetup('Please run this program as root/with sudo')
process_options ()
#!/usr/bin/python
import os
import sys
-import getpass
import shutil
import multiprocessing
import logging
### Main ###
-if getpass.getuser() != 'root':
+if os.getuid() != 0:
fail('Please run this program as root/with sudo')
pid = os.getpid()
-ret = os.system('taskset -pc 0 %s' % pid)
+ret, out, err = run_command('taskset -pc 0 %s' % pid)
if ret:
- fail('Could not set self affinity to core zero.')
+ fail('Could not set self affinity to core zero. Result: %s' % [ret, out, err])
daemon_actions = OrderedDict([('start', 'start the daemon'),
('stop', 'exit the daemon process'),
args.daemon_type = args.daemon_type or 'master_daemon'
stl_rpc_proxy_dir = os.path.join(args.trex_dir, 'automation', 'trex_control_plane', 'stl', 'examples')
-stl_rpc_proxy = SingletonDaemon('Stateless RPC proxy', 'trex_stl_rpc_proxy', args.stl_rpc_proxy_port, 'sudo -u nobody %s rpc_proxy_server.py' % sys.executable, stl_rpc_proxy_dir)
+stl_rpc_proxy = SingletonDaemon('Stateless RPC proxy', 'trex_stl_rpc_proxy', args.stl_rpc_proxy_port, "su -s /bin/bash -c '%s rpc_proxy_server.py' nobody" % sys.executable, stl_rpc_proxy_dir)
trex_daemon_server = SingletonDaemon('TRex daemon server', 'trex_daemon_server', args.trex_daemon_port, '%s trex_daemon_server start' % sys.executable, args.trex_dir)
master_daemon = SingletonDaemon('Master daemon', 'trex_master_daemon', args.master_port, start_master_daemon) # add ourself for easier check if running, kill etc.
#!/usr/bin/python
-import os, sys, getpass
+import os, sys
import tempfile
import time
import subprocess, shlex
print(msg)
sys.exit(-1)
-if getpass.getuser() != 'root':
+if os.getuid() != 0:
fail('Please run this program as root/with sudo')
pwd = os.path.abspath(os.path.dirname(__file__))
return
server_path = os.path.join(pwd, 'automation', 'trex_control_plane', 'stl', 'services', 'scapy_server')
with tempfile.TemporaryFile() as stdout_file:
- subprocess.Popen(shlex.split('sudo -u nobody %s scapy_zmq_server.py -s %s' % (sys.executable, args.daemon_port)), stdout = stdout_file,
+ subprocess.Popen(shlex.split("su -s /bin/bash -c '%s scapy_zmq_server.py -s %s' nobody" % (sys.executable, args.daemon_port)), stdout = stdout_file,
stderr = subprocess.STDOUT, cwd = server_path, close_fds = True, universal_newlines = True)
ret = progress(is_running, 'Starting Scapy server', 'Scapy server is started', 'Scapy server failed to run')
if ret:
formatter_class = RawTextHelpFormatter,
)
- parser.add_argument('-p', '--port', type = int, default = 4507, metavar="PORT", dest="daemon_port",
- help="Select tcp port on which Scapy server listens.\nDefault port is 4507.", action="store")
+ parser.add_argument('-p', '--port', type = int, default = 4507, metavar = 'PORT', dest = 'daemon_port',
+ help='Select tcp port on which Scapy server will listen.\nDefault is 4507.')
+ #parser.add_argument('-c', '--core', type = int, default = 0,
+ # help='Core number to set affinity.\nAdvised to set on free core or TRex master thread core\nDefault is 0.')
parser.add_argument('action', choices=action_funcs.keys(),
action='store', help=actions_help)
parser.usage = None
#!/usr/bin/python
-import os, sys, getpass
+import os, sys
import tempfile
from time import time, sleep
import subprocess, shlex, multiprocessing
print(msg)
sys.exit(-1)
-if getpass.getuser() != 'root':
+if os.getuid() != 0:
fail('Please run this program as root/with sudo')
sys.path.append(os.path.join('automation', 'trex_control_plane', 'server'))