示例#1
0
        static List <CloudResource> SandboxResourcesFailing(string region, string studyName, string sandboxName,
                                                            int resourcesSucceeded        = 0,
                                                            string statusOfFailedResource = CloudResourceOperationState.FAILED,
                                                            int tryCount    = CloudResourceConstants.RESOURCE_MAX_TRY_COUNT,
                                                            int maxTryCount = CloudResourceConstants.RESOURCE_MAX_TRY_COUNT)
        {
            var resourceCreationIndex = 0;//number of resources created

            var resourceGroupName = AzureResourceNameUtil.SandboxResourceGroup(studyName, sandboxName);

            CloudResource resourceGroup;

            if (resourceCreationIndex++ < resourcesSucceeded)
            {
                resourceGroup = CloudResourceFactory.CreateResourceGroup(region, resourceGroupName, purpose: CloudResourcePurpose.SandboxResourceGroup, sandboxControlled: true);
            }
            else
            {
                resourceGroup = CloudResourceFactory.CreateResourceGroupFailing(region, resourceGroupName, purpose: CloudResourcePurpose.SandboxResourceGroup, sandboxControlled: true, statusOfFailedResource: statusOfFailedResource, tryCount: tryCount, maxTryCount: maxTryCount);
            }

            var result = new List <CloudResource>()
            {
                resourceGroup
            };

            result.Add(CreateSucceedingOrFailing(resourcesSucceeded, resourceCreationIndex++, statusOfFailedResource, tryCount, maxTryCount, region, AzureResourceType.StorageAccount, resourceGroupName, AzureResourceNameUtil.DiagnosticsStorageAccount(studyName, sandboxName), parentResource: resourceGroup, sandboxControlled: true));
            result.Add(CreateSucceedingOrFailing(resourcesSucceeded, resourceCreationIndex++, statusOfFailedResource, tryCount, maxTryCount, region, AzureResourceType.NetworkSecurityGroup, resourceGroupName, AzureResourceNameUtil.NetworkSecGroup(studyName, sandboxName), parentResource: resourceGroup, sandboxControlled: true));
            result.Add(CreateSucceedingOrFailing(resourcesSucceeded, resourceCreationIndex++, statusOfFailedResource, tryCount, maxTryCount, region, AzureResourceType.VirtualNetwork, resourceGroupName, AzureResourceNameUtil.VNet(studyName, sandboxName), parentResource: resourceGroup, sandboxControlled: true));
            result.Add(CreateSucceedingOrFailing(resourcesSucceeded, resourceCreationIndex++, statusOfFailedResource, tryCount, maxTryCount, region, AzureResourceType.Bastion, resourceGroupName, AzureResourceNameUtil.Bastion(studyName, sandboxName), parentResource: resourceGroup, sandboxControlled: true));

            return(result);
        }
示例#2
0
 public static CloudResource CreateSucceedingOrFailing(int resourcesSucceeded, int resourceCreationIndex, string statusOfFailedResource, int tryCount, int maxTryCount,
                                                       string region,
                                                       string resourceType,
                                                       string resourceGroup,
                                                       string resourceName,
                                                       string resourceId            = null,
                                                       string resourceKey           = null,
                                                       string purpose               = null,
                                                       bool sandboxControlled       = false,
                                                       string batchId               = null,
                                                       CloudResource parentResource = null)
 {
     return(resourceCreationIndex == resourcesSucceeded?
            CloudResourceFactory.CreateFailing(region, resourceType, resourceGroup, resourceName, resourceId, resourceKey, purpose, sandboxControlled, batchId, parentResource, statusOfFailedResource, tryCount, maxTryCount) :
                CloudResourceFactory.Create(region, resourceType, resourceGroup, resourceName, resourceId, resourceKey, purpose, sandboxControlled, batchId, parentResource, resourceCreationIndex >= resourcesSucceeded ? false : true));
 }
示例#3
0
        static CloudResource CreateVmResource(Sandbox sandbox,
                                              CloudResource sandboxResourceGroup,
                                              string studyName,
                                              string nameSuffix,
                                              string configString  = null,
                                              bool deleted         = false,
                                              bool deleteSucceeded = false)
        {
            var vmResourceName = AzureResourceNameUtil.VirtualMachine(studyName, sandbox.Name, nameSuffix);

            var vmResource = CloudResourceFactory.Create(sandboxResourceGroup.Region, AzureResourceType.VirtualMachine, sandboxResourceGroup.ResourceName, vmResourceName, parentResource: sandboxResourceGroup, deleted: deleted, deleteSucceeded: deleteSucceeded);

            vmResource.SandboxId    = sandbox.Id;
            vmResource.ConfigString = configString;
            return(vmResource);
        }
示例#4
0
        static List <CloudResource> SandboxResources(string region, string studyName, string sandboxName)
        {
            var resourceGroupName = AzureResourceNameUtil.SandboxResourceGroup(studyName, sandboxName);
            var resourceGroup     = CloudResourceFactory.CreateResourceGroup(region, resourceGroupName, purpose: CloudResourcePurpose.SandboxResourceGroup, sandboxControlled: true);

            var result = new List <CloudResource>()
            {
                resourceGroup
            };

            result.Add(CloudResourceFactory.Create(region, AzureResourceType.StorageAccount, resourceGroupName, AzureResourceNameUtil.DiagnosticsStorageAccount(studyName, sandboxName), parentResource: resourceGroup, sandboxControlled: true));
            result.Add(CloudResourceFactory.Create(region, AzureResourceType.NetworkSecurityGroup, resourceGroupName, AzureResourceNameUtil.NetworkSecGroup(studyName, sandboxName), parentResource: resourceGroup, sandboxControlled: true));
            result.Add(CloudResourceFactory.Create(region, AzureResourceType.VirtualNetwork, resourceGroupName, AzureResourceNameUtil.VNet(studyName, sandboxName), parentResource: resourceGroup, sandboxControlled: true));
            result.Add(CloudResourceFactory.Create(region, AzureResourceType.Bastion, resourceGroupName, AzureResourceNameUtil.Bastion(studyName, sandboxName), parentResource: resourceGroup, sandboxControlled: true));

            return(result);
        }
示例#5
0
        static CloudResource CreateFailedVmResource(Sandbox sandbox,
                                                    CloudResource sandboxResourceGroup,
                                                    string studyName,
                                                    string nameSuffix,
                                                    string configString           = null,
                                                    string statusOfFailedResource = CloudResourceOperationState.FAILED,
                                                    int tryCount         = CloudResourceConstants.RESOURCE_MAX_TRY_COUNT,
                                                    int maxTryCount      = CloudResourceConstants.RESOURCE_MAX_TRY_COUNT,
                                                    bool deleted         = false,
                                                    bool deleteSucceeded = false)
        {
            var vmResourceName = AzureResourceNameUtil.VirtualMachine(studyName, sandbox.Name, nameSuffix);

            var vmResource = CloudResourceFactory.CreateFailing(sandboxResourceGroup.Region, AzureResourceType.VirtualMachine, sandboxResourceGroup.ResourceName, vmResourceName, parentResource: sandboxResourceGroup, statusOfFailedResource: statusOfFailedResource, tryCount: tryCount, maxTryCount: maxTryCount, deleted: deleted, deleteSucceeded: deleteSucceeded);

            vmResource.SandboxId    = sandbox.Id;
            vmResource.ConfigString = configString;
            return(vmResource);
        }
示例#6
0
        static CloudResource StudySpecificDatasetResourceGroup(string studyName)
        {
            var resourceGroupName = AzureResourceNameUtil.StudySpecificDatasetResourceGroup(studyName);

            return(CloudResourceFactory.CreateResourceGroup(TestConstants.REGION, resourceGroupName, purpose: CloudResourcePurpose.StudySpecificDatasetContainer));
        }