Esempio n. 1
0
        private bool ShowNetwork(object targetRef, XenAPI.Network network, string vsId)
        {
            if (network.IsSriov() && !AllowSriovNetwork(network, vsId))
            {
                return(false);
            }

            if (!network.Show(Properties.Settings.Default.ShowHiddenVMs))
            {
                return(false);
            }

            if (network.IsSlave())
            {
                return(false);
            }

            var  targetHostRef = targetRef as XenRef <Host>;
            Host targetHost    = targetHostRef == null ? null : TargetConnection.Resolve(targetHostRef);

            if (targetHost != null && !targetHost.CanSeeNetwork(network))
            {
                return(false);
            }

            if (targetHost == null && !network.AllHostsCanSeeNetwork())
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Function tells you when you can / cannot show the network based on the following rules
        /// 1) Don't show the guest installer network or networks with HideFromXenCenter==true.
        /// 2) If you selected an affinity, only show networks that host can see
        /// 3) If you haven't selected an affinity, only show networks all hosts can see
        /// </summary>
        private bool ShowNetwork(XenAPI.Network network)
        {
            if (!network.Show(Properties.Settings.Default.ShowHiddenVMs))
            {
                return(false);
            }

            if (network.IsSlave())
            {
                return(false);
            }

            if (m_selectedAffinity != null && !m_selectedAffinity.CanSeeNetwork(network))
            {
                return(false);
            }

            if (m_selectedAffinity == null && !network.AllHostsCanSeeNetwork())
            {
                return(false);
            }

            if (network.IsSriov() && !m_vm.HasSriovRecommendation())
            {
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        private bool ShowNetwork(Host targetHost, XenAPI.Network network, string vsId)
        {
            if (network.IsSriov() && !AllowSriovNetwork(network, vsId))
            {
                return(false);
            }

            if (!network.Show(Properties.Settings.Default.ShowHiddenVMs))
            {
                return(false);
            }

            if (network.IsSlave())
            {
                return(false);
            }

            if (targetHost != null && !targetHost.CanSeeNetwork(network))
            {
                return(false);
            }

            if (targetHost == null && !network.AllHostsCanSeeNetwork())
            {
                return(false);
            }

            return(true);
        }
Esempio n. 4
0
            private VirtualTreeNode AddNetworkNode(XenAPI.Network network)
            {
                bool   hidden  = network.IsHidden();
                bool   slave   = network.IsSlave();
                string rawName = network.Name();
                String name    = slave
                                  ? String.Format(Messages.NIC_SLAVE, rawName)
                                  : hidden
                                        ? String.Format(Messages.X_HIDDEN, rawName)
                                        : rawName;

                return(AddNode(name, Images.GetIconFor(network), slave || hidden, network));
            }
Esempio n. 5
0
            public void UpdateDetails()
            {
                Enabled = !Network.IsSlave();

                DeregisterPifEvents();

                Pif = Helpers.FindPIF(Network, Xmo as Host);

                RegisterPifEvents();

                ImageCell.Value       = Properties.Resources._000_Network_h32bit_16;
                NameCell.Value        = NetworkName();
                DescriptionCell.Value = Network.Description();
                NicCell.Value         = Helpers.GetName(Pif);
                VlanCell.Value        = Helpers.VlanString(Pif);
                AutoCell.Value        = Network.GetAutoPlug() ? Messages.YES : Messages.NO;
                LinkStatusCell.Value  = Xmo is Pool?Network.LinkStatusString() :
                                            Pif == null ? Messages.NONE : Pif.LinkStatusString();

                MacCell.Value = Pif != null && Pif.IsPhysical() ? Pif.MAC : Messages.SPACED_HYPHEN;
                MtuCell.Value = Network.CanUseJumboFrames() ? Network.MTU.ToString() : Messages.SPACED_HYPHEN;
            }
Esempio n. 6
0
            public void UpdateDetails()
            {
                Enabled = !Network.IsSlave();

                DeregisterPifEvents();

                Pif = Helpers.FindPIF(Network, Xmo as Host);

                RegisterPifEvents();

                ImageCell.Value       = Properties.Resources._000_Network_h32bit_16;
                NameCell.Value        = NetworkName();
                DescriptionCell.Value = Network.Description();
                NicCell.Value         = Helpers.GetName(Pif);
                VlanCell.Value        = Helpers.VlanString(Pif);
                AutoCell.Value        = Network.GetAutoPlug() ? Messages.YES : Messages.NO;
                LinkStatusCell.Value  = Xmo is Pool?Network.LinkStatusString() :
                                            Pif == null ? Messages.NONE : Pif.LinkStatusString();

                MacCell.Value = Pif != null && Pif.IsPhysical() ? Pif.MAC : Messages.SPACED_HYPHEN;
                MtuCell.Value = Network.CanUseJumboFrames() ? Network.MTU.ToString() : Messages.SPACED_HYPHEN;

                var networkSriov = Pif != null?Pif.NetworkSriov() : null;

                if (networkSriov == null)
                {
                    SriovCell.Value = Messages.NO;
                }
                else
                {
                    var sriov = Pif.Connection.Resolve(networkSriov);
                    SriovCell.Value = sriov == null
                        ? Messages.NO
                        : sriov.requires_reboot
                            ? Messages.HOST_NEEDS_REBOOT_ENABLE_SRIOV
                            : Messages.YES;
                }
            }
Esempio n. 7
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;
            }
        }