Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
00b9235
{Docs} Remove stale reference in README to closed issue about extensi…
dkmiller Apr 27, 2020
ab16df0
Merge remote-tracking branch 'upstream/release'
azclibot Apr 28, 2020
03436bc
Merge remote-tracking branch 'upstream/release'
azclibot Apr 30, 2020
7d98b1f
Merge remote-tracking branch 'upstream/release'
azclibot May 19, 2020
06f6ec5
Merge remote-tracking branch 'upstream/release'
azclibot Jun 2, 2020
adab2d2
Merge remote-tracking branch 'upstream/release'
azclibot Jun 23, 2020
c7b9f98
Merge remote-tracking branch 'upstream/release'
azclibot Jul 14, 2020
18e8b8d
Merge remote-tracking branch 'upstream/release'
azclibot Jul 16, 2020
1eb5074
Merge remote-tracking branch 'upstream/release'
azclibot Aug 4, 2020
cc3a159
Merge remote-tracking branch 'upstream/release' into master
azclibot Aug 6, 2020
af8f98e
Merge remote-tracking branch 'upstream/release' into master
azclibot Aug 26, 2020
0f904b9
Merge remote-tracking branch 'upstream/release' into master
azclibot Aug 28, 2020
d17a993
Merge remote-tracking branch 'upstream/release' into master
azclibot Sep 22, 2020
331b406
Merge branch 'master' of github.com:Azure/azure-cli into dev
Sep 24, 2020
c98c195
Merge branch 'dev' of github.com:Azure/azure-cli into dev
Sep 25, 2020
ee648a0
Merge branch 'dev' of github.com:Azure/azure-cli into dev
Nov 5, 2020
d2faa9f
Merge branch 'dev' of github.com:Azure/azure-cli into dev
Nov 9, 2020
64d0de4
Merge branch 'dev' of github.com:Azure/azure-cli into dev
Nov 10, 2020
7b250f5
Merge branch 'dev' of github.com:Azure/azure-cli into dev
Nov 18, 2020
03c8785
Merge branch 'dev' of github.com:Azure/azure-cli into dev
Dec 1, 2020
2f814b1
Merge branch 'dev' of github.com:Azure/azure-cli into dev
Dec 7, 2020
82ce0cc
Merge branch 'dev' of github.com:Azure/azure-cli into dev
Jan 29, 2021
3731883
Merge branch 'dev' of github.com:Azure/azure-cli into dev
Mar 18, 2021
1e48381
Merge branch 'dev' of github.com:Azure/azure-cli into dev
Apr 2, 2021
b50a530
Merge branch 'dev' of github.com:Azure/azure-cli into dev
Apr 25, 2021
15a1cef
Merge branch 'dev' of github.com:Azure/azure-cli into dev
Apr 26, 2021
a7fb6f7
Merge branch 'dev' of github.com:Azure/azure-cli into dev
May 11, 2021
0ce596f
Merge branch 'dev' of github.com:Azure/azure-cli into dev
May 24, 2021
0aad636
Merge branch 'dev' of github.com:Azure/azure-cli into dev
Jun 15, 2021
1136685
Remove breaking change incoming notice and support new azure monitor
Jun 17, 2021
11a3003
fix cred scan ci error
Jun 17, 2021
e9ef617
Replace CLIError with RequiredArgumentMissingError
Jun 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove breaking change incoming notice and support new azure monitor
  • Loading branch information
Zhenyu Zhou committed Jun 17, 2021
commit 1136685ffaf05bc697d6fdb522b21f10dacf5fcb
26 changes: 23 additions & 3 deletions src/azure-cli/azure/cli/command_modules/hdinsight/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,41 @@

helps['hdinsight monitor'] = """
type: group
short-summary: Manage Azure Monitor logs integration on an HDInsight cluster.
short-summary: Manage Classic Azure Monitor logs integration on an HDInsight cluster.
"""

helps['hdinsight monitor disable'] = """
type: command
short-summary: Disable the Azure Monitor logs integration on an HDInsight cluster.
short-summary: Disable the Classic Azure Monitor logs integration on an HDInsight cluster.
"""

helps['hdinsight monitor enable'] = """
type: command
short-summary: Enable the Azure Monitor logs integration on an HDInsight cluster.
short-summary: Enable the Classic Azure Monitor logs integration on an HDInsight cluster.
"""

helps['hdinsight monitor show'] = """
type: command
short-summary: Get the status of Classic Azure Monitor logs integration on an HDInsight cluster.
"""

helps['hdinsight azure-monitor'] = """
type: group
short-summary: Manage Azure Monitor logs integration on an HDInsight cluster.
"""

helps['hdinsight azure-monitor disable'] = """
type: command
short-summary: Disable the Azure Monitor logs integration on an HDInsight cluster.
"""

helps['hdinsight azure-monitor enable'] = """
type: command
short-summary: Enable the Azure Monitor logs integration on an HDInsight cluster.
"""

helps['hdinsight azure-monitor show'] = """
type: command
short-summary: Get the status of Azure Monitor logs integration on an HDInsight cluster.
"""

Expand Down
16 changes: 12 additions & 4 deletions src/azure-cli/azure/cli/command_modules/hdinsight/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,10 @@ def load_arguments(self, _):

# Node
c.argument('headnode_size', arg_type=node_size_type,
help='Incoming BREAKING CHANGE: The default value "large" will be removed in next CLI version.'
'The size of the node. See also: https://docs.microsoft.com/azure/'
help='The size of the node. See also: https://docs.microsoft.com/azure/'
'hdinsight/hdinsight-hadoop-provision-linux-clusters#configure-cluster-size')
c.argument('workernode_size', arg_type=node_size_type,
help='Incoming BREAKING CHANGE: The default value "large" will be removed in next CLI version.'
'The size of the node. See also: https://docs.microsoft.com/azure/'
help='The size of the node. See also: https://docs.microsoft.com/azure/'
'hdinsight/hdinsight-hadoop-provision-linux-clusters#configure-cluster-size')
c.argument('workernode_data_disks_per_node', arg_group='Node',
help='The number of data disks to use per worker node.')
Expand Down Expand Up @@ -296,6 +294,16 @@ def load_arguments(self, _):
'Required when workspace ID is provided.')
c.ignore('workspace_type')

# Azure Monitor
with self.argument_context('hdinsight azure-monitor') as c:
c.argument('workspace', validator=validate_workspace,
completer=get_resource_name_completion_list_under_subscription(
'Microsoft.OperationalInsights/workspaces'),
help='The name, resource ID or workspace ID of Log Analytics workspace.')
c.argument('primary_key', help='The certificate for the Log Analytics workspace. '
'Required when workspace ID is provided.')
c.ignore('workspace_type')

with self.argument_context('hdinsight host') as c:
c.argument('cluster_name', options_list=['--cluster-name'],
completer=get_resource_name_completion_list('Microsoft.HDInsight/clusters'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,19 @@ def load_command_table(self, _): # pylint: disable=too-many-statements
g.wait_command('wait')
g.command('delete', 'begin_delete', confirmation=True, supports_no_wait=True)

# Monitoring operations
# Monitoring operations(classic monitor)
with self.command_group('hdinsight monitor', hdinsight_extensions_sdk, client_factory=cf_hdinsight_extensions) as g:
g.show_command('show', 'get_monitoring_status')
g.custom_command('enable', 'enable_hdi_monitoring')
g.command('disable', 'begin_disable_monitoring')

# New Azure Monitor operations
with self.command_group('hdinsight azure-monitor', hdinsight_extensions_sdk,
client_factory=cf_hdinsight_extensions) as g:
g.show_command('show', 'get_azure_monitor_status')
g.custom_command('enable', 'enable_hdi_azure_monitor')
g.command('disable', 'begin_disable_azure_monitor')

# VirtualMachine operations
with self.command_group('hdinsight host', hdinsight_virtual_machines_sdk,
client_factory=cf_hdinsight_virtual_machines) as g:
Expand Down
43 changes: 43 additions & 0 deletions src/azure-cli/azure/cli/command_modules/hdinsight/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def create_cluster(cmd, client, cluster_name, resource_group_name, cluster_type,

if component_version:
# See validator
# pylint: disable=consider-using-dict-comprehension
component_version = dict([version.split('=') for version in component_version])

# Validate whether HTTP credentials were provided
Expand Down Expand Up @@ -568,6 +569,48 @@ def enable_hdi_monitoring(cmd, client, resource_group_name, cluster_name, worksp
monitor_request_parameter)


# pylint: disable=unused-argument
def enable_hdi_azure_monitor(cmd, client, resource_group_name, cluster_name, workspace, primary_key=None,
workspace_type='resource_id', no_validation_timeout=False):
from azure.mgmt.hdinsight.models import AzureMonitorRequest
from msrestazure.tools import parse_resource_id
from ._client_factory import cf_log_analytics

if workspace_type != 'resource_id' and not primary_key:
raise CLIError('primary key is required when workspace ID is provided')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLIError is deprecated. Please follow the guide line and use a detailed error type.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLIError is deprecated. Please follow the guide line and use a detailed error type.

Hi @kairu-ms , I have fixed this line. And I also checked the other CLIError usages, For the other CLIError I can not find a correct replacement so keep the other CLIError usages.
Could you please help review again?


workspace_id = workspace
if workspace_type == 'resource_id':
parsed_workspace = parse_resource_id(workspace)
workspace_resource_group_name = parsed_workspace['resource_group']
workspace_name = parsed_workspace['resource_name']

log_analytics_client = cf_log_analytics(cmd.cli_ctx)
log_analytics_workspace = log_analytics_client.workspaces.get(workspace_resource_group_name, workspace_name)
if not log_analytics_workspace:
raise CLIError('Fails to retrieve workspace by {}'.format(workspace))

# Only retrieve primary key when not provided
if not primary_key:
shared_keys = log_analytics_client.shared_keys.get_shared_keys(workspace_resource_group_name,
workspace_name)
if not shared_keys:
raise CLIError('Fails to retrieve shared key for workspace {}'.format(log_analytics_workspace))

primary_key = shared_keys.primary_shared_key

workspace_id = log_analytics_workspace.customer_id

azure_monitor_request_parameter = AzureMonitorRequest(
workspace_id=workspace_id,
primary_key=primary_key
)
return client.begin_enable_azure_monitor(
resource_group_name,
cluster_name,
azure_monitor_request_parameter)


# pylint: disable=unused-argument
def execute_hdi_script_action(cmd, client, resource_group_name, cluster_name,
script_uri, script_action_name, roles, script_parameters=None,
Expand Down
Loading