From d98929b8bb39abb2a30cfd30dff6827120bb330f Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Thu, 14 Nov 2019 17:26:58 -0500 Subject: [PATCH 1/7] [openshift]Change "--workspace-resource-id" to "workspace-resource" Change help and parameters to match "workspace-resource" --- .../azure/cli/command_modules/acs/_help.py | 6 +++--- .../azure/cli/command_modules/acs/_params.py | 2 +- .../azure/cli/command_modules/acs/custom.py | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) 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..372f22ef5a5 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-resource 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-resource "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups//providers/Microsoft.OperationalInsights/workspaces/" """ 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..4eaceeb289c 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_resource') 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..84bb75bf7e2 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_resource=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_resource is not None: + workspace_resource = workspace_resource.strip() + if not workspace_resource.startswith('/'): + workspace_resource = '/' + workspace_resource + if workspace_resource.endswith('/'): + workspace_resource = workspace_resource.rstrip('/') + monitor_profile = OpenShiftManagedClusterMonitorProfile(enabled=True, workspace_resource=workspace_resource) # pylint: disable=line-too-long else: monitor_profile = None From dd74388e3a1dbc21ad1ecff3a3c1817a12573249 Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Thu, 14 Nov 2019 17:38:14 -0500 Subject: [PATCH 2/7] [openshift]Change HISTORY to reflect change in parameter in az openshift create --- src/azure-cli/HISTORY.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/azure-cli/HISTORY.rst b/src/azure-cli/HISTORY.rst index 7d133b53fd1..2c04a3483a2 100644 --- a/src/azure-cli/HISTORY.rst +++ b/src/azure-cli/HISTORY.rst @@ -38,7 +38,7 @@ Release History **Azure Red Hat OpenShift** -* Add `--workspace-resource-id` flag to allow creation of Azure Red Hat Openshift cluster with monitoring +* Add `--workspace-resource` flag to allow creation of Azure Red Hat Openshift cluster with monitoring * Add `monitor_profile` to create Azure Red Hat OpenShift cluster with monitoring **AKS** From 74d8fbe9380ab03da79de68794a72096db3de439 Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Fri, 15 Nov 2019 15:00:19 -0500 Subject: [PATCH 3/7] [openshift]Change paramter to workspace-id --- src/azure-cli/HISTORY.rst | 2 +- .../azure/cli/command_modules/acs/_help.py | 4 ++-- .../azure/cli/command_modules/acs/_params.py | 2 +- .../azure/cli/command_modules/acs/custom.py | 16 ++++++++-------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/azure-cli/HISTORY.rst b/src/azure-cli/HISTORY.rst index 2c04a3483a2..77789a39f65 100644 --- a/src/azure-cli/HISTORY.rst +++ b/src/azure-cli/HISTORY.rst @@ -38,7 +38,7 @@ Release History **Azure Red Hat OpenShift** -* Add `--workspace-resource` flag to allow creation of Azure Red Hat Openshift cluster with monitoring +* Add `--workspace-id` flag to allow creation of Azure Red Hat Openshift cluster with monitoring * Add `monitor_profile` to create Azure Red Hat OpenShift cluster with monitoring **AKS** 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 372f22ef5a5..cedb2126c65 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/_help.py +++ b/src/azure-cli/azure/cli/command_modules/acs/_help.py @@ -896,7 +896,7 @@ - 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 + - name: --workspace-id type: string short-summary: The resource id of an existing Log Analytics Workspace to use for storing monitoring data. @@ -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 "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups//providers/Microsoft.OperationalInsights/workspaces/" + text: az openshift create -g MyResourceGroup -n MyManagedCluster --workspace-id "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups//providers/Microsoft.OperationalInsights/workspaces/" """ 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 4eaceeb289c..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') + 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 84bb75bf7e2..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=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 is not None: - workspace_resource = workspace_resource.strip() - if not workspace_resource.startswith('/'): - workspace_resource = '/' + workspace_resource - if workspace_resource.endswith('/'): - workspace_resource = workspace_resource.rstrip('/') - monitor_profile = OpenShiftManagedClusterMonitorProfile(enabled=True, workspace_resource=workspace_resource) # 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 From 2970cbeffd978102deeabe271bb4c9cb21f9f0ac Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Tue, 19 Nov 2019 18:16:16 -0800 Subject: [PATCH 4/7] [openshift]Change workspace_resource_id to workspace_id [openshift]Test command for openshift create with monitor profile as None --- .../azure/cli/command_modules/acs/_help.py | 2 +- .../acs/tests/latest/test_osa_commands.py | 40 +++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) 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 cedb2126c65..7a43f602689 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/_help.py +++ b/src/azure-cli/azure/cli/command_modules/acs/_help.py @@ -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-id "/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups//providers/Microsoft.OperationalInsights/workspaces/" + 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/tests/latest/test_osa_commands.py b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_osa_commands.py index e7e95a724b7..7b96c8bd72c 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,37 @@ 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_without_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 + }) + + # 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}' + + self.cmd(create_cmd, checks=[ + self.exists('fqdn'), + self.check('provisioningState', 'Succeeded'), + self.check('monitor_profile', None) + ]) + # 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()]) + From 91d7c20239994fd3b16f129164a4283cbf9e3f03 Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Wed, 11 Dec 2019 15:08:13 -0500 Subject: [PATCH 5/7] [openshift]Add workspace_id to test for monitorProfile in az openshift create command --- .../acs/tests/latest/test_osa_commands.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 7b96c8bd72c..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 @@ -157,7 +157,7 @@ def test_openshift_create_default_service_no_aad(self, resource_group, resource_ @live_only() @ResourceGroupPreparer(random_name_length=17, name_prefix='clitestosa', location='eastus') @ManagedApplicationPreparer() - def test_openshift_create_without_monitoring(self, resource_group, resource_group_location, aad_client_app_id, aad_client_app_secret): + 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({ @@ -167,16 +167,18 @@ def test_openshift_create_without_monitoring(self, resource_group, resource_grou '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}' + '--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.check('monitor_profile', None) + self.exists('monitorProfile') ]) # show self.cmd('openshift show -g {resource_group} -n {name}', checks=[ From d444557a954b5103fede1e675cdae4a79153fff6 Mon Sep 17 00:00:00 2001 From: MyronFanQiu Date: Thu, 12 Dec 2019 12:54:09 +0800 Subject: [PATCH 6/7] refine History --- src/azure-cli/HISTORY.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/azure-cli/HISTORY.rst b/src/azure-cli/HISTORY.rst index 77789a39f65..8d6401a03c9 100644 --- a/src/azure-cli/HISTORY.rst +++ b/src/azure-cli/HISTORY.rst @@ -7,6 +7,10 @@ Release History * Support Local context in acr task run +**ACS** + +* [BREAKING CHANGE]az openshift create: rename `--workspace-resource-id` to `--workspace-id`. + **Compute** * vmss create/update: Add --scale-in-policy, which decides which virtual machines are chosen for removal when a VMSS is scaled-in @@ -38,7 +42,7 @@ Release History **Azure Red Hat OpenShift** -* Add `--workspace-id` flag to allow creation of Azure Red Hat Openshift cluster with monitoring +* Add `--workspace-resource-id` flag to allow creation of Azure Red Hat Openshift cluster with monitoring * Add `monitor_profile` to create Azure Red Hat OpenShift cluster with monitoring **AKS** From 25b8edb867c0f23cf46ecb0042673d69f625e9ea Mon Sep 17 00:00:00 2001 From: MyronFanQiu Date: Thu, 12 Dec 2019 13:12:36 +0800 Subject: [PATCH 7/7] remove history and add it in another PR to solve conflicts --- src/azure-cli/HISTORY.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/azure-cli/HISTORY.rst b/src/azure-cli/HISTORY.rst index 8d6401a03c9..7d133b53fd1 100644 --- a/src/azure-cli/HISTORY.rst +++ b/src/azure-cli/HISTORY.rst @@ -7,10 +7,6 @@ Release History * Support Local context in acr task run -**ACS** - -* [BREAKING CHANGE]az openshift create: rename `--workspace-resource-id` to `--workspace-id`. - **Compute** * vmss create/update: Add --scale-in-policy, which decides which virtual machines are chosen for removal when a VMSS is scaled-in