
    
                     d    S r SSKJr  SSKJr  SSKJr  SSKJr  / SQrSrSr	S	 r
S
 rS rSS jrg)zFUtility function for OS Config Troubleshooter to check metadata setup.    )absolute_import)division)unicode_literals)utils)trueyyes1   zenable-osconfigzosconfig-disabled-featuresc                     / SQn[         R                  " X!5      nSSSU R                  S/n[         R                  " XA5      nSU-   S-   U-   $ )N)computeproject_infoadd-metadata--metadata=enable-osconfig=truer   	instancesr   r   zeNo
OS Config agent is not enabled for this VM instance. To enable for all VMs in this project, run:

z

To enable for this VM, run:

)r   GetCommandStringname)instancerelease_trackcommand_argsproject_commandinstance_argsinstance_commands         Olib/googlecloudsdk/command_lib/compute/os_config/troubleshoot/metadata_setup.py_DisabledMessager   $   sj    5,**<G/k>8==46-++MI/1@AD,, /?? @    c                     SU -   S-   $ )Nz_Yes
OS Config agent is enabled for this VM instance, but the following features are disabled:
[z].
See https://cloud.google.com/compute/docs/manage-os#disable-features for instructions on how to make changes to this setting. )disabled_featuress    r   #_EnabledWithDisabledFeaturesMessager    1   s     "$569BBr   c                 0   ^ [        U4S jU  5       S5      $ )zGets the value of the key field of the given metadata list.

Args:
  metadata: The metadata to look through.
  key: the key to look for

Returns:
The value of the key, None if the metadata field does not exist.
c              3   ^   >#    U  H"  oR                   T:X  d  M  UR                  v   M$     g 7fN)keyvalue).0mdr$   s     r   	<genexpr>$_GetMetadataValue.<locals>.<genexpr>E   s     <(Bffmxrxx(s   --N)next)metadatar$   s    `r   _GetMetadataValuer,   ;   s     
<(<d	CCr   Nc                 n   SnSnSnSnU(       a/  U[         R                  " U5      -  n[         R                  " XT5      $ UR                  R                  nU(       a   [        U[        5      n[        U[        5      nU R                  R                  n	U	(       a.  U(       d  [        U	[        5      nU(       d  [        U	[        5      nU(       aE  UR                  5       [        ;   a  SnU(       a  U[        U5      -  nO#US-  nOU[        X5      -  nOU[        X5      -  n[         R                  " XT5      $ )z+Checks if the metadata is set up correctly.z"> Is the OS Config agent enabled? FNTYes)r   UnknownMessageResponser+   itemsr,   _ENABLE_OSCONFIG_DISABLED_FEATUREScommonInstanceMetadatalower_METADATA_BOOLr    r   )
projectr   r   	exceptionresponse_messagecontinue_flagenable_osconfigr   instance_metadataproject_metadatas
             r   Checkr>   H   s#   9-/,,Y77>>-:: ''--'(9;KLO)*;=OP 3399)*:<LMo+,<,>@ .0m	? 	 	E!*8CC(AA		88r   r#   )__doc__
__future__r   r   r   9googlecloudsdk.command_lib.compute.os_config.troubleshootr   r6   r2   r3   r   r    r,   r>   r   r   r   <module>rB      sB    M &  ' K % 1 
@
D(9r   