protected bool GetAllBladesInfo(out GetAllBladesInfoResponse allBladesInfoResponse, [CallerMemberName] string testName = null) { // if the blade info has already been cached // just return it. if (this.allBladesInfo != null) { allBladesInfoResponse = this.allBladesInfo; return true; } try { CmTestLog.Info("Trying to get the information for all blades", testName); if (!this.SetPowerState(PowerState.ON) || !this.SetBladeState(PowerState.ON)) { allBladesInfoResponse = null; return false; } allBladesInfoResponse = this.Channel.GetAllBladesInfo(); if (CompletionCode.Success != allBladesInfoResponse.completionCode) { CmTestLog.Failure("Failed to get all blades info", testName); return false; } CmTestLog.Success("Get all blades info successfully", testName); this.allBladesInfo = allBladesInfoResponse; // save it return true; } catch (Exception e) { CmTestLog.Exception(e, testName); allBladesInfoResponse = null; return false; } }
/// <summary> /// Get information for all blades /// </summary> /// <returns>Array of blade info response</returns> public GetAllBladesInfoResponse GetAllBladesInfo() { byte maxbladeCount = (byte)ConfigLoaded.Population; Tracer.WriteInfo("Received GetAllBladesInfo()"); Tracer.WriteUserLog("Invoked GetAllBladesInfo()"); // Server side class structure to populate blade information GetAllBladesInfoResponse responses = new GetAllBladesInfoResponse(); responses.completionCode = Contracts.CompletionCode.Unknown; responses.statusDescription = string.Empty; responses.bladeInfoResponseCollection = new List<BladeInfoResponse>(); Contracts.CompletionCode[] bladeInternalResponseCollection = new Contracts.CompletionCode[maxbladeCount]; Tracer.WriteInfo("GetAllBladesInfo: Processing Blades "); // Loop to populate blade information for requested number of blades for (int loop = 0; loop < maxbladeCount; loop++) { int bladeId = loop + 1; // we need to get for all blades //Call getBladeInfo for the Blade ID responses.bladeInfoResponseCollection.Add(this.GetBladeInfo(bladeId)); // Set the internal blade response to the blade completion code. bladeInternalResponseCollection[loop] = responses.bladeInfoResponseCollection[loop].completionCode; } Tracer.WriteInfo("GetAllBladesInfo: Completed populating for Blades"); Contracts.ChassisResponse varResponse = new Contracts.ChassisResponse(); varResponse = ChassisManagerUtil.ValidateAllBladeResponse(bladeInternalResponseCollection); responses.completionCode = varResponse.completionCode; responses.statusDescription = varResponse.statusDescription; return responses; }
public TestsResultResponse VerifyBladesInfo(string skuxmlFile, int index = 1701) { GetAllBladesInfoResponse allBladesInfo = new GetAllBladesInfoResponse(); string failureMessage = string.Empty; string firmwareVer; string hardmwareVer; //read the expected values for firmware and hardware versions string skuDefinition = skuxmlFile; using (XmlReader xr = XmlReader.Create(skuDefinition)) { xr.ReadToFollowing("firmwareVersion"); firmwareVer = xr.ReadString(); xr.ReadToFollowing("hardwareVersion"); hardmwareVer = xr.ReadString(); } //Verify blade info Console.WriteLine("\n!!!!!!!!! Starting verificatgion of blades info"); // Only health for specified blade is needed. if (index != 1701) { allBladesInfo.bladeInfoResponseCollection.Add(this.Channel.GetBladeInfo(index)); } else { allBladesInfo = this.Channel.GetAllBladesInfo(); } foreach (BladeInfoResponse binfo in allBladesInfo.bladeInfoResponseCollection) { if (!this.EmptySlots.Contains(binfo.bladeNumber) && binfo.completionCode != CompletionCode.Success) { failureMessage = "\n!!! Blade Information failure: Failed to get blade information."; Console.WriteLine(failureMessage); return new TestsResultResponse(ExecutionResult.Failed, failureMessage); } if (!this.EmptySlots.Contains(binfo.bladeNumber) && binfo.bladeType.Equals("Server") && !(binfo.firmwareVersion.Equals(firmwareVer))) { failureMessage = string.Format("\n!!! Blade Information failure: Failed to verifiy Firmware version for blade# {0}", binfo.bladeNumber); Console.WriteLine(failureMessage); return new TestsResultResponse(ExecutionResult.Failed, failureMessage); } if (!this.EmptySlots.Contains(binfo.bladeNumber) && binfo.bladeType.Equals("Server") && binfo.hardwareVersion != hardmwareVer) { failureMessage = string.Format("\n!!! Blade Information failure: Failed to verify Hardware version for blade# {0}", binfo.bladeNumber); Console.WriteLine(failureMessage); return new TestsResultResponse(ExecutionResult.Failed, failureMessage); } if (!this.EmptySlots.Contains(binfo.bladeNumber) && binfo.macAddress.First<NicInfo>().completionCode != CompletionCode.Success && binfo.bladeType.Equals("Server")) { failureMessage = string.Format("\n!!! Blade Information failure: failed to get NicInfo for blade# {0}", binfo.bladeNumber); Console.WriteLine(failureMessage); return new TestsResultResponse(ExecutionResult.Failed, failureMessage); } if (!this.EmptySlots.Contains(binfo.bladeNumber) && string.IsNullOrEmpty(binfo.macAddress.First<NicInfo>().macAddress) && binfo.bladeType.Equals("Server")) { failureMessage = string.Format("\n!!! Blade Information failure: Failed to verify macaddress for blade# {0}", binfo.bladeNumber); Console.WriteLine(failureMessage); return new TestsResultResponse(ExecutionResult.Failed, failureMessage); } if (!this.EmptySlots.Contains(binfo.bladeNumber) && string.IsNullOrEmpty(binfo.serialNumber)) { failureMessage = string.Format("\n!!! Blade Information failure: Failed to verify SerialNumber for blade# {0}", binfo.bladeNumber); Console.WriteLine(failureMessage); return new TestsResultResponse(ExecutionResult.Failed, failureMessage); } } Console.WriteLine("\n++++++++++++++++++++++++++++++++"); failureMessage = "\n!!!!!!!!! Successfully finished execution of CheckBladesinfo tests."; Console.WriteLine(failureMessage); return new TestsResultResponse(ExecutionResult.Passed, failureMessage); }
private void PowerOffRandomBlade(GetAllBladesInfoResponse allBladesInfoResponse, out int[] nonEmptyBlades, out int powerOffBladeId) { // power off a random blade nonEmptyBlades = allBladesInfoResponse .bladeInfoResponseCollection .Where(blade => !string.IsNullOrWhiteSpace(blade.bladeType)) .Select(blade => blade.bladeNumber) .ToArray(); powerOffBladeId = nonEmptyBlades.RandomOrDefault(); CmTestLog.Info(string.Format("Trying to power off Blade# {0}", powerOffBladeId)); if (!this.SetPowerState(PowerState.OFF, powerOffBladeId)) { throw new ApplicationException("Not able to power off the blade"); } }
/// <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() { BladeInfoResponse myPacket = new BladeInfoResponse(); GetAllBladesInfoResponse myPackets = new GetAllBladesInfoResponse(); try { if (this.argVal.ContainsKey('a')) { myPackets = WcsCli2CmConnectionManager.channel.GetAllBladesInfo(); } else if (this.argVal.ContainsKey('i')) { dynamic mySledId = null; this.argVal.TryGetValue('i', out mySledId); myPacket = WcsCli2CmConnectionManager.channel.GetBladeInfo((int)mySledId); } } catch (Exception ex) { SharedFunc.ExceptionOutput(ex); return; } if ((this.argVal.ContainsKey('a') && myPackets == null) || (myPacket == null)) { Console.WriteLine(WcsCliConstants.serviceResponseEmpty); return; } if (this.argVal.ContainsKey('a')) { for (int index = 0; index < myPackets.bladeInfoResponseCollection.Count(); index++) { Console.WriteLine("======================= Blade {0} ========================", myPackets.bladeInfoResponseCollection[index].bladeNumber); printGetscinfoPacket(myPackets.bladeInfoResponseCollection[index]); } } else { printGetscinfoPacket(myPacket); } }