
                         x   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
lmZ dZe	j(                   e	j*                  dee       e	j,                  e	j.                  j0                  e	j.                  j2                         G d de	j4                                             Zy)z;Command for suspending the TPU node and GCE VM combination.    )absolute_import)division)unicode_literals)HttpConflictError)HttpNotFoundError)base)flags)util)logzThis command is deprecated and will be removed in a future release. We recommend that you use the TPU-VM or Queued Resource API. See https://cloud.google.com/tpu/docs/managing-tpus-tpu-vm for more information.F)
is_removedwarningerrorc                   &    e Zd ZdZed        Zd Zy)ResumezCreates Google Compute TPU and resumes the VM.

  ## EXAMPLES

  To resume a suspended TPU VM combination, run:

    $ {command} test-execution-group --zone=test-zone --project=test-project \
    --accelerator-type=v2-8 --tf-version=2.4.1

  c                 L   t        j                  |dd       t        j                  |       t        j                         j                  |       t        j                  |       t        j                  |       t        j                  |       t        j                  |       y )Ntpuresume)resource_typeoperation_type)
r	   AddZoneFlag
tpus_flagsAddTpuNameArgGetAcceleratorTypeFlagAddToParserAddTfVersionFlagForResumeAddPreemptibleFlagAddVmOnlyFlagAddNetworkArgsForResume)clsparsers     3lib/surface/compute/tpus/execution_groups/resume.pyArgszResume.Args9   sq    	fE(KV$%%'33F;((0!!&)V$&&v.    c                    t         j                  j                  |       g }t        j                  | j	                               }d }d }|j
                  sS	 |j                  |j                  |j                  |j                  |j                  |j                  |j                        }t        j$                  | j	                               }	 |j'                  |j                  |j                        }|r#|j+                  |d      }|j-                  |       |r:|j-                  |j+                  |dj#                  |j                                     |S # t        $ r= t        j                  j!                  dj#                  |j                               |cY S w xY w# t(        $ r= t        j                  j!                  dj#                  |j                               |cY S w xY w)Nz:TPU Node with name:{} already exists, try a different namez(Instance:{} not found, possibly deleted.zStarting GCE VMzCreating TPU node:{})	tpu_utilsDefaultArgsValidateZoneTPUNodeReleaseTrackvm_onlyCreateexecution_group_nameaccelerator_type
tf_versionzonepreemptiblenetworkr   r   statusPrintformatInstanceStartr   WaitForOperationappend)selfargs	responsesr   tpu_operation_refinstance_operation_refinstanceinstance_start_responses           r!   Runz
Resume.RunC   s   &&t,I


D--/
0C!<<	JJt'@'@'+'<'<doo'+yy$2B2B'+||5 !!$"3"3"56H'~~

#
#TYY 0  ( 9 9
 "3!5./


02H2O2O''3) *+ 3  

 006!6618	9 	  	jjAHH

#
#% &s'   AE &F AFFAG$#G$N)__name__
__module____qualname____doc__classmethodr"   r@    r#   r!   r   r   '   s     	 / /&r#   r   N)rD   
__future__r   r   r   apitools.base.py.exceptionsr   r   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer	   'googlecloudsdk.command_lib.compute.tpusr   8googlecloudsdk.command_lib.compute.tpus.execution_groupsr
   r%   googlecloudsdk.corer   _DEPRECATION_WARNINGDefaultUniverseOnly	DeprecateReleaseTracksr)   BETAALPHACommandr   rF   r#   r!   <module>rU      s    B &  ' 9 9 ( 4 G V #   
  D%%**D,=,=,C,CD<T\\ < E	  <r#   