public override void PopulatePage() { var external = SelectedNetworkType == NetworkTypes.External; labelExternal.Visible = external; labelInternal.Visible = !external; labelNIC.Visible = external; comboBoxNICList.Visible = external; if (comboBoxNICList.Visible) { try { _populatingNics = true; comboBoxNICList.Items.Clear(); foreach (PIF ThePIF in Connection.Cache.PIFs) { if (ThePIF.host.opaque_ref == Host.opaque_ref && ThePIF.IsPhysical() && (Properties.Settings.Default.ShowHiddenVMs || ThePIF.Show(Properties.Settings.Default.ShowHiddenVMs)) && !ThePIF.IsBondSlave()) { comboBoxNICList.Items.Add(ThePIF); } } } finally { _populatingNics = false; } if (comboBoxNICList.Items.Count > 0) { comboBoxNICList.SelectedIndex = 0; } comboBoxNICList.Focus(); } labelVLAN.Visible = external; numericUpDownVLAN.Visible = external; numericUpDownVLAN.Minimum = Helpers.VLAN0Allowed(Connection) ? 0 : 1; numericUpDownMTU.Visible = labelMTU.Visible = infoMtuPanel.Visible = external; checkBoxSriov.Visible = SelectedHostNic != null && SelectedHostNic.IsSriovPhysicalPIF(); OnPageUpdated(); }
private void UpdateEnablement(bool external, Host host) { lblNicHelp.Text = external ? Messages.WIZARD_DESC_NETWORK_SETTINGS_EXTERNAL : Messages.WIZARD_DESC_NETWORK_SETTINGS_INTERNAL; comboBoxNICList.Visible = external; labelVLAN.Visible = external; numericUpDownVLAN.Visible = external; numericUpDownMTU.Visible = labelMTU.Visible = infoMtuPanel.Visible = external; labelNIC.Visible = external; if (comboBoxNICList.Items.Count > 0) { comboBoxNICList.SelectedIndex = external ? comboBoxNICList.Items.Count - 1 : -1; } checkBoxSriov.Visible = SelectedHostNic != null && SelectedHostNic.IsSriovPhysicalPIF(); OnPageUpdated(); }
private void cmbHostNicList_SelectedIndexChanged(object sender, EventArgs e) { OnPageUpdated(); if (SelectedHostNic == null) { return; } checkBoxSriov.Visible = SelectedHostNic.IsSriovPhysicalPIF(); numericUpDownMTU.Maximum = Math.Min(SelectedHostNic.MTU, XenAPI.Network.MTU_MAX); numericUpDownMTU.Enabled = numericUpDownMTU.Minimum != numericUpDownMTU.Maximum; infoMtuMessage.Text = numericUpDownMTU.Minimum == numericUpDownMTU.Maximum ? string.Format(Messages.ALLOWED_MTU_VALUE, numericUpDownMTU.Minimum) : string.Format(Messages.ALLOWED_MTU_RANGE, numericUpDownMTU.Minimum, numericUpDownMTU.Maximum); vlans = GetVLANList(SelectedHostNic); //CA-72484: check whether the currently selected VLAN is available and keep it int curVlan = CurrentVLANValue; if (!vlans.Contains(curVlan)) { SetError(null); return; } int avail_vlan = GetFirstAvailableVLAN(vlans); if (avail_vlan == -1) { return; } numericUpDownVLAN.Value = avail_vlan; }