Merge pull request #366 from MihaelaStoica/CA-162992

CA-162992: Better display of container network port mapping information on General tab
This commit is contained in:
Gabor Apati-Nagy 2015-03-09 15:48:50 +00:00
commit 4b768d5f52
5 changed files with 125 additions and 5 deletions

View File

@ -1372,7 +1372,11 @@ namespace XenAdmin.TabPages
s.AddEntry(Messages.CONTAINER_IMAGE, dockerContainer.image.Length != 0 ? dockerContainer.image : Messages.NONE);
s.AddEntry(Messages.CONTAINER, dockerContainer.container.Length != 0 ? dockerContainer.container : Messages.NONE);
s.AddEntry(Messages.CONTAINER_COMMAND, dockerContainer.command.Length != 0 ? dockerContainer.command : Messages.NONE);
s.AddEntry(Messages.CONTAINER_PORTS, dockerContainer.ports.Length != 0 ? dockerContainer.ports : Messages.NONE);
var ports = dockerContainer.PortList.Select(p => p.Description);
if (ports.Count() > 0)
{
s.AddEntry(Messages.CONTAINER_PORTS, string.Join(Environment.NewLine, ports));
}
s.AddEntry(Messages.UUID, dockerContainer.uuid.Length != 0 ? dockerContainer.uuid : Messages.NONE);
}
}

View File

@ -30,6 +30,8 @@
*/
using System;
using System.Collections.Generic;
using System.Xml;
using XenAPI;
using XenAdmin.Core;
@ -302,5 +304,71 @@ namespace XenAdmin.Model
return string.Format(Messages.CONTAINER_ON_VM_TITLE, Name, parent.Name, parent.LocationString);
}
}
public List<DockerContainerPort> PortList
{
get
{
var portList = new List<DockerContainerPort>();
if (string.IsNullOrEmpty(ports))
return portList;
var xmlDoc = new XmlDocument();
try
{
xmlDoc.LoadXml("<items>" + ports + "</items>"); // wrap the ports into a root node
var items = xmlDoc.GetElementsByTagName("item");
foreach (XmlNode node in items)
{
var item = new DockerContainerPort();
foreach (XmlNode child in node.ChildNodes)
{
switch (child.Name)
{
case "IP":
item.Address = child.InnerText;
break;
case "PublicPort":
item.PublicPort = child.InnerText;
break;
case "PrivatePort":
item.PrivatePort = child.InnerText;
break;
case "Type":
item.Protocol = child.InnerText;
break;
}
}
portList.Add(item);
}
}
catch { }
return portList;
}
}
public struct DockerContainerPort
{
public string Address, PublicPort, PrivatePort, Protocol;
public string Description
{
get
{
var list = new List<string>();
if (!string.IsNullOrEmpty(Address))
list.Add(string.Format(Messages.CONTAINER_PORTS_ADDRESS, Address));
if (!string.IsNullOrEmpty(PublicPort))
list.Add(string.Format(Messages.CONTAINER_PORTS_PUBLIC_PORT, PublicPort));
if (!string.IsNullOrEmpty(PrivatePort))
list.Add(string.Format(Messages.CONTAINER_PORTS_PRIVATE_PORT, PrivatePort));
if (!string.IsNullOrEmpty(Protocol))
list.Add(string.Format(Messages.CONTAINER_PORTS_PROTOCOL, Protocol));
return string.Join("; ", list);
}
}
}
}
}

View File

@ -230,7 +230,7 @@ namespace XenAdmin.Model
string ports = "";
propertyNode = entry.ChildNodes.Cast<XmlNode>().FirstOrDefault(node => node.Name == "ports");
if (propertyNode != null)
ports = propertyNode.InnerText;
ports = propertyNode.InnerXml;
DockerContainer newContainer = new DockerContainer(vm, id, name, string.Empty, status, container, created, image, command, ports);

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34209
// Runtime Version:4.0.30319.18444
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -7878,6 +7878,42 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to Address: {0}.
/// </summary>
public static string CONTAINER_PORTS_ADDRESS {
get {
return ResourceManager.GetString("CONTAINER_PORTS_ADDRESS", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Private port: {0}.
/// </summary>
public static string CONTAINER_PORTS_PRIVATE_PORT {
get {
return ResourceManager.GetString("CONTAINER_PORTS_PRIVATE_PORT", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Protocol: {0}.
/// </summary>
public static string CONTAINER_PORTS_PROTOCOL {
get {
return ResourceManager.GetString("CONTAINER_PORTS_PROTOCOL", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Public port: {0}.
/// </summary>
public static string CONTAINER_PORTS_PUBLIC_PORT {
get {
return ResourceManager.GetString("CONTAINER_PORTS_PUBLIC_PORT", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to contains.
/// </summary>

View File

@ -2840,14 +2840,26 @@ You can only connect to a single Citrix XenServer Express Edition server at a ti
<data name="CONTAINER_GENERAL_TAB_TITLE" xml:space="preserve">
<value>Container General Properties</value>
</data>
<data name="CONTAINER_IMAGE" xml:space="preserve">
<value>Image</value>
</data>
<data name="CONTAINER_ON_VM_TITLE" xml:space="preserve">
<value>{0} on '{1}' {2}</value>
</data>
<data name="CONTAINER_PORTS" xml:space="preserve">
<value>Ports</value>
</data>
<data name="CONTAINER_IMAGE" xml:space="preserve">
<value>Image</value>
<data name="CONTAINER_PORTS_ADDRESS" xml:space="preserve">
<value>Address: {0}</value>
</data>
<data name="CONTAINER_PORTS_PRIVATE_PORT" xml:space="preserve">
<value>Private port: {0}</value>
</data>
<data name="CONTAINER_PORTS_PROTOCOL" xml:space="preserve">
<value>Protocol: {0}</value>
</data>
<data name="CONTAINER_PORTS_PUBLIC_PORT" xml:space="preserve">
<value>Public port: {0}</value>
</data>
<data name="CONTAINS" xml:space="preserve">
<value>contains</value>