
                         r   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S	K
Jr  SSKJr  SSKJr  SS
KJr  \	R(                  " \	R*                  R,                  \	R*                  R.                  \	R*                  R0                  5       " S S\	R2                  5      5       rSSSS.\l        g)z;Command for updating instances in a managed instance group.    )absolute_import)division)unicode_literals)base_classes)instance_groups_utils)base)flags)scope)update_instances_utilsc                   :    \ rS rSrSr\S 5       rS rS rS r	Sr
g)	UpdateInstances   QImmediately update selected instances in a Compute Engine managed instance group.c                     U R                   R                  S5        [        R                  " U S9  [        R
                  R                  U 5        g )Nzp
        table(project(),
              zone(),
              instanceName:label=INSTANCE,
              status)parser)display_info	AddFormatinstance_groups_managed_flagsAddUpdateInstancesArgsinstance_groups_flags%MULTISCOPE_INSTANCE_GROUP_MANAGER_ARGAddArgumentr   s    ?lib/surface/compute/instance_groups/managed/update_instances.pyArgsUpdateInstances.Args$   sB    
!! # 
 "88G??KK    c           	         [         R                  " U R                  5       5      nUR                  n[        R
                  R                  UUR                  [        R                  R                  [        R                  " U5      S9n[        R                  " U5        UR                  5       S:X  a  [        R                   " SUR"                  =(       d    SUR$                  R&                  R(                  5      n[        R                   " SUR*                  =(       d    SUR$                  R&                  R,                  5      nSnU R/                  XEXc5      nOUR                  5       S:X  a  [        R                   " SUR"                  =(       d    SUR$                  R0                  R(                  5      n[        R                   " SUR*                  =(       d    SUR$                  R0                  R,                  5      nS	nU R3                  XEXc5      nO([5        S
R7                  UR                  5       5      5      eUR8                  (       a  [:        R<                  " USUUUS9$ [:        R>                  " USUUUUR@                  S9$ )N)default_scopescope_listerzcompute.instanceGroupManagersz--minimal-actionnonez --most-disruptive-allowed-actionreplace(instanceGroupManagersApplyUpdatesRequestz#compute.regionInstanceGroupManagers.regionInstanceGroupManagersApplyUpdatesRequestzUnknown reference type {0}ApplyUpdatesToInstances)
api_holdermethod_namerequest_templateall_instances_holder_fieldigm_ref)r&   r'   r(   instances_holder_fieldr*   	instances)!r   ComputeApiHolderReleaseTrackclientr   r   ResolveAsResource	resourcescompute_scope	ScopeEnumZONEr	   GetDefaultScopeListerr   ValidateIgmReference
CollectionParseInstanceActionFlagminimal_actionmessages(InstanceGroupManagersApplyUpdatesRequestMinimalActionValueValuesEnummost_disruptive_allowed_action*MostDisruptiveAllowedActionValueValuesEnum_CreateZonalApplyUpdatesRequest.RegionInstanceGroupManagersApplyUpdatesRequest"_CreateRegionalApplyUpdatesRequest
ValueErrorformatall_instancesr   SendAllInstancesRequest*SendInstancesRequestsAndPostProcessOutputsr,   )	selfargsholderr/   r*   r9   r=   r+   requests	            r   RunUpdateInstances.Run/   s5   **4+<+<+>?F]]F$JJ!!##!.!8!8!=!= % ; ;F C	 " E  //8>>-EE
d11;V
//
B
B'')n
 !
8
8011>YooFF99(;$  J44
#AKg				!F	F-EE
d11;V
//
H
H'')n
 !
8
8011>YooLL99(;$  P77
#AKg 3::



  ! ! "::/"%;  #MM/"!7NN$ $r   c           	          UR                   R                  UR                  5       UR                   R                  / UUS9UR                  UR
                  S9$ )Nr,   minimalActionmostDisruptiveAllowedAction)instanceGroupManagerr#   projectzone)r:   :ComputeInstanceGroupManagersApplyUpdatesToInstancesRequestNamer;   rR   rS   rG   r*   r9   r=   r/   s        r   r?   /UpdateInstances._CreateZonalApplyUpdatesRequestk   sY    ??UU$\\^17	1	1((F 
2 
H \\ V  r   c           	          UR                   R                  UR                  5       UR                   R                  / UUS9UR                  UR
                  S9$ )NrN   )rQ   r$   rR   region)r:   @ComputeRegionInstanceGroupManagersApplyUpdatesToInstancesRequestrU   r@   rR   rY   rV   s        r   rA   2UpdateInstances._CreateRegionalApplyUpdatesRequestw   s[     ??[[$\\^7=	7	7((F 
8 
H ~~ \ 	 	r    N)__name__
__module____qualname____firstlineno____doc__staticmethodr   rK   r?   rA   __static_attributes__r\   r   r   r   r      s*     [ :$x
r   r   r   a            When using a managed instance group, it's possible that your intended
          specification for a VM is different from the current state of that VM. For
          example, this can happen due to changes to the group's target instance
          template. This command enables you to initiate the update process on the given
          set of instances instantly, thus when your Managed Instance Group is stable
          you can be sure that all the changes were applied.

          *{command}* allows you to specify the least and the most disruptive actions
          that can be performed while updating the instances. This way you can reduce
          the risk of rolling out too many changes at once. Possible actions are:
          `none`, `refresh`, `restart` and `replace`. The level of disruption to the
          instance is ordered as: `none` < `refresh` < `restart` < `replace`.

          The command returns the operation status per instance, which might be
          ``FAIL'', ``SUCCESS'', or ``MEMBER_NOT_FOUND''. ``MEMBER_NOT_FOUND''
          is returned only for regional groups when the gcloud command-line tool
          wasn't able to resolve the zone from the instance name.
        ah          To update instances `instance-1`, `instance-2` in `my-group`,
        with `minimal-action=none` and `most-disruptive-allowed-action=restart`,
        run:

            $ {command} \
                  my-group --instances=instance-1,instance2 \
                  --minimal-action=none
                  --most-disruptive-allowed-action=restart
        )briefDESCRIPTIONEXAMPLESN)ra   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer	   r
   r2   2googlecloudsdk.command_lib.compute.instance_groupsr   :googlecloudsdk.command_lib.compute.instance_groups.managedr   :googlecloudsdk.command_lib.compute.managed_instance_groupsr   ReleaseTracksr.   GABETAALPHACommandr   detailed_helpr\   r   r   <module>rt      s    B &  ' 7 @ ( 4 E ] m ] $++00$2C2C2I2IKbdll bKbN	"	(		3#! r   