Skip to content

Commit de04326

Browse files
author
rogerhu
committed
add-resize-cluster-api
1 parent 9c83384 commit de04326

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

qingcloud/iaas/connection.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5134,3 +5134,58 @@ def verify_notification_item(self,
51345134
return None
51355135

51365136
return self.send_request(action, body)
5137+
5138+
def start_clusters(self, clusters,
5139+
**ignore):
5140+
""" Start one or more clusters.
5141+
@param clusters: the array of clusters IDs.
5142+
"""
5143+
action = const.ACTION_START_CLUSTERS
5144+
body = {'clusters': clusters}
5145+
if not self.req_checker.check_params(body,
5146+
required_params=['clusters'],
5147+
integer_params=[],
5148+
list_params=['clusters']
5149+
):
5150+
return None
5151+
5152+
return self.send_request(action, body)
5153+
5154+
def stop_clusters(self, clusters,
5155+
**ignore):
5156+
""" Stop one or more clusters.
5157+
@param clusters: the array of clusters IDs.
5158+
"""
5159+
action = const.ACTION_STOP_CLUSTERS
5160+
body = {'clusters': clusters}
5161+
if not self.req_checker.check_params(body,
5162+
required_params=['clusters'],
5163+
integer_params=[],
5164+
list_params=['clusters']
5165+
):
5166+
return None
5167+
5168+
return self.send_request(action, body)
5169+
5170+
def resize_cluster(self, cluster,
5171+
node_role=None,
5172+
cpu=None,
5173+
memory=None,
5174+
storage_size=None,
5175+
**ignore):
5176+
""" Resize cluster
5177+
@param cluster: the ID of the cluster you want to resize.
5178+
@param cpu: cpu core number.
5179+
@param memory: memory size in MB.
5180+
@param storage_size: The new larger size of the storage_size, unit is GB.
5181+
"""
5182+
action = const.ACTION_RESIZE_CLUSTER
5183+
valid_keys = ['cluster', 'node_role', 'cpu', 'memory', 'storage_size']
5184+
body = filter_out_none(locals(), valid_keys)
5185+
if not self.req_checker.check_params(body,
5186+
required_params=['cluster'],
5187+
integer_params=['cpu', 'memory']
5188+
):
5189+
return None
5190+
5191+
return self.send_request(action, body)

qingcloud/iaas/constants.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,3 +359,8 @@
359359
# eip
360360
EIP_BILLING_MODE_BANDWIDTH = "bandwidth"
361361
EIP_BILLING_MODE_TRAFFIC = "traffic"
362+
363+
# cluster
364+
ACTION_START_CLUSTERS = "StartClusters"
365+
ACTION_STOP_CLUSTERS = "StopClusters"
366+
ACTION_RESIZE_CLUSTER = "ResizeCluster"

0 commit comments

Comments
 (0)