Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
recover for MHSM
  • Loading branch information
evelyn-ys committed May 12, 2021
commit 8a558ca21de66f8eec6dcd5ca0568ef769d7750d
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ def validate_deleted_vault_or_hsm_name(cmd, ns):
vault_name = getattr(ns, 'vault_name', None)
hsm_name = getattr(ns, 'hsm_name', None)

if hsm_name and 'keyvault recover' in cmd.name:
raise InvalidArgumentValueError('Operation "recover" has not been supported for HSM.')
# if hsm_name and 'keyvault recover' in cmd.name:
# raise InvalidArgumentValueError('Operation "recover" has not been supported for HSM.')

if not vault_name and not hsm_name:
raise CLIError('Please specify --vault-name or --hsm-name.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ def recover_vault_or_hsm(cmd, client, resource_group_name=None, location=None, v


def recover_hsm(cmd, client, hsm_name, resource_group_name, location, no_wait=False):
deleted = client.get_deleted(name=hsm_name, location=location)
from azure.cli.core._profile import Profile

ManagedHsm = cmd.get_models('ManagedHsm', resource_type=ResourceType.MGMT_KEYVAULT)
Expand All @@ -414,7 +415,8 @@ def recover_hsm(cmd, client, hsm_name, resource_group_name, location, no_wait=Fa

parameters = ManagedHsm(location=location,
sku=ManagedHsmSku(name='Standard_B1', family='B'),
properties={'tenant_id': tenant_id, 'create_mode': CreateMode.recover.value})
properties={'tenant_id': tenant_id, 'create_mode': CreateMode.recover.value,
'initial_admin_object_ids': deleted.properties.additional_properties.get('initialAdminObjectIds')})

return sdk_no_wait(
no_wait, client.begin_create_or_update,
Expand Down