def re_register_wl_container(cmd, client, vault_name, resource_group_name, workload_type, container_name, container_type): workload_type = workload_type_map[workload_type] if not cust_help.is_native_name(container_name): raise CLIError( """ Container name passed cannot be a friendly name. Please pass a native container name. """) backup_cf = backup_protection_containers_cf(cmd.cli_ctx) containers = common.list_containers(backup_cf, resource_group_name, vault_name, container_type) source_resource_id = None for container in containers: if container.name == container_name: source_resource_id = container.properties.source_resource_id break if not source_resource_id: raise CLIError( """ No such registered container exists. """) properties = AzureVMAppContainerProtectionContainer(backup_management_type=container_type, workload_type=workload_type, operation_type='Reregister', source_resource_id=source_resource_id) param = ProtectionContainerResource(properties=properties) # Trigger register and wait for completion result = sdk_no_wait(True, client.register, vault_name, resource_group_name, fabric_name, container_name, param) return cust_help.track_register_operation(cmd.cli_ctx, result, vault_name, resource_group_name, container_name)
def register_wl_container(cmd, client, vault_name, resource_group_name, workload_type, resource_id, container_type): if not cust_help.is_id(resource_id): raise CLIError( """ Resource ID is not a valid one. """) workload_type = workload_type_map[workload_type] container_name = resource_id.split('/')[-1] containers = list_protectable_containers(cmd, resource_group_name, vault_name) for container in containers: if cust_help.get_resource_id(container.properties.container_id) == cust_help.get_resource_id(resource_id): container_name = container.name break if not cust_help.is_native_name(container_name): raise CLIError( """ Container unavailable or already registered. """) properties = AzureVMAppContainerProtectionContainer(backup_management_type=container_type, source_resource_id=resource_id, workload_type=workload_type) param = ProtectionContainerResource(properties=properties) # Trigger register and wait for completion result = sdk_no_wait(True, client.register, vault_name, resource_group_name, fabric_name, container_name, param) return cust_help.track_register_operation(cmd.cli_ctx, result, vault_name, resource_group_name, container_name)
def register_wl_container(cmd, client, vault_name, resource_group_name, workload_type, resource_id, container_type): if not cust_help.is_id(resource_id): raise CLIError( """ Resource ID is not a valid one. """) workload_type = _check_map(workload_type, workload_type_map) container_name = _get_protectable_container_name(cmd, resource_group_name, vault_name, resource_id) if container_name is None or not cust_help.is_native_name(container_name): # refresh containers and try to get the protectable container object again client.refresh(vault_name, resource_group_name, fabric_name) container_name = _get_protectable_container_name(cmd, resource_group_name, vault_name, resource_id) if container_name is None or not cust_help.is_native_name(container_name): raise ResourceNotFoundError( """ Container unavailable or already registered. """) properties = AzureVMAppContainerProtectionContainer(backup_management_type=container_type, source_resource_id=resource_id, workload_type=workload_type) param = ProtectionContainerResource(properties=properties) # Trigger register and wait for completion result = client.register(vault_name, resource_group_name, fabric_name, container_name, param, raw=True) return cust_help.track_register_operation(cmd.cli_ctx, result, vault_name, resource_group_name, container_name)