// I lied slightly above. A secondary management interface in Boston and greater // is one with an IP address. In Cowley and earlier, it's one where disallow_unplug // is set. If the interface was configured through XenCenter, both of these things // will be true, but if it was configured on the command line, they may not be. // See CA-56611 for a discussion of this. public bool IsSecondaryManagementInterface(bool showHiddenVMs) { if (management) { return(false); } bool criterion = (ip_configuration_mode != ip_configuration_mode.None && ip_configuration_mode != ip_configuration_mode.unknown); if (!criterion) { return(false); } Network nw = Connection.Resolve(network); return(nw != null && nw.Show(showHiddenVMs)); }
private object NetworkName() { if (Network.Show(XenAdmin.Properties.Settings.Default.ShowHiddenVMs) && !Network.IsSlave) { return(Helpers.GetName(Network)); } else if (Network.IsSlave && Properties.Settings.Default.ShowHiddenVMs) { return(string.Format(Messages.NIC_SLAVE, Helpers.GetName(Network))); } else if (Properties.Settings.Default.ShowHiddenVMs) { return(string.Format(Messages.NIC_HIDDEN, Helpers.GetName(Network))); } else { return(string.Empty); } }
// I lied slightly above. A secondary management interface in Boston and greater // is one with an IP address. In Cowley and earlier, it's one where disallow_unplug // is set. If the interface was configured through XenCenter, both of these things // will be true, but if it was configured on the command line, they may not be. // See CA-56611 for a discussion of this. public bool IsSecondaryManagementInterface(bool showHiddenVMs) { if (management) { return(false); } bool criterion = Helpers.BostonOrGreater(Connection) ? (ip_configuration_mode != ip_configuration_mode.None && ip_configuration_mode != ip_configuration_mode.unknown) : disallow_unplug; if (!criterion) { return(false); } Network nw = Connection.Resolve(network); return(nw != null && nw.Show(showHiddenVMs)); }
private bool ShowNetwork(Host targetHost, XenAPI.Network network) { 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); }
/// <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); } return(true); }
public void BuildList() { Program.AssertOnEventThread(); if (!this.Visible) { return; } if (InBuildList) { return; } InBuildList = true; try { if (XenObject == null || XenObject.Locked) { return; } if (!XenObject.Connection.CacheIsPopulated) { return; } if (XenObject is VM) { DeregisterEventsOnGridRows(); VIF selectedVIF = SelectedVif; VM vm = XenObject as VM; NetworksGridView.SuspendLayout(); NetworksGridView.Rows.Clear(); List <VIF> vifs = vm.Connection.ResolveAll(vm.VIFs); vifs.Sort(); // CA-8981 - Listen for guest metric changes which is necessary for IP Address updates VM_guest_metrics vmGuestMetrics = vm.Connection.Resolve(vm.guest_metrics); if (vmGuestMetrics != null) { vmGuestMetrics.PropertyChanged += Server_PropertyChanged; } var vifRowsToAdd = new List <VifRow>(); foreach (var vif in vifs) { var network = vif.Connection.Resolve(vif.network); if (network != null && // CA-218956 - Expose HIMN when showing hidden objects (network.IsGuestInstallerNetwork() && !XenAdmin.Properties.Settings.Default.ShowHiddenVMs)) { continue; // Don't show the guest installer network in the network tab (CA-73056) } vifRowsToAdd.Add(new VifRow(vif)); } NetworksGridView.Rows.AddRange(vifRowsToAdd.ToArray()); bool selected = true; if (selectedVIF != null) { foreach (VifRow row in NetworksGridView.Rows) { // Cannot compare opaque_ref as VIFs get destroyed / recreated on each edit. if (row.Vif.device == selectedVIF.device) { row.Selected = true; break; } } } if (!selected && NetworksGridView.Rows.Count > 0) { NetworksGridView.Rows[0].Selected = true; } } else if (XenObject is Host || XenObject is Pool) { DeregisterEventsOnGridRows(); XenAPI.Network selectedNetwork = SelectedNetwork; NetworksGridView.SuspendLayout(); NetworksGridView.Rows.Clear(); XenAPI.Network[] networks = XenObject.Connection.Cache.Networks; Array.Sort <XenAPI.Network>(networks); List <NetworkRow> networkRowsToAdd = new List <NetworkRow>(); for (int i = 0; i < networks.Length; i++) { if (!networks[i].Show(XenAdmin.Properties.Settings.Default.ShowHiddenVMs)) { continue; } networkRowsToAdd.Add(new NetworkRow(networks[i], XenObject)); } NetworksGridView.Rows.AddRange(networkRowsToAdd.ToArray()); // The following update causes this to be a lot slower with many networks. Alot! CA-43944 //foreach(NetworkRow r in NetworksGridView.Rows) //r.UpdateDefaultCellStyle(); // Has to be done again after adding to the grid view, even though it's already called in the constructor if (selectedNetwork != null) { foreach (NetworkRow row in NetworksGridView.Rows) { if (row.Network.opaque_ref == selectedNetwork.opaque_ref && selectedNetwork.Show(XenAdmin.Properties.Settings.Default.ShowHiddenVMs)) { row.Selected = true; break; } } } } } finally { if (NetworksGridView.SortedColumn != null) { NetworksGridView.Sort( NetworksGridView.SortedColumn, NetworksGridView.SortOrder == SortOrder.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending); } NetworksGridView.ResumeLayout(); InBuildList = false; } }