Exemplo n.º 1
0
 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));
     }
 }
Exemplo n.º 2
0
 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]));
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
 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
     }));
 }
Exemplo n.º 6
0
        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));
        }