/** * Update a node pool and waits until the work request finished * * @param containerEngineClient the service client to use to update the node pool * @param nodePoolId the node pool ID * @param newNodePoolName The new node pool name * */ private static async Task UpdateNodePool(ContainerEngineClient containerEngineClient, string nodePoolId, string newDisplayName) { var updateNodePoolDetails = new UpdateNodePoolDetails { Name = newDisplayName }; var updateNodePoolRequest = new UpdateNodePoolRequest { NodePoolId = nodePoolId, UpdateNodePoolDetails = updateNodePoolDetails }; var updateNodePoolResponse = await containerEngineClient.UpdateNodePool(updateNodePoolRequest); string workRequestId = updateNodePoolResponse.OpcWorkRequestId; var workRequestResponse = WaitForWorkRequestFinished(containerEngineClient, workRequestId); GetNodePoolRequest getNodePoolRequest = new GetNodePoolRequest { NodePoolId = nodePoolId }; GetNodePoolResponse getNodePoolResponse = await containerEngineClient.GetNodePool(getNodePoolRequest); NodePool nodePool = getNodePoolResponse.NodePool; logger.Info($"Node pool name changed to {nodePool.Name}"); }
/// <summary> /// Get the details of a node pool. /// </summary> /// <param name="request">The request object containing the details to send. Required.</param> /// <param name="retryConfiguration">The retry configuration that will be used by to send this request. Optional.</param> /// <param name="cancellationToken">The cancellation token to cancel this operation. Optional.</param> /// <returns>A response object containing details about the completed operation</returns> /// <example>Click <a href="https://docs.cloud.oracle.com/en-us/iaas/tools/dot-net-examples/latest/containerengine/GetNodePool.cs.html">here</a> to see an example of how to use GetNodePool API.</example> public async Task <GetNodePoolResponse> GetNodePool(GetNodePoolRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default) { logger.Trace("Called getNodePool"); Uri uri = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/nodePools/{nodePoolId}".Trim('/'))); HttpMethod method = new HttpMethod("GET"); HttpRequestMessage requestMessage = Converter.ToHttpRequestMessage(uri, method, request); requestMessage.Headers.Add("Accept", "application/json"); GenericRetrier retryingClient = Retrier.GetPreferredRetrier(retryConfiguration, this.retryConfiguration); HttpResponseMessage responseMessage; try { if (retryingClient != null) { responseMessage = await retryingClient.MakeRetryingCall(this.restClient.HttpSend, requestMessage, cancellationToken).ConfigureAwait(false); } else { responseMessage = await this.restClient.HttpSend(requestMessage).ConfigureAwait(false); } this.restClient.CheckHttpResponseMessage(requestMessage, responseMessage); return(Converter.FromHttpResponseMessage <GetNodePoolResponse>(responseMessage)); } catch (Exception e) { logger.Error($"GetNodePool failed with error: {e.Message}"); throw; } }
protected override void ProcessRecord() { base.ProcessRecord(); GetNodePoolRequest request; try { request = new GetNodePoolRequest { NodePoolId = NodePoolId, OpcRequestId = OpcRequestId }; response = client.GetNodePool(request).GetAwaiter().GetResult(); WriteOutput(response, response.NodePool); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/** * Creates a node pool in a cluster and waits until the work request finished * * @param containerEngineClient the containerEngineclient used to create the node pool * @param compartmentId The compartment ID * @param clusterId The ID of the cluster that the node pool is added in * @param displayName The display name of the node pool * @param kubernetesVersion kubernetesVersion * @param nodeImageName The image to use on each node in the node pool * @param nodeShape The number of CPUs and the amount of memory allocated to each node in the node pool * @param initialNodeLabels The initial node label * @param nodePoolNodeConfigDetails The node pool size and the placementConfig of nodes. * @return the created node pool */ private static async Task <NodePool> CreateNodePool(ContainerEngineClient containerEngineClient, string compartmentId, string clusterId, string displayName, string kubernetesVersion, string nodeImageName, string nodeShape, List <KeyValue> initialNodeLabels, CreateNodePoolNodeConfigDetails nodePoolNodeConfigDetails) { var createNodePoolDetails = new CreateNodePoolDetails { CompartmentId = compartmentId, ClusterId = clusterId, Name = displayName, KubernetesVersion = kubernetesVersion, NodeImageName = nodeImageName, InitialNodeLabels = initialNodeLabels, NodeConfigDetails = nodePoolNodeConfigDetails, NodeShape = nodeShape }; var createNodePoolRequest = new CreateNodePoolRequest { CreateNodePoolDetails = createNodePoolDetails }; var createNodePoolResponse = await containerEngineClient.CreateNodePool(createNodePoolRequest); string workRequestId = createNodePoolResponse.OpcWorkRequestId; logger.Info($"Create node pool work request ID: {workRequestId}"); GetWorkRequestResponse workRequestResponse = WaitForWorkRequestFinished(containerEngineClient, workRequestId); var nodePoolId = GetWorkRequestResourceId(workRequestResponse, "nodepool"); logger.Info($"Node pool ID is {nodePoolId}"); GetNodePoolRequest getNodePoolRequest = new GetNodePoolRequest { NodePoolId = nodePoolId }; GetNodePoolResponse getNodePoolResponse = await containerEngineClient.GetNodePool(getNodePoolRequest); return(getNodePoolResponse.NodePool); }