/// <summary>
        /// Test Command: GetChassisInfo: Get Only blade information (bladeInfo=true). 
        /// </summary>
        /// <param name="allPassed"></param>
        /// <param name="chassisInfo"></param>
        /// <returns>True if all check-points pass; false, otherwise.</returns>
        private TestResponse VerifyOnlyChassisBladeInfo(ChassisInfoResponse chassisInfo)
        {
            TestResponse response = new TestResponse();
            try
            {
                response.Result = ChassisManagerTestHelper.IsTrue(chassisInfo != null, "Received chasssis information ");

                // Return if chassis information is null
                if (response.Result == false)
                {
                    response.ResultDescription.Append("\nReceived chassis object is null");
                    return response;
                }

                if (chassisInfo.completionCode != CompletionCode.Success)
                {
                    response.Result = false;
                    response.ResultDescription.Append("\nFailed to get chassis information with only bladeInfo set to true, completion code returned: " + chassisInfo.completionCode);
                    CmTestLog.Failure(response.ResultDescription.ToString());
                    return response;
                }
                CmTestLog.Success("Successfully received chassis information");

                response = this.VerifyChassisBladeInfo(chassisInfo);

                // Verify battery info is empty
                if (!ChassisManagerTestHelper.IsTrue(chassisInfo.batteryCollections.Count == 0, "Battery information is empty"))
                {
                    response.Result &= false;
                    response.ResultDescription.Append("\nVerifyOnlyChassisBladeInfo failed: Battery information is not empty");
                }

                // Verify PSU information is empty
                if (!ChassisManagerTestHelper.IsTrue(chassisInfo.psuCollections.Count == 0, "PSU information is empty"))
                {
                    response.Result &= false;
                    response.ResultDescription.Append("\nVerifyOnlyChassisBatteryInfo failed: PSU information is not empty");
                }

                // Verify chassis controller info is empty
                if (!ChassisManagerTestHelper.IsTrue(chassisInfo.chassisController == null, "Chassis controller information is empty"))
                {
                    response.Result &= false;
                    response.ResultDescription.Append("\nVerifyOnlyChassisBatteryInfo failed: Chassis Controller information is not empty");
                }
            }
            catch (Exception ex)
            {
                ChassisManagerTestHelper.IsTrue(false, ex.Message);
                response.Result = false;
                response.ResultDescription.Append(ex.Message);
            }

            return response;
        }
        /// <summary>
        /// Verify chassis info
        /// </summary>
        /// <param name="allPassed">Flag indicating success/failure</param>
        /// <param name="chassisInfo">Chassis info response</param>
        /// <returns>returns success/failure</returns>
        private TestResponse VerifyChassisInfo(ChassisInfoResponse chassisInfo)
        {
            TestResponse response = new TestResponse();

            response.Result = ChassisManagerTestHelper.IsTrue(chassisInfo != null, "Received chasssis information ");

            // Return if chassis information is null
            if (response.Result == false)
            {
                response.ResultDescription.Append("\nReceived chassis object is null");
                return response;
            }

            if (chassisInfo.completionCode != CompletionCode.Success)
            {
                response.Result = false;
                response.ResultDescription.Append("\nFailed to get chassis information, completion code returned: " + chassisInfo.completionCode);
                CmTestLog.Failure(response.ResultDescription.ToString());
                return response;
            }
            CmTestLog.Success("Successfully received chassis info");

            TestResponse testResponse = VerifyChassisBladeInfo(chassisInfo);
            response.Result &= testResponse.Result;
            response.ResultDescription.Append(testResponse.ResultDescription);

            testResponse = VerifyChassisPsuInfo(chassisInfo);
            response.Result &= testResponse.Result;
            response.ResultDescription.Append(testResponse.ResultDescription);

            testResponse = VerifyChassisBatteryInfo(chassisInfo);
            response.Result &= testResponse.Result;
            response.ResultDescription.Append(testResponse.ResultDescription);

            testResponse = VerifyChassisControllerInfo(chassisInfo);
            response.Result &= testResponse.Result;
            response.ResultDescription.Append(testResponse.ResultDescription);

            return response;
        }
        /// <summary>
        /// Test Command: GetChassisInfo: Get Only Battery information (batteryInfo=true). 
        /// </summary>
        /// <param name="allPassed"></param>
        /// <param name="chassisHealth"></param>
        /// <returns>True if all check-points pass; false, otherwise.</returns>
        private TestResponse VerifyOnlyChassisBatteryInfo(ChassisInfoResponse chassisInfo)
        {
            TestResponse response = new TestResponse();

            try
            {
                response.Result = ChassisManagerTestHelper.IsTrue(chassisInfo != null, "Received chasssis info ");

                // Return if chassis information is null
                if (response.Result == false)
                {
                    response.ResultDescription.Append("\nReceived chassis object is null");
                    return response;
                }

                if (CmConstants.NumBatteries == 0)
                {
                    foreach (var battery in chassisInfo.batteryCollections)
                    {
                        if (battery.completionCode != CompletionCode.Unknown || battery.presence != 0)
                        {
                            response.ResultDescription.Append(string.Format("\n Battery# {0} returns {1} when it should be Unknown", battery.id, battery.completionCode));
                            response.ResultDescription.Append(string.Format("Battery# {0} returns Presence value as {1}", battery.id, battery.presence));
                            response.Result &= false;
                            return response;
                        }
                    }

                    response.Result = true;
                    response.ResultDescription.Append("\nSuccessfully verified response for case of non present batteries.");
                    CmTestLog.Success(response.ResultDescription.ToString());
                    return response;
                }
                else
                {
                    if (chassisInfo.completionCode != CompletionCode.Success)
                    {
                        response.Result = false;
                        response.ResultDescription.Append("\nFailed to get chassis information with only Chassis Battery Info set to true, completion code returned: " + chassisInfo.completionCode);
                        CmTestLog.Failure(response.ResultDescription.ToString());
                        return response;
                    }
                    CmTestLog.Success("Successfully received chassis info");

                    response = VerifyChassisBatteryInfo(chassisInfo);

                    // Verify blade information is empty
                    if (!ChassisManagerTestHelper.IsTrue(chassisInfo.bladeCollections.Count == 0, "Blade information is empty"))
                    {
                        response.Result &= false;
                        response.ResultDescription.Append("\nVerifyOnlyChassisBatteryInfo failed: Blade information is not empty");
                    }

                    // Verify PSU information is empty
                    if (!ChassisManagerTestHelper.IsTrue(chassisInfo.psuCollections.Count == 0, "PSU information is empty"))
                    {
                        response.Result &= false;
                        response.ResultDescription.Append("\nVerifyOnlyChassisBatteryInfo failed: PSU information is not empty");
                    }

                    // Verify chassis controller info is empty
                    if (!ChassisManagerTestHelper.IsTrue(chassisInfo.chassisController == null, "Chassis controller information is empty"))
                    {
                        response.Result &= false;
                        response.ResultDescription.Append("\nVerifyOnlyChassisBatteryInfo failed: Chassis Controller information is not empty");
                    }
                }
            }
            catch (Exception ex)
            {
                ChassisManagerTestHelper.IsTrue(false, ex.Message);
                response.Result = false;
                response.ResultDescription.Append(ex.Message);
            }

            return response;
        }
        private TestResponse GetChassisInfoByAllUsers(WCSSecurityRole roleId)
        {
            TestResponse response = new TestResponse();
            try
            {
                // Use the Domain User Channel
                this.TestChannelContext = this.ListTestChannelContexts[(int)roleId];
                if (this.TestChannelContext != null)
                {
                    ChassisInfoResponse chassisInfo = new ChassisInfoResponse();

                    // Test GetChassisInfo, get all information
                    CmTestLog.Info("Verifying chassis information when all params are true");
                    chassisInfo = this.TestChannelContext.GetChassisInfo(true, true, true, true);

                    TestResponse testResponse = this.VerifyChassisInfo(chassisInfo);
                    response.Result &= testResponse.Result;
                    response.ResultDescription.Append(testResponse.ResultDescription);

                    CmTestLog.Info("Finished verification of GetchassisInfo when all information was returned blade, PSU, battery and chassis controller \n");

                    // Test GetChassisInfo with no params
                    CmTestLog.Info("Verifying chassis information when all params are false OR no Params\n");
                    chassisInfo = this.TestChannelContext.GetChassisInfo(false, false, false, false);

                    testResponse = this.VerifyChassisInfo(chassisInfo);
                    response.Result &= testResponse.Result;
                    response.ResultDescription.Append(testResponse.ResultDescription);

                    CmTestLog.Info("Finished verification of GetchassisInfo with no params \n");

                    // Test for GetChassisInfo with only blade info
                    CmTestLog.Info("Verifying chassis information for only Blade, bladeInfo param is true\n");
                    chassisInfo = this.TestChannelContext.GetChassisInfo(true, false, false, false);

                    testResponse = this.VerifyOnlyChassisBladeInfo(chassisInfo);
                    response.Result &= testResponse.Result;
                    response.ResultDescription.Append(testResponse.ResultDescription);

                    CmTestLog.Info("Finished verification of GetchassisInfo for only Blade information \n");

                    // Test for GetChassisInfo for only PSU information
                    CmTestLog.Info("Verifying chassis information for only psuInfo param is true\n");
                    chassisInfo = this.TestChannelContext.GetChassisInfo(false, true, false, false);

                    testResponse = this.VerifyOnlyChassisPsuInfo(chassisInfo);
                    response.Result &= testResponse.Result;
                    response.ResultDescription.Append(testResponse.ResultDescription);

                    CmTestLog.Info("Finished verification of GetChassisInfo for only PSU information \n");

                    // Test for GetChassisInfo for only Battery information
                    CmTestLog.Info("Verifying chassis information for only batteryInfo param is true\n");
                    chassisInfo = this.TestChannelContext.GetChassisInfo(false, false, false, true);

                    testResponse = this.VerifyOnlyChassisBatteryInfo(chassisInfo);
                    response.Result = testResponse.Result;
                    response.ResultDescription.Append(testResponse.ResultDescription);

                    CmTestLog.Info("Finished verification of GetChassisInfo for only battery information \n");

                    // Test for GetChassisInfo for only chassis controller information
                    CmTestLog.Info("Verifying chassis information for only chassisControllerInfo param is true\n");
                    chassisInfo = this.TestChannelContext.GetChassisInfo(false, false, true, false);

                    testResponse = this.VerifyOnlyChassisControllerInfo(chassisInfo);
                    response.Result = testResponse.Result;
                    response.ResultDescription.Append(testResponse.ResultDescription);

                    CmTestLog.Info("Finished verification of GetChassisInfo for only chassis controller information \n");
                }
            }
            catch (Exception ex)
            {
                ChassisManagerTestHelper.IsTrue(false, ex.Message);
                response.Result &= false;
                response.ResultDescription.Append(ex.Message);
            }
            return response;
        }
        /// <summary>
        /// Verify chassis blade info
        /// </summary>
        /// <param name="allPassed">Flag indicating success/failure</param>
        /// <param name="chassisInfo">Chassis info response</param>
        /// <returns>returns success/failure</returns>
        private TestResponse VerifyChassisBladeInfo(ChassisInfoResponse chassisInfo)
        {
            TestResponse response = new TestResponse();

            CmTestLog.Info("Verifying blade info");
            response.Result = ChassisManagerTestHelper.AreEqual(CmConstants.Population, chassisInfo.bladeCollections.Count, "Verified the number of blades in the chassis");
            if (response.Result == false)
            {
                response.ResultDescription.Append("\nChassis blade info verification failed : Number of blades in the chassis do not match with the config value");
            }
            foreach (var bladeInfo in chassisInfo.bladeCollections)
            {
                if (!EmptyLocations.Contains(bladeInfo.bladeNumber))
                {
                response.Result &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, bladeInfo.completionCode, string.Format("Blade# {0} returns {1}", bladeInfo.bladeNumber, bladeInfo.completionCode));
                if (response.Result == false)
                {
                    response.ResultDescription.Append(string.Format("\nFailed to get blade " + bladeInfo.bladeNumber + " information, completion code returned: " + bladeInfo.completionCode));
                }
            }
            }
            return response;
        }
예제 #6
0
        /// <summary>
        /// Verify chassis battery info
        /// </summary>
        /// <param name="allPassed">Flag indicating success/failure</param>
        /// <param name="chassisInfo">Chassis info response</param>
        /// <returns>returns success/failure</returns>
        private static bool VerifyChassisBatteryInfo(bool allPassed, ChassisInfoResponse chassisInfo)
        {
            CmTestLog.Info("Verifying battery info");
            allPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.NumBattery, chassisInfo.batteryCollections.Count, "Verified the number of Batteries");

            foreach (var battery in chassisInfo.batteryCollections)
            {
                allPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, battery.completionCode, string.Format("Battery #{0} returns success", battery.id));
            }
            return allPassed;
        }
        /// <summary>
        /// Verify chassis PSU info
        /// </summary>
        /// <param name="allPassed">Flag indicating success/failure</param>
        /// <param name="chassisInfo">Chassis info response</param>
        /// <returns>returns success/failure</returns>
        private static TestResponse VerifyChassisPsuInfo(ChassisInfoResponse chassisInfo)
        {
            TestResponse response = new TestResponse();

            CmTestLog.Info("Verifying PSU info");

            if (!ChassisManagerTestHelper.AreEqual(CmConstants.NumPsus, chassisInfo.psuCollections.Count, "Verified the number of PSUs is correct"))
            {
                response.Result = false;
                response.ResultDescription.Append("\n VerifyChassisBatteryInfo : Number of PSUs do not match the config value");
            }

            foreach (var psu in chassisInfo.psuCollections)
            {
                if (!ChassisManagerTestHelper.AreEqual(PowerState.ON, psu.state, string.Format("PSU# {0} power state is {1}", psu.id, psu.state)))
                {
                    response.ResultDescription.Append(string.Format("\nPSU# {0} power state is {1}", psu.id, psu.state));
                    response.Result &= false;
                }
            }
            return response;
        }
        /// <summary>
        /// Test GetChassisInfo for all possible parameters
        /// </summary>
        /// <returns>True if all check-points pass; false, otherwise.</returns>
        public TestResponse GetChassisInfoTest()
        {
            CmTestLog.Start();
            TestResponse response = new TestResponse();

            this.ServerLocations = this.GetServerLocations();
            this.EmptyLocations = this.GetEmptyLocations();
            this.JbodLocations = this.GetJbodLocations();

            try
            {
                ChassisInfoResponse chassisInfo = new ChassisInfoResponse();

                // Test GetChassisInfo, get all information
                CmTestLog.Info("Verifying chassis information when all params are true");
                chassisInfo = this.Channel.GetChassisInfo(true, true, true, true);

                // define an object of TestResponse class for test results
                TestResponse testResponse = this.VerifyChassisInfo(chassisInfo);
                response.Result &= testResponse.Result;
                response.ResultDescription.Append(testResponse.ResultDescription);

                CmTestLog.Info("Finished verification of GetchassisInfo when all information was returned blade, PSU, battery and chassis controller \n");

                // Test GetChassisInfo with no params
                CmTestLog.Info("Verifying chassis information when all params are false OR no Params\n");
                chassisInfo = this.Channel.GetChassisInfo(false, false, false, false);

                testResponse = this.VerifyChassisInfo(chassisInfo);
                response.Result &= testResponse.Result;
                response.ResultDescription.Append(testResponse.ResultDescription);

                CmTestLog.Info("Finished verification of GetchassisInfo with no params \n");

                // Test for GetChassisInfo with only blade info
                CmTestLog.Info("Verifying chassis information for only Blade, bladeInfo param is true\n");
                chassisInfo = this.Channel.GetChassisInfo(true, false, false, false);

                testResponse = this.VerifyOnlyChassisBladeInfo(chassisInfo);
                response.Result &= testResponse.Result;
                response.ResultDescription.Append(testResponse.ResultDescription);

                CmTestLog.Info("Finished verification of GetchassisInfo for only Blade information \n");

                // Test for GetChassisInfo for only PSU information
                CmTestLog.Info("Verifying chassis information for only psuInfo param is true");
                chassisInfo = this.Channel.GetChassisInfo(false, true, false, false);

                testResponse = this.VerifyOnlyChassisPsuInfo(chassisInfo);
                response.Result &= testResponse.Result;
                response.ResultDescription.Append(testResponse.ResultDescription);

                CmTestLog.Info("Finished verification of GetChassisInfo for only PSU information \n");

                // Test for GetChassisInfo for only Battery information
                CmTestLog.Info("Verifying chassis information for only batteryInfo param is true\n");
                chassisInfo = this.Channel.GetChassisInfo(false, false, false, true);

                testResponse = this.VerifyOnlyChassisBatteryInfo(chassisInfo);
                response.Result &= testResponse.Result;
                response.ResultDescription.Append(testResponse.ResultDescription);

                CmTestLog.Info("Finished verification of GetChassisInfo for only battery information \n");

                // Test for GetChassisInfo for only chassis controller information
                CmTestLog.Info("Verifying chassis information for only chassisControllerInfo param is true\n");
                chassisInfo = this.Channel.GetChassisInfo(false, false, true, false);

                testResponse = this.VerifyOnlyChassisControllerInfo(chassisInfo);
                response.Result &= testResponse.Result;
                response.ResultDescription.Append(testResponse.ResultDescription);

                CmTestLog.Info("Finished verification of GetChassisInfo for only chassis controller information \n");
            }
            catch (Exception ex)
            {
                ChassisManagerTestHelper.IsTrue(false, ex.Message);
                response.Result &= false;
                response.ResultDescription.Append(ex.Message);
            }

            CmTestLog.End(response.Result);
            return response;
        }
        /// <summary>
        /// Verify chassis battery info
        /// </summary>
        /// <param name="allPassed">Flag indicating success/failure</param>
        /// <param name="chassisInfo">Chassis info response</param>
        /// <returns>returns success/failure</returns>
        private static TestResponse VerifyChassisBatteryInfo(ChassisInfoResponse chassisInfo)
        {
            TestResponse response = new TestResponse();

            CmTestLog.Info("Verifying battery info");
            if (CmConstants.NumBatteries == 0)
            {
                foreach (var battery in chassisInfo.batteryCollections)
                {
                    if (battery.completionCode != CompletionCode.Unknown || battery.presence != 0)
                    {
                        response.ResultDescription.Append(string.Format("\n Battery# {0} returns {1} when it should be Unknown", battery.id, battery.completionCode));
                        response.ResultDescription.Append(string.Format("Battery# {0} returns Presence value as {1}", battery.id, battery.presence));
                        response.Result &= false;
                    }
                }
            }
            else
            {
                foreach (var battery in chassisInfo.batteryCollections)
                {
                    if (!ChassisManagerTestHelper.AreEqual(CompletionCode.Success, battery.completionCode, string.Format("Battery# {0} returns {1}", battery.id, battery.completionCode)))
                    {
                        response.ResultDescription.Append(string.Format("\n Battery# {0} returns {1}", battery.id, battery.completionCode));
                        response.Result &= false;
                    }
                }
            }
            return response;
        }
예제 #10
0
        /// <summary>
        /// Verify chassis info
        /// </summary>
        /// <param name="allPassed">Flag indicating success/failure</param>
        /// <param name="chassisInfo">Chassis info response</param>
        /// <returns>returns success/failure</returns>
        private bool VerifyChassisInfo(bool allPassed, ChassisInfoResponse chassisInfo)
        {
            allPassed &= ChassisManagerTestHelper.IsTrue(chassisInfo != null, "Received chasssis information ");

            if (chassisInfo.completionCode != CompletionCode.Success)
            {
                CmTestLog.Failure(string.Format("Failed to get chassis info, completion code returned : {0}", chassisInfo.completionCode));
                return false;
            }
            CmTestLog.Success("Successfully received chassis info");

            allPassed = this.VerifyChassisBladeInfo(allPassed, chassisInfo);

            allPassed = VerifyChassisPsuInfo(allPassed, chassisInfo);

            allPassed = VerifyChassisBatteryInfo(allPassed, chassisInfo);

            allPassed = VerifyChassisControllerInfo(allPassed, chassisInfo);

            return allPassed;
        }
예제 #11
0
        /// <summary>
        /// Test Command: GetChassisInfo: Get Only PSU information (psuInfo=true). 
        /// </summary>
        /// <param name="allPassed"></param>
        /// <param name="chassisInfo"></param>
        /// <returns>True if all check-points pass; false, otherwise.</returns>
        private bool VerifyOnlyChassisPsuInfo(bool allPassed, ChassisInfoResponse chassisInfo)
        {
            try
            {
                allPassed &= ChassisManagerTestHelper.IsTrue(chassisInfo != null, "Received chasssis information ");
                if (chassisInfo.completionCode != CompletionCode.Success)
                {
                    CmTestLog.Failure("Failed to get chassis info");
                    return false;
                }
                CmTestLog.Success("Successfully get chassis info");

                allPassed = VerifyChassisPsuInfo(allPassed, chassisInfo);
                allPassed &= ChassisManagerTestHelper.IsTrue(chassisInfo.bladeCollections.Count == 0, "Blade information is empty");
                allPassed &= ChassisManagerTestHelper.IsTrue(chassisInfo.batteryCollections.Count == 0, "Battery information is empty");
                allPassed &= ChassisManagerTestHelper.IsTrue(chassisInfo.chassisController == null, "Chassis controller information is empty");
            }
            catch (Exception ex)
            {
                ChassisManagerTestHelper.IsTrue(false, ex.Message);
                allPassed = false;
            }

            return allPassed;
        }
예제 #12
0
        /// <summary>
        /// Verify chassis blade info
        /// </summary>
        /// <param name="allPassed">Flag indicating success/failure</param>
        /// <param name="chassisInfo">Chassis info response</param>
        /// <returns>returns success/failure</returns>
        private bool VerifyChassisBladeInfo(bool allPassed, ChassisInfoResponse chassisInfo)
        {
            CmTestLog.Info("Verifying blade info");
            allPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.Population, chassisInfo.bladeCollections.Count, "Verified the number of blades in the chassis");

            foreach (var bladeInfo in chassisInfo.bladeCollections)
            {
                allPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, bladeInfo.completionCode, string.Format("Blade #{0} returns success", bladeInfo.bladeNumber));
            }
            return allPassed;
        }
예제 #13
0
        /// <summary>
        /// Verify chassis PSU info
        /// </summary>
        /// <param name="allPassed">Flag indicating success/failure</param>
        /// <param name="chassisInfo">Chassis info response</param>
        /// <returns>returns success/failure</returns>
        private static bool VerifyChassisPsuInfo(bool allPassed, ChassisInfoResponse chassisInfo)
        {
            CmTestLog.Info("Verifying PSU info");
            allPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.NumPsus, chassisInfo.psuCollections.Count, "Verified the number of PSUs is correct");

            foreach (var psu in chassisInfo.psuCollections)
            {
                allPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, psu.completionCode, string.Format("PSU #{0} returns success", psu.id));
                allPassed &= ChassisManagerTestHelper.AreEqual(PowerState.ON, psu.state, string.Format("PSU #{0} is ON", psu.id));
            }
            return allPassed;
        }
예제 #14
0
        /// <summary>
        /// Verify chassis controller info
        /// </summary>
        /// <param name="allPassed">Flag indicating success/failure</param>
        /// <param name="chassisInfo">Chassis info response</param>
        /// <returns>returns success/failure</returns>
        private static bool VerifyChassisControllerInfo(bool allPassed, ChassisInfoResponse chassisInfo)
        {
            CmTestLog.Info("Verifying chassis controller info");

            allPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, chassisInfo.chassisController.completionCode, "Chassis controller returns success");
            return allPassed;
        }
예제 #15
0
        public TestsResultResponse CheckChassisInfo(string SKUXMLFile = "Default")
        {
            ChassisInfoResponse chassisInfo = new ChassisInfoResponse();
            string failureMessage = string.Empty;

            Console.WriteLine("\n!!!!!!!!! Starting execution of CheckChassisInfo tests.");
            chassisInfo = this.Channel.GetChassisInfo(true, true, true, true);
            if (chassisInfo.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed to get all chassis components information";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }

            chassisInfo = this.Channel.GetChassisInfo(true, false, false, false);
            if (chassisInfo.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed to get chassis information when asking for only blade information";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }
            chassisInfo = this.Channel.GetChassisInfo(true, true, false, false);
            if (chassisInfo.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed to get chassis information when excluding Chassis controller info";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }
            chassisInfo = this.Channel.GetChassisInfo(true, false, true, false);
            if (chassisInfo.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed to get chassis information when excluding PSU info";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }
            chassisInfo = this.Channel.GetChassisInfo(false, true, true, false);
            if (chassisInfo.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed to get chassis information when excluding Blades info";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }
            chassisInfo = this.Channel.GetChassisInfo(false, true, false, false);
            if (chassisInfo.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed to get chassis information when including only PSU info.";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }
            chassisInfo = this.Channel.GetChassisInfo(false, false, true, false);
            if (chassisInfo.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed to get chassis information when asking only for Chassis controller info";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }

            chassisInfo = this.Channel.GetChassisInfo(false, false, false, false);
            if (chassisInfo.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed to get chassis information when excluding all info";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }
            chassisInfo = this.Channel.GetChassisInfo(false, false, false, true);
            if (chassisInfo.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed to get chassis information when asking only for Batteries info";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }
            Console.WriteLine("\n++++++++++++++++++++++++++++++++");
            failureMessage = "\n!!!!!!!!! Successfully finished execution of CheckChassisInfo tests";
            Console.WriteLine(failureMessage);
            return new TestsResultResponse(ExecutionResult.Passed, failureMessage);
        }
        /// <summary>
        /// Verify chassis controller info
        /// </summary>
        /// <param name="allPassed">Flag indicating success/failure</param>
        /// <param name="chassisInfo">Chassis info response</param>
        /// <returns>returns success/failure</returns>
        private static TestResponse VerifyChassisControllerInfo(ChassisInfoResponse chassisInfo)
        {
            TestResponse response = new TestResponse();

            CmTestLog.Info("Verifying chassis controller info");

            if (!ChassisManagerTestHelper.AreEqual(CompletionCode.Success, chassisInfo.chassisController.completionCode, "Chassis controller returns success"))
            {
                response.Result = false;
                response.ResultDescription.Append("\n Verify Chassis controller info failed with completion code: " + chassisInfo.chassisController.completionCode);
             }
            return response;
        }
        /// <summary>
        /// Get Chassis Information
        /// </summary>
        /// <param name="bladeInfo">Set to True to get blade info </param>
        /// <param name="psuInfo">Set to True to get PSU info</param>
        /// <param name="chassisControllerInfo">Set to True to get chassis controller info</param>
        /// <param name="batteryInfo">Set to True to get battery info</param>
        /// <returns>Response packet for Chassis Info</returns>
        public ChassisInfoResponse GetChassisInfo(bool bladeInfo, bool psuInfo, bool chassisControllerInfo, bool batteryInfo)
        {
            byte MaxbladeCount = (byte)ConfigLoaded.Population;

            Tracer.WriteInfo("Received GetChassisInfo bladeInfo = {0}, psuInfo = {1}, chassisControllerInfo = {2})", bladeInfo, psuInfo, chassisControllerInfo);
            Tracer.WriteInfo("                        batteryInfo = {0}", batteryInfo);
            Tracer.WriteUserLog("Received GetChassisInfo bladeInfo = {0}, psuInfo = {1}, chassisControllerInfo = {2})", bladeInfo, psuInfo, chassisControllerInfo);
            Tracer.WriteUserLog("                        batteryInfo = {0}", batteryInfo);

            // Check for the scenario where none of the params are specified or where all params are set to false
            // return everything in that case.
            if (bladeInfo == false && psuInfo == false && chassisControllerInfo == false && batteryInfo == false)
            {
                bladeInfo = true;
                psuInfo = true;
                chassisControllerInfo = true;
                batteryInfo = true;
            }

            // Server side class structure to populate blade, psu and battery information
            ChassisInfoResponse cip = new ChassisInfoResponse();
            cip.completionCode = Contracts.CompletionCode.Unknown;
            cip.statusDescription = String.Empty;

            // Initialize to empty collections to begin with
            cip.bladeCollections = new List<BladeInfo>();
            cip.chassisController = null;

            if (bladeInfo)
            {
                // Loop to populate blade information for requested number of blades
                for (int loop = 1; loop <= MaxbladeCount; loop++)
                {
                    try
                    {
                        BladeInfo bladeInstance = new BladeInfo();
                        bladeInstance.bladeNumber = loop;

                        // initialize completion code to unknown to start with
                        bladeInstance.completionCode = Contracts.CompletionCode.Unknown;

                        BladeStateResponse bladeResponse = new BladeStateResponse();
                        Tracer.WriteInfo("Calling Get blade active power state");
                        bladeResponse = GetBladeState(loop);

                        bladeInstance.completionCode = bladeResponse.completionCode;

                        // Even if one succeeds, we set the function completion code to success
                        if (bladeInstance.completionCode == Contracts.CompletionCode.Success)
                        {
                            cip.completionCode = Contracts.CompletionCode.Success;
                        }
                        else if (bladeInstance.completionCode == Contracts.CompletionCode.FirmwareDecompressing)
                        {
                            cip.completionCode = Contracts.CompletionCode.FirmwareDecompressing;
                            cip.statusDescription = "Blade firmware is decompressing. Data could not be retrieved, for one or more blades";
                        }
                        else
                        {
                            // If not already set to success, set to failure, because something actually failed here
                            if (cip.completionCode != Contracts.CompletionCode.Success)
                            {
                                cip.completionCode = Contracts.CompletionCode.Failure;
                                cip.statusDescription = "Blade info could not be retrieved, for one or more blades";
                            }
                        }

                        Contracts.PowerState powerResponse = bladeResponse.bladeState;
                        Tracer.WriteInfo("powerResponse received");

                        // Get Blade Power State
                        if (powerResponse == PowerState.ON)
                        {
                            bladeInstance.powerState = PowerState.ON;
                        }
                        else if (powerResponse == PowerState.OFF)
                        {
                            bladeInstance.powerState = PowerState.OFF;
                        }
                        else
                        {
                            bladeInstance.powerState = PowerState.NA;
                        }

                        if (bladeInstance.completionCode == Contracts.CompletionCode.Success)
                        {
                            // Get GUID, force session logon if session timed out.
                            Ipmi.DeviceGuid devGuid = WcsBladeFacade.GetSystemGuid((byte)loop, true);

                            if (devGuid.CompletionCode == (byte)CompletionCode.Success)
                            {
                                bladeInstance.bladeGuid = devGuid.Guid;
                                cip.completionCode = Contracts.CompletionCode.Success;
                            }
                            else
                            {
                                Tracer.WriteWarning("GetSystemGuid failed with Completion Code {0}", devGuid.CompletionCode);
                                bladeInstance.bladeGuid = System.Guid.Empty;

                                // If completion code not already set to success, set to failure, because something actually failed here
                                if (cip.completionCode != Contracts.CompletionCode.Success)
                                {
                                    cip.completionCode = Contracts.CompletionCode.Failure;
                                    cip.statusDescription = "Blade info could not be retrieved, for one or more blades";
                                }
                            }

                            // Any success is sufficient for this function, so only if we did not succeed, we set new value to completionCode
                            if (bladeInstance.completionCode != Contracts.CompletionCode.Success)
                            {
                                bladeInstance.completionCode =
                                        ChassisManagerUtil.GetContractsCompletionCodeMapping(devGuid.CompletionCode);
                            }

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

                            for (byte i = 0; i < ConfigLoaded.NumNicsPerBlade; i++)
                            {
                                Ipmi.NicInfo ipmiNicInfo = WcsBladeFacade.GetNicInfo((byte)loop, (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, loop, ipmiNicInfo.CompletionCode);
                                }
                                Contracts.NicInfo nicInfo = GetNicInfoObject(ipmiNicInfo);
                                bladeInstance.bladeMacAddress.Add(nicInfo);
                            }

                        }
                        else
                        {
                            bladeInstance.bladeGuid = System.Guid.Empty;

                            // BMC Mac address should be added as a list
                            bladeInstance.bladeMacAddress = new List<NicInfo>();
                            Ipmi.NicInfo ipmiNicInfo = new Ipmi.NicInfo((byte)CompletionCode.FirmwareDecompressing);
                            Contracts.NicInfo nicInfo = GetNicInfoObject(ipmiNicInfo);
                            bladeInstance.bladeMacAddress.Add(nicInfo);
                        }

                        // bladename is BladeId
                        bladeInstance.bladeName = String.Concat("BLADE", loop);

                        // Add blade to list
                        cip.bladeCollections.Add(bladeInstance);

                    }
                    catch (Exception ex)
                    {
                        Tracer.WriteUserLog("GetChassisInfo (Blade portion) failed for blade {0} with exception: {1}", loop, ex.Message);
                        cip.completionCode = Contracts.CompletionCode.Failure;
                        cip.statusDescription = String.Format("GetChassisInfo (Blade portion) failed for blade {0} with exception: {1}", loop, ex.Message);
                    }
                }
            }

            if (psuInfo)
            {
                // Get the PSU Info.
                cip.psuCollections = GetPsuInfo();

                // if the master object is not successful, check child objects
                if (cip.completionCode != Contracts.CompletionCode.Success)
                {
                    // if Psu status received any positive results, return success.
                    foreach (PsuInfo psu in cip.psuCollections)
                    {
                        // if any children are successful, set master to success.
                        if (psu.completionCode == Contracts.CompletionCode.Success)
                        {
                            cip.completionCode = Contracts.CompletionCode.Success;
                            break; // once a match has been found escape foreach
                        }
                    }

                    // if master completion code is still unknown, replace with failure.
                    if (cip.completionCode == Contracts.CompletionCode.Unknown)
                    {
                        if (ConfigLoaded.NumPsus > 0)
                            cip.completionCode = Contracts.CompletionCode.Failure;
                        else
                        {
                            cip.completionCode = Contracts.CompletionCode.Success;
                            cip.statusDescription += "\nPower Supply monitoring not supported in sku configuration.";
                        }
                    }
                }
            }

            if (batteryInfo)
            {
                // Get the battery info
                cip.batteryCollections = GetBatteryInfo();

                // if the master object is not successful, check child objects
                if (cip.completionCode != Contracts.CompletionCode.Success)
                {
                    // if battery status received any positive results, return success.
                    foreach (BatteryInfo battery in cip.batteryCollections)
                    {
                        // if any children are successful, set master to success.
                        if (battery.completionCode == Contracts.CompletionCode.Success)
                        {
                            cip.completionCode = Contracts.CompletionCode.Success;
                            break; // once a match has been found escape foreach
                        }
                    }

                    // if master completion code is still unknown, replace with failure.
                    if (cip.completionCode == Contracts.CompletionCode.Unknown)
                    {
                        if (ConfigLoaded.NumBatteries > 0)
                            cip.completionCode = Contracts.CompletionCode.Failure;
                        else
                        {
                            cip.completionCode = Contracts.CompletionCode.Success;
                            cip.statusDescription += "\nBattery monitoring not supported in sku configuration.";
                        }
                    }
                }
            }

            // Chassis Info should be read by reading the Fru device
            if (chassisControllerInfo)
            {
                try
                {
                    //Populate chassis controller data
                    cip.chassisController = new ChassisControllerInfo();
                    ServiceVersionResponse version = GetServiceVersion();

                    if (version.completionCode == Contracts.CompletionCode.Success)
                    {
                        cip.chassisController.softwareVersion = version.serviceVersion;
                    }
                    else
                    {
                        cip.chassisController.softwareVersion = string.Format("Unable to obtain: Completion Code: {0}.", version.completionCode);
                    }

                    // get chassis network properties
                    cip.chassisController.networkProperties = new ChassisNetworkPropertiesResponse();
                    cip.chassisController.networkProperties = GetChassisNetworkProperties();
                    // Populate chassis IP address
                    if (cip.chassisController.networkProperties != null)
                    {
                        cip.chassisController.completionCode = Contracts.CompletionCode.Success;
                        cip.completionCode = Contracts.CompletionCode.Success;
                    }
                    else
                    {
                        Tracer.WriteInfo("GetChassisInfo - failed to get chassis network properties");
                        if (cip.chassisController.completionCode != Contracts.CompletionCode.Success)
                        {
                            cip.chassisController.completionCode = Contracts.CompletionCode.Failure;
                            cip.chassisController.statusDescription = String.Format("GetChassisInfo - failed to get chassis network properties");
                        }
                        if (cip.completionCode != Contracts.CompletionCode.Success)
                        {
                            cip.completionCode = Contracts.CompletionCode.Failure;
                            cip.statusDescription = "Failed to get chassis information";
                        }
                    }

                    cip.chassisController.systemUptime = (DateTime.Now - Process.GetCurrentProcess().StartTime).ToString();

                    // Default Chassis details before reading FRU later
                    cip.chassisController.firmwareVersion = "NA";
                    cip.chassisController.hardwareVersion = "NA";
                    cip.chassisController.serialNumber = "NA";
                    cip.chassisController.assetTag = "NA";

                    Ipmi.FruDevice fruDevice = ChassisState.CmFruData.ReadFru(DeviceType.ChassisFruEeprom);

                    if (fruDevice.CompletionCode == (byte)CompletionCode.Success)
                    {
                        cip.chassisController.completionCode = Contracts.CompletionCode.Success;
                        cip.completionCode = Contracts.CompletionCode.Success;

                        cip.chassisController.firmwareVersion = fruDevice.ProductInfo.ProductVersion.ToString();
                        cip.chassisController.hardwareVersion = fruDevice.ProductInfo.Version.ToString();
                        cip.chassisController.serialNumber = fruDevice.ProductInfo.SerialNumber.ToString();
                        cip.chassisController.assetTag = fruDevice.ProductInfo.AssetTag.ToString();
                    }
                    else
                    {
                        Tracer.WriteWarning("CM Fru Read failed with completion code: {0:X}", fruDevice.CompletionCode);
                        if (cip.chassisController.completionCode != Contracts.CompletionCode.Success)
                        {
                            cip.chassisController.completionCode = Contracts.CompletionCode.Failure;
                            cip.chassisController.statusDescription =
                                String.Format("CM Fru Read failed with completion code: {0:X}", fruDevice.CompletionCode);
                        }
                        if (cip.completionCode != Contracts.CompletionCode.Success)
                        {
                            cip.completionCode = Contracts.CompletionCode.Failure;
                            cip.statusDescription = "Failed to get chassis information";
                        }
                    }
                }
                catch (Exception ex)
                {
                    Tracer.WriteUserLog(" GetChassisInfo failed with exception: " + ex.Message);
                    if (cip.completionCode != Contracts.CompletionCode.Success)
                    {
                        cip.completionCode = Contracts.CompletionCode.Failure;
                        cip.statusDescription = String.Format(" GetChassisInfo failed with exception: " + ex.Message);
                    }
                }
            }

            Tracer.WriteInfo("Return: GetChassisInfo returned, Number of Blades: {0}, Number of PSUs: {1}", cip.bladeCollections.Count(),
                cip.psuCollections.Count());

            return cip;
        }
예제 #18
0
        /// <summary>
        /// Test GetChassisInfo for all possible parameters
        /// </summary>
        /// <returns>True if all check-points pass; false, otherwise.</returns>
        public bool GetChassisInfoTest()
        {
            CmTestLog.Start();
            bool allPassed = true;

            this.EmptyLocations = this.GetEmptyLocations();
            this.JbodLocations = this.GetJbodLocations();

            try
            {
                ChassisInfoResponse chassisInfo = new ChassisInfoResponse();

                // Test GetChassisInfo, get all information
                CmTestLog.Info("Verifying chassis information when all params are true");
                chassisInfo = this.Channel.GetChassisInfo(true, true, true, true);
                allPassed = this.VerifyChassisInfo(allPassed, chassisInfo);
                CmTestLog.Info("Finished verification of GetchassisInfo when all information was returned blade, PSU, battery and chassis controller \n");

                // Test GetChassisInfo with no params
                CmTestLog.Info("Verifying chassis information when all params are false OR no Params");
                chassisInfo = this.Channel.GetChassisInfo(false, false, false, false);
                allPassed = this.VerifyChassisInfo(allPassed, chassisInfo);
                CmTestLog.Info("Finished verification of GetchassisInfo with no params \n");

                // Test for GetChassisInfo with only blade info
                CmTestLog.Info("Verifying chassis information for only Blade, bladeInfo param is true");
                chassisInfo = this.Channel.GetChassisInfo(true, false, false, false);
                allPassed = this.VerifyOnlyChassisBladeInfo(allPassed, chassisInfo);
                CmTestLog.Info("Finished verification of GetchassisInfo for only Blade information \n");

                // Test for GetChassisInfo for only PSU information
                CmTestLog.Info("Verifying chassis information for only psuInfo param is true");
                chassisInfo = this.Channel.GetChassisInfo(false, true, false, false);
                allPassed = this.VerifyOnlyChassisPsuInfo(allPassed, chassisInfo);
                CmTestLog.Info("Finished verification of GetChassisInfo for only PSU information \n");

                // Test for GetChassisInfo for only Battery information
                CmTestLog.Info("Verifying chassis information for only batteryInfo param is true");
                chassisInfo = this.Channel.GetChassisInfo(false, false, false, true);
                allPassed = this.VerifyOnlyChassisBatteryInfo(allPassed, chassisInfo);
                CmTestLog.Info("Finished verification of GetChassisInfo for only battery information \n");

                // Test for GetChassisInfo for only chassis controller information
                CmTestLog.Info("Verifying chassis information for only chassisControllerInfo param is true");
                chassisInfo = this.Channel.GetChassisInfo(false, false, true, false);
                allPassed = this.VerifyOnlyChassisControllerInfo(allPassed, chassisInfo);
                CmTestLog.Info("Finished verification of GetChassisInfo for only chassis controller information \n");
            }
            catch (Exception ex)
            {
                ChassisManagerTestHelper.IsTrue(false, ex.Message);
                allPassed = false;
            }

            CmTestLog.End(allPassed);
            return allPassed;
        }