
    |i                        S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKrSSK	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Jr  SSKJr  SSKrSr / SQr! " S S\RD                  5      r#S r$S r%S r&S r'S r(S r) S9S jr*\RV                  " \RX                  RZ                  5      \R\                  " SS S!S"9\R^                   " S# S$\R`                  5      5       5       5       r1\Rd                  " \Rf                  5       " S% S&\45      5       r5 " S' S(\55      r6 " S) S*\55      r7 " S+ S,\55      r8 " S- S.\85      r9 " S/ S0\85      r:\RV                  " \RX                  Rv                  5       " S1 S2\15      5       r<\RV                  " \RX                  Rz                  5       " S3 S4\<5      5       r>S5S6S7S8.\1l?        g):zImport image command.    )absolute_import)division)unicode_literalsN)base_classes)daisy_utils)image_utils)utils)storage_api)storage_util)base)
exceptions)flags)
os_choices)log)
properties)	resources)progress_trackerzbhttps://github.com/GoogleCloudPlatform/compute-image-import/tree/main/daisy_workflows/image_import)z[Daisyz[import-z	[onestep-zstarting buildz  importERRORc                       \ rS rSrSrSrSrg)CloudProvider9   r       N)__name__
__module____qualname____firstlineno__UNKNOWNAWS__static_attributes__r       $lib/surface/compute/images/import.pyr   r   9   s    '	#r!   r   c                     U R                   =(       dk    U R                  =(       dX    U R                  =(       dE    U R                  =(       d2    U R                  =(       d    U R
                  =(       d    U R                  $ N)aws_access_key_idaws_secret_access_keyaws_session_token
aws_region
aws_ami_idaws_ami_export_locationaws_source_ami_file_pathargss    r"   _HasAwsArgsr.   >   sh    
 '		#	#'			' 
' 
	'
 
	%	%' 
	&	&r!   c                 :    [        U 5      [        R                  :g  $ r$   )_GetExternalCloudProviderr   r   r,   s    r"   _HasExternalCloudProviderr1   J   s    	"4	(M,A,A	AAr!   c                 b    [        U 5      (       a  [        R                  $ [        R                  $ r$   )r.   r   r   r   r,   s    r"   r0   r0   N   s%    			r!   c                     U R                   (       a"  [        R                  " USU R                   5        [        R                  " USU R                  5        g )Noscustom_translate_workflow)r4   r   	AppendArgcustom_workflowr-   import_argss     r"   _AppendTranslateWorkflowArgr:   T   s;    	WW+tTWW5.0D0Dr!   c                 H   [         R                  " USU R                  5        [         R                  " USU R                  5        [         R                  " USU R                  5        [         R                  " USU R
                  5        U R                  (       a"  [         R                  " USU R                  5        U R                  (       a"  [         R                  " USU R                  5        U R                  (       a#  [         R                  " USU R                  5        gg)	z)Appends args related to AWS image import.r%   r&   r'   r(   r)   r*   r+   N)	r   r6   r%   r&   r'   r(   r)   r*   r+   r8   s     r"   _AppendAwsArgsr<   \   s     &(>(> *D,F,F &(>(> \4??C	__+|T__E	!!.0L0L 
""/1N1N #r!   c                 :  ^ SnSn[         R                  [         R                  -   S-   m[        U 5      S:  a  SnOBU S   [         R                  ;  a  SnO([	        U4S jU  5       5      (       d  SnOU S   S:X  a  SnU(       d  [
        R                  " S	U5      eg
)z"Checks for a valid GCE image name.zName must start with a lowercase letter followed by up to 63 lowercase letters, numbers, or hyphens, and cannot end with a hyphen.T-@   Fr   c              3   ,   >#    U  H	  oT;   v   M     g 7fr$   r   ).0charvalid_charss     r"   	<genexpr>"_CheckImageName.<locals>.<genexpr>   s     :zt{"zs   
IMAGE_NAMEN)stringdigitsascii_lowercaselenallr   InvalidArgumentException)
image_namename_messagename_okrC   s      @r"   _CheckImageNamerQ   v   s     
 ' 6 66<+_rG!}F222G:z:::G"~G	

-
-lL
II 
r!   Fc                 J   S/nU(       a  X;   a  g[         R                  R                  U SS[        R                  R
                  R                  R                  0S9n[        R                  " UR                  UR                   5      n UR                  U5      nSnU(       d.  U(       a'  SR                  U 5      n	[        R                   " X)5      eU(       a/  U(       d'  S	R                  U 5      n	[        R                   " X)5      egg! [        R                   a    Sn Nf = f)
zCheck if image already exists.zsample-image-123Ncompute.imagesproject
collectionparamsTFzThe image [{0}] already exists.zThe image [{0}] does not exist.)r   REGISTRYParser   VALUEScorerT   	GetOrFailr   ImageExpanderclientGetImager	   ImageNotFoundErrorformatr   rM   )
rN   compute_holderarg_nameexpect_to_exist%expect_to_exist_image_name_exclusions	image_refimage_expander_image_existsmessages
             r"   _CheckForExistingImagerk      s    ,>*>'L
  &&!**//77AAB ' ) ,,^55.	*AL 
\/66zBG

-
-h
@@|/66zBG

-
-h
@@  , 
	!	! Ls   
D	 	D"!D"zThis command is being deprecated. Instead, use the `gcloud migration vms image-imports` command. For more information, see https://cloud.google.com/migrate/virtual-machines/docs/5.0/migrate/image_import.zThis command hash been deprecated. Instead, use the `gcloud migration vms image-imports` command. For more information, see https://cloud.google.com/migrate/virtual-machines/docs/5.0/migrate/image_import.)
is_removedwarningerrorc                   z   ^  \ rS rSrSr\R                  rU 4S jr\	S 5       r
\	S
S j5       rS rS rS rS	rU =r$ )Import   z$Import an image into Compute Engine.c                 b   > [         R                  " 5       U l        [        [        U ]  " U0 UD6  g r$   )r
   StorageClientstorage_clientsuperrp   __init__)selfr-   kwargs	__class__s      r"   rv   Import.__init__   s(    %335D	&$ $1&1r!   c                    U R                  SS9nUR                  nUR                  n[        R                  " 5       [
        l        [
        R                  R                  USS9  [        R                  R                  USSSS9  UR                  SS	S
9nUR                  SS9nUR                  SSS9  [        R                  R                  USS9  UR                  SS9n[        R                  " U5        [         R"                  " X5        UR                  5       nUR                  5       n	[        R$                  " U	5        U	R                  S['        U R(                  5      SS9  UR                  SSSS9  UR                  SSR+                  [,        5      SS9  [        R.                  " USSS9  UR                  SSSSS9  UR                  S S!S9  UR                  S"S#S9  UR                  S$S%S9  UR                  S&S'S9  UR0                  R3                  [        R4                  5        UR                  S(S)S9  UR                  S*SSS+S,9  [        R6                  " US-S.5        [        R8                  " US-[        R:                  5        [        R<                  " US-[        R>                  5        UR                  S/SSS0S19  g )2NT)no_httpcreate)operation_typeimageimportzZone to use when importing the image. When you import an image, the import tool creates and uses temporary VMs in your project for the import process. Use this flag to specify the zone to use for these temporary VMs.)	help_textF)required	sort_argszDImage import from local file, Cloud Storage or Compute Engine image.)helpz--source-fileaL  A local file, or the Cloud Storage URI of the virtual
              disk file to import. For example: ``gs://my-bucket/my-image.vmdk''
              or ``./my-local-image.vmdk''. For more information about Cloud
            Storage URIs, see
            https://cloud.google.com/storage/docs/request-endpoints#json-api.
            zImage import from AWS.z--osz2Specifies the OS of the disk image being imported.)choicesr   z--data-diskzSpecifies that the disk has no bootable OS installed on it. Imports the disk without making it bootable or installing Google tools on it.
store_true)r   actionz--custom-workflowz              Specifies a custom workflow to use for image translation. Workflow
              should be relative to the image_import directory here: []({0}).
              For example: `debian/translate_debian_9.wf.json')r   hiddenz	an importz

          If you are importing a large image that takes longer than 24 hours to
          import, either use the RAW disk format to reduce the time needed for
          converting the image, or split the data into several smaller images.
          )	operationextra_timeout_helpz--guest-environmentzpInstalls the guest environment on the image. See https://cloud.google.com/compute/docs/images/guest-environment.)r   defaultr   z	--networkzName of the network in your project to use for the image import. When you import an image, the import tool creates and uses temporary VMs in your project for the import process. Use this flag to specify the network to use for these temporary VMs.z--subnetaH        Name of the subnetwork in your project to use for the image import. When
      you import an image, the import tool creates and uses temporary VMs in
      your project for the import process. Use this flag to specify the
      subnetwork to use for these temporary VMs.
          * If the network resource is in legacy mode, do not provide this
            property.
          * If the network is in auto subnet mode, specifying the subnetwork is
            optional.
          * If the network is in custom subnet mode, then this field must be
            specified.
        z--familyz%Family to set for the imported image.z--descriptionz*Description to set for the imported image.z--storage-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.
      z--sysprep-windowsz6Whether to generalize the image using Windows Sysprep.)r   r   r   zimage importzShttps://cloud.google.com/compute/docs/import/importing-virtual-disks#no-external-ipz--cmd-deprecatedaE  
        The command you're using is deprecated and will be removed by December 31,
        2025. We recommend using `gcloud compute migration image-imports` instead.
        See our official documentation for more information.
        https://cloud.google.com/migrate/virtual-machines/docs/5.0/migrate/image_import.
        )r   r   r   ) _GetComputeApiHolderr^   messagesr   MakeDiskImageArgrp   DISK_IMAGE_ARGAddArgumentcompute_flagsAddZoneFlagadd_mutually_exclusive_groupadd_argumentSOURCE_IMAGE_ARG	add_groupr   AddAWSImageImportSourceArgsr   AddGuestOsFeaturesArgForImport
AddByolArgsorted_OS_CHOICESra   _WORKFLOWS_URLAddCommonDaisyArgsdisplay_infoAddCacheUpdaterImagesCompleterAddNoAddressArgAddComputeServiceAccountArg(IMPORT_ROLES_FOR_COMPUTE_SERVICE_ACCOUNTAddCloudBuildServiceAccountArg+IMPORT_ROLES_FOR_CLOUDBUILD_SERVICE_ACCOUNT)
clsparserrb   compute_clientr   sourceimport_from_local_or_gcsimport_from_awsworkflowos_groups
             r"   ArgsImport.Args   sF   --d-;N#**N&&H!224F
%%fX%F	##? $ 
 00$%0PF%BB$  C   )) *  
&&  '  &&,D&EO++O<..v@224H!!#H8$s'A   "    B CI&C    ""	 N  	 O       @   J   ''(=(=>

   E	   ] ++<< ..?? 	  
r!   c                 L    [         R                  " U R                  5       U5      $ r$   )r   ComputeApiHolderReleaseTrack)r   r|   s     r"   r   Import._GetComputeApiHolder  s    (()9)9);WEEr!   c                    U R                  5       n[        UR                  5        [        UR                  U5        U R	                  X5      nUR                  5       n[        R                  " S5        S/nU R                  XU[        5      $ )Nz-Importing image. This may take up to 2 hours.zgce-daisy-image-import)
r   rQ   rN   rk   _CreateImportStagerStager   rm   _RunImageImport_OUTPUT_FILTER)rw   r-   rb   stagerimport_metadatatagss         r"   Run
Import.Run  sq    ..0N DOO$4??N;%%d;FllnOKK?@$%Dt^LLr!   c           	         [         R                  " 5       n[        US5      (       a  UR                  n[	        U5      (       a]  [         R
                  " UUU[        U R                  5       (       a+  U R                  5       R                  R                  5       US9$ S US9$ [         R                  " UUU[        U R                  5       (       a+  U R                  5       R                  R                  5       US9$ S US9$ )Ndocker_image_tag)release_trackr   )r   GetDefaultBuilderVersionhasattrr   r1   RunOnestepImageImportr   r   idlowerRunImageImport)rw   r-   r9   r   output_filter	image_tags         r"   r   Import._RunImageImport  s    446It'((''i &&..



   ))+..446 %	 	 $	 	 %% ''),,224 #	 	 "	 	r!   c                    [        U5      (       a  [        U R                  X!5      $ UR                  (       a  [	        U R                  X!5      $ [
        R                  " UR                  5      (       a  [        U R                  X!5      $  [
        R                  " UR                  5      n[        U R                  X!U5      $ ! [        R                   a    [        R                  " SS5      ef = f)Nzsource-filez3must be a path to an object in Google Cloud Storage)r1   %ImportFromExternalCloudProviderStagerrt   source_imageImportFromImageStagerr   IsLocalFilesource_fileImportFromLocalFileStagerMakeGcsObjectUriImportFromGSFileStagerr   InvalidObjectNameErrorr   rM   )rw   r-   rb   gcs_uris       r"   r   Import._CreateImportStager  s     &&2


~  "4#6#6MMt//00&


~ 	,,T-=-=>g $


~W  .. //
N s   
 C ,C-)rt   )F)r   r   r   r   __doc__r   OS_CHOICES_IMAGE_IMPORT_GAr   rv   classmethodr   r   r   r   r   r    __classcell__ry   s   @r"   rp   rp      sZ    $ -55+2 s sj F FM 6 r!   rp   c                   0    \ rS rSrSrS rS rS rS rSr	g)	BaseImportStageri  zBase class for image import stager.

An abstract class which is responsible for preparing import parameters, such
as Daisy parameters and workflow, as well as creating Daisy scratch bucket in
the appropriate location.
c                 R    Xl         X l        X0l        U R                  5       U l        g r$   )rt   rb   r-   GetAndCreateDaisyBucketdaisy_bucket)rw   rt   rb   r-   s       r"   rv   BaseImportStager.__init__  s$    ((I446Dr!   c           	         / nU R                   R                  R                  n[        R                  " US[
        R                  R                  R                  R                  5       5        U R                  R                  (       a,  [        R                  " USU R                  R                  5        [        R                  " USSR                  U R                  5      5        [        R                  " USSR                  [        R                  " U R                  5      5      5        [        R                  " USS5        [        R                  " US	U R                  R                  5        [        R                   " US
U R                  R"                  (       + 5        [        R$                  " U R                  U5        [        R                  " USU R                  R&                  5        [        R                  " USU R                  R(                  5        SU R                  ;   a,  [        R                   " USU R                  R*                  5        [-        U R                  SS5      =(       d    SnUR.                  R0                  R2                  R4                  U;   nU(       a  [        R                   " USS5        SU R                  ;   a,  [        R                   " USU R                  R6                  5        SU R                  ;   a,  [        R                   " USU R                  R8                  5        SU R                  ;   a,  [        R                  " USU R                  R:                  5        U$ )zPrepares for import args.

It supports running new import wrapper (gce_vm_image_import).

Returns:
  import_args - array of strings, import args.
zonestorage_locationscratch_bucket_gcs_pathz	gs://{0}/timeoutz{}s	client_idgcloudrN   no_guest_environmentdescriptionfamilybyolguest_os_featuresNr   uefi_compatibleTsysprep_windows
no_addressno_external_ipcompute_service_account)rb   r^   r   r   r6   r   rZ   computer   Getr-   r   ra   r   GetDaisyTimeoutrN   AppendBoolArgguest_environmentAppendNetworkAndSubnetArgsr   r   r   getattrGuestOsFeatureTypeValueValuesEnumUEFI_COMPATIBLEnamer   r   r   )rw   r9   r   r   r   s        r"   r   BaseImportStager.Stage  s    K""))22HVZ..66;;??A yy!!
)499+E+E !4,,-
 [00;< +{H=+|TYY5I5IJ+1L1L-L **499kB+}dii6K6KL+x1A1ABVTYY^^D  		+>EK33CCHH	  ->EDII%
($))*C*C tyy 
')=)= !DII-

#
))
+
+
 r!   c                 `    [         R                  " U R                  5       U R                  SSS9$ )NTr   )enable_uniform_level_accesssoft_delete_duration)r   CreateDaisyBucketInProjectGetBucketLocationrt   rw   s    r"   r   (BaseImportStager.GetAndCreateDaisyBucket   s0    11 $(	 r!   c                 f    U R                   R                  (       a  U R                   R                  $ g r$   )r-   r   r  s    r"   r  "BaseImportStager.GetBucketLocation(  s"    yy!!YY'''r!   )r-   rb   r   rt   N)
r   r   r   r   r   rv   r   r   r  r    r   r!   r"   r   r     s    7DLr!   r   c                   8   ^  \ rS rSrSrU 4S jrU 4S jrSrU =r$ )r   i/  z4Image import stager from an external cloud provider.c                    > / n[        U R                  U5        [        U R                  U5        UR                  [        [
        U ]  5       5        U$ r$   )r<   r-   r:   extendru   r   r   rw   r9   ry   s     r"   r   +ImportFromExternalCloudProviderStager.Stage2  sH    K499k*		;73T@B r!   c                    > U R                   R                  (       a*  [        R                  " U R                   R                  5      $ [        [
        U ]  5       $ r$   )r-   r   r   GetRegionFromZoneru   r   r  rw   ry   s    r"   r  7ImportFromExternalCloudProviderStager.GetBucketLocation=  s<    yy~~**499>>::-tr!   r   )	r   r   r   r   r   r   r  r    r   r   s   @r"   r   r   /  s    <	 r!   r   c                   >   ^  \ rS rSrSrU 4S jrS rU 4S jrSrU =r	$ )r   iE  z+Image import stager from an existing image.c                   > [        U R                  R                  U R                  SSS9  / n[        R
                  " USU R                  R                  5        U R                  R                  (       a-  [        R                  " USU R                  R                  5        O[        U R                  U5        UR                  [        [        U ]3  5       5        U$ )Nzsource-imageT)rc   rd   r   	data_disk)rk   r-   r   rb   r   r6   r  r   r:   r	  ru   r   r   r
  s     r"   r   ImportFromImageStager.StageH  s    			 K+~tyy7M7MNyy[$)):M:MN!$))[9u2D?ABr!   c                 >   [         R                  R                  U R                  R                  SS[
        R                  R                  R                  R                  0S9nUR                  5       [        UR                  5       R                  5       S-   5      S  nU$ )NrS   rT   rU   /)r   rX   rY   r-   r   r   rZ   r[   rT   r\   RelativeNamerK   Parent)rw   refsource_names      r"   _GetSourceImage%ImportFromImageStager._GetSourceImageZ  s    



"
"		#:,,1199CCD # C ""$S)B)B)Ds)J%K%MNKr!   c                    > U R                   R                  (       a*  [        R                  " U R                   R                  5      $ [        [
        U ]  5       $ r$   )r-   r   r   r  ru   r   r  r  s    r"   r  'ImportFromImageStager.GetBucketLocationd  s8    yy~~**499>>::&?AAr!   r   )
r   r   r   r   r   r   r  r  r    r   r   s   @r"   r   r   E  s    3$B Br!   r   c                   V   ^  \ rS rSrSrU 4S jrS r\R                  S 5       r	Sr
U =r$ )BaseImportFromFileStagerij  z4Abstract image import stager for import from a file.c                 n  > U R                  5         / n[        R                  " USU R                  5        U R                  R
                  (       a-  [        R                  " USU R                  R
                  5        O[        U R                  U5        UR                  [        [        U ]/  5       5        U$ )Nr   r  )
_FileStager   r6   r   r-   r  r   r:   r	  ru   r  r   r
  s     r"   r   BaseImportFromFileStager.Stagem  s    OOK +}dllCyy[$)):M:MN!$))[9u5tBDEr!   c                    U R                   R                  R                  5       R                  S5      (       a  [        R
                  " S5        OU R                   R                  R                  5       R                  S5      (       d8  U R                   R                  R                  5       R                  S5      (       a  [        R                  " S5      eU R                  5       U l	        g)z!Prepare image file for importing.z.ovazThe specified input file may contain more than one virtual disk. Only the first vmdk disk will be imported. To import a .ovacompletely, please try 'gcloud compute instances import'instead.z.tar.gzz.tgzaB  `gcloud compute images import` does not support compressed archives. Please extract your image and try again.
 If you got this file by exporting an image from Compute Engine (e.g., by using `gcloud compute images export`) then you can instead use `gcloud compute images create` to create your image from your .tar.gz file.N)
r-   r   r   endswithr   rm   r   BadFileException_CopySourceFileToScratchBucketr   r  s    r"   r!  #BaseImportFromFileStager._FileStage|  s     yy""$--f55	kk 
			$	$	&	/	/
 
				$	$	&	/	/	7	7''  668DLr!   c                     [         er$   )NotImplementedErrorr  s    r"   r&  7BaseImportFromFileStager._CopySourceFileToScratchBucket  s    
r!   )r   )r   r   r   r   r   r   r!  abcabstractmethodr&  r    r   r   s   @r"   r  r  j  s*    <9.  r!   r  c                   *    \ rS rSrSrS rS rS rSrg)r   i  z&Image import stager from a local file.c                     U R                  U R                  R                  U R                  R                  U R                  [
        R                  " 5       5      $ r$   )_UploadToGcsr-   async_r   r   uuiduuid4r  s    r"   r&  8ImportFromLocalFileStager._CopySourceFileToScratchBucket  s>    		$))//1B1BDJJL r!   c                 r   [         R                  R                  U5      R                  SS5      nSR	                  X4U5      nU(       a  [
        R                  R                  S5        [        R                  " SR	                  X&5      5         U R                  X&5      sSSS5        $ ! , (       d  f       g= f)z@Uploads a local file to GCS. Returns the gs:// URI to that file. r>   gs://{0}/tmpimage/{1}-{2}z_Async: After upload is complete, your image will be imported from Cloud Storage asynchronously.Copying [{0}] to [{1}]N)r4   pathbasenamereplacera   r   statusPrintr   ProgressTracker_UploadToGcsStorageApi)rw   is_async
local_pathr   
image_uuid	file_name	dest_paths          r"   r/  &ImportFromLocalFileStager._UploadToGcs  s      ,44S#>I+22)I 	jj8 
	)	) ''
>
 ((?
 
 
s   B((
B6c                 z    [         R                  R                  U5      nU R                  R	                  X5        U$ )zJUploads a local file to Cloud Storage using the gcloud storage api client.)r   ObjectReferenceFromUrlrt   CopyFileToGCS)rw   r@  rC  dest_objects       r"   r>  0ImportFromLocalFileStager._UploadToGcsStorageApi  s2    ..66yAK%%j>r!   r   N)	r   r   r   r   r   r&  r/  r>  r    r   r!   r"   r   r     s    .
@ r!   r   c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )r   i  z1Image import stager from a file in Cloud Storage.c                 :   > X@l         [        [        U ]  XU5        g r$   )source_file_gcs_uriru   r   rv   )rw   rt   rb   r-   r   ry   s        r"   rv   ImportFromGSFileStager.__init__  s    &	
 $0r!   c                 L    U R                   R                  U R                  5      $ r$   )rt   GetBucketLocationForFilerM  r  s    r"   r  (ImportFromGSFileStager.GetBucketLocation  s$    77   r!   c                    [         R                  R                  U R                  5      nSR	                  U R
                  [        R                  " 5       U5      n[        R                  R                  U R                  SS9n[        R                  R                  USS9n[        R                  " SR	                  U R                  U5      5         U R                  R                  X45        S S S 5        U$ ! , (       d  f       U$ = f)Nr6  zstorage.objects)rV   r7  )r4   r8  r9  rM  ra   r   r1  r2  r   rX   rY   r   r=  rt   Rewrite)rw   
image_filedest_uri
src_objectrI  s        r"   r&  5ImportFromGSFileStager._CopySourceFileToScratchBucket  s    !!$":":;J*114::<H ##))  -> * J $$**. + K 
	)	) ''(@(@(K
 !!*:
 O	
 
 Os   C66
D)rM  )
r   r   r   r   r   rv   r  r&  r    r   r   s   @r"   r   r     s    9
 r!   r   c                   N   ^  \ rS rSrSr\R                  r\U 4S j5       r	Sr
U =r$ )
ImportBetai  z6Import an image into Compute Engine for beta releases.c                 X   > [         [        U ]  U5        [        R                  " U5        g r$   )ru   rY  r   r   AddExtraCommonDaisyArgs)r   r   ry   s     r"   r   ImportBeta.Args  s     	*c'''/r!   r   )r   r   r   r   r   r   OS_CHOICES_IMAGE_IMPORT_BETAr   r   r   r    r   r   s   @r"   rY  rY    s#    >77+0 0r!   rY  c                   0    \ rS rSrSr\R                  rSrg)ImportAlphai  z7Import an image into Compute Engine for alpha releases.r   N)	r   r   r   r   r   r   OS_CHOICES_IMAGE_IMPORT_ALPHAr   r    r   r!   r"   r_  r_    s    ?88+r!   r_  z#Import an image into Compute Engineaf  
        *{command}* imports Virtual Disk images, such as VMWare VMDK files
        and VHD files, into Compute Engine.

        Importing images involves four steps:
        *  Upload the virtual disk file to Cloud Storage.
        *  Import the image to Compute Engine.
        *  Detect the OS and bootloader contained on the disk.
        *  Translate the image to make a bootable image.
        This command performs all four of these steps as required,
        depending on the input arguments specified.

        Before importing an image, set up access to Cloud Storage and grant
        required roles to the user accounts and service accounts. For more
        information, see [](https://cloud.google.com/compute/docs/import/requirements-export-import-images).

        To override the detected OS, specify the `--os` flag.
        You can omit the translation step using the `--data-disk` flag.

        If you exported your disk from Compute Engine then you don't
        need to re-import it. Instead, use `{parent_command} create`
        to create more images from the disk.

        Files stored on Cloud Storage and images in Compute Engine incur
        charges. See [](https://cloud.google.com/compute/docs/images/importing-virtual-disks#resource_cleanup).

        Troubleshooting: Image import/export tools rely on CloudBuild default
        behavior. They has been using the default CloudBuild service account in
        order to import/export images to/from Google Cloud Platform. However,
        Cloud Build has changed this default behavior and in new projects a
        custom user managed service account may need to be provided to perform
        the builds. If you get a CloudBuild service account related error, run
        gcloud with --cloudbuild-service-account=<custom service account>.
        See `gcloud compute images import --help` for details.
        a  
        To import a centos-7 VMDK file, run:

          $ {command} myimage-name --os=centos-7 --source-file=mysourcefile

        To import a data disk without operating system, run:

          $ {command} myimage-name --data-disk --source-file=mysourcefile
        )briefDESCRIPTIONEXAMPLES)rG   F)@r   
__future__r   r   r   r+  enumos.pathr4   rH   r1  googlecloudsdk.api_lib.computer   r   r   r	   googlecloudsdk.api_lib.storager
   r   googlecloudsdk.callioper   r   )googlecloudsdk.command_lib.compute.imagesr   r   googlecloudsdk.corer   r   r   googlecloudsdk.core.consoler   sixr   r   Enumr   r.   r1   r0   r:   r<   rQ   rk   ReleaseTracksr   GA	DeprecateDefaultUniverseOnlyCreateCommandrp   add_metaclassABCMetaobjectr   r   r   r  r   r   BETArY  ALPHAr_  detailed_helpr   r!   r"   <module>rz     s    &  ' 
     7 6 6 0 6 7 ( . ; @ # * ) 8 
- 
DII 

	B4J. HM#AL D%%(()		 ET E  *"EP 3;;`v `  `F,< ,"B, "BJ+/ +\ 8 >5 @ D%%**+0 0 ,0 D%%++,9* 9 -9 3"FK. r!   