/// <summary> /// Returns disks from a given iscsiserver on a device /// </summary> /// <param name="iscsiServer"></param> /// <param name="deviceName"></param> /// <returns></returns> public static IEnumerable <ISCSIDisk> GetIscsiDisks( this ISCSIServer iscsiServer, string deviceName) { var iscsiDisks = iscsiServer.Client.IscsiDisks.ListByIscsiServer( deviceName.GetDoubleEncoded(), iscsiServer.Name.GetDoubleEncoded(), iscsiServer.ResourceGroupName, iscsiServer.ManagerName); if (iscsiDisks == null || !iscsiDisks.Any()) { // Create a IscsiDisk with Tiered data policy var iscsiDisktoCreate = new ISCSIDisk( iscsiServer.Client, iscsiServer.ResourceGroupName, iscsiServer.ManagerName, TestConstants.DefaultTieredIscsiDiskName); iscsiDisktoCreate.Initialize(DataPolicy.Tiered); var iscsiDisk = iscsiDisktoCreate.CreateOrUpdate( iscsiServer.Name, iscsiServer.Name); } iscsiDisks = iscsiServer.Client.IscsiDisks.ListByIscsiServer( deviceName.GetDoubleEncoded(), iscsiServer.Name.GetDoubleEncoded(), iscsiServer.ResourceGroupName, iscsiServer.ManagerName); foreach (var iscsiDisk in iscsiDisks) { iscsiDisk.SetBaseResourceValues( iscsiServer.Client, iscsiServer.ResourceGroupName, iscsiServer.ManagerName); } return(iscsiDisks); }
public void TestCreateOrUpdateIscsiDisk() { try { var iSCSIServers = TestUtilities.GetIscsiServers( this.Client, this.ResourceGroupName, this.ManagerName); Assert.True( iSCSIServers != null && iSCSIServers.Any(), $"No iscsiservers were found in the manger {this.ManagerName}"); // Select the first iscsiserver var iscsiServer = iSCSIServers.First(); // Create a iscsidisk with Tiered data policy var iscsiDisk = new ISCSIDisk( this.Client, this.ResourceGroupName, this.ManagerName, "Auto-TestIscsiDisk1"); iscsiDisk.Initialize(DataPolicy.Tiered); var iscsiDiskCreated = iscsiDisk.CreateOrUpdate( iscsiServer.Name, iscsiServer.Name); // Create a iscsidisk with tiered data policy var iscsiDisk2 = new ISCSIDisk( this.Client, this.ResourceGroupName, this.ManagerName, "Auto-TestIscsiDisk2"); iscsiDisk2.Initialize(DataPolicy.Tiered); var iscsiDiskCreated2 = iscsiDisk2.CreateOrUpdate( iscsiServer.Name, iscsiServer.Name); // Update Description and ShareStatus iscsiDiskCreated.Description = "Updated: " + iscsiDiskCreated.Description; iscsiDiskCreated.DiskStatus = DiskStatus.Offline; iscsiDiskCreated = iscsiDiskCreated.CreateOrUpdate( iscsiServer.Name, iscsiServer.Name); // Validate iscsi disks by Managers var iscsiDisksByIscsiServer = this.Client.IscsiDisks.ListByIscsiServer( iscsiServer.Name, iscsiServer.Name, this.ResourceGroupName, this.ManagerName); var iscsiDisksByDevice = this.Client.IscsiDisks.ListByDevice( iscsiServer.Name, this.ResourceGroupName, this.ManagerName); } catch (Exception e) { Assert.Null(e); } #endregion Test methods }