@@ -694,9 +694,16 @@ def _initialize(self, *args: Any, **kwargs: Any) -> None:
694694 try :
695695 super ()._initialize (* args , ** kwargs )
696696 except TcpConnectionException as e :
697- vm_logs = self ._collect_logs_using_platform ()
698- if vm_logs :
699- self .log .info (f"Collected information using platform:\n { vm_logs } " )
697+ try :
698+ vm_logs = self ._collect_logs_using_non_ssh_executor ()
699+ if vm_logs :
700+ self .log .info (
701+ f"Collected information using non-ssh executor:\n { vm_logs } "
702+ )
703+ except Exception as log_error :
704+ self .log .debug (
705+ f"Failed to collect logs using non-ssh executor: { log_error } "
706+ )
700707 raise e
701708
702709 def get_working_path (self ) -> PurePath :
@@ -741,31 +748,22 @@ def check_sudo_password_required(self) -> None:
741748 raise RequireUserPasswordException ("Reset password failed" )
742749 self ._check_password_and_store_prompt ()
743750
744- def _collect_logs_using_platform (self ) -> Optional [str ]:
751+ def _collect_logs_using_non_ssh_executor (self ) -> Optional [str ]:
745752 """
746- Collects information using the RunCommand feature.
753+ Collects information using the NonSshExecutor feature.
747754 This is used when the connection to the node is not stable.
748755 """
749- from lisa .features import RunCommand
750-
751- if self .features .is_supported (RunCommand ):
752- run_command = self .features [RunCommand ]
753- commands = [
754- "echo 'Executing: ip addr show'" ,
755- "ip addr show" ,
756- "echo 'Executing: ip link show'" ,
757- "ip link show" ,
758- "echo 'Executing: systemctl status NetworkManager --no-pager --plain'" ,
759- "systemctl status NetworkManager --no-pager --plain" ,
760- "echo 'Executing: systemctl status network --no-pager --plain'" ,
761- "systemctl status network --no-pager --plain" ,
762- "echo 'Executing: systemctl status systemd-networkd --no-pager --plain'" ,
763- "systemctl status systemd-networkd --no-pager --plain" ,
764- "echo 'Executing: ping -c 3 -n 8.8.8.8'" ,
765- "ping -c 3 -n 8.8.8.8" ,
766- ]
767- out = run_command .execute (commands = commands )
768- return out
756+ from lisa .features import NonSshExecutor
757+
758+ if self .features .is_supported (NonSshExecutor ):
759+ non_ssh_executor = self .features [NonSshExecutor ]
760+ out = non_ssh_executor .execute ()
761+ return "\n " .join (out )
762+ else :
763+ self .log .debug (
764+ f"NonSshExecutor is not supported on { self .name } , "
765+ "cannot collect logs using non-ssh executor."
766+ )
769767 return None
770768
771769 def _check_password_and_store_prompt (self ) -> None :
@@ -815,29 +813,7 @@ def _check_bash_prompt(self) -> None:
815813 ssh_shell .bash_prompt = bash_prompt
816814 self .has_checked_bash_prompt = True
817815
818- def _login_to_serial_console (self ) -> None :
819- from lisa .features import SerialConsole
820-
821- if self .features .is_supported (SerialConsole ):
822- serial_console = self .features [SerialConsole ]
823- # clear the serial console
824- # write \n to serial console to get the prompt
825- # read the serial console output
826- _ = serial_console .read ()
827- serial_console .write ("\n " )
828- serial_read = serial_console .read ()
829- if "login" in serial_read :
830- password = self ._get_password ()
831- serial_console .write (f"{ self ._connection_info .username } \n " )
832- password_prompt = serial_console .read ()
833- if "password" in password_prompt .lower ():
834- serial_console .write (f"{ password } \n " )
835- else :
836- self .log .debug (
837- "No login prompt found, serial console is already logged in."
838- )
839-
840- def _get_password (self , generate : bool = True ) -> str :
816+ def get_password (self , generate : bool = True ) -> str :
841817 """
842818 Get the password for the node. If the password is not set, it will
843819 generate a strong password and reset it.
0 commit comments