Skip to content

Commit

Permalink
Added changes for preliminary recommendations and restart replicas (#179
Browse files Browse the repository at this point in the history
)

* Added  changes for preliminary recommendations and restart replicas

* Documentation Update

* Fix update_right_sizing_rule API implementation

* Bump Version

---------

Co-authored-by: Anurag Sharma <anurag4@netapp.com>
  • Loading branch information
adityas1netapp and anuragsharma-123 authored Aug 21, 2024
1 parent 90a23d0 commit 61066b8
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.11.0] - 2024-08-21
### Fixed
- Updated new fields for ocean Automatic Rightsizing APIs (beta release. For internal use only).

## [3.10.0] - 2024-07-04
### Added
- Added `initialNodes` query parameter for Ocean GKE `create_virtual_node_group` API.
Expand Down
2 changes: 1 addition & 1 deletion docs/clients/ocean/ocean_gcp_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ OceanGcpClient.get_elastilog(ocean_id: str,
limit: int = None)
```

Get groups Elastilog by
Get group's Elastilog by

__Arguments__

Expand Down
16 changes: 12 additions & 4 deletions spotinst_sdk2/clients/ocean/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1988,7 +1988,7 @@ def reimport_ocean_cluster(self, ocean_id: str):
def get_elastilog(self, ocean_id: str, from_date: str, to_date: str, severity: str = None, resource_id: str = None,
limit: int = None):
"""
Get groups Elastilog by
Get group's Elastilog by
# Arguments
to_date (String): end date value
Expand Down Expand Up @@ -2491,6 +2491,8 @@ def launch_nodes_in_vng(self, ocean_launch_spec_id: str, amount: int):
class OceanRightSizingClient(Client):

def create_right_sizing_rule(self, ocean_id: str, rule_name: str, restart_pods: bool,
restart_replicas: right_sizing_ocean.RestartReplicas,
exclude_preliminary_recommendations: bool,
application_intervals: List[right_sizing_ocean.RecommendationApplicationInterval],
application_min_threshold: right_sizing_ocean.RecommendationApplicationMinThreshold = None,
application_boundaries: right_sizing_ocean.RecommendationApplicationBoundaries = None,
Expand All @@ -2502,6 +2504,8 @@ def create_right_sizing_rule(self, ocean_id: str, rule_name: str, restart_pods:
ocean_id (String): ID of the Ocean Cluster
rule_name (String): Name of the Right Sizing Rule
restart_pods (boolean): Enable to sequentially restart pod batches according to recommendations
restart_replicas (RestartReplicas): Restart Replicas
exclude_preliminary_recommendations (boolean): Exclude preliminary recommendations
application_intervals (List[RecommendationApplicationIntervals]): Recommendation Application Intervals
application_min_threshold (RecommendationApplicationMinThreshold): Recommendation Application Min Threshold
application_boundaries (RecommendationApplicationBoundaries): Recommendation Application Boundaries
Expand All @@ -2511,7 +2515,7 @@ def create_right_sizing_rule(self, ocean_id: str, rule_name: str, restart_pods:
(Object): Ocean Right Sizing Rule API response
"""
right_sizing_rule_request = right_sizing_ocean.CreateRightSizingRuleRequest(rule_name=rule_name, restart_pods=restart_pods, recommendation_application_intervals=application_intervals,
right_sizing_rule_request = right_sizing_ocean.CreateRightSizingRuleRequest(rule_name=rule_name, restart_pods=restart_pods, restart_replicas=restart_replicas, exclude_preliminary_recommendations=exclude_preliminary_recommendations, recommendation_application_intervals=application_intervals,
recommendation_application_min_threshold=application_min_threshold, recommendation_application_boundaries=application_boundaries, recommendation_application_overhead_values=application_overhead_values)

excluded_missing_dict = self.exclude_missing(
Expand Down Expand Up @@ -2563,6 +2567,8 @@ def delete_right_sizing_rule(self, ocean_id: str, rule_names: List[str]):
def update_right_sizing_rule(self, ocean_id: str,
rule_name: str,
restart_pods: bool,
restart_replicas: right_sizing_ocean.RestartReplicas,
exclude_preliminary_recommendations: bool,
application_intervals: right_sizing_ocean.RecommendationApplicationInterval,
application_min_threshold: right_sizing_ocean.RecommendationApplicationMinThreshold,
application_boundaries: right_sizing_ocean.RecommendationApplicationBoundaries,
Expand All @@ -2584,6 +2590,8 @@ def update_right_sizing_rule(self, ocean_id: str,
"""
right_sizing_rule_request = right_sizing_ocean.UpdateRightSizingRuleRequest(
restart_pods,
restart_replicas,
exclude_preliminary_recommendations,
application_intervals,
application_min_threshold,
application_boundaries,
Expand Down Expand Up @@ -2721,8 +2729,8 @@ def get_ocean_right_sizing_recommendations(self, ocean_id: str, cluster_resource
# Arguments
ocean_id (String): ID of the Ocean Cluster
rule_name (String): Ocean right sizing rule
namespaces (List[Namespace]): List of namespaces to attach the right sizing rule to
cluster_resources (ClusterResources): Cluster Resources
cluster_labels (ClusterLabels): Cluster Labels
# Returns
(Object): Ocean Right Sizing Rule API response
Expand Down
14 changes: 14 additions & 0 deletions spotinst_sdk2/models/ocean/rightsizing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,26 @@ def __init__(
# endregion


class RestartReplicas(Enum):
More_than_one_replica = "MORE_THAN_ONE_REPLICA"
All_manifest = "ALL_MANIFEST"
No_restart = "NO_RESTART"


class CreateRightSizingRuleRequest:
def __init__(self,
rule_name: str,
restart_pods: bool,
restart_replicas: RestartReplicas,
exclude_preliminary_recommendations: bool,
recommendation_application_intervals: List[RecommendationApplicationInterval],
recommendation_application_min_threshold: RecommendationApplicationMinThreshold,
recommendation_application_boundaries: RecommendationApplicationBoundaries,
recommendation_application_overhead_values: RecommendationApplicationOverheadValues):
self.rule_name = rule_name
self.restart_pods = restart_pods
self.restart_replicas = restart_replicas
self.exclude_preliminary_recommendations = exclude_preliminary_recommendations
self.recommendation_application_intervals = recommendation_application_intervals
self.recommendation_application_min_threshold = recommendation_application_min_threshold
self.recommendation_application_boundaries = recommendation_application_boundaries
Expand All @@ -321,11 +331,15 @@ def toJSON(self):
class UpdateRightSizingRuleRequest:
def __init__(self,
restart_pods: bool,
restart_replicas: RestartReplicas,
exclude_preliminary_recommendations: bool,
recommendation_application_intervals: List[RecommendationApplicationInterval],
recommendation_application_threshold: RecommendationApplicationMinThreshold,
recommendation_application_boundaries: RecommendationApplicationBoundaries,
recommendation_application_overhead_values: RecommendationApplicationOverheadValues):
self.restart_pods = restart_pods
self.restart_replicas = restart_replicas
self.exclude_preliminary_recommendations = exclude_preliminary_recommendations
self.recommendation_application_intervals = recommendation_application_intervals
self.recommendation_application_threshold = recommendation_application_threshold
self.recommendation_application_boundaries = recommendation_application_boundaries
Expand Down
2 changes: 1 addition & 1 deletion spotinst_sdk2/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.10.0'
__version__ = '3.11.0'

0 comments on commit 61066b8

Please sign in to comment.