Example #1
0
        private static void mockedBiosThread(mockedBiosThreadParams param)
        {
            using (lockableBladeSpec blade = param.db.getBladeByIP(param.nodeIP, bladeLockType.lockBIOS, bladeLockType.lockBIOS, true, true))
            {
                blade.spec.currentlyHavingBIOSDeployed = true;
            }
            param.isStarted = true;
            param.signalOnStart.Set();

            using (lockableBladeSpec blade = param.db.getBladeByIP(param.nodeIP, bladeLockType.lockLongRunningBIOS, bladeLockType.lockLongRunningBIOS, true, true))
            {
                while (true)
                {
                    if (DateTime.Now > param.deadline)
                    {
                        using (var tmp = new tempLockElevation(blade, bladeLockType.lockBIOS, bladeLockType.lockBIOS))
                        {
                            param.parent.markLastKnownBIOS(blade, param.BIOSToWrite);
                            param.result = new result(resultCode.success);

                            return;
                        }
                    }

                    if (param.isCancelled)
                    {
                        param.result = new result(resultCode.cancelled);
                        return;
                    }

                    Thread.Sleep(TimeSpan.FromSeconds(1));
                }
            }
        }
Example #2
0
        public result rebootAndStartReadingBIOSConfiguration(hostStateManager_core parent, string nodeIp, ManualResetEvent signalOnStart)
        {
            lock (_threads)
            {
                if (_threads.ContainsKey(nodeIp))
                {
                    if (!_threads[nodeIp].isFinished)
                    {
                        throw new Exception("Blade " + nodeIp + " has not yet finished a previous operation");
                    }
                    _threads.Remove(nodeIp);
                }
                mockedBiosThreadParams newParams = new mockedBiosThreadParams
                {
                    isFinished    = false,
                    nodeIP        = nodeIp,
                    db            = parent.db,
                    deadline      = DateTime.Now + biosOperationTime,
                    signalOnStart = signalOnStart
                };
                _threads.Add(nodeIp, newParams);

                Thread newThread = new Thread(mockedBiosThread)
                {
                    Name = "Mocked BIOS deployment thread"
                };
                newThread.Start(newParams);

                return(new result(resultCode.success));
            }
        }
Example #3
0
        private static void mockedBiosThread(Object param)
        {
            mockedBiosThreadParams paramTyped = (mockedBiosThreadParams)param;

            try
            {
                mockedBiosThread(paramTyped);
            }
            catch (Exception e)
            {
                paramTyped.result = new result(resultCode.genericFail, e.Message + " @ " + e.StackTrace);
            }
            finally
            {
                using (lockableBladeSpec blade = paramTyped.db.getBladeByIP(paramTyped.nodeIP,
                                                                            bladeLockType.lockBIOS, bladeLockType.lockBIOS, true, true))
                {
                    blade.spec.currentlyHavingBIOSDeployed = false;
                    paramTyped.isFinished = true;
                }
            }
        }