public IEnumerable <IVm> GetAllVms() { foreach (IComputerSystem vm in ComputerSystem.Query(((IWMICommon)this._Host).Scope, "InstallDate!=NULL")) { yield return((IVm) new Vm(this._Host, vm, this._Logger)); } }
public IHost GetLocalHost() { using (IEnumerator <IComputerSystem> enumerator = ComputerSystem.Query(this._Scope, "Name='{0}'", (object)this._SystemName).GetEnumerator()) { if (enumerator.MoveNext()) { return((IHost) new Host(enumerator.Current, this._Logger)); } } throw new HyperVException(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "Unable to get the local host", new object[0])); }
public IVm GetVmByName(string vmName) { using (IEnumerator <IComputerSystem> enumerator = ComputerSystem.Query(((IWMICommon)this._Host).Scope, "InstallDate!=NULL And ElementName='{0}'", (object)vmName).GetEnumerator()) { if (enumerator.MoveNext()) { return((IVm) new Vm(this._Host, enumerator.Current, this._Logger)); } } throw new HyperVmNotFoundException("Could not find the VM with name " + vmName); }
public IVm GetVmByUuid(string vmUuid) { using (IEnumerator <IComputerSystem> enumerator = ComputerSystem.Query(((IWMICommon)this._Host).Scope, "Name='{0}'", (object)vmUuid).GetEnumerator()) { if (enumerator.MoveNext()) { return((IVm) new Vm(this._Host, enumerator.Current, this._Logger)); } } throw new HyperVmNotFoundException("Could not find the VM with uuid " + vmUuid); }
public IEnumerable <IVm> GetVms(string[] vms) { string specific = string.Join(" Or ", ((IEnumerable <string>)vms).Select <string, string>((Func <string, string>)(vm => "Name='" + vm + "'")).ToArray <string>()); specific.Insert(0, "("); specific.Insert(specific.Length - 1, ")"); foreach (IComputerSystem vm in ComputerSystem.QuerySpecific(((IWMICommon)this._Host).Scope, specific, "InstallDate!=NULL")) { yield return((IVm) new Vm(this._Host, vm, this._Logger)); } }
public static IComputerSystem GetComputerSystem(ManagementScope scope, string name) { using (IEnumerator <IComputerSystem> enumerator = ComputerSystem.Query(scope, "ElementName='{0}'", (object)name).GetEnumerator()) { if (enumerator.MoveNext()) { return(enumerator.Current); } } throw new HyperVException(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "Unable to get the Msvm_ComputerSystem object for {0}", new object[1] { (object)name })); }
public IComputerSystem DefineSystem(string systemSettings, string[] resourceSettings, IVirtualSystemSettingData referenceConfiguration) { using (ManagementBaseObject methodParameters = this._Instance.GetMethodParameters(nameof(DefineSystem))) { methodParameters["SystemSettings"] = (object)systemSettings; methodParameters["ResourceSettings"] = (object)resourceSettings; if (referenceConfiguration != null) { methodParameters["ReferenceConfiguration"] = (object)referenceConfiguration.Object; } using (ManagementBaseObject managementBaseObject = this._Instance.InvokeAndWait(nameof(DefineSystem), methodParameters)) { using (ManagementObject managementObject = new ManagementObject((string)managementBaseObject["ResultingSystem"])) return(ComputerSystem.GetComputerSystem(this._Instance.Scope, (string)managementObject["ElementName"])); } } }
public static IEnumerable <IComputerSystem> Query(ManagementScope scope, string condition, params object[] args) { string condition1 = string.Format((IFormatProvider)CultureInfo.InvariantCulture, condition, args); return(ComputerSystem.Query(scope, condition1)); }