public static IEmulatedEthernetPortSettingData GetDefaultLegacyAdapter(IComputerSystem host) { IResourcePool resource = ResourcePool.Query(host, "ResourceSubType = 'Microsoft:Hyper-V:Emulated Ethernet Port' and Primordial = True").FirstOrDefault <IResourcePool>(); Invariant.ArgumentNotNull((object)resource, "Legacy Adapter not found"); using (resource) return(EmulatedEthernetPortSettingData.GetDefaultFromResourcePool(resource)); }
public static IResourceAllocationSettingData GetDefaultSyntheticDVDDrive(IComputerSystem host) { IResourcePool resource = ResourcePool.Query(host, "ResourceSubType = 'Microsoft:Hyper-V:Synthetic DVD Drive' and Primordial = True").FirstOrDefault <IResourcePool>(); Invariant.ArgumentNotNull((object)resource, "Synthetic DVD Drive not found"); using (resource) return(ResourceAllocationSettingData.GetDefaultFromResourcePool(resource)); }
public static IResourceAllocationSettingData GetDefaultEmulatedIDEController(IComputerSystem host) { IResourcePool resource = ResourcePool.Query(host, "ResourceSubType = 'Microsoft:Hyper-V:Emulated IDE Controller' and Primordial = True").FirstOrDefault <IResourcePool>(); Invariant.ArgumentNotNull((object)resource, "Emulated IDE Controller"); using (resource) return(ResourceAllocationSettingData.GetDefaultFromResourcePool(resource)); }
public static IStorageAllocationSettingData GetDefaultVirtualHardDiskStorageAllocationSettingData(IComputerSystem host) { using (IResourcePool resource = ResourcePool.Query(host, "ResourceSubType = 'Microsoft:Hyper-V:Virtual Hard Disk' and Primordial = True").FirstOrDefault <IResourcePool>()) { Invariant.ArgumentNotNull((object)resource, "Couldn't find the resource pool for Virtual Hard Disk"); return(StorageAllocationSettingData.GetDefaultFromResourcePool(resource)); } }
public static ulong GetMaxConsumableResource(IComputerSystem host) { using (IResourcePool resourcePool = ResourcePool.Query(host, "ResourceType = 4").FirstOrDefault <IResourcePool>()) { if (resourcePool == null) { throw new HyperVException("Unable to find the default settings for the Memory resource"); } return(resourcePool.MaxConsumableResource); } }
public static IEthernetPortAllocationSettingData GetDefaultEthernetPortAllocationSettingData(IComputerSystem host) { IResourcePool resourcePool = ResourcePool.Query(host, "ResourceType = 33 and Primordial = True").FirstOrDefault <IResourcePool>(); if (resourcePool == null) { throw new HyperVException("Unable to find the default settings for the resource"); } ManagementObject managementObject = (ManagementObject)null; using (ManagementObjectCollection related = ((IWMICommon)resourcePool).Object.GetRelated("Msvm_AllocationCapabilities", "Msvm_ElementCapabilities", (string)null, (string)null, (string)null, (string)null, false, (EnumerationOptions)null)) { using (ManagementObject firstElement = related.GetFirstElement()) { foreach (ManagementObject relationship in firstElement.GetRelationships("Msvm_SettingsDefineCapabilities")) { if ((int)(ushort)relationship["ValueRole"] == 0) { managementObject = relationship; break; } relationship.Dispose(); } } } if (managementObject == null) { throw new HyperVException("Unable to find the default settings for the resource"); } string path = (string)managementObject["PartComponent"]; managementObject.Dispose(); ManagementObject instance = new ManagementObject(path); instance.Scope = ((IWMICommon)resourcePool).Scope; instance.Get(); return((IEthernetPortAllocationSettingData) new EthernetPortAllocationSettingData(instance)); }