Beispiel #1
0
        /// <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());
                }
            }
        }
        /// <summary>
        /// Get all blades soft power state
        /// </summary>
        /// <returns>Blade state response class object</returns>
        public GetAllBladesStateResponse GetAllBladesState()
        {
            byte MaxbladeCount = (byte)ConfigLoaded.Population;

            GetAllBladesStateResponse responses = new GetAllBladesStateResponse();
            responses.completionCode = Contracts.CompletionCode.Unknown;
            responses.statusDescription = string.Empty;
            responses.bladeStateResponseCollection = new List<BladeStateResponse>();
            Contracts.CompletionCode[] bladeInternalResponseCollection = new Contracts.CompletionCode[MaxbladeCount];
            uint bladeCount = MaxbladeCount;

            Tracer.WriteUserLog("Invoked GetAllBladesState()");
            Tracer.WriteInfo("Invoked GetAllBladesState()");

            for (int loop = 0; loop < bladeCount; loop++)
            {
                responses.bladeStateResponseCollection.Add(GetBladeState(loop + 1));
                Tracer.WriteInfo("Blade state: ", responses.bladeStateResponseCollection[loop].bladeState);

                // Set the internal blade response to the blade completion code.
                bladeInternalResponseCollection[loop] = responses.bladeStateResponseCollection[loop].completionCode;
            }

            Contracts.ChassisResponse varResponse = new Contracts.ChassisResponse();
            varResponse = ChassisManagerUtil.ValidateAllBladeResponse(bladeInternalResponseCollection);
            responses.completionCode = varResponse.completionCode;
            responses.statusDescription = varResponse.statusDescription;
            return responses;
        }
        /// <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 + ": --");
                    }
                }
            }
        }