Beispiel #1
0
        public static void ParseActionResult(NewPayLoad RC, Act actPlugin)
        {
            // After we send it we parse the driver response
            if (RC.Name == "ActionResult")
            {
                // We read the ExInfo, Err and output params
                actPlugin.ExInfo = RC.GetValueString();
                string error = RC.GetValueString();
                if (!string.IsNullOrEmpty(error))
                {
                    actPlugin.Error += error;
                    actPlugin.Status = Execution.eRunStatus.Failed;
                    return;
                }

                List <NewPayLoad> OutpuValues = RC.GetListPayLoad();
                foreach (NewPayLoad OPL in OutpuValues)
                {
                    //    //TODO: change to use PL AddValueByObjectType

                    //    // it is param name, type and value
                    string PName            = OPL.GetValueString();
                    string path             = OPL.GetValueString();
                    string mOutputValueType = OPL.GetValueEnum();

                    switch (mOutputValueType)
                    {
                    case nameof(Amdocs.Ginger.CoreNET.RunLib.NodeActionOutputValue.OutputValueType.String):
                        string stringValue = OPL.GetValueString();
                        actPlugin.AddOrUpdateReturnParamActualWithPath(PName, stringValue, path);
                        break;

                    case nameof(Amdocs.Ginger.CoreNET.RunLib.NodeActionOutputValue.OutputValueType.ByteArray):
                        byte[] b = OPL.GetBytes();
                        //actPlugin.ReturnValues.Add(new ActReturnValue() { Param = PName, Path= path, Actual = "aaaaaaa" });   //FIXME!!! when act can have values types
                        actPlugin.AddOrUpdateReturnParamActualWithPath(PName, "aaa", path);       //FIXME!!! when act can have values types
                        break;

                    default:
                        throw new Exception("Unknown param type: " + mOutputValueType);
                    }
                }
            }


            else
            {
                // The RC is not OK when we faced some unexpected exception
                //TODO:
                string Err = RC.GetValueString();
                actPlugin.Error += Err;
            }
        }
Beispiel #2
0
        bool RSTFound; // set to true if and when an RST packet found

        #endregion Fields

        #region Constructors

        public TCPG(Packet pkt, H h)
            : base(pkt)
        {
            // note: base class constructor is called first (due to : base(pkt) above)

            TCPH th = (TCPH)h;

            // set group properties here

            S1IP4 = pkt.SrcIP4;
            S1Port = pkt.SrcPort;
            S2IP4 = pkt.DestIP4;
            S2Port = pkt.DestPort;

            // SET ADDITIONAL GROUP PROPERTIES AS NECESSARY
            OPL1 = new OPL(this, S1Port);
            OPL2 = new OPL(this, S2Port);
            State = TCPGState.NotSequencedYet;
            RSTFound = false;
        }
Beispiel #3
0
        public void RunAction(GingerAction GA)
        {
            // Here we decompose the GA and create Payload to transfer it to the agent
            NewPayLoad PL = new NewPayLoad("RunAction");

            PL.AddValue(GA.ID);
            List <NewPayLoad> Params = new List <NewPayLoad>();

            foreach (ActionParam AP in GA.InputParams.Values)
            {
                // TODO: use const
                NewPayLoad p = new NewPayLoad("P");   // To save network trafic we send just one letter
                p.AddValue(AP.Name);
                p.AddValue(AP.Value.ToString());
                p.ClosePackage();
                Params.Add(p);
            }

            PL.AddListPayLoad(Params);
            PL.ClosePackage();

            // TODO: use function which goes to local grid or remote grid
            NewPayLoad RC = SendRequestPayLoad(PL);

            // After we send it we parse the driver response

            if (RC.Name == "ActionResult")
            {
                // We read the ExInfo, Err and output params
                GA.ExInfo = RC.GetValueString();
                string Error = RC.GetValueString();
                if (!string.IsNullOrEmpty(Error))
                {
                    GA.AddError("Driver", RC.GetValueString());   // We need to get Error even if Payload is OK - since it might be in
                }

                List <NewPayLoad> OutpuValues = RC.GetListPayLoad();
                foreach (NewPayLoad OPL in OutpuValues)
                {
                    //TODO: change to use PL AddValueByObjectType

                    // it is param name, type and value
                    string PName            = OPL.GetValueString();
                    string mOutputValueType = OPL.GetValueEnum();

                    switch (mOutputValueType)
                    {
                    case nameof(OutputValueType.String):
                        string v = OPL.GetValueString();
                        GA.Output.Values.Add(new ActionOutputValue()
                        {
                            Param = PName, ValueString = v
                        });
                        break;

                    case nameof(OutputValueType.ByteArray):
                        byte[] b = OPL.GetBytes();
                        GA.Output.Values.Add(new ActionOutputValue()
                        {
                            Param = PName, ValueByteArray = b
                        });
                        break;

                    default:
                        throw new Exception("Unknown param type: " + mOutputValueType);
                    }
                }
            }
            else
            {
                // The RC is not OK when we faced some unexpected exception
                //TODO:
                string Err = RC.GetValueString();
                GA.AddError("RunAction", Err);
            }
        }