protected hypervisor_vmware_withoutSnapshots(hypSpec_vmware spec, clientExecutionMethod newExecMethod = clientExecutionMethod.vmwaretools) { _spec = spec; VClient = new cachedVIMClientConnection(_spec); _executionMethod = newExecMethod; switch (newExecMethod) { case clientExecutionMethod.vmwaretools: executor = new vmwareRemoteExecutor(spec, VClient); break; case clientExecutionMethod.smbWithPSExec: executor = new SMBExecutorWithPSExec(spec.kernelDebugIPOrHostname, spec.kernelVMUsername, spec.kernelVMPassword); break; case clientExecutionMethod.smbWithWMI: executor = new SMBExecutor(spec.kernelDebugIPOrHostname, spec.kernelVMUsername, spec.kernelVMPassword); break; case clientExecutionMethod.SSHToBASH: executor = new SSHExecutor(spec.kernelDebugIPOrHostname, spec.kernelVMUsername, spec.kernelVMPassword); break; default: throw new ArgumentOutOfRangeException("newExecMethod", newExecMethod, null); } }
public hypervisor_vmware_FreeNAS(hypSpec_vmware spec, NASParams nasParams, clientExecutionMethod newExecMethod = clientExecutionMethod.vmwaretools) : base(spec, newExecMethod) { nas = FreeNasGroup.getOrMake(nasParams.IP, nasParams.username, nasParams.password); }
public static void doWorkingDirTest(clientExecutionMethod exec, string newWorkingDir) { using (hypervisor_vmware hyp = machinePools.vmware.createHypervisorForNextFreeVMOrWait(execType: exec)) { prepVM(hyp); executionResult res = hyp.startExecutable("cmd /c", "cd", newWorkingDir); Assert.AreEqual(newWorkingDir + "\r\n", res.stdout); } }
public static void doExecTest(clientExecutionMethod exec) { using (hypervisor_vmware hyp = machinePools.vmware.createHypervisorForNextFreeVMOrWait(execType: exec)) { prepVM(hyp); executionResult res = hyp.startExecutable("cmd.exe", "/c echo This is a test&&echo and stderr 1>&2 && exit /b 1234"); Assert.AreEqual("This is a test\r\n", res.stdout); Assert.AreEqual("and stderr \r\n", res.stderr); Assert.AreEqual(1234, res.resultCode); } }
public static void doExecTestAsync(clientExecutionMethod exec) { using (hypervisor_vmware hyp = machinePools.vmware.createHypervisorForNextFreeVMOrWait(execType: exec)) { prepVM(hyp); IAsyncExecutionResult asyncRes = null; while (asyncRes == null) { asyncRes = hyp.startExecutableAsync("cmd.exe", "/c choice /t 5 /d y >nul & echo This is a test&echo and stderr 1>&2 & exit /b 1234"); } executionResult res = null; while (res == null) { res = asyncRes.getResultIfComplete(); Thread.Sleep(TimeSpan.FromSeconds(1)); } Assert.AreEqual("This is a test\r\n", res.stdout); Assert.AreEqual("and stderr \r\n", res.stderr); Assert.AreEqual(1234, res.resultCode); } }
public hypervisor_iLo(hypSpec_iLo spec, clientExecutionMethod newExecMethod = clientExecutionMethod.smbWithPSExec) { _spec = spec; lock (_ilos) { if (!_ilos.ContainsKey(spec.iLoHostname)) { _ilos.Add(spec.iLoHostname, new refCount <hypervisor_iLo_HTTP>(new hypervisor_iLo_HTTP(spec.iLoHostname, spec.iLoUsername, spec.iLoPassword))); } else { _ilos[spec.iLoHostname].addRef(); } } if (_spec.iscsiserverIP != null && _spec.iscsiServerUsername != null && _spec.iscsiServerPassword != null) { theNas = FreeNasGroup.getOrMake(_spec.iscsiserverIP, _spec.iscsiServerUsername, _spec.iscsiServerPassword); } if (newExecMethod == clientExecutionMethod.smbWithPSExec) { _executor = new SMBExecutorWithPSExec(spec.kernelDebugIPOrHostname, spec.hostUsername, spec.hostPassword); } else if (newExecMethod == clientExecutionMethod.smbWithWMI) { _executor = new SMBExecutor(spec.kernelDebugIPOrHostname, spec.hostUsername, spec.hostPassword); } else if (newExecMethod == clientExecutionMethod.vmwaretools) { throw new NotSupportedException(); } else if (newExecMethod == clientExecutionMethod.SSHToBASH) { _executor = new SSHExecutor(spec.kernelDebugIPOrHostname, spec.hostUsername, spec.hostPassword); } }
public static hypervisor_vmware_FreeNAS createHypForVM(vmSpec vmSpec, bladeSpec vmServerSpec, snapshotDetails snapshotInfo, NASParams nas, clientExecutionMethod exec = clientExecutionMethod.smbWithWMI) { userDesc usernameToUse = vmSpec.credentials.First(); return(new hypervisor_vmware_FreeNAS( new hypSpec_vmware( vmSpec.friendlyName, vmServerSpec.bladeIP, vmServerSpec.ESXiUsername, vmServerSpec.ESXiPassword, usernameToUse.username, usernameToUse.password, snapshotInfo.friendlyName, snapshotInfo.path, vmSpec.kernelDebugPort, vmSpec.kernelDebugKey, vmSpec.VMIP ), nas.IP, nas.username, nas.password, exec)); }
public hypervisor_vmware(hypSpec_vmware spec, clientExecutionMethod newExecMethod = clientExecutionMethod.vmwaretools) : base(spec, newExecMethod) { }
public hypervisor_vmware_FreeNAS(hypSpec_vmware spec, string freeNasip, string freeNasUsername, string freeNasPassword, clientExecutionMethod newExecMethod = clientExecutionMethod.vmwaretools) : base(spec, newExecMethod) { nas = FreeNasGroup.getOrMake(freeNasip, freeNasUsername, freeNasPassword); }
public hypervisor_vmware createHypervisorForNextFreeVMOrNull(string snapshotName = "clean", clientExecutionMethod execType = clientExecutionMethod.smbWithWMI, VMSource src = VMSource.configuredServer, string bladeID = null) { lock (hypervisorSpecLock) { populateSpecsIfNeeded(snapshotName, src); // Atomically find an unused VM, and mark it as in-use KeyValuePair <hypSpec_vmware, bool> hypKVP; lock (hypervisorSpecLock) { KeyValuePair <hypSpec_vmware, bool>[] selectedHyp = hypervisorSpecs.Where(x => x.Value == false).ToArray(); if (selectedHyp.Length == 0) { // Allocation failed return(null); } if (bladeID != null) { // We actually throw if a user filter returned nothing, for now. selectedHyp = selectedHyp.Where(x => x.Key.kernelVMServer.ToLower().Contains(bladeID.ToLower())).ToArray(); if (selectedHyp.Length == 0) { throw new Exception("XDL blade not found"); } } hypKVP = selectedHyp.First(); hypervisorSpecs[hypKVP.Key] = true; } try { hypervisor_vmware toRet = new hypervisor_vmware(hypKVP.Key, execType); toRet.setDisposalCallback(onDestruction); return(toRet); } catch (Exception) { lock (hypervisorSpecLock) { hypervisorSpecs[hypKVP.Key] = false; throw; } } } }
public hypervisorCollection <hypSpec_vmware> createVMs(int VMsToAlloc, string snapshotName = "clean", clientExecutionMethod execType = clientExecutionMethod.smbWithWMI, VMSource src = VMSource.configuredServer, string bladeID = null) { hypervisorCollection <hypSpec_vmware> hyps = new hypervisorCollection <hypSpec_vmware>(); for (int i = 0; i < VMsToAlloc; i++) { hypervisor_vmware thisHyp = machinePools.vmware.createHypervisorForNextFreeVMOrNull(snapshotName, execType, src, bladeID); if (thisHyp == null) { break; } hyps.TryAdd(thisHyp.getConnectionSpec().kernelDebugIPOrHostname, thisHyp); } return(hyps); }
public hypervisor_vmware createHypervisorForNextFreeVMOrWait(string snapshotName = "clean", clientExecutionMethod execType = clientExecutionMethod.smbWithWMI, string bladeID = null, VMSource src = VMSource.configuredServer) { while (true) { hypervisor_vmware toRet = createHypervisorForNextFreeVMOrNull(snapshotName, execType, bladeID: bladeID, src: src); if (toRet != null) { return(toRet); } Thread.Sleep(TimeSpan.FromSeconds(5)); } }