Ejemplo n.º 1
0
        /// <summary>
        /// This method should be called prior to using this class
        /// </summary>
        static internal CompletionCode Init()
        {
            CompletionCode completionCode = CompletionCode.CommDevFailedToInit;

            // Clear this flag in case that CM retries to initialize
            isTerminating = false;

            // Safe mode is disabled by default when initialized
            isSafeModeEnabled = false;

            // Enforce that the update to the flag variable is visible to other threads orderly
            Thread.MemoryBarrier();

            portManagers = new PortManager[numPorts];

            for (int i = 0; i < numPorts; i++)
            {
                portManagers[i] = new SerialPortManager(i, numPriorityLevels);
                completionCode  = portManagers[i].Init();
                if (CompletionCodeChecker.Failed(completionCode) == true)
                {
                    Tracer.WriteError("Failed to initialize portManager: {0} Logical Id: {1}", i,
                                      PortManager.GetPhysicalPortNameFromLogicalId(i));
                    Release();
                    return(completionCode);
                }
            }

            return(completionCode);
        }
        /// <summary>
        /// This method should be called prior to using this class
        /// </summary>
        static internal CompletionCode Init()
        {
            CompletionCode completionCode = CompletionCode.CommDevFailedToInit;

            // populdate Blade_En State Cache.
            foreach (byte Id in physicalServerIdTable)
            {
                CachedBladePowerStatus.Add(Id, new BladeEnState());
            }

            // Clear this flag in case that CM retries to initialize
            isTerminating = false;

            // Enforce that the update to the flag variable is visible to other threads orderly
            Thread.MemoryBarrier();

            portManagers = new PortManager[numPorts];

            for (int i = 0; i < numPorts; i++)
            {
                portManagers[i] = new SerialPortManager(i, numPriorityLevels);
                completionCode  = portManagers[i].Init();
                if (CompletionCodeChecker.Failed(completionCode) == true)
                {
                    Tracer.WriteError("Failed to initialize portManager: {0} Logical Id: {1}", i,
                                      PortManager.GetPhysicalPortNameFromLogicalId(i));
                    Release();
                    return(completionCode);
                }
            }

            return(completionCode);
        }
        /// <summary>
        /// Initialize Communication Device
        /// </summary>
        /// <returns>status byte which indicates whether initialization was successful or not</returns>
        private static byte CommunicationDeviceInitialize()
        {
            byte status = (byte)CompletionCode.UnspecifiedError;

            Tracer.WriteInfo("Initializing Communication Device");
            CompletionCode completionCode = CommunicationDevice.Init();

            #region Comm. Device Initialization Retry
            if (CompletionCodeChecker.Failed(completionCode))
            {
                Tracer.WriteWarning("Initialization failed: {0}", completionCode);
                int loop = 0;

                // Retry 3 times before failing completely
                for (loop = 0; loop < ConfigLoaded.MaxRetries; loop++)
                {
                    Tracer.WriteInfo("Initialization Retry: {0}", loop);

                    completionCode = CommunicationDevice.Init();
                    if (CompletionCodeChecker.Succeeded(completionCode))
                    {
                        break;
                    }
                }

                if (loop == ConfigLoaded.MaxRetries)
                {
                    Tracer.WriteError("Re-attempt at Communication Device Initialization failed with code: {0}", completionCode);
                    return(status);
                }
            }
            #endregion

            if (CompletionCodeChecker.Succeeded(completionCode))
            {
                Tracer.WriteInfo("Communication Device Initialization successful..");
            }

            return((byte)CompletionCode.Success);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initialize Chassis constants and configs
        /// </summary>
        internal byte Initialize()
        {
            Tracer.WriteInfo("Initializing state");

            byte status = (byte)CompletionCode.UnspecifiedError;

            ChassisState.Initialize();

            Tracer.WriteInfo("Initializing Communication Device");
            // Initializer lower layer communication device
            CompletionCode completionCode = CommunicationDevice.Init();

            if (CompletionCodeChecker.Failed(completionCode))
            {
                Tracer.WriteWarning("Initialization failed: {0}", completionCode);
                int loop = 0;

                // Retry 3 times before failing completely
                for (loop = 0; loop < ConfigLoaded.MaxRetries; loop++)
                {
                    Tracer.WriteInfo("Initialization Retry: {0}", loop);

                    completionCode = CommunicationDevice.Init();
                    if (CompletionCodeChecker.Succeeded(completionCode))
                    {
                        break;
                    }
                }

                if (loop == ConfigLoaded.MaxRetries)
                {
                    Tracer.WriteError("Re-attempt at Communication Device Initialization failed with code: {0}", completionCode);
                    return(status);
                }
            }
            if (CompletionCodeChecker.Succeeded(completionCode))
            {
                Tracer.WriteInfo("Communication Device Initialized");
                status = (byte)CompletionCode.Success;
            }

            // Get power status of enable pin for each blade and update blade state
            for (byte deviceId = 1; deviceId <= MaxSledCount; deviceId++)
            {
                CheckPowerEnableState(deviceId);
            }

            // Initialize Wcs Blade - TODO: This initialize should return some status
            WcsBladeFacade.Initialize();  // This method just creates IPMI Client Class for each blade.
            Tracer.WriteInfo("IPMI Facade Initialized, Number of blades initialized: {0}", WcsBladeFacade.Initialized);

            // check all client initialization status and update state
            Tracer.WriteInfo("Checking client status for {0} blades", MaxSledCount);
            for (byte deviceId = 1; deviceId <= MaxSledCount; deviceId++)
            {
                // TODO: How to check initialized status, now that this has become a function
                if (WcsBladeFacade.clients[deviceId].Initialize()) // This method logs on to an IPMI session.
                {
                    // If initialized is true, change state to probation
                    Tracer.WriteInfo("State Transition for Sled {0}: {1} -> Probation", deviceId,
                                     ChassisState.GetStateName(deviceId));

                    ChassisState.SetBladeState(deviceId, (byte)BladeState.Probation);
                }
                else
                {
                    Tracer.WriteInfo("Blade not initialized: Blade ", +deviceId);
                }
            }

            Tracer.WriteInfo("Initializing Watchdog Timer");

            // Initialize WatchDog Timer
            ChassisState.Wdt.EnableWatchDogTimer();

            Tracer.WriteInfo("Watchdog timer initialized");

            // Initialize internal chassis manager tables
            this.ChassisInternalInitialize();

            return(status);
        }