From ff6dccb9b2bf55ff4b7f7a5a8f301668b285c581 Mon Sep 17 00:00:00 2001 From: vasantchaitanyamahipala Date: Wed, 29 Jan 2020 16:29:00 +0530 Subject: [PATCH] new: dev: ACM-6382: Added for parent cluster label in hs2 clusters (#301) Co-authored-by: vasantm7 <60360689+vasantm7@users.noreply.github.com> --- qds_sdk/clusterv2.py | 6 ++++++ tests/test_clusterv2.py | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/qds_sdk/clusterv2.py b/qds_sdk/clusterv2.py index 6e20ef20..08a7d821 100755 --- a/qds_sdk/clusterv2.py +++ b/qds_sdk/clusterv2.py @@ -183,6 +183,7 @@ def set_cluster_info_from_arguments(self, arguments): disable_autoscale_node_pause=arguments.disable_autoscale_node_pause, paused_autoscale_node_timeout_mins=arguments.paused_autoscale_node_timeout_mins, parent_cluster_id=arguments.parent_cluster_id, + parent_cluster_label=arguments.parent_cluster_label, image_version=arguments.image_version) def set_cluster_info(self, @@ -227,6 +228,7 @@ def set_cluster_info(self, disable_autoscale_node_pause=None, paused_autoscale_node_timeout_mins=None, parent_cluster_id=None, + parent_cluster_label=None, image_version=None): """ Args: @@ -366,6 +368,7 @@ def set_cluster_info(self, self.cluster_info['rootdisk'] = {} self.cluster_info['rootdisk']['size'] = root_disk_size self.cluster_info['parent_cluster_id'] = parent_cluster_id + self.cluster_info['parent_cluster_label'] = parent_cluster_label self.cluster_info['cluster_image_version'] = image_version self.set_spot_instance_settings(maximum_bid_price_percentage, timeout_for_request, @@ -529,6 +532,9 @@ def cluster_info_parser(argparser, action): dest="parent_cluster_id", type=int, help="Id of the parent cluster this hs2 cluster is attached to") + cluster_info.add_argument("--parent-cluster-label", + dest="parent_cluster_label", + help="Label of the parent cluster this hs2 cluster is attached to") cluster_info.add_argument("--image-version", dest="image_version", help="cluster image version") diff --git a/tests/test_clusterv2.py b/tests/test_clusterv2.py index aef0f50d..38074410 100644 --- a/tests/test_clusterv2.py +++ b/tests/test_clusterv2.py @@ -461,6 +461,24 @@ def test_hs2_engine_config(self): 'min_nodes': 3, 'node_bootstrap': 'test_file_name', 'slave_instance_type': 'c1.xlarge' }}) + def test_hs2_parent_cluster_label(self): + with tempfile.NamedTemporaryFile() as temp: + temp.write("config.properties:\na=1\nb=2".encode("utf8")) + temp.flush() + sys.argv = ['qds.py', '--version', 'v2', 'cluster', 'create', '--label', + 'test_label', '--flavour', 'hs2', '--node-bootstrap-file', 'test_file_name', '--slave-instance-type', 'c1.xlarge', '--min-nodes', '3', '--parent-cluster-label', 'parent_cluster_label'] + Qubole.cloud = None + print_command() + Connection._api_call = Mock(return_value={}) + qds.main() + Connection._api_call.assert_called_with('POST', 'clusters', + {'engine_config': + {'flavour': 'hs2'}, + 'cluster_info': {'label': ['test_label'], + 'parent_cluster_label': 'parent_cluster_label', + 'min_nodes': 3, + 'node_bootstrap': 'test_file_name', + 'slave_instance_type': 'c1.xlarge' }}) def test_spark_engine_config(self): with tempfile.NamedTemporaryFile() as temp: