-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a requests-like interface to pysipp.agent.Scenario #4
Comments
The last bullet is completed by 18b560b |
Looking at making requests it seems to me that there really isn't a parallel between That is, In terms of applying command parameters more globally might (some of) the following be appropriate? # these set the 'global' scenario state
scen.global.sockaddr = ('10.10.8.1', 5060)
scen.global['sockaddr'] = ('10.10.8.1', 5060)
scen.global.update({'sockaddr': ('10.10.8.1', 5060)})
# sets clients group state
scen.clients.sockaddr = ('10.10.8.1', 5060)
scen.clients['sockaddr'] = ('10.10.8.1', 5060)
scen.clients.update({'sockaddr': ('10.10.8.1', 5060)})
# passed in at run time but not saved permanently
allagents = {
'sockaddr': ('10.10.8.1', 5060),
'key_vals': {'domainstr': '[email protected]:5060'},
}
clients = {'sockaddr': ('10.10.8.2', 5060)}
# run the scenario by invoking all commands
scen(block=False, timeout=10, global=allagents, clients=clients) Also any opinion on whether the The scenario api could look like: scen = pysipp.scenario(global=agents, clients=clients)
# create a default ua pair
uas = pysipp.server(sockaddr=(<ip>, <port>))
uac = pysipp.client(*uas.sockaddr, sockaddr=(<ip>, <port>))
# assign agents to the scenario in launch order
scen.agents = [uas, uac]
# could also have be added at instance time
scen = pysipp.scenario(agents=[uas, uac], global=allagents, clients=clients)
# don't add to `agents` but modify with params and return (copy?)
# this is always done at run time for each agent?
prepped_uac = scen.prepare_agent(uac)
# maybe allow passing agents at call time as well?
# means passed agents are run in place of contained ones?
scen(agents=[uas, uac], block=False, timeout=10, global=agents, clients=clients) For the hook api I agree that we should definitely have: def pysipp_conf_scen(agents, scen):
agents['some wild UAC name'].sockaddr = (<ip>, <port>)
scen.global.timeout = 10000 ^ Looking for some serious feedback here... |
How about: def pysipp_conf_scen(agents, scen):
agents['some wild UAC name'].sockaddr = (<ip>, <port>)
scen.timeout = 10000 Less typing. You can keep the |
+1 |
For the for |
Works for me. |
For the record I ended up going with: def pysipp_conf_scen(scen):
scen.defaults.sockaddr = ('10.10.8.1', 5060)
scen.clientdefaults.timeout = 10000
|
Closed by dbe28b1 |
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: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 apysipp.agent.UserAgent
and values act as defaults.clients
andservers
values (which are mutex) will overrideagents
values and attributes set directly on aUserAgent
will always take the highest precedence.pysipp.agent.Scenario
will get aprepare
method similar to prepared-requests. This method takes in a singleUserAgent
and returns a copy of that agent now modified as per theparams
overrides from above such that can be used in place of the original.Scenario.__call__
will of course callprepare
on each contained agent before invoking the run protocol hook with the full agent set.pysipp_run_protocol
hook will be changed to take in anagents
sequence argument instead of ascen
arg and accordingly therunner
arg must be explicitly provided by the caller.launch.PopenRunner
will be modified to remove it'sagents
arg to__init__
and instead take in acmditems
arg to__call__
such that the entire object becomes 'agent' agnostic and is only concerned with running commands.The text was updated successfully, but these errors were encountered: