Currently the scenario object supports an interface where you can immediately apply user agent instance variables (which eventually translate to cmd paramaters) via the MultiAccess type with syntax:
def pysipp_conf_scen(scen):
scen.agents.sockaddr = ('10.10.8.1', 5060)
scen.clients.timeout = 10000
The agents attr here references the entire scenario agent set and applies the named variable for all contained agents immediately in a loop. Getting the same attribute will result in a returned dictionary who's keys are the agent names and values are the accessed value per agent. This __getattr__/__setattr__ is not only asymmetric but unintuitive.
@vodik has suggested something similar to the requests.session interface.
I propose the following:
Scenario.agents, clients, servers simply become dict objects which can contain optional parameter (attribute) overrides. The keys can be any attribute of a pysipp.agent.UserAgent and values act as defaults.
clients and servers values (which are mutex) will override agents values and attributes set directly on a UserAgent will always take the highest precedence.
pysipp.agent.Scenario will get a prepare method similar to prepared-requests. This method takes in a single UserAgent and returns a copy of that agent now modified as per the params overrides from above such that can be used in place of the original. Scenario.__call__ will of course call prepare on each contained agent before invoking the run protocol hook with the full agent set.
- the default
pysipp_run_protocol hook will be changed to take in an agents sequence argument instead of a scen arg and accordingly the runner arg must be explicitly provided by the caller.
- the
launch.PopenRunner will be modified to remove it's agents arg to __init__ and instead take in a cmditems arg to __call__ such that the entire object becomes 'agent' agnostic and is only concerned with running commands.
Currently the scenario object supports an interface where you can immediately apply user agent instance variables (which eventually translate to cmd paramaters) via the
MultiAccesstype with syntax:The
agentsattr here references the entire scenario agent set and applies the named variable for all contained agents immediately in a loop. Getting the same attribute will result in a returned dictionary who's keys are the agent names and values are the accessed value per agent. This__getattr__/__setattr__is not only asymmetric but unintuitive.@vodik has suggested something similar to the
requests.sessioninterface.I propose the following:
Scenario.agents,clients,serverssimply become dict objects which can contain optional parameter (attribute) overrides. The keys can be any attribute of apysipp.agent.UserAgentand values act as defaults.clientsandserversvalues (which are mutex) will overrideagentsvalues and attributes set directly on aUserAgentwill always take the highest precedence.pysipp.agent.Scenariowill get apreparemethod similar to prepared-requests. This method takes in a singleUserAgentand returns a copy of that agent now modified as per theparamsoverrides from above such that can be used in place of the original.Scenario.__call__will of course callprepareon each contained agent before invoking the run protocol hook with the full agent set.pysipp_run_protocolhook will be changed to take in anagentssequence argument instead of ascenarg and accordingly therunnerarg must be explicitly provided by the caller.launch.PopenRunnerwill be modified to remove it'sagentsarg to__init__and instead take in acmditemsarg to__call__such that the entire object becomes 'agent' agnostic and is only concerned with running commands.