public hypervisorCollection <hypSpec_iLo> requestAsManyHypervisorsAsPossible(string snapshotName)
        {
            initialiseIfNeeded();
            using (BladeDirectorServices director = new BladeDirectorServices(machinePools.bladeDirectorURL))
            {
                int nodeCount = director.svc.getAllBladeIP().Length;

                hypervisorCollection <hypSpec_iLo> toRet = new hypervisorCollection <hypSpec_iLo>();
                DateTime deadline = DateTime.Now + TimeSpan.FromMinutes(60);
                try
                {
                    for (int i = 0; i < nodeCount; i++)
                    {
                        resultAndBladeName res      = director.svc.RequestAnySingleNode();
                        resultAndBladeName progress = director.waitForSuccess(res, deadline - DateTime.Now);

                        bladeSpec          bladeConfig = director.svc.getBladeByIP_withoutLocking(progress.bladeName);
                        resultAndWaitToken snapRes     = director.svc.selectSnapshotForBladeOrVM(progress.bladeName, snapshotName);
                        director.waitForSuccess(snapRes, TimeSpan.FromMinutes(3));

                        snapshotDetails snapshot = director.svc.getCurrentSnapshotDetails(progress.bladeName);
                        userDesc        cred     = bladeConfig.credentials.First();
                        NASParams       nas      = director.svc.getNASParams();
                        hypSpec_iLo     spec     = new hypSpec_iLo(
                            bladeConfig.bladeIP, cred.username, cred.password,
                            bladeConfig.iLOIP, bladeConfig.iLoUsername, bladeConfig.iLoPassword,
                            nas.IP, nas.username, nas.password,
                            snapshot.friendlyName, snapshot.path,
                            bladeConfig.kernelDebugPort, bladeConfig.kernelDebugKey
                            );

                        ipUtils.ensurePortIsFree(bladeConfig.kernelDebugPort);

                        bladeDirectedHypervisor_iLo newHyp = new bladeDirectedHypervisor_iLo(spec);
                        newHyp.setDisposalCallback(onDestruction);

                        if (!toRet.TryAdd(bladeConfig.bladeIP, newHyp))
                        {
                            throw new Exception();
                        }
                    }
                    return(toRet);
                }
                catch (Exception)
                {
                    toRet.Dispose();
                    throw;
                }
            }
        }
        public bladeDirectedHypervisor_iLo createSingleHypervisor(string snapshotName)
        {
            initialiseIfNeeded();

            // We request a blade from the blade director, and use them for all our tests, blocking if none are available.
            using (BladeDirectorServices director = new BladeDirectorServices(machinePools.bladeDirectorURL))
            {
                // Request a node. If all queues are full, then wait and retry until we get one.
                resultAndBladeName allocatedBladeResult;
                while (true)
                {
                    allocatedBladeResult = director.svc.RequestAnySingleNode();
                    if (allocatedBladeResult.result.code == resultCode.success ||
                        allocatedBladeResult.result.code == resultCode.pending)
                    {
                        break;
                    }
                    if (allocatedBladeResult.result.code == resultCode.bladeQueueFull)
                    {
                        Debug.WriteLine("All blades are fully queued, waiting until one is spare");
                        Thread.Sleep(TimeSpan.FromSeconds(5));
                        continue;
                    }
                    throw new Exception("Blade director returned unexpected return status '" + allocatedBladeResult.result + "'");
                }

                // Now, wait until our blade is available.
                try
                {
                    bool isMine = director.svc.isBladeMine(allocatedBladeResult.bladeName);
                    while (!isMine)
                    {
                        Debug.WriteLine("Blade " + allocatedBladeResult.bladeName + " not released yet, awaiting release..");
                        Thread.Sleep(TimeSpan.FromSeconds(5));
                        isMine = director.svc.isBladeMine(allocatedBladeResult.bladeName);
                    }

                    // Great, now we have ownership of the blade, so we can use it safely.
                    //bladeSpec bladeConfig = director.svc.getConfigurationOfBlade(allocatedBladeResult.bladeName);
                    resultAndWaitToken res = director.svc.selectSnapshotForBladeOrVM(allocatedBladeResult.bladeName, snapshotName);
                    director.waitForSuccess(res, TimeSpan.FromMinutes(5));

                    bladeSpec       bladeConfig = director.svc.getBladeByIP_withoutLocking(allocatedBladeResult.bladeName);
                    snapshotDetails currentShot = director.svc.getCurrentSnapshotDetails(allocatedBladeResult.bladeName);
                    userDesc        cred        = bladeConfig.credentials.First();
                    NASParams       nas         = director.svc.getNASParams();

                    hypSpec_iLo spec = new hypSpec_iLo(
                        bladeConfig.bladeIP, cred.username, cred.password,
                        bladeConfig.iLOIP, bladeConfig.iLoUsername, bladeConfig.iLoPassword,
                        nas.IP, nas.username, nas.password,
                        currentShot.friendlyName, currentShot.path,
                        bladeConfig.kernelDebugPort, bladeConfig.kernelDebugKey
                        );

                    ipUtils.ensurePortIsFree(bladeConfig.kernelDebugPort);

                    bladeDirectedHypervisor_iLo toRet = new bladeDirectedHypervisor_iLo(spec);
                    toRet.setDisposalCallback(onDestruction);
                    return(toRet);
                }
                catch (Exception)
                {
                    director.svc.ReleaseBladeOrVM(allocatedBladeResult.bladeName);
                    throw;
                }
            }
        }