internal static bool ValidateResponse(string message, ChassisResponse response, bool echoSuccess = true)
        {
            if (response == null)
            {
                Console.WriteLine(WcsCliConstants.serviceResponseEmpty);
                return false;
            }

            if (response.completionCode == Contracts.CompletionCode.Success)
            {
                if (echoSuccess)
                {
                    Console.WriteLine(WcsCliConstants.commandSuccess + " " + (string.IsNullOrEmpty(message) ? WcsCliConstants.commandComplete: message));
                }
                return true;
            }

            if (response.completionCode == Contracts.CompletionCode.Failure)
            {
                Console.WriteLine(WcsCliConstants.commandFailure);
                return false;
            }
            else if (response.completionCode == Contracts.CompletionCode.Timeout)
            {
                Console.WriteLine(WcsCliConstants.commandTimeout);
                return false;
            }
            else if (response.completionCode == Contracts.CompletionCode.SerialSessionActive)
            {
                Console.WriteLine(WcsCliConstants.commandSerialSessionActive);
                return false;
            }
            else if (response.completionCode == Contracts.CompletionCode.UserNotFound)
            {
                Console.WriteLine(WcsCliConstants.commandUserNotFound);
                return false;
            }
            else if (response.completionCode == Contracts.CompletionCode.UserPasswordDoesNotMeetRequirement)
            {
                Console.WriteLine(WcsCliConstants.commandUserPwdDoesNotMeetReq);
                return false;
            }
            else if (response.completionCode == Contracts.CompletionCode.FirmwareDecompressing)
            {
                Console.WriteLine(WcsCliConstants.decompressing + (string.IsNullOrEmpty(response.statusDescription) ? WcsCliConstants.defaultTimeout: response.statusDescription));
                return false;
            }
            else
            {
                Console.WriteLine(WcsCliConstants.commandFailure + string.Format(" Completion Code: {0}", response.completionCode));
                return false;
            }
        }
        internal static bool ValidateBladeResponse(int bladeId, string message, ChassisResponse response, bool echoSuccess = true)
        {
            if (response == null)
            {
                Console.WriteLine(WcsCliConstants.serviceResponseEmpty);
                return false;
            }

            if (response.completionCode == Contracts.CompletionCode.Success)
            {
                if (echoSuccess)
                {
                    Console.WriteLine(WcsCliConstants.commandSuccess + " Blade " + bladeId + ": " + (string.IsNullOrEmpty(message) ? WcsCliConstants.commandComplete: message));
                }
                return true;
            }
            else if (response.completionCode == Contracts.CompletionCode.Unknown)
            {
                Console.WriteLine(WcsCliConstants.bladeStateUnknown + " Blade " + bladeId);
                return false;
            }
            else if (response.completionCode == Contracts.CompletionCode.Failure)
            {
                Console.WriteLine(WcsCliConstants.commandFailure + " Blade " + bladeId + ": " + response.completionCode.ToString());
                return false;
            }
            else if (response.completionCode == Contracts.CompletionCode.FirmwareDecompressing)
            {
                Console.WriteLine(WcsCliConstants.decompressing + " Blade " + bladeId + ": " + (string.IsNullOrEmpty(response.statusDescription) ? WcsCliConstants.defaultTimeout: response.statusDescription));
                return false;
            }
            else
            {
                Console.WriteLine(WcsCliConstants.commandFailure + string.Format(" Blade {0}: Completion Code: {1}", bladeId, response.completionCode));
                return false;
            }
        }
        private TestResponse ParameterOutOfRangePsuIdUpdatePsuFirmware()
        {
            TestCase testCase = new TestCase("ParameterOutOfRangePsuIdUpdatePsuFirmware", 22773);

            CmTestLog.Info(string.Format(
                "\n !!!!!!Verifying {0} Returns ParameterOutOfRange for Invalid PsuId. WorkItemId: {1}!!!!!!",
                this.currentApi, testCase.WorkItemId));
            TestResponse response = new TestResponse();

            ChassisResponse updatePsuFwResponse = new ChassisResponse();
            this.TestChannelContext = this.ListTestChannelContexts[(int)WCSSecurityRole.WcsCmAdmin];
            string fwFilePath = lesPsusInChassis == "1" ? priLesFwFilePath : priNonLesFwFilePath;

            foreach (int invalidValue in Enum.GetValues(typeof(InvalidPsuId)))
            {
                updatePsuFwResponse = this.TestChannelContext.UpdatePSUFirmware(invalidValue, fwFilePath, primaryImage);
                LogMessage.Message = string.Format(
                        "{0}: Command returns completion code {1} for invalid Psu Id {2}",
                        this.currentApi, updatePsuFwResponse.completionCode, invalidValue);

                if (updatePsuFwResponse.completionCode != CompletionCode.ParameterOutOfRange)
                    LogMessage.Log(LogMessage.MessageType.Failure, ref response);
                else
                    LogMessage.Log(LogMessage.MessageType.Success, ref response);
            }

            testCase.LogPassOrFail(ref response, currentApi);
            return response;
        }
 public UpdatePsu(int idx, string fwFilePath, bool priImage)
 {
     psuFwStatus = new PsuFirmwareStatus();
     psuFwUpdateResponse = new ChassisResponse();
     psuFwFilePath = fwFilePath;
     primaryImage = priImage;
     passed = true;
     primaryUpdateSuccessCount = 0;
     secondaryUpdateSuccessCount = 0;
     index = idx;
 }
 public UpdatePsu(int idx)
 {
     psuFwStatus = new PsuFirmwareStatus();
     psuFwUpdateResponse = new ChassisResponse();
     psuFwFilePath = string.Empty;
     primaryImage = false;
     passed = true;
     primaryUpdateSuccessCount = 0;
     secondaryUpdateSuccessCount = 0;
     index = idx;
 }
        //Test AddChassisControllerUser
        public TestsResultResponse AddChassisControllerUserTest()
        {
            Console.WriteLine("\n!!!!!!!!!! Starting execution of AddChassisControllerUserTest");

            string failureMessage = string.Empty;
            ChassisResponse response = new ChassisResponse();

            string adminUserName = "******";
            string operatorUserName = "******";
            string userName = "******";

            string adminPass1 = "AdminPass1";
            string adminPass2 = "AdminPass2";
            string operatorPass1 = "OperatorPass1";
            string operatorPass2 = "OperatorPass2";
            string userPass1 = "UserPass1";
            string userPass2 = "UserPass2";

            WCSSecurityRole adminRole = WCSSecurityRole.WcsCmAdmin;
            WCSSecurityRole operatorRole = WCSSecurityRole.WcsCmOperator;
            WCSSecurityRole userRole = WCSSecurityRole.WcsCmUser;

            //Remove user Doesn't exist
            response = this.Channel.RemoveChassisControllerUser(adminUserName);
            if (response.completionCode != CompletionCode.UserNotFound || !response.statusDescription.Equals("User not found"))
            {
                failureMessage = "\n!!!Failed when removing a non existant user";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }

            //Change user Password and role when user doesn't exist
            response = this.Channel.ChangeChassisControllerUserPassword(adminUserName, adminPass1);
            if (response.completionCode != CompletionCode.UserNotFound || !response.statusDescription.Equals("User not found"))
            {
                failureMessage = "\n!!!Failed when changing password for a non existant user";

                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }

            response = this.Channel.ChangeChassisControllerUserRole(adminUserName, adminRole);
            if (response.completionCode != CompletionCode.UserNotFound || !response.statusDescription.Equals("User name provided cannot be found"))
            {
                failureMessage = "\n!!!Failed when changing user role of a non existant user";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }

            //Add different users
            response = this.Channel.AddChassisControllerUser(adminUserName, adminPass1, adminRole);
            if (response.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed when adding an admin user.";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }

            response = this.Channel.AddChassisControllerUser(operatorUserName, operatorPass1, operatorRole);
            if (response.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed when adding a an Operator user.";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }
            response = this.Channel.AddChassisControllerUser(userName, userPass1, userRole);
            if (response.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed when adding a an new user.";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }
            //Change user passwords
            response = this.Channel.ChangeChassisControllerUserPassword(adminUserName, adminPass2);
            if (response.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed when changing Admin password.";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }

            response = this.Channel.ChangeChassisControllerUserPassword(operatorUserName, operatorPass2);
            if (response.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed when changing Operator password.";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }

            response = this.Channel.ChangeChassisControllerUserPassword(userName, userPass2);
            if (response.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed when changing User password.";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }

            //Change user roles
            response = this.Channel.ChangeChassisControllerUserRole(adminUserName, userRole);
            if (response.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed when changing User Role.";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }

            response = this.Channel.ChangeChassisControllerUserRole(operatorUserName, adminRole);
            if (response.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed when changing User Role.";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }

            response = this.Channel.ChangeChassisControllerUserRole(userName, operatorRole);
            if (response.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed when changing User Role.";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }

            //Remove all users
            response = this.Channel.RemoveChassisControllerUser(adminUserName);
            if (response.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed when removing Admin user.";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }

            response = this.Channel.RemoveChassisControllerUser(operatorUserName);
            if (response.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed when removing Operator user.";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }

            response = this.Channel.RemoveChassisControllerUser(userName);
            if (response.completionCode != CompletionCode.Success)
            {
                failureMessage = "\n!!!Failed when removing a user.";
                Console.WriteLine(failureMessage);
                return new TestsResultResponse(ExecutionResult.Failed, failureMessage);
            }

            Console.WriteLine("\n++++++++++++++++++++++++++++++++");
            failureMessage = "\n!!!!!!!!! Successfully finished execution of ChassisControllerUser tests.............";
            Console.WriteLine(failureMessage);
            return new TestsResultResponse(ExecutionResult.Passed, failureMessage);
        }
        /// <summary>
        ///     ChangeChassisControllerUserRole: Verify only users from WcsCmAdmin are able to execute the command
        ///     Prerequisites (tools/hw/sw needed)
        ///     =========================
        ///     1- Chassis Manager Service is installed and running on the target CM under test.
        ///     2- Can use internet explorer from the CM or from a remote machine able to communicate with the CM through the
        ///     network. If SSL is enabled on the test CM use https instead of what is shown here.
        ///     Setup instructions
        ///     ===================
        ///     1- Login and ensure the the CM under test does not have a user named testUser for this test.
        ///     2- Ensure that the CM under test has a user named WcsAdmin added to group WcsCmAdmin for this test
        ///     3- Ensure that the CM under test has a user named WcsOperator added to group WcsCmOperator for this test
        ///     4- Ensure that the CM under test has a user named WcsUser added to group WcsCmUser for this test
        ///     5- Ensure <aValidPassword> and <aDifferentValidPassword> conform to the Windows user complexity requirements.
        /// </summary>
        /// <returns>True, iff WcsCMAdmin group user can execute this command. Otherwise false.</returns>
        protected bool ChangeChassisControllerUserRolebyAdminTest()
        {
            CmTestLog.Start();
            bool testPassed = true;

            const string TestCaseUser = "******";

            var restRspnsRslt = new ChassisResponse();

            try
            {
                //Create TestUsers that change password
                restRspnsRslt = this.Channel.AddChassisControllerUser(TestCaseUser, this.defaultAdminPassword,
                    WCSSecurityRole.WcsCmUser);

                if (restRspnsRslt.completionCode != CompletionCode.Success &&
                    restRspnsRslt.completionCode == CompletionCode.UserAccountExists)
                {
                    // Reset user
                    this.Channel.RemoveChassisControllerUser(TestCaseUser);

                    this.Channel.AddChassisControllerUser(TestCaseUser, this.defaultAdminPassword, WCSSecurityRole.WcsCmUser);
                }

                // Run the test
                foreach (WCSSecurityRole roleId in Enum.GetValues(typeof (WCSSecurityRole)))
                {
                    // Use different user contect WcsCM group role and send Rest request to update password
                    this.TestChannelContext = this.ListTestChannelContexts[(int)roleId];

                    try
                    {
                        // Try to Change to different Role
                        foreach (WCSSecurityRole groupID in Enum.GetValues(typeof (WCSSecurityRole)))
                        {
                            //Try to change WcsRole
                            restRspnsRslt = this.TestChannelContext.ChangeChassisControllerUserRole(TestCaseUser, groupID);

                            // Only WcsCMAdmin can change the password
                            if ((restRspnsRslt.completionCode == CompletionCode.Success) &&
                                (roleId != WCSSecurityRole.WcsCmAdmin))
                            {
                                // Functional validation failed
                                CmTestLog.Failure("Test case change role by WcsAdmin Validation Failed.");
                                testPassed = false;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        // Check error is due to permission HTTP 401 unauthorize
                        if (!e.Message.Contains("401"))
                        {
                            // Test failed, http response should contain http 401 error
                            CmTestLog.Failure("We are expecting 401 error, but we received 400 instead.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ChassisManagerTestHelper.IsTrue(false, ex.Message);
                testPassed = false;
            }

            // Clean up Test user
            this.Channel.RemoveChassisControllerUser(TestCaseUser);

            // end of the test
            CmTestLog.End(testPassed);
            return testPassed;
        }
        /// <summary>
        ///     ChangeChassisControllerUserPassword: Verify completion code UserPasswordDoesNotMeetRequirement if password not
        ///     valid
        ///     Prerequisites (tools/hw/sw needed)
        ///     =========================
        ///     1- Chassis Manager Service is installed and running on the target CM under test.
        ///     2- Can use internet explorer from the CM or from a remote machine able to communicate with the CM through the
        ///     network. If SSL is enabled on the test CM use https instead of what is shown here.
        ///     Setup instructions
        ///     ===================
        ///     1- Login and ensure the the CM under test does not have a user named testUser for this test.
        ///     2- Ensure that the CM under test has a user named WcsAdmin added to group WcsCmAdmin for this test
        ///     3- Ensure that the CM under test has a user named WcsOperator added to group WcsCmOperator for this test
        ///     4- Ensure that the CM under test has a user named WcsUser added to group WcsCmUser for this test
        ///     5- Ensure <aValidPassword> and <aDifferentValidPassword> conform to the Windows user complexity requirements.
        /// </summary>
        /// <returns>True, iff User password meet requirement to update password. Otherwise false.</returns>
        protected bool ChangeChassisControllerUserPasswordReqTest()
        {
            CmTestLog.Start();
            bool testPassed = true;

            try
            {
                const string TestCaseUser = "******";

                var restRspnsRslt = new ChassisResponse();

                //Create TestcaseUsers that change password
                restRspnsRslt = this.Channel.AddChassisControllerUser(TestCaseUser, this.defaultAdminPassword,
                    WCSSecurityRole.WcsCmUser);

                if (restRspnsRslt.completionCode != CompletionCode.Success &&
                    restRspnsRslt.completionCode == CompletionCode.UserAccountExists)
                {
                    // Reset test case user
                    this.Channel.RemoveChassisControllerUser(TestCaseUser);
                    //Create TestcaseUsers that change password
                    restRspnsRslt = this.Channel.AddChassisControllerUser(TestCaseUser, this.defaultAdminPassword,
                        WCSSecurityRole.WcsCmUser);
                }

                // Try to change password
                try
                {
                    //Test Case, update user password using admin channel
                    restRspnsRslt = this.Channel.ChangeChassisControllerUserPassword(TestCaseUser, this.defaultAdminPassword);
                    if (restRspnsRslt.completionCode != CompletionCode.Success)
                    {
                        testPassed = false;
                    }

                    //This case must fail.
                    restRspnsRslt = this.Channel.ChangeChassisControllerUserPassword(TestCaseUser, string.Empty);
                    if (restRspnsRslt.completionCode == CompletionCode.Failure &&
                        restRspnsRslt.completionCode != CompletionCode.UserPasswordDoesNotMeetRequirement)
                    {
                        testPassed = false;
                    }
                }
                catch (Exception ex)
                {
                    ChassisManagerTestHelper.IsTrue(false, ex.Message);
                    testPassed = false;
                }

                // Cleanup Test
                this.Channel.RemoveChassisControllerUser(TestCaseUser);
            }
            catch (Exception ex)
            {
                ChassisManagerTestHelper.IsTrue(false, ex.Message);
                testPassed = false;
            }

            // end of the test
            CmTestLog.End(testPassed);
            return testPassed;
        }
        /// <summary>
        ///     AddChassisControllerUser: Verify only role names and corresponding integers can be used for role parameter
        ///     Prerequisites (tools/hw/sw needed)
        ///     =========================
        ///     1- Chassis Manager Service is installed and running on the target CM under test.
        ///     2- Can use internet explorer from the CM or from a remote machine able to communicate with the CM through the
        ///     network. If SSL is enabled on the test CM use https instead of what is shown here.
        ///     Setup instructions
        ///     ===================
        ///     1- Login and ensure the the CM under test does not have a user named testUser for this test.
        ///     2- Ensure that the CM under test has a user named WcsAdmin added to group WcsCmAdmin for this test
        ///     3- Ensure that the CM under test has a user named WcsOperator added to group WcsCmOperator for this test
        ///     4- Ensure that the CM under test has a user named WcsUser added to group WcsCmUser for this test
        ///     5- Ensure <aValidPassword> and <aDifferentValidPassword> conform to the Windows user complexity requirements.
        /// </summary>
        /// <returns></returns>
        protected bool AddChassisControllerValidateRolesTest()
        {
            CmTestLog.Start();
            bool testPassed = true;

            try
            {
                var restRspnsRslt = new ChassisResponse();

                const string TestCaseUser = "******";

                CmTestLog.Info("Starting set up Add Chassis Controller User ");
                CmTestLog.Info("Starting remove automation test users accounts");

                // Try to Add user with proper Role
                foreach (WCSSecurityRole roleId in Enum.GetValues(typeof (WCSSecurityRole)))
                {
                    try
                    {
                        restRspnsRslt = this.Channel.AddChassisControllerUser(TestCaseUser, this.defaultAdminPassword, roleId);
                        if (restRspnsRslt.completionCode != CompletionCode.Success)
                        {
                            testPassed = false;
                        }//test failed
                        else
                        {
                            this.Channel.RemoveChassisControllerUser(TestCaseUser);
                        }// Test passed remove test user
                    }
                    catch (Exception ex)
                    {
                        ChassisManagerTestHelper.IsTrue(false, ex.Message);
                        testPassed = false;
                    }
                }
            }
            catch (Exception ex)
            {
                ChassisManagerTestHelper.IsTrue(false, ex.Message);
                testPassed = false;
            }

            // end of the test
            CmTestLog.End(testPassed);
            return testPassed;
        }
        /// <summary>
        ///     Clean up test case user
        /// </summary>
        /// <returns></returns>
        private void ResetTestControlUser(string userName, bool deleteAll)
        {
            if (userName == null)
            {
                throw new ArgumentNullException("userName");
            }
            var restRspnsRslt = new ChassisResponse();

            // Create test dummy accounts to be removed
            foreach (WCSSecurityRole roleId in Enum.GetValues(typeof (WCSSecurityRole)))
            {
                try
                {
                    if (deleteAll)
                    {
                        this.Channel.RemoveChassisControllerUser(string.Format("{0}{1}", userName, (int)roleId));
                    }
                    else
                    {
                        // Use admin connection to add users
                        this.Channel.AddChassisControllerUser(string.Format("{0}{1}", userName, (int)roleId),
                            this.defaultAdminPassword, roleId);

                        if (restRspnsRslt.completionCode != CompletionCode.UserAccountExists)
                        {
                            // Reset users
                            this.Channel.RemoveChassisControllerUser(string.Format("{0}{1}", userName, (int)roleId));

                            restRspnsRslt =
                                this.Channel.AddChassisControllerUser(string.Format("{0}{1}", userName, (int)roleId),
                                    this.defaultAdminPassword, roleId);
                        }
                    }
                }
                catch
                {
                    // ignore error
                }
            }
        }
 private TestResponse VerifyStopSerialPortConsoleByUser(TestResponse response, WCSSecurityRole roleId, ChassisResponse stopResponse)
 {
     if (!(CompletionCode.NoActiveSerialSession == stopResponse.completionCode || CompletionCode.Success == stopResponse.completionCode) && (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
     {
         response.Result = false;
         response.ResultDescription.Append(string.Format("\nFailed to stop Port serial session with WcsAdmin/WcsOperator User {0}, completion code returned: {1} ", roleId, stopResponse.completionCode));
         return response;
     }
     else if ((CompletionCode.NoActiveSerialSession == stopResponse.completionCode || CompletionCode.Success == stopResponse.completionCode) && (roleId == WCSSecurityRole.WcsCmUser))
     {
         response.Result = false;
         response.ResultDescription.Append(string.Format("WcsUser is able to stop port serial session {0}", roleId, "completion code returned: {1} ", stopResponse.completionCode));
         return response;
     }
     else
     {
         response.Result &= ChassisManagerTestHelper.IsTrue((CompletionCode.NoActiveSerialSession == stopResponse.completionCode || CompletionCode.Success == stopResponse.completionCode),
             string.Format("Received success with user {0}", Enum.GetName(typeof(WCSSecurityRole), roleId)));
     }
     return response;
 }
 private TestResponse VerifySendPortSerialDataByUser(TestResponse response, WCSSecurityRole roleId, ChassisResponse sendPortSerialDataResponse)
 {
     if (!(CompletionCode.Success == sendPortSerialDataResponse.completionCode) && (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
     {
         response.Result = false;
         response.ResultDescription.Append(string.Format("\nFailed to send port serial data with WcsAdmin/WcsOperator User {0}, completion code returned: {1} ", roleId, sendPortSerialDataResponse.completionCode));
         CmTestLog.Failure(response.ResultDescription.ToString());
         return response;
     }
     else if ((CompletionCode.Success == sendPortSerialDataResponse.completionCode) && (roleId == WCSSecurityRole.WcsCmUser))
     {
         response.Result = false;
         response.ResultDescription.Append(string.Format("User is able to send port serial data {0}", roleId, "completion code returned: {1} ", sendPortSerialDataResponse.completionCode));
         CmTestLog.Failure(response.ResultDescription.ToString());
         return response;
     }
     else
     {
         response.Result &= ChassisManagerTestHelper.IsTrue(CompletionCode.Success == sendPortSerialDataResponse.completionCode,
             string.Format("Received success with user {0}", Enum.GetName(typeof(WCSSecurityRole), roleId)));
     }
     return response;
 }
        /// <summary>
        /// command specific implementation 
        /// </summary>
        internal override void commandImplementation()
        {
            ChassisResponse response = new ChassisResponse();
            dynamic psuId = null;
            dynamic fwFilepath = null;
            dynamic primaryImage = null;

            try
            {
                if (this.argVal.TryGetValue('i', out psuId) &&
                    this.argVal.TryGetValue('f', out fwFilepath) &&
                    this.argVal.TryGetValue('p', out primaryImage))
                {
                    if ((primaryImage == 0) || (primaryImage == 1))
                    {
                        bool isPrimaryImage = ((int)primaryImage == 0) ? false : true;
                        response = WcsCli2CmConnectionManager.channel.UpdatePSUFirmware((int)psuId, (string)fwFilepath, isPrimaryImage);
                    }
                    else
                    {
                        Console.WriteLine(WcsCliConstants.argsOutOfRange);
                        return;
                    }
                }
                else
                {
                    Console.WriteLine(WcsCliConstants.argsMissingString);
                }
            }
            catch (Exception ex)
            {
                SharedFunc.ExceptionOutput(ex);
                return;
            }

            string message = "Use wcscli -getpsufwstatus to check the status of the firmware update.";
            if (!ResponseValidation.ValidateResponse(message, response, true))
            {
                Console.WriteLine(response.statusDescription);
            }
        }
 /// <summary>
 /// This method displays error message based on the completion code returned by user.
 /// </summary>
 /// <param name="completionCode">API completion code</param>
 protected void printErrorMessage(Contracts.CompletionCode completionCode, ChassisResponse response)
 {
     if (completionCode == Contracts.CompletionCode.Failure)
     {
         Console.WriteLine(WcsCliConstants.commandFailure);
         return;
     }
     if (completionCode == Contracts.CompletionCode.Timeout)
     {
         Console.WriteLine(WcsCliConstants.commandTimeout);
         return;
     }
     if (completionCode == Contracts.CompletionCode.FirmwareDecompressing)
     {
         Console.WriteLine(WcsCliConstants.decompressing + (string.IsNullOrEmpty(response.statusDescription) ? WcsCliConstants.defaultTimeout : response.statusDescription));
         return;
     }
     if (completionCode != Contracts.CompletionCode.Success)
     {
         Console.WriteLine(WcsCliConstants.commandFailure + " Completion code: {0}", completionCode);
         return;
     }
 }
Example #15
0
        /// <summary>
        /// command specific implementation 
        /// </summary>
        internal override void commandImplementation()
        {
            ChassisResponse response = new ChassisResponse();
            dynamic psuId = null;
            dynamic fwFilepath = null;
            dynamic primaryImage = null;

            try
            {
                if (this.argVal.TryGetValue('i', out psuId) &&
                    this.argVal.TryGetValue('f', out fwFilepath) &&
                    this.argVal.TryGetValue('p', out primaryImage))
                {
                    bool isPrimaryImage = ((int)primaryImage == 0) ? false : true;
                    response = WcsCli2CmConnectionManager.channel.UpdatePSUFirmware((int)psuId, (string)fwFilepath, isPrimaryImage);
                }
                else
                {
                    Console.WriteLine(WcsCliConstants.argsMissingString);
                }
            }
            catch (Exception ex)
            {
                SharedFunc.ExceptionOutput(ex);
                return;
            }

            if (response == null)
            {
                Console.WriteLine(WcsCliConstants.serviceResponseEmpty);
                return;
            }

            if (response.completionCode == Contracts.CompletionCode.Success)
            {
                Console.WriteLine(WcsCliConstants.commandSuccess +
                    ". Use wcscli -getpsufwstatus to check the status of the firmware update.");
            }
            else
            {
                Console.WriteLine(WcsCliConstants.commandFailure + " Completion Code: {0}", response.completionCode);
            }
            Console.WriteLine();
        }
Example #16
0
        /// <summary>
        /// command specific implementation
        /// </summary>
        internal override void commandImplementation()
        {
            try
                {
                    ChassisResponse response = new ChassisResponse();

                    // Force termination of any active serial session. We cannot terminate only on a specific blade
                    // since we do not have the session token in the CLI.
                    response = WcsCli2CmConnectionManager.channel.StopBladeSerialSession(0, null, true);
                    CliSerialPort.ClearWindow();

                    ResponseValidation.ValidateResponse("StopBladeSerialSession completed successfully.", response, true);
                }
                catch (Exception ex)
                {
                    SharedFunc.ExceptionOutput(ex);
                    return;
                }
        }