/// <summary> /// Get power status of AC socket within the chassis /// </summary> /// <param name="portNo">Port no corresponding to the AC sockets internal to the chassis like TOR switches</param> /// <returns>AC Socket power state.</returns> public ACSocketStateResponse GetACSocketPowerState(uint portNo) { byte MaxbladeCount = (byte)ConfigLoaded.Population; Tracer.WriteInfo("Received GetACSocketPowerState({0})", portNo); Tracer.WriteUserLog("Invoked GetACSocketPowerState(portNo: {0})", portNo); ACSocketStateResponse response = new ACSocketStateResponse(); response.completionCode = Contracts.CompletionCode.Unknown; response.statusDescription = String.Empty; response.portNo = portNo; response.powerState = new PowerState(); // Validate port number if (!ChassisManagerUtil.CheckPortValidity(portNo)) { Tracer.WriteError("GetACSocketPowerState: Input port number is invalid {0}", portNo); response.completionCode = Contracts.CompletionCode.ParameterOutOfRange; response.statusDescription = "Port Number is invalid"; return response; } AcSocket acSocket = ChassisState.AcPowerSockets[portNo - 1]; PowerState status = acSocket.getAcSocketStatus(); Tracer.WriteInfo("Return: {0}", status); if (status == PowerState.NA) { Tracer.WriteError("AC Socket Get Status Failed with Completion code {0:X}", status); response.completionCode = Contracts.CompletionCode.Failure; response.statusDescription = String.Format("AC Socket Get Status Failed with Completion code {0:X}", status); } else { response.completionCode = Contracts.CompletionCode.Success; response.powerState = status; } 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() { ACSocketStateResponse myResponse = new ACSocketStateResponse(); dynamic myPortNo = null; uint portNo = 0; try { this.argVal.TryGetValue('p', out myPortNo); portNo = (uint)myPortNo; myResponse = WcsCli2CmConnectionManager.channel.GetACSocketPowerState(portNo); } catch (Exception ex) { SharedFunc.ExceptionOutput(ex); return; } if (ResponseValidation.ValidateResponse(null, myResponse, false)) { Console.Write(WcsCliConstants.commandSuccess); int index = (int)myPortNo; if (myResponse.powerState == PowerState.ON) { Console.WriteLine("ON"); } else if (myResponse.powerState == PowerState.OFF) { Console.WriteLine("OFF"); } else { Console.WriteLine("--"); } } }
/// <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() { ACSocketStateResponse myResponse = new ACSocketStateResponse(); dynamic myPortNo = null; uint portNo = 0; try { this.argVal.TryGetValue('p', out myPortNo); portNo = (uint)myPortNo; myResponse = WcsCli2CmConnectionManager.channel.GetACSocketPowerState(portNo); } catch (Exception ex) { SharedFunc.ExceptionOutput(ex); return; } if (myResponse == null) { Console.WriteLine(WcsCliConstants.serviceResponseEmpty); return; } if (myResponse.completionCode == Contracts.CompletionCode.Success) { int index = (int)myPortNo; if (myResponse.powerState == PowerState.ON) { Console.WriteLine("ON"); } else if (myResponse.powerState == PowerState.OFF) { Console.WriteLine("OFF"); } else { Console.WriteLine("--"); } } else if (myResponse.completionCode == Contracts.CompletionCode.Failure) { Console.WriteLine(WcsCliConstants.commandFailure); } else if (myResponse.completionCode == Contracts.CompletionCode.Timeout) { Console.WriteLine(WcsCliConstants.commandTimeout); } else { Console.WriteLine("Command failed with the completion code: {0}", myResponse.completionCode.ToString()); } }
/// <summary> /// Get power status of AC socket within the chassis /// </summary> /// <param name="portNo">Port no corresponding to the AC sockets internal to the chassis like TOR switches</param> /// <returns>AC Socket power state.</returns> public ACSocketStateResponse GetACSocketPowerState(uint portNo) { byte MaxbladeCount = (byte)ConfigLoaded.Population; Tracer.WriteInfo("Received GetACSocketPowerState({0})", portNo); Tracer.WriteUserLog("Invoked GetACSocketPowerState(portNo: {0})", portNo); ACSocketStateResponse response = new ACSocketStateResponse(); response.completionCode = Contracts.CompletionCode.Unknown; response.statusDescription = String.Empty; response.portNo = portNo; response.powerState = new PowerState(); AcSocket acSocket = ChassisState.AcPowerSockets[portNo - 1]; PowerState status = acSocket.getAcSocketStatus(); Tracer.WriteInfo("Return: {0}", status); if (status == PowerState.NA) { Tracer.WriteError("blade AC Socket Get Status Failed with Completion code {0:X}", status); response.completionCode = Contracts.CompletionCode.Failure; response.statusDescription = String.Format("blade AC Socket Get Status Failed with Completion code {0:X}", status); } else { response.completionCode = Contracts.CompletionCode.Success; response.powerState = status; } return response; }