Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions src/azure-cli/azure/cli/command_modules/acs/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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'] = """
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/azure/cli/command_modules/acs/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
16 changes: 8 additions & 8 deletions src/azure-cli/azure/cli/command_modules/acs/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

workspace_id=workspace_id instead of workspace_resource_id=workspace_id?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the string passed in to --workspace-id is, in fact, jus the name of the workspace-id, the variable will still be workspace-id and reference the string to build the workspace-resource-id (/subscriptions/...).

else:
monitor_profile = None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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} ' \
Copy link
Contributor

Choose a reason for hiding this comment

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

is it able to link a workspace since this PR is related with workspace? We have az monitor log-analytics workspace create

'--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()])