コード例 #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);
        }
コード例 #2
0
        private void m_buttonAddNetwork_Click(object sender, EventArgs e)
        {
            if (m_networkGridView.Rows.Count >= m_vm.MaxVIFsAllowed)
            {
                new ThreeButtonDialog(new ThreeButtonDialog.Details(
                                          SystemIcons.Error,
                                          FriendlyErrorNames.VIFS_MAX_ALLOWED, FriendlyErrorNames.VIFS_MAX_ALLOWED_TITLE)).ShowDialog(Program.MainWindow);
                return;
            }

            VIF vif = new VIF {
                Connection = m_selectedConnection
            };

            int i = 0;

            while (true)
            {
                bool exists = false;
                foreach (DataGridViewRow row in m_networkGridView.Rows)
                {
                    VifRow vifRow = row as VifRow;
                    if (vifRow == null)
                    {
                        continue;
                    }

                    VIF v = vifRow.Vif;
                    if (v == null)
                    {
                        continue;
                    }

                    if (int.Parse(v.device) == i)
                    {
                        exists = true;
                    }
                }

                if (exists)
                {
                    i++;
                }
                else
                {
                    break;
                }
            }

            vif.device = i.ToString();
            vif.MAC    = Messages.MAC_AUTOGENERATE;

            if (GetDefaultNetwork() != null)
            {
                vif.network = new XenRef <XenAPI.Network>(GetDefaultNetwork().opaque_ref);
            }

            AddVIFRow(vif);
        }
コード例 #3
0
        private void m_networkGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            VifRow row = m_networkGridView.Rows[e.RowIndex] as VifRow;

            if (row == null)
            {
                return;
            }

            VIF vif = row.Vif;

            if (vif == null)
            {
                return;
            }

            if (e.ColumnIndex == MACAddressNetworkColumn.Index)
            {
                row.HasValidMac = true;
                string mac = (string)row.Cells[e.ColumnIndex].Value;

                if (mac == null || mac.Trim().Length == 0)
                {
                    // We take it that zero-length mac means the user wants to auto-generate
                    row.Cells[e.ColumnIndex].Value = Messages.MAC_AUTOGENERATE;
                }
                else if (mac.Trim() == Messages.MAC_AUTOGENERATE)
                {
                    row.Cells[e.ColumnIndex].Value = Messages.MAC_AUTOGENERATE;
                    vif.MAC = Messages.MAC_AUTOGENERATE;
                }
                else if (Helpers.IsValidMAC(mac))
                {
                    vif.MAC = mac;
                }
                else
                {
                    row.HasValidMac = false;
                }

                UpdateControlsEnabledState(AllMacAddressesValid());
            }
            else if (e.ColumnIndex == NetworkNetworkColumn.Index)
            {
                object         enteredValue = row.Cells[e.ColumnIndex].Value;
                var            entry        = enteredValue as ToStringWrapper <XenAPI.Network>;
                XenAPI.Network network      = (entry == null) ? (XenAPI.Network)enteredValue : entry.item;

                if (network != null)
                {
                    vif.network = new XenRef <XenAPI.Network>(network.opaque_ref);
                }
            }
        }
コード例 #4
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);
        }