コード例 #1
0
        private NetworkComboBoxItem CreateNewItem(PIF pif)
        {
            var network = PopulateConnection.Resolve(pif.network);

            return(new NetworkComboBoxItem
            {
                IncludePoolNameInComboBox = IncludePoolNameInComboBox,
                IsManagement = pif.management,
                Network = network,
                NetworkIsConnected = pif.LinkStatus == PIF.LinkState.Connected,
                HasIPAddress = pif.IsManagementInterface(false)
            });
        }
コード例 #2
0
        private bool CanShowItem(PIF pif, out NetworkComboBoxItem existingItem)
        {
            existingItem = Items.Cast <NetworkComboBoxItem>().FirstOrDefault(i => i.Network.opaque_ref == pif.network.opaque_ref);

            if (existingItem != null)
            {
                return(false);
            }

            if (ExcludeDisconnectedNetworks && pif.LinkStatus() != PIF.LinkState.Connected)
            {
                return(false);
            }

            if (ExcludeNetworksWithoutIpAddresses && !pif.IsManagementInterface(false))
            {
                return(false);
            }

            return(true);
        }
コード例 #3
0
        private void SetMTUControlEnablement()
        {
            if (!network.CanUseJumboFrames)
            {
                labelCannotConfigureMTU.Visible = false;
                labelMTU.Visible = numericUpDownMTU.Visible = false;
                return;
            }

            if (SelectedIsInternal)
            {
                // internal
                // MTU doesn't really do much here
                labelCannotConfigureMTU.Visible = false;
                numericUpDownMTU.Enabled        = false;
                return;
            }

            PIF networksPIF = GetSelectedPIF();  // returns null for new VLAN

            if (networksPIF == null || !networksPIF.IsManagementInterface(XenAdmin.Properties.Settings.Default.ShowHiddenVMs))
            {
                // non management external (could be bond)

                if (runningVMsWithoutTools)
                {
                    // The MTU controls have been designed to be more relaxed than the rest of the page, we will only block if we can't unplug the vifs
                    // due to lack of tools (which then lets us unplug the PIFs)
                    labelCannotConfigureMTU.Text    = Messages.CANNOT_CONFIGURE_JUMBO_VM_NO_TOOLS;
                    labelCannotConfigureMTU.Visible = true;
                    numericUpDownMTU.Enabled        = false;
                }
                else if (networksPIF != null && networksPIF.IsTunnelAccessPIF)
                {
                    // This branch is currently not in use as setting the MTU is disabled on CHINs.
                    // Left in in case future support is added

                    // with no other more danger warnings we should tell the user it's recommended that they set the MTU on the underlying networks to match
                    XenAPI.Network mainNetwork = FindCHINMainNetwork(networksPIF);
                    labelCannotConfigureMTU.Text = string.Format(Messages.SET_MTU_ON_CHINS_UNDER_NETWORK, mainNetwork.Name);
                    // incase 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.Enabled        = true;
                    labelCannotConfigureMTU.Visible = true;
                }
                else
                {
                    labelCannotConfigureMTU.Visible = false;
                    // 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.Enabled = true;
                }
            }
            else
            {
                // physical or virtual external management (could be bond)
                numericUpDownMTU.Enabled        = false;
                labelCannotConfigureMTU.Text    = string.Format(Messages.CANNOT_CONFIGURE_JUMBO_DISTURB_MANAGEMENT, networksPIF.ManagementInterfaceNameOrUnknown);
                labelCannotConfigureMTU.Visible = true;
            }
        }