private void onDestruction(hypSpec_vmware obj) { using (BladeDirectorServices director = new BladeDirectorServices(machinePools.bladeDirectorURL)) { director.svc.ReleaseBladeOrVM(obj.kernelDebugIPOrHostname); } }
public override hypervisor makeHypervisorForVM(lockableVMSpec vm, lockableBladeSpec parentBladeSpec) { hypSpec_vmware spec = new hypSpec_vmware(vm.spec.friendlyName, parentBladeSpec.spec.bladeIP, Settings.Default.esxiUsername, Settings.Default.esxiPassword, Settings.Default.vmUsername, Settings.Default.vmPassword, null, null, vm.spec.kernelDebugPort, vm.spec.kernelDebugKey, vm.spec.VMIP); return(new hypervisor_vmware(spec, clientExecutionMethod.smbWithWMI)); }
private void onDestruction(hypSpec_vmware beingDestroyed) { lock (hypervisorSpecLock) { // Make a new hypervisor object, just so we can make sure the old blade is powered off. hypervisorWithSpec <hypSpec_vmware> VMBeingDestroyed = new hypervisor_vmware(beingDestroyed); { VMBeingDestroyed.powerOff(); } hypervisorSpecs[beingDestroyed] = false; } }
private void populateSpecsIfNeeded_VMServer(string snapshotName) { if (hypervisorSpecs == null) { try { // time to initialise the collection, marking all as unused. hypervisorSpecs = new ConcurrentDictionary <hypSpec_vmware, bool>(); int kernelVMCount = Properties.Settings.Default.kernelVMCount; string vmNameBase = Properties.Settings.Default.VMWareVMName; int kernelVMPortBase = Properties.Settings.Default.VMWareVMPortBase; string kernelVMServer = Properties.Settings.Default.VMWareVMServer; string kernelVMServerUsername = Properties.Settings.Default.VMWareVMServerUsername; string kernelVMServerPassword = Properties.Settings.Default.VMWareVMServerPassword; string kernelVMUsername = Properties.Settings.Default.VMWareVMUsername; string kernelVMPassword = Properties.Settings.Default.VMWareVMPassword; string kernelVMDebugKey = Properties.Settings.Default.VMWareVMDebugKey; if (kernelVMCount == 0 || vmNameBase == "" || kernelVMPortBase == 0 || kernelVMServer == "" || kernelVMServerUsername == "" || kernelVMServerPassword == "" || kernelVMDebugKey == "") { throw new Exception("BladeDirectorClient not configured properly"); } hypSpec_vmware[] hyps = new hypSpec_vmware[kernelVMCount]; int VMServerIndex = 0; for (int i = 1; i < kernelVMCount + 1; i++) { string vmname = String.Format("{0}-{1}", vmNameBase, i); ushort vmPort = (ushort)(kernelVMPortBase + i - 1); hyps[i - 1] = new hypSpec_vmware( vmname, kernelVMServer, kernelVMServerUsername, kernelVMServerPassword, kernelVMUsername, kernelVMPassword, snapshotName, null, vmPort, kernelVMDebugKey, vmname, newDebugMethod: kernelConnectionMethod.net); hypervisorSpecs[hyps[i - 1]] = false; // Check the relevant port isn't already in use ipUtils.ensurePortIsFree(vmPort); } } catch (Exception) { hypervisorSpecs = null; throw; } } }
private void populateSpecsIfNeeded_XDLCluster(string snapshotName) { if (hypervisorSpecs == null) { try { hypervisorSpecs = new ConcurrentDictionary <hypSpec_vmware, bool>(); int kernelVMCount = Properties.Settings.Default.XDLClusterVMsPerBlade; string kernelVMServerUsername = Properties.Settings.Default.XDLVMServerUsername; string kernelVMServerPassword = Properties.Settings.Default.XDLVMServerPassword; string kernelVMUsername = Properties.Settings.Default.VMWareVMUsername; string kernelVMPassword = Properties.Settings.Default.VMWareVMPassword; if (kernelVMServerUsername == "" || kernelVMServerPassword == "") { throw new Exception("BladeDirectorClient not configured properly"); } List <hypSpec_vmware> hyps = new List <hypSpec_vmware>(); // Construct the hostnames of the blades we will be using string[] bladeIndexesAsString = Properties.Settings.Default.XDLClusterBladeList.Split(','); int[] bladeIndexes = bladeIndexesAsString.Select(x => Int32.Parse(x)).ToArray(); string[] bladeHostnames = bladeIndexes.Select(x => String.Format("blade{0:D2}.fuzz.xd.lan", x)).ToArray(); // Iterate over each blade, constructing VMs. for (int index = 0; index < bladeHostnames.Length; index++) { string bladeHostname = bladeHostnames[index]; int bladeID = bladeIndexes[index]; // Get VMs on this blade, and filter them according to our naming scheme. // VMs of the form "bladeXX_YY" are our worker VMs, and the VM with the name // 'KDRunner' is the KD proxy. Regex bladeNameRe = new Regex("blade[0-9][0-9]_vm[0-9][0-9]", RegexOptions.IgnoreCase); string[] allVMNames = hypervisor_vmware.getVMNames(bladeHostname, kernelVMServerUsername, kernelVMServerPassword).OrderBy(x => x).ToArray(); string[] workerVMNames = allVMNames.Where(x => bladeNameRe.IsMatch(x)).ToArray(); // Construct some info about the KD proxy VM. string KDProxyName = String.Format("blade{0:D2}_kdproxy", bladeID); string KDProxyVMHostNAme = String.Format("blade{0:D2}_kdproxy.xd.lan", bladeID); IPAddress KDProxyIPAddress = Dns.GetHostAddresses(KDProxyVMHostNAme).Single(); // Now construct the worker VMs, configuring each to use the KD proxy. for (int vmIndex = 0; vmIndex < kernelVMCount; vmIndex++) { string vmname = workerVMNames[vmIndex]; string serialPortName; kernelConnectionMethod connMethod; string proxyHostName; ushort kernelDebugPort; string kernelVMDebugKey; if (allVMNames.Any(x => x.ToLower() == KDProxyName.ToLower())) { // Serial ports are specified as seen by the KD proxy. serialPortName = String.Format("com{0}", vmIndex + 1); connMethod = kernelConnectionMethod.serial; proxyHostName = KDProxyIPAddress.ToString(); kernelDebugPort = 0; kernelVMDebugKey = null; } else { serialPortName = null; connMethod = kernelConnectionMethod.net; proxyHostName = null; // VMWare ports are generated according to the blade and VM IDs. // VM 02 on blade 12 would get '51202'. kernelDebugPort = (ushort)(50000 + (bladeID * 100) + (vmIndex) + 1); kernelVMDebugKey = Properties.Settings.Default.VMWareVMDebugKey; // Check the relevant port isn't already in use ipUtils.ensurePortIsFree(kernelDebugPort); } var newHyp = new hypSpec_vmware( vmname, bladeHostname, kernelVMServerUsername, kernelVMServerPassword, kernelVMUsername, kernelVMPassword, snapshotName, null, kernelDebugPort, kernelVMDebugKey, vmname, serialPortName, proxyHostName, connMethod); hyps.Add(newHyp); hypervisorSpecs[newHyp] = false; } } } catch (Exception) { hypervisorSpecs = null; throw; } } }