示例#1
0
        internal void RefreshNetworkComboBox(Dictionary <XenAPI.Network, List <NetworkingPropertiesPage> > InUseMap, XenAPI.Network ManagementNetwork)
        {
            this.InUseMap          = InUseMap;
            this.ManagementNetwork = ManagementNetwork;

            XenAPI.Network selected = (XenAPI.Network)NetworkComboBox.SelectedItem;

            List <XenAPI.Network> networks = new List <XenAPI.Network>(InUseMap.Keys);

            networks.Sort();
            NetworkComboBox.Items.Clear();

            if (type == Type.PRIMARY || type == Type.PRIMARY_WITH_HA)
            {
                networks.RemoveAll(
                    network => network.IsVLAN);
            }

            NetworkComboBox.Items.AddRange(networks.ToArray());

            SquelchNetworkComboBoxChange = true;
            try
            {
                NetworkComboBox.SelectedItem = selected;
            }
            finally
            {
                SquelchNetworkComboBoxChange = false;
            }

            if (!TriggeringChange)
            {
                RefreshButtons();
            }
        }
        protected override bool AllowSriovNetwork(XenAPI.Network network, string sysId)
        {
            var vhs  = OVF.FindVirtualHardwareSectionByAffinity(SelectedOvfEnvelope, sysId, "xen");
            var data = vhs.VirtualSystemOtherConfigurationData;

            foreach (var s in data)
            {
                if (s.Name == "recommendations")
                {
                    try
                    {
                        XmlDocument xdRecommendations = new XmlDocument();
                        xdRecommendations.LoadXml(s.Value.Value);

                        XmlNode xn = xdRecommendations.SelectSingleNode(@"restrictions/restriction[@field='allow-network-sriov']");
                        if (xn == null || xn.Attributes == null)
                        {
                            return(false);
                        }

                        return(Convert.ToInt32(xn.Attributes["value"].Value) != 0);
                    }
                    catch
                    {
                        return(false);
                    }
                }
            }

            return(false);
        }
示例#3
0
        public void RefreshButtons()
        {
            XenAPI.Network network = (XenAPI.Network)NetworkComboBox.SelectedItem;
            string         purpose = network == null ? null : FindOtherPurpose(network);

            InUseWarning =
                purpose == null || purpose == Purpose ?
                null :
                type == Type.SECONDARY && network == ManagementNetwork?
                string.Format(Messages.NETWORKING_PROPERTIES_IN_USE_WARNING_MANAGEMENT, network.ToString()) :
                    string.Format(Messages.NETWORKING_PROPERTIES_IN_USE_WARNING, network.ToString(), purpose);

            PurposeLabel.Visible         =
                PurposeTextBox.Visible   =
                    DeleteButton.Visible =
                        (type == Type.SECONDARY);

            panelHAEnabledWarning.Visible =
                (type == Type.PRIMARY_WITH_HA);

            SetDNSControlsVisible(type != Type.SECONDARY);

            panelInUseWarning.Visible =
                InUseWarning != null;
            InUseWarningText.Text = InUseWarning;

            IpAddressSettingsLabel.Text = type == Type.SECONDARY
                                              ? Messages.NETWORKING_PROPERTIES_IP_SETTINGS
                                              : Messages.NETWORKING_PROPERTIES_IP_AND_DNS_SETTINGS;
            IPAddressLabel.Text = Pool ? Messages.IP_ADDRESS_RANGE_LABEL : Messages.IP_ADDRESS_LABEL;

            tableLayoutPanelStaticSettings.Enabled = FixedIPRadioButton.Checked;

            RangeEndLabel.Visible = Pool;

            Valid =
                InUseWarning == null &&
                NetworkComboBox.SelectedIndex != -1 &&
                (DHCPIPRadioButton.Checked ||
                 ((StringUtility.IsIPAddress(IPAddressTextBox.Text)) &&
                  StringUtility.IsValidNetmask(SubnetTextBox.Text) && IsOptionalIPAddress(GatewayTextBox.Text))) &&
                (type == Type.SECONDARY || ((IsOptionalIPAddress(PreferredDNSTextBox.Text) &&
                                             IsOptionalIPAddress(AlternateDNS1TextBox.Text) &&
                                             IsOptionalIPAddress(AlternateDNS2TextBox.Text))));

            // Grey out everything if HA is enabled: CA-24714
            if (type == Type.PRIMARY_WITH_HA)
            {
                foreach (Control c in Controls)
                {
                    c.Enabled = false;
                }
                haEnabledWarningIcon.Enabled =
                    haEnabledRubric.Enabled  =
                        true;
            }
        }
示例#4
0
 private string FindOtherPurpose(XenAPI.Network network)
 {
     if (InUseMap[network] != null)
     {
         List <NetworkingPropertiesPage> pages = InUseMap[network];
         foreach (NetworkingPropertiesPage page in pages)
         {
             if (page != this)
             {
                 return(page.Purpose);
             }
         }
     }
     return(null);
 }
示例#5
0
        public bool CanSeeNetwork(XenAPI.Network network)
        {
            System.Diagnostics.Trace.Assert(network != null);

            // Special case for local networks.
            if (network.PIFs.Count == 0)
            {
                return(true);
            }

            foreach (PIF pif in network.Connection.ResolveAll(network.PIFs))
            {
                if (pif.host != null && pif.host.opaque_ref == opaque_ref)
                {
                    return(true);
                }
            }

            return(false);
        }
示例#6
0
        private void NetworkComboBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            Graphics g = e.Graphics;

            XenAPI.Network network =
                (XenAPI.Network)(e.Index == -1 ? NetworkComboBox.SelectedItem : NetworkComboBox.Items[e.Index]);

            if (network == null)
            {
                return;
            }

            string purpose = FindOtherPurpose(network);
            string label   =
                purpose == null || purpose == Purpose?
                network.ToString() :
                    string.Format(Messages.NETWORK_IN_USE_BY, network.ToString(), purpose);

            Brush text_brush = (e.State & DrawItemState.Selected) > 0 ? SystemBrushes.HighlightText : SystemBrushes.ControlText;

            e.DrawBackground();
            g.DrawString(label, Program.DefaultFont, text_brush, new PointF(e.Bounds.X + 1, e.Bounds.Y + 1));
            e.DrawFocusRectangle();
        }
        internal void RefreshNetworkComboBox(Dictionary<XenAPI.Network, List<NetworkingPropertiesPage>> InUseMap, XenAPI.Network ManagementNetwork)
        {
            this.InUseMap = InUseMap;
            this.ManagementNetwork = ManagementNetwork;

            XenAPI.Network selected = (XenAPI.Network)NetworkComboBox.SelectedItem;

            List<XenAPI.Network> networks = new List<XenAPI.Network>(InUseMap.Keys);
            networks.Sort();
            NetworkComboBox.Items.Clear();

            if (type == Type.PRIMARY || type == Type.PRIMARY_WITH_HA)
                networks.RemoveAll(
                    network=>network.IsVLAN);
            
            NetworkComboBox.Items.AddRange(networks.ToArray());

            SquelchNetworkComboBoxChange = true;
            try
            {
                NetworkComboBox.SelectedItem = selected;
            }
            finally
            {
                SquelchNetworkComboBoxChange = false;
            }

            if (!TriggeringChange)
            {
                RefreshButtons();
            }
        }