
    9                        d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 dd	lmZ dd	lmZ  G d
 dej                        Ze
j"                   e
j$                  e
j&                  j(                  e
j&                  j*                  e
j&                  j,                         G d de
j.                                      Zddj3                  ddd      de_        y)zBCommand for perform maintenance on Google Compute Engine instance.    )absolute_import)division)unicode_literals)base_classes)
exceptions)utils)base)flagsc                       e Zd ZdZy)PerformMaintenanceErrorzTException thrown when there is a problem with performing maintenance on an instance.N)__name__
__module____qualname____doc__     4lib/surface/compute/instances/perform_maintenance.pyr   r      s    \r   r   c                   &    e Zd ZdZed        Zd Zy)PerformMaintenancez6Perform maintenance of Google Compute Engine instance.c                 B    t         j                  j                  |        y )N)instance_flagsINSTANCES_ARGAddArgument)parsers    r   ArgszPerformMaintenance.Args(   s      ,,V4r   c                 .   t        j                  | j                               }|j                  }|j                  j                  }t
        j                  j                  ||j                  t        j                  |            }g }|D ]L  } |j                  di |j                         }|j                  j                  d|f}	|j                  |	       N g }
|j                  j!                  ||
       |
rt#        j$                  |
t&        d       y y )N)scope_listerr   )errors_to_collectz+Could not perform maintenance for resource:)error_messager   )r   ComputeApiHolderReleaseTrackclientmessagesr   r   ResolveAsResource	resourcesr
   GetDefaultScopeLister)ComputeInstancesPerformMaintenanceRequestAsDictapitools_client	instancesappendMakeRequestsr   RaiseExceptionr   )selfargsholderr"   r#   instance_refsrequestsinstance_refrequest_protobufrequesterrorss              r   RunzPerformMaintenance.Run,   s   **4+<+<+>?F]]F}}%%H"00BBfU-H-H-P C M H%KKK ! 
 
 
*
*

g
 oog & F
MMx6B

!E r   N)r   r   r   r   staticmethodr   r7   r   r   r   r   r   !   s    
 ?5 5r   r   z5Perform maintenance of Google Compute Engine instancez        To perform customer-triggered maintenance on an instance named ``{0}''
        located in zone ``{1}'', run:

          $ {2} {0} --zone={1}
        ztest-instancez
us-east1-dz	{command})briefEXAMPLESN)r   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   r   googlecloudsdk.callioper	   "googlecloudsdk.command_lib.computer
   ,googlecloudsdk.command_lib.compute.instancesr   Errorr   DefaultUniverseOnlyReleaseTracksr!   ALPHABETAGAUpdateCommandr   formatdetailed_helpr   r   r   <module>rI      s    I &  ' 7 5 0 ( 4 P]j.. ] T..33T5F5F5I5I!++ ! !L 	@	
 F?L+>
$   r   