Example #1
0
        private void generateGeneralBox()
        {
            PDSection s = pdSectionGeneral;

            s.AddEntry(FriendlyName("host.name_label"), Helpers.GetName(xenObject),
                new PropertiesToolStripMenuItem(new PropertiesCommand(Program.MainWindow, xenObject)));

            VM vm = xenObject as VM;
            if (vm == null || vm.DescriptionType != VM.VmDescriptionType.None)
            {
                s.AddEntry(FriendlyName("host.name_description"), xenObject.Description,
                            new PropertiesToolStripMenuItem(new DescriptionPropertiesCommand(Program.MainWindow, xenObject)));
            }

            GenTagRow(s);
            GenFolderRow(s);

            if (xenObject is Host)
            {
                Host host = xenObject as Host;

                if (Helpers.GetPool(xenObject.Connection) != null)
                    s.AddEntry(Messages.POOL_MASTER, host.IsMaster() ? Messages.YES : Messages.NO);

                if (!host.IsLive)
                {
                    s.AddEntry(FriendlyName("host.enabled"), Messages.HOST_NOT_LIVE, Color.Red);
                }
                else if (!host.enabled)
                {
                    var item = new ToolStripMenuItem(Messages.EXIT_MAINTENANCE_MODE);
                    item.Click += delegate
                        {
                            new HostMaintenanceModeCommand(Program.MainWindow, host,
                                                           HostMaintenanceModeCommandParameter.Exit).Execute();
                        };
                    s.AddEntry(FriendlyName("host.enabled"),
                               host.MaintenanceMode ? Messages.HOST_IN_MAINTENANCE_MODE : Messages.DISABLED,
                               new[] { item },
                               Color.Red);
                }
                else
                {
                    var item = new ToolStripMenuItem(Messages.ENTER_MAINTENANCE_MODE);
                    item.Click += delegate
                        {
                            new HostMaintenanceModeCommand(Program.MainWindow, host,
                                HostMaintenanceModeCommandParameter.Enter).Execute();
                        };
                    s.AddEntry(FriendlyName("host.enabled"), Messages.YES, item);
                }

                s.AddEntry(FriendlyName("host.iscsi_iqn"), host.iscsi_iqn,
                    new PropertiesToolStripMenuItem(new IqnPropertiesCommand(Program.MainWindow, xenObject)));
                s.AddEntry(FriendlyName("host.log_destination"), host.SysLogDestination ?? Messages.HOST_LOG_DESTINATION_LOCAL,
                   new PropertiesToolStripMenuItem(new HostEditLogDestinationCommand(Program.MainWindow, xenObject)));

                PrettyTimeSpan uptime = host.Uptime;
                PrettyTimeSpan agentUptime = host.AgentUptime;
                s.AddEntry(FriendlyName("host.uptime"), uptime == null ? "" : host.Uptime.ToString());
                s.AddEntry(FriendlyName("host.agentUptime"), agentUptime == null ? "" : host.AgentUptime.ToString());

                if (host.external_auth_type == Auth.AUTH_TYPE_AD)
                    s.AddEntry(FriendlyName("host.external_auth_service_name"), host.external_auth_service_name);
            }
            else if (xenObject is VM)
            {
                s.AddEntry(FriendlyName("VM.OSName"), vm.GetOSName());

                s.AddEntry(FriendlyName("VM.OperatingMode"), vm.IsHVM ? Messages.VM_OPERATING_MODE_HVM : Messages.VM_OPERATING_MODE_PV);

                if (!vm.DefaultTemplate)
                {
                    s.AddEntry(Messages.BIOS_STRINGS_COPIED, vm.BiosStringsCopied ? Messages.YES : Messages.NO);
                }

				if (vm.Connection != null)
				{
					var appl = vm.Connection.Resolve(vm.appliance);
					if (appl != null)
					{
                        var applProperties = new ToolStripMenuItem(Messages.VM_APPLIANCE_PROPERTIES);
					    applProperties.Click +=
					        (sender, e) =>
					            {
					                using (PropertiesDialog propertiesDialog = new PropertiesDialog(appl))
					                    propertiesDialog.ShowDialog(this);
					            };

						s.AddEntryLink(Messages.VM_APPLIANCE, appl.Name, new[] { applProperties },
									   () =>
									   {
										   using (PropertiesDialog propertiesDialog = new PropertiesDialog(appl))
											   propertiesDialog.ShowDialog(this);
									   });
					}
				}


            	if (vm.is_a_snapshot)
                {
                    VM snapshotOf = vm.Connection.Resolve(vm.snapshot_of);
                    s.AddEntry(Messages.SNAPSHOT_OF, snapshotOf == null ? string.Empty : snapshotOf.Name);
                    s.AddEntry(Messages.CREATION_TIME, HelpersGUI.DateTimeToString(vm.snapshot_time.ToLocalTime() + vm.Connection.ServerTimeOffset, Messages.DATEFORMAT_DMY_HMS, true));
                }

                if (!vm.is_a_template)
                {
                    GenerateVirtualisationStatusForGeneralBox(s, vm);

                    if (vm.RunningTime != null)
                        s.AddEntry(FriendlyName("VM.uptime"), vm.RunningTime.ToString());

                    if (vm.IsP2V)
                    {
                        s.AddEntry(FriendlyName("VM.P2V_SourceMachine"), vm.P2V_SourceMachine);
                        s.AddEntry(FriendlyName("VM.P2V_ImportDate"), HelpersGUI.DateTimeToString(vm.P2V_ImportDate.ToLocalTime(), Messages.DATEFORMAT_DMY_HMS, true));
                    }

                    // Dont show if WLB is enabled.
                    if (VMCanChooseHomeServer(vm))
                    {
                        s.AddEntry(FriendlyName("VM.affinity"), vm.AffinityServerString,
                            new PropertiesToolStripMenuItem(new VmEditHomeServerCommand(Program.MainWindow, xenObject)));}
                }
            }
            else if (xenObject is XenObject<SR>)
            {
                SR sr = xenObject as SR;
                s.AddEntry(Messages.TYPE, sr.FriendlyTypeName);

                if (sr.content_type != SR.Content_Type_ISO && sr.GetSRType(false) != SR.SRTypes.udev)
                {
                    s.AddEntry(FriendlyName("SR.size"), sr.SizeString);

                    /* DISABLED THIN PROVISIONING
                    if (sr.type == "lvmohba" || sr.type == "lvmoiscsi")
                    {
                        // add entries related to thin lvhd SRs
                        IEnumerable<CommandToolStripMenuItem> menuItems = null;
                        if (!sr.IsThinProvisioned)
                        {
                            menuItems = new[] { new CommandToolStripMenuItem(new ConvertToThinSRCommand(Program.MainWindow, new List<SelectedItem>() { new SelectedItem(xenObject) }), true) };
                        }
                        s.AddEntry(FriendlyName("SR.provisioning"), sr.IsThinProvisioned 
                            ? string.Format(Messages.SR_THIN_PROVISIONING_COMMITTED, sr.PercentageCommitted) 
                            : Messages.SR_THICK_PROVISIONING, menuItems);
                        
                        if(sr.IsThinProvisioned && sr.sm_config.ContainsKey("initial_allocation") && sr.sm_config.ContainsKey("allocation_quantum"))
                        {
                            s.AddEntry(FriendlyName("SR.disk-space-allocations"), 
                                       Helpers.GetAllocationProperties(sr.sm_config["initial_allocation"], sr.sm_config["allocation_quantum"]));
                        }
                    } 
                    */
                }

                if (sr.GetScsiID() != null)
                    s.AddEntry(FriendlyName("SR.scsiid"), sr.GetScsiID() ?? Messages.UNKNOWN);

                // if in folder-view or if looking at SR on storagelink then display
                // location here
                if (Program.MainWindow.SelectionManager.Selection.HostAncestor == null && Program.MainWindow.SelectionManager.Selection.PoolAncestor == null)
                {
                    IXenObject belongsTo = Helpers.GetPool(sr.Connection);

                    if (belongsTo != null)
                    {
                        s.AddEntry(Messages.POOL, Helpers.GetName(belongsTo));
                    }
                    else
                    {
                        belongsTo = Helpers.GetMaster(sr.Connection);

                        if (belongsTo != null)
                        {
                            s.AddEntry(Messages.SERVER, Helpers.GetName(belongsTo));
                        }
                    }
                }
            }
            else if (xenObject is XenObject<Pool>)
            {
                Pool p = xenObject as Pool;
                if (p != null)
                {
                    s.AddEntry(Messages.POOL_LICENSE, p.LicenseString);
                    if (Helpers.ClearwaterOrGreater(p.Connection))
                        s.AddEntry(Messages.NUMBER_OF_SOCKETS, p.CpuSockets.ToString());

                    var master = p.Connection.Resolve(p.master);
                    if (master != null)
                    {
                        if (p.IsPoolFullyUpgraded)
                        {
                            s.AddEntry(Messages.SOFTWARE_VERSION_PRODUCT_VERSION, master.ProductVersionText);
                        }
                        else
                        {
                            var cmd = new RollingUpgradeCommand(Program.MainWindow);
                            var runRpuWizard = new ToolStripMenuItem(Messages.ROLLING_POOL_UPGRADE_ELLIPSIS,
                                                                     null,
                                                                     (sender, args) => cmd.Execute());

                            s.AddEntryLink(Messages.SOFTWARE_VERSION_PRODUCT_VERSION,
                                           string.Format(Messages.POOL_VERSIONS_LINK_TEXT, master.ProductVersionText),
                                           new[] { runRpuWizard },
                                           cmd);
                        }
                    }
                }
            }

            s.AddEntry(FriendlyName("host.uuid"), GetUUID(xenObject));
        }
Example #2
0
        private void generateGeneralBox()
        {
            PDSection s = pdSectionGeneral;

            s.AddEntry(FriendlyName("host.name_label"), Helpers.GetName(xenObject),
                new PropertiesToolStripMenuItem(new PropertiesCommand(Program.MainWindow, xenObject)));

            if (!(xenObject is IStorageLinkObject))
            {
                VM vm = xenObject as VM;
                if (vm == null || vm.DescriptionType != VM.VmDescriptionType.None)
                {
                    s.AddEntry(FriendlyName("host.name_description"), xenObject.Description,
                               new PropertiesToolStripMenuItem(new DescriptionPropertiesCommand(Program.MainWindow, xenObject)));
                }

                GenTagRow(s);
                GenFolderRow(s);
            }

            if (xenObject is Host)
            {
                Host host = xenObject as Host;

                if (Helpers.GetPool(xenObject.Connection) != null)
                    s.AddEntry(Messages.POOL_MASTER, host.IsMaster() ? Messages.YES : Messages.NO);

                if (!host.IsLive)
                {
                    s.AddEntry(FriendlyName("host.enabled"), Messages.HOST_NOT_LIVE, Color.Red);
                }
                else if (!host.enabled)
                {
                    var item = new ToolStripMenuItem(Messages.EXIT_MAINTENANCE_MODE);
                    item.Click += delegate
                        {
                            new HostMaintenanceModeCommand(Program.MainWindow, host,
                                                           HostMaintenanceModeCommandParameter.Exit).Execute();
                        };
                    s.AddEntry(FriendlyName("host.enabled"),
                               host.MaintenanceMode ? Messages.HOST_IN_MAINTENANCE_MODE : Messages.DISABLED,
                               new[] { item },
                               Color.Red);
                }
                else
                {
                    var item = new ToolStripMenuItem(Messages.ENTER_MAINTENANCE_MODE);
                    item.Click += delegate
                        {
                            new HostMaintenanceModeCommand(Program.MainWindow, host,
                                HostMaintenanceModeCommandParameter.Enter).Execute();
                        };
                    s.AddEntry(FriendlyName("host.enabled"), Messages.YES, item);
                }

                s.AddEntry(FriendlyName("host.iscsi_iqn"), host.iscsi_iqn,
                    new PropertiesToolStripMenuItem(new IqnPropertiesCommand(Program.MainWindow, xenObject)));
                s.AddEntry(FriendlyName("host.log_destination"), host.SysLogDestination ?? Messages.HOST_LOG_DESTINATION_LOCAL,
                   new PropertiesToolStripMenuItem(new HostEditLogDestinationCommand(Program.MainWindow, xenObject)));

                PrettyTimeSpan uptime = host.Uptime;
                PrettyTimeSpan agentUptime = host.AgentUptime;
                s.AddEntry(FriendlyName("host.uptime"), uptime == null ? "" : host.Uptime.ToString());
                s.AddEntry(FriendlyName("host.agentUptime"), agentUptime == null ? "" : host.AgentUptime.ToString());

                if ((Helpers.GeorgeOrGreater(xenObject.Connection) && host.external_auth_type == Auth.AUTH_TYPE_AD))
                    s.AddEntry(FriendlyName("host.external_auth_service_name"), host.external_auth_service_name);
            }
            else if (xenObject is VM)
            {
                VM vm = xenObject as VM;

                s.AddEntry(FriendlyName("VM.OSName"), vm.GetOSName());

                s.AddEntry(FriendlyName("VM.OperatingMode"), vm.IsHVM ? Messages.VM_OPERATING_MODE_HVM : Messages.VM_OPERATING_MODE_PV);

                if (!vm.DefaultTemplate && Helpers.MidnightRideOrGreater(vm.Connection))
                {
                    s.AddEntry(Messages.BIOS_STRINGS_COPIED, vm.BiosStringsCopied ? Messages.YES : Messages.NO);
                }

                if (Helpers.BostonOrGreater(vm.Connection) && vm.Connection != null)
                {
                    var appl = vm.Connection.Resolve(vm.appliance);
                    if (appl != null)
                    {
                        var applProperties = new ToolStripMenuItem(Messages.VM_APPLIANCE_PROPERTIES);
                        applProperties.Click +=
                            (sender, e) =>
                                {
                                    using (PropertiesDialog propertiesDialog = new PropertiesDialog(appl))
                                        propertiesDialog.ShowDialog(this);
                                };

                        s.AddEntryLink(Messages.VM_APPLIANCE, appl.Name, new[] { applProperties },
                                       () =>
                                       {
                                           using (PropertiesDialog propertiesDialog = new PropertiesDialog(appl))
                                               propertiesDialog.ShowDialog(this);
                                       });
                    }
                }

                if (vm.is_a_snapshot)
                {
                    VM snapshotOf = vm.Connection.Resolve(vm.snapshot_of);
                    s.AddEntry(Messages.SNAPSHOT_OF, snapshotOf == null ? string.Empty : snapshotOf.Name);
                    s.AddEntry(Messages.CREATION_TIME, HelpersGUI.DateTimeToString(vm.snapshot_time.ToLocalTime() + vm.Connection.ServerTimeOffset, Messages.DATEFORMAT_DMY_HMS, true));
                }

                if (!vm.is_a_template)
                {
                    GenerateVirtualisationStatusForGeneralBox(s, vm);

                    if (vm.RunningTime != null)
                        s.AddEntry(FriendlyName("VM.uptime"), vm.RunningTime.ToString());

                    if (vm.IsP2V)
                    {
                        s.AddEntry(FriendlyName("VM.P2V_SourceMachine"), vm.P2V_SourceMachine);
                        s.AddEntry(FriendlyName("VM.P2V_ImportDate"), HelpersGUI.DateTimeToString(vm.P2V_ImportDate.ToLocalTime(), Messages.DATEFORMAT_DMY_HMS, true));
                    }

                    // Dont show if WLB is enabled.
                    if (VMCanChooseHomeServer(vm))
                    {
                        s.AddEntry(FriendlyName("VM.affinity"), vm.AffinityServerString,
                            new PropertiesToolStripMenuItem(new VmEditHomeServerCommand(Program.MainWindow, xenObject)));}
                }
            }
            else if (xenObject is XenObject<SR>)
            {
                SR sr = xenObject as SR;
                s.AddEntry(Messages.TYPE, sr.FriendlyTypeName);

                if (sr.content_type != SR.Content_Type_ISO && sr.GetSRType(false) != SR.SRTypes.udev)
                {
                    s.AddEntry(FriendlyName("SR.size"), sr.SizeString);
                    s.AddEntry(FriendlyName("SR.provisioning"), sr.IsThinProvisioned ? Messages.SR_THIN_PROVISIONING : Messages.SR_THICK_PROVISIONING);
                }

                if (sr.GetScsiID() != null)
                    s.AddEntry(FriendlyName("SR.scsiid"), sr.GetScsiID() ?? Messages.UNKNOWN);

                // if in folder-view or if looking at SR on storagelink then display
                // location here
                if (Program.MainWindow.SelectionManager.Selection.HostAncestor == null && Program.MainWindow.SelectionManager.Selection.PoolAncestor == null)
                {
                    IXenObject belongsTo = Helpers.GetPool(sr.Connection);

                    if (belongsTo != null)
                    {
                        s.AddEntry(Messages.POOL, Helpers.GetName(belongsTo));
                    }
                    else
                    {
                        belongsTo = Helpers.GetMaster(sr.Connection);

                        if (belongsTo != null)
                        {
                            s.AddEntry(Messages.SERVER, Helpers.GetName(belongsTo));
                        }
                    }
                }
            }
            else if (xenObject is XenObject<Pool>)
            {
                Pool p = xenObject as Pool;
                if (p != null)
                {
                    s.AddEntry(Messages.POOL_LICENSE, p.LicenseString);
                    if (Helpers.ClearwaterOrGreater(p.Connection))
                        s.AddEntry(Messages.NUMBER_OF_SOCKETS, p.CpuSockets.ToString());

                    var master = p.Connection.Resolve(p.master);
                    if (master != null)
                    {
                        if (p.IsPoolFullyUpgraded)
                        {
                            s.AddEntry(Messages.SOFTWARE_VERSION_PRODUCT_VERSION, master.ProductVersionText);
                        }
                        else
                        {
                            var cmd = new RollingUpgradeCommand(Program.MainWindow);
                            var runRpuWizard = new ToolStripMenuItem(Messages.ROLLING_POOL_UPGRADE_ELLIPSIS,
                                                                     null,
                                                                     (sender, args) => cmd.Execute());

                            s.AddEntryLink(Messages.SOFTWARE_VERSION_PRODUCT_VERSION,
                                           string.Format(Messages.POOL_VERSIONS_LINK_TEXT, master.ProductVersionText),
                                           new[] { runRpuWizard },
                                           cmd);
                        }
                    }
                }
            }
            else if (xenObject is StorageLinkPool)
            {
                var pool = (StorageLinkPool)xenObject;

                string capacityText = Util.DiskSizeString(pool.Capacity * 1024L * 1024L);
                string usedSpaceText = Util.DiskSizeString(pool.UsedSpace * 1024L * 1024L);
                string text = string.Format(Messages.STORAGELINK_POOL_SIZE_USED, usedSpaceText, capacityText);

                s.AddEntry(Messages.SIZE, text);
            }
            else if (xenObject is StorageLinkServer)
            {
                StorageLinkServer server = (StorageLinkServer)xenObject;
                s.AddEntry(Messages.USERNAME, server.StorageLinkConnection.Username);

                string error = server.StorageLinkConnection.Error;

                if (!string.IsNullOrEmpty(error))
                {
                    s.AddEntry(Messages.ERROR, error);
                }
            }
            else if (xenObject is StorageLinkSystem)
            {
                StorageLinkSystem sys = (StorageLinkSystem)xenObject;
                s.AddEntry(Messages.FULL_NAME, sys.FullName);
                s.AddEntry(Messages.MODEL, sys.Model);
                s.AddEntry(Messages.SERIAL_NUMBER, sys.SerialNumber);
            }

            s.AddEntry(FriendlyName("host.uuid"), GetUUID(xenObject));
        }