/// <summary>
        /// Get Blade info for given Blade ID
        /// </summary>
        /// <param name="bladeId">Blade ID (1-48)</param>
        /// <returns>Blade info response</returns>
        public BladeInfoResponse GetBladeInfo(int bladeId)
        {
            byte MaxBladeCount = (byte)ConfigLoaded.Population;

            // Server side class structure to populate blade information
            BladeInfoResponse bip = new BladeInfoResponse();
            bip.bladeNumber = bladeId;
            bip.statusDescription = String.Empty;
            bip.completionCode = Contracts.CompletionCode.Unknown;

            Tracer.WriteInfo("Received GetBladeInfo({0})", bladeId);

            Tracer.WriteUserLog("Invoked GetBladeInfo({0})", bladeId);

            Contracts.ChassisResponse varResponse = ValidateRequest("GetBladeInfo", bladeId);
            if (varResponse.completionCode != Contracts.CompletionCode.Success)
            {
                bip.completionCode = varResponse.completionCode;
                bip.statusDescription = varResponse.statusDescription;
                return bip;
            }

            // Get the blade information from Chassis Controller
            BladeStatusInfo bladeInfo = WcsBladeFacade.GetBladeInfo((byte)bladeId);

            if (bladeInfo.CompletionCode != (byte)CompletionCode.Success)
            {
                Tracer.WriteWarning("GetBladeInfo failed for blade: {0}, with Completion Code: {1}", bladeId,
                     Ipmi.IpmiSharedFunc.ByteToHexString((byte)bladeInfo.CompletionCode));
                bip.completionCode = ChassisManagerUtil.GetContractsCompletionCodeMapping((byte)bladeInfo.CompletionCode);
                bip.statusDescription = bip.completionCode.ToString();
            }
            else
            {
                // Populate the returned object
                bip.completionCode = Contracts.CompletionCode.Success;
                bip.bladeNumber = bladeId;
                bip.firmwareVersion = bladeInfo.BmcFirmware;
                bip.hardwareVersion = bladeInfo.HardwareVersion;
                bip.serialNumber = bladeInfo.SerialNumber;
                bip.assetTag = bladeInfo.AssetTag;

                if (Enum.IsDefined(typeof(BladeTypeName), ChassisState.GetBladeType((byte)bladeId)))
                {
                    bip.bladeType = Enum.GetName(typeof(BladeTypeName), ChassisState.GetBladeType((byte)bladeId));
                }
                else
                {
                    bip.bladeType = BladeTypeName.Unknown.ToString();
                }

                // BMC Mac address should be added as a list
                bip.macAddress = new List<NicInfo>();

                for (int i = 0; i < ConfigLoaded.NumNicsPerBlade; i++)
                {
                    Ipmi.NicInfo ipmiNicInfo = WcsBladeFacade.GetNicInfo((byte)bladeId, (byte)(i + 1));

                    if (ipmiNicInfo.CompletionCode != (byte)CompletionCode.Success &&
                        ipmiNicInfo.CompletionCode != (byte)CompletionCode.IpmiInvalidDataFieldInRequest)
                    {
                        Tracer.WriteError("Nic {0} from Blade {1} returned an error code: {2}", i, bladeId, ipmiNicInfo.CompletionCode);
                    }
                    NicInfo nicInfo = GetNicInfoObject(ipmiNicInfo);
                    bip.macAddress.Add(nicInfo);
                }
            }

            return bip;
        }
        private bool VerifyJbodBladeInfo(bool testPassed, BladeInfoResponse bladeInfo)
        {
            if(bladeInfo.bladeType.ToLower() != "jbod")
            {
                CmTestLog.Warning(String.Format("The provided blade# {0} is not for a JBOD. We cannot check JBOD information against submitted blade", bladeInfo.bladeNumber));
                testPassed = false;
                return testPassed;
            }
            CmTestLog.Info(string.Format("Location# {0} is Jbod", bladeInfo.bladeNumber));

            testPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, bladeInfo.completionCode, "Received success completion code for JBOD");
            testPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.JbodBladeType, bladeInfo.bladeType, "Received JBOD blade type");
            string serialNumber = ConfigurationManager.AppSettings[bladeInfo.bladeNumber.ToString()];
            testPassed &= ChassisManagerTestHelper.AreEqual(bladeInfo.serialNumber, serialNumber, "Received Serial number");
            testPassed &= ChassisManagerTestHelper.AreEqual(ConfigurationManager.AppSettings["JbodFirmwareVersion"], bladeInfo.firmwareVersion, "Successfully verified firmwareVersion");
            testPassed &= ChassisManagerTestHelper.AreEqual(ConfigurationManager.AppSettings["JbodHardwareVersion"], bladeInfo.hardwareVersion, "Successfully verified hardwareVersion");

            if (bladeInfo.macAddress.Count != 0)
            {
                foreach (var nicInfo in bladeInfo.macAddress)
                {
                    testPassed &= ChassisManagerTestHelper.AreEqual(nicInfo.completionCode, CompletionCode.Failure, "Received Failure completion code for Nic#" + nicInfo.deviceId);
                    testPassed &= ChassisManagerTestHelper.IsTrue(string.IsNullOrEmpty(nicInfo.macAddress), "Received empty macAddress ");
                }
            }
            else
            {
                CmTestLog.Info("Received macaddress count is null/zero");
                testPassed = false;
            }

            return testPassed;
        }
        private bool VerifyServerBladeInfo(bool testPassed, BladeInfoResponse bladeInfo)
        {
            PowerStateResponse pState = this.Channel.GetPowerState(bladeInfo.bladeNumber);
            if (pState.powerState != PowerState.ON)
            {
                CmTestLog.Warning("Blade is Powered off. Powering ON blade# " + bladeInfo.bladeNumber);
                this.Channel.SetPowerOn(bladeInfo.bladeNumber);
                System.Threading.Thread.Sleep(35000);
                bladeInfo = this.Channel.GetBladeInfo(bladeInfo.bladeNumber);
            }
            if(bladeInfo.bladeType != "Server")
            {
                BladeStateResponse bs = this.Channel.GetBladeState(bladeInfo.bladeNumber);
                PowerStateResponse ps = this.Channel.GetPowerState(bladeInfo.bladeNumber);
                CmTestLog.Failure("the blade type is not a server. Please verify the blade type and call right blade info verification against slot# " + bladeInfo.bladeNumber + " Blade type is " + bladeInfo.bladeType );
                return false;
            }

            CmTestLog.Info(string.Format("Location# {0} is a Server", bladeInfo.bladeNumber));

            testPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, bladeInfo.completionCode, string.Format("{0} Blade# {1} returns success completion code", bladeInfo.bladeType, bladeInfo.bladeNumber));
            testPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.ServerBladeType, bladeInfo.bladeType, "Received Server blade type");
            testPassed &= ChassisManagerTestHelper.IsTrue(!string.IsNullOrEmpty(bladeInfo.serialNumber), "Nic information section is populated for blade# " + bladeInfo.bladeNumber);
            testPassed &= ChassisManagerTestHelper.AreEqual(ConfigurationManager.AppSettings["FirmwareVersion"], bladeInfo.firmwareVersion, "Successfully verified firmwareVersion for blade#" + bladeInfo.bladeNumber);
            testPassed &= ChassisManagerTestHelper.AreEqual(ConfigurationManager.AppSettings["HardwareVersion"], bladeInfo.hardwareVersion, "Successfully verified hardwareVersion for blade#" + bladeInfo.bladeNumber);

            int numberOfNics = 0;

            if (bladeInfo.macAddress.Count != 0)
            {
                foreach (NicInfo nicInfo in bladeInfo.macAddress)
                {
                    if (nicInfo.statusDescription != "Not Present")
                    {
                        numberOfNics++;
                        testPassed &= ChassisManagerTestHelper.AreEqual(nicInfo.completionCode, CompletionCode.Success, "Received Success completion code for Nic# " + nicInfo.deviceId);
                        testPassed &= ChassisManagerTestHelper.IsTrue(!string.IsNullOrEmpty(nicInfo.macAddress), "macAddress is populated for blade# " + bladeInfo.bladeNumber);
                    }
                }
                testPassed &= ChassisManagerTestHelper.AreEqual(ConfigurationManager.AppSettings["NicCount"], numberOfNics.ToString(), "Nic information failed with wrong nic number");
            }
            else
            {
                CmTestLog.Info("Received macaddress count is null/zero");
                testPassed = false;
            }
            return testPassed;
        }
        private bool VerifyEmptybladeInfo(bool testPassed, BladeInfoResponse bladeInfo)
        {
            CmTestLog.Info(string.Format("Location# {0} is empty", bladeInfo.bladeNumber));

            testPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Timeout, bladeInfo.completionCode, "Received TimeOut completion code for empty blade");
            testPassed &= ChassisManagerTestHelper.IsTrue(string.IsNullOrEmpty(bladeInfo.bladeType), "Received empty blade Type");
            testPassed &= ChassisManagerTestHelper.IsTrue(string.IsNullOrEmpty(bladeInfo.serialNumber), "Received empty serialNumber");
            testPassed &= ChassisManagerTestHelper.IsTrue(string.IsNullOrEmpty(bladeInfo.firmwareVersion), "Received empty firmwareVersion");
            testPassed &= ChassisManagerTestHelper.IsTrue(string.IsNullOrEmpty(bladeInfo.hardwareVersion), "Received empty hardwareVersion");
            testPassed &= ChassisManagerTestHelper.IsTrue(bladeInfo.macAddress.Count == 0, "Received empty macAddress");

            return testPassed;
        }
        private bool VerifyServerBladeInfo(bool testPassed, BladeInfoResponse bladeInfo)
        {
            CmTestLog.Info(string.Format("Location #{0} is Server", bladeInfo.bladeNumber));

            testPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, bladeInfo.completionCode, string.Format("{0} Blade #{1} returns success completion code", bladeInfo.bladeType, bladeInfo.bladeNumber));
            testPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.ServerBladeType, bladeInfo.bladeType, "Received Server blade type");
            string serialNumber = ConfigurationManager.AppSettings[bladeInfo.bladeNumber.ToString()];
            testPassed &= ChassisManagerTestHelper.AreEqual(bladeInfo.serialNumber, serialNumber, "Received Serial number");
            testPassed &= ChassisManagerTestHelper.AreEqual(ConfigurationManager.AppSettings["FirmwareVersion"], bladeInfo.firmwareVersion, "Received firmwareVersion");
            testPassed &= ChassisManagerTestHelper.AreEqual(ConfigurationManager.AppSettings["HardwareVersion"], bladeInfo.hardwareVersion, "Received hardwareVersion");

            if (bladeInfo.macAddress.Count != 0)
            {
                foreach (var nicInfo in bladeInfo.macAddress)
                {
                    testPassed &= ChassisManagerTestHelper.AreEqual(nicInfo.completionCode, CompletionCode.Success, "Received Success completion code for NicInfo");
                    testPassed &= ChassisManagerTestHelper.IsTrue(!string.IsNullOrEmpty(nicInfo.macAddress), "Received macAddress ");
                }
            }
            else
            {
                CmTestLog.Info("Received macaddress count is null/zero");
                testPassed = false;
            }
            return testPassed;
        }
Exemple #6
0
        void printGetscinfoPacket(BladeInfoResponse myPacket)
        {
            if (myPacket.completionCode == Contracts.CompletionCode.Failure)
            {
                Console.WriteLine(WcsCliConstants.commandFailure);
            }
            else if (myPacket.completionCode == Contracts.CompletionCode.Timeout)
            {
                Console.WriteLine(WcsCliConstants.commandTimeout);
            }
            else if (myPacket.completionCode == Contracts.CompletionCode.Unknown)
            {
                Console.WriteLine(WcsCliConstants.bladeStateUnknown);
            }
            else if (myPacket.completionCode != Contracts.CompletionCode.Success)
            {
                Console.WriteLine("Command failed with the completion code :{0}", myPacket.completionCode.ToString());
            }
            else if (myPacket.completionCode == Contracts.CompletionCode.Success)
            {
                // Display output 
                List<string> myStrings = new List<string>();

                // bladeCollections output
                if (myPacket == null)
                {
                    Console.WriteLine(WcsCliConstants.serviceResponseEmpty);
                    return;
                }
                else
                {
                    Console.WriteLine();
                    Console.WriteLine(WcsCliConstants.getscinfoComputeNodeHeader);
                    Console.WriteLine("Firmware Version\t: " + myPacket.firmwareVersion);
                    Console.WriteLine("Hardware Version\t: " + myPacket.hardwareVersion);
                    Console.WriteLine("Serial Number\t\t: " + myPacket.serialNumber);
                    Console.WriteLine("Asset Tag\t\t: " + myPacket.assetTag);
                    Console.WriteLine("");
                    if (myPacket.macAddress != null)
                    {
                        Console.WriteLine(WcsCliConstants.macAddressesInfoHeader);

                        foreach (NicInfo ni in myPacket.macAddress)
                        {
                            Console.WriteLine("Device Id\t\t\t: " + ni.deviceId);
                            Console.WriteLine("MAC Address\t\t: " + ni.macAddress + "\n");
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine(WcsCliConstants.dataFetchError);
            }
        }
Exemple #7
0
        /// <summary>
        /// command specific implementation 
        /// argVal command class member has all user-entered command argument indicators and parameter values
        /// Currently just prints all argument indicators and argument values
        /// </summary>
        internal override void commandImplementation()
        {
            BladeInfoResponse myPacket = new BladeInfoResponse();
            GetAllBladesInfoResponse myPackets = new GetAllBladesInfoResponse();

            try
            {
                if (this.argVal.ContainsKey('a'))
                {
                    myPackets = WcsCli2CmConnectionManager.channel.GetAllBladesInfo();
                }
                else if (this.argVal.ContainsKey('i'))
                {
                    dynamic mySledId = null;
                    this.argVal.TryGetValue('i', out mySledId);
                    myPacket = WcsCli2CmConnectionManager.channel.GetBladeInfo((int)mySledId);
                }
            }
            catch (Exception ex)
            {
                SharedFunc.ExceptionOutput(ex);
                return;
            }

            if ((this.argVal.ContainsKey('a') && myPackets == null) || (myPacket == null))
            {
                Console.WriteLine(WcsCliConstants.serviceResponseEmpty);
                return;
            }

            if (this.argVal.ContainsKey('a'))
            {
                for (int index = 0; index < myPackets.bladeInfoResponseCollection.Count(); index++)
                {
                    Console.WriteLine("======================= Blade {0} ========================", myPackets.bladeInfoResponseCollection[index].bladeNumber);
                    printGetscinfoPacket(myPackets.bladeInfoResponseCollection[index]);
                }
            }
            else
            {
                printGetscinfoPacket(myPacket);
            }
        }
Exemple #8
0
        /// <summary>
        /// command specific implementation 
        /// argVal command class member has all user-entered command argument indicators and parameter values
        /// Currently just prints all argument indicators and argument values
        /// </summary>
        internal override void commandImplementation()
        {
            StartSerialResponse myResponse = new StartSerialResponse();
            BladeInfoResponse bladeInfo = new BladeInfoResponse();

            try
            {
                if (this.argVal.ContainsKey('i'))
                {
                    dynamic mySledId = null;
                    dynamic sessionTimeoutInSecs = null;
                    this.argVal.TryGetValue('i', out mySledId);
                    
                    // Determine blade type
                    bladeInfo = WcsCli2CmConnectionManager.channel.GetBladeInfo((int)mySledId);
                    if (bladeInfo.completionCode == Contracts.CompletionCode.Success)
                    {
                        if (bladeInfo.bladeType == WcsCliConstants.BladeTypeCompute)
                        {
                            // Compute blade needs CR+LF for Enter key
                            enterEncodeCRLF = true;
                        }
                        else if (bladeInfo.bladeType == WcsCliConstants.BladeTypeJBOD)
                        {
                            // JBOD only needs CR for Enter key
                            enterEncodeCRLF = false;
                        }

                        // Open serial session
                        if (this.argVal.TryGetValue('s', out sessionTimeoutInSecs))
                        {
                            myResponse = WcsCli2CmConnectionManager.channel.StartBladeSerialSession(
                            (int)mySledId, (int)sessionTimeoutInSecs);
                        }
                        else
                        {
                            myResponse = WcsCli2CmConnectionManager.channel.StartBladeSerialSession(
                            (int)mySledId, 0);
                        }

                    }
                    else
                    {
                        myResponse.completionCode = Contracts.CompletionCode.Failure;
                    }

                    // set blade Id
                    bladeId = (int)mySledId;
                }
            }
            catch (Exception ex)
            {
                SharedFunc.ExceptionOutput(ex);
            }

            if (myResponse.completionCode == Contracts.CompletionCode.Success)
            {
                if (myResponse.serialSessionToken != null)
                {
                    // set the serial cache
                    SessionString = myResponse.serialSessionToken;

                    if (bladeId > 0)
                    {
                        // Console client
                        if (!this.isSerialClient)
                        {
                            // Automatically start into VT100 mode.
                            // This is a blocking method.
                            SetupVt100(enterEncodeCRLF);
                        }
                        else // Serial client
                        {
                            SharedFunc.SetSerialSession(true);
                            EstablishBladeSerialSessionOverSerialClient();
                        }
                        // When the setup ends, call a close session by default
                        // as the session should be destroyed.
                        WcsCli2CmConnectionManager.channel.StopBladeSerialSession(bladeId, SessionString);
                    }
                    else
                    {
                        ErrorMessage("failed to start serial session due to conversion of blade Id", false, false);
                    }
                    return;
                }
            }
            else if (myResponse.completionCode == Contracts.CompletionCode.Failure)
            {
                Console.WriteLine(WcsCliConstants.commandFailure);
                return;
            }
            else if (myResponse.completionCode == Contracts.CompletionCode.Timeout)
            {
                Console.WriteLine(WcsCliConstants.commandTimeout);
                return;
            }
            else
            {
                Console.WriteLine(WcsCliConstants.unknownError);
            }
        }