Esempio n. 1
0
 def complete_print(strDesc):
     print('    Set  %-13s for engine "%s" completed...' %
           ('"%s"' % strDesc, self._host))
     s.msg_out(
         self.message_output,
         '    Set  %-13s for engine "%s" completed.\n' %
         ('"%s"' % strDesc, self._host))
     time.sleep(0.25)
Esempio n. 2
0
   def show_conmgr_status(self):
       string_to_show = self._executeCMD('conmgr status')
       s.msg_out(
           self.message_output, '''
 Conmgr Status:
 -------------------------------------------
 %s
 -------------------------------------------
             \n''' % string_to_show)
Esempio n. 3
0
 def get_result(self):
     status_complete = self.get_status()
     if status_complete == 'Complete':
         self._get_result_file()
         s.msg_out(self.message_output, '  5. Finish getting test result.')
     else:
         print('Test not complete, please retry later.')
         s.msg_out(self.message_output,
                   '  ***5. Test not complete, please retry later.')
         sys.exit()
Esempio n. 4
0
 def _reset_engine(ip_engine):
     s.msg_out(obj_msg_out,
               '    6.x Start resetting engine %s.\n' % ip_engine)
     objEngine = Action(ip_engine, telnet_port, passwd, FTP_port, version,
                        solid_args)
     objEngine.reset_engine()
     time.sleep(1)
     s.msg_out(obj_msg_out,
               '    6.x Finish resetting engine %s.\n' % ip_engine)
     del objEngine
     s.chg_light_to_red(obj_light_FTP, instance_light_FTP)
Esempio n. 5
0
 def change_FW(self, strFWFile):
     connFTP = self._ftp()
     time.sleep(0.25)
     connFTP.PutFile('/mbflash', './', 'fwimage', strFWFile)
     print('FW upgrade completed for {}, waiting for reboot...'.format(
         self._host))
     s.msg_out(self.message_output,
               '  0.1 Finish changing firmware, Rebooting...\n')
     s.chg_light_to_red(self.obj_light_telnet, self.instance_light_telnet)
     s.chg_light_to_red(self.obj_light_FTP, self.instance_light_FTP)
     s.sand_glass(45, self.message_output)
Esempio n. 6
0
   def show_mirror_and_mappting(self):
       string_to_show = ''
       string_to_show = string_to_show + self._executeCMD('mirror') + '\n'
       string_to_show = string_to_show + self._executeCMD('map') + '\n'
       s.msg_out(
           self.message_output, '''
 Mirror and Mapping:
 -------------------------------------------
 %s
 -------------------------------------------
             \n''' % string_to_show)
Esempio n. 7
0
    def sync_time(self):
        if self.AHStatus:
            print("Engine '%s' is at AH status(AH Code %d)" %
                  (self.host, self.AHStatus))
            return

        def _exct_cmd():
            t = s.TimeNow()

            def complete_print(strDesc):
                print('    Set  %-13s for engine "%s" completed...' %
                      ('"%s"' % strDesc, self._host))
                s.msg_out(
                    self.message_output,
                    '    Set  %-13s for engine "%s" completed.\n' %
                    ('"%s"' % strDesc, self._host))
                time.sleep(0.25)

            try:
                # Set Time
                if self._TN_Conn.exctCMD('rtc set time %d %d %d' %
                                         (t.h(), t.mi(), t.s())):
                    complete_print('Time')
                    # Set Date
                    if self._TN_Conn.exctCMD('rtc set date %d %d %d' %
                                             (t.y() - 2000, t.mo(), t.d())):
                        complete_print('Date')
                        # Set Day of the Week
                        DoW = t.wd() + 2
                        if DoW == 8:
                            DoW - 7
                        if self._TN_Conn.exctCMD('rtc set day %d' % DoW):
                            complete_print('Day_of_Week')
                return True
            except Exception as E:
                s.ShowErr(
                    self.__class__.__name__,
                    sys._getframe().f_code.co_name,
                    'rtc set faild for engine "{}" with error:'.format(
                        self._host), '"{}"'.format(E))
                sys.exit()

        if self._TN_Conn:
            if _exct_cmd():
                print('\nSetting time for engine "%s" completed...' %
                      self._host)
                s.msg_out(
                    self.message_output,
                    '  0.9 Finish syncing time of engine with system.\n')
            else:
                print('\nSetting time for engine "%s" failed!!!' % self._host)
                s.msg_out(self.message_output,
                          '  ***0.9 Syncing time of engine failed.\n')
Esempio n. 8
0
def start_test(version, solid_args):
    obj_msg_out = solid_args[0]
    obj_light_FTP = solid_args[3]
    instance_light_FTP = solid_args[4]

    objEngine = Action(ip_engine_initiator, telnet_port, passwd, FTP_port,
                       version, solid_args)
    s.msg_out(obj_msg_out, '  3. Start testing.\n')
    objEngine.start_test()
    time.sleep(1)
    del objEngine
    s.chg_light_to_red(obj_light_FTP, instance_light_FTP)
Esempio n. 9
0
    def register_drives(self):
        # generate command
        lst_cmd = []
        lst_port = ['a1', 'a2', 'b1', 'b2']
        for i in range(len(lst_port)):
            str_cmd = 'conmgr drive add S %d %s 2%d00-006022-112250 0' % (
                i + 1, lst_port[i], i + 1)
            lst_cmd.append(str_cmd)

        # start registing
        self._register(lst_cmd)
        s.msg_out(self.message_output,
                  '  2.1 Finish registering initiators.\n')
Esempio n. 10
0
def get_test_result(version, solid_args):
    obj_msg_out = solid_args[0]
    # obj_light_telnet = solid_args[1]
    # instance_light_telnet = solid_args[2]
    obj_light_FTP = solid_args[3]
    instance_light_FTP = solid_args[4]
    objEngine = Action(ip_engine_initiator, telnet_port, passwd, FTP_port,
                       version, solid_args)
    s.msg_out(obj_msg_out, '  5. Start getting result.\n')
    objEngine.get_result()
    time.sleep(1)
    del objEngine
    s.chg_light_to_red(obj_light_FTP, instance_light_FTP)
Esempio n. 11
0
def config_target(IP_Entered, license, version, speed, solid_args):
    obj_msg_out = solid_args[0]
    obj_light_telnet = solid_args[1]
    instance_light_telnet = solid_args[2]
    # obj_light_FTP = solid_args[3]
    # instance_light_FTP = solid_args[4]

    _config_universal('target', IP_Entered, license, version, speed,
                      solid_args)

    objEngine = Action(ip_engine_target, telnet_port, passwd, FTP_port,
                       version, solid_args)

    s.msg_out(obj_msg_out, '  1.1 Start creating fake drives.\n')
    objEngine.create_fake_drive()

    s.msg_out(obj_msg_out, '  1.2 Start creating mirror and mapping.\n')
    objEngine.mirror_and_mapping()

    s.msg_out(obj_msg_out, '  1.3 Start registering initiators.\n')
    objEngine.register_initiator()

    # show info -- mirror and mapping.
    objEngine.show_mirror_and_mappting()

    # show info -- conmgr status.
    objEngine.show_conmgr_status()

    s.msg_out(obj_msg_out, '  1. Finish configuring target engine.\n')
    time.sleep(0.25)
    del objEngine
    s.chg_light_to_red(obj_light_telnet, instance_light_telnet)
Esempio n. 12
0
 def change_UID(self, mode):
     if mode == 'target':
         str_uid = '0000006022112250'
     elif mode == 'initiator':
         str_uid = '0000006022112251'
     else:
         s.msg_out(self.message_output, 'failed ,check')
         sys.exit()
     uid_cmd = 'uid %s' % str_uid
     output = self._executeCMD(uid_cmd)
     if 'take full effect!' in output:
         self._executeCMD('boot')
     s.msg_out(self.message_output,
               '  0.4 Finish changeing UID, Rebooting...\n')
     s.sand_glass(20, self.message_output)
Esempio n. 13
0
 def start_test(self):
     self._put_params()
     status_ready = self.get_status()
     print('---------got status', status_ready)
     if status_ready == 'Ready':
         s.msg_out(self.message_output, '    3.1 Ready to start testing.\n')
         self._put_command()
         time.sleep(2)
         status_started = self.get_status()
         if status_started == 'Testing':
             s.msg_out(self.message_output, '    3.2 Testing started.\n')
             print('Testing started.')
         else:
             print('Please check "command".')
     else:
         print('Please check "params".')
Esempio n. 14
0
 def factory_default(self):
     if self._TN_Conn.go_to_main_menu():
         self._telnet_write('f')
         self._TN_Conn.Connection.read_until(s.encode_utf8('Reset'),
                                             timeout=1)
         time.sleep(0.25)
         self._telnet_write('y')
         self._telnet_write('y')
         self._telnet_write('y')
         print('Finish restoring factory default, Reboot...\n')
         s.msg_out(
             self.message_output,
             '  0.2 Finish restoring factory default, Rebooting...\n')
         s.chg_light_to_red(self.obj_light_telnet,
                            self.instance_light_telnet)
         s.sand_glass(20, self.message_output)
Esempio n. 15
0
    def shutdown_behaviour(self):
        if self._TN_Conn.go_to_main_menu():
            self._telnet_write('6')
            # output6 = self._TN_Conn.Connection.read_until(s.encode_utf8('seen'), timeout = 1)
            # print('------------------shutdown',output6)
            for i in range(2):
                output = self._TN_Conn.Connection.read_until(
                    s.encode_utf8('seen'), timeout=1)
                # print('------------------shutdown',output)
                if s.encode_utf8(
                        'stay up if no storage or engines seen') in output:
                    break
                else:
                    self._telnet_write('x')

            s.msg_out(self.message_output,
                      '  0.6 Finish setting shutdown behaviour.\n')
        else:
            s.msg_out(self.message_output,
                      '  ***0.6 Setting shutdown behaviour failed!')
            sys.exit()
Esempio n. 16
0
    def change_FC_speed(self, port, speed):
        def _change_speed(port, speed):
            self._telnet_write(port)
            self._telnet_write('s')
            self._telnet_write(speed)
            # output = self._TN_Conn.Connection.read_until(s.encode_utf8('Default: Point'), timeout = 1)
            # print('--------output after speed set\n',output)
            self._telnet_write('\r')

        if self._TN_Conn.go_to_main_menu():
            self._telnet_write('6')
            # output6 = self._TN_Conn.Connection.read_until(s.encode_utf8('Default: Point'), timeout = 1)
            # print('--------output after write 6\n',output6)
            if port == 'all':
                lst_port = ['a', 'b', 'c', 'd']
                for port in lst_port:
                    _change_speed(port, speed)
                    time.sleep(0.25)
                    s.msg_out(self.message_output,
                              '      Port %s Changed.\n' % port)
            else:
                _change_speed(port, speed)
            self._telnet_write('\r')
            s.msg_out(self.message_output,
                      '  0.8 Finish changing speed of FC ports.\n')
        else:
            s.msg_out(self.message_output,
                      '  ***0.8 Changing speed of FC ports failed!\n')
            sys.exit()
Esempio n. 17
0
def reset_all_engines(license, version, speed, solid_args):
    obj_msg_out = solid_args[0]
    # obj_light_telnet = solid_args[1]
    # instance_light_telnet = solid_args[2]
    obj_light_FTP = solid_args[3]
    instance_light_FTP = solid_args[4]

    def _reset_engine(ip_engine):
        s.msg_out(obj_msg_out,
                  '    6.x Start resetting engine %s.\n' % ip_engine)
        objEngine = Action(ip_engine, telnet_port, passwd, FTP_port, version,
                           solid_args)
        objEngine.reset_engine()
        time.sleep(1)
        s.msg_out(obj_msg_out,
                  '    6.x Finish resetting engine %s.\n' % ip_engine)
        del objEngine
        s.chg_light_to_red(obj_light_FTP, instance_light_FTP)

    s.msg_out(obj_msg_out, '  6. Start resetting all engines.\n')
    _reset_engine(ip_engine_target)
    _reset_engine(ip_engine_initiator)
Esempio n. 18
0
def config_initiator(IP_Entered, license, version, speed, solid_args):
    obj_msg_out = solid_args[0]
    obj_light_telnet = solid_args[1]
    instance_light_telnet = solid_args[2]
    # obj_light_FTP = solid_args[3]
    # instance_light_FTP = solid_args[4]

    _config_universal('initiator', IP_Entered, license, version, speed,
                      solid_args)

    objEngine = Action(ip_engine_initiator, telnet_port, passwd, FTP_port,
                       version, solid_args)
    s.msg_out(obj_msg_out, '  2.1 Start registering drives.\n')
    objEngine.register_drives()

    # show info -- conmgr status.
    objEngine.show_conmgr_status()

    s.msg_out(obj_msg_out, '  2. Finish configuring initiator engine.\n')
    time.sleep(0.25)
    del objEngine
    s.chg_light_to_red(obj_light_telnet, instance_light_telnet)
Esempio n. 19
0
    def install_license(self, string_license):
        if string_license:
            lst_lsc = re.split(' |,|;', string_license)
            if len(lst_lsc) != 3:
                s.msg_out(self.message_output,
                          '    ***0.5 Please check license code\n')
                sys.exit()
            lst_lsc_id = [3, 5, 6]
            lst_lsc_desc = ['Firmware Downgrade', 'IO Generater', 'Fake Drive']
            flag_success = 0
            for i in range(len(lst_lsc)):
                # Command: "license install 3 xxxxxxx"
                cmd_lsc_install = 'license install %s %s' % (str(
                    lst_lsc_id[i]), lst_lsc[i])
                output = self._executeCMD(cmd_lsc_install)
                if 'installed' in output:
                    s.msg_out(
                        self.message_output,
                        '    0.5.%d %s License install successful on %s.\n' %
                        (i + 1, lst_lsc_desc[i], self._host))
                    flag_success = flag_success + 1
                else:
                    s.msg_out(
                        self.message_output,
                        '    ***0.5.%d %s License isntall failed!\n' %
                        (i + 1, lst_lsc_desc[i]))
            if flag_success == 3:
                s.msg_out(
                    self.message_output,
                    '  0.5 Finish installing licenses on %s.\n' % self._host)

        else:
            s.msg_out(
                self.message_output,
                '  ***0.5 License install failed on %s.\n    Please check license code\n'
                % self._host)
            sys.exit()
Esempio n. 20
0
    def change_ip_address(self, new_ip_address):
        s.msg_out(
            self.message_output,
            '    0.3.1 changing IP from "%s" to "%s" ...\n' %
            (self._host, new_ip_address))
        print('changing IP from "%s" to "%s" ...\n' %
              (self._host, new_ip_address))
        if self._TN_Conn.go_to_main_menu():
            self._telnet_write('6')
            self._TN_Conn.Connection.read_until(s.encode_utf8('interface'),
                                                timeout=2)
            time.sleep(0.2)
            self._telnet_write('e')
            self._telnet_write('a')
            self._TN_Conn.Connection.read_until(s.encode_utf8('new IP'),
                                                timeout=2)
            self._telnet_write(new_ip_address)
            self._telnet_write('\r')
            self._telnet_write('\r')

            self._TN_Conn.Connection.read_until(
                '<Enter> = done'.encode(encoding="utf-8"), timeout=2)
            self._telnet_write('\r')
            # try:
            self._TN_Conn.Connection.read_until(s.encode_utf8('Coredump'),
                                                timeout=2)
            self._TN_Conn.Connection.write(s.encode_utf8('b'))
            self._TN_Conn.Connection.read_until(s.encode_utf8('Reboot'),
                                                timeout=1)
            time.sleep(0.4)
            self._TN_Conn.Connection.write(s.encode_utf8('y'))

            s.msg_out(self.message_output,
                      '  0.3 Finish changing IP address, Rebooting...\n')
            s.chg_light_to_red(self.obj_light_telnet,
                               self.instance_light_telnet)
            s.sand_glass(20, self.message_output)
Esempio n. 21
0
 def _telnet_connect(self):
     s.msg_out(self.message_output,
               '0. Telnet Connecting to %s ...\n' % self._host)
     self._TN_Conn = conn.HAAPConn(self._host, self._TNport, self._password,
                                   self._timeout)
     self._TN_Connect_Status = self._TN_Conn.get_connection_status()
     if self._TN_Connect_Status:
         s.msg_out(self.message_output,
                   '0. Telnet Connected to %s.\n' % self._host)
         s.chg_light_to_green(self.obj_light_telnet,
                              self.instance_light_telnet)
     else:
         s.msg_out(self.message_output,
                   '0. Telnet Connect to %s Failed!!!\n' % self._host)
Esempio n. 22
0
 def reset_engine(self):
     self._executeCMD('uid 0')
     s.msg_out(
         self.message_output,
         '    6.1 Finish restoring UID Setting for engine %s.' % self._host)
     s.msg_out(
         self.message_output,
         '    6.2 Start Setting engine to factory default for engine %s.' %
         self._host)
     self.factory_default()
     s.msg_out(
         self.message_output,
         '    6.2 Finish Setting engine to factory default for engine %s.' %
         self._host)
Esempio n. 23
0
 def _ftp(self):
     s.msg_out(self.message_output,
               '0. FTP Connecting to %s ...\n' % self._host)
     if self._FTP_Conn:
         connFTP = self._FTP_Conn
     else:
         self._FTP_connect()
         connFTP = self._FTP_Conn
     if connFTP:
         s.msg_out(self.message_output,
                   '0. FTP Connected to %s.\n' % self._host)
         s.chg_light_to_green(self.obj_light_FTP, self.instance_light_FTP)
     else:
         s.msg_out(self.message_output,
                   '0. FTP Connect to %s Failed!!!\n' % self._host)
     return connFTP
Esempio n. 24
0
    def change_FC_mode(self, port, port_mode):
        def _change_mode(port, port_mode):
            time.sleep(0.25)
            tmp = self._TN_Conn.Connection.read_until(
                s.encode_utf8('<Enter> = done'), timeout=1)
            self._telnet_write(port)
            time.sleep(0.25)
            output = self._TN_Conn.Connection.read_until(
                s.encode_utf8('Default: Point-to-point mode'), timeout=1)
            print('--------output after write port\n', output)
            if port_mode == 'loop':
                if not s.encode_utf8(
                        'Current: Arbitrated loop mode') in output:
                    self._telnet_write('l')
                    # o  = self._TN_Conn.Connection.read_until(s.encode_utf8('Default: Point'), timeout = 1)
                    # print('----------\n',o)
            elif port_mode == 'point':
                if not s.encode_utf8('Current: Point-to-point mode') in output:
                    self._telnet_write('l')
                    # o = self._TN_Conn.Connection.read_until(s.encode_utf8('Default: Point'), timeout = 1)
                    # print('----------\n',o)
            self._telnet_write('\r')
            # self._TN_Conn.Connection.read_until(s.encode_utf8('Default: Point'), timeout = 1)

        if self._TN_Conn.go_to_main_menu():
            time.sleep(0.25)
            self._telnet_write('6')
            # output6 = self._TN_Conn.Connection.read_until(s.encode_utf8('Default: Point'), timeout = 1)
            # print('--------output after write 6\n',output6)
            if port == 'all':
                lst_port = ['a', 'b', 'c', 'd']
                for port in lst_port:
                    _change_mode(port, port_mode)

                    s.msg_out(self.message_output,
                              '      Port %s Changed.\n' % port)
            else:
                _change_mode(port, port_mode)
            self._telnet_write('\r')
            self._telnet_write('\r')
            s.msg_out(self.message_output,
                      '  0.7 Finish changing mode of FC ports.\n')
        else:
            s.msg_out(self.message_output,
                      '  ***0.7 Changing mode of FC ports failed.\n')
            sys.exit()
Esempio n. 25
0
def config_target(IP_Entered, license, version, speed, solid_args):
    obj_msg_out = solid_args[0]

    s.msg_out(obj_msg_out, '0. Connecting to Engine %s \n' % IP_Entered)
    objEngine = Action(IP_Entered, telnet_port, passwd, FTP_port, version,
                       solid_args)
    s.msg_out(obj_msg_out, '0. Connected to Engine %s \n' % IP_Entered)

    s.msg_out(obj_msg_out, '  1. Start to Change FW\n')
    objEngine.change_FW(firmware_file_name)
    s.msg_out(obj_msg_out, '  1. Change FW Done, Rebooting...\n')
    s.sand_glass(45)

    solid_args[0].insert('insert', '  2. Start Restor Factory Default\n')
    objEngine.factory_default()
    solid_args[0].insert('insert',
                         '  2. Restor Factory Default Done, Rebooting...\n')
    sandglass(20)

    solid_args[0].insert('insert', '  3. Start Changing IP Address\n')
    objEngine.change_ip_address(ip_engine_target)
    solid_args[0].insert('insert',
                         '  3. Change IP Address Done, Rebooting...\n')
    sandglass(15)

    del objEngine

    s.msg_out(obj_msg_out, '0. Connecting to Engine %s' % ip_engine_target)
    objEngine = Action(ip_engine_target, telnet_port, passwd, FTP_port,
                       version, solid_args)

    s.msg_out(obj_msg_out, '  4. Start to Install License\n')
    objEngine.install_license(license)
    s.msg_out(obj_msg_out, '  4. Install License Done\n')
Esempio n. 26
0
def _config_universal(mode, IP_Entered, license, version, speed, solid_args):
    obj_msg_out = solid_args[0]
    obj_light_telnet = solid_args[1]
    instance_light_telnet = solid_args[2]
    obj_light_FTP = solid_args[3]
    instance_light_FTP = solid_args[4]

    if mode == 'target':
        ip_engine = ip_engine_target
    elif mode == 'initiator':
        ip_engine = ip_engine_initiator

    objEngine = Action(IP_Entered, telnet_port, passwd, FTP_port, version,
                       solid_args)
    s.msg_out(obj_msg_out, '  0.1 Start changing FW.\n')
    # objEngine.change_FW(firmware_file_name)
    s.msg_out(obj_msg_out, '  0.1 Finish changing FW, Rebooting...\n')
    del objEngine

    objEngine = Action(IP_Entered, telnet_port, passwd, FTP_port, version,
                       solid_args)
    s.msg_out(obj_msg_out, '  0.2 Start restoring factory default.\n')
    objEngine.factory_default()
    time.sleep(0.25)
    del objEngine

    objEngine = Action(IP_Entered, telnet_port, passwd, FTP_port, version,
                       solid_args)
    solid_args[0].insert('insert', '  0.3 Start changing IP address.\n')
    objEngine.change_ip_address(ip_engine)
    time.sleep(0.25)
    del objEngine

    objEngine = Action(ip_engine, telnet_port, passwd, FTP_port, version,
                       solid_args)
    s.msg_out(obj_msg_out, '  0.4 Start changing UID.\n')
    objEngine.change_UID(mode)
    time.sleep(0.25)
    del objEngine

    objEngine = Action(ip_engine, telnet_port, passwd, FTP_port, version,
                       solid_args)

    s.msg_out(obj_msg_out, '  0.5 Start setting shutdown behaviour.\n')
    objEngine.shutdown_behaviour()

    s.msg_out(obj_msg_out, '  0.6 Start changing mode of FC ports.\n')
    objEngine.change_FC_mode('all', 'loop')

    s.msg_out(obj_msg_out, '  0.7 Start changing speed of FC ports.\n')
    objEngine.change_FC_speed('all', speed)

    s.msg_out(obj_msg_out, '  0.8 Start installing license.\n')
    objEngine.install_license(license)

    s.msg_out(obj_msg_out, '  0.9 Start syncing time of engine with system.\n')
    objEngine.sync_time()

    time.sleep(0.25)
    del objEngine
    time.sleep(1)
Esempio n. 27
0
 def mirror_and_mapping(self):
     self._executeCMD('mirror create 2044')
     self._executeCMD('map auto on')
     self._executeCMD('map 0 33281')
     s.msg_out(self.message_output,
               '  1.2 Finish creating mirror and mapping.\n')
Esempio n. 28
0
 def create_fake_drive(self):
     self._executeCMD('fake on')
     s.msg_out(self.message_output, '  1.1 Finish creating fake drives.\n')