From 90a23d0b3a9b965ec4b11087593c4943f2ca914e Mon Sep 17 00:00:00 2001 From: Amrutha Ramanathan <105342664+ramrutha497@users.noreply.github.com> Date: Thu, 4 Jul 2024 00:29:18 +0530 Subject: [PATCH] (Ocean/GKE) - Add `initial_nodes` option to GKE (#178) --- CHANGELOG.md | 4 ++++ docs/clients/ocean/ocean_gcp_client.md | 4 +++- spotinst_sdk2/clients/ocean/__init__.py | 14 +++++++++++--- spotinst_sdk2/version.py | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35890561..df4270c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [3.10.0] - 2024-07-04 +### Added +- Added `initialNodes` query parameter for Ocean GKE `create_virtual_node_group` API. + ## [3.9.1] - 2024-06-28 ### Fixed - Made few parameter objects in `create_right_sizing_rule` to optional (For internal use only). diff --git a/docs/clients/ocean/ocean_gcp_client.md b/docs/clients/ocean/ocean_gcp_client.md index 897feb27..65d11265 100644 --- a/docs/clients/ocean/ocean_gcp_client.md +++ b/docs/clients/ocean/ocean_gcp_client.md @@ -202,7 +202,8 @@ __Returns__

create_virtual_node_group

```python -OceanGcpClient.create_virtual_node_group(vng: VirtualNodeGroup) +OceanGcpClient.create_virtual_node_group(vng: VirtualNodeGroup, + initial_nodes: int = None) ``` Create a virtual node group. @@ -210,6 +211,7 @@ Create a virtual node group. __Arguments__ - __vng (VirtualNodeGroup)__: VirtualNodeGroup Object +- __initial_nodes__: When set to an integer greater than 0, a corresponding number of nodes will be launched from the virtual node group created. __Returns__ diff --git a/spotinst_sdk2/clients/ocean/__init__.py b/spotinst_sdk2/clients/ocean/__init__.py index d8b6941b..530ef49d 100644 --- a/spotinst_sdk2/clients/ocean/__init__.py +++ b/spotinst_sdk2/clients/ocean/__init__.py @@ -1820,6 +1820,8 @@ def get_aggregated_summary_costs(self, ocean_id: str, aggregated_cluster_costs: # endregion # region GCP + + class OceanGcpClient(Client): __base_ocean_url = "/ocean/k8s/cluster/" __base_ocean_cluster_url = "/ocean/gcp/k8s/cluster" @@ -2108,12 +2110,13 @@ def get_aggregated_summary_costs(self, ocean_id: str, aggregated_cluster_costs: return formatted_response["response"]["items"][0] - def create_virtual_node_group(self, vng: gcp_ocean.VirtualNodeGroup): + def create_virtual_node_group(self, vng: gcp_ocean.VirtualNodeGroup, initial_nodes: int = None): """ Create a virtual node group. # Arguments vng (VirtualNodeGroup): VirtualNodeGroup Object + initial_nodes: When set to an integer greater than 0, a corresponding number of nodes will be launched from the virtual node group created. # Returns (Object): Ocean Launch Spec response @@ -2128,10 +2131,13 @@ def create_virtual_node_group(self, vng: gcp_ocean.VirtualNodeGroup): body_json = json.dumps(formatted_missing_dict) - response = self.send_post( + query_params = dict(initialNodes=initial_nodes) + + response = self.send_post_with_params( body=body_json, url=self.__base_ocean_launchspec_url, - entity_name='ocean_gcp_vng') + entity_name='ocean_gcp_vng', + user_query_params=query_params) formatted_response = self.convert_json(response, self.camel_to_underscore) @@ -2480,6 +2486,8 @@ def launch_nodes_in_vng(self, ocean_launch_spec_id: str, amount: int): # endRegion # region RightSizing + + class OceanRightSizingClient(Client): def create_right_sizing_rule(self, ocean_id: str, rule_name: str, restart_pods: bool, diff --git a/spotinst_sdk2/version.py b/spotinst_sdk2/version.py index d0282444..3f3750c9 100644 --- a/spotinst_sdk2/version.py +++ b/spotinst_sdk2/version.py @@ -1 +1 @@ -__version__ = '3.9.1' +__version__ = '3.10.0'