From f4fd6268fb0e8afa5e73d5d14369a83cee27923f Mon Sep 17 00:00:00 2001 From: Warren Jones Date: Wed, 16 Oct 2024 01:11:41 -0700 Subject: [PATCH] [Quantum] Remove msrestazure dependency (#8145) * commented-out _create_role_asignment and the msrestazure import * Deleted commented-out code --- .../azext_quantum/operations/workspace.py | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/src/quantum/azext_quantum/operations/workspace.py b/src/quantum/azext_quantum/operations/workspace.py index c516834faa2..52505c832a7 100644 --- a/src/quantum/azext_quantum/operations/workspace.py +++ b/src/quantum/azext_quantum/operations/workspace.py @@ -18,7 +18,6 @@ from azure.cli.core.azclierror import (InvalidArgumentValueError, AzureInternalError, RequiredArgumentMissingError, ResourceNotFoundError) -from msrestazure.azure_exceptions import CloudError from .._client_factory import cf_workspaces, cf_quotas, cf_workspace, cf_offerings, _get_data_credentials from ..vendored_sdks.azure_mgmt_quantum.models import QuantumWorkspace from ..vendored_sdks.azure_mgmt_quantum.models import QuantumWorkspaceIdentity @@ -176,31 +175,6 @@ def _add_quantum_providers(cmd, workspace, providers, auto_accept, skip_autoadd) workspace.providers.append(p) -def _create_role_assignment(cmd, quantum_workspace): - from azure.cli.command_modules.role.custom import create_role_assignment - retry_attempts = 0 - while retry_attempts < MAX_RETRIES_ROLE_ASSIGNMENT: - try: - create_role_assignment(cmd, role="Contributor", scope=quantum_workspace.storage_account, assignee=quantum_workspace.identity.principal_id) - break - except (CloudError, AzureInternalError) as e: - error = str(e.args).lower() - if (("does not exist" in error) or ("cannot find" in error)): - print('.', end='', flush=True) - time.sleep(POLLING_TIME_DURATION) - retry_attempts += 1 - continue - raise e - except Exception as x: - raise AzureInternalError(f"Role assignment encountered exception ({type(x).__name__}): {x}") from x - if retry_attempts > 0: - print() # To end the line of the waiting indicators. - if retry_attempts == MAX_RETRIES_ROLE_ASSIGNMENT: - max_time_in_seconds = MAX_RETRIES_ROLE_ASSIGNMENT * POLLING_TIME_DURATION - raise AzureInternalError(f"Role assignment could not be added to storage account {quantum_workspace.storage_account} within {max_time_in_seconds} seconds.") - return quantum_workspace - - def _validate_storage_account(tier_or_kind_msg_text, tier_or_kind, supported_tiers_or_kinds): if tier_or_kind not in supported_tiers_or_kinds: tier_or_kind_list = ', '.join(supported_tiers_or_kinds)