
                            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  / rSrS/rS/rSr\R<                  " \R>                  R@                  \R>                  RB                  5       " S S\RD                  5      5       r#SSSS.\#l$        S r%g)z<Command for importing machine images in OVF format into GCE.    )absolute_import)division)unicode_literalsN)base_classes)daisy_utils)utils)base)
exceptions)flags)log)
console_io)resource_printerz
os-upgradezwindows-2008r2zwindows-2012r2z(The following instance will be upgraded.c                   4    \ rS rSrSr\S 5       rS rS rSr	g)	OsUpgrade/   z Upgrade a instance's OS version.c                    UR                  SS[        [        5      SS9  UR                  SS[        [        5      SS9  UR                  SSS	SS
S9  UR                  SSS	SS9  UR                  SSS	SSS9  [        R
                  " USS9  [        R                  " U5        [        R                  R                  U[        S9  g )Nz--source-osTz-OS version of the source instance to upgrade.)requiredchoiceshelpz--target-osz Version of the OS after upgrade.z--create-machine-backupF
store_truez[When enabled, a machine image is created that backs up the original state of your instance.)r   actiondefaultr   z--auto-rollbackzWhen auto rollback is enabled, the instance and its resources are restored to their original state. Otherwise, the instance and any temporary resources are left in the intermediate state of the time of failure. This is useful for debugging.)r   r   r   z--use-staging-install-mediaztUse staging install media. This flag is for testing only. Set to true to upgrade with staging windows install media.)r   r   r   hiddenz
an upgrade)	operation)operation_type)add_argumentsorted_OS_CHOICES_SOURCE_OS_CHOICES_TARGETr   AddCommonDaisyArgsAddExtraCommonDaisyArgsr   INSTANCES_ARG_FOR_OS_UPGRADEAddArgument_OS_UPGRADE_OPERATION_TYPE)clsparsers     +lib/surface/compute/os_config/os_upgrade.pyArgsOsUpgrade.Args3   s    
)*<	  >
 )*/	  1 !0  1 E	  F %C   ""6\B''/	&&229 3 ;    c                 0    [         R                  " X5        g )N)r   ValidateZone)selfargscompute_clients      r'   _ValidateArgsOsUpgrade._ValidateArgs]   s    T2r*   c                 ~   [         R                  " U R                  5       5      nUR                  nU R	                  X5        [
        R                  R                  XR                  [        R                  " U5      S9nSR                  UR                  UR                  UR                  5       5      n[        XA5        UR                  Ul        [         R"                  " S5        [$        R&                  " U[(        UU R                  5       (       a*  U R                  5       R*                  R-                  5       S9$ S S9$ )N)scope_listerz$projects/{0}/zones/{1}/instances/{2}zQUpgrading OS. This usually takes around 40 minutes but may take up to 90 minutes.)r.   output_filterinstance_urirelease_track)r   ComputeApiHolderReleaseTrackclientr0   r   r"   ResolveAsResource	resourcesinstances_flagsGetInstanceZoneScopeListerformatprojectzoneName_PromptForUpgrader   warningr   RunOsUpgradeBuild_OUTPUT_FILTERidlower)r-   r.   holderr9   refr5   s         r'   RunOsUpgrade.Run`   s   **4+<+<+>?F]]Ft$

,
,
>
>$??G ? IC :@@SXXsxxz+L c DIKK ) * (($! ''),,224	 
 %) r*    N)
__name__
__module____qualname____firstlineno____doc__classmethodr(   r0   rJ   __static_attributes__rL   r*   r'   r   r   /   s"    ('; ';R3r*   r   z!Upgrade the instances OS version.a        *{command}* upgrades the instance's OS version.

      OS Upgrade involves:
      *  Create a snapshot and/or machine image for the instance.
      *  Create an install media disk and attach it to the instance.
      *  Upgrade the OS version.
      *  Cleanup install media disk after upgrade.

      Virtual instances, snapshots, 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 upgrade a instance named `my-instance` from windows-2008r2 to windows-2012r2, run:

        $ {command} my-instance --source-os=windows-2008r2 --target-os=windows-2012r2
      )briefDESCRIPTIONEXAMPLESc                 
   Sn[         R                  " U R                  5       5      n[         R                  " U5      nSR	                  U R                  5       [        X5      5      nSR	                  XAR                  UR                  5      n[        R                  " 5       nSR	                  US9n[        R                  " XXUS9  UR                  5       n	[        R                  " U	S9(       d  [         R"                  " S5      eg	)
z0Prompts the user to confirm upgrade of instance.r@   z[{0}] in [{1}]z3The following {0} will be upgraded from {1} to {2}:z*list[title="{title}",always-display-title])title)out)messagezUpgrade aborted by user.N)r   CollectionToResourceType
CollectionCamelCaseToOutputFriendlyr>   rA   getattr	source_os	target_osioStringIOr   Printgetvaluer   PromptContinuecompute_exceptionsAbortedError)
rI   r.   
scope_nameresource_typeresource_nameprompt_itemprompt_titlebuffmtprompt_messages
             r'   rB   rB      s    *001AB-11-@- ''
GC4LM+FMM^^T^^5, 	#4;;,;O#s3<<>.		"	">	:

)
)*D
EE 
;r*   )&rQ   
__future__r   r   r   ra   googlecloudsdk.api_lib.computer   r   r   googlecloudsdk.callioper	   "googlecloudsdk.command_lib.computer
   rf   ,googlecloudsdk.command_lib.compute.instancesr   r<   ,googlecloudsdk.command_lib.compute.os_configgooglecloudsdk.corer   googlecloudsdk.core.consoler   googlecloudsdk.core.resourcer   rE   r$   r   r   _OS_UPGRADE_PROMPTReleaseTracksr8   ALPHABETACommandr   detailed_helprB   rL   r*   r'   <module>r      s    C &  ' 	 7 6 0 ( O Q > # 2 9 )     @  D%%++T->->-C-CDG G EGV 3	
	
!	 0Fr*   