internal void UpdateFromProxy(Proxy_PBD proxy) { uuid = proxy.uuid == null ? null : (string)proxy.uuid; host = proxy.host == null ? null : XenRef <Host> .Create(proxy.host); SR = proxy.SR == null ? null : XenRef <SR> .Create(proxy.SR); device_config = proxy.device_config == null ? null : Maps.convert_from_proxy_string_string(proxy.device_config); currently_attached = (bool)proxy.currently_attached; other_config = proxy.other_config == null ? null : Maps.convert_from_proxy_string_string(proxy.other_config); }
public Proxy_PBD ToProxy() { Proxy_PBD result_ = new Proxy_PBD(); result_.uuid = (uuid != null) ? uuid : ""; result_.host = (host != null) ? host : ""; result_.SR = (SR != null) ? SR : ""; result_.device_config = Maps.convert_to_proxy_string_string(device_config); result_.currently_attached = currently_attached; result_.other_config = Maps.convert_to_proxy_string_string(other_config); return(result_); }
public Proxy_PBD ToProxy() { Proxy_PBD result_ = new Proxy_PBD(); result_.uuid = uuid ?? ""; result_.host = host ?? ""; result_.SR = SR ?? ""; result_.device_config = Maps.convert_to_proxy_string_string(device_config); result_.currently_attached = currently_attached; result_.other_config = Maps.convert_to_proxy_string_string(other_config); return(result_); }
public override string SaveChanges(Session session, string opaqueRef, PBD server) { if (opaqueRef == null) { Proxy_PBD p = this.ToProxy(); return(session.proxy.pbd_create(session.uuid, p).parse()); } else { if (!Helper.AreEqual2(_other_config, server._other_config)) { PBD.set_other_config(session, opaqueRef, _other_config); } if (!Helper.AreEqual2(_device_config, server._device_config)) { PBD.set_device_config(session, opaqueRef, _device_config); } return(null); } }
protected override void Run() { log.Debug("Running SR repair"); log.DebugFormat("SR='{0}'", SR.Name()); //CA-176935, CA-173497 - we need to run Plug for the master first - creating a new list of hosts where the master is always first var allHosts = new List <Host>(); var master = Helpers.GetMaster(Connection); if (master != null) { allHosts.Add(master); } foreach (var host in Connection.Cache.Hosts) { if (!allHosts.Contains(host)) { allHosts.Add(host); } } foreach (Host host in allHosts) { Host stoHost = SR.GetStorageHost(); if (SR.shared || (stoHost != null && host.opaque_ref == stoHost.opaque_ref)) { _hostList.Add(host); } } if (_hostList.Count == 0) { return; } for (int i = 0; i < _hostList.Count; i++) { log.DebugFormat("_hostList[{0}]='{1}'", i, _hostList[i].Name()); } int max = _hostList.Count * 2; int delta = 100 / max; foreach (Host host in _hostList) { if (!host.HasPBDTo(SR) && SR.shared && SR.PBDs.Count > 0) { PBD template = SR.Connection.Resolve(SR.PBDs[0]); if (template != null) { this.Description = string.Format(Messages.ACTION_SR_REPAIR_CREATE_PBD, Helpers.GetName(host)); log.Debug(this.Description); Proxy_PBD proxyPBD = new Proxy_PBD(); proxyPBD.currently_attached = false; proxyPBD.device_config = new Hashtable(template.device_config); proxyPBD.SR = template.SR; proxyPBD.host = new XenRef <Host>(host.opaque_ref); try { RelatedTask = XenAPI.PBD.async_create(this.Session, new PBD(proxyPBD)); if (PercentComplete + delta <= 100) { PollToCompletion(PercentComplete, PercentComplete + delta); } else { PollToCompletion(PercentComplete, 100); PercentComplete = 100; } } catch (XenAPI.Failure f) { failure = f; failureDescription = Description; } } } else { PercentComplete += delta; } PBD thePBD = host.GetPBDTo(SR); if (thePBD != null && !thePBD.currently_attached) { this.Description = string.Format(Messages.ACTION_SR_REPAIR_PLUGGING_PBD, Helpers.GetName(host)); log.Debug(this.Description); try { RelatedTask = XenAPI.PBD.async_plug(this.Session, thePBD.opaque_ref); if (PercentComplete + delta <= 100) { PollToCompletion(PercentComplete, PercentComplete + delta); } else { PollToCompletion(PercentComplete, 100); PercentComplete = 100; } } catch (XenAPI.Failure f) { failure = f; failureDescription = Description; } } else { PercentComplete += delta; } } if (failure != null && failureDescription != null) { Description = failureDescription; throw failure; } // CA-14928: Sometimes we have too many PBDs if there has just been a host // eject and the GC hasn't collected the PBD yet. // //if (SR.PBDs.Count != _hostList.Count && SR.shared && !SR.IsToolsSR) //{ // throw new Exception(Messages.ACTION_SR_REPAIR_FAILED); //} if (isSharedAction) { Description = string.Format(Messages.ACTION_SR_SHARE_SUCCESSFUL, SR.NameWithoutHost()); } else { Description = string.Format(Messages.ACTION_SR_REPAIR_SUCCESSFUL, SR.NameWithoutHost()); } }
/// <summary> /// Creates a new PBD from a Proxy_PBD. /// </summary> /// <param name="proxy"></param> public PBD(Proxy_PBD proxy) { this.UpdateFromProxy(proxy); }
/// <summary> /// Creates a new PBD from a Proxy_PBD. /// </summary> /// <param name="proxy"></param> public PBD(Proxy_PBD proxy) { UpdateFrom(proxy); }