Removed unused method and fixed some code inefficiencies.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2018-12-04 13:02:56 +00:00 committed by Mihaela Stoica
parent 5a4ff2c8a9
commit 7918bc9480

View File

@ -73,8 +73,7 @@ namespace XenAdmin.TabPages
{
InitializeComponent();
VM_guest_metrics_CollectionChangedWithInvoke =
Program.ProgramInvokeHandler(VM_guest_metrics_CollectionChanged);
VM_guest_metrics_CollectionChangedWithInvoke = Program.ProgramInvokeHandler(VM_guest_metrics_CollectionChanged);
OtherConfigAndTagsWatcher.TagsChanged += OtherConfigAndTagsWatcher_TagsChanged;
sections = new List<PDSection>();
foreach (Control control in panel2.Controls)
@ -102,26 +101,16 @@ namespace XenAdmin.TabPages
if (pdSectionLicense == null || licenseStatus == null)
return;
GeneralTabLicenseStatusStringifier ss = new GeneralTabLicenseStatusStringifier(licenseStatus);
Program.Invoke(Program.MainWindow, () =>
{
pdSectionLicense.UpdateEntryValueWithKey(
FriendlyName("host.license_params-expiry"),
ss.ExpiryDate,
ss.ShowExpiryDate);
});
var ss = new GeneralTabLicenseStatusStringifier(licenseStatus);
Program.Invoke(Program.MainWindow, () =>
{
pdSectionLicense.UpdateEntryValueWithKey(
Messages.LICENSE_STATUS,
ss.ExpiryStatus,
true);
});
pdSectionLicense.UpdateEntryValueWithKey(FriendlyName("host.license_params-expiry"),
ss.ExpiryDate, ss.ShowExpiryDate);
Pool p = xenObject as Pool;
if (p != null)
Program.Invoke(Program.MainWindow, () =>
pdSectionLicense.UpdateEntryValueWithKey(Messages.LICENSE_STATUS, ss.ExpiryStatus, true);
Pool p = xenObject as Pool;
if (p != null)
{
var additionalString = PoolAdditionalLicenseString();
pdSectionGeneral.UpdateEntryValueWithKey(
@ -130,7 +119,8 @@ namespace XenAdmin.TabPages
? string.Format(Messages.MAINWINDOW_CONTEXT_REASON, Helpers.GetFriendlyLicenseName(p), additionalString)
: Helpers.GetFriendlyLicenseName(p),
true);
});
}
});
}
void s_contentReceivedFocus(PDSection s)
@ -418,11 +408,11 @@ namespace XenAdmin.TabPages
buttonProperties.Enabled = xenObject != null && !xenObject.Locked && xenObject.Connection != null && xenObject.Connection.IsConnected;
//keeping it separate
if (xenObject is DockerContainer)
var container = xenObject as DockerContainer;
if (container != null)
{
buttonProperties.Enabled = false;
DockerContainer container = (DockerContainer)xenObject;
buttonViewConsole.Visible = true;
buttonViewLog.Visible = true;
@ -990,7 +980,7 @@ namespace XenAdmin.TabPages
Dictionary<string, string> info = new Dictionary<string, string>(host.license_params);
// This field is now supressed as it has no meaning under the current license scheme, and was never
// This field is now suppressed as it has no meaning under the current license scheme, and was never
// enforced anyway.
info.Remove("sockets");
@ -1027,12 +1017,12 @@ namespace XenAdmin.TabPages
{
var licenseServerAddress = host.license_server["address"].Trim();
if (licenseServerAddress == "" || licenseServerAddress.ToLower() == "localhost")
s.AddEntry(FriendlyName(String.Format("host.license_server-address")), host.license_server["address"]);
s.AddEntry(FriendlyName("host.license_server-address"), host.license_server["address"]);
else
{
var openUrl = new ToolStripMenuItem(Messages.LICENSE_SERVER_WEB_CONSOLE_GOTO);
openUrl.Click += (sender, args) => Program.OpenURL(string.Format(Messages.LICENSE_SERVER_WEB_CONSOLE_FORMAT, licenseServerAddress, Host.LicenseServerWebConsolePort));
s.AddEntryLink(FriendlyName(String.Format("host.license_server-address")),
s.AddEntryLink(FriendlyName("host.license_server-address"),
host.license_server["address"],
new[] {openUrl},
openUrl.PerformClick);
@ -1040,7 +1030,7 @@ namespace XenAdmin.TabPages
}
if (host.license_server.ContainsKey("port"))
{
s.AddEntry(FriendlyName(String.Format("host.license_server-port")), host.license_server["port"]);
s.AddEntry(FriendlyName("host.license_server-port"), host.license_server["port"]);
}
foreach (string key in new string[] { "productcode", "serialnumber" })
@ -1481,10 +1471,10 @@ namespace XenAdmin.TabPages
private void generateDockerContainerGeneralBox()
{
if (xenObject is DockerContainer)
var dockerContainer = xenObject as DockerContainer;
if (dockerContainer != null)
{
PDSection s = pdSectionGeneral;
DockerContainer dockerContainer = (DockerContainer)xenObject;
s.AddEntry(Messages.NAME, dockerContainer.Name().Length != 0 ? dockerContainer.Name() : Messages.NONE);
s.AddEntry(Messages.STATUS, dockerContainer.status.Length != 0 ? dockerContainer.status : Messages.NONE);
try
@ -1670,20 +1660,6 @@ namespace XenAdmin.TabPages
return string.Join(Environment.NewLine, result.ToArray());
}
private string hostUnappliedPatches(Host host)
{
List<string> result = new List<string>();
foreach (Pool_patch patch in Pool_patch.GetAllThatApply(host, ConnectionsManager.XenConnectionsCopy))
{
if (!patch.AppliedTo(ConnectionsManager.XenConnectionsCopy).Contains(new XenRef<Host>(xenObject.opaque_ref)))
result.Add(patch.Name());
}
result.Sort(StringUtility.NaturalCompare);
return string.Join("\n", result.ToArray());
}
private string hostInstalledSuppPacks(Host host)
{
var result = host.SuppPacks().Select(suppPack => suppPack.LongDescription).ToList();
@ -1927,9 +1903,9 @@ namespace XenAdmin.TabPages
private void buttonViewConsole_Click(object sender, EventArgs e)
{
if (xenObject is DockerContainer)
var dockerContainer = xenObject as DockerContainer;
if (dockerContainer != null)
{
DockerContainer dockerContainer = (DockerContainer)xenObject;
string vmIp = dockerContainer.Parent.IPAddressForSSH();
//Set command 'docker attach' to attach to the container.
string dockerCmd = "env docker attach --sig-proxy=false " + dockerContainer.uuid;
@ -1939,9 +1915,9 @@ namespace XenAdmin.TabPages
private void buttonViewLog_Click(object sender, EventArgs e)
{
if (xenObject is DockerContainer)
var dockerContainer = xenObject as DockerContainer;
if (dockerContainer != null)
{
DockerContainer dockerContainer = (DockerContainer)xenObject;
string vmIp = dockerContainer.Parent.IPAddressForSSH();
//Set command 'docker logs' to retrieve the logs of the container.
string dockerCmd = "env docker logs --tail=50 --follow --timestamps " + dockerContainer.uuid;