
    )!                     V   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  SSKJr  SSKJr  / SQr\R.                  " \R0                  R2                  5      \R4                  " SSSS9\R6                   " S S\R8                  5      5       5       5       r\R.                  " \R0                  R<                  5       " S S\5      5       r\R.                  " \R0                  R@                  5       " S S\5      5       r!SSSS.\l"        g)z<Command for importing machine images in OVF format into GCE.    )base_classes)daisy_utils)image_utils)base)
exceptions)
completers)flags)
os_choices)labels_util)log)	resources)z[Daisyz[import-zstarting buildz  importERRORFzThis command is being deprecated. Instead, use the `gcloud migration vms machine-image-imports` command. For more information, See "gcloud alpha migration vms machine-image-imports --help".zThis command has been deprecated. Instead, use the `gcloud migration vms machine-image-imports` command. For more information, See "gcloud alpha migration vms machine-image-imports --help".)
is_removedwarningerrorc                   H    \ rS rSrSr\S 5       r\S	S j5       rS rS r	Sr
g)
Import#   z4Import a machine image into Compute Engine from OVF.c                    U R                  SS9nUR                  R                  nUR                  R	                  [
        R                  5        [
        R                  " 5       [        l	        [        R                  R                  USS9  UR                  SSS9  [        R                  " US5        [        R                  " US	5        [
        R                  " U5        [
        R                   " U5        [
        R"                  " U5        [
        R$                  " U5        [
        R&                  " U5        [(        R*                  " U5        [(        R,                  " U5        [.        R0                  " U5        [2        R4                  " US
S9  [2        R6                  " U5        [8        R:                  " X5        UR                  SS[=        [>        R@                  5      SS9  [2        RB                  " U5        [        RD                  " US	SS[        RF                  -   S9  [2        RH                  " US	5        UR                  RK                  [L        RN                  5        [2        RP                  " USSS9  [2        RR                  " US[2        RT                  5        [2        RV                  " US[2        RX                  5        [(        RZ                  " USSSS	S9  UR                  SSSSS9  g )NT)no_httpimport)operation_typez--descriptionz2Specifies a text description of the machine image.)helpzmachine image'szmachine imagez	an import)	operationz--osFz5Specifies the OS of the machine image being imported.)requiredchoicesr   z>The zone in which to perform the import of the machine image. )explanationzmachine image importzyhttps://cloud.google.com/nat/docs/gce-example#create-nat and https://cloud.google.com/vpc/docs/private-access-options#pga)docs_urlay  However, if neither `--scopes` nor `--no-scopes` are specified and the project has no default service account, then the machine image is imported with no scopes. Note that the level of access that a service account has is determined by a combination of access scopes and IAM roles so you must configure both access scopes and IAM roles for the service account to work properly.r   )extra_scopes_helpr   resourcez--cmd-deprecated
store_trueaE  
        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.
        )actionr   r   )._GetComputeApiHolderclientmessagesdisplay_info	AddFormatmachine_image_flagsDEFAULT_LIST_FORMATMakeMachineImageArgr   MACHINE_IMAGE_ARGAddArgumentadd_argumentr	   AddStorageLocationFlagAddGuestFlushFlagAddNoRestartOnFailureArgsAddTagsArgsAddCanIpForwardArgsAddNetworkArgsAddNetworkTierArgsinstances_flagsAddMachineTypeArgsAddCustomMachineTypeArgsr   AddCreateLabelsFlagsr   AddCommonDaisyArgsAddOVFSourceUriArgr   AddGuestOsFeaturesArgForImportsortedr
   OS_CHOICES_INSTANCE_IMPORT_BETA
AddByolArgAddZoneFlagZONE_PROPERTY_EXPLANATIONAddGuestEnvironmentArgAddCacheUpdaterr   InstancesCompleterAddNoAddressArgAddComputeServiceAccountArg(IMPORT_ROLES_FOR_COMPUTE_SERVICE_ACCOUNTAddCloudBuildServiceAccountArg+IMPORT_ROLES_FOR_CLOUDBUILD_SERVICE_ACCOUNTAddServiceAccountAndScopeArgs)clsparsercompute_holderr%   s       ,lib/surface/compute/machine_images/import.pyArgsImport.Args5   sr   --d-;N$$--H
!!"5"I"IJ2FFHF
(((I
A  C 
  ):;	FO411&9##F+++F3&&v.**62&&v.,,V4$$V,""6[A""6*..v@
zAABD	  F
 6"	T

)
)*	+ &&v?
''
(E(EFO	Q ++&<<> ..??
 11   " 	  
    c                 L    [         R                  " U R                  5       U5      $ N)r   ComputeApiHolderReleaseTrack)rJ   r   s     rM   r#   Import._GetComputeApiHolder   s    (()9)9);WEErP   c                 ^   [         R                  " U5        [         R                  " U5        [        R                  " X5        [         R
                  " U5         [        R                  " UR                  5      Ul        g ! [        R                   a    [        R                  " SS5      ef = f)Nz
source-uriz;must be a path to an object or a directory in Cloud Storage)r5   ValidateNicFlagsValidateNetworkTierArgsr   ValidateZone"ValidateServiceAccountAndScopeArgs
MakeGcsUri
source_urir   UnknownCollectionExceptionr   InvalidArgumentException)selfargscompute_clients      rM   _ValidateArgsImport._ValidateArgs   s    $$T*++D1T266t<I#..t?do// I//

GI IIs   %B   ,B,c                 L   U R                  5       nUR                  nU R                  X5        [        R                  " S5        [
        R                  " U[        U R                  5       (       a(  U R                  5       R                  R                  5       OS UR                  S9$ )NzeImporting OVF. This may take 40 minutes for smaller OVFs and up to a couple of hours for larger OVFs.)r`   output_filterrelease_trackr%   )r#   r$   rb   r   r   r   RunMachineImageOVFImportBuild_OUTPUT_FILTERrT   idlowerr%   )r_   r`   rL   ra   s       rM   Run
Import.Run   s    ..0N#**Nt,KK ? @ 44$++-- ((*--33537((* *rP    N)F)__name__
__module____qualname____firstlineno____doc__classmethodrN   r#   rb   rk   __static_attributes__rm   rP   rM   r   r   #   s=      =P Pd F F
I*rP   r   c                   6   ^  \ rS rSrSr\U 4S j5       rSrU =r$ )
ImportBeta   z=Import a machine image into Compute Engine from OVF for Beta.c                 X   > [         [        U ]  U5        [        R                  " U5        g rR   )superrv   rN   r   AddExtraCommonDaisyArgsrJ   rK   	__class__s     rM   rN   ImportBeta.Args   s     	*c'''/rP   rm   	rn   ro   rp   rq   rr   rs   rN   rt   __classcell__r|   s   @rM   rv   rv      s    E0 0rP   rv   c                   6   ^  \ rS rSrSr\U 4S j5       rSrU =r$ )ImportAlpha   z>Import a machine image into Compute Engine from OVF for Alpha.c                 X   > [         [        U ]  U5        [        R                  " U5        g rR   )ry   r   rN   r   rz   r{   s     rM   rN   ImportAlpha.Args   s     	+s (''/rP   rm   r~   r   s   @rM   r   r      s    F0 0rP   r   zOCreate a Compute Engine machine image from virtual appliance in OVA/OVF format.a          *{command}* creates Compute Engine machine image from virtual appliance
        in OVA/OVF format.

        Importing OVF involves:
        *  Unpacking OVF package (if in OVA format) to Cloud Storage.
        *  Import disks from OVF to Compute Engine.
        *  Translate the boot disk to make it bootable in Compute Engine.
        *  Create a machine image using OVF metadata and imported disks.

        Virtual instances, images, machine images, and disks in Compute engine
        and files stored on Cloud Storage incur charges. See [](https://cloud.google.com/compute/docs/images/importing-virtual-disks#resource_cleanup).
        z        To import an OVF package from Cloud Storage into a machine image named
        `my-machine-image`, run:

          $ {command} my-machine-image --source-uri=gs://my-bucket/my-dir
        )briefDESCRIPTIONEXAMPLESN)#rr   googlecloudsdk.api_lib.computer   r   r   googlecloudsdk.callioper   r   "googlecloudsdk.command_lib.computer   r	   )googlecloudsdk.command_lib.compute.imagesr
   ,googlecloudsdk.command_lib.compute.instancesr5   1googlecloudsdk.command_lib.compute.machine_imagesr(   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   rh   ReleaseTracksrT   GA	DeprecateDefaultUniverseOnlyCreateCommandr   BETArv   ALPHAr   detailed_helprm   rP   rM   <module>r      s    C 8 6 6 ( . 9 4 @ Q Z < # )N D%%(()	>
	> t*T t*  *t*n D%%**+0 0 ,0 D%%++,0& 0 -0			' rP   