
    IU                     >   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ ddl
mZ dd	lmZ ddlmZ dd
lmZ ddlmZ ddlmZ dddZd Zej.                   ej0                  ej2                  j4                        ej6                   G d dej8                                             Z ej0                  ej2                  j<                         G d de             Z ej0                  ej2                  j@                         G d de             Z!ee_"        y)zUpdate node pool command.    )absolute_import)division)unicode_literals)
exceptions)utils)api_adapter)util)base)flags)log)
console_iozW        *{command}* updates a node pool in a Google Kubernetes Engine cluster.
        z        To turn on node autoupgrade in "node-pool-1" in the cluster
        "sample-cluster", run:

          $ {command} node-pool-1 --cluster=sample-cluster --enable-autoupgrade
        )DESCRIPTIONEXAMPLESc                     t        j                  | d       t        j                  | d       t        j                  |        | j	                  dt
        ddd       y)	zRegister flags for this command.

  Args:
    parser: An argparse.ArgumentParser-like object. It is mocked out in order to
      capture some information, but behaves like an ArgumentParser.
  zThe name of the node pool.zThe name of the cluster.z	--timeouti  TzTHIS ARGUMENT NEEDS HELP TEXT.)typedefaulthiddenhelpN)r   AddNodePoolNameArgAddNodePoolClusterFlagAddAsyncFlagadd_argumentint)parsers    *lib/surface/container/node_pools/update.py_Argsr   .   sV     6#?@v'ABV+  -    c                   ,    e Zd ZdZed        Zd Zd Zy)Update)Updates a node pool in a running cluster.c                    t        |        | j                  d      }t        j                  |       |j	                  d      }t        j
                  |d       t        j                  |d       t        j                  |dddd       t        j                  |      }t        j                  |d       t        j                  |       |j	                  d      }t        j                  |       t        j                  |d       t        j                  |d       t        j                  |       t        j                  |d       t        j                   |       t        j"                  |d       t        j$                  |d       t        j&                  |d       t        j(                  |dd	       t        j*                  |dd	       t        j,                  |       t        j.                  |       t        j0                  |d       t        j2                  |dd
       t        j4                  |dd
       t        j6                  |d       t        j8                  |       t        j:                  |       t        j<                  |d       t        j>                  |       t        j@                  |       t        jB                  |dd       t        jD                  |       t        jF                  |       t        jH                  |       t        jJ                  |       t        jL                  |       |j	                  d      }t        jN                  |d       t        jP                  |       t        jR                  |       t        jT                  |       t        jV                  |       y )NTrequiredNode managementfor_node_poolFenable_gpu_partitionenable_gpu_sharingenable_gpu_driver_installationr   r   Upgrade settingsr&   
for_updater&   	is_updater&   
for_createNode configupdate),r   add_mutually_exclusive_groupr   AddNodePoolLocationsFlagadd_argument_groupAddEnableAutoRepairFlagAddEnableAutoUpgradeFlagAddAcceleratorArgsAddClusterAutoscalingFlagsAddNodePoolAutoprovisioningFlagAddWorkloadMetadataFlagAddEnableSurgeUpgradeFlagAddSurgeUpgradeFlagAddMaxUnavailableUpgradeFlagAddEnableBlueGreenUpgradeFlagAddStandardRolloutPolicyFlagAddAutoscaledRolloutPolicyFlagAddNodePoolSoakDurationFlagAddSystemConfigFlagAddLabelsFlagAddNodeLabelsFlagAddNodeTaintsFlagAddTagsNodePoolUpdateAddEnableGvnicFlagAddEnableImageStreamingFlagAddEnableConfidentialNodesFlagAddConfidentialNodeTypeFlag AddNetworkPerformanceConfigFlagsAddNodePoolEnablePrivateNodesAddEnableFastSocketFlagAddLoggingVariantFlagAddWindowsOsVersionFlagAddContainerdConfigFlagAddStoragePoolsFlag$AddResourceManagerTagsNodePoolUpdateAddQueuedProvisioningFlagAddMaxRunDurationFlagAddFlexStartFlag AddEnableKubeletReadonlyPortFlagAddMachineTypeFlagAddDiskTypeFlagAddDiskSizeFlag$AddBootDiskProvisionedThroughputFlagAddBootDiskProvisionedIopsFlagr   groupnode_management_groupautoscaling_groupupgrade_settings_groupnode_config_groups         r   ArgszUpdate.ArgsG   s   	&M///>E	""5)!445FG	!!"7tL	""#8M	!'+ 88?	))*;EJ	!!%("556HI	##$:;	4DI	&&d4 
''(>?	&&d4	(()?@	%%d4 
eE2	T2	E$G	E$G	&	U#	%%e4@	((TT3	%%e44P	**5?	''.	!!%(	T:	!!%(	!!%(	Te5	..u5	##E*	&	5!	**5100?	.t<	+,	+,	../@A	(():;r   c           	      @   t        j                  |       t        j                  d0i d|j                  d|j
                  d|j                  d|j                  d|j                  d|j                  d|j                  d|j                  d	|j                  d
|j                  d|j                  d|j                  d|j                   d|j"                  d|j$                  d|j&                  d|j(                  d|j*                  d|j,                  d|j.                  d|j0                  d|j2                  d|j4                  d|j6                  d|j8                  d|j:                  d|j<                  d|j>                  d|j@                  d|jB                  d|jD                  d |jF                  d!|jH                  d"|jJ                  d#|jL                  d$|jN                  d%|jP                  d&|jR                  d'|jT                  d(|jV                  d)|jX                  d*|jZ                  d+t]        |d,      rt_        j`                  |jb                        nd d-|jd                  d.|jf                  d/|jh                  S )1Nacceleratorsenable_autorepairenable_autoupgradeenable_autoscalingnode_locations	max_nodes	min_nodestotal_max_nodestotal_min_nodeslocation_policyworkload_metadataworkload_metadata_from_nodeenable_autoprovisioningmax_surge_upgrademax_unavailable_upgradesystem_config_from_filelabelsnode_labelsnode_taintstagsgvnicenable_image_streamingnetwork_performance_configenable_confidential_nodesconfidential_node_typeenable_blue_green_upgradeenable_surge_upgradenode_pool_soak_durationstandard_rollout_policyautoscaled_rollout_policyenable_private_nodesenable_fast_socketlogging_variantwindows_os_versioncontainerd_config_from_filestorage_poolsenable_queued_provisioningmax_run_duration
flex_startmachine_type	disk_type%enable_insecure_kubelet_readonly_portdisk_size_gb	disk_sizeresource_manager_tagsboot_disk_provisioned_iops boot_disk_provisioned_throughput )5r   ValidateSurgeUpgradeSettingsr   UpdateNodePoolOptionsacceleratorri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   enable_gvnicr}   network_performance_configsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   hasattrr   	BytesToGbr   r   r   r   )selfargss     r   ParseUpdateNodePoolOptionsz!Update.ParseUpdateNodePoolOptions   s(   	&&t,,, 1%%1001  221  22	1
 **1 ..1 ..1 ,,1 ,,1 ,,1 001 %)$D$D1 !% < <1 001 !% < <1  !% < <!1" {{#1$ $$%1& $$'1( YY)1* +1,  $::-1. $(#C#C/10 #'"@"@112  $::314 #'"@"@516 "66718 !% < <91: !% < <;1< #'"@"@=1> "66?1@  22A1B ,,C1D  22E1F %)$D$DG1H ((I1J $(#B#BK1L ..M1N ??O1P &&Q1R ..S1T /3.X.XU1X 4% __T^^4[1\ #88]1^ $(#B#B_1` *.)N)Na1 1r   c                    | j                   d   }| j                   d   } ||      }|j                  |j                  |      }| j                  |      }|j                  7t        j                  dj                  |j                  d            dd       |j                  7t        j                  d	j                  |j                  d
            dd       |j                  7t        j                  dj                  |j                  d            dd       |j                  rt        j                  |j                         	 |j                  ||      }|j                   r9|j#                  |      }|j%                  d      st        j&                  |_        |S |j)                  |dj                  |j*                        |j,                         |j/                  |      }	t        j0                  |	       t=        j>                  |       |	S # t2        j4                  $ r)}
t7        j8                  |
t        j:                        d}
~
ww xY w)a4  This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      Cluster message for the successfully updated node pool.

    Raises:
      util.Error, if creation failed.
    r   location_getNzSThe previous user-specified labels on this node pool will be replaced by '{labels}'ry   )rx   T)messagethrow_if_unattendedcancel_on_nozSThe previous user-specified taints on this node pool will be replaced by '{taints}'rz   )taintszOThe previous user-specified tags on this node pool will be replaced by '{tags}'r{   )r{   formatzUpdating node pool {0})	timeout_s) contextParseNodePoolnamer   ry   r   PromptContinuer   GetValuerz   r{   r}   r	   2CheckForContainerFileSystemApiEnablementWithPrompt	projectIdUpdateNodePoolasync_GetOperationIsSpecifiedOPERATIONS_FORMATWaitForOperation
nodePoolIdtimeoutGetNodePoolCheckForCgroupModeV1apitools_exceptions	HttpErrorr   HttpExceptionHTTP_ERROR_FORMATr   UpdatedResource)r   r   adapterr   locationpool_refoptionsoperation_refoppoolerrors              r   Runz
Update.Run   s    ll=)G<</LD!H$$TYY9H--d3G&)*0&}5 +1 +7" &)*0&}5 +1 +7" ||,-3Vv9NV-O"	 %%
==


D,,Xw?m	!!-0)..$+	

"
)
)(*=*=
>LL  "   *d
% !K	 (( D$$UD,B,BCCDs    	AH  AH I'$IIN)__name__
__module____qualname____doc__staticmethodrf   r   r   r   r   r   r   r   A   s&     2>< ><@4lDr   r   c                   &    e Zd ZdZed        Zd Zy)
UpdateBetar    c                    t        |        | j                  d      }|j                  d      }t        j                  |d       t        j
                  |d       t        j                  |dddd       t        j                  |      }t        j                  |d       |j                  d      }t        j                  |       t        j                  |d       t        j                  |d       t        j                  |       t        j                  |d       t        j                  |       t        j                  |d       t        j                   |d	       t        j"                  |       t        j$                  |d       t        j&                  |d       t        j(                  |dd
       t        j*                  |dd
       t        j,                  |       t        j.                  |       t        j0                  |d       t        j2                  |       t        j4                  |d       t        j6                  |d       t        j8                  |dd       t        j:                  |dd       t        j<                  |       t        j>                  |d       t        j@                  |       t        jB                  |       t        jD                  |       t        jF                  |dd       t        jH                  |       t        jJ                  |       t        jL                  |       t        jN                  |       |j                  d      }t        jP                  |d       t        jR                  |       t        jT                  |       t        jV                  |       t        jX                  |       y NTr"   r$   r%   Fr'   r+   r,   )use_moder-   r/   r1   r3   r4   -r   r6   r8   r   r9   r:   r;   r<   r=   r?   r@   rA   rB   rC   rD   rE   r>   r7   rF   rG   rH   rI   rJ   rP   AddEnableGcfsFlagrK   rL   rO   rM   rN   rQ   rR   rS   rV   rT   rU   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   s         r   rf   zUpdateBeta.Args	     	&M///>E!445FG	!!"7tL	""#8M	!'+ 88?	))*;EJ"556HI	##$:;	4DI	&&d4 
''(>?	&&d4	(()?@	%%d4 
!!%%8	""5)	eE2	T2	E$G	E$G	&	''.	E6	U#	%%e4@	**5?	((TT3	%%e44P	!!%(	T:	!!%(	..u5	!!%(	Te5	##E*	&	5!	**5100?	.t<	+,	+,	../@A	(():;r   c           	      ^   t        j                  |       t        j                  d1i d|j                  d|j
                  d|j                  d|j                  d|j                  d|j                  d|j                  d|j                  d	|j                  d
|j                  d|j                  d|j                  d|j                   d|j"                  d|j$                  d|j&                  d|j(                  d|j*                  d|j,                  d|j.                  d|j0                  d|j2                  d|j4                  d|j6                  d|j8                  d|j:                  d|j<                  d|j>                  d|j@                  d|jB                  d|jD                  d |jF                  d!|jH                  d"|jJ                  d#|jL                  d$|jN                  d%|jP                  d&|jR                  d'|jT                  d(|jV                  d)|jX                  d*|jZ                  d+|j\                  d,|j^                  d-ta        |d.      rtc        jd                  |jf                        nd d/|jh                  d0|jj                  }|S 2Nrh   ri   rj   rk   rm   rn   ro   rp   rq   rt   rr   rs   rl   ru   rv   rw   rx   ry   rz   r{   r   enable_gcfsr|   r}   r   r   r   r   r   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   6r   r   r   r   r   ri   rj   rk   rm   rn   ro   rp   rq   rt   rr   rs   rl   ru   rv   rw   rx   ry   rz   r{   r   r   r   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   opss      r   r   z%UpdateBeta.ParseUpdateNodePoolOptionsN  ?   	&&t,

+
+ 2%%2002  222  22	2
 ..2 ..2 ,,2 ,,2 ,,2 !% < <2 002 %)$D$D2 **2 002 !% < <2  !% < <!2" {{#2$ $$%2& $$'2( YY)2* "66+2, $$-2. /20  $::122 #'"@"@324 "66526 !% < <728 !% < <92: #'"@"@;2< $(#C#C=2> #'"@"@?2@  $::A2B  22C2D ,,E2F  22G2H #88I2J %)$D$DK2L ((M2N $(#B#BO2P ..Q2R ??S2T &&U2V ..W2X /3.X.XY2\ 4% __T^^4_2` $(#B#Ba2b *.)N)Nc2Cf Jr   Nr   r   r   r   r   rf   r   r   r   r   r   r         1B< B<H6r   r   c                   &    e Zd ZdZed        Zd Zy)UpdateAlphar    c                    t        |        | j                  d      }|j                  d      }t        j                  |d       t        j
                  |d       t        j                  |dddd       t        j                  |      }t        j                  |d       |j                  d      }t        j                  |       t        j                  |d       t        j                  |d       t        j                  |       t        j                  |d       t        j                  |       t        j                  |d       t        j                   |d	       t        j"                  |       t        j$                  |d       t        j&                  |d       t        j(                  |dd
       t        j*                  |dd
       t        j,                  |       t        j.                  |       t        j0                  |d       t        j2                  |       t        j4                  |d       t        j6                  |d       t        j8                  |dd       t        j:                  |dd       t        j<                  |       t        j>                  |d       t        j@                  |       t        jB                  |       t        jD                  |       t        jF                  |dd       t        jH                  |       t        jJ                  |       t        jL                  |       t        jN                  |       |j                  d      }t        jP                  |d       t        jR                  |       t        jT                  |       t        jV                  |       t        jX                  |       y r   r   r`   s         r   rf   zUpdateAlpha.Args  r   r   c           	      ^   t        j                  |       t        j                  d1i d|j                  d|j
                  d|j                  d|j                  d|j                  d|j                  d|j                  d|j                  d	|j                  d
|j                  d|j                  d|j                  d|j                   d|j"                  d|j$                  d|j&                  d|j(                  d|j*                  d|j,                  d|j.                  d|j0                  d|j2                  d|j4                  d|j6                  d|j8                  d|j:                  d|j<                  d|j>                  d|j@                  d|jB                  d|jD                  d |jF                  d!|jH                  d"|jJ                  d#|jL                  d$|jN                  d%|jP                  d&|jR                  d'|jT                  d(|jV                  d)|jX                  d*|jZ                  d+|j\                  d,|j^                  d-ta        |d.      rtc        jd                  |jf                        nd d/|jh                  d0|jj                  }|S r   r   r   s      r   r   z&UpdateAlpha.ParseUpdateNodePoolOptions  r   r   Nr   r   r   r   r   r     r   r   r   N)#r   
__future__r   r   r   apitools.base.pyr   r   googlecloudsdk.api_lib.computer    googlecloudsdk.api_lib.containerr   r	   googlecloudsdk.callioper
   $googlecloudsdk.command_lib.containerr   googlecloudsdk.corer   googlecloudsdk.core.consoler   DETAILED_HELPr   DefaultUniverseOnlyReleaseTracksReleaseTrackGAUniverseCompatibleUpdateCommandr   BETAr   ALPHAr   detailed_helpr   r   r   <module>r      s     &  ' > 0 8 1 ( . 6 # 2		-& D%%(()~T ~  * ~B D%%**+~ ~ ,~B D%%++,~& ~ -~B % r   