Beispiel #1
0
    def __init__(self,
                 str_sub_type='',
                 obj_xmlnode_runtime=None,
                 obj_device_parent=None):
        CLogger.__init__(self)
        # for the device tree
        self.str_sub_type = str_sub_type
        self.obj_device_parent = obj_device_parent
        self.obj_xmlnode_runtime = obj_xmlnode_runtime
        self.dict_device_children = {}
        self.str_device_type = None
        self.str_device_name = None
        # the interfaces
        self.obj_rest_agent = None
        # for runtime
        self.obj_logger = None
        self.on_data = {}
        self.mon_data = {}
        # flags
        self.b_valid = True  # this flag is set to True by default. It will be set to false
        # when a error appeared, which means the device is not OK to
        # be used
        self.b_build = False  # device built
        self.b_logger_set = False  # logger set or not
        self.b_interface_set = False  # interfaces set or not
        CDevice.list_type.append(self.str_device_type)

        self.uri = ''
Beispiel #2
0
 def __init__(self, str_task_file=''):
     CLogger.__init__(self)
     self.b_valid = True
     self.str_error_code = ''
     self.b_quit = False
     self.b_status_change = False
     self.b_completed = False
     self.b_still_case_queued = True
     self._b_create_junit_report = True
     self.str_task_file = os.path.basename(str_task_file)
     self.str_report_file = ''
     self.str_work_directory = 'temp'
     self.str_task_file_full_path = str_task_file
     self.str_platform = 'unknown'
     self.str_hwimo_version = ''
     self.str_hwimo_ip = ''
     self.str_stack = ''
     self.str_test_alias = ''
     self.str_test_title = ''
     self.str_task_ID = os.path.basename(self.str_task_file).split('_')[0]
     self.dict_thread_case_running = {}
     self.dict_case_result_error_code = {}
     self.int_case_retry_threshold = 2
     self.list_xmlnode_case = []
     if str_task_file == '':
         raise Exception(
             'No task file is found when initialize a test executor.')
     self.test_run_id = None
     self.testrail = None
     self.dict_pqa_tr_id = {}
     self.__parse_info__()
Beispiel #3
0
 def __init__(self, str_task_file=''):
     CLogger.__init__(self)
     self.b_valid = True
     self.str_error_code = ''
     self.b_quit = False
     self.b_status_change = False
     self.b_completed = False
     self.b_still_case_queued = True
     self._b_create_junit_report = True
     self.str_task_file = os.path.basename(str_task_file)
     self.str_report_file = ''
     self.str_work_directory = 'temp'
     self.str_task_file_full_path = str_task_file
     self.str_platform = 'unknown'
     self.str_hwimo_version = ''
     self.str_hwimo_ip = ''
     self.str_stack = ''
     self.str_test_alias = ''
     self.str_test_title = ''
     self.str_task_ID = os.path.basename(self.str_task_file).split('_')[0]
     self.dict_thread_case_running = {}
     self.dict_case_result_error_code = {}
     self.int_case_retry_threshold = 2
     self.list_xmlnode_case = []
     if str_task_file == '':
         raise Exception('No task file is found when initialize a test executor.')
     self.test_run_id = None
     self.testrail = None
     self.dict_pqa_tr_id = {}
     self.__parse_info__()
Beispiel #4
0
    def __init__(self, para, str_session_log = None):
        # for event log
        CLogger.__init__(self)
        # for console output logging
        CLogTool.__init__(self, str_session_log)
        
        self._int_port = para[0]-1
        self._int_baudrate = para[1]        
        self.h_serial = Serial()
        server_platform=platform.system()

        # support cygwin;
        # in cygwin, we should use device name instead of port number in int;
        # in Windows and Linux, pyserial could get device by port number automatically;
        # However in cygwin it will try to find /dev/com32 if we only provide 32.
        if 'CYGWIN' in server_platform:
            self.h_serial.port = '/dev/ttyS%d' % self._int_port
        elif server_platform == 'Windows':
            self.h_serial.port = self._int_port
        elif server_platform == 'Linux':
            self.h_serial.port = '/dev/ttyr%02x' % self._int_port
        else:
            raise Exception('Unsupported platform: %s' % server_platform)

        self.h_serial.baudrate = self._int_baudrate
        
        # used in read_until_strings, indicating which string is found
        self._int_match_index = 0
        # indicate if the port is connected
        self._b_connected = False
        # size of searching buffer
        self._int_buffer_size = 1024*4
        # the output buffer, will be cleared in flush_buffer
        self._str_buffer = ''
        # Lock for buffer change
        self._lock_buffer = Lock()
        # used by user to request caching the output
        self._b_caching = False
        # used by user to cache the output
        self._str_cache = ''
        # used to prevent the port from being disconnected when reading data
        self._lock_connection = Lock()
        # used to track if user is checking the buffer
        self._b_checking = False
        
        # used to terminate reading thread
        self.event_thread_quit = Event()
        self.event_thread_quit.clear()

        self.thread_read = Thread(target=self.read_data)
        self.thread_read.setDaemon(True)
        self.thread_read.start()
Beispiel #5
0
    def __init__(self, para, str_session_log=None):
        # for event log
        CLogger.__init__(self)
        # for console output logging
        CLogTool.__init__(self, str_session_log)

        self._int_port = para[0] - 1
        self._int_baudrate = para[1]
        self.h_serial = Serial()
        server_platform = platform.system()

        # support cygwin;
        # in cygwin, we should use device name instead of port number in int;
        # in Windows and Linux, pyserial could get device by port number automatically;
        # However in cygwin it will try to find /dev/com32 if we only provide 32.
        if 'CYGWIN' in server_platform:
            self.h_serial.port = '/dev/ttyS%d' % self._int_port
        elif server_platform == 'Windows':
            self.h_serial.port = self._int_port
        elif server_platform == 'Linux':
            self.h_serial.port = '/dev/ttyr%02x' % self._int_port
        else:
            raise Exception('Unsupported platform: %s' % server_platform)

        self.h_serial.baudrate = self._int_baudrate

        # used in read_until_strings, indicating which string is found
        self._int_match_index = 0
        # indicate if the port is connected
        self._b_connected = False
        # size of searching buffer
        self._int_buffer_size = 1024 * 4
        # the output buffer, will be cleared in flush_buffer
        self._str_buffer = ''
        # Lock for buffer change
        self._lock_buffer = Lock()
        # used by user to request caching the output
        self._b_caching = False
        # used by user to cache the output
        self._str_cache = ''
        # used to prevent the port from being disconnected when reading data
        self._lock_connection = Lock()
        # used to track if user is checking the buffer
        self._b_checking = False

        # used to terminate reading thread
        self.event_thread_quit = Event()
        self.event_thread_quit.clear()

        self.thread_read = Thread(target=self.read_data)
        self.thread_read.setDaemon(True)
        self.thread_read.start()
Beispiel #6
0
 def __init__(self, verify=False, 
              username='', 
              password='', 
              session_log=True,
              headers={'Content-Type': 'application/json'}):
     CLogger.__init__(self)
     self.str_session_log = ''
     self.b_verify = verify
     self.username = username
     self.password = password
     self.b_session_log = session_log
     self.http_header = headers
     try:
         urllib3.disable_warnings()
     except:
         pass
Beispiel #7
0
 def __init__(self, str_config_file):
     CLogger.__init__(self)
     self.str_config_file = str_config_file
     self.lock_update_file = Lock()
     self.event_quit = Event()
     self.event_quit.clear()
     self.str_source_folder = ''
     self.lst_enclosure = []
     self.lst_apc = []
     self.dict_runtime = {}
     self.dict_system_type = {}
     self.dict_branch_name_platform = {}
     self.dict_email = {}
     self.et_root = None
     if self.refresh() != 0:
         self.log('ERROR', 'Failed to parse config file')
         sys.exit()
Beispiel #8
0
 def __init__(self, str_config_file):
     CLogger.__init__(self)
     self.str_config_file = str_config_file
     self.lock_update_file = Lock()
     self.event_quit = Event()
     self.event_quit.clear()
     self.str_source_folder = ''
     self.lst_enclosure = []
     self.lst_apc = []
     self.dict_runtime = {}
     self.dict_system_type = {}
     self.dict_branch_name_platform = {}
     self.dict_email = {}
     self.et_root = None
     if self.refresh() != 0:
         self.log('ERROR', 'Failed to parse config file')
         sys.exit()
Beispiel #9
0
 def __init__(self,
              verify=False,
              username='',
              password='',
              session_log=True,
              headers={'Content-Type': 'application/json'}):
     CLogger.__init__(self)
     self.str_session_log = ''
     self.b_verify = verify
     self.username = username
     self.password = password
     self.b_session_log = session_log
     self.http_header = headers
     try:
         urllib3.disable_warnings()
     except:
         pass
Beispiel #10
0
    def __init__(self, ip, username, password, str_session_log=None, port=22):

        # Log tool init
        CLogger.__init__(self)
        CLogTool.__init__(self, str_session_log)

        # ssh host IP
        self.ip = ip
        self.port = port
        # ssh host username
        self.username = username
        # ssh host password
        self.password = password
        # ssh connection
        self.h_ssh = paramiko.SSHClient()
        self.h_chan = None

        # used in read_until_strings, indicating which string is found
        self._int_match_index = 0
        # indicate if the port is connected
        self._b_connected = False
        # size of recv buffer
        self._int_buffer_size = 1024 * 4
        # the recv buffer used for searching, will be cleared in flush_buffer
        self._str_buffer = ''
        # Lock for buffer change
        self._lock_buffer = Lock()
        # used by user to request caching the output
        self._b_caching = False
        # used by user to cache the output
        self._str_cache = ''
        # used to keep cache
        self._lock_cache = Lock()
        # used to prevent the port from being disconnected when reading data
        self._lock_connection = Lock()
        # used to track if user is checking the buffer
        self._b_checking = False

        # used to terminate reading thread
        self.event_thread_quit = Event()
        self.event_thread_quit.clear()
        self.thread_read = Thread(target=self.read_data)

        self.thread_read.setDaemon(True)
        self.thread_read.start()
Beispiel #11
0
    def __init__(self, ip, username, password, str_session_log=None, port=22):

        # Log tool init
        CLogger.__init__(self)
        CLogTool.__init__(self, str_session_log)

        # ssh host IP
        self.ip = ip
        self.port = port
        # ssh host username
        self.username = username
        # ssh host password
        self.password = password
        # ssh connection
        self.h_ssh = paramiko.SSHClient()
        self.h_chan = None

        # used in read_until_strings, indicating which string is found
        self._int_match_index = 0
        # indicate if the port is connected
        self._b_connected = False
        # size of recv buffer
        self._int_buffer_size = 1024 * 4
        # the recv buffer used for searching, will be cleared in flush_buffer
        self._str_buffer = ''
        # Lock for buffer change
        self._lock_buffer = Lock()
        # used by user to request caching the output
        self._b_caching = False
        # used by user to cache the output
        self._str_cache = ''
        # used to keep cache
        self._lock_cache = Lock()
        # used to prevent the port from being disconnected when reading data
        self._lock_connection = Lock()
        # used to track if user is checking the buffer
        self._b_checking = False

        # used to terminate reading thread
        self.event_thread_quit = Event()
        self.event_thread_quit.clear()
        self.thread_read = Thread(target=self.read_data)

        self.thread_read.setDaemon(True)
        self.thread_read.start()
Beispiel #12
0
    def __init__(self, str_ip='', port=None, str_user='******', str_password='******'):
        CLogger.__init__(self)
        if CIOL.b_ipmitool_warning:
            print CIOL.str_ipmitool_warning
            CIOL.b_ipmitool_warning
        self.str_ip = str_ip
        # RMCP+ udp port used by BMC; by default it is 623.
        if port:
            self.port = port
        else:
            self.port = 623

        self.str_user = str_user
        self.str_password = str_password
        self.str_param = ''
        self.set_ipmitool_command_prefix()
        self.b_create_session_log = True
        self.str_session_log = ''
Beispiel #13
0
    def __init__(self, int_port = None, int_baudrate = 115200, str_session_log = ''):
        CLogger.__init__(self)
        self.int_port = int_port - 1
        self.int_baudrate = int_baudrate
        self.b_logging = False
        self.str_logging_info = ''
        self.h_serial = Serial()
        self.h_serial.port = self.int_port
        self.h_serial.baudrate = self.int_baudrate
        self.str_default_raw_session_log_file = 'log_com_' + str(int_port) + '_raw.txt'
        if str_session_log == '':
            self.str_raw_log_file_name = self.str_default_raw_session_log_file
        else:
            self.str_raw_log_file_name =  str_session_log.split('.txt')[0] + '_raw.txt'
        self.b_raw_logging = False
        self.str_default_formatted_session_log_file = 'log_com_' + str(int_port) + '_formatted.txt'
        if str_session_log == '':
            self.str_formatted_log_file_name = self.str_default_formatted_session_log_file
        else:
            self.str_formatted_log_file_name = str_session_log.split('.txt')[0] + '_formatted.txt'
        self.b_formatted_logging = False
        self.b_wait = False                  #Indicate whether is waiting for a string 
        self.str_buffer = ''
        self.lock_buffer = Lock()
        self.lock_disconnect = Lock() # used to prevent the port from being disconnected when reading data
        self.int_match_index = 0
        
        self.event_thread_quit = Event()      # used to terminate reading thread
        self.event_thread_quit.clear()
        self.thread_read = Thread(target = self.read_data)
        self.thread_read.setDaemon(True)
        self.thread_read.start()
        '''
        #Not used for the moment.
        self.VT100 = VT100()
#        self.thread_VT100_screen = Thread(target = self.print_vt100_screen)
#        self.thread_VT100_screen.setDaemon(True)
#        self.thread_VT100_screen.start()
#        self.thread_receive_input_from_file = Thread(target = self.receive_input_from_file)
#        self.thread_receive_input_from_file.setDaemon(True)
#        self.thread_receive_input_from_file.start()
        
        '''
        self.connect()
Beispiel #14
0
 def __init__(self, addr = None, obj_logger = None):
     CLogger.__init__(self)
     self.set_logger(obj_logger)
     # if the IP is not set, use the server ip
     if addr == None:
         import socket
         str_server_name = socket.getfqdn(socket.gethostname())
         list_server_ip = socket.gethostbyname_ex(str_server_name)
         str_server_ip = '' 
         for each_ip in list_server_ip[2]:
             if each_ip.startswith('10.'):
                 str_server_ip = each_ip
                 break
         if str_server_ip == '':
             print '[ERROR] Cannot find IP of 10.xxx.xxx.xxx. Exit'
             import sys
             sys.exit()
         addr = (str_server_ip, 8003)
     SimpleJSONRPCServer.__init__(self, addr, logRequests = False)
     self.instance_register()
     self._deactivate_socket()
Beispiel #15
0
    def __init__(self,
                 str_ip='',
                 port=None,
                 str_user='******',
                 str_password='******'):
        CLogger.__init__(self)
        if CIOL.b_ipmitool_warning:
            print CIOL.str_ipmitool_warning
            CIOL.b_ipmitool_warning
        self.str_ip = str_ip
        # RMCP+ udp port used by BMC; by default it is 623.
        if port:
            self.port = port
        else:
            self.port = 623

        self.str_user = str_user
        self.str_password = str_password
        self.str_param = ''
        self.set_ipmitool_command_prefix()
        self.b_create_session_log = True
        self.str_session_log = ''
Beispiel #16
0
    def __init__(self, connect_type, para, session_log = ''):
        CLogger.__init__(self)

        connect_type = connect_type.lower()

        if connect_type == self.TELNET:
            if type(para[1]) != int:
                para[1] = int(para[1], 10)

            self._connection = CTelnet(para, session_log)
            self.int_port = para[1]

        elif connect_type == self.SERIAL:
            if type(para[0]) != int:
                para[0] = int(para[0], 10)
            if type(para[1]) != int:
                para[1] = int(para[1], 10)

            self._connection = CSerial(para, session_log)
            self.int_port = para[0] - 1

        else:
            raise Exception('Interface type not supported(%s)' % connect_type)
Beispiel #17
0
    def __init__(self, connect_type, para, session_log=''):
        CLogger.__init__(self)

        connect_type = connect_type.lower()

        if connect_type == self.TELNET:
            if type(para[1]) != int:
                para[1] = int(para[1], 10)

            self._connection = CTelnet(para, session_log)
            self.int_port = para[1]

        elif connect_type == self.SERIAL:
            if type(para[0]) != int:
                para[0] = int(para[0], 10)
            if type(para[1]) != int:
                para[1] = int(para[1], 10)

            self._connection = CSerial(para, session_log)
            self.int_port = para[0] - 1

        else:
            raise Exception('Interface type not supported(%s)' % connect_type)
Beispiel #18
0
    def __init__(self, para, str_session_log=None):
        CLogger.__init__(self)
        CLogTool.__init__(self, str_session_log)

        # telnet ip address
        self._str_ip_addr = para[0]
        # telnet port
        self._int_port = int(para[1])
        # telnet connection
        self.h_telnet = telnetlib.Telnet()

        # used in read_until_strings, indicating which string is found
        self._int_match_index = 0
        # indicate if the port is connected
        self._b_connected = False
        # size of recv buffer
        self._int_buffer_size = 1024 * 4
        # the recv buffer used for searching, will be cleared in flush_buffer
        self._str_buffer = ''
        # Lock for buffer change
        self._lock_buffer = Lock()
        # used by user to request caching the output
        self._b_caching = False
        # used by user to cache the output
        self._str_cache = ''
        # used to prevent the port from being disconnected when reading data
        self._lock_connection = Lock()
        # used to track if user is checking the buffer
        self._b_checking = False

        # used to terminate reading thread
        self.event_thread_quit = Event()
        self.event_thread_quit.clear()
        self.thread_read = Thread(target=self.read_data)

        self.thread_read.setDaemon(True)
        self.thread_read.start()
Beispiel #19
0
 def __init__(self):
     CLogger.__init__(self)
     self.reset()
Beispiel #20
0
 def __init__(self, str_ip = None, int_port = _DEFAULT_ATRAGON_PORT):
     CLogger.__init__(self)
     self.obj_json_client = None
     self.str_ip = str_ip
     self.int_port = int_port
Beispiel #21
0
 def __init__(self, obj_logger = None):
     CLogger.__init__(self)
     self.set_logger(obj_logger)
     result, info = self._parse_task_file('T000003', 'megatron')
     self.dict_result = info
Beispiel #22
0
 def __init__(self):
     CLogger.__init__(self)
     self.obj_logger = None
     self.dict_interface = {}
Beispiel #23
0
 def __init__(self):
     CLogger.__init__(self)
     self.obj_logger = None
     self.dict_interface = {}
Beispiel #24
0
 def __init__(self, str_ip=None, int_port=_DEFAULT_ATRAGON_PORT):
     CLogger.__init__(self)
     self.obj_json_client = None
     self.str_ip = str_ip
     self.int_port = int_port