public async Task EnsureFirewallExistsAsync(Study study, Dataset dataset, string clientIp, CancellationToken cancellationToken = default)
        {
            var currentUser = await _userService.GetCurrentUserAsync();

            var serverPublicIp = await _publicIpService.GetIp();

            if (DatasetFirewallUtils.SetDatasetFirewallRules(currentUser, dataset, clientIp, serverPublicIp))
            {
                await _db.SaveChangesAsync(cancellationToken);

                var stateForFirewallOperation     = DatasetFirewallUtils.TranslateAllowedIpsToOperationDesiredState(dataset.FirewallRules.ToList());
                var datasetStorageAccountResource = DatasetUtils.GetStudySpecificStorageAccountResourceEntry(dataset);
                var firewallUpdateOperation       = await _cloudResourceOperationCreateService.CreateUpdateOperationAsync(datasetStorageAccountResource.Id,
                                                                                                                          CloudResourceOperationType.ENSURE_FIREWALL_RULES, desiredState : stateForFirewallOperation);

                await _provisioningQueueService.CreateItemAndEnqueue(firewallUpdateOperation);

                await WaitForOperationToCompleteAsync(firewallUpdateOperation.Id);
            }
        }
        protected async Task CreateRoleUpdateOperationsAsync(int studyId)
        {
            var resourcesToUpdate = await _cloudResourceReadService.GetDatasetResourceGroupIdsForStudy(studyId);

            resourcesToUpdate.AddRange(await _cloudResourceReadService.GetSandboxResourceGroupIdsForStudy(studyId));

            foreach (var currentResourceId in resourcesToUpdate)
            {
                var desiredState    = CloudResourceConfigStringSerializer.Serialize(new CloudResourceOperationStateForRoleUpdate(studyId));
                var updateOperation = await _cloudResourceOperationCreateService.CreateUpdateOperationAsync(currentResourceId, CloudResourceOperationType.ENSURE_ROLES, desiredState : desiredState);

                await _provisioningQueueService.CreateItemAndEnqueue(updateOperation);
            }
        }
예제 #3
0
        async Task CreateUpdateOperationAndAddQueueItem(CloudResource vm, string description)
        {
            //If un-started update allready exist, no need to create update op?
            if (await _sandboxResourceOperationReadService.HasUnstartedCreateOrUpdateOperation(vm.Id))
            {
                _logger.LogWarning($"Updating VM {vm.Id}: There is allready an unstarted VM Create or Update operation. Not creating additional");
            }
            else
            {
                var vmUpdateOperation = await _sandboxResourceOperationCreateService.CreateUpdateOperationAsync(vm.Id);

                await _provisioningQueueService.CreateItemAndEnqueue(vmUpdateOperation);
            }
        }