示例#1
0
            private void RegisterPifEvents()
            {
                if (Pif != null)
                {
                    Pif.PropertyChanged += Server_PropertyChanged;

                    // Listen for Tunnel and PIF_metrics changes which is necessary for Link Status updates (CA-46103)
                    if (Pif.IsTunnelAccessPIF())
                    {
                        Tunnel tunnel = Pif.Connection.Resolve(Pif.tunnel_access_PIF_of[0]);
                        if (tunnel != null)
                        {
                            tunnel.PropertyChanged += Pif_PropertyChanged;
                        }
                    }
                    else
                    {
                        PIF_metrics metrics = Pif.PIFMetrics();
                        if (metrics != null)
                        {
                            metrics.PropertyChanged += Pif_PropertyChanged;
                        }
                    }
                }
            }
示例#2
0
        // Get the selected PIF.
        // Return null for single-host internal network, or a new VLAN.
        private PIF GetSelectedPIF()
        {
            // If we are on a physical network we don't look at the VLAN combo box, as it is obv not used
            PIF p = GetNetworksPIF();

            if (p != null && p.physical)
            {
                return(p);
            }

            if (p != null && p.IsBondNIC())
            {
                return(p);
            }

            // also no need to look in the combo box if we're a CHIN as they can't be edited either
            if (p != null && p.IsTunnelAccessPIF())
            {
                return(p);
            }

            p = NICNameToVirtualPIF((string)HostPNICList.SelectedItem, (long)numUpDownVLAN.Value);

            // this is either now null (on an internal network or a new VLAN) or a non phys pif representing a vlan (external network)
            return(p);
        }
示例#3
0
 private void destroyPIFs()
 {
     foreach (PIF pif in PIFs)
     {
         if (pif.IsTunnelAccessPIF())
         {
             // A tunnel access PIF is destroyed by destroying its tunnel.
             // (Actually each network will have either all tunnel access PIFs (if
             // it is a CHIN) or all regular PIFs (if it isn't), but we don't use
             // that: we do it PIF-by-PIF).
             foreach (Tunnel tunnel in Connection.ResolveAll(pif.tunnel_access_PIF_of))  // actually there will only ever be one
             {
                 Tunnel.destroy(Session, tunnel.opaque_ref);
             }
         }
         else
         {
             if (!pif.physical)
             {
                 VLAN.destroy(Session, pif.VLAN_master_of);
             }
             else
             {
                 // do we ever destroy physical pifs anyway? not sure this is something we need but here for completeness
                 PIF.forget(Session, pif.opaque_ref);
             }
         }
     }
     PIFs = null;
 }
示例#4
0
 // Can the network's NIC, SR-IOV network and VLAN be edited?
 private bool Editable(PIF pif)
 {
     return(pif == null || (!pif.IsPhysical() && !pif.IsTunnelAccessPIF() && (pif.sriov_logical_PIF_of == null || pif.sriov_logical_PIF_of.Count == 0)));
 }
示例#5
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;
            }
        }
示例#6
0
 // Can the network's NIC and VLAN be edited?
 private bool Editable(PIF pif)
 {
     return(pif == null || (!pif.IsPhysical() && !pif.IsTunnelAccessPIF()));
 }