mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-23 20:36:33 +01:00
CP-9370:Add network type and more error message for resource list report feature
Signed-off-by: Cheng Zhang <cheng.zhang@citrix.com>
This commit is contained in:
parent
5eb82ae6de
commit
f1c02cdc4e
@ -127,6 +127,13 @@ namespace XenAdmin.Actions
|
||||
{
|
||||
log.Warn(string.Format("Export of Pool {0} failed", this.Connection.Cache.Pools[0].Name), _exception);
|
||||
log.DebugFormat("Progress of the action until exception: {0}", PercentComplete);
|
||||
|
||||
if (_exception is IOException)
|
||||
{
|
||||
this.Description = string.Format(Messages.ACTION_EXPORT_DESCRIPTION_FAILED_OF_OPEN_FILE, _filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(_filename);
|
||||
@ -136,6 +143,7 @@ namespace XenAdmin.Actions
|
||||
log.Warn(string.Format("deleting file {0} failed", _filename), e);
|
||||
}
|
||||
this.Description = Messages.ACTION_EXPORT_DESCRIPTION_FAILED;
|
||||
}
|
||||
throw new Exception(Description);
|
||||
}
|
||||
else
|
||||
@ -254,13 +262,14 @@ namespace XenAdmin.Actions
|
||||
private class NetworkInfo
|
||||
{
|
||||
public NetworkInfo(string name, string networkVlanID, string networkLinkStatus,
|
||||
string NetworkMac, string NetworkMtu)
|
||||
string NetworkMac, string NetworkMtu, string Type)
|
||||
{
|
||||
_name = name;
|
||||
_vlanID = networkVlanID;
|
||||
_linkStatus = networkLinkStatus;
|
||||
_mac = NetworkMac;
|
||||
_mtu = NetworkMtu;
|
||||
_networkType = Type;
|
||||
}
|
||||
public virtual string Name
|
||||
{
|
||||
@ -282,11 +291,16 @@ namespace XenAdmin.Actions
|
||||
{
|
||||
get { return _mtu; }
|
||||
}
|
||||
public virtual string NetworkType
|
||||
{
|
||||
get { return _networkType; }
|
||||
}
|
||||
private string _name;
|
||||
private string _vlanID;
|
||||
private string _linkStatus;
|
||||
private string _mac;
|
||||
private string _mtu;
|
||||
private string _networkType;
|
||||
}
|
||||
|
||||
private class VMInfo
|
||||
@ -586,7 +600,7 @@ namespace XenAdmin.Actions
|
||||
throw new CancelledException();
|
||||
|
||||
string cpu_usage = PropertyAccessorHelper.hostCpuUsageStringByMetric(host, MetricUpdater);
|
||||
string usage = PropertyAccessorHelper.hostMemoryUsageStringByMetric(host, MetricUpdater);
|
||||
string usage = PropertyAccessorHelper.hostMemoryUsagePercentageStringByMetric(host, MetricUpdater);
|
||||
string network_usage = PropertyAccessorHelper.hostNetworkUsageStringByMetric(host, MetricUpdater);
|
||||
|
||||
HostInfo buf = new HostInfo(host.name_label, host.address, host.uuid, cpu_usage,
|
||||
@ -617,12 +631,23 @@ namespace XenAdmin.Actions
|
||||
}
|
||||
|
||||
List<PIF> pifs = network.Connection.ResolveAll(network.PIFs);
|
||||
string type;
|
||||
if (Cancelling)
|
||||
throw new CancelledException();
|
||||
if (network.IsBond)
|
||||
type = Messages.BOND;
|
||||
else if (network.IsVLAN)
|
||||
type = Messages.NETWORKPANEL_VLAN;
|
||||
else if (pifs.Count != 0 && pifs[0].IsTunnelAccessPIF)
|
||||
type = Messages.CHIN;
|
||||
else
|
||||
type = Messages.HYPHEN;
|
||||
|
||||
NetworkInfo buf;
|
||||
if (pifs.Count != 0)
|
||||
buf = new NetworkInfo(network.Name, Helpers.VlanString(pifs[0]), network.LinkStatusString, pifs[0].MAC, network.MTU.ToString());
|
||||
buf = new NetworkInfo(network.Name, Helpers.VlanString(pifs[0]), network.LinkStatusString, pifs[0].MAC, network.MTU.ToString(), type);
|
||||
else
|
||||
buf = new NetworkInfo(network.Name, Messages.HYPHEN, network.LinkStatusString, Messages.HYPHEN, network.MTU.ToString());
|
||||
buf = new NetworkInfo(network.Name, Messages.HYPHEN, network.LinkStatusString, Messages.HYPHEN, network.MTU.ToString(), type);
|
||||
|
||||
m_Networks.Add(buf);
|
||||
|
||||
@ -738,7 +763,7 @@ namespace XenAdmin.Actions
|
||||
if (vbd != null && !vbd.IsCDROM && !vbd.IsFloppyDrive && vbd.bootable)
|
||||
{
|
||||
VDI vdi = vm.Connection.Resolve(vbd.VDI);
|
||||
srInfo += vdi.name_label + ":" + vbd.Name + ":" + vdi.SizeText + ";";
|
||||
srInfo += vdi.name_label + ":" + vdi.SizeText + ";";
|
||||
}
|
||||
}
|
||||
if (srInfo.Length == 0)
|
||||
@ -754,7 +779,7 @@ namespace XenAdmin.Actions
|
||||
default_template_name = vm.other_config["base_template_name"];
|
||||
|
||||
VMInfo buf = new VMInfo(vm.Name, vm.uuid, PropertyAccessorHelper.vmCpuUsageStringByMetric(vm, MetricUpdater),
|
||||
PropertyAccessorHelper.vmMemoryUsageStringByMetric(vm, MetricUpdater), srInfo, Convert.ToString(vm.VIFs.Count),
|
||||
PropertyAccessorHelper.vmMemoryUsagePercentageStringByMetric(vm, MetricUpdater), srInfo, Convert.ToString(vm.VIFs.Count),
|
||||
Convert.ToString(addresses), MacInfo, OSinfo, Convert.ToString(vm.power_state),
|
||||
Convert.ToString(vm.RunningTime), running_on, default_template_name, vm.Description);
|
||||
|
||||
@ -841,8 +866,6 @@ namespace XenAdmin.Actions
|
||||
|
||||
fs = new FileStream(_filename, FileMode.Create);
|
||||
fs.Write(bytes, 0, bytes.Length);
|
||||
|
||||
|
||||
PercentComplete = 100;
|
||||
if (fs != null)
|
||||
fs.Close();
|
||||
@ -1074,8 +1097,8 @@ namespace XenAdmin.Actions
|
||||
{
|
||||
FileStream fs = null;
|
||||
List<string> items = new List<string>();
|
||||
|
||||
fs = new FileStream(_filename, FileMode.Create);
|
||||
|
||||
//pool information part
|
||||
items.Add(Messages.POOL + ":" + Connection.Cache.Pools[0].Name);
|
||||
ComposeCSVRow(ref fs, ref items);
|
||||
|
@ -110,6 +110,10 @@
|
||||
<DataField>VlanID</DataField>
|
||||
<rd:TypeName>System.String</rd:TypeName>
|
||||
</Field>
|
||||
<Field Name="NetworkType">
|
||||
<DataField>NetworkType</DataField>
|
||||
<rd:TypeName>System.String</rd:TypeName>
|
||||
</Field>
|
||||
</Fields>
|
||||
<Query>
|
||||
<DataSourceName>DummyDataSource</DataSourceName>
|
||||
@ -2515,7 +2519,7 @@
|
||||
<ZIndex>4</ZIndex>
|
||||
<DataSetName>Report_NetworkInfo</DataSetName>
|
||||
<Top>5.25cm</Top>
|
||||
<Width>15cm</Width>
|
||||
<Width>20.75cm</Width>
|
||||
<Details>
|
||||
<TableRows>
|
||||
<TableRow>
|
||||
@ -2541,7 +2545,7 @@
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
<ZIndex>4</ZIndex>
|
||||
<ZIndex>5</ZIndex>
|
||||
<CanGrow>true</CanGrow>
|
||||
<Value>=Fields!Name.Value</Value>
|
||||
</Textbox>
|
||||
@ -2568,7 +2572,7 @@
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
<ZIndex>3</ZIndex>
|
||||
<ZIndex>4</ZIndex>
|
||||
<CanGrow>true</CanGrow>
|
||||
<Value>=Fields!LinkStatus.Value</Value>
|
||||
</Textbox>
|
||||
@ -2595,7 +2599,7 @@
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
<ZIndex>2</ZIndex>
|
||||
<ZIndex>3</ZIndex>
|
||||
<CanGrow>true</CanGrow>
|
||||
<Value>=Fields!MAC.Value</Value>
|
||||
</Textbox>
|
||||
@ -2622,7 +2626,7 @@
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
<ZIndex>1</ZIndex>
|
||||
<ZIndex>2</ZIndex>
|
||||
<CanGrow>true</CanGrow>
|
||||
<Value>=Fields!MTU.Value</Value>
|
||||
</Textbox>
|
||||
@ -2642,11 +2646,30 @@
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
<ZIndex>1</ZIndex>
|
||||
<CanGrow>true</CanGrow>
|
||||
<Value>=Fields!VlanID.Value</Value>
|
||||
</Textbox>
|
||||
</ReportItems>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<ReportItems>
|
||||
<Textbox Name="NetworkType">
|
||||
<rd:DefaultName>NetworkType</rd:DefaultName>
|
||||
<Style>
|
||||
<BorderStyle>
|
||||
<Default>Solid</Default>
|
||||
</BorderStyle>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
<CanGrow>true</CanGrow>
|
||||
<Value>=Fields!NetworkType.Value</Value>
|
||||
</Textbox>
|
||||
</ReportItems>
|
||||
</TableCell>
|
||||
</TableCells>
|
||||
<Height>0.66667cm</Height>
|
||||
</TableRow>
|
||||
@ -2684,7 +2707,7 @@
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
<ZIndex>9</ZIndex>
|
||||
<ZIndex>11</ZIndex>
|
||||
<CanGrow>true</CanGrow>
|
||||
<Value>=Code.GetLabel("LBL_HOSTNAME")</Value>
|
||||
</Textbox>
|
||||
@ -2706,7 +2729,7 @@
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
<ZIndex>8</ZIndex>
|
||||
<ZIndex>10</ZIndex>
|
||||
<CanGrow>true</CanGrow>
|
||||
<Value>=Code.GetLabel("LBL_LINKSTATUS")</Value>
|
||||
</Textbox>
|
||||
@ -2734,7 +2757,7 @@
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
<ZIndex>7</ZIndex>
|
||||
<ZIndex>9</ZIndex>
|
||||
<CanGrow>true</CanGrow>
|
||||
<Value>=Code.GetLabel("LBL_MAC")</Value>
|
||||
</Textbox>
|
||||
@ -2763,7 +2786,7 @@
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
<ZIndex>6</ZIndex>
|
||||
<ZIndex>8</ZIndex>
|
||||
<CanGrow>true</CanGrow>
|
||||
<Value>=Code.GetLabel("LBL_MTU")</Value>
|
||||
</Textbox>
|
||||
@ -2792,12 +2815,40 @@
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
<ZIndex>5</ZIndex>
|
||||
<ZIndex>7</ZIndex>
|
||||
<CanGrow>true</CanGrow>
|
||||
<Value>=Code.GetLabel("LBL_VLAN")</Value>
|
||||
</Textbox>
|
||||
</ReportItems>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<ReportItems>
|
||||
<Textbox Name="textbox39">
|
||||
<rd:DefaultName>textbox39</rd:DefaultName>
|
||||
<Style>
|
||||
<BackgroundColor>Gray</BackgroundColor>
|
||||
<BorderColor>
|
||||
<Left>Black</Left>
|
||||
</BorderColor>
|
||||
<BorderStyle>
|
||||
<Default>Solid</Default>
|
||||
<Left>Solid</Left>
|
||||
</BorderStyle>
|
||||
<BorderWidth>
|
||||
<Left>1pt</Left>
|
||||
</BorderWidth>
|
||||
<FontWeight>700</FontWeight>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
<ZIndex>6</ZIndex>
|
||||
<CanGrow>true</CanGrow>
|
||||
<Value>=Code.GetLabel("LBL_STORAGETYPE")</Value>
|
||||
</Textbox>
|
||||
</ReportItems>
|
||||
</TableCell>
|
||||
</TableCells>
|
||||
<Height>0.66667cm</Height>
|
||||
</TableRow>
|
||||
@ -2819,6 +2870,9 @@
|
||||
<TableColumn>
|
||||
<Width>3cm</Width>
|
||||
</TableColumn>
|
||||
<TableColumn>
|
||||
<Width>5.75cm</Width>
|
||||
</TableColumn>
|
||||
</TableColumns>
|
||||
<Height>1.33334cm</Height>
|
||||
</Table>
|
||||
|
18
XenModel/Messages.Designer.cs
generated
18
XenModel/Messages.Designer.cs
generated
@ -780,6 +780,15 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Export failed due to open destination file {0} failed.
|
||||
/// </summary>
|
||||
public static string ACTION_EXPORT_DESCRIPTION_FAILED_OF_OPEN_FILE {
|
||||
get {
|
||||
return ResourceManager.GetString("ACTION_EXPORT_DESCRIPTION_FAILED_OF_OPEN_FILE", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Export failed due to a header checksum mismatch. Please retry the export..
|
||||
/// </summary>
|
||||
@ -4989,6 +4998,15 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Bond.
|
||||
/// </summary>
|
||||
public static string BOND {
|
||||
get {
|
||||
return ResourceManager.GetString("BOND", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Create Bond.
|
||||
/// </summary>
|
||||
|
@ -357,6 +357,9 @@
|
||||
<data name="ACTION_EXPORT_DESCRIPTION_FAILED" xml:space="preserve">
|
||||
<value>エクスポートに失敗しました</value>
|
||||
</data>
|
||||
<data name="ACTION_EXPORT_DESCRIPTION_FAILED_OF_OPEN_FILE" xml:space="preserve">
|
||||
<value>Export failed due to open destination file {0} failed</value>
|
||||
</data>
|
||||
<data name="ACTION_EXPORT_DESCRIPTION_HEADER_CHECKSUM_FAILED" xml:space="preserve">
|
||||
<value>ヘッダーのチェックサムが一致しないため、エクスポートに失敗しました。もう一度エクスポートしてください。</value>
|
||||
</data>
|
||||
@ -1761,6 +1764,9 @@ CPU 使用率が {3} を超えるとアラートが送信されます。</value>
|
||||
<data name="BIOS_STRINGS_COPIED" xml:space="preserve">
|
||||
<value>BIOS 文字列のコピー</value>
|
||||
</data>
|
||||
<data name="BOND" xml:space="preserve">
|
||||
<value>Bond</value>
|
||||
</data>
|
||||
<data name="BOND_CREATE" xml:space="preserve">
|
||||
<value>ボンディングの作成</value>
|
||||
</data>
|
||||
|
@ -357,6 +357,9 @@
|
||||
<data name="ACTION_EXPORT_DESCRIPTION_FAILED" xml:space="preserve">
|
||||
<value>Export failed</value>
|
||||
</data>
|
||||
<data name="ACTION_EXPORT_DESCRIPTION_FAILED_OF_OPEN_FILE" xml:space="preserve">
|
||||
<value>Export failed due to open destination file {0} failed</value>
|
||||
</data>
|
||||
<data name="ACTION_EXPORT_DESCRIPTION_HEADER_CHECKSUM_FAILED" xml:space="preserve">
|
||||
<value>Export failed due to a header checksum mismatch. Please retry the export.</value>
|
||||
</data>
|
||||
@ -1818,6 +1821,9 @@ This is a potentially dangerous operation and is not allowed.</value>
|
||||
<data name="BIOS_STRINGS_COPIED" xml:space="preserve">
|
||||
<value>BIOS strings copied</value>
|
||||
</data>
|
||||
<data name="BOND" xml:space="preserve">
|
||||
<value>Bond</value>
|
||||
</data>
|
||||
<data name="BOND_CREATE" xml:space="preserve">
|
||||
<value>Create Bond</value>
|
||||
</data>
|
||||
|
@ -357,6 +357,9 @@
|
||||
<data name="ACTION_EXPORT_DESCRIPTION_FAILED" xml:space="preserve">
|
||||
<value>导出失败</value>
|
||||
</data>
|
||||
<data name="ACTION_EXPORT_DESCRIPTION_FAILED_OF_OPEN_FILE" xml:space="preserve">
|
||||
<value>导出操作因源文件 {0} 打开失败</value>
|
||||
</data>
|
||||
<data name="ACTION_EXPORT_DESCRIPTION_HEADER_CHECKSUM_FAILED" xml:space="preserve">
|
||||
<value>导出操作因标头校验和不匹配而失败。请重新尝试导出。</value>
|
||||
</data>
|
||||
@ -1761,6 +1764,9 @@ XenServer 可以重新启动服务器并将服务器的 CPU 级别降至池中
|
||||
<data name="BIOS_STRINGS_COPIED" xml:space="preserve">
|
||||
<value>已复制 BIOS 字符串</value>
|
||||
</data>
|
||||
<data name="BOND" xml:space="preserve">
|
||||
<value>绑定</value>
|
||||
</data>
|
||||
<data name="BOND_CREATE" xml:space="preserve">
|
||||
<value>创建绑定</value>
|
||||
</data>
|
||||
|
@ -109,6 +109,17 @@ namespace XenAdmin.XenSearch
|
||||
return String.Format(Messages.QUERY_MEMORY_USAGE, Util.MemorySizeStringWithoutUnits((total - (free * Util.BINARY_KILO))), Util.MemorySizeString(total));
|
||||
}
|
||||
|
||||
public static string vmMemoryUsagePercentageStringByMetric(VM vm, MetricUpdater MetricUpdater)
|
||||
{
|
||||
double free = MetricUpdater.GetValue(vm, "memory_internal_free");
|
||||
double total = MetricUpdater.GetValue(vm, "memory");
|
||||
|
||||
if (total == 0 || Double.IsNaN(total) || Double.IsNaN(free))
|
||||
return Messages.HYPHEN;
|
||||
|
||||
return String.Format(Messages.QUERY_MEMORY_PERCENT, ((total - (free * Util.BINARY_KILO))/total * 100.0).ToString("0."), Util.MemorySizeString(total));
|
||||
}
|
||||
|
||||
public static int vmMemoryUsageRank(VM vm)
|
||||
{
|
||||
double free = MetricUpdater.GetValue(vm, "memory_internal_free");
|
||||
@ -221,6 +232,17 @@ namespace XenAdmin.XenSearch
|
||||
return String.Format(Messages.QUERY_MEMORY_USAGE, Util.MemorySizeStringWithoutUnits((total - free) * Util.BINARY_KILO), Util.MemorySizeString(total * Util.BINARY_KILO));
|
||||
}
|
||||
|
||||
public static string hostMemoryUsagePercentageStringByMetric(Host host, MetricUpdater MetricUpdater)
|
||||
{
|
||||
double free = MetricUpdater.GetValue(host, "memory_free_kib");
|
||||
double total = MetricUpdater.GetValue(host, "memory_total_kib");
|
||||
|
||||
if (total == 0 || Double.IsNaN(total) || Double.IsNaN(free))
|
||||
return Messages.HYPHEN;
|
||||
|
||||
return String.Format(Messages.QUERY_MEMORY_PERCENT, ((total - free) / total * 100.0).ToString("0."), Util.MemorySizeString(total * Util.BINARY_KILO));
|
||||
}
|
||||
|
||||
public static string hostMemoryUsageString(Host host)
|
||||
{
|
||||
return hostMemoryUsageStringByMetric(host, MetricUpdater);
|
||||
|
Loading…
Reference in New Issue
Block a user