Exemplo n.º 1
0
        private void fillInterfacesForHost(Host Host, bool includeHostSuffix)
        {
            PDSection s = pdSectionManagementInterfaces;

            ToolStripMenuItem editValue = new ToolStripMenuItem(Messages.EDIT) { Image = Properties.Resources.edit_16 };
            editValue.Click += delegate
                {
                    NetworkingProperties p = new NetworkingProperties(Host, null);
                    p.ShowDialog(Program.MainWindow);
                };

            if (!string.IsNullOrEmpty(Host.hostname))
            {
                if (!includeHostSuffix)
                    s.AddEntry(FriendlyName("host.hostname"), Host.hostname, editValue);
                else
                    s.AddEntry(
                        string.Format(Messages.PROPERTY_ON_OBJECT, FriendlyName("host.hostname"), Helpers.GetName(Host)),
                        Host.hostname,
                        editValue);
            }
            foreach (PIF pif in xenObject.Connection.ResolveAll<PIF>(Host.PIFs))
            {
                if (pif.management)
                {
                    if (!includeHostSuffix)
                        s.AddEntry(Messages.MANAGEMENT_INTERFACE, pif.FriendlyIPAddress, editValue);
                    else
                        s.AddEntry(
                            string.Format(Messages.PROPERTY_ON_OBJECT, Messages.MANAGEMENT_INTERFACE, Helpers.GetName(Host)),
                            pif.FriendlyIPAddress,
                            editValue);
                }
            }

            foreach (PIF pif in xenObject.Connection.ResolveAll<PIF>(Host.PIFs))
            {
                if (pif.IsSecondaryManagementInterface(Properties.Settings.Default.ShowHiddenVMs))
                {
                    if (!includeHostSuffix)
                        s.AddEntry(pif.ManagementPurpose.Ellipsise(30), pif.FriendlyIPAddress, editValue);
                    else
                        s.AddEntry(
                            string.Format(Messages.PROPERTY_ON_OBJECT, pif.ManagementPurpose.Ellipsise(30), Helpers.GetName(Host)),
                            pif.FriendlyIPAddress,
                            editValue);
                }
            }
        }
Exemplo n.º 2
0
        private void buttonManagementInterfaces_Click(object sender, EventArgs e)
        {
            PIF selectedPIF = null;
            if (dataGridViewEx1.SelectedRows.Count == 1)
            {
                selectedPIF = ((PIFRow)dataGridViewEx1.SelectedRows[0]).PIF;
            }


            NetworkingProperties interfacesDialog = null;
            Host host = _xenObject as Host;
            if (host != null)
            {
                interfacesDialog = new NetworkingProperties(host, selectedPIF);
            }
            else
            {
                System.Diagnostics.Trace.Assert(_xenObject is Pool);
                Pool pool = (Pool)_xenObject;
                if (pool.Connection.Cache.HostCount <= 1)
                {
                    // Standalone host -- we redirect to the per-host dialog
                    Host _host = pool.Connection.Resolve(pool.master);
                    interfacesDialog = new NetworkingProperties(_host, selectedPIF);
                }
                else
                    interfacesDialog = new NetworkingProperties(pool, selectedPIF);
            }

            interfacesDialog.ShowDialog(this);
        }