Пример #1
0
        private void RemoveNetworkButton_Click(object sender, EventArgs e)
        {
            if (NetworksGridView.SelectedRows.Count == 0)
            {
                return;
            }

            XenAPI.Network network = SelectedNetwork;
            if (network != null && network.IsBond())
            {
                var destroyBondCommand = new DestroyBondCommand(Program.MainWindow, network);
                destroyBondCommand.Execute();
            }
            else
            {
                // Check and see if the system is running in automation test mode.  If so, then
                // do not launch the popup Y/N dialog.
                DialogResult result;
                if (Program.RunInAutomatedTestMode)
                {
                    result = DialogResult.Yes;
                }
                else if (XenObject is VM)
                {
                    // Deleting a VIF, not a Network.
                    using (var dlg = new WarningDialog(Messages.MESSAGEBOX_VIF_DELETE,
                                                       ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)
                    {
                        WindowTitle = Messages.MESSAGEBOX_VIF_DELETE_TITLE
                    })
                    {
                        result = dlg.ShowDialog(Program.MainWindow);
                    }
                }
                else
                {
                    using (var dlg = new WarningDialog(Messages.MESSAGEBOX_NETWORK_DELETE,
                                                       ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)
                    {
                        WindowTitle = Messages.MESSAGEBOX_NETWORK_DELETE_TITLE
                    })
                    {
                        result = dlg.ShowDialog(Program.MainWindow);
                    }
                }

                if (result == DialogResult.Yes)
                {
                    DoRemoveNetwork();
                }
            }
        }
Пример #2
0
        public void Repopulate()
        {
            if (network == null || host == null)
            {
                return;
            }

            populateHostNicList();

            //set minimum value for VLAN
            numUpDownVLAN.Minimum = Helpers.VLAN0Allowed(network.Connection) ? 0 : 1;

            PIF pif = GetNetworksPIF();

            if (pif != null)
            {
                bool editable = Editable(pif);

                HostVLanLabel.Visible = editable;
                HostNicLabel.Visible  = editable;
                numUpDownVLAN.Visible = editable;
                HostPNICList.Visible  = editable;
                nicHelpLabel.Visible  = editable;

                if (editable)
                {
                    // virtual pif (external network on VLAN)
                    numUpDownVLAN.Value = pif.VLAN;
                    PIF ThePhysicalPIF = FindAssociatedPhysicalPIF();
                    if (ThePhysicalPIF != null)
                    {
                        HostPNICList.SelectedItem = ThePhysicalPIF.Name();
                    }
                    else
                    {
                        HostPNICList.SelectedItem = pif.Name();
                    }
                }

                bool hasBondMode = network.IsBond();
                groupBoxBondMode.Visible = hasBondMode;

                bool supportsLinkAggregation = Helpers.SupportsLinkAggregationBond(network.Connection);
                radioButtonLacpSrcMac.Visible = radioButtonLacpTcpudpPorts.Visible = supportsLinkAggregation;

                if (hasBondMode)
                {
                    switch (NetworkBondMode)
                    {
                    case bond_mode.balance_slb:
                        radioButtonBalanceSlb.Checked = true;
                        break;

                    case bond_mode.active_backup:
                        radioButtonActiveBackup.Checked = true;
                        break;

                    case bond_mode.lacp:
                        if (supportsLinkAggregation)
                        {
                            switch (HashingAlgorithm)
                            {
                            case Bond.hashing_algoritm.tcpudp_ports:
                                radioButtonLacpTcpudpPorts.Checked = true;
                                break;

                            default:
                                radioButtonLacpSrcMac.Checked = true;
                                break;
                            }
                        }
                        break;
                    }
                }
            }
            else
            {
                // internal network
                HostVLanLabel.Visible = true;
                HostNicLabel.Visible  = true;
                numUpDownVLAN.Visible = true;
                HostVLanLabel.Visible = true;
                HostPNICList.Visible  = true;
                nicHelpLabel.Visible  = true;

                groupBoxBondMode.Visible  = false;
                numUpDownVLAN.Enabled     = false;
                HostPNICList.SelectedItem = HostPNICList.Items[0];
            }

            foreach (VIF v in network.Connection.ResolveAll <VIF>(network.VIFs))
            {
                VM vm = network.Connection.Resolve <VM>(v.VM);
                if (vm.power_state != vm_power_state.Running || vm.GetVirtualisationStatus(out _).HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                {
                    continue;
                }

                runningVMsWithoutTools = true;
                break;
            }

            // Populate Automatic checkbox
            autoCheckBox.Checked = network.GetAutoPlug();
            autoCheckBox.Enabled = !network.IsGuestInstallerNetwork();
            // in case some odd value has been set on the CLI
            numericUpDownMTU.Maximum = Math.Max(network.MTU, XenAPI.Network.MTU_MAX);
            numericUpDownMTU.Minimum = Math.Min(network.MTU, XenAPI.Network.MTU_MIN);
            numericUpDownMTU.Value   = network.MTU;
            numericUpDownMTU.Visible = network.CanUseJumboFrames();
        }