
                             S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  S	rS
r/ SQrSr/ SQrSr " S S\R$                  5      rg)z9Troubleshoot VM boot and kernel issue for ssh connection.    )absolute_import)division)unicode_literals)apis)ssh_troubleshooter)ssh_troubleshooter_utils)logcomputev1)zSecurity ViolationzFailed to load imagez1You are now being dropped into an emergency shellz"You are in (rescue|emergency) modez!Started \x1b?\[?.*Emergency Shellz'Reached target \x1b?\[?.*Emergency Modez+Minimal BASH-like line editing is supporteda;  The VM may not be running. The serial console logs show the VM has been unable to complete the boot process. Check your serial console logs to see if the VM has been dropped into an "emergency shell" or has reached "Emergency Mode". If that is the case, try restarting the VM to see if the problem is reproducible.
)z3Kernel panic - not syncing: Attempted to kill init!z+Kernel panic - not syncing: Fatal exceptionz2Kernel panic - not syncing: No working init found.zIKernel panic - not syncing: VFS: Unable to mount root fs on unknown-blockzThe VM is experiencing a kernel panic. This problem is specific to your VM and its workload, so you may need to investigate based on a "kernel panic" error in your serial console logs.
c                   0    \ rS rSrSrS rS rS rS rSr	g)	VMBootTroubleshooterA   zCheck VM boot and kernel panic issues.

Attributes:
  project: The project object.
  zone: str, the zone name.
  instance: The instance object.
c                     Xl         X l        X0l        [        R                  " [
        [        5      U l        [        R                  " [
        [        5      U l	        0 U l
        g N)projectzoneinstancer   GetClientInstance_API_COMPUTE_CLIENT_NAME_API_CLIENT_VERSION_V1compute_clientGetMessagesModulecompute_messageissues)selfr   r   r   s       @lib/googlecloudsdk/command_lib/compute/vm_boot_troubleshooter.py__init__VMBootTroubleshooter.__init__J   sL    LIM001I1GID112J2HJDDK    c                     g r    r   s    r   check_prerequisite'VMBootTroubleshooter.check_prerequisiteT       
r   c                     g r   r!   r"   s    r   cleanup_resources&VMBootTroubleshooter.cleanup_resourcesW   r%   r   c                    [         R                  R                  S5        [        R                  " U R
                  U R                  U R                  R                  U R                  R                  U R                  5      n[        R                  " [        U5      (       a  [        U R                  S'   [        R                  " [        U5      (       a  [         U R                  S'   [         R                  R                  SR#                  [%        U R                  5      5      5        U R                  R'                  5        H"  n[         R                  R                  U5        M$     g )Nz!---- Checking VM boot status ----
boot_issuekernel_paniczVM boot: {0} issue(s) found.
)r	   statusPrintr   GetSerialConsoleLogr   r   r   namer   r   SearchPatternErrorInLogVM_BOOT_PATTERNSVM_BOOT_MESSAGEr   KERNEL_PANIC_PATTERNSKERNEL_PANIC_MESSAGEformatlenvalues)r   sc_logmessages      r   troubleshoot!VMBootTroubleshooter.troubleshootZ   s    JJ89%99T114==3E3E499&F  778H8>@ @"1dkk,778M8>@ @$8dkk.!JJ5<<S=MNO;;%%'	jjw (r   )r   r   r   r   r   r   N)
__name__
__module____qualname____firstlineno____doc__r   r#   r'   r:   __static_attributes__r!   r   r   r   r   A   s     r   r   N)r@   
__future__r   r   r   googlecloudsdk.api_lib.utilr   "googlecloudsdk.command_lib.computer   r   googlecloudsdk.corer	   r   r   r1   r2   r3   r4   SshTroubleshooterr   r!   r   r   <module>rG      sc    @ &  ' , A G #$   "%  2 ' -?? ' r   