summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-05-14 06:14:08 +0300
committerYaroslav Brustinov <ybrustin@cisco.com>2016-05-14 06:14:08 +0300
commitccd12c1e16cd5a8b575fd531444a6415d250b8ed (patch)
tree85be3e77d13bc5015578fe30c224a05685da8963
parenta08c4df1da6892a515fb5e4ddce4a7d525d8fcee (diff)
add master daemon to package, little fixes to update method
-rwxr-xr-xlinux_dpdk/ws_main.py1
-rwxr-xr-xscripts/automation/regression/stateful_tests/trex_general_test.py10
-rwxr-xr-xscripts/master_daemon.py15
3 files changed, 10 insertions, 16 deletions
diff --git a/linux_dpdk/ws_main.py b/linux_dpdk/ws_main.py
index b1e1f6bd..4c2d3c51 100755
--- a/linux_dpdk/ws_main.py
+++ b/linux_dpdk/ws_main.py
@@ -853,6 +853,7 @@ files_list=[
'dpdk_setup_ports.py',
'doc_process.py',
'trex_daemon_server',
+ 'master_daemon.py',
'trex-console',
'daemon_server'
];
diff --git a/scripts/automation/regression/stateful_tests/trex_general_test.py b/scripts/automation/regression/stateful_tests/trex_general_test.py
index ac2d7b89..38e97597 100755
--- a/scripts/automation/regression/stateful_tests/trex_general_test.py
+++ b/scripts/automation/regression/stateful_tests/trex_general_test.py
@@ -274,17 +274,9 @@ class CTRexGeneral_Test(unittest.TestCase):
# raise
def unzip_client_package(self):
- client_pkg_files = glob('%s/trex_client*.tar.gz' % CTRexScenario.scripts_path)
- if not len(client_pkg_files):
- raise Exception('Could not find client package')
- if len(client_pkg_files) > 1:
- raise Exception('Found more than one client packages')
- client_pkg_name = os.path.basename(client_pkg_files[0])
if not os.path.exists('%s/trex_client' % CTRexScenario.scripts_path):
print('\nUnzipping package')
- return_code, _, stderr = misc_methods.run_command("sh -ec 'cd %s; tar -xzf %s'" % (CTRexScenario.scripts_path, client_pkg_name))
- if return_code:
- raise Exception('Could not untar the client package: %s' % stderr)
+ CTRexScenario.trex.master_daemon.unpack_client()
else:
print('\nClient package is untarred')
diff --git a/scripts/master_daemon.py b/scripts/master_daemon.py
index caaaf5fc..aaa3f22c 100755
--- a/scripts/master_daemon.py
+++ b/scripts/master_daemon.py
@@ -5,7 +5,6 @@ import argparse
import socket
from time import time, sleep
import subprocess, shlex, shutil, multiprocessing
-from distutils.dir_util import mkpath
from glob import glob
import logging
logging.basicConfig(level = logging.FATAL) # keep quiet
@@ -74,16 +73,16 @@ def update_trex(package_path = 'http://trex-tgn.cisco.com/trex/release/latest'):
if os.path.exists(bu_dir):
shutil.rmtree(bu_dir)
shutil.move(cur_dir, bu_dir)
- mkpath(cur_dir)
+ os.makedirs(cur_dir)
except Exception as e:
raise Exception('Could not make backup of previous directory. Err: %s' % e)
# getting new package
if package_path.startswith('http://'):
file_name = package_path.split('/')[-1]
- ret_code, stdout, stderr = run_command('wget %s -O %s' % (package_path, cur_dir), timeout = 600)
+ ret_code, stdout, stderr = run_command('wget %s -O %s' % (package_path, os.path.join(cur_dir, file_name)), timeout = 600)
elif os.path.normpath(package_path).startswith('/auto/') and package_path.endswith('.tar.gz'):
file_name = os.path.basename(package_path)
- ret_code, stdout, stderr = run_command('rsync -cL %s %s' % (package_path, cur_dir), timeout = 300)
+ ret_code, stdout, stderr = run_command('rsync -Lc %s %s' % (package_path, os.path.join(cur_dir, file_name)), timeout = 300)
else:
raise Exception('package_path should be http address or path starting with /auto')
if ret_code:
@@ -133,7 +132,7 @@ def unpack_client():
else:
shutil.rmtree(client_new_path)
# unpacking
- ret_code, stdout, stderr = run_command('tar -mxzf %s -C %s' % (client_pkg_files[0], args.trex_dir))
+ ret_code, stdout, stderr = run_command('tar -xzf %s -C %s' % (os.path.join(args.trex_dir, client_pkg_files[0]), args.trex_dir))
if ret_code:
raise Exception('Could not untar the client package: %s' % stderr)
return True
@@ -270,10 +269,12 @@ parser.add_argument('action', choices=action_funcs.keys(),
parser.usage = None
args = parser.parse_args()
-if not os.path.exists(args.trex_dir):
- raise Exception("Given path '%s' does not exist" % args.trex_dir)
if not _check_path_under_current_or_temp(args.trex_dir):
raise Exception('Only allowed to use path under /tmp or current directory')
+if os.path.isfile(args.trex_dir):
+ raise Exception('Given path is a file')
+if not os.path.exists(args.trex_dir):
+ os.makedirs(args.trex_dir)
trex_daemon_path = os.path.join(args.trex_dir, 'trex_daemon_server')
action_funcs[args.action]()