private void UpdatePieChart() { try { WinAPI.SR selectedSR = this.SelectedSR; this._otherUsedDiskSpace = 0L; if (this.OtherUsedDiskSpaceDict.ContainsKey(selectedSR)) { this._otherUsedDiskSpace = this.OtherUsedDiskSpaceDict[selectedSR]; } double num = selectedSR.physical_size; double num2 = selectedSR.physical_utilisation + this._otherUsedDiskSpace; double num3 = num - num2; long bytes = selectedSR.physical_size - (selectedSR.physical_utilisation + this._otherUsedDiskSpace); double num5 = (num3 * 100.0) / num; double num6 = (num2 * 100.0) / num; double[] numArray = new double[] { num6, num5 }; string[] xValue = new string[] { string.Format(Messages.USED_SPACE, Helpers.DiskSizeString(selectedSR.physical_utilisation + this._otherUsedDiskSpace, 2), num6), string.Format(Messages.FREE_SPACE, Helpers.DiskSizeString(bytes, 2), num5) }; this.chart1.Series["Series1"].Points.DataBindXY(xValue, new IEnumerable[] { numArray }); this.chart1.Series["Series1"]["PieLabelStyle"] = "Inside"; this.chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true; this.chart1.Series["Series1"]["PieDrawingStyle"] = "SoftEdge"; this.chart1.Legends["Legend1"].Enabled = false; } catch (Exception exception) { LOG.Error(exception, exception); } }
public WinAPI.SR GetDefaultSR(ServerInfo hostInfo) { WinAPI.SR sr = null; try { Session session = OpenSessionAndLogin(hostInfo); Dictionary <XenRef <Pool>, Pool> dictionary = Pool.get_all_records(session); if (dictionary != null) { foreach (XenRef <Pool> ref2 in dictionary.Keys) { XenRef <WinAPI.SR> ref3 = Pool.get_default_SR(session, (string)ref2); if (ref3 != null) { sr = WinAPI.SR.get_record(session, (string)ref3); } return(sr); } } return(sr); } catch (Exception exception) { LOG.Error("Unable to get default SR from WinServer! Exception caught...", exception); } return(sr); }
public CollectSetupDataCompletedEventArgs(bool failedCollectSetupData, Exception exception, string friendlyExceptionMessage, List <VmInstance> vmList, NetworkInstance[] vmwareNetworks, List <WinAPI.SR> SRs, WinAPI.SR defaultSR, Dictionary <WinAPI.SR, long> diskSpaceDict, Dictionary <XenRef <Network>, Network> xsNetworks, Network xsDefaultNetwork) : this(failedCollectSetupData, exception, friendlyExceptionMessage) { this._availVMs = vmList; this._vmwareNetworks = vmwareNetworks; this._availSRs = SRs; this._defaultSR = defaultSR; this._diskSpaceDict = diskSpaceDict; this._xsNetworks = xsNetworks; this._xsDefaultNetwork = xsDefaultNetwork; }
public DoConversionTask(ConversionClient client, ServerInfo destVMwareServerInfo, List <VmInstance> vms, WinAPI.SR sr, bool preserveMAC, XmlRpcStruct networkMappings) { this._client = client; this._destVMwareServerInfo = destVMwareServerInfo; this._vms = vms; this._sr = sr; this._preserveMAC = preserveMAC; this._networkMappings = networkMappings; base.SupportsProgress = false; }
private bool IsValidSR(WinAPI.SR sr) { //if (sr.content_type == "iso") //{ // return false; //} //return true; //五种类型 nfs ext lvm lvmhba lvmoiscsi if ("nfs".Equals(sr.type) || "ext".Equals(sr.type) || (!String.IsNullOrEmpty(sr.type) && sr.type.IndexOf("lvm") >= 0)) { return(true); } return(false); }
protected override void DoTask() { this._failedCollectSetupData = false; try { this._vmList = Commands.GetVMs(this._client, this._vmwareCredInfo); if ((this._vmList != null) && (this._vmList.Count <= 0)) { this._exception = new Exception(Messages.NO_VMS_DETECTED_ON_SERVER); this._failedCollectSetupData = true; this._friendExceptionMessage = Messages.NO_VMS_DETECTED_ON_SERVER; } } catch (Exception exception) { this._exception = exception; this._failedCollectSetupData = true; string str = string.Format(Messages.ERROR_CONNECTING_BLURB, "XenServer"); this._friendExceptionMessage = str; } if (!this._failedCollectSetupData) { this._SRs = this._client.GetSRList(this._xenServerHostInfo); this._defaultSR = this._client.GetDefaultSR(this._xenServerHostInfo); this._diskSpaceDict = this._client.GetReservedDiskSpaceDict(this._SRs); if ((this._SRs == null) || (this._SRs.Count <= 0)) { this._exception = new Exception(Messages.NO_DETECTED_SRS); this._failedCollectSetupData = true; this._friendExceptionMessage = Messages.NO_DETECTED_SRS; } } if (!this._failedCollectSetupData) { try { this._xsNetworks = this._client.GetXenServerNetworks(this._xenServerHostInfo); this._xsDefaultNetwork = this._client.GetDefaultXenServerNetwork(this._xenServerHostInfo); this._vmwareNetworks = this._client.GetHypervisorNetworks(this._vmwareCredInfo); } catch (Exception exception2) { this._exception = exception2; this._failedCollectSetupData = true; this._friendExceptionMessage = Messages.ERROR_NETWORK_GET_BLURB; } } }
private TreeNode BuildTreeNode(WinAPI.SR sr) { TreeNode node = null; try { int imageIndex = Images.GetImageIndex16For(sr); node = new TreeNode(this.SelectedSR.name_label, imageIndex, imageIndex) { NodeFont = new Font(this.summaryTreeView.Font, FontStyle.Regular) }; } catch { } return(node); }
public static Icons GetIconFor(WinAPI.SR sr) { return(Icons.SR_Default); }
private bool IsSharedSR(WinAPI.SR sr) { return(sr.shared); }
public static bool DoConversion(ConversionClient client, ServerInfo destVMwareServerInfo, List <VmInstance> vms, WinAPI.SR sr) { bool flag = false; try { foreach (VmInstance instance in vms) { JobInfo jobInfo = new JobInfo { SourceVmUUID = instance.UUID, SourceVmName = instance.Name }; jobInfo.ImportInfo.SRuuid = sr.uuid; jobInfo.Source = destVMwareServerInfo; client.CreateJob(jobInfo); flag = true; } } catch (Exception exception) { LOG.Error("DoConversion failed to submit job.", exception); } return(flag); }
public static string SrToString(WinAPI.SR sr, long otherUsedDiskSpace) { return(string.Format(Messages.SR_SIZE_FREE, sr.name_label, GetFreeSpaceString(sr, otherUsedDiskSpace))); }
public static string SrToString(WinAPI.SR sr) { return(string.Format(Messages.SR_SIZE_FREE, sr.name_label, GetFreeSpaceString(sr))); }
public static string GetFreeSpaceString(WinAPI.SR theSR, long otherUsedDiskSpace) { return(DiskSizeString(theSR.physical_size - (theSR.physical_utilisation + otherUsedDiskSpace), 2)); }
public static string GetFreeSpaceString(WinAPI.SR theSR) { return(DiskSizeString(theSR.physical_size - theSR.physical_utilisation, 2)); }