private void InitDiskBtn_Click(object sender, EventArgs e) { CheckedListBox.CheckedItemCollection selecets = ISCSiCheckedListBox.CheckedItems; foreach (string item in selecets) { try { ISCSiInfo info = GetSelectVolum(item); bool result = ISCSiAPI.InitializeDisk(info.Number); if (!result) { MessageBox.Show("Initialize disk " + item + "Success."); } else { MessageBox.Show("Initialize disk " + item + "Success."); } } catch (Exception ex) { logger.Error(ex.ToString()); MessageBox.Show("InitDisk error: " + ex.Message); } } }
public void GetVolumeInfoTest() { List <ISCSiInfo> actual; actual = ISCSiAPI.GetVolumeInfo(); Assert.IsTrue(actual.Count > 0); }
private void CreatePartitionAndFormat_Click(object sender, EventArgs e) { CheckedListBox.CheckedItemCollection selecets = ISCSiCheckedListBox.CheckedItems; foreach (string item in selecets) { ISCSiInfo info = GetSelectVolum(item); try { bool result = ISCSiAPI.CreatePartitionAndFormat(info.Number); if (result) { MessageBox.Show("Create partition and format disk " + item + " Success."); } else { MessageBox.Show("Create partition and format disk " + item + " fail."); } } catch (Exception ex) { logger.Error(ex.ToString()); if (ex.Message.Contains("available capacity")) { this.ReFormatPartition(info.Number); } } } }
private void ISCSiStatus() { try { bool isPer = ISCSiAPI.IsPersistentConnetionType(); bool isConnected = ISCSiAPI.IsIscsiConneted(); bool isDiskAlready = ISCSiAPI.DisksAlready(); if (!isPer) { MessageBox.Show("ISCSi not persistent."); } if (!isConnected) { MessageBox.Show("ISCSi not connected."); } if (!isDiskAlready) { MessageBox.Show("ISCSi not online."); } ChangeStatus(CheckModule.ISCSiConnection, isPer && isConnected && isDiskAlready); } catch (Exception ex) { logger.Debug(ex.ToString()); MessageBox.Show("Iscsi Error:" + ex.Message); } }
public void IsPersistentConnetionTypeTest() { bool expected = true; // TODO: 初始化為適當值 bool actual; actual = ISCSiAPI.IsPersistentConnetionType(); Assert.AreEqual(expected, actual); }
public void IsIscsiConnetedTest() { bool expected = true; // TODO: 初始化為適當值 bool actual; actual = ISCSiAPI.IsIscsiConneted(); Assert.AreEqual(expected, actual); }
public void DiskAlreadyTest() { bool expected = false; // TODO: 初始化為適當值 bool actual; actual = ISCSiAPI.DisksAlready(); Assert.AreEqual(expected, actual); }
public void SetDiskOnlineTest() { int diskNumber = 2; // TODO: 初始化為適當值 bool expected = true; // TODO: 初始化為適當值 bool actual; actual = ISCSiAPI.SetDiskStatus(diskNumber, true); Assert.AreEqual(expected, actual); }
public void InitializeDiskTest() { int diskNumber = 0; // TODO: 初始化為適當值 bool expected = false; // TODO: 初始化為適當值 bool actual; actual = ISCSiAPI.InitializeDisk(diskNumber); Assert.AreEqual(expected, actual); }
private void RefleshVolumeInfo(bool reflesh) { if (reflesh) { this.iSCSiInfo = ISCSiAPI.GetVolumeInfo(); } string textInfo = ISCSiCheckedListBox.SelectedItem.ToString(); logger.Debug("RefleshVolumeInfo:" + textInfo); // MessageBox.Show(ISCSiCheckedListBox.SelectedItem.ToString()); ISCSiInfo info = GetSelectVolum(textInfo); logger.Debug("RefleshVolumeInfo info :" + JsonConvert.SerializeObject(info)); ISCSiStatusText.Text = info.IsOffline == true ? Constants.offline : Constants.online; PartitionSizeText.Text = info.PartitionSizeInGb + "GB."; }
private void ReFormatPartition(int diskNumber) { if (MessageBox.Show("Partition " + diskNumber + " is already format. Are you sure re-format partision?", "Format partision", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { logger.Debug("In ReFormatPartition"); bool removeResult = ISCSiAPI.RemovePartitionByDiskNumber(diskNumber); bool createResult = ISCSiAPI.CreatePartitionAndFormat(diskNumber); if (removeResult && createResult) { MessageBox.Show("CreatePartition And Format Success"); } else { MessageBox.Show("Some error. Please see the log."); } } }
private List <ISCSiInfo> GetISCSiInfo() { List <ISCSiInfo> iscsiInfo = new List <ISCSiInfo>(); try { iscsiInfo = ISCSiAPI.GetVolumeInfo(); logger.Debug(JsonConvert.SerializeObject(iscsiInfo)); } catch (Exception ex) { logger.Error(ex.ToString()); MessageBox.Show("ISCSI connection is not ready. You shoud create iSCSI connection first (Open iSCSI UI)."); } // iscsiInfo.Add(new ISCSiInfo(1, "test", "qwe", 100)); return(iscsiInfo); }
private void SetDiskOnline_Click(object sender, EventArgs e) { CheckedListBox.CheckedItemCollection selecets = ISCSiCheckedListBox.CheckedItems; foreach (string item in selecets) { ISCSiInfo info = GetSelectVolum(item); bool result = ISCSiAPI.SetDiskStatus(info.Number, true); if (!result) { MessageBox.Show("Set Online fail."); } else { MessageBox.Show("Set Online Success."); } } if (selecets.Count > 0) { RefleshVolumeInfo(true); } }