
                            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,                  5       " S S\
R.                  5      5       5       r\
R(                  " \
R*                  R2                  5       " S S\5      5       r\
R(                  " \
R*                  R6                  5       " S S\5      5       rg)z$Command for creating machine images.    )absolute_import)division)unicode_literals)base_classes)
csek_utils)	kms_utils)base)flags)scope)resource_argsc                   @    \ rS rSrSrSrSrSSS.r\S 5       r	S r
S	rg
)Create   &Create a Compute Engine machine image.TFz
         To create a machine image, run:

           $ {command} my-machine-image --source-instance=example-source --source-instance-zone=us-central1-a
       )briefEXAMPLESc                    UR                   R                  [        R                  5        [        R                  " 5       [
        l        [
        R                  R                  USS9  UR                  SSS9  [        R                  " USS9  [        R                  " US5        [        R                  " US5        [        R                  " U5        [        R                   " US5        U R"                  (       a  [        R$                  " U5        [        R&                  " 5       [
        l        [
        R(                  R                  U5        g )	Ncreate)operation_typez--descriptionz2Specifies a text description of the machine image.)helpzmachine image)resource_typezmachine image's)display_info	AddFormatmachine_image_flagsDEFAULT_LIST_FORMATMakeMachineImageArgr   MACHINE_IMAGE_ARGAddArgumentadd_argumentr   AddCsekKeyArgsr
   AddStorageLocationFlagAddGuestFlushFlagAddSourceDiskCsekKeyArgkms_resource_argsAddKmsKeyResourceArg_SUPPORT_DISK_FILTERINGAddDiskFilterArgsMakeSourceInstanceArgSOURCE_INSTANCE)clsparsers     ,lib/surface/compute/machine_images/create.pyArgsCreate.Args1   s    
!!"5"I"IJ2FFHF
(((I
A  C fOD	  ):;	FO4	!!&)**6?C
""++F30FFHF
&&v.    c                    [         R                  " U R                  5       5      nUR                  n[        R
                  R                  UUR                  [        R                  R                  [        R                  " U5      S9n[        R                  R                  XR                  5      nUR                  R                  UR!                  5       UR"                  UR%                  5       S9n[&        R(                  R+                  XR,                  5      nU(       a=  [&        R.                  " UR1                  XAR2                  S9UR4                  5      Ul        [8        R:                  " XR                  UR6                  5      Ul        UR=                  S5      (       a  UR>                  /Ul         UR=                  S5      (       a  URB                  Ul"        U RF                  (       a|  UR=                  S5      (       a(  UR                  RI                  URJ                  S9Ul&        UR=                  S5      (       a(  UR                  RI                  URN                  S	9Ul&        [Q        US
/ 5      n0 n	U(       a  U H  n
U
RS                  S5      nUR                  RU                  USURV                  URV                  S.S9n[&        R(                  RY                  U
RS                  S5      U R,                  5      n[&        R.                  " UR1                  U5      UR4                  5      nXU'   M     / nU	(       aE  U	R[                  5        H1  u  nn
UR                  R]                  UU
S9nUR_                  U5        M3     U(       a  Xl0        UR                  Rc                  XdRV                  S9nURe                  UR4                  Rf                  SU4/5      $ )z?Returns a list of requests necessary for adding machine images.)default_scopescope_lister)namedescriptionsourceInstance)raise_if_missingstorage_locationguest_flushinclude_disks)includedDisksexclude_disks)excludedDiskssource_disk_csek_keydiskzcompute.disks)projectzone)
collectionparamszcsek-key-file)
sourceDiskdiskEncryptionKey)machineImager?   Insert)4r   ComputeApiHolderReleaseTrackclientr   r   ResolveAsResource	resourcesr   	ScopeEnumGLOBALr
   GetDefaultScopeListerr)   messagesMachineImageNamer4   SelfLinkr   CsekKeyStoreFromArgs_ALLOW_RSA_ENCRYPTED_CSEK_KEYSMaybeToMessage	LookupKeyrequire_csek_key_createapitools_clientmachineImageEncryptionKeyr   MaybeGetKmsKeyIsSpecifiedr7   storageLocationsr8   
guestFlushr&   MachineImageParamsr9   rB   r;   getattrgetParser?   FromFileitemsSourceDiskEncryptionKeyappendsourceDiskEncryptionKeys!ComputeMachineImagesInsertRequestMakeRequestsmachineImages)selfargsholderrI   machine_image_refsource_instancemachine_image	csek_keyssource_csek_keys	disk_keyskeydisk_urldisk_ref	key_storedisk_keysource_disk_messagesr>   source_disk_messagerequests                      r,   Run
Create.RunE   sy   **4+<+<+>?F]]F00BBoo,,008	 C : ,,>> O OO00##%$$&//1 1 3M
 ''00113I0:0I0I


2N2N  P

 
 1"m- /8.F.Foo}FF/HM+ *++(,(=(='>m$&&!%!1!1m##			/	*	*%AA,,  B  
 
		/	*	*%AA,,  B  
 t%;R@I!#776?##))&*22'// *  ++44GGO$d&I&IK	 ,,)6+A+AC&( "   ()$$ooEEs F 4##$78 )
 /C,oo??",E,E @ GG!7!7!E!Ex!(!*  + , ,r/    N)__name__
__module____qualname____firstlineno____doc__rU   r&   detailed_helpclassmethodr-   r|   __static_attributes__r~   r/   r,   r   r      s>     /#' ! 3		- / /&P,r/   r   c                       \ rS rSrSrSrSrg)
CreateBeta   r   Fr~   Nr   r   r   r   r   r&   r   r~   r/   r,   r   r      s    .!r/   r   c                       \ rS rSrSrSrSrg)CreateAlpha   r   Tr~   Nr   r~   r/   r,   r   r      s    . r/   r   N)r   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   r   googlecloudsdk.callioper	   "googlecloudsdk.command_lib.computer
   r   1googlecloudsdk.command_lib.compute.machine_imagesr   googlecloudsdk.command_lib.kmsr   r$   DefaultUniverseOnlyReleaseTracksrH   GACreateCommandr   BETAr   ALPHAr   r~   r/   r,   <module>r      s    + &  ' 7 5 4 ( 4 4 Z M D%%(()t,T t, * t,n D%%**+" " ," D%%++,!* ! -!r/   