2017-01-16 20:59:50 +01:00
|
|
|
|
/* Copyright (c) Citrix Systems, Inc.
|
2015-02-09 08:42:00 +01:00
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms,
|
|
|
|
|
* with or without modification, are permitted provided
|
|
|
|
|
* that the following conditions are met:
|
|
|
|
|
*
|
|
|
|
|
* * Redistributions of source code must retain the above
|
|
|
|
|
* copyright notice, this list of conditions and the
|
|
|
|
|
* following disclaimer.
|
|
|
|
|
* * Redistributions in binary form must reproduce the above
|
|
|
|
|
* copyright notice, this list of conditions and the
|
|
|
|
|
* following disclaimer in the documentation and/or other
|
|
|
|
|
* materials provided with the distribution.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
|
|
|
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Windows.Forms;
|
2015-02-18 10:50:55 +01:00
|
|
|
|
using XenAdmin.Actions;
|
2015-02-25 13:44:03 +01:00
|
|
|
|
using XenAdmin.Core;
|
2015-02-09 08:42:00 +01:00
|
|
|
|
using XenAPI;
|
|
|
|
|
using XenAdmin.Model;
|
|
|
|
|
using System.Xml;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
|
|
|
|
namespace XenAdmin.TabPages
|
|
|
|
|
{
|
|
|
|
|
public partial class DockerDetailsPage : BaseTabPage
|
|
|
|
|
{
|
|
|
|
|
private const int REFRESH_INTERVAL = 20000;
|
|
|
|
|
|
2015-02-25 16:08:59 +01:00
|
|
|
|
private DockerContainer container;
|
2015-02-25 13:24:39 +01:00
|
|
|
|
private VM parentVM;
|
|
|
|
|
private Host host;
|
|
|
|
|
private string cachedResult;
|
2015-02-09 08:42:00 +01:00
|
|
|
|
|
2015-02-26 10:45:43 +01:00
|
|
|
|
public DockerContainer DockerContainer
|
2015-02-09 08:42:00 +01:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
Program.AssertOnEventThread();
|
2015-02-25 16:08:59 +01:00
|
|
|
|
return container;
|
2015-02-09 08:42:00 +01:00
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
Program.AssertOnEventThread();
|
2015-02-25 13:44:03 +01:00
|
|
|
|
RefreshButton.Enabled = true;
|
2015-02-09 08:42:00 +01:00
|
|
|
|
|
|
|
|
|
if (value == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-02-25 16:08:59 +01:00
|
|
|
|
if (container != value)
|
2015-02-09 08:42:00 +01:00
|
|
|
|
{
|
2015-02-25 16:08:59 +01:00
|
|
|
|
container = value;
|
|
|
|
|
parentVM = container.Parent;
|
|
|
|
|
if (parentVM.resident_on == null || string.IsNullOrEmpty(parentVM.resident_on.opaque_ref) ||
|
|
|
|
|
(parentVM.resident_on.opaque_ref.ToLower().Contains("null")))
|
|
|
|
|
return;
|
2015-02-09 08:42:00 +01:00
|
|
|
|
|
2015-02-25 16:08:59 +01:00
|
|
|
|
host = container.Connection.Resolve(parentVM.resident_on);
|
2015-02-25 13:44:03 +01:00
|
|
|
|
|
2015-02-25 16:08:59 +01:00
|
|
|
|
DetailtreeView.Nodes.Clear();
|
2015-02-25 13:44:03 +01:00
|
|
|
|
|
2015-02-25 16:08:59 +01:00
|
|
|
|
RefreshTime.Text = Messages.LAST_REFRESH_IN_PROGRESS;
|
|
|
|
|
StartUpdating();
|
2015-02-09 08:42:00 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-18 10:50:55 +01:00
|
|
|
|
private void StartUpdating()
|
|
|
|
|
{
|
|
|
|
|
var args = new Dictionary<string, string>();
|
2015-02-25 13:24:39 +01:00
|
|
|
|
args["vmuuid"] = parentVM.uuid;
|
2015-02-25 16:08:59 +01:00
|
|
|
|
args["object"] = container.uuid;
|
2015-02-18 10:50:55 +01:00
|
|
|
|
|
2015-02-25 16:08:59 +01:00
|
|
|
|
var action = new ExecuteContainerPluginAction(container, host,
|
2015-02-18 10:50:55 +01:00
|
|
|
|
"xscontainer", "get_inspect", args, true);
|
|
|
|
|
|
|
|
|
|
action.Completed += action_Completed;
|
|
|
|
|
action.RunAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void action_Completed(ActionBase sender)
|
|
|
|
|
{
|
2015-02-25 13:44:03 +01:00
|
|
|
|
var action = sender as ExecuteContainerPluginAction;
|
2015-02-25 16:08:59 +01:00
|
|
|
|
if (action == null || action.Container != container)
|
2015-02-25 13:44:03 +01:00
|
|
|
|
return;
|
2015-02-18 10:50:55 +01:00
|
|
|
|
Program.Invoke(Program.MainWindow, () =>
|
|
|
|
|
{
|
|
|
|
|
if (action.Succeeded)
|
|
|
|
|
Rebuild(action.Result);
|
|
|
|
|
else
|
|
|
|
|
ShowInvalidInfo();
|
2015-02-25 13:44:03 +01:00
|
|
|
|
RefreshButton.Enabled = true;
|
2015-02-18 10:50:55 +01:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-09 08:42:00 +01:00
|
|
|
|
private void CreateTree(XmlNode node, TreeNode rootNode)
|
|
|
|
|
{
|
|
|
|
|
Program.AssertOnEventThread();
|
|
|
|
|
|
|
|
|
|
if (node.NodeType == XmlNodeType.Text)
|
|
|
|
|
rootNode.Text = node.Value;
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-02-18 10:50:55 +01:00
|
|
|
|
if (node.Name == "SPECIAL_XS_ENCODED_ELEMENT" && node.Attributes != null)
|
|
|
|
|
{
|
2015-02-09 08:42:00 +01:00
|
|
|
|
rootNode.Text = node.Attributes["name"].Value;
|
2015-02-18 10:50:55 +01:00
|
|
|
|
}
|
2015-02-09 08:42:00 +01:00
|
|
|
|
else
|
|
|
|
|
rootNode.Text = node.Name;
|
|
|
|
|
}
|
|
|
|
|
IEnumerator ienum = node.GetEnumerator();
|
|
|
|
|
while (ienum.MoveNext())
|
|
|
|
|
{
|
|
|
|
|
XmlNode current = (XmlNode)ienum.Current;
|
|
|
|
|
TreeNode currentNode = new TreeNode();
|
|
|
|
|
CreateTree(current, currentNode);
|
|
|
|
|
rootNode.Nodes.Add(currentNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-18 10:50:55 +01:00
|
|
|
|
public void Rebuild(string currentResult)
|
2015-02-09 08:42:00 +01:00
|
|
|
|
{
|
|
|
|
|
Program.AssertOnEventThread();
|
2015-02-25 13:44:03 +01:00
|
|
|
|
RefreshTime.Text = string.Format(Messages.LAST_REFRESH_SUCCESS,
|
|
|
|
|
HelpersGUI.DateTimeToString(DateTime.Now, Messages.DATEFORMAT_HMS, true));
|
2015-02-18 10:50:55 +01:00
|
|
|
|
try
|
2015-02-09 08:42:00 +01:00
|
|
|
|
{
|
2015-02-25 13:24:39 +01:00
|
|
|
|
if (cachedResult == currentResult)
|
2015-02-18 10:50:55 +01:00
|
|
|
|
return;
|
CA-162989: Container Management GUI use-ability/homogeneity fixes
Implemented changes as follows (copied from ticket):
"I'd suggest the following use-ability/homogeneity fixes for the new container management tabs, if they are quick and easy:
Combine "Docker Version" and "Docker Information" on the VM-General-tab into "Container Management - Docker Status" with the following fields only:
API version
Version
Git Commit
Driver
Index Server Address
Execution Driver
IPv4 Forwarding
In the "Processes" tab, change the name from "Docker Processes" to "Container Processes"
In the "Details" tab, change the name from "Docker Detail" to "Container Details"
In the "Details" tab, drop the top level element "docker_inspect" (XML requires a single root-node, afaik the Windows form treenode does not), or alternatively open the root node by default and rename it to "Inspect Result"
In the "Details" tab, add the "Details"-headline in black on white - just like on the "Processes"-tab
Also, on the container's General tab, show Properties button disabled, instead on hiding it (to be consistent to other cases, e.g. disconnected servers)
"
Signed-off-by: Gabor Apati-Nagy <gabor.apati-nagy@citrix.com>
2015-03-05 20:10:54 +01:00
|
|
|
|
|
2015-02-25 13:24:39 +01:00
|
|
|
|
cachedResult = currentResult;
|
2015-02-18 10:50:55 +01:00
|
|
|
|
DetailtreeView.Nodes.Clear();
|
|
|
|
|
|
|
|
|
|
XmlDocument doc = new XmlDocument();
|
|
|
|
|
doc.LoadXml(currentResult);
|
CA-162989: Container Management GUI use-ability/homogeneity fixes
Implemented changes as follows (copied from ticket):
"I'd suggest the following use-ability/homogeneity fixes for the new container management tabs, if they are quick and easy:
Combine "Docker Version" and "Docker Information" on the VM-General-tab into "Container Management - Docker Status" with the following fields only:
API version
Version
Git Commit
Driver
Index Server Address
Execution Driver
IPv4 Forwarding
In the "Processes" tab, change the name from "Docker Processes" to "Container Processes"
In the "Details" tab, change the name from "Docker Detail" to "Container Details"
In the "Details" tab, drop the top level element "docker_inspect" (XML requires a single root-node, afaik the Windows form treenode does not), or alternatively open the root node by default and rename it to "Inspect Result"
In the "Details" tab, add the "Details"-headline in black on white - just like on the "Processes"-tab
Also, on the container's General tab, show Properties button disabled, instead on hiding it (to be consistent to other cases, e.g. disconnected servers)
"
Signed-off-by: Gabor Apati-Nagy <gabor.apati-nagy@citrix.com>
2015-03-05 20:10:54 +01:00
|
|
|
|
|
|
|
|
|
IEnumerator firstEnum = doc.GetEnumerator();
|
|
|
|
|
XmlNode node;
|
|
|
|
|
while (firstEnum.MoveNext())
|
2015-02-09 08:42:00 +01:00
|
|
|
|
{
|
CA-162989: Container Management GUI use-ability/homogeneity fixes
Implemented changes as follows (copied from ticket):
"I'd suggest the following use-ability/homogeneity fixes for the new container management tabs, if they are quick and easy:
Combine "Docker Version" and "Docker Information" on the VM-General-tab into "Container Management - Docker Status" with the following fields only:
API version
Version
Git Commit
Driver
Index Server Address
Execution Driver
IPv4 Forwarding
In the "Processes" tab, change the name from "Docker Processes" to "Container Processes"
In the "Details" tab, change the name from "Docker Detail" to "Container Details"
In the "Details" tab, drop the top level element "docker_inspect" (XML requires a single root-node, afaik the Windows form treenode does not), or alternatively open the root node by default and rename it to "Inspect Result"
In the "Details" tab, add the "Details"-headline in black on white - just like on the "Processes"-tab
Also, on the container's General tab, show Properties button disabled, instead on hiding it (to be consistent to other cases, e.g. disconnected servers)
"
Signed-off-by: Gabor Apati-Nagy <gabor.apati-nagy@citrix.com>
2015-03-05 20:10:54 +01:00
|
|
|
|
node = (XmlNode)firstEnum.Current;
|
|
|
|
|
|
|
|
|
|
if (node.NodeType != XmlNodeType.XmlDeclaration)
|
2015-02-09 08:42:00 +01:00
|
|
|
|
{
|
CA-162989: Container Management GUI use-ability/homogeneity fixes
Implemented changes as follows (copied from ticket):
"I'd suggest the following use-ability/homogeneity fixes for the new container management tabs, if they are quick and easy:
Combine "Docker Version" and "Docker Information" on the VM-General-tab into "Container Management - Docker Status" with the following fields only:
API version
Version
Git Commit
Driver
Index Server Address
Execution Driver
IPv4 Forwarding
In the "Processes" tab, change the name from "Docker Processes" to "Container Processes"
In the "Details" tab, change the name from "Docker Detail" to "Container Details"
In the "Details" tab, drop the top level element "docker_inspect" (XML requires a single root-node, afaik the Windows form treenode does not), or alternatively open the root node by default and rename it to "Inspect Result"
In the "Details" tab, add the "Details"-headline in black on white - just like on the "Processes"-tab
Also, on the container's General tab, show Properties button disabled, instead on hiding it (to be consistent to other cases, e.g. disconnected servers)
"
Signed-off-by: Gabor Apati-Nagy <gabor.apati-nagy@citrix.com>
2015-03-05 20:10:54 +01:00
|
|
|
|
//we are on the root element now (docker_inspect)
|
|
|
|
|
//using the following enumerator to iterate through the children nodes and to build related sub-trees
|
|
|
|
|
//note that we are intentionally not adding the root node to the tree (UX decision)
|
|
|
|
|
var secondEnum = node.GetEnumerator();
|
|
|
|
|
while (secondEnum.MoveNext())
|
|
|
|
|
{
|
|
|
|
|
//recursively building the tree
|
|
|
|
|
TreeNode rootNode = new TreeNode();
|
|
|
|
|
CreateTree((XmlNode)secondEnum.Current, rootNode);
|
|
|
|
|
|
|
|
|
|
//adding the current sub-tree to the TreeView
|
|
|
|
|
DetailtreeView.Nodes.Add(rootNode);
|
|
|
|
|
}
|
2015-02-09 08:42:00 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-02-18 10:50:55 +01:00
|
|
|
|
}
|
2019-07-22 14:05:22 +02:00
|
|
|
|
catch (Exception)
|
2015-02-18 10:50:55 +01:00
|
|
|
|
{
|
|
|
|
|
ShowInvalidInfo();
|
2015-02-09 08:42:00 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DockerDetailsPage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
base.Text = Messages.DOCKER_DETAIL_TAB_TITLE;
|
|
|
|
|
RefreshTimer.Interval = REFRESH_INTERVAL;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-18 10:50:55 +01:00
|
|
|
|
private void ShowInvalidInfo()
|
|
|
|
|
{
|
|
|
|
|
RefreshTime.Text = Messages.LAST_REFRESH_FAIL;
|
|
|
|
|
DetailtreeView.Nodes.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-09 08:42:00 +01:00
|
|
|
|
private void RefreshButton_Click(object sender, EventArgs e)
|
2015-02-25 13:44:03 +01:00
|
|
|
|
{
|
|
|
|
|
RefreshTime.Text = Messages.LAST_REFRESH_IN_PROGRESS;
|
|
|
|
|
RefreshButton.Enabled = false;
|
|
|
|
|
StartUpdating();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshTimer_Tick(object sender, EventArgs e)
|
2015-02-09 08:42:00 +01:00
|
|
|
|
{
|
2015-02-18 10:50:55 +01:00
|
|
|
|
StartUpdating();
|
2015-02-09 08:42:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PauseRefresh()
|
|
|
|
|
{
|
|
|
|
|
RefreshTimer.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ResumeRefresh()
|
|
|
|
|
{
|
|
|
|
|
RefreshTimer.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|