
                            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
Zej&                   ej(                  dee       ej*                  ej,                  j.                  ej,                  j0                  ej,                  j2                         G d dej4                                             Zy)z?Command to delete the TPU node and GCE VM combinations created.    )absolute_import)division)unicode_literals)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)Deletea;  Delete TPU Node + VM created by execution group.

  ## EXAMPLES

  To delete both, the TPU and the VM, run:

    $ {command} test-execution-group --zone=test-zone --project=test-project

  To delete the TPU only, run:

    $ {command} test-execution-group --zone=test-zone --project=test-project \
    --tpu-only
  c                     t        j                  |dd       t        j                  |       t        j                  |       y )Ntpudelete)resource_typeoperation_type)r   AddZoneFlag
tpus_flagsAddTpuNameArgAddTpuOnlyFlagForDelete)clsparsers     3lib/surface/compute/tpus/execution_groups/delete.pyArgszDelete.Args;   s0    	fE(KV$&&v.    c                 b   g }d }d }t         j                  j                  |       |j                  sJt        j                  | j                               }	 |j                  |j                  |j                        }t        j                  | j                               }	 |j                  |j                  |j                        }|r$	 j                  |d      }|j!                  |       |r$	 |j!                  |j                  |d             |S |S # t        $ r; t        j                  j                  dj                  |j                               Y w xY w# t        $ r; t        j                  j                  dj                  |j                               Y w xY w# t        $ r; t        j                  j                  dj                  |j                               Y w xY w# t        $ r< t        j                  j                  dj                  |j                               Y |S w xY w)Nz0Instance:{} not found, possibly already deleted.z0TPU Node:{} not found, possibly already deleted.zDeleting GCE VMzDeleting TPU node)	tpu_utilsDefaultArgsValidateZonetpu_onlyInstanceReleaseTrackr   execution_group_namezoner   r
   statusPrintformatTPUNodeWaitForOperationNoResourcesappend)selfargs	responsestpu_operation_refinstance_operation_refinstancer   instance_delete_responses           r   Runz
Delete.RunA   s   I!&&t,==##D$5$5$78h,!)1J1J15"< 

D--/
0C***T%>%>		J ,#+#G#G"$5$7 12 ,++!#68	9 9C  ,

>EE))+	,,  *	jj
<
C
C'')**  ,

>EE))+	,,  ,

>EE))+	, ,sL   &D  &E 	#F" /!G) AEEAFF"AG&%G&)AH.-H.N)__name__
__module____qualname____doc__classmethodr   r4    r   r   r   r   %   s      / /
-r   r   N)r8   
__future__r   r   r   apitools.base.py.exceptionsr   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$   GABETAALPHADeleteCommandr   r:   r   r   <module>rJ      s    F &  ' 9 ( 4 G V #   
  D%%(($*;*;*@*@%%++-BT B-	  Br   