Skip to content

Commit

Permalink
[Quantum] Remove msrestazure dependency (#8145)
Browse files Browse the repository at this point in the history
* commented-out _create_role_asignment and the msrestazure import

* Deleted commented-out code
  • Loading branch information
warren-jones authored Oct 16, 2024
1 parent 57b800f commit f4fd626
Showing 1 changed file with 0 additions and 26 deletions.
26 changes: 0 additions & 26 deletions src/quantum/azext_quantum/operations/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f4fd626

Please sign in to comment.