/// <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; }
/// <summary> /// Returns the default blade board power state /// </summary> /// <param name="bladeId">Blade ID (1-24)</param> /// <returns>Blade State Response packet</returns> public BladeStateResponse GetBladeDefaultPowerState(int bladeId) { Tracer.WriteInfo("Received GetBladeDefaultPowerState({0})", bladeId); Tracer.WriteUserLog("Invoked GetBladeDefaultPowerState({0})", bladeId); BladeStateResponse response = new BladeStateResponse(); response.bladeNumber = bladeId; response.completionCode = Contracts.CompletionCode.Unknown; response.statusDescription = String.Empty; Contracts.ChassisResponse varResponse = ValidateRequest("GetBladeDefaultPowerState", bladeId); if (varResponse.completionCode != Contracts.CompletionCode.Success) { response.completionCode = varResponse.completionCode; response.statusDescription = varResponse.statusDescription; return response; } Ipmi.SystemStatus powerPolicy = WcsBladeFacade.GetChassisState((byte)bladeId); if (powerPolicy.CompletionCode != (byte)CompletionCode.Success) { Tracer.WriteWarning("GetBladeDefaultPowerState failed with completion code:" + Ipmi.IpmiSharedFunc.ByteToHexString((byte)powerPolicy.CompletionCode)); response.completionCode = Contracts.CompletionCode.Failure; response.statusDescription = response.completionCode.ToString(); response.bladeState = PowerState.NA; } else { response.completionCode = Contracts.CompletionCode.Success; Ipmi.PowerRestoreOption currentSetting = powerPolicy.PowerOnPolicy; switch (currentSetting) { case Microsoft.GFS.WCS.ChassisManager.Ipmi.PowerRestoreOption.StayOff: response.bladeState = PowerState.OFF; Tracer.WriteInfo("GetBladeDefaultPowerState(BladeId: {0}) return is OFF", bladeId); break; case Microsoft.GFS.WCS.ChassisManager.Ipmi.PowerRestoreOption.AlwaysPowerUp: response.bladeState = PowerState.ON; Tracer.WriteInfo("GetBladeDefaultPowerState(BladeID: {0}) return is ON", bladeId); break; case Microsoft.GFS.WCS.ChassisManager.Ipmi.PowerRestoreOption.GetCurrentPolicy: response.bladeState = PowerState.NA; Tracer.WriteInfo("GetBladeDefaultPowerState(BladeID: {0}) return is curr policy", bladeId); break; case Microsoft.GFS.WCS.ChassisManager.Ipmi.PowerRestoreOption.PreviousState: response.bladeState = PowerState.NA; Tracer.WriteInfo("GetBladeDefaultPowerState(BladeID: {0}) return is prev state", bladeId); break; case Microsoft.GFS.WCS.ChassisManager.Ipmi.PowerRestoreOption.Unknown: response.bladeState = PowerState.NA; Tracer.WriteInfo("GetBladeDefaultPowerState(BladeID: {0}) return is unknown", bladeId); break; default: response.bladeState = PowerState.NA; Tracer.WriteInfo("GetBladeDefaultPowerState(BladeID: {0}) return is NA", bladeId); break; } } return response; }
/// <summary> /// Get Blade soft power state /// </summary> /// <param name="bladeId">Blade ID(1-48)</param> /// <returns>Blade state response class object</returns> public BladeStateResponse GetBladeState(int bladeId) { Tracer.WriteInfo("Received GetBladeState({0})", bladeId); Tracer.WriteUserLog("Invoked GetBladeState(bladeid: {0})", bladeId); BladeStateResponse stateResponse = new BladeStateResponse(); stateResponse.bladeNumber = bladeId; stateResponse.bladeState = Contracts.PowerState.NA; stateResponse.completionCode = Contracts.CompletionCode.Unknown; stateResponse.statusDescription = String.Empty; Contracts.ChassisResponse varResponse = ValidateRequest("GetBladeState", bladeId); if (varResponse.completionCode != Contracts.CompletionCode.Success) { stateResponse.completionCode = varResponse.completionCode; stateResponse.statusDescription = varResponse.statusDescription; return stateResponse; } // Check to see if the blade enable itself is OFF - then the BMC power state does not matter BladePowerStatePacket response = ChassisState.BladePower[bladeId - 1].GetBladePowerState(); if (response.CompletionCode != CompletionCode.Success) { // No return here, because we still want to return a BMC state on the fall through, // if Blade enable read fails for whatever reason Tracer.WriteWarning("GetBladeState: Blade {0} Power Enable state read failed (Completion Code: {1:X})", bladeId, response.CompletionCode); stateResponse.completionCode = ChassisManagerUtil.GetContractsCompletionCodeMapping((byte)response.CompletionCode); stateResponse.statusDescription = stateResponse.completionCode.ToString(); } else { // Only if the blade enable is OFF, we return that status, for anything else we have to read BMC status if (response.PowerStatus == Contracts.PowerState.OFF) { // Since we do not know if a blade is present in that slot or not, we return NA as power state stateResponse.bladeState = Contracts.PowerState.OFF; stateResponse.completionCode = Contracts.CompletionCode.Success; return stateResponse; } else if (response.PowerStatus == Contracts.PowerState.ON) { if (response.DecompressionTime > 0) { stateResponse.completionCode = Contracts.CompletionCode.Success; stateResponse.bladeState = PowerState.OnFwDecompress; stateResponse.statusDescription = string.Format("Blade On. Firmware Decompression Time Remaining: {0}", response.DecompressionTime); return stateResponse; } } } Ipmi.SystemStatus powerState = WcsBladeFacade.GetChassisState((byte)bladeId); Tracer.WriteInfo("GetBladeState {0} Return: {1}, Blade State: {2}", bladeId, powerState.CompletionCode, powerState.PowerState.ToString()); if (powerState.CompletionCode != (byte)CompletionCode.Success) { Tracer.WriteError("GetBladeState Failed with Completion code {0:X}", powerState.CompletionCode); stateResponse.bladeState = Contracts.PowerState.NA; stateResponse.completionCode = ChassisManagerUtil.GetContractsCompletionCodeMapping((byte)powerState.CompletionCode); stateResponse.statusDescription = stateResponse.completionCode.ToString(); } else { stateResponse.completionCode = Contracts.CompletionCode.Success; if (powerState.PowerState == Ipmi.IpmiPowerState.On) { stateResponse.bladeState = Contracts.PowerState.ON; } else { stateResponse.bladeState = Contracts.PowerState.OFF; } } return stateResponse; }
/// <summary> /// A test for SetBladeActivePowerCycle /// </summary> public TestsResultResponse SetBladeActivePowerCycleTest() { BladeStateResponse response = new BladeStateResponse(); string failureMessage = string.Empty; int randomBlade = 0; bool isServer = false; int bladeIndex = 1; Console.WriteLine("\n!!!!!!!!! Starting execution of SetBladeActivePowerCycleTest."); //make sure you pick a server and not a JBOD while (!isServer && bladeIndex <= this.ChassisPopulation) { randomBlade = new Random().Next(1, (byte)this.ChassisPopulation); if (!this.JbodLocations.Contains(bladeIndex) && !this.EmptySlots.Contains(bladeIndex)) { isServer = true; } else { bladeIndex++; } } if (bladeIndex > this.ChassisPopulation) { failureMessage = "\n!!!Failed to find a server machine to run the test."; Console.WriteLine(failureMessage); return new TestsResultResponse(ExecutionResult.Failed, failureMessage); } this.Channel.SetPowerOn(randomBlade); System.Threading.Thread.Sleep(50000); this.Channel.SetBladeOn(randomBlade); System.Threading.Thread.Sleep(50000); //Make sure blade is on to start with response = this.Channel.GetBladeState(randomBlade); if (response.bladeState != PowerState.ON) { failureMessage = "\n!!!Blade should be ON."; Console.WriteLine(failureMessage); return new TestsResultResponse(ExecutionResult.Failed, failureMessage); } //PowerCycle blade this.Channel.SetBladeActivePowerCycle(randomBlade, 20); System.Threading.Thread.Sleep(10000); response = this.Channel.GetBladeState(randomBlade); if (response.bladeState != PowerState.OFF) { failureMessage = string.Format("\n!!!Blade should still be off for blade# {0}", randomBlade); Console.WriteLine(failureMessage); return new TestsResultResponse(ExecutionResult.Failed, failureMessage); } System.Threading.Thread.Sleep(20000); response = this.Channel.GetBladeState(randomBlade); if (response.bladeState != PowerState.ON) { failureMessage = "\n!!!Blade should be already turned ON."; Console.WriteLine(failureMessage); return new TestsResultResponse(ExecutionResult.Failed, failureMessage); } Console.WriteLine("\n++++++++++++++++++++++++++++++++"); failureMessage = "\n!!!!!!!!! Successfully finished execution of SetBladeActivePowerCycleTest."; Console.WriteLine(failureMessage); return new TestsResultResponse(ExecutionResult.Passed, failureMessage); }
/// <summary> /// command specific implementation /// argVal command class member has all user-entered command argument indicators and parameter values /// Currently just prints all argument indicators and argument values /// </summary> internal override void commandImplementation() { uint sledId = 1; BladeStateResponse myResponse = new BladeStateResponse(); GetAllBladesStateResponse myResponses = new GetAllBladesStateResponse(); try { if (this.argVal.ContainsKey('a')) { myResponses = WcsCli2CmConnectionManager.channel.GetAllBladesState(); } else if (this.argVal.ContainsKey('i')) { dynamic mySledId = null; this.argVal.TryGetValue('i', out mySledId); sledId = (uint)mySledId; myResponse = WcsCli2CmConnectionManager.channel.GetBladeState((int)mySledId); } } catch (Exception ex) { SharedFunc.ExceptionOutput(ex); return; } if ((this.argVal.ContainsKey('a') && myResponses == null) || myResponse == null) { Console.WriteLine(WcsCliConstants.serviceResponseEmpty); return; } if (this.argVal.ContainsKey('a')) { for (int index = 0; index < myResponses.bladeStateResponseCollection.Count(); index++) { if (myResponses.bladeStateResponseCollection[index].completionCode == Contracts.CompletionCode.Success) { if (myResponses.bladeStateResponseCollection[index].bladeState == Contracts.PowerState.ON) { Console.WriteLine("Blade State " + myResponses.bladeStateResponseCollection[index].bladeNumber + ": ON"); } else if (myResponses.bladeStateResponseCollection[index].bladeState == Contracts.PowerState.OFF) { Console.WriteLine("Blade State " + myResponses.bladeStateResponseCollection[index].bladeNumber + ": OFF"); } else { Console.WriteLine("Blade State " + myResponses.bladeStateResponseCollection[index].bladeNumber + ": --"); } } else { // If not success, return the exact error state Console.WriteLine("Blade State " + myResponses.bladeStateResponseCollection[index].bladeNumber + ": " + myResponses.bladeStateResponseCollection[index].completionCode.ToString()); } } } else { if (myResponse.completionCode == Contracts.CompletionCode.Success) { if (myResponse.bladeState == Contracts.PowerState.ON) { Console.WriteLine("Blade State " + myResponse.bladeNumber + ": ON"); } else if (myResponse.bladeState == Contracts.PowerState.OFF) { Console.WriteLine("Blade State " + myResponse.bladeNumber + ": OFF"); } else { Console.WriteLine("Blade State " + myResponse.bladeNumber + ": --"); } } else if (myResponse.completionCode == Contracts.CompletionCode.Unknown) { Console.WriteLine("Blade State " + myResponse.bladeNumber + ": " + WcsCliConstants.bladeStateUnknown); } else { // Display error if other than success/unknown Console.WriteLine("Blade State " + sledId + ": " + myResponse.completionCode.ToString()); } } }
private TestResponse TrueAfterRestartGetBladeMezzPassThroughMode(int bladeId) { TestCase testCase = new TestCase("TrueAfterRestartGetBladeMezzPassThroughMode", 24181); CmTestLog.Info(string.Format( "\n !!!!!!Verifying {0} Returns Correct Pass-ThroughMode After Restarting Blade. WorkItemId: {1}!!!!!!", this.currentApi, testCase.WorkItemId)); TestResponse response = new TestResponse(); BladeResponse setBladeActivePowerCycleResponse = new BladeResponse(); BladeStateResponse getBladeStateResponse = new BladeStateResponse(); this.TestChannelContext = this.ListTestChannelContexts[(int)WCSSecurityRole.WcsCmAdmin]; // Restart blade setBladeActivePowerCycleResponse = this.TestChannelContext.SetBladeActivePowerCycle(bladeId, Convert.ToInt32(CmConstants.OffTimeSec)); if (setBladeActivePowerCycleResponse.completionCode != CompletionCode.Success) { LogMessage.Message = string.Format( "{0}: Failed to restart blade {1} with completion code {2}", this.currentApi, bladeId, setBladeActivePowerCycleResponse.completionCode); LogMessage.Log(LogMessage.MessageType.Failure, ref response); } // Sleep Thread for 2 minutes 30 seconds CmTestLog.Info(string.Format("Thread sleeping for {0} seconds...", TimeSpan.FromSeconds(150))); Thread.Sleep(TimeSpan.FromSeconds(150)); // Verify blade soft-powered on getBladeStateResponse = this.TestChannelContext.GetBladeState(bladeId); if (getBladeStateResponse.completionCode != CompletionCode.Success || getBladeStateResponse.bladeState != PowerState.ON) { LogMessage.Message = string.Format( "{0}: Blade {1} did not soft-power ON", this.currentApi, bladeId); LogMessage.Log(LogMessage.MessageType.Failure, ref response); } else { CallAndVerifyGetBladeMezzPassThroughMode(bladeId, ref response, "true"); } testCase.LogPassOrFail(ref response, currentApi); return response; }
/// <summary> /// command specific implementation /// argVal command class member has all user-entered command argument indicators and parameter values /// Currently just prints all argument indicators and argument values /// </summary> internal override void commandImplementation() { uint sledId = 1; BladeStateResponse myResponse = new BladeStateResponse(); GetAllBladesStateResponse myResponses = new GetAllBladesStateResponse(); try { if (this.argVal.ContainsKey('a')) { myResponses = WcsCli2CmConnectionManager.channel.GetAllBladesState(); } else if (this.argVal.ContainsKey('i')) { dynamic mySledId = null; this.argVal.TryGetValue('i', out mySledId); sledId = (uint)mySledId; myResponse = WcsCli2CmConnectionManager.channel.GetBladeState((int)mySledId); } } catch (Exception ex) { SharedFunc.ExceptionOutput(ex); return; } if ((this.argVal.ContainsKey('a') && myResponses == null) || myResponse == null) { Console.WriteLine(WcsCliConstants.serviceResponseEmpty); return; } if (this.argVal.ContainsKey('a')) { for (int index = 0; index < myResponses.bladeStateResponseCollection.Count(); index++) { if (ResponseValidation.ValidateBladeResponse(myResponses.bladeStateResponseCollection[index].bladeNumber, null, myResponses.bladeStateResponseCollection[index], false)) { if (myResponses.bladeStateResponseCollection[index].bladeState == Contracts.PowerState.ON) { Console.WriteLine(WcsCliConstants.commandSuccess + " Blade State " + myResponses.bladeStateResponseCollection[index].bladeNumber + ": ON"); } else if (myResponses.bladeStateResponseCollection[index].bladeState == Contracts.PowerState.OFF) { Console.WriteLine(WcsCliConstants.commandSuccess + " Blade State " + myResponses.bladeStateResponseCollection[index].bladeNumber + ": OFF"); } else if (myResponses.bladeStateResponseCollection[index].bladeState == Contracts.PowerState.OnFwDecompress) { Console.WriteLine(WcsCliConstants.commandSuccess + " Blade State " + myResponses.bladeStateResponseCollection[index].bladeNumber + ": ON - Firmware Decompressing"); } else { Console.WriteLine(WcsCliConstants.commandSuccess + " Blade State " + myResponses.bladeStateResponseCollection[index].bladeNumber + ": --"); } } } } else { if (ResponseValidation.ValidateBladeResponse(myResponse.bladeNumber, null, myResponse, false)) { if (myResponse.bladeState == Contracts.PowerState.ON) { Console.WriteLine(WcsCliConstants.commandSuccess + " Blade State " + myResponse.bladeNumber + ": ON"); } else if (myResponse.bladeState == Contracts.PowerState.OFF) { Console.WriteLine(WcsCliConstants.commandSuccess + " Blade State " + myResponse.bladeNumber + ": OFF"); } else if (myResponse.bladeState == Contracts.PowerState.OnFwDecompress) { Console.WriteLine(WcsCliConstants.commandSuccess + " Blade State " + myResponse.bladeNumber + ": ON - Firmware Decompressing"); } else { Console.WriteLine(WcsCliConstants.commandSuccess + " Blade State " + myResponse.bladeNumber + ": --"); } } } }