public Feature(string name, string advertise, string control, bool controlmustexist, IExceptionHandler exceptionhandler) { this.exceptionhandler = exceptionhandler; this.name = name; wmisession = WmiBase.Singleton.GetXenStoreSession("Citrix Xen Service Feature : " + name); wmisession.Log("New Feature"); controlKey = wmisession.GetXenStoreItem(control); this.controlmustexist = controlmustexist; try { if (controlKey.value != "") { wmisession.Log("Control key " + control + ":" + controlKey.value); } } catch {} enabled = true; listener = controlKey.Watch(new EventArrivedEventHandler(onFeatureWrapper)); if (!advertise.Equals("")) { advert = wmisession.GetXenStoreItem(advertise); features.Add(this); } Disposer.Add(this); }
public ClipboardAccess(WmiSession wmisession) { this.wmisession = wmisession; xsSetClipboard = wmisession.GetXenStoreItem("data/set_clipboard"); xsReportClipboard = wmisession.GetXenStoreItem("data/report_clipboard"); serverwatch = xsSetClipboard.Watch(new EventArrivedEventHandler(OnServerClipboard)); clientwatch = xsReportClipboard.Watch(new EventArrivedEventHandler(OnClientClipboard)); }
private WmiBase() { debugmsg = new Queue <string>(); syncSingleton = new Object(); xenbaselock = new Object(); wmisession = new WmiSession("Base", this); xsupdated = wmisession.GetXenStoreItem("data/updated"); xsupdatedcount = wmisession.GetXenStoreItem("data/update_cnt"); xserror = wmisession.GetXenStoreItem("control/error"); }
private WmiBase() { debugmsg = new Queue<string>(); syncSingleton = new Object(); xenbaselock = new Object(); wmisession = new WmiSession("Base", this); xsupdated = wmisession.GetXenStoreItem("data/updated"); xsupdatedcount = wmisession.GetXenStoreItem("data/update_cnt"); xserror = wmisession.GetXenStoreItem("control/error"); }
public static void removeSnapshot(WmiSession wmisession) { try { wmisession.GetXenStoreItem("control/snapshot").Remove(); } catch { }; try { wmisession.GetXenStoreItem("control/feature-snapshot").Remove(); } catch { } }
public NetInfo(IExceptionHandler exceptionhandler) { updating = new Object(); this.exceptionhandler = exceptionhandler; wmisession = WmiBase.Singleton.GetXenStoreSession("Adapters"); devicevif = wmisession.GetXenStoreItem("device/vif"); datavif = wmisession.GetXenStoreItem("data/vif"); numvif = wmisession.GetXenStoreItem("data/num_vif"); needsRefresh = true; onAddrChange(null, null); addrChangeHandler = new NetworkAddressChangedEventHandler(onAddrChange); NetworkChange.NetworkAddressChanged += addrChangeHandler; vifListen = devicevif.Watch(onVifChanged); }
void removeDevices() { try { foreach (string node in datavif.children) { try { wmisession.GetXenStoreItem(node).Remove(); } catch { }; // Ignore failure, if nodes don't exist } } catch { }; // If there are no nodes, then we can also ignore failure }
bool backupHandler(IntPtr bstrMem) { try { string backup = Marshal.PtrToStringBSTR(bstrMem); string vm = wmisession.GetXenStoreItemCached("vm").value.Substring(4); if (type == VssSnapshot.Type.VM) { string snapstr = wmisession.GetXenStoreItem("/vss/" + vm + "/snapuuid").value; wmisession.GetXenStoreItem("control/snapshot/snapuuid").value = snapstr; wmisession.GetXenStoreItem("control/snapshot/type").value = "vm"; } else if (type == VssSnapshot.Type.VOLUME) { string rootkeyname = "/vss/" + vm + "/vdisnap"; XenStoreItem vdisnap = wmisession.GetXenStoreItem(rootkeyname); foreach (string entryKey in vdisnap.children) { XenStoreItem src = wmisession.GetXenStoreItem(entryKey); XenStoreItem dest = wmisession.GetXenStoreItem("control/snapshot/vdi/" + entryKey.Substring(rootkeyname.Length + 1)); src.value = dest.value; } string snaptype = wmisession.GetXenStoreItem("/vss/" + vm + "/snaptype").value; wmisession.GetXenStoreItem("control/snapshot/type").value = snaptype; } wmisession.GetXenStoreItem("control/snapshot/snapid").Remove(); int size = backup.Length; int poscount = 0; int pagecount = 0; string substr = ""; while (size > 0) { substr += string.Format("{0:x2}{1:x2}", ((int)backup[poscount]) & 0xff, (((int)backup[poscount]) >> 8) & 0xff); size--; poscount++; if (((poscount % 255) == 0) || (size == 0)) { wmisession.GetXenStoreItem("control/snapshot/snapid/" + pagecount.ToString()).value = substr; substr = ""; pagecount++; } } } catch (Exception e) { try { wmisession.GetXenStoreItem("control/snapshot/snapid").Remove(); WmiBase.Singleton.DebugMsg("Backup failed: " + e.ToString()); } catch {} return(false); } return(true); }
protected void addAdvert(string advertname) { advert = wmisession.GetXenStoreItem(advertname); features.Add(this); }
public Feature(string name, string advertise, string control, bool controlmustexist, IExceptionHandler exceptionhandler) { this.exceptionhandler = exceptionhandler; this.name = name; wmisession = WmiBase.Singleton.GetXenStoreSession("Citrix Xen Service Feature : " + name); wmisession.Log("New Feature"); controlKey = wmisession.GetXenStoreItem(control); this.controlmustexist = controlmustexist; try { if (controlKey.value != "") { wmisession.Log("Control key "+control+":"+controlKey.value); } } catch {} enabled = true; listener = controlKey.Watch(new EventArrivedEventHandler(onFeatureWrapper)); if (!advertise.Equals("")) { advert = wmisession.GetXenStoreItem(advertise); features.Add(this); } Disposer.Add(this); }
public void Remove() { wmisession.GetXenStoreItem(path).Remove(); }