
    w=                        S r SSKJr  SSKJr  SSKJr  SSK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  SSKJr  SSKrSr   SS jr\R:                  \R<                  " \R>                  R@                  5       " S S\RB                  5      5       5       r"\R:                  \R<                  " \R>                  RF                  5       " S S\"5      5       5       r$\R:                  \R<                  " \R>                  RJ                  5       " S S\"5      5       5       r&SSSS.\"l'        \"RN                  \$l'        g)zCommand for creating images.    )absolute_import)division)unicode_literalsN)base_classes)
csek_utils)image_utils)	kms_utils)arg_parsers)base)
exceptions)flags)resource_args)labels_util)	resourcesi  c                 >   U R                   R                  [        R                  5        U R	                  SS9n[        R
                  " XS9  [        R                  " X5        [        R                  " 5       [        l	        [        R                  R                  U SS9  [        R                  " U SS9  [        R                  " U 5        [        R                  " 5       R!                  U 5        [        R"                  " X5        [        R$                  " X5        [&        R(                  " X5        [&        R*                  " X5        [,        R.                  " U S5        [        R0                  " U 5        U(       a$  [        R2                  " 5       R!                  U 5        U R5                  SS	S
S9  U R5                  SSSSSS9  [6        [8        R:                  " 5       S.nU(       a#  U R5                  S[8        R:                  " US9SS9  [<        R>                  " U 5        g)z Set Args based on Release Track.T)requiredsupport_user_licensescreate)operation_typeimage)resource_typez--storage-locationLOCATIONz    Specifies a Cloud Storage location, either regional or multi-regional,
    where image content is to be stored. If not specified, the multi-region
    location closest to the source is chosen automatically.
    )metavarhelpz--locked
store_trueNa      Specifies that any boot disk created from this image can't be used
    for data backup operations such as snapshot creation, image creation,
    instance snapshot creation, and disk cloning.

    If a VM instance is created using this image, the boot disk is fixed
    to this VM. The disk can't be attached to any other VMs, whether in
    `read-write` mode or in `read-only` mode. Also, any VM created from this
    disk, has the following characteristics:

    * The VM can't be used for creating machine images or instance templates
    * After the VM is created, you can't attach any secondary disk
    * After the VM is deleted, the attached boot disk can't be retained
    )actiondefaulthiddenr   )default_rollout_timelocation_rollout_policiesz--rollout-override)speca          A rollout policy for the image. A rollout policy is used to restrict
        the zones where this image is accessible when using a zonal image
        family reference. When specified, the rollout policy overrides per-zone
        references to the image through the associated image family. When the
        rollout policy does not include the user specified zone, or if the zone
        is rolled out, this image is accessible.

          default_rollout_time
            This is an optional RFC3339 timestamp on or after which
            the update is considered rolled out to any zone that is not
            explicitly stated.

          location_rollout_policies
            Location based rollout policies to apply to the resource.
            Currently only zone names are supported as the key and must be
            represented as valid URLs, like: zones/us-central1-a.
            The value expects an RFC3339 timestamp on or after which the update
            is considered rolled out to the specified location.
    )typer   ) display_info	AddFormatr   LIST_FORMATadd_mutually_exclusive_groupAddCommonArgsAddCommonSourcesArgsMakeDiskImageArgCreateDISK_IMAGE_ARGAddArgumentr   AddCsekKeyArgsr   AddCreateLabelsFlagsMakeForceArgAddToParserAddCloningImagesArgs AddCreatingImageFromSnapshotArgsr   AddGuestOsFeaturesArgAddArchitectureArgkms_resource_argsAddKmsKeyResourceArgAddSourceDiskProjectFlagMakeForceCreateArgadd_argumentstrr
   ArgDictcompute_flags%AddShieldedInstanceInitialStateKeyArg)parsermessagessupports_force_creater   supports_rollout_overridesources_groupr"   s          $lib/surface/compute/images/create.py_ArgsrE   (   s    	 1 1255t5D-fJV3002&##F8#DF':""6*""6*V3((?##F5  2((9  ( 	**62  	 	  	, "#.#6#6#8
$
 
  d+  0 55f=    c                   N    \ rS rSrSr\S 5       r\S	S j5       rS r S
S jr	Sr
g)r+      Create Compute Engine images.c                     U R                  SS9R                  R                  n[        X5        UR                  R                  [        R                  5        g )NTno_http_GetApiHolderclientr@   rE   r$   AddCacheUpdaterr   ImagesCompleterclsr?   r@   s      rD   ArgsCreate.Args   sC       .55>>H	&
''(=(=>rF   c                 L    [         R                  " U R                  5       U5      $ N)r   ComputeApiHolderReleaseTrack)rS   rL   s     rD   rN   Create._GetApiHolder   s    (()9)9);WEErF   c                 $    U R                  U5      $ rW   _Runselfargss     rD   Run
Create.Run   s    99T?rF   c                    U R                  5       nUR                  nUR                  nUR                  n[        R
                  R                  XR                  5      nUR                  UR                  UR                  UR                  R                  R                  UR                  S9n	UR                  S5      (       a*  UR                  R                  UR                  5      U	l        U(       a'  UR                  S5      (       a  UR                   U	l        [$        R&                  R)                  US5      n
U
(       a>  [$        R*                  " U
R-                  UUR.                  S9UR0                  5      U	l        [4        R6                  " XU	R2                  5      U	l        U(       a  UR                  S5      (       a  SnSUR8                  ;   aj  UR:                  R=                  UR8                  S   R?                  5        VVs/ s H(  u  pUR:                  R<                  RA                  XS	9PM*     snnS
9nUR8                  RC                  S5      nUR;                  UUS9U	l"        URF                  (       a(  URH                  (       d  [J        RL                  " SS5      eURN                  (       a(  URH                  (       d  [J        RL                  " SS5      eURP                  nURR                  nURT                  nU(       a%  U(       d  U(       d  [J        RL                  " SS5      eU(       d  U(       an  [V        RX                  " XW5      nUR[                  UR\                  UUUSS9u  nnUR^                  U	l0        [$        Rb                  " U
UUR0                  5      U	l2        URf                  (       a  Sn[h        Rj                  " UURf                  5      (       a  URf                  nO=[l        Rn                  " [        Rp                  Rs                  URf                  5      5      nUR                  Ru                  US9U	l;        GO1URH                  (       a  [x        Rz                  R                  UUR                  [|        R~                  " U5      URN                  S9nUR                  5       U	lA        [$        Rb                  " U
UUR0                  5      U	lB        O[        US5      (       a  UR                  (       ay  [x        R                  R                  UUR                  [|        R~                  " U5      S9nUR                  5       U	lF        [$        Rb                  " U
UUR0                  5      U	lG        UR                  (       a  UR                  U	lH        [        US/ 5      nU(       aU  / nU HF  nUR                  R                  U5      nUR                  5       nUUlL        UR                  U5        MH     UU	lN        [V        R                  " X5      u  nnU(       a  UU	lP        UR                  S5      (       a  UR                  /U	lR        [        U	S5      (       a  UR                  U	lS        UR                  U	UR\                  S9n [        USS5      n!U!(       a  UR                  R                  [        [l        R                  " U!5      5       V"V#s/ s H*  u  n"n#UR                  R                  RA                  U"U#S	9PM,     sn#n"S
9n$U$U R                  lX        UR                  (       d  [        USS5      (       a  SU lZ        UR                  UR0                  R                  SU 4/[        S 9$ s  snnf s  sn#n"f )!z7Returns a list of requests necessary for adding images.)namedescription
sourceTypefamilyarchitectureuser_licensesT)raise_if_missingrollout_overrideNr!   )keyvalue)additionalPropertiesr    )locationRolloutPoliciesdefaultRolloutTimez--source-disk-zonezRYou cannot specify [--source-disk-zone] unless you are specifying [--source-disk].source_disk_projectzSYou cannot specify [source_disk_project] unless you are specifying [--source_disk].z--source-image-projectzrYou cannot specify [--source-image-project] unless you are specifying [--source-image] or [--source-image-family].)user_projectr   image_familyimage_projectreturn_image_resourcez.projects/[^/]+/locations/[^/]+/repositories/.*)source)scope_listersource_projectsource_snapshot)rw   guest_os_featuresstorage_locationlocked)r   projectlabelsforce_createInsert)timeout)^rN   rO   r@   r   r+   r,   ResolveAsResourceImager   re   SourceTypeValueValuesEnumRAWrg   IsSpecifiedArchitectureValueValuesEnumrh   ri   userLicensesr   CsekKeyStoreFromArgsMaybeToMessage	LookupKeyrequire_csek_key_createapitools_clientimageEncryptionKeyr	   MaybeGetKmsKeyrk   RolloutPolicyLocationRolloutPoliciesValueitemsAdditionalPropertygetrolloutOverridesource_disk_zonesource_diskr   InvalidArgumentExceptionrq   source_image_projectsource_imagesource_image_familyr   ImageExpanderExpandImageFlagr}   selfLinksourceImageMaybeLookupKeyMessagesourceImageEncryptionKey
source_urirematchsix	text_typeREGISTRYParseRawDiskValuerawDiskr   SOURCE_DISK_ARGr=   GetDefaultScopeListerSelfLink
sourceDisksourceDiskEncryptionKeyhasattrry   SOURCE_SNAPSHOT_ARGsourceSnapshotsourceSnapshotEncryptionKeylicensesgetattrGuestOsFeatureTypeValueValuesEnumr#   appendguestOsFeaturesCreateInitialStateConfigshieldedInstanceInitialStater{   storageLocationsr|   ComputeImagesInsertRequestLabelsValuesorted	iteritemsr~   forceforceCreateMakeRequestsimagesPOLL_TIMEOUT)%r_   r`   r   rB   holderrO   r@   resource_parser	image_refr   	csek_keysr!   kvr    r   r   r   image_expander_source_image_refar_uri_regexr   source_disk_refsource_snapshot_refrz   guest_os_feature_messagesfeaturegf_typeguest_os_featureinitial_statehas_setrequestargs_labelsrl   rm   r~   s%                                        rD   r]   Create._Run   s    !F]]FH&&O%%77>N>NOINN__$$>>;;??{{	  E ''#>>EE


e !1!1/!B!B--e''00t<I!+!:!:


i/3/K/K  M

 
 ""e  )7700 2E T%5%56H%I%I"&	$(=(=	=$,$:$:$W$W
 !11/%'	"DA &&CCVV W 	" %X 	%
! "22667MN&44";1 5 e T%5%5//
 
 (8(8//
() )
  44$$L22\5H//
"DE E
 *"00In*:: ((*, $ ; &a	 +33e'1'G'G
%v'='=(?e$  Gl	,	0	0__
]]9#5#5#;#;DOO#LM
nn111Dem			--??



$::6B11	 @ 3o
 )113e&0&F&F
_f&<&<'>e#	(	)	)d.B.B!55GG



$::6B H D 199;e*4*J*J
(&*@*@+Be' }}}}en&92>"$&'))==gF#224 '!(()9:	 '
 8e(AAM7 +8e(*++ $ 5 56euh[[el11!! 2 #G $$/K~~)) #3==#=>@@ ?jc5 ..
$
$
7
7U 8 $>@@) Af $gmm zzWT>488 g!7!7!>!>!(!*  +4@  B Bq"\@@s   	/]?
!1^
 N)F)FF)__name__
__module____qualname____firstlineno____doc__classmethodrT   rN   ra   r]   __static_attributes__r   rF   rD   r+   r+      sB     &? ?
 F F JO[BrF   r+   c                   .    \ rS rSrSr\S 5       rS rSrg)
CreateBetai9  rI   c                     U R                  SS9R                  R                  n[        UUSSSS9  UR                  R                  [        R                  5        g )NTrK   FrA   r   rB   rM   rR   s      rD   rT   CreateBeta.Args>  sT       .55>>H	"""' ''(=(=>rF   c                 "    U R                  USS9$ )NTr   r\   r^   s     rD   ra   CreateBeta.RunJ  s    99T966rF   r   N	r   r   r   r   r   r   rT   ra   r   r   rF   rD   r   r   9  s     &	? 	?7rF   r   c                   .    \ rS rSrSr\S 5       rS rSrg)CreateAlphaiN  rI   c                     U R                  SS9R                  R                  n[        UUSSSS9  UR                  R                  [        R                  5        g )NTrK   r   rM   rR   s      rD   rT   CreateAlpha.ArgsS  sT       .55>>H	"""& ''(=(=>rF   c                 $    U R                  USSS9$ )NT)r   rB   r\   r^   s     rD   ra   CreateAlpha.Run_  s    99DD   rF   r   Nr   r   rF   rD   r   r   N  s     &	? 	?rF   r   zCreate Compute Engine imagesa          *{command}* is used to create custom disk images.
        The resulting image can be provided during instance or disk creation
        so that the instance attached to the resulting disks has access
        to a known set of software or files from the image.

        Images can be created from gzipped compressed tarball containing raw
        disk data, existing disks in any zone, existing images, and existing
        snapshots inside the same project.

        Images are global resources, so they can be used across zones and
        projects.

        To learn more about creating image tarballs, visit
        [](https://cloud.google.com/compute/docs/creating-custom-image).
        ao          To create an image 'my-image' from a disk 'my-disk' in zone 'us-east1-a', run:

            $ {command} my-image --source-disk=my-disk --source-disk-zone=us-east1-a

        To create an image 'my-image' from a disk 'my-disk' in zone 'us-east1-a' with source
        disk project 'source-disk-project' run:

            $ {command} my-image --source-disk=my-disk --source-disk-zone=us-east1-a --source-disk-project=source-disk-project

        To create an image 'my-image' from another image 'source-image'
        with source image project 'source-image-project', run:

            $ {command} my-image --source-image=source-image --source-image-project=source-image-project

        To create an image 'my-image' from the latest non-deprecated image in the family 'source-image-family'
        with source image project 'source-image-project', run:

            $ {command} my-image --source-image-family=source-image-family --source-image-project=source-image-project

        To create an image 'my-image' from a snapshot 'source-snapshot', run:

            $ {command} my-image --source-snapshot=source-snapshot
        )briefDESCRIPTIONEXAMPLES)FFF)(r   
__future__r   r   r   r   googlecloudsdk.api_lib.computer   r   r   r	   googlecloudsdk.callioper
   r   r   "googlecloudsdk.command_lib.computer   r=   )googlecloudsdk.command_lib.compute.imagesgooglecloudsdk.command_lib.kmsr   r6   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   r   rE   DefaultUniverseOnlyReleaseTracksrY   GACreateCommandr+   BETAr   ALPHAr   detailed_helpr   rF   rD   <module>r     sK   # &  ' 	 7 5 6 4 / ( . E ; M < ) 
  #^>B D%%(()kBT kB * kB\ D%%**+7 7 , 7& D%%++,&  - . 	'	"	+- ^ "//
 rF   