/// <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() { BladeResponse myResponse = new BladeResponse(); AllBladesResponse myResponses = new AllBladesResponse(); dynamic bladeId = null; dynamic action = null; try { if (!this.argVal.TryGetValue('d', out action)) { action = 0; // default NoAction } if (this.argVal.ContainsKey('a')) { myResponses = WcsCli2CmConnectionManager.channel.SetAllBladesPsuAlert( this.argVal.ContainsKey('c'), (int)action, this.argVal.ContainsKey('r')); } else if (this.argVal.ContainsKey('i')) { if (this.argVal.TryGetValue('i', out bladeId)) { myResponse = WcsCli2CmConnectionManager.channel.SetBladePsuAlert((int)bladeId, this.argVal.ContainsKey('c'), (int)action, this.argVal.ContainsKey('r')); } else { Console.WriteLine(WcsCliConstants.commandFailure + " No blade ID specified, please look at command help."); return; } } } catch (Exception ex) { SharedFunc.ExceptionOutput(ex); return; } if ((this.argVal.ContainsKey('a') && myResponses == null) || (this.argVal.ContainsKey('a') && myResponses.bladeResponseCollection == null) || myResponse == null) { Console.WriteLine(WcsCliConstants.serviceResponseEmpty); return; } if (this.argVal.ContainsKey('a')) { for (int index = 0; index < myResponses.bladeResponseCollection.Count(); index++) { ResponseValidation.ValidateBladeResponse(myResponses.bladeResponseCollection[index].bladeNumber, "activate/deactivate PSU alert done", myResponses.bladeResponseCollection[index]); } } else { ResponseValidation.ValidateBladeResponse(myResponse.bladeNumber, "activate/deactivate PSU alert done", myResponse); } }
internal override void commandImplementation() { uint sledId = 1; BladeResponse myResponse = new BladeResponse(); AllBladesResponse myResponses = new AllBladesResponse(); try { if (this.argVal.ContainsKey('a')) { myResponses = WcsCli2CmConnectionManager.channel.SetAllBladesPowerLimitOn(); } else if (this.argVal.ContainsKey('i')) { dynamic mySledId = null; this.argVal.TryGetValue('i', out mySledId); sledId = (uint)mySledId; myResponse = WcsCli2CmConnectionManager.channel.SetBladePowerLimitOn((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.bladeResponseCollection.Count(); index++) { if (ResponseValidation.ValidateBladeResponse(myResponses.bladeResponseCollection[index].bladeNumber, null, myResponses.bladeResponseCollection[index], false)) { Console.WriteLine(WcsCliConstants.commandSuccess + "Blade " + myResponses.bladeResponseCollection[index].bladeNumber + ": Power Limit Activated"); } } } else { if (ResponseValidation.ValidateBladeResponse(myResponse.bladeNumber, null, myResponse, false)) { Console.WriteLine(WcsCliConstants.commandSuccess + "Blade " + myResponse.bladeNumber + ": Power Limit Activated"); } } }
/// <summary> /// Power On all blades /// </summary> /// <returns>Array of blade responses, one for each blade. Indicates success/failure.</returns> public AllBladesResponse SetAllPowerOn() { byte maxBladeCount = (byte)ConfigLoaded.Population; AllBladesResponse responses = new AllBladesResponse(); responses.completionCode = Contracts.CompletionCode.Unknown; responses.statusDescription = string.Empty; responses.bladeResponseCollection = new List<BladeResponse>(); Contracts.CompletionCode[] bladeInternalResponseCollection = new Contracts.CompletionCode[maxBladeCount]; Tracer.WriteInfo("Invoked SetAllPowerOn()"); Tracer.WriteUserLog("Invoked SetAllPowerOn()"); for (int loop = 0; loop < maxBladeCount; loop++) { int bladeId = loop + 1; responses.bladeResponseCollection.Add(SetPowerOn(bladeId)); // Set the internal blade response to the blade completion code. bladeInternalResponseCollection[loop] = responses.bladeResponseCollection[loop].completionCode; } Contracts.ChassisResponse varResponse = new Contracts.ChassisResponse(); varResponse = ChassisManagerUtil.ValidateAllBladeResponse(bladeInternalResponseCollection); responses.completionCode = varResponse.completionCode; responses.statusDescription = varResponse.statusDescription; return responses; }
/// <summary> /// Set active power limit ON for all blades /// </summary> /// <returns>Array of blade responses indicating blade operation was success/failure</returns> public AllBladesResponse SetAllBladesPowerLimitOn() { byte MaxbladeCount = (byte)ConfigLoaded.Population; AllBladesResponse responses = new AllBladesResponse(); responses.completionCode = Contracts.CompletionCode.Unknown; responses.statusDescription = string.Empty; responses.bladeResponseCollection = new List<BladeResponse>(); Contracts.CompletionCode[] bladeInternalResponseCollection = new Contracts.CompletionCode[MaxbladeCount]; Tracer.WriteUserLog("Invoked SetAllBladesPowerLimitOn()"); try { for (int index = 0; index < ConfigLoaded.Population; index++) { int bladeId = index + 1; responses.bladeResponseCollection.Add(SetBladePowerLimitOn(bladeId)); // Set the internal blade response to the blade completion code. bladeInternalResponseCollection[index] = responses.bladeResponseCollection[index].completionCode; } } catch (Exception ex) { responses.completionCode = Contracts.CompletionCode.Failure; responses.statusDescription = responses.completionCode.ToString() + ": " + ex.Message; Tracer.WriteError("SetAllBladesPowerLimitOn Exception"); return responses; } Contracts.ChassisResponse varResponse = new Contracts.ChassisResponse(); varResponse = ChassisManagerUtil.ValidateAllBladeResponse(bladeInternalResponseCollection); responses.completionCode = varResponse.completionCode; responses.statusDescription = varResponse.statusDescription; return responses; }
/// <summary> /// Power cycle all blades /// </summary> /// <param name="offTime">time for which the blades will be powered off in seconds</param> /// <returns>Collection of Blade responses indicating if blade operation was success/failure</returns> public AllBladesResponse SetAllBladesActivePowerCycle(uint offTime) { byte maxbladeCount = (byte)ConfigLoaded.Population; AllBladesResponse responses = new AllBladesResponse(); responses.completionCode = Contracts.CompletionCode.Unknown; responses.statusDescription = string.Empty; responses.bladeResponseCollection = new List<BladeResponse>(); Contracts.CompletionCode[] bladeInternalResponseCollection = new Contracts.CompletionCode[maxbladeCount]; Tracer.WriteUserLog(" Invoked SetAllBladesActivePowerCycle(offTime: {0})", offTime); // Check that the power off time is valid for a byte value since the IPMI command takes a byte value if (offTime > Byte.MaxValue) { Tracer.WriteWarning("SetAllBladesActivePowerCycle failed, Invalid power off time: {0}", offTime); responses.completionCode = Contracts.CompletionCode.ParameterOutOfRange; responses.statusDescription = Contracts.CompletionCode.ParameterOutOfRange.ToString(); return responses; } for (int loop = 0; loop < maxbladeCount; loop++) { int bladeId = loop + 1; responses.bladeResponseCollection.Add(SetBladeActivePowerCycle(bladeId, offTime)); // Set the internal blade response to the blade completion code. bladeInternalResponseCollection[loop] = responses.bladeResponseCollection[loop].completionCode; } Contracts.ChassisResponse varResponse = new Contracts.ChassisResponse(); varResponse = ChassisManagerUtil.ValidateAllBladeResponse(bladeInternalResponseCollection); responses.completionCode = varResponse.completionCode; responses.statusDescription = varResponse.statusDescription; return responses; }
private bool VerifySetAllBladesDefaultPowerState(ref bool testPassed, WCSSecurityRole roleId, AllBladesResponse allPowerResponse) { if (allPowerResponse.completionCode != CompletionCode.Success && (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator)) { CmTestLog.Failure(string.Format("Cannot set all blades default power state With User {0}", roleId)); CmTestLog.End(false); return false; } else if (allPowerResponse.completionCode == CompletionCode.Success && (roleId == WCSSecurityRole.WcsCmUser)) { CmTestLog.Failure(string.Format("User is able to set all blades default power state {0}", roleId)); CmTestLog.End(false); return false; } else { testPassed &= ChassisManagerTestHelper.AreEqual(allPowerResponse.completionCode, CompletionCode.Success, string.Format("Received success with user {0}", Enum.GetName(typeof(WCSSecurityRole), roleId))); } return testPassed; }
internal override void commandImplementation() { uint sledId = 1; BladeResponse myResponse = new BladeResponse(); AllBladesResponse myResponses = new AllBladesResponse(); try { if (this.argVal.ContainsKey('a')) { myResponses = WcsCli2CmConnectionManager.channel.SetAllBladesPowerLimitOff(); } else if (this.argVal.ContainsKey('i')) { dynamic mySledId = null; this.argVal.TryGetValue('i', out mySledId); sledId = (uint)mySledId; myResponse = WcsCli2CmConnectionManager.channel.SetBladePowerLimitOff((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.bladeResponseCollection.Count(); index++) { if (myResponses.bladeResponseCollection[index].completionCode == Contracts.CompletionCode.Success) { Console.WriteLine("Blade " + myResponses.bladeResponseCollection[index].bladeNumber + ": Power Limit Deactive"); } else if (myResponse.completionCode == Contracts.CompletionCode.Unknown) { Console.WriteLine("Blade " + myResponses.bladeResponseCollection[index].bladeNumber + ": " + WcsCliConstants.bladeStateUnknown); } else { // Display error if other than success/unknown Console.WriteLine("Blade " + myResponses.bladeResponseCollection[index].bladeNumber + " failed with completion code: " + myResponses.bladeResponseCollection[index].completionCode.ToString()); } } } else { if (myResponse.completionCode == Contracts.CompletionCode.Success) { Console.WriteLine("Blade " + myResponse.bladeNumber + ": Power Limit Deactive"); } else if (myResponse.completionCode == Contracts.CompletionCode.Unknown) { Console.WriteLine("Blade " + myResponse.bladeNumber + ": " + WcsCliConstants.bladeStateUnknown); } else { // Display error if other than success/unknown Console.WriteLine("Blade " + myResponse.bladeNumber + ": " + myResponse.completionCode.ToString()); } } }
/// <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() { BladeResponse myResponse = new BladeResponse(); AllBladesResponse myResponses = new AllBladesResponse(); dynamic myState = null; dynamic mySledId = null; this.argVal.TryGetValue('s', out myState); try { if (this.argVal.ContainsKey('a')) { if ((uint)myState == 0) { myResponses = WcsCli2CmConnectionManager.channel.SetAllBladesDefaultPowerStateOff(); } else if ((uint)myState == 1) { myResponses = WcsCli2CmConnectionManager.channel.SetAllBladesDefaultPowerStateOn(); } else { Console.WriteLine("Invalid power state."); return; } } else if (this.argVal.ContainsKey('i')) { this.argVal.TryGetValue('i', out mySledId); if ((uint)myState == 0) { myResponse = WcsCli2CmConnectionManager.channel.SetBladeDefaultPowerStateOff((int)mySledId); } else if ((uint)myState == 1) { myResponse = WcsCli2CmConnectionManager.channel.SetBladeDefaultPowerStateOn((int)mySledId); } else { Console.WriteLine("Invalid power state."); return; } } } 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.bladeResponseCollection.Count(); index++) { if (myResponses.bladeResponseCollection[index].completionCode == Contracts.CompletionCode.Success) { if ((uint)myState == 0) { Console.WriteLine("Blade " + myResponses.bladeResponseCollection[index].bladeNumber + ":OFF"); } else if ((uint)myState == 1) { Console.WriteLine("Blade " + myResponses.bladeResponseCollection[index].bladeNumber + ":ON"); } } else if (myResponses.bladeResponseCollection[index].completionCode == Contracts.CompletionCode.Unknown) { Console.WriteLine("Blade " + myResponses.bladeResponseCollection[index].bladeNumber + ": " + WcsCliConstants.bladeStateUnknown); } else { Console.WriteLine("Blade " + myResponses.bladeResponseCollection[index].bladeNumber + ": " + myResponses.bladeResponseCollection[index].completionCode.ToString()); } } } else { if (myResponse.completionCode == Contracts.CompletionCode.Success) { if ((uint)myState == 0) { Console.WriteLine("Blade " + myResponse.bladeNumber + ":OFF"); } else if ((uint)myState == 1) { Console.WriteLine("Blade " + myResponse.bladeNumber + ":ON"); } } else if (myResponse.completionCode == Contracts.CompletionCode.Unknown) { Console.WriteLine("Blade " + myResponse.bladeNumber + ": " + WcsCliConstants.bladeStateUnknown); } else { Console.WriteLine("Blade " + myResponse.bladeNumber + ": " + myResponse.completionCode.ToString()); } } }
/// <summary> /// Verify only users member of Operator or Admin is able to execute following command /// </summary> /// <param name="testPassed"></param> /// <param name="bladeIndex"></param> /// <param name="powerLimitValue"></param> /// <param name="failureMessage"></param> /// <param name="roleId"></param> /// <param name="allbladeResponse"></param> private void SetBladPowerLimitByAdminOperator(ref Boolean testPassed, ref int bladeIndex, int powerLimitValue, ref string failureMessage, WCSSecurityRole roleId, out AllBladesResponse allbladeResponse) { BladeResponse bladeResponse; allbladeResponse = TestChannelContext.SetAllBladesPowerLimit(powerLimitValue); foreach (BladeResponse bResponse in allbladeResponse.bladeResponseCollection) { if (!JbodLocations.Contains(bladeIndex) && !EmptyLocations.Contains(bladeIndex)) { if (bResponse.completionCode != CompletionCode.Success && (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator)) { failureMessage = string.Format("Failed to set blade power limit for blade# {0} by {1}", bladeIndex, roleId); CmTestLog.Failure(failureMessage); testPassed = false; } else if (bResponse.completionCode == CompletionCode.Success && (roleId == WCSSecurityRole.WcsCmUser)) { failureMessage = string.Format("wcsUser successfully to set blade power limit for blade# {0}", bladeIndex); CmTestLog.Failure(failureMessage); testPassed = false; } // This must be valid blade, try to set the set power limit bladeResponse = TestChannelContext.SetBladePowerLimit(bladeIndex, powerLimitValue); if (bladeResponse.completionCode != CompletionCode.Success && (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator)) { failureMessage = "Admin/Operator Failed to set power limit."; CmTestLog.Failure(failureMessage); testPassed = false; } else if (bladeResponse.completionCode == CompletionCode.Success && roleId == WCSSecurityRole.WcsCmUser) { failureMessage = "WcsUser shouldn't allow to set the power limit."; CmTestLog.Failure(failureMessage); testPassed = false; } } else { if (JbodLocations.Contains(bladeIndex) && bResponse.completionCode != CompletionCode.CommandNotValidForBlade) { failureMessage = "This must have been a JBOD. it must fail with commandNotValidForBlade for blade# " + bladeIndex; Console.WriteLine(failureMessage); testPassed = false; } if (!EmptyLocations.Contains(bladeIndex)) { // This must be Jbod, send requests for set power limit bladeResponse = TestChannelContext.SetBladePowerLimit(bladeIndex, powerLimitValue); if (bladeResponse.completionCode == CompletionCode.Success && (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator)) { failureMessage = "It must fail with commandNotValidForBlade for blade"; Console.WriteLine(failureMessage); testPassed = false; } } } bladeIndex++; } }
private void powerOnAndSetAllBladesOn() { // SetPowerOn all blades CmTestLog.Info("Powering ON all blades"); AllBladesResponse setAllOnResponse = new AllBladesResponse(); setAllOnResponse = this.TestChannelContext.SetAllPowerOn(); if (setAllOnResponse.completionCode != CompletionCode.Success) { CmTestLog.Failure("SetAllPowerOn: Command returned completionCode " + setAllOnResponse.completionCode); return; } else { CmTestLog.Info(string.Format("Powered On all blades. Thread sleeping for {0} seconds...", CmConstants.BladePowerOnSeconds)); Thread.Sleep(TimeSpan.FromSeconds(CmConstants.BladePowerOnSeconds)); } // SetAllBladesOn CmTestLog.Info("Soft-powering ON all blades"); setAllOnResponse = this.TestChannelContext.SetAllBladesOn(); if (setAllOnResponse.completionCode != CompletionCode.Success) { CmTestLog.Failure("SetAllBladesOn: Command returned completionCode " + setAllOnResponse.completionCode); } else { CmTestLog.Info(string.Format("Soft-powered On all blades. Thread sleeping for {0} seconds...", CmConstants.BladePowerOnSeconds)); Thread.Sleep(TimeSpan.FromSeconds(CmConstants.BladePowerOnSeconds)); } }
/// <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() { dynamic bladeId = null; dynamic defaultPowerCap = null; dynamic waitTime = null; BladeResponse myResponse = new BladeResponse(); AllBladesResponse myResponses = new AllBladesResponse(); try { if (this.argVal.ContainsKey('a') && this.argVal.TryGetValue('c', out defaultPowerCap) && this.argVal.TryGetValue('t', out waitTime)) { myResponses = WcsCli2CmConnectionManager.channel.SetAllBladesPsuAlertDefaultPowerCap( (ushort)defaultPowerCap, (ushort)waitTime); } else if (this.argVal.TryGetValue('i', out bladeId) && this.argVal.TryGetValue('c', out defaultPowerCap) && this.argVal.TryGetValue('t', out waitTime)) { myResponse = WcsCli2CmConnectionManager.channel.SetBladePsuAlertDefaultPowerCap((int)bladeId, (ushort)defaultPowerCap, (ushort)waitTime); } } catch (Exception ex) { SharedFunc.ExceptionOutput(ex); return; } if ((this.argVal.ContainsKey('a') && myResponses == null) || (this.argVal.ContainsKey('a') && myResponses.bladeResponseCollection == null) || myResponse == null) { Console.WriteLine(WcsCliConstants.serviceResponseEmpty); return; } if (this.argVal.ContainsKey('a')) { foreach (var response in myResponses.bladeResponseCollection) { ResponseValidation.ValidateBladeResponse(response.bladeNumber, "psu alert default power cap set", response, true); } } else { ResponseValidation.ValidateBladeResponse(myResponse.bladeNumber, "psu alert default power cap set", myResponse, true); } }
/// <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; BladeResponse myResponse = new BladeResponse(); AllBladesResponse allBladesResponse = new AllBladesResponse(); dynamic myOffTime = null; if (this.argVal.ContainsKey('t')) { this.argVal.TryGetValue('t', out myOffTime); } else { myOffTime = WcsCliConstants.powercycleOfftime; } try { if (this.argVal.ContainsKey('a')) { allBladesResponse = WcsCli2CmConnectionManager.channel.SetAllBladesActivePowerCycle((uint)myOffTime); } else if (this.argVal.ContainsKey('i')) { dynamic mySledId = null; this.argVal.TryGetValue('i', out mySledId); sledId = (uint)mySledId; myResponse = WcsCli2CmConnectionManager.channel.SetBladeActivePowerCycle((int)mySledId, (uint)myOffTime); } } catch (Exception ex) { SharedFunc.ExceptionOutput(ex); return; } if ((this.argVal.ContainsKey('a') && allBladesResponse == null) || myResponse == null) { Console.WriteLine(WcsCliConstants.serviceResponseEmpty); return; } if (this.argVal.ContainsKey('a')) { if (allBladesResponse.completionCode == Contracts.CompletionCode.Success) { for (int index = 0; index < allBladesResponse.bladeResponseCollection.Count(); index++) { if (ResponseValidation.ValidateBladeResponse(allBladesResponse.bladeResponseCollection[index].bladeNumber, null, allBladesResponse.bladeResponseCollection[index], false)) { Console.WriteLine(WcsCliConstants.commandSuccess + " Blade " + allBladesResponse.bladeResponseCollection[index].bladeNumber + ": OK"); } } } else { // Display error if not Success/Unknown Console.WriteLine(WcsCliConstants.commandFailure + " Completion code: " + allBladesResponse.completionCode.ToString()); } } else { ResponseValidation.ValidateBladeResponse(myResponse.bladeNumber, null, myResponse, true); } }