1#!/router/bin/python
2
3import os
4import sys
5import subprocess
6import misc_methods
7import re
8import signal
9import time
10from CProgressDisp import TimedProgressBar
11from stateful_tests.tests_exceptions import TRexInUseError
12import datetime
13import copy
14import outer_packages
15import yaml
16
17class CTRexScenario:
18    modes            = set() # list of modes of this setup: loopback, virtual etc.
19    server_logs      = False
20    is_test_list     = False
21    is_init          = False
22    is_stl_init      = False
23    trex_crashed     = False
24    configuration    = None
25    trex             = None
26    stl_trex         = None
27    stl_ports_map    = None
28    stl_init_error   = None
29    router           = None
30    router_cfg       = None
31    daemon_log_lines = 0
32    setup_name       = None
33    setup_dir        = None
34    router_image     = None
35    trex_version     = None
36    scripts_path     = None
37    benchmark        = None
38    report_dir       = 'reports'
39    # logger         = None
40    test_types       = {'functional_tests': [], 'stateful_tests': [], 'stateless_tests': []}
41    pkg_updated      = False
42    GAManager        = None
43    no_daemon        = False
44    debug_image      = False
45    test             = None
46    json_verbose     = False
47    elk              = None
48    elk_info         = None
49    global_cfg       = None
50
51def copy_elk_info ():
52   assert(CTRexScenario.elk_info)
53   d = copy.deepcopy(CTRexScenario.elk_info);
54
55   timestamp = datetime.datetime.now() - datetime.timedelta(hours=2); # Jerusalem timeZone, Kibana does not have feature to change timezone
56   d['timestamp']=timestamp.strftime("%Y-%m-%d %H:%M:%S")
57   return(d)
58
59global_cfg = 'cfg/global_regression_cfg.yaml'
60if not os.path.exists(global_cfg):
61    raise Exception('Global configuration file %s is missing' % global_cfg)
62with open(global_cfg) as f:
63    CTRexScenario.global_cfg = yaml.safe_load(f.read())
64
65
66
67
68