
    w	                         d Z ddlmZ ddlmZ ddlmZ ddlZddlZddlmZ ddl	m
Z
 ddl	mZ d	 Zd
 Zd Zd Z G d d      Zy)z5Extra utility functions for OS Config Troubleshooter.    )absolute_import)division)unicode_literalsN)base)log)
propertiesc                     |t         j                  j                  k7  r| j                  d|j                         dj                  ddg| z         S )zGets the command string for the user to invoke.

  Args:
    args: the command args. These should be arguments put after 'gcloud'.
    release_track: The release track.

  Returns:
    The command string, formatted as '$ gcloud [args]'.
  r    $gcloud)r   ReleaseTrackGAinsertprefixjoin)argsrelease_tracks     Flib/googlecloudsdk/command_lib/compute/os_config/troubleshoot/utils.pyGetCommandStringr      sD     d''***KK=''(	3/D(	))    c                     t        j                         t        j                  k(  }dt	        |       j
                  z   dz   }|r(|dj                  t        j                  d            z  }|S )Nz'Unknown
The troubleshooter encountered z while checking your instance.z
{}
r   )limit)	r   GetVerbosityloggingDEBUGtype__name__format	traceback
format_exc)	exceptiondebug_verbositymessages      r   UnknownMessager$   ,   si    $$&'--7/(*.y/*B*BCF   

 xy33!<==G	.r   c           	          | j                  | j                  j                  d| j                  j	                  |xs4 t
        j                  j                  j                  j                  d            fg      d   S )NGetT)required)projectr   )
MakeRequestsapitools_clientprojectsmessagesComputeProjectsGetRequestr   VALUEScorer(   r&   )clientr(   s     r   
GetProjectr1   8   s    			''11 >""**...= 	2 	@A B
C DE	
F Fr   c                      | j                   j                  di |j                         }| j                  | j                  j
                  d|fg      d   S )Nr&   r    )r,   ComputeInstancesGetRequestAsDictr)   r*   	instances)r0   instance_refrequests      r   GetInstancer9   @   s_    6FOO66 '			''8: 
;;<
> >r   c                       e Zd ZdZd Zy)ResponsezBRepresents a response returned by each of the prerequisite checks.c                      || _         || _        y )N)continue_flagresponse_message)selfr=   r>   s      r   __init__zResponse.__init__J   s    &D,Dr   N)r   
__module____qualname____doc__r@   r3   r   r   r;   r;   G   s
    J-r   r;   )rC   
__future__r   r   r   r   r   googlecloudsdk.callioper   googlecloudsdk.corer   r   r   r$   r1   r9   r;   r3   r   r   <module>rG      sA    < &  '   ( # **	F>- -r   