diff --git a/src/azure-cli/azure/cli/command_modules/acs/_help.py b/src/azure-cli/azure/cli/command_modules/acs/_help.py index 66817404833..7a43f602689 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/_help.py +++ b/src/azure-cli/azure/cli/command_modules/acs/_help.py @@ -896,9 +896,9 @@ - name: --customer-admin-group-id type: string short-summary: The Object ID of an Azure Active Directory Group that memberships will get synced into the OpenShift group "osa-customer-admins". If not specified, no cluster admin access will be granted. - - name: --workspace-resource-id + - name: --workspace-id type: string - short-summary: The resource ID of an existing Log Analytics Workspace to use for storing monitoring data. + short-summary: The resource id of an existing Log Analytics Workspace to use for storing monitoring data. examples: @@ -911,7 +911,7 @@ - name: Create an Openshift cluster using a custom vnet text: az openshift create -g MyResourceGroup -n MyManagedCluster --vnet-peer "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/openshift-vnet/providers/Microsoft.Network/virtualNetworks/test" - name: Create an Openshift cluster with Log Analytics monitoring enabled - text: az openshift create -g MyResourceGroup -n MyManagedCluster --workspace-resource-id {WORKSPACE_RESOURCE_ID} + text: az openshift create -g MyResourceGroup -n MyManagedCluster --workspace-id "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.OperationalInsights/workspaces/{workspace-id}" """ helps['openshift delete'] = """ diff --git a/src/azure-cli/azure/cli/command_modules/acs/_params.py b/src/azure-cli/azure/cli/command_modules/acs/_params.py index 631a2db79f9..12c032f6a5a 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/_params.py +++ b/src/azure-cli/azure/cli/command_modules/acs/_params.py @@ -321,7 +321,7 @@ def load_arguments(self, _): c.argument('name', validator=validate_linux_host_name) c.argument('compute_vm_size', options_list=['--compute-vm-size', '-s']) c.argument('customer_admin_group_id', options_list=['--customer-admin-group-id']) - c.argument('workspace_resource_id') + c.argument('workspace_id') def _get_default_install_location(exe_name): diff --git a/src/azure-cli/azure/cli/command_modules/acs/custom.py b/src/azure-cli/azure/cli/command_modules/acs/custom.py index dfb5c8bc3af..f73b4b3e6ed 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/custom.py +++ b/src/azure-cli/azure/cli/command_modules/acs/custom.py @@ -3125,7 +3125,7 @@ def openshift_create(cmd, client, resource_group_name, name, # pylint: disable= vnet_peer=None, tags=None, no_wait=False, - workspace_resource_id=None, + workspace_id=None, customer_admin_group_id=None): if location is None: @@ -3196,13 +3196,13 @@ def openshift_create(cmd, client, resource_group_name, name, # pylint: disable= namespace='Microsoft.Network', type='virtualNetwork', name=vnet_peer ) - if workspace_resource_id is not None: - workspace_resource_id = workspace_resource_id.strip() - if not workspace_resource_id.startswith('/'): - workspace_resource_id = '/' + workspace_resource_id - if workspace_resource_id.endswith('/'): - workspace_resource_id = workspace_resource_id.rstrip('/') - monitor_profile = OpenShiftManagedClusterMonitorProfile(enabled=True, workspace_resource_id=workspace_resource_id) # pylint: disable=line-too-long + if workspace_id is not None: + workspace_id = workspace_id.strip() + if not workspace_id.startswith('/'): + workspace_id = '/' + workspace_id + if workspace_id.endswith('/'): + workspace_id = workspace_id.rstrip('/') + monitor_profile = OpenShiftManagedClusterMonitorProfile(enabled=True, workspace_id=workspace_id) # pylint: disable=line-too-long else: monitor_profile = None diff --git a/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_osa_commands.py b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_osa_commands.py index e7e95a724b7..86ee5cd9e6f 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_osa_commands.py +++ b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_osa_commands.py @@ -18,7 +18,7 @@ class AzureOpenShiftServiceScenarioTest(ScenarioTest): - + # It works in --live mode but fails in replay mode.get rid off @live_only attribute once this resolved @live_only() @ResourceGroupPreparer(random_name_length=17, name_prefix='clitestosa', location='eastus') @@ -67,7 +67,7 @@ def test_openshift_create_default_service(self, resource_group, resource_group_l # delete self.cmd('openshift delete -g {resource_group} -n {name} --yes --no-wait', checks=[self.is_empty()]) - + # It works in --live mode but fails in replay mode.get rid off @live_only attribute once this resolved @live_only() @ResourceGroupPreparer(random_name_length=17, name_prefix='clitestosa', location='eastus') @@ -108,7 +108,7 @@ def test_openshift_create_service_no_wait(self, resource_group, resource_group_l # show again and expect failure self.cmd('openshift show -g {resource_group} -n {name}', expect_failure=True) - + # It works in --live mode but fails in replay mode.get rid off @live_only attribute once this resolved @live_only() @ResourceGroupPreparer(random_name_length=17, name_prefix='clitestosa', location='eastus') @@ -153,3 +153,39 @@ def test_openshift_create_default_service_no_aad(self, resource_group, resource_ # delete self.cmd('openshift delete -g {resource_group} -n {name} --yes --no-wait', checks=[self.is_empty()]) + # It works in --live mode but fails in replay mode.get rid off @live_only attribute once this resolved + @live_only() + @ResourceGroupPreparer(random_name_length=17, name_prefix='clitestosa', location='eastus') + @ManagedApplicationPreparer() + def test_openshift_create_with_monitoring(self, resource_group, resource_group_location, aad_client_app_id, aad_client_app_secret): + # kwargs for string formatting + osa_name = self.create_random_name('clitestosa', 15) + self.kwargs.update({ + 'resource_group': resource_group, + 'name': osa_name, + 'location': resource_group_location, + 'aad_client_app_id': aad_client_app_id, + 'aad_client_app_secret': aad_client_app_secret + }) + workspace = self.cmd("monitor log-analytics workspace create -g {resource_group} -n {osa_name}").get_output_in_json() + workspace_id = workspace["id"] + # create + create_cmd = 'openshift create --resource-group={resource_group} --name={name} --location={location} ' \ + '--compute-count=1 ' \ + '--aad-client-app-id {aad_client_app_id} --aad-client-app-secret {aad_client_app_secret}' \ + '--workspace-id {workspace_id}' + + self.cmd(create_cmd, checks=[ + self.exists('fqdn'), + self.check('provisioningState', 'Succeeded'), + self.exists('monitorProfile') + ]) + # show + self.cmd('openshift show -g {resource_group} -n {name}', checks=[ + self.check('name', '{name}'), + self.check('resourceGroup', '{resource_group}'), + self.exists('openShiftVersion') + ]) + # delete + self.cmd('openshift delete -g {resource_group} -n {name} --yes --no-wait', checks=[self.is_empty()]) +