Exemple #1
0
        /// <summary>
        /// Establish blade serial session over Serial
        /// </summary>
        private void EstablishBladeSerialSessionOverSerialClient()
        {
            // start the read on another thread.
            Thread receiver = new Thread(new ThreadStart(Receive));
            receiver.Start();

            // Read continually until activeRead signal escapes.
            while (SharedFunc.ActiveSerialSession)
            {
                // This method blocks. Get user input and send it to the blade
                Byte[] userEnteredData = CliSerialPort.ReadUserInputBytesFromSerial();
                // Check if the data has ctrl-c and exit 
                for (int i = 0; i < userEnteredData.Length; i++)
                {
                    // Snoop to see if the user entered Ctrl+C 
                    if ((int)userEnteredData[i] == 3)
                    {
                        // Signal the receive thread to stop
                        SharedFunc.SetSerialSession(false);

                        // Stop the serial session
                        StopBladeSerialSession stopCmd = new StopBladeSerialSession();
                        stopCmd.isSerialClient = true;
                        stopCmd.argVal.Add('i', bladeId);
                        stopCmd.commandImplementation();

                        // Display that serial session has ended
                        Console.WriteLine("Blade serial session ended..\n");
                        break;
                    }
                }
                Send(userEnteredData);
            }
        }
        /* Private member functions */
        /// <summary>
        /// Creates object for each individual command
        /// Corresponding command constructor initializes command specific parameters
        /// Also adds each command name and command object to command dictionary
        /// </summary>
        private static void CommandInitializer()
        {
            #region Chassis Infrastructure Commands
            GetServiceVersion getServiceVersionCmd = new GetServiceVersion();
            commandMap.Add(WcsCliConstants.getserviceversion, getServiceVersionCmd);

            // Get Chassis Info
            getinfo getinfoCmd = new getinfo();
            commandMap.Add(WcsCliConstants.getinfo, getinfoCmd);

            GetChassisHealth getChassisHealthCmd = new GetChassisHealth();
            commandMap.Add(WcsCliConstants.getChassisHealth, getChassisHealthCmd);

            // Get Blade Info
            getscinfo getscinfoCmd = new getscinfo();
            commandMap.Add(WcsCliConstants.getscinfo, getscinfoCmd);

            GetBladeHealth getBladeHealthCmd = new GetBladeHealth();
            commandMap.Add(WcsCliConstants.getBladeHealth, getBladeHealthCmd);

            // PSU Firmware
            UpdatePsuFirmware updatePsuFirmwareCmd = new UpdatePsuFirmware();
            commandMap.Add(WcsCliConstants.updatePsuFirmware, updatePsuFirmwareCmd);

            GetPsuFirmwareStatus getPsuFirmwareStatusCmd = new GetPsuFirmwareStatus();
            commandMap.Add(WcsCliConstants.getPsuFirmwareStatus, getPsuFirmwareStatusCmd);

            #endregion

            #region Blade Management Commands
            // Get Power State
            getscpowerstate getscpowerstateCmd = new getscpowerstate();
            commandMap.Add(WcsCliConstants.getscpowerstate, getscpowerstateCmd);

            poweron poweronCmd = new poweron();
            commandMap.Add(WcsCliConstants.poweron, poweronCmd);

            poweroff poweroffCmd = new poweroff();
            commandMap.Add(WcsCliConstants.poweroff, poweroffCmd);

            getbladestate bladeStateCmd = new getbladestate();
            commandMap.Add(WcsCliConstants.getbladestate, bladeStateCmd);

            bladeon bladeOnCmd = new bladeon();
            commandMap.Add(WcsCliConstants.bladeon, bladeOnCmd);

            bladeoff bladeOffCmd = new bladeoff();
            commandMap.Add(WcsCliConstants.bladeoff, bladeOffCmd);

            // Blade Default Power On state
            setscponstate setscponstateCmd = new setscponstate();
            commandMap.Add(WcsCliConstants.setscponstate, setscponstateCmd);

            getscponstate getscponstateCmd = new getscponstate();
            commandMap.Add(WcsCliConstants.getscponstate, getscponstateCmd);

            powercycle powercycleCmd = new powercycle();
            commandMap.Add(WcsCliConstants.powercycle, powercycleCmd);

            GetNextBoot getNextBootCmd = new GetNextBoot();
            commandMap.Add(WcsCliConstants.getnextboot, getNextBootCmd);

            SetNextBoot setNextBootCmd = new SetNextBoot();
            commandMap.Add(WcsCliConstants.setnextboot, setNextBootCmd);

            // Blade Attention LED on
            scidon scidonCmd = new scidon();
            commandMap.Add(WcsCliConstants.scidon, scidonCmd);

            // Blade Attention LED off
            scidoff scidoffCmd = new scidoff();
            commandMap.Add(WcsCliConstants.scidoff, scidoffCmd);

            // Read Blade Log
            readsclog readsclogCmd = new readsclog();
            commandMap.Add(WcsCliConstants.readsclog, readsclogCmd);

            // Clear Blade Log
            clrsclog clrsclogCmd = new clrsclog();
            commandMap.Add(WcsCliConstants.clrsclog, clrsclogCmd);

            getpowerreading getpowerreadingCmd = new getpowerreading();
            commandMap.Add(WcsCliConstants.getpowerreading, getpowerreadingCmd);

            getpowerlimit getpowerlimitCmd = new getpowerlimit();
            commandMap.Add(WcsCliConstants.getpowerlimit, getpowerlimitCmd);

            setpowerlimit setpowerlimitCmd = new setpowerlimit();
            commandMap.Add(WcsCliConstants.setpowerlimit, setpowerlimitCmd);

            activatepowerlimit activatepowerlimitCmd = new activatepowerlimit();
            commandMap.Add(WcsCliConstants.activatepowerlimit, activatepowerlimitCmd);

            deactivatepowerlimit deactivatepowerlimitCmd = new deactivatepowerlimit();
            commandMap.Add(WcsCliConstants.deactivatepowerlimit, deactivatepowerlimitCmd);

            SetDataSafeBladeOn dataSafeBladeOnCmd = new SetDataSafeBladeOn();
            commandMap.Add(WcsCliConstants.dataSafeBladeOn, dataSafeBladeOnCmd);

            SetDataSafePowerOn dataSafePowerOnCmd = new SetDataSafePowerOn();
            commandMap.Add(WcsCliConstants.dataSafePowerOn, dataSafePowerOnCmd);

            SetDataSafeBladeOff dataSafeBladeOffCmd = new SetDataSafeBladeOff();
            commandMap.Add(WcsCliConstants.dataSafeBladeOff, dataSafeBladeOffCmd);

            SetDataSafePowerOff dataSafePowerOffCmd = new SetDataSafePowerOff();
            commandMap.Add(WcsCliConstants.dataSafePowerOff, dataSafePowerOffCmd);

            SetDataSafeBladeActivePowerCycle dataSafePowerCycleCmd = new SetDataSafeBladeActivePowerCycle();
            commandMap.Add(WcsCliConstants.dataSafePowerCycle, dataSafePowerCycleCmd);

            GetBladeDataSafePowerState getBladeDataSafePowerStateCmd = new GetBladeDataSafePowerState();
            commandMap.Add(WcsCliConstants.getBladeDataSafePowerState, getBladeDataSafePowerStateCmd);

            GetBladeBiosPostCode getBiosPostCodeCmd = new GetBladeBiosPostCode();
            commandMap.Add(WcsCliConstants.getBladeBiosPostCode, getBiosPostCodeCmd);

            SetBladePsuAlertDefaultPowerCap setPsuAlertDpcCmd = new SetBladePsuAlertDefaultPowerCap();
            commandMap.Add(WcsCliConstants.setBladePsuAlertDpc, setPsuAlertDpcCmd);

            GetBladePsuAlertDpc getPsuAlertDpcCmd = new GetBladePsuAlertDpc();
            commandMap.Add(WcsCliConstants.getBladePsuAlertDpc, getPsuAlertDpcCmd);

            GetBladePsuAlert getPsuAlertCmd = new GetBladePsuAlert();
            commandMap.Add(WcsCliConstants.getBladePsuAlert, getPsuAlertCmd);

            ActivateDeactivateBladePsuAlert activateDeactivatePsuAlertCmd = new ActivateDeactivateBladePsuAlert();
            commandMap.Add(WcsCliConstants.activateDeactivateBladePsuAlert, activateDeactivatePsuAlertCmd);

            GetBladeAssetInfo getBladeAssetInfoCmd = new GetBladeAssetInfo();
            commandMap.Add(WcsCliConstants.getBladeAssetInfo, getBladeAssetInfoCmd);

            SetBladeAssetInfo setBladeAssetInfoCmd = new SetBladeAssetInfo();
            commandMap.Add(WcsCliConstants.setBladeAssetInfo, setBladeAssetInfoCmd);
            #endregion

            #region Chassis Management Commands
            // Chassis Attention LED Status
            ncidstatus ncidstatusCmd = new ncidstatus();
            commandMap.Add(WcsCliConstants.ncidstatus, ncidstatusCmd);

            // Chassis Attention LED On
            ncidon ncidonCmd = new ncidon();
            commandMap.Add(WcsCliConstants.ncidon, ncidonCmd);

            // Chassis Attention LED Off
            ncidoff ncidoffCmd = new ncidoff();
            commandMap.Add(WcsCliConstants.ncidoff, ncidoffCmd);

            readnclog readnclogCmd = new readnclog();
            commandMap.Add(WcsCliConstants.readnclog, readnclogCmd);

            clrnclog clrnclogCmd = new clrnclog();
            commandMap.Add(WcsCliConstants.clrnclog, clrnclogCmd);

            // Get AC socket power state
            getpowerintstate getpowerintstateCmd = new getpowerintstate();
            commandMap.Add(WcsCliConstants.getpowerintstate, getpowerintstateCmd);

            // Set AC socket power state On
            powerinton powerintonCmd = new powerinton();
            commandMap.Add(WcsCliConstants.powerinton, powerintonCmd);

            // Set AC socket power state Off
            powerintoff powerintoffCmd = new powerintoff();
            commandMap.Add(WcsCliConstants.powerintoff, powerintoffCmd);

            GetChassisAssetInfo getChassisAssetInfoCmd = new GetChassisAssetInfo();
            commandMap.Add(WcsCliConstants.getCMAssetInfo, getChassisAssetInfoCmd);

            GetPDBAssetInfo getPDBAssetInfoCmd = new GetPDBAssetInfo();
            commandMap.Add(WcsCliConstants.getPDBAssetInfo, getPDBAssetInfoCmd);

            SetChassisManagerAssetInfo setCMAssetInfoCmd = new SetChassisManagerAssetInfo();
            commandMap.Add(WcsCliConstants.setCMAssetInfo, setCMAssetInfoCmd);

            SetPDBAssetInfo setPDBAssetInfoCmd = new SetPDBAssetInfo();
            commandMap.Add(WcsCliConstants.setPDBAssetInfo, setPDBAssetInfoCmd);
            #endregion

            #region Local Commands (WCSCLI Serial Mode Only)
            setnic setnicCmd = new setnic();
            setnicCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.setnic, setnicCmd);

            getnic getnicCmd = new getnic();
            getnicCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.getnic, getnicCmd);

            Clear clearCmd = new Clear();
            clearCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.clear, clearCmd);

            //RunWinCommand runWinCmd = new RunWinCommand();
            //runWinCmd.isCmServiceCommand = false;
            //commandMap.Add(WcsCliConstants.runWinCommand, runWinCmd);
            #endregion

            #region Chassis Manager Service Configuration Commands (WCSCLI Serial Mode Only)
            StartChassisManagerService startCMServiceCmd = new StartChassisManagerService();
            startCMServiceCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.startchassismanager, startCMServiceCmd);

            StopChassisManagerService stopCMServiceCmd = new StopChassisManagerService();
            stopCMServiceCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.stopchassismanager, stopCMServiceCmd);

            GetCMServiceStatus getCMServiceStatusCmd = new GetCMServiceStatus();
            getCMServiceStatusCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.getchassismanagerstatus, getCMServiceStatusCmd);

            EnableSSL enableSslCmd = new EnableSSL();
            enableSslCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.enablessl, enableSslCmd);

            DisableSSL disableSslCmd = new DisableSSL();
            disableSslCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.disablessl, disableSslCmd);
            #endregion

            #region User Management Commands
            adduser adduserCmd = new adduser();
            commandMap.Add(WcsCliConstants.adduser, adduserCmd);

            ChangeUserRole changeuserCmd = new ChangeUserRole();
            commandMap.Add(WcsCliConstants.changeuserrole, changeuserCmd);

            ChangeUserPassword changeUserPwd = new ChangeUserPassword();
            commandMap.Add(WcsCliConstants.changeuserpassword, changeUserPwd);

            removeuser removeuserCmd = new removeuser();
            commandMap.Add(WcsCliConstants.removeuser, removeuserCmd);
            #endregion

            #region Serial Session Commands
            startBladeSerialSession startBladeSerialSessionCmd = new startBladeSerialSession();
            commandMap.Add(WcsCliConstants.startBladeSerialSession, startBladeSerialSessionCmd);

            StopBladeSerialSession stopBladeSerialSessionCmd = new StopBladeSerialSession();
            commandMap.Add(WcsCliConstants.stopBladeSerialSession, stopBladeSerialSessionCmd);

            startPortSerialSession startPortSerialSessionCmd = new startPortSerialSession();
            commandMap.Add(WcsCliConstants.startPortSerialSession, startPortSerialSessionCmd);

            StopPortSerialSession stopPortSerialSessionCmd = new StopPortSerialSession();
            commandMap.Add(WcsCliConstants.stopPortSerialSession, stopPortSerialSessionCmd);

            EstablishConnectionToCm establishCmConnectionCmd = new EstablishConnectionToCm();
            establishCmConnectionCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.establishCmConnection, establishCmConnectionCmd);

            TerminateCmConnection terminateCmConnectionCmd = new TerminateCmConnection();
            terminateCmConnectionCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.terminateCmConnection, terminateCmConnectionCmd);
            #endregion

            help helpCmd = new help();
            helpCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.help, helpCmd);

            return;
        }
        /* Private memeber functions */
        /// <summary>
        /// Creates object for each individual command
        /// Corresponding command constructor initializes command specific parameters
        /// Also adds each command name and command object to command dictionary
        /// </summary>
        private static void CommandInitializer()
        {
            getinfo getinfoCmd = new getinfo();
            commandMap.Add(WcsCliConstants.getinfo, getinfoCmd);

            getscinfo getscinfoCmd = new getscinfo();
            commandMap.Add(WcsCliConstants.getscinfo, getscinfoCmd);
            commandsWithSledIdAndSledName.Add(getscinfoCmd);

            help helpCmd = new help();
            helpCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.help, helpCmd);

            ncidon ncidonCmd = new ncidon();
            commandMap.Add(WcsCliConstants.ncidon, ncidonCmd);

            ncidoff ncidoffCmd = new ncidoff();
            commandMap.Add(WcsCliConstants.ncidoff, ncidoffCmd);

            ncidstatus ncidstatusCmd = new ncidstatus();
            commandMap.Add(WcsCliConstants.ncidstatus, ncidstatusCmd);

            scidon scidonCmd = new scidon();
            commandMap.Add(WcsCliConstants.scidon, scidonCmd);
            commandsWithSledIdAndSledName.Add(scidonCmd);

            scidoff scidoffCmd = new scidoff();
            commandMap.Add(WcsCliConstants.scidoff, scidoffCmd);
            commandsWithSledIdAndSledName.Add(scidoffCmd);

            setscponstate setscponstateCmd = new setscponstate();
            commandMap.Add(WcsCliConstants.setscponstate, setscponstateCmd);
            commandsWithSledIdAndSledName.Add(setscponstateCmd);

            getscponstate getscponstateCmd = new getscponstate();
            commandMap.Add(WcsCliConstants.getscponstate, getscponstateCmd);
            commandsWithSledIdAndSledName.Add(getscponstateCmd);

            poweron poweronCmd = new poweron();
            commandMap.Add(WcsCliConstants.poweron, poweronCmd);
            commandsWithSledIdAndSledName.Add(poweronCmd);

            poweroff poweroffCmd = new poweroff();
            commandMap.Add(WcsCliConstants.poweroff, poweroffCmd);
            commandsWithSledIdAndSledName.Add(poweroffCmd);

            bladeon bladeOnCmd = new bladeon();
            commandMap.Add(WcsCliConstants.bladeon, bladeOnCmd);
            commandsWithSledIdAndSledName.Add(bladeOnCmd);

            bladeoff bladeOffCmd = new bladeoff();
            commandMap.Add(WcsCliConstants.bladeoff, bladeOffCmd);
            commandsWithSledIdAndSledName.Add(bladeOffCmd);

            getbladestate bladeStateCmd = new getbladestate();
            commandMap.Add(WcsCliConstants.getbladestate, bladeStateCmd);
            commandsWithSledIdAndSledName.Add(bladeStateCmd);

            powercycle powercycleCmd = new powercycle();
            commandMap.Add(WcsCliConstants.powercycle, powercycleCmd);
            commandsWithSledIdAndSledName.Add(powercycleCmd);

            getscpowerstate getscpowerstateCmd = new getscpowerstate();
            commandMap.Add(WcsCliConstants.getscpowerstate, getscpowerstateCmd);
            commandsWithSledIdAndSledName.Add(getscpowerstateCmd);

            powerinton powerintonCmd = new powerinton();
            commandMap.Add(WcsCliConstants.powerinton, powerintonCmd);

            powerintoff powerintoffCmd = new powerintoff();
            commandMap.Add(WcsCliConstants.powerintoff, powerintoffCmd);

            getpowerintstate getpowerintstateCmd = new getpowerintstate();
            commandMap.Add(WcsCliConstants.getpowerintstate, getpowerintstateCmd);

            startBladeSerialSession startBladeSerialSessionCmd = new startBladeSerialSession();
            commandMap.Add(WcsCliConstants.startBladeSerialSession, startBladeSerialSessionCmd);
            commandsWithSledIdAndSledName.Add(startBladeSerialSessionCmd);

            startPortSerialSession startPortSerialSessionCmd = new startPortSerialSession();
            commandMap.Add(WcsCliConstants.startPortSerialSession, startPortSerialSessionCmd);
            commandsWithSledIdAndSledName.Add(startBladeSerialSessionCmd);

            StopPortSerialSession stopsersessionCmd = new StopPortSerialSession();
            commandMap.Add(WcsCliConstants.stopPortSerialSession, stopsersessionCmd);
            commandsWithSledIdAndSledName.Add(stopsersessionCmd);

            StopBladeSerialSession stopBladeSerialSessionCmd = new StopBladeSerialSession();
            commandMap.Add(WcsCliConstants.stopBladeSerialSession, stopBladeSerialSessionCmd);
            commandsWithSledIdAndSledName.Add(stopBladeSerialSessionCmd);

            readnclog readnclogCmd = new readnclog();
            commandMap.Add(WcsCliConstants.readnclog, readnclogCmd);

            clrnclog clrnclogCmd = new clrnclog();
            commandMap.Add(WcsCliConstants.clrnclog, clrnclogCmd);

            readsclog readsclogCmd = new readsclog();
            commandMap.Add(WcsCliConstants.readsclog, readsclogCmd);
            commandsWithSledIdAndSledName.Add(readsclogCmd);

            clrsclog clrsclogCmd = new clrsclog();
            commandMap.Add(WcsCliConstants.clrsclog, clrsclogCmd);
            commandsWithSledIdAndSledName.Add(clrsclogCmd);

            adduser adduserCmd = new adduser();
            commandMap.Add(WcsCliConstants.adduser, adduserCmd);

            ChangeUserRole changeuserCmd = new ChangeUserRole();
            commandMap.Add(WcsCliConstants.changeuserrole, changeuserCmd);

            ChangeUserPassword changeUserPwd = new ChangeUserPassword();
            commandMap.Add(WcsCliConstants.changeuserpassword, changeUserPwd);

            removeuser removeuserCmd = new removeuser();
            commandMap.Add(WcsCliConstants.removeuser, removeuserCmd);

            getnic getnicCmd = new getnic();
            getnicCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.getnic, getnicCmd);

            setnic setnicCmd = new setnic();
            setnicCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.setnic, setnicCmd);

            getpowerreading getpowerreadingCmd = new getpowerreading();
            commandMap.Add(WcsCliConstants.getpowerreading, getpowerreadingCmd);

            getpowerlimit getpowerlimitCmd = new getpowerlimit();
            commandMap.Add(WcsCliConstants.getpowerlimit, getpowerlimitCmd);

            setpowerlimit setpowerlimitCmd = new setpowerlimit();
            commandMap.Add(WcsCliConstants.setpowerlimit, setpowerlimitCmd);

            activatepowerlimit activatepowerlimitCmd = new activatepowerlimit();
            commandMap.Add(WcsCliConstants.activatepowerlimit, activatepowerlimitCmd);

            deactivatepowerlimit deactivatepowerlimitCmd = new deactivatepowerlimit();
            commandMap.Add(WcsCliConstants.deactivatepowerlimit, deactivatepowerlimitCmd);

            GetChassisHealth getChassisHealthCmd = new GetChassisHealth();
            commandMap.Add(WcsCliConstants.getChassisHealth, getChassisHealthCmd);

            GetBladeHealth getBladeHealthCmd = new GetBladeHealth();
            commandMap.Add(WcsCliConstants.getBladeHealth, getBladeHealthCmd);

            SetNextBoot setNextBootCmd = new SetNextBoot();
            commandMap.Add(WcsCliConstants.setnextboot, setNextBootCmd);

            GetNextBoot getNextBootCmd = new GetNextBoot();
            commandMap.Add(WcsCliConstants.getnextboot, getNextBootCmd);

            GetServiceVersion getServiceVersionCmd = new GetServiceVersion();
            commandMap.Add(WcsCliConstants.getserviceversion, getServiceVersionCmd);

            EstablishConnectionToCm establishCmConnectionCmd = new EstablishConnectionToCm();
            establishCmConnectionCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.establishCmConnection, establishCmConnectionCmd);

            TerminateCmConnection terminateCmConnectionCmd = new TerminateCmConnection();
            terminateCmConnectionCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.terminateCmConnection, terminateCmConnectionCmd);

            StartChassisManagerService startCMServiceCmd = new StartChassisManagerService();
            startCMServiceCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.startchassismanager, startCMServiceCmd);

            StopChassisManagerService stopCMServiceCmd = new StopChassisManagerService();
            stopCMServiceCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.stopchassismanager, stopCMServiceCmd);

            GetCMServiceStatus getCMServiceStatusCmd = new GetCMServiceStatus();
            getCMServiceStatusCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.getchassismanagerstatus, getCMServiceStatusCmd);

            EnableSSL enableSslCmd = new EnableSSL();
            enableSslCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.enablessl, enableSslCmd);

            DisableSSL disableSslCmd = new DisableSSL();
            disableSslCmd.isCmServiceCommand = false;
            commandMap.Add(WcsCliConstants.disablessl, disableSslCmd);

            return;
        }