/// <summary> /// Disable clustering on the host (if the network is used by clustering), before changing the management interface; /// Before disabling clustering we also unplug all the GFS2 SRs /// </summary> private void DisableClustering(PIF pif, out List <PBD> gfs2Pbds) { gfs2Pbds = new List <PBD>(); var isUsedByClustering = Connection.Cache.Clusters.Any(cluster => cluster.network.opaque_ref == pif.network.opaque_ref); if (!isUsedByClustering) { return; } var host = Connection.Resolve(pif.host); if (host == null) { return; } var clusterHost = Connection.Cache.Cluster_hosts.FirstOrDefault(c => c.host.opaque_ref == host.opaque_ref); if (clusterHost == null) { return; } // unplug the GFS2 SRs, saving the list of the PBDs unplugged, to plug back later foreach (var pbd in Connection.ResolveAll(host.PBDs).Where(pbd => pbd.currently_attached)) { var sr = Connection.Resolve(pbd.SR); if (sr != null && sr.GetSRType(true) == SR.SRTypes.gfs2) { gfs2Pbds.Add(pbd); Description = string.Format(Messages.ACTION_SR_DETACHING, sr.Name(), host.Name()); PBD.unplug(Session, pbd.opaque_ref); } } // disable clustering Description = string.Format(Messages.DISABLING_CLUSTERING_ON_POOL, host.Name()); log.Debug(Description); Cluster_host.disable(Session, clusterHost.opaque_ref); }
/// <summary> /// Enable clustering on the host (if the network is used by clustering), after the management interface has been changed; /// After enabling clustering we also plug back all the GFS2 SRs that we unplugged /// </summary> private void EnableClustering(PIF pif, List <PBD> gfs2Pbds) { var isUsedByClustering = Connection.Cache.Clusters.Any(cluster => cluster.network.opaque_ref == pif.network.opaque_ref); if (!isUsedByClustering) { return; } var host = Connection.Resolve(pif.host); if (host == null) { return; } var clusterHost = Connection.Cache.Cluster_hosts.FirstOrDefault(c => c.host.opaque_ref == host.opaque_ref); if (clusterHost == null) { return; } Description = string.Format(Messages.ENABLING_CLUSTERING_ON_POOL, host.Name()); log.Debug(Description); PIF.set_disallow_unplug(Session, pif.opaque_ref, true); Cluster_host.enable(Session, clusterHost.opaque_ref); // plug the GFS2 SRs foreach (var pbd in gfs2Pbds.Where(pbd => !pbd.currently_attached)) { var sr = Connection.Resolve(pbd.SR); if (sr != null) { Description = string.Format(Messages.ACTION_SR_ATTACHING_TITLE, sr.Name(), host.Name()); } PBD.plug(Session, pbd.opaque_ref); } }