Skip to content

Commit efbcd5d

Browse files
aim-for-betterdkmillerazclibotZhenyu Zhou
authored
[HDInsight] Add two commands to support hdinsight node reboot feature (#14005)
* {Docs} Remove stale reference in README to closed issue about extensions (#12771) * Support hdinsight node reboot feature: Add two commands: az hdinsight host list and az hdinsight host restart * Change location back 2 eastus2 * Update parameter name and help doc * Removed support_no_wait Co-authored-by: Daniel Miller <[email protected]> Co-authored-by: Azure CLI Team <[email protected]> Co-authored-by: Zhenyu Zhou <[email protected]>
1 parent b6c5078 commit efbcd5d

File tree

10 files changed

+2257
-34
lines changed

10 files changed

+2257
-34
lines changed

src/azure-cli/azure/cli/command_modules/hdinsight/_client_factory.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@ def cf_hdinsight_extensions(cli_ctx, *_, **__):
7777

7878
def cf_hdinsight_locations(cli_ctx, *_, **__):
7979
return cf_hdinsight(cli_ctx).locations
80+
81+
82+
def cf_hdinsight_virtual_machines(cli_ctx, *_, **__):
83+
return cf_hdinsight(cli_ctx).virtual_machines

src/azure-cli/azure/cli/command_modules/hdinsight/_help.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# --------------------------------------------------------------------------------------------
66

77
from knack.help_files import helps # pylint: disable=unused-import
8+
89
# pylint: disable=line-too-long, too-many-lines
910

1011
helps['hdinsight'] = """
@@ -162,6 +163,29 @@
162163
--persist-on-success
163164
"""
164165

166+
helps['hdinsight host'] = """
167+
type: group
168+
short-summary: Manage HDInsight cluster's virtual hosts.
169+
"""
170+
171+
helps['hdinsight host list'] = """
172+
type: command
173+
short-summary: List the hosts of the specified HDInsight cluster.
174+
examples:
175+
- name: List the hosts of the specified HDInsight cluster.
176+
text: |-
177+
az hdinsight host list --resource-group MyResourceGroup --cluster-name MyCluster
178+
"""
179+
180+
helps['hdinsight host restart'] = """
181+
type: command
182+
short-summary: Restart the specific hosts of the specified HDInsight cluster.
183+
examples:
184+
- name: Restart the specific hosts of the specified HDInsight cluster.
185+
text: |-
186+
az hdinsight host restart --resource-group MyResourceGroup --cluster-name MyCluster --host-names hostname1 hostname2
187+
"""
188+
165189
helps['hdinsight wait'] = """
166190
type: command
167191
short-summary: Place the CLI in a waiting state until an operation is complete.

src/azure-cli/azure/cli/command_modules/hdinsight/_params.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def load_arguments(self, _):
3434

3535
# cluster
3636
with self.argument_context('hdinsight') as c:
37-
3837
# Cluster
3938
c.argument('cluster_name', arg_type=name_type,
4039
completer=get_resource_name_completion_list('Microsoft.HDInsight/clusters'),
@@ -237,3 +236,10 @@ def load_arguments(self, _):
237236
c.argument('primary_key', help='The certificate for the Log Analytics workspace. '
238237
'Required when workspace ID is provided.')
239238
c.ignore('workspace_type')
239+
240+
with self.argument_context('hdinsight host') as c:
241+
c.argument('cluster_name', options_list=['--cluster-name'],
242+
completer=get_resource_name_completion_list('Microsoft.HDInsight/clusters'),
243+
help='The name of the cluster.')
244+
c.argument('hosts', options_list=['--host-names'], nargs='+',
245+
help='A space-delimited list of host names that need to be restarted.')

src/azure-cli/azure/cli/command_modules/hdinsight/commands.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def load_command_table(self, _):
1212
from ._client_factory import cf_hdinsight_locations
1313
from ._client_factory import cf_hdinsight_script_execution_history
1414
from ._client_factory import cf_hdinsight_script_actions
15+
from ._client_factory import cf_hdinsight_virtual_machines
1516

1617
hdinsight_clusters_sdk = CliCommandType(
1718
operations_tmpl='azure.mgmt.hdinsight.operations#ClustersOperations.{}',
@@ -43,6 +44,11 @@ def load_command_table(self, _):
4344
client_factory=cf_hdinsight_script_execution_history
4445
)
4546

47+
hdinsight_virtual_machines_sdk = CliCommandType(
48+
operations_tmpl='azure.mgmt.hdinsight.operations#VirtualMachinesOperations.{}',
49+
client_factory=cf_hdinsight_virtual_machines
50+
)
51+
4652
# cluster operations
4753
with self.command_group('hdinsight', hdinsight_clusters_sdk, client_factory=cf_hdinsight_clusters) as g:
4854
g.custom_command('create', 'create_cluster', supports_no_wait=True)
@@ -92,3 +98,9 @@ def load_command_table(self, _):
9298
g.show_command('show', 'get_monitoring_status')
9399
g.custom_command('enable', 'enable_hdi_monitoring')
94100
g.command('disable', 'disable_monitoring')
101+
102+
# VirtualMachine operations
103+
with self.command_group('hdinsight host', hdinsight_virtual_machines_sdk,
104+
client_factory=cf_hdinsight_virtual_machines) as g:
105+
g.command('list', 'list_hosts')
106+
g.command('restart', 'restart_hosts', confirmation=True)

0 commit comments

Comments
 (0)