protected override void Run() { log.Debug("Running SR Reconfigure Action"); log.DebugFormat("SR uuid = '{0}'", sr.uuid); log.DebugFormat("name = '{0}'", name); log.DebugFormat("description = '{0}'", description); Description = Messages.ACTION_SR_ATTACHING; // Repair the SR with new PBDs for each host in the pool PBD pbdTemplate = new PBD(); pbdTemplate.currently_attached = false; pbdTemplate.device_config = dconf; pbdTemplate.SR = new XenRef <SR>(sr.opaque_ref); int delta = 100 / (Connection.Cache.HostCount * 2); List <Host> _listHost = new List <Host>(Connection.Cache.Hosts); Util.masterFirst(_listHost); foreach (Host host in _listHost) { // Create the PBD log.DebugFormat("Creating PBD for host {0}", host.Name); this.Description = String.Format(Messages.ACTION_SR_REPAIR_CREATE_PBD, Helpers.GetName(host)); pbdTemplate.host = new XenRef <Host>(host.opaque_ref); RelatedTask = PBD.async_create(this.Session, pbdTemplate); PollToCompletion(PercentComplete, PercentComplete + delta); XenRef <PBD> pbdRef = new XenRef <PBD>(this.Result); // Now plug the PBD log.DebugFormat("Plugging PBD for host {0}", host.Name); this.Description = String.Format(Messages.ACTION_SR_REPAIR_PLUGGING_PBD, Helpers.GetName(host)); RelatedTask = PBD.async_plug(this.Session, pbdRef); PollToCompletion(PercentComplete, PercentComplete + delta); } // Update the name and description of the SR XenAPI.SR.set_name_label(Session, sr.opaque_ref, name); XenAPI.SR.set_name_description(Session, sr.opaque_ref, description); Description = Messages.ACTION_SR_ATTACH_SUCCESSFUL; }
protected override void Run() { foreach (XenRef <PBD> pbd in sr.PBDs) { RelatedTask = PBD.async_destroy(Session, pbd.opaque_ref); PollToCompletion(); } Description = Messages.ACTION_SR_ATTACHING; // Now repair the SR with new PBDs for each host in the pool PBD pbdTemplate = new PBD(); pbdTemplate.currently_attached = false; pbdTemplate.device_config = dconf; pbdTemplate.SR = new XenRef <SR>(sr.opaque_ref); int delta = 100 / (Connection.Cache.HostCount * 2); List <Host> _listHost = new List <Host>(Connection.Cache.Hosts); masterFirst(_listHost); foreach (Host host in _listHost) { // Create the PBD log.DebugFormat("Creating PBD for host {0}", host.Name); this.Description = String.Format(Messages.ACTION_SR_REPAIR_CREATE_PBD, Helpers.GetName(host)); pbdTemplate.host = new XenRef <Host>(host.opaque_ref); RelatedTask = PBD.async_create(this.Session, pbdTemplate); PollToCompletion(PercentComplete, PercentComplete + delta); XenRef <PBD> pbdRef = new XenRef <PBD>(this.Result); // Now plug the PBD log.DebugFormat("Plugging PBD for host {0}", host.Name); this.Description = String.Format(Messages.ACTION_SR_REPAIR_PLUGGING_PBD, Helpers.GetName(host)); RelatedTask = PBD.async_plug(this.Session, pbdRef); PollToCompletion(PercentComplete, PercentComplete + delta); } Description = Messages.ACTION_SR_ATTACH_SUCCESSFUL; }