Esempio n. 1
0
        private void AddVIFRow(VIF vif)
        {
            var row = new VifRow(vif);

            XenAPI.Network network = m_selectedConnection.Resolve(vif.network);
            bool           isGuestInstallerNetwork = network != null && network.IsGuestInstallerNetwork();

            ToStringWrapper <XenAPI.Network> comboBoxEntry = FindComboBoxEntryForNetwork(network);

            // CA-66962: Don't choose disallowed networks: choose a better one instead.
            // CA-79930/CA-73056: Except for the guest installer network, which we let
            // through for now, but hide it below.
            if (comboBoxEntry == null && !isGuestInstallerNetwork)
            {
                network       = GetDefaultNetwork();
                comboBoxEntry = FindComboBoxEntryForNetwork(network);
                vif.network   = new XenRef <XenAPI.Network>(network.opaque_ref);
            }

            row.CreateCells(m_networkGridView,
                            String.Format(Messages.NETWORKPICKER_INTERFACE, vif.device),
                            vif.MAC,
                            comboBoxEntry);
            row.Cells[0].ReadOnly = true;

            // CA-73056: A row for the guest installer network shouldn't show up. But we still need
            // it present but invisible, otherwise the corresponding VIF doesn't get created at all.
            // CA-218956 - Expose HIMN when showing hidden objects
            if (isGuestInstallerNetwork && !XenAdmin.Properties.Settings.Default.ShowHiddenVMs)
            {
                row.Visible = false;
            }

            m_networkGridView.Rows.Add(row);
        }
Esempio n. 2
0
        public bool IsPrimaryManagementInterface()
        {
            if (!management)
            {
                return(false);
            }

            Network nw = Connection.Resolve(network);

            return(nw != null && !nw.IsGuestInstallerNetwork());
        }
Esempio n. 3
0
        private void UpdateEnablement()
        {
            bool locked = _xenObject.Locked;

            if (SelectedNetwork != null)
            {
                XenAPI.Network TheNetwork = SelectedNetwork;

                AddNetworkButton.Enabled = !locked;

                EditNetworkButton.Enabled = !locked && !TheNetwork.Locked && !TheNetwork.IsSlave() && !TheNetwork.CreateInProgress() &&
                                            !TheNetwork.IsGuestInstallerNetwork();
                // CA-218956 - Expose HIMN when showing hidden objects
                // HIMN should not be editable

                if (HasPhysicalNonBondNIC(TheNetwork))
                {
                    RemoveNetworkButton.Enabled = false;
                    RemoveButtonContainer.SetToolTip(Messages.TOOLTIP_REMOVE_PIF);
                }
                else
                {
                    RemoveNetworkButton.Enabled = EditNetworkButton.Enabled;
                    // CA-218956 - Expose HIMN when showing hidden objects
                    // HIMN should not be removable

                    RemoveButtonContainer.SetToolTip("");
                }
            }
            else if (SelectedVif != null)
            {
                VIF vif = SelectedVif;
                AddNetworkButton.Enabled = !locked;
                // In this case read vif.currently_attached as is-it-plugged
                RemoveNetworkButton.Enabled  = !locked && (vif.allowed_operations.Contains(vif_operations.unplug) || !vif.currently_attached);
                EditNetworkButton.Enabled    = !locked && (vif.allowed_operations.Contains(vif_operations.unplug) || !vif.currently_attached);
                buttonActivateToggle.Enabled = !locked && (
                    vif.currently_attached && vif.allowed_operations.Contains(vif_operations.unplug) ||
                    !vif.currently_attached && vif.allowed_operations.Contains(vif_operations.plug));

                buttonActivateToggle.Text = vif.currently_attached ? Messages.VM_NETWORK_TAB_DEACTIVATE_BUTTON_LABEL : Messages.VM_NETWORK_TAB_ACTIVATE_BUTTON_LABEL;

                VM vm = (VM)XenObject;
                if (vm.power_state == vm_power_state.Suspended)
                {
                    RemoveButtonContainer.SetToolTip(Messages.TOOLTIP_REMOVE_NETWORK_SUSPENDED);
                    EditButtonContainer.SetToolTip(vm.HasNewVirtualisationStates() ? Messages.TOOLTIP_EDIT_NETWORK_IO_DRIVERS : Messages.TOOLTIP_EDIT_NETWORK_TOOLS);
                    toolTipContainerActivateToggle.SetToolTip(vif.currently_attached
                        ? Messages.TOOLTIP_DEACTIVATE_VIF_SUSPENDED : Messages.TOOLTIP_ACTIVATE_VIF_SUSPENDED);
                }
                else
                {
                    if (vm.power_state == vm_power_state.Running && !vm.GetVirtualisationStatus().HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                    {
                        RemoveButtonContainer.SetToolTip(vm.HasNewVirtualisationStates() ? Messages.TOOLTIP_REMOVE_NETWORK_IO_DRIVERS : Messages.TOOLTIP_REMOVE_NETWORK_TOOLS);
                        EditButtonContainer.SetToolTip(vm.HasNewVirtualisationStates() ? Messages.TOOLTIP_EDIT_NETWORK_IO_DRIVERS : Messages.TOOLTIP_EDIT_NETWORK_TOOLS);
                        toolTipContainerActivateToggle.SetToolTip(vif.currently_attached
                            ? Messages.TOOLTIP_DEACTIVATE_VIF_TOOLS : Messages.TOOLTIP_ACTIVATE_VIF_TOOLS);
                    }
                    else
                    {
                        RemoveButtonContainer.RemoveAll();
                        EditButtonContainer.RemoveAll();
                        toolTipContainerActivateToggle.RemoveAll();
                    }
                }
            }
            else
            {
                AddNetworkButton.Enabled     = !locked;
                RemoveNetworkButton.Enabled  = false;
                EditNetworkButton.Enabled    = false;
                buttonActivateToggle.Enabled = false;
            }
        }
Esempio n. 4
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();
        }