public override async Task <VmNetwork[]> GetVmNetworks(ManagedObjectReference mor) { List <VmNetwork> result = new List <VmNetwork>(); RetrievePropertiesResponse response = await _client.vim.RetrievePropertiesAsync( _client.props, FilterFactory.VmFilter(mor, "name config.hardware")); ObjectContent[] oc = response.returnval; foreach (ObjectContent obj in oc) { // if (!obj.IsInPool(_client.pool)) // continue; string vmName = obj.GetProperty("name").ToString(); VirtualHardware hardware = obj.GetProperty("config.hardware") as VirtualHardware; foreach (VirtualEthernetCard card in hardware.device.OfType <VirtualEthernetCard>()) { result.Add(new VmNetwork { NetworkMOR = ((VirtualEthernetCardNetworkBackingInfo)card.backing).deviceName, VmName = vmName }); } } return(result.ToArray()); }
public void Startup() { if (((this.m_thread != null) && this.m_running) && this.m_thread.IsAlive) { this.Shutdown(); } this.m_virtualHardware = new VirtualHardware(this.m_boardLayout.Width, this.m_boardLayout.Height, this.m_ledSize, this.m_ledColor, this.m_dotPitch); EventSequence executable = (EventSequence)this.m_executable; this.m_ledUINode = executable.Extensions[".led"]; if (!this.m_useWithScript) { this.LoadFrames(); this.m_frameIndex = this.GetFrameAt(this.m_timer.Milliseconds); this.FrameTimesFromFrameIndex(this.m_frameIndex); this.m_thread = new Thread(new ThreadStart(this.StaticExecutionThread)); } else { this.m_frames.Clear(); this.m_thread = new Thread(new ThreadStart(this.DynamicExecutionThread)); } this.m_virtualHardware.Start(); this.m_running = true; this.m_thread.Start(); }
private static VirtualDeviceConfigSpec[] CreateVmDeviceSpecs(VirtualHardware virtualHardware) { List <VirtualDeviceConfigSpec> deviceConfigSpecList = new List <VirtualDeviceConfigSpec>(); foreach (VirtualDevice virtualDevice in virtualHardware.device) { if (!(virtualDevice is VirtualDisk)) { if (virtualDevice is VirtualFloppy) { VirtualFloppyRemoteDeviceBackingInfo deviceBackingInfo = new VirtualFloppyRemoteDeviceBackingInfo(); deviceBackingInfo.deviceName = ""; virtualDevice.backing = (VirtualDeviceBackingInfo)deviceBackingInfo; } else if (virtualDevice is VirtualCdrom) { VirtualCdromRemotePassthroughBackingInfo passthroughBackingInfo = new VirtualCdromRemotePassthroughBackingInfo(); passthroughBackingInfo.deviceName = ""; passthroughBackingInfo.exclusive = false; virtualDevice.backing = (VirtualDeviceBackingInfo)passthroughBackingInfo; } deviceConfigSpecList.Add(new VirtualDeviceConfigSpec() { operation = VirtualDeviceConfigSpecOperation.add, operationSpecified = true, device = virtualDevice }); } } return(deviceConfigSpecList.ToArray()); }
public void Awake() { error = new Error(); hardware = GetComponent <VirtualHardware>(); compiler = new Compiler(); }
public void queryMemoryOverhead() { _service = ecb.getConnection().Service; _sic = ecb.getConnection().ServiceContent; ArrayList supportedVersions = VersionUtil.getSupportedVersions(ecb.get_option("url")); String hostname = ecb.get_option("hostname"); ManagedObjectReference hmor = ecb.getServiceUtil().GetDecendentMoRef(null, "HostSystem", hostname); if (hmor != null) { if (VersionUtil.isApiVersionSupported(supportedVersions, "2.5")) { VirtualMachineConfigInfo vmConfigInfo = new VirtualMachineConfigInfo(); vmConfigInfo.changeVersion = "1"; DateTime dt = ecb.getConnection().Service.CurrentTime(ecb.getConnection().ServiceRef); vmConfigInfo.modified = dt; VirtualMachineDefaultPowerOpInfo defaultInfo = new VirtualMachineDefaultPowerOpInfo(); vmConfigInfo.defaultPowerOps = defaultInfo; VirtualMachineFileInfo fileInfo = new VirtualMachineFileInfo(); vmConfigInfo.files = fileInfo; VirtualMachineFlagInfo flagInfo = new VirtualMachineFlagInfo(); vmConfigInfo.flags = flagInfo; vmConfigInfo.guestFullName = "Full Name"; vmConfigInfo.guestId = "Id"; VirtualHardware vhardware = new VirtualHardware(); vhardware.memoryMB = int.Parse(ecb.get_option("memorysize")); vhardware.numCPU = int.Parse(ecb.get_option("cpucount")); vmConfigInfo.hardware = vhardware; // Not Required For Computing The Overhead vmConfigInfo.name = "OnlyFoeInfo"; vmConfigInfo.uuid = "12345678-abcd-1234-cdef-123456789abc"; vmConfigInfo.version = "First"; vmConfigInfo.template = false; vmConfigInfo.alternateGuestName = "Alternate"; long overhead = ecb._connection._service.QueryMemoryOverheadEx( hmor, vmConfigInfo); Console.WriteLine("Using queryMemoryOverheadEx API using vmReconfigInfo"); Console.WriteLine("Memory overhead necessary to " + "poweron a virtual machine with memory " + ecb.get_option("memorysize") + " MB and cpu count " + ecb.get_option("cpucount") + " -: " + overhead + " bytes"); } else { long overhead = ecb._connection._service.QueryMemoryOverhead(hmor, long.Parse(ecb.get_option("memorysize")), 0, false, int.Parse(ecb.get_option("cpucount")) ); Console.WriteLine("Using queryMemoryOverhead API " + "using CPU count and Memory Size"); Console.WriteLine("Memory overhead necessary to " + "poweron a virtual machine with memory " + ecb.get_option("memorysize") + " MB and cpu count " + ecb.get_option("cpucount") + " -: " + overhead + " bytes"); } } else { Console.WriteLine("Host " + ecb.get_option("hostname") + " not found"); } }
public void queryMemoryOverhead() { _service = ecb.getConnection().Service; _sic = ecb.getConnection().ServiceContent; ArrayList supportedVersions = VersionUtil.getSupportedVersions(ecb.get_option("url")); String hostname = ecb.get_option("hostname"); ManagedObjectReference hmor = ecb.getServiceUtil().GetDecendentMoRef(null, "HostSystem", hostname); if (hmor != null) { if (VersionUtil.isApiVersionSupported(supportedVersions, "2.5")) { VirtualMachineConfigInfo vmConfigInfo = new VirtualMachineConfigInfo(); vmConfigInfo.changeVersion = "1"; DateTime dt = ecb.getConnection().Service.CurrentTime(ecb.getConnection().ServiceRef); vmConfigInfo.modified = dt; VirtualMachineDefaultPowerOpInfo defaultInfo = new VirtualMachineDefaultPowerOpInfo(); vmConfigInfo.defaultPowerOps=defaultInfo; VirtualMachineFileInfo fileInfo = new VirtualMachineFileInfo(); vmConfigInfo.files=fileInfo; VirtualMachineFlagInfo flagInfo = new VirtualMachineFlagInfo(); vmConfigInfo.flags=flagInfo; vmConfigInfo.guestFullName="Full Name"; vmConfigInfo.guestId="Id"; VirtualHardware vhardware = new VirtualHardware(); vhardware.memoryMB=int.Parse(ecb.get_option("memorysize")); vhardware.numCPU=int.Parse(ecb.get_option("cpucount")); vmConfigInfo.hardware=vhardware; // Not Required For Computing The Overhead vmConfigInfo.name="OnlyFoeInfo"; vmConfigInfo.uuid="12345678-abcd-1234-cdef-123456789abc"; vmConfigInfo.version="First"; vmConfigInfo.template=false; vmConfigInfo.alternateGuestName="Alternate"; long overhead = ecb._connection._service.QueryMemoryOverheadEx( hmor,vmConfigInfo); Console.WriteLine("Using queryMemoryOverheadEx API using vmReconfigInfo"); Console.WriteLine("Memory overhead necessary to " + "poweron a virtual machine with memory " + ecb.get_option("memorysize") + " MB and cpu count " + ecb.get_option("cpucount") + " -: " + overhead + " bytes"); } else { long overhead = ecb._connection._service.QueryMemoryOverhead(hmor, long.Parse(ecb.get_option("memorysize")), 0, false, int.Parse(ecb.get_option("cpucount")) ); Console.WriteLine("Using queryMemoryOverhead API " + "using CPU count and Memory Size"); Console.WriteLine("Memory overhead necessary to " + "poweron a virtual machine with memory " + ecb.get_option("memorysize") + " MB and cpu count " + ecb.get_option("cpucount") + " -: " + overhead + " bytes"); } } else { Console.WriteLine("Host " + ecb.get_option("hostname") + " not found"); } }