
                            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 dd
Z e
j$                  e
j&                  j(                         G d de
j*                               Z e
j$                  e
j&                  j.                  e
j&                  j0                         G d de             Zddde_        ej4                  e_        y)zGCommand for waiting until managed instance group reaches desired state.    )absolute_import)division)unicode_literals)base_classes)
wait_utils)base)flags)scopec                    | j                  dt        d       | j                  d      }|j                  dddd	
       |r|j                  dddd
       |j                  dddd
       t        j                  j                  |        y)z
Adds args.z	--timeoutzAWaiting time in seconds for the group to reach the desired state.)typehelpT)requiredz--version-target-reached
store_trueFz%Wait until version target is reached.)actiondefaultr   z --all-instances-config-effectivezVWait until the group's all-instances configuration is applied to all VMs in the group.z--stablezWait until the group is stable.N)add_argumentintadd_mutually_exclusive_groupinstance_groups_flags%MULTISCOPE_INSTANCE_GROUP_MANAGER_ARGAddArgument)parserbeta
event_types      9lib/surface/compute/instance_groups/managed/wait_until.py_AddArgsr      s    $  % 22D2A*4!-"'F  H 
*(	  ) *!-"'@  B ==II    c                   ,    e Zd ZdZed        Zd Zd Zy)WaitUntilGA@Wait until the managed instance group reaches the desired state.c                     t        |        y )Nr   r   r"   s    r   ArgszWaitUntilGA.Args>   s
    Fr   c                     t         j                  j                  ||t        j                  j
                  t        j                  |            S )N)default_scopescope_lister)r   r   ResolveAsResourcecompute_scope	ScopeEnumZONEr	   GetDefaultScopeLister)selfclient	resourcesargss       r   CreateGroupReferencez WaitUntilGA.CreateGroupReferenceB   sE    !GG+55::"88@	  BBr   c                    t        j                  | j                               }|j                  }| j	                  ||j
                  |      }|j                  rt        j                  j                  }nM|j                  rt        j                  j                  }n&|j                  rt        j                  j                  }t        j                  |||j                         y)z8Issues requests necessary to wait until stable on a MIG.N)r   ComputeApiHolderReleaseTrackr.   r1   r/   stabler   IgmStateSTABLEversion_target_reachedVERSION_TARGET_REACHEDall_instances_config_effectiveALL_INSTANCES_CONFIG_EFFECTIVEWaitForIgmStatetimeout)r-   r0   holderr.   	group_ref	igm_states         r   RunzWaitUntilGA.RunJ   s    **4+<+<+>?F]]F))&&2B2BDII{{%%,,i		$	$%%<<i		,	,%%DDivy)T\\Jr   N)__name__
__module____qualname____doc__staticmethodr$   r1   rA    r   r   r   r   :   s#    H BKr   r   c                        e Zd ZdZed        Zy)WaitUntilBetar    c                     t        | d       y )NT)r   r   r#   r"   s    r   r$   zWaitUntilBeta.Args^   s    F&r   N)rB   rC   rD   rE   rF   r$   rG   r   r   rI   rI   Z   s    H' 'r   rI   r    z        To wait until the managed instance group ``instance-group-1'' is stable,
        run:

          $ {command} --stable instance-group-1
        )briefEXAMPLESN)F)rE   
__future__r   r   r   googlecloudsdk.api_lib.computer   6googlecloudsdk.api_lib.compute.instance_groups.managedr   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer	   r
   r)   2googlecloudsdk.command_lib.compute.instance_groupsr   r   ReleaseTracksr4   GACommandr   BETAALPHArI   detailed_helprG   r   r   <module>rY      s    N &  ' 7 M ( 4 E ]: D%%(()K$,, K *K> D%%**D,=,=,C,CD'K ' E' 	K		
  *77 r   