
                         *   d Z ddlmZ ddlmZ ddlmZ ddl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  ej"                  d      Zd Z ej(                  ej*                  j,                         G d dej.                               Zdddde_         ej(                  ej*                  j4                         G d de             Z ej(                  ej*                  j8                         G d de             Zej2                  e_        y)z3Command for setting size of instance group manager.    )absolute_import)division)unicode_literalsN)base_classes)utils)arg_parsers)base)flags)
console_ioz
    This command increases disk size. This change is not reversible.
    For more information, see:
    https://cloud.google.com/sdk/gcloud/reference/compute/disks/resizec                     t         j                  j                  |        | j                  ddt	        j
                  d      d       y )Nz--sizeT1GB)lower_boundaG          Indicates the new size of the disks. The value must be a whole
        number followed by a size unit of ``GB'' for gigabyte, or
        ``TB'' for terabyte. If no size unit is specified, GB is
        assumed. For example, ``10GB'' will produce 10 gigabyte disks.
        Disk size must be a multiple of 1 GB.
        )requiredtypehelp)Resize	DISKS_ARGAddArgumentadd_argumentr   
BinarySize)parsers    #lib/surface/compute/disks/resize.py_CommonArgsr   #   sB    v&!!e4	  
    c                   &    e Zd ZdZed        Zd Zy)r   zSet size of a persistent disk.c                 X    t        j                  d      t        _        t	        |       y NT)pluraldisks_flagsMakeDiskArgr   r   r   clsr   s     r   ArgszResize.Args6       "..d;Fr   c           	         t        j                  | j                               }|j                  }t	        j
                  |j                        }t        j                  j                  ||j                        }t        j                  t        d       g }|D ]1  }|j                         dk(  r|j                  j!                  |j#                         |j$                  |j&                  |j                  j)                  |            }|j+                  |j,                  j.                  d|f       |j                         dk(  s|j                  j1                  |j#                         |j$                  |j2                  |j                  j5                  |            }|j+                  |j,                  j6                  d|f       4 |j9                  |      S )	z#Issues request for resizing a disk.T)messagecancel_on_nozcompute.disks)sizeGb)diskprojectzonedisksResizeRequestr   zcompute.regionDisks)r*   r+   regionregionDisksResizeRequest)r   ComputeApiHolderReleaseTrackclientr   	BytesToGbsizer   r   ResolveAsResource	resourcesr   PromptContinueCONTINUE_WITH_RESIZE_PROMPT
CollectionmessagesComputeDisksResizeRequestNamer+   r,   DisksResizeRequestappendapitools_clientdisksComputeRegionDisksResizeRequestr.   RegionDisksResizeRequestregionDisksMakeRequests)	selfargsholderr2   size_gb	disk_refsrequestsdisk_refrequests	            r   Runz
Resize.Run;   s   **4+<+<+>?F]]Foodii(G  22f I + H				/	1//;;$$%AA  B   	 < ! 	//55xIJ $99//AA$$??%+__%M%M &N & 	 B ! 	//;;XwOP! $ x((r   N)__name__
__module____qualname____doc__classmethodr$   rM    r   r   r   r   2   s    & !)r   r   zResize a disk or disksz        *{command}* resizes a Compute Engine disk(s).

        Only increasing disk size is supported. Disks can be resized
        regardless of whether they are attached.

    at          To resize a disk called example-disk-1 to new size 6TB, run:

           $ {command} example-disk-1 --size=6TB

        To resize two disks called example-disk-2 and example-disk-3 to
        new size 6TB, run:

           $ {command} example-disk-2 example-disk-3 --size=6TB

        This assumes that original size of each of these disks is 6TB or less.
        )briefDESCRIPTIONEXAMPLESc                       e Zd Zed        Zy)
ResizeBetac                 X    t        j                  d      t        _        t	        |       y r   r   r"   s     r   r$   zResizeBeta.Argsx   r%   r   NrN   rO   rP   rR   r$   rS   r   r   rX   rX   u         r   rX   c                       e Zd Zed        Zy)ResizeAlphac                 X    t        j                  d      t        _        t	        |       y r   r   r"   s     r   r$   zResizeAlpha.Args   r%   r   NrZ   rS   r   r   r]   r]   ~   r[   r   r]   )rQ   
__future__r   r   r   textwrapgooglecloudsdk.api_lib.computer   r   googlecloudsdk.callioper   r	   (googlecloudsdk.command_lib.compute.disksr
   r    googlecloudsdk.core.consoler   dedentr8   r   ReleaseTracksr1   GACommandr   detailed_helpBETArX   ALPHAr]   rS   r   r   <module>rl      s   : &  '  7 0 / ( I 2-hoo /J K  D%%(()))T\\ )) *))X & . D%%**+  , D%%++,&  - #00 r   