diff --git a/qingcloud/iaas/actions/cluster.py b/qingcloud/iaas/actions/cluster.py index a875596..91fae32 100644 --- a/qingcloud/iaas/actions/cluster.py +++ b/qingcloud/iaas/actions/cluster.py @@ -68,13 +68,15 @@ def resize_cluster(self, cluster, @param memory: memory size in MB. @param storage_size: The new larger size of the storage_size, unit is GB. @param instance_class: The new class of instance + @param node_role: node role you want to. list type """ action = const.ACTION_RESIZE_CLUSTER valid_keys = ['cluster', 'node_role', 'cpu', 'memory', 'storage_size', 'instance_class'] body = filter_out_none(locals(), valid_keys) if not self.conn.req_checker.check_params(body, required_params=['cluster'], - integer_params=['cpu', 'memory'] + integer_params=['cpu', 'memory'], + list_params=['node_role'] ): return None diff --git a/qingcloud/iaas/actions/instance.py b/qingcloud/iaas/actions/instance.py index 1d94a78..d5ff371 100644 --- a/qingcloud/iaas/actions/instance.py +++ b/qingcloud/iaas/actions/instance.py @@ -86,6 +86,16 @@ def run_instances(self, image_id, cpu_max=None, mem_max=None, os_disk_size=None, + os_disk_encryption=None, + platform=None, + f_resetpwd=None, + processor_type=None, + default_user=None, + default_passwd=None, + hypervisor=None, + gpu=None, + gpu_class=None, + place_group_id=None, **ignore): """ Create one or more instances. @param image_id : ID of the image you want to use, "img-12345" @@ -116,6 +126,16 @@ def run_instances(self, image_id, @param cpu_max: max cpu core number. @param mem_max: max memory size in MB. @param os_disk_size: operation system disk size in GB. + @param os_disk_encryption: int, + @param platform: linux, + @param f_resetpwd: int, + @param processor_type: 64bit, + @param default_user: root, + @param default_passwd: password, + @param hypervisor: kvm, + @param gpu: int, + @param gpu_class: int, + @param place_group_id: string, """ action = const.ACTION_RUN_INSTANCES valid_keys = ['image_id', 'instance_type', 'cpu', 'memory', 'count', diff --git a/tests/actions/test_resize_cluster.py b/tests/actions/test_resize_cluster.py new file mode 100644 index 0000000..95672e5 --- /dev/null +++ b/tests/actions/test_resize_cluster.py @@ -0,0 +1,60 @@ +# ========================================================================= +# Copyright 2012-present Yunify, Inc. +# ------------------------------------------------------------------------- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this work except in compliance with the License. +# You may obtain a copy of the License in the LICENSE file, or at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ========================================================================= +import os +import unittest + +from qingcloud.iaas import APIConnection +from qingcloud.iaas.errors import InvalidRouterStatic +from qingcloud.iaas.actions.cluster import ClusterAction + + +class ClusterFactoryTestCase(unittest.TestCase): + + protocol = None + port = None + host = None + conn = None + zone = None + secret_access_key = None + access_key_id = None + + @classmethod + def test_resize_cluster(self): + self.access_key_id = os.getenv("QY_ACCESS_KEY_ID") + self.secret_access_key = os.getenv("QY_SECRET_ACCESS_KEY") + self.host = os.getenv("QY_HOST") + self.port = os.getenv("QY_PORT") + self.zone = os.getenv("QY_ZONE") + self.protocol = os.getenv("QY_PROTOCOL") + + self.conn = APIConnection( + qy_access_key_id=self.access_key_id, + qy_secret_access_key=self.secret_access_key, + zone=self.zone, + host=self.host, + port=self.port, + protocol=self.protocol, + + ) + cluster = "" + # node_role_not_list = {"cpu": 2, "memory": 2048, "volume_size": 120, "storage_size": 120, "node_role": "maininstance"} + node_role_with_list = [{"cpu":4,"memory":8192,"volume_size":100,"storage_size":100,"node_role":"maininstance"}] + + action = ClusterAction(self.conn) + resp = action.resize_cluster(cluster, node_role=node_role_with_list) + print(resp) + assert resp.get('ret_code') == 0 +