def Run(self, args): """Runs the describe command.""" location = resource_args.ParseAwsNodePoolResourceArg(args).locationsId with endpoint_util.GkemulticloudEndpointOverride(location): node_pool_ref = resource_args.ParseAwsNodePoolResourceArg(args) node_pool_client = api_util.NodePoolsClient() return node_pool_client.Get(node_pool_ref)
def Run(self, args): """Runs the describe command.""" location = resource_args.ParseAzureClusterResourceArg(args).locationsId with endpoint_util.GkemulticloudEndpointOverride(location): cluster_ref = resource_args.ParseAzureClusterResourceArg(args) client = api_util.ClustersClient() return client.Get(cluster_ref)
def Run(self, args): """Runs the list command.""" location_ref = args.CONCEPTS.location.Parse() with endpoint_util.GkemulticloudEndpointOverride(location_ref.locationsId): api_client = api_util.ClustersClient() return api_client.List( location_ref, page_size=args.page_size, limit=args.limit)
def Run(self, args): """Runs the create command.""" location = resource_args.ParseAzureClientResourceArg(args).locationsId with endpoint_util.GkemulticloudEndpointOverride(location): client_ref = resource_args.ParseAzureClientResourceArg(args) api_client = api_util.ClientsClient() api_client.Create(client_ref, args) log.CreatedResource(client_ref, kind=constants.AZURE_CLIENT_KIND)
def Run(self, args): """Runs the describe command.""" with endpoint_util.GkemulticloudEndpointOverride( resource_args.ParseAzureClientResourceArg(args).locationsId, self.ReleaseTrack()): client_ref = resource_args.ParseAzureClientResourceArg(args) api_client = api_util.ClientsClient() return api_client.Get(client_ref)
def Run(self, args): """Runs the list command.""" cluster_ref = args.CONCEPTS.cluster.Parse() with endpoint_util.GkemulticloudEndpointOverride( cluster_ref.locationsId): node_pool_client = api_util.NodePoolsClient() return node_pool_client.List(cluster_ref, args.page_size, args.limit)
def Run(self, args): """Runs the describe command.""" with endpoint_util.GkemulticloudEndpointOverride( resource_args.ParseOperationResourceArg(args).locationsId, self.ReleaseTrack()): op_client = op_api_util.OperationsClient() op_ref = resource_args.ParseOperationResourceArg(args) return op_client.Get(op_ref)
def Run(self, args): """Runs the wait command.""" with endpoint_util.GkemulticloudEndpointOverride( resource_args.ParseOperationResourceArg(args).locationsId, self.ReleaseTrack()): op_client = op_api_util.OperationsClient() op_ref = resource_args.ParseOperationResourceArg(args) op_client.Wait( op_ref, 'Waiting for operation {} to complete'.format( op_ref.RelativeName())) return op_client.Get(op_ref)
def Run(self, args): """Runs the command.""" cluster_ref = args.CONCEPTS.cluster.Parse() with endpoint_util.GkemulticloudEndpointOverride(cluster_ref.locationsId): cluster_client = api_util.ClustersClient() response = cluster_client.GenerateAccessToken(cluster_ref) if args.exec_credential: return kubeconfig.ExecCredential( expiration_timestamp=response.expirationTime, access_token=response.accessToken) return response
def Run(self, args): """Runs the describe command.""" release_track = self.ReleaseTrack() location_ref = args.CONCEPTS.location.Parse() with endpoint_util.GkemulticloudEndpointOverride( location_ref.locationsId, release_track): op_client = op_api_util.OperationsClient() return op_client.List(location_ref, args.page_size, args.limit, parent_field='name')
def Run(self, args): """Runs the print-access-token command.""" with endpoint_util.GkemulticloudEndpointOverride( resource_args.ParseAzureClusterResourceArg(args).locationsId, self.ReleaseTrack()): cluster_ref = resource_args.ParseAzureClusterResourceArg(args) client = api_util.ClustersClient() response = client.GenerateAccessToken(cluster_ref) if args.exec_credential: return kubeconfig.ExecCredential( expiration_timestamp=response.expirationTime, access_token=response.accessToken) return response
def Run(self, args): """Runs the update command.""" location = resource_args.ParseAzureClusterResourceArg(args).locationsId with endpoint_util.GkemulticloudEndpointOverride(location): cluster_ref = resource_args.ParseAzureClusterResourceArg(args) cluster_client = api_util.ClustersClient() message = command_util.ClusterMessage( cluster_ref.azureClustersId, action='Updating') return command_util.Update( resource_ref=cluster_ref, resource_client=cluster_client, args=args, message=message, kind=constants.AZURE_CLUSTER_KIND)
def Run(self, args): """Run get-server-config command.""" release_track = self.ReleaseTrack() location_ref = args.CONCEPTS.location.Parse() with endpoint_util.GkemulticloudEndpointOverride( location_ref.locationsId, release_track): client = api_util.GetClientInstance(release_track=release_track) messages = api_util.GetMessagesModule(release_track=release_track) log.status.Print('Fetching server config for {location}'.format( location=location_ref.locationsId)) req = messages.GkemulticloudProjectsLocationsGetAwsServerConfigRequest( name='{}/awsServerConfig'.format(location_ref.RelativeName())) return client.projects_locations.GetAwsServerConfig(req)
def Run(self, args): """Runs the delete command.""" location = resource_args.ParseAwsNodePoolResourceArg(args).locationsId with endpoint_util.GkemulticloudEndpointOverride(location): node_pool_ref = resource_args.ParseAwsNodePoolResourceArg(args) node_pool_client = api_util.NodePoolsClient() message = command_util.NodePoolMessage( node_pool_ref.awsNodePoolsId, cluster=node_pool_ref.awsClustersId) return command_util.Delete(resource_ref=node_pool_ref, resource_client=node_pool_client, message=message, args=args, kind=constants.AWS_NODEPOOL_KIND)
def Run(self, args): """Runs the delete command.""" location = resource_args.ParseAwsClusterResourceArg(args).locationsId with endpoint_util.GkemulticloudEndpointOverride(location): cluster_ref = resource_args.ParseAwsClusterResourceArg(args) cluster_client = api_util.ClustersClient() cluster = cluster_client.Get(cluster_ref) message = command_util.ClusterMessage(cluster_ref.awsClustersId, kind=constants.AWS, region=cluster.awsRegion) return command_util.Delete(resource_ref=cluster_ref, resource_client=cluster_client, args=args, message=message, kind=constants.AWS_CLUSTER_KIND)
def Run(self, args): """Runs the get-public-cert command.""" with endpoint_util.GkemulticloudEndpointOverride( resource_args.ParseAzureClientResourceArg(args).locationsId, self.ReleaseTrack()): client_ref = resource_args.ParseAzureClientResourceArg(args) api_client = api_util.ClientsClient() client = api_client.Get(client_ref) cert = self._GetCert(client) log.WriteToFileOrStdout( args.output_file if args.output_file else '-', cert, overwrite=True, binary=False, private=True)
def Run(self, args): """Runs the create command.""" location = resource_args.ParseAzureNodePoolResourceArg( args).locationsId with endpoint_util.GkemulticloudEndpointOverride(location): node_pool_ref = resource_args.ParseAzureNodePoolResourceArg(args) node_pool_client = api_util.NodePoolsClient() message = command_util.NodePoolMessage( node_pool_ref.azureNodePoolsId, action='Creating', cluster=node_pool_ref.azureClustersId) return command_util.Create(resource_ref=node_pool_ref, resource_client=node_pool_client, args=args, message=message, kind=constants.AZURE_NODEPOOL_KIND)
def Run(self, args): """Runs the delete command.""" location = resource_args.ParseAzureClientResourceArg(args).locationsId with endpoint_util.GkemulticloudEndpointOverride(location): client_ref = resource_args.ParseAzureClientResourceArg(args) api_client = api_util.ClientsClient() api_client.Delete(client_ref, validate_only=True) console_io.PromptContinue(message=gke_util.ConstructList( 'The following Azure clients will be deleted:', [ '[{name}] in [{region}]'.format( name=client_ref.azureClientsId, region=client_ref.locationsId) for ref in [client_ref] ]), throw_if_unattended=True, cancel_on_no=True) api_client.Delete(client_ref) log.DeletedResource(client_ref, kind=constants.AZURE_CLIENT_KIND)
def Run(self, args): """Runs the get-credentials command.""" with endpoint_util.GkemulticloudEndpointOverride( resource_args.ParseAwsClusterResourceArg(args).locationsId, self.ReleaseTrack()): cluster_ref = resource_args.ParseAwsClusterResourceArg(args) cluster_client = api_util.ClustersClient() if not args.private_endpoint: kubeconfig.CheckClusterHasNodePools( api_util.NodePoolsClient(), cluster_ref) resp = cluster_client.Get(cluster_ref) kubeconfig.ValidateClusterVersion(resp) context = kubeconfig.GenerateContext('aws', cluster_ref.projectsId, cluster_ref.locationsId, cluster_ref.awsClustersId) cmd_args = kubeconfig.GenerateAuthProviderCmdArgs( 'aws', cluster_ref.awsClustersId, cluster_ref.locationsId, cluster_ref.projectsId) kubeconfig.GenerateKubeconfig(resp, context, args.auth_provider_cmd_path, cmd_args, args.private_endpoint)