
                         >   S 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
  \R                  " S5      \R                  " S5      S	.r\R                  \R                  " \R                  R                   5       " S
 S\R"                  5      5       5       r\\l        g)z6Command to create a cluster-director cluster resource.    N)utils)base)flags)logaC  
        *{command}* facilitates the creation of a cluster resource.

        There are following ways to create a cluster:
        - [Preferred] Use granular flags to define cluster specs.
        - Use --config flag with cluster specs in JSON format.

        Please refer to the examples below for more details.
        a"  
        To create a cluster `my-cluster` in location `us-central1-a` with granular flags, run the following example:

        $ {command} my-cluster --location us-central1-a         --description "My cluster description"         --labels env=prod,client=gcloud-cli         --create-network name=network0         --create-filestores name=locations/us-central1-a/instances/filestore0,tier=BASIC_HDD,capacityGb={filestoreSize},fileshare={fileshare}         --filestores locations/us-central1-a/instances/filestore1         --create-buckets name=bucket0         --buckets bucket1         --create-lustres name=locations/us-central1-a/instances/lustre0,capacityGb={lustreSize},filesystem={filesystem}         --lustres locations/us-central1-a/instances/lustre1         --reserved-instances id=compute0,machineType={machineType},reservation=zones/us-central1-a/reservations/{reservation}         --slurm-login-node machineType={machineType},zone=us-central1-a         --slurm-node-sets id=nodeset0,computeId=compute0         --slurm-partitions id=partition0,nodesetIds=[nodeset0]         --slurm-default-partition partition0         --format json

        To create a cluster `my-cluster` in location `us-central1-a` with config in JSON string format run the following example:

        $ {command} my-cluster --location=us-central1-a --config='{"key": "value"}'

        Or create a JSON file `my-cluster-config.json` with the cluster specs and run the following file example:

        $ {command} my-cluster --location=us-central1-a --config=my-cluster-config.json
        )DESCRIPTIONEXAMPLESc                   .    \ rS rSrSr\S 5       rS rSrg)CreateD   z$Creates a Cluster Director resource.c                 \   [         R                  R                  U5        [        R                  " U R                  5       5      n[        R                  " XS9  UR                  SSSS9n[        R                  " X2S9  UR                  SS9n[        R                  " XBS9  [        R                  " XBS9  UR                  SSSS9n[        R                  " XRS9  UR                  S	S9n[        R                  " XbSS
9  [        R                  " XbSS
9  [        R                   " XBS9  [        R"                  " XBS9  [        R$                  " XBS9  [        R&                  " XBS9  [        R(                  " XBS9  [        R*                  " XBS9  [        R,                  " XBS9  [        R.                  " XBS9  [        R0                  " XBS9  [        R2                  " XBS9  [        R4                  " XBSS
9  [        R6                  " XBSS
9  [        R8                  " XBSS
9  [        R:                  " XBS9  g)zbSpecifies command flags.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
)parserapi_versionz'Cluster configuration for provisioning.T)helpmutexrequiredz+Flag Configurations to define cluster spec.)r   z&Network configuration for the cluster.)r   r   r   z/Use an existing network source for the cluster.)r   r   r   N)r   
ASYNC_FLAGAddToParser	api_utilsGetApiVersionReleaseTrackr   AddClusterNameArgToParser	add_groupr   	AddConfigAddDescription	AddLabelsAddCreateNetworkAddNetworkSourceAddSubnetSourceAddCreateFilestoresAddFilestoresAddCreateGcsBucketsAddGcsBucketsAddCreateLustres
AddLustresAddOnDemandInstancesAddSpotInstancesAddReservedInstancesAddDwsFlexInstancesAddSlurmLoginNodeAddSlurmNodeSetsAddSlurmPartitionsAddSlurmDefaultPartition)clsr   r   group
flag_groupnetwork_groupnetwork_source_groups          /lib/surface/cluster_director/clusters/create.pyArgsCreate.ArgsI   s    	OO'))#*:*:*<=K	##6K6  E
 
OO5:: ! J 

D	OO:?((5 ) M
 
-I(22> 3  
#t 
#t 
ZI	zC	ZI	zC	*F	J@	jJ	*F	jJ	ZI	T 
T 
T 
""*N    c                 J   U R                  5       n[        R                  " U5      n[        R                  " U5      n[        R
                  " XS9nUR                  nUR                  S5      (       a  UR                  5       nOUR                  5       nUR                  R                  UR                  UR                  5       R                  5       UR                  5       US95      n[         R"                  R%                  SR'                  UR                  5       5      5        UR(                  (       a  U$ [        R*                  " UUSR'                  UR,                  5      SS9n	[         R"                  R%                  SR'                  UR                  5       5      5        U	$ )	zConstructs and sends request.

Args:
  args: argparse.Namespace, An object that contains the values for the
    arguments specified in the .Args() method.

Returns:
  ProcessHttpResponse of the request made.
)argsmessage_moduleconfig)parent	clusterIdclusterz Create request issued for: [{0}]z'Waiting for operation [{0}] to completei   )client	operationmessagemax_wait_seczCreated cluster [{0}].)r   r   GetClientInstanceGetMessagesModuler   ClusterUtilcluster_refIsSpecifiedMakeClusterFromConfigMakeClusterprojects_locations_clustersr
   9HypercomputeclusterProjectsLocationsClustersCreateRequestParentRelativeNameNamer   statusPrintformatasync_WaitForOperationname)
selfr7   release_trackr=   messagescluster_utilrD   r<   r>   responses
             r2   Run
Create.Run   s`    %%'M((7F**=9H$$$HL**K!!224g((*g2299JJ%%'446!&&( 	K 	
I JJ*11+2B2B2DE {{))9@@NN
 H JJ-44[5E5E5GHIOr5    N)	__name__
__module____qualname____firstlineno____doc__classmethodr3   rX   __static_attributes__rZ   r5   r2   r
   r
   D   s!     -6O 6Op+r5   r
   )r_   textwrap*googlecloudsdk.api_lib.hypercomputeclusterr   r   googlecloudsdk.callioper   4googlecloudsdk.command_lib.cluster_director.clustersr   googlecloudsdk.corer   dedentDETAILED_HELPDefaultUniverseOnlyReleaseTracksr   ALPHACreateCommandr
   detailed_helprZ   r5   r2   <module>rn      s     =  I ( F F # ?? $   ! &R D%%++,gT g - gT % r5   