Beispiel #1
0
 internal DiskPoolData(ResourceIdentifier id, string name, ResourceType type, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, Models.Sku sku, string managedBy, IReadOnlyList <string> managedByExtended, ProvisioningStates provisioningState, IList <string> availabilityZones, OperationalStatus status, IList <WritableSubResource> disks, string subnetId, IList <string> additionalCapabilities) : base(id, name, type, systemData, tags, location)
 {
     Sku                    = sku;
     ManagedBy              = managedBy;
     ManagedByExtended      = managedByExtended;
     ProvisioningState      = provisioningState;
     AvailabilityZones      = availabilityZones;
     Status                 = status;
     Disks                  = disks;
     SubnetId               = subnetId;
     AdditionalCapabilities = additionalCapabilities;
 }
        public async Task DiskPoolCrudOperations()
        {
            var diskPoolName       = Recording.GenerateAssetName("diskpool-");
            var diskPoolCollection = _resourceGroup.GetDiskPools();

            var sku            = new DiskPoolSku("Standard_S1");
            var diskPoolCreate = new DiskPoolCreate(sku, DefaultLocation, SubnetResourceId)
            {
            };

            diskPoolCreate.AvailabilityZones.Add("1");
            // the following additional capability is not needed for non-test disk pools
            diskPoolCreate.AdditionalCapabilities.Add("DiskPool.SkipInfrastructureDeployment");

            // create disk pool
            var response = await diskPoolCollection.CreateOrUpdateAsync(true, diskPoolName, diskPoolCreate);

            var diskPool = response.Value;

            Assert.AreEqual(diskPoolName, diskPool.Data.Name);
            Assert.AreEqual(ProvisioningStates.Succeeded, diskPool.Data.ProvisioningState);

            // update disk pool -- by adding a new tag
            diskPoolCreate.Tags.Add("tag2", "value2");
            var updateResponse = await diskPoolCollection.CreateOrUpdateAsync(true, diskPoolName, diskPoolCreate);

            diskPool = updateResponse.Value;
            Assert.AreEqual(diskPoolCreate.Tags, diskPool.Data.Tags);
            Assert.AreEqual(ProvisioningStates.Succeeded, diskPool.Data.ProvisioningState);

            // stop disk pool
            var deallocateResponse = await diskPool.DeallocateAsync(true);

            // start disk pool
            var startResponse = await diskPool.StartAsync(true);

            // delete disk pool
            var deleteResponse = await diskPool.DeleteAsync(true);

            try
            {
                var getResponse = await diskPoolCollection.GetAsync(diskPoolName);
            } catch (RequestFailedException e)
            {
                Assert.AreEqual(StatusCodes.Status404NotFound, e.Status);
            }
        }
Beispiel #3
0
        public async Task IscsiTargetCrudOperations()
        {
            var diskPoolName       = Recording.GenerateAssetName("diskpool-");
            var diskPoolCollection = _resourceGroup.GetDiskPools();

            var sku            = new DiskPoolSku("Standard_S1");
            var diskPoolCreate = new DiskPoolCreate(sku, DefaultLocation, SubnetResourceId)
            {
            };

            diskPoolCreate.AvailabilityZones.Add("1");

            // create disk pool
            var response = await diskPoolCollection.CreateOrUpdateAsync(true, diskPoolName, diskPoolCreate);

            var diskPool = response.Value;

            Assert.AreEqual(diskPoolName, diskPool.Data.Name);
            Assert.AreEqual(ProvisioningStates.Succeeded, diskPool.Data.ProvisioningState);

            // create iSCSI target
            var targetCollection  = diskPool.GetIscsiTargets();
            var iscsiTargetName   = Recording.GenerateAssetName("target-");
            var iscsiTargetCreate = new IscsiTargetCreate(IscsiTargetAclMode.Dynamic);

            var targetCreateResponse = await targetCollection.CreateOrUpdateAsync(true, iscsiTargetName, iscsiTargetCreate);

            var iscsiTarget = targetCreateResponse.Value;

            Assert.AreEqual(iscsiTargetName, iscsiTarget.Data.Name);
            Assert.AreEqual(ProvisioningStates.Succeeded, iscsiTarget.Data.ProvisioningState);

            // update iSCSI target -- by updating the managed by property
            var dataStoreId = "/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.AVS/privateClouds/myPrivateCloud/clusters/Cluster-1/datastores/datastore1";

            iscsiTargetCreate.ManagedBy = dataStoreId;
            iscsiTargetCreate.ManagedByExtended.Add(dataStoreId);
            var targetUpdateResponse = await targetCollection.CreateOrUpdateAsync(true, iscsiTargetName, iscsiTargetCreate);

            iscsiTarget = targetUpdateResponse.Value;

            Assert.AreEqual(dataStoreId, iscsiTarget.Data.ManagedBy);
            Assert.AreEqual(ProvisioningStates.Succeeded, iscsiTarget.Data.ProvisioningState);

            // remove managed by reference
            iscsiTargetCreate.ManagedBy = "";
            iscsiTargetCreate.ManagedByExtended.Remove(dataStoreId);
            targetUpdateResponse = await targetCollection.CreateOrUpdateAsync(true, iscsiTargetName, iscsiTargetCreate);

            iscsiTarget = targetUpdateResponse.Value;

            Assert.AreEqual(null, iscsiTarget.Data.ManagedBy);
            Assert.AreEqual(ProvisioningStates.Succeeded, iscsiTarget.Data.ProvisioningState);

            // delete iSCSI target
            var targetDeleteResponse = await iscsiTarget.DeleteAsync(true);

            try
            {
                var getResponse = await targetCollection.GetAsync(iscsiTargetName);
            }
            catch (RequestFailedException e)
            {
                Assert.AreEqual(StatusCodes.Status404NotFound, e.Status);
            }
        }