Ejemplo n.º 1
0
    def change_ip_address(self, new_ip_address):
        if self._TN_Conn.go_to_main_menu():
            #         self._TN_Conn.change_ip_address(new_ip_address)

            # def change_ip_address(self, new_ip_address):
            #     if self.go_to_main_menu():
            self._TN_Conn.Connection.write('6'.encode(encoding="utf-8"))
            self._TN_Conn.Connection.read_until(s.encode_utf8('interface'),
                                                timeout=2)
            time.sleep(0.2)
            self._telnet_write('e', 0.1)
            self._telnet_write('a', 0.1)
            self._TN_Conn.Connection.read_until(s.encode_utf8('new IP'),
                                                timeout=2)
            time.sleep(0.2)
            self._TN_Conn.Connection.write(s.encode_utf8('new_ip_address'))
            self._TN_Conn.Connection.write('\r'.encode(encoding="utf-8"))
            time.sleep(0.2)
            self._TN_Conn.Connection.write(s.encode_utf8('\r'))
            time.sleep(0.2)
            self._TN_Conn.Connection.read_until(
                '<Enter> = done'.encode(encoding="utf-8"), timeout=2)
            self._TN_Conn.Connection.write('\r'.encode(encoding="utf-8"))
            time.sleep(0.5)
            # 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'))
            print('Rebooting engine, Please waiting...\n')
            s.sand_glass(45, self.message_output)
Ejemplo n.º 2
0
 def go_to_CLI(self):
     self.Connection.write(b'\r')
     output = self.Connection.read_until(self._strCLIPrompt, timeout=1)
     if self._strCLIPrompt in output:
         return True
     elif self._strMainPrompt in output:
         self.Connection.write(s.encode_utf8('7'))
         str7Output = self.Connection.read_until(self._strCLIPrompt,
                                                 timeout=1)
         if self._strCLIPrompt in str7Output:
             return True
         elif self._strCLIConflict in str7Output:
             self.Connection.write(s.encode_utf8('y'))
             strConfirmCLI = self.Connection.read_until(self._strCLIPrompt,
                                                        timeout=1)
             if self._strCLIPrompt in strConfirmCLI:
                 return True
Ejemplo n.º 3
0
 def is_AH(self):
     strPrompt = self.exctCMD('')
     if strPrompt:
         if self._strAHPrompt in s.encode_utf8(strPrompt):
             strVPD = self.exctCMD('vpd')
             reAHNum = re.compile(r'Alert:\s*(\d*)')
             objReAHNum = reAHNum.search(strVPD)
             return int(objReAHNum.group(1))
         else:
             return 0
Ejemplo n.º 4
0
 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')
Ejemplo n.º 5
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()
Ejemplo n.º 6
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)
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
 def _telnet_write(self, str, time_out=0.5):
     str_encoded = s.encode_utf8(str)
     self._TN_Conn.Connection.write(str_encoded)
     time.sleep(time_out)