Use a loop instead. Without it the script will eventually crash with a
RecursionError.
File "/usr/bin/osmo_trap2cgi.py", line 211, in conn_client
await ctrl_client(proxy, reader, writer)
File "/usr/bin/osmo_trap2cgi.py", line 202, in ctrl_client
proxy.dispatch(wr, data)
[...]
File "/usr/bin/osmo_trap2cgi.py", line 202, in ctrl_client
proxy.dispatch(wr, data)
File "/usr/bin/osmo_trap2cgi.py", line 201, in ctrl_client
[...]
RecursionError: maximum recursion depth exceeded in comparison
Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c
Related: SYS#4399
* Install systemd file with debian
* Depend on python3-aiohttp in python3-osmopy-utils as it is required
for osmo-trap2cgi
Related: SYS#4399
Sponsored-by: On-Waves ehf
Change-Id: I6add5f37b63dd5fcfdefe0459b539e0050d03897
* split hash generation into simpler functions
* move them into helper file
* split log init into separate function
This facilitates code sharing with new version of ctrl2cgi proxy in
folow-up patches.
Change-Id: Ic5c349349d2c246f934d6701435b1a2d9de77de1
Related: SYS#4399
It might be removed in one of the future releases as we move away from
Twisted. Let's mark it as deprecated to make sure it won't be a
surprise.
Change-Id: Iefd69e7712d456e3bc42c3277bbfa103a2448bb6
Previously we've tried to determine the type of TRAP and handle as many
as possible via generic method dispatcher similar to parent class. Let's
make code simpler by explicitly ignoring all but 'location-state'
TRAPs. This should also reduce debug log output because we'll only log
the TRAP variable for ignored messages instead of entire content.
Change-Id: I42b715cb82eb309950ff387649726504b6c7cf61
Related: SYS#4399
Save and propagate separate timestamp for HTTP request duration to
distinguish between time spent waiting on connection limit availability
from actual http request time.
Change-Id: I14d1db5206864ac9ab7c64f96f67139113ab3fcf
Related: SYS#4399
osmo-mgw's configure.ac won't find osmotestvty.py, unless it is
executable. This allows passing its ./configure with placing the scripts
dir of osmo-python-tests in PATH, instead of installing it.
Change-Id: If6cefd32d0dc544093db08efc114db86b9bb18b0
The same messages are better handled in derived classes using
message-specific functions instead of generic dispatchers.
Change-Id: I4a054eec9ef7ab39e15ac0cd64834a251d4fb2d7
Log repr() of error because it's more conscience which makes it easier to
read the logs: in case of "e" there's additional
"Failure instance: Traceback (failure with no frames)" prefix which is
pretty useless because we won't have proper tracebacks for deferred anyway.
Change-Id: I39870b83cacee9a589636974d04e356ef0d32345
Log http request timestamp and duration on debug loglevel. This is
especially helpful while troubleshooting issues with multiple concurrent
requests under significant load while network issues are present.
Change-Id: I11c8ac67a2730a9c6912694e5b83bbdf08fe357d
Related: SYS#4399
Log the basic location-state trap triggering request and command reply
as info level - that way we can receive useful information without
turning on full debug output.
Change-Id: If8eae9f36292930571954becf6613fada43d301c
When receiving commands for particular BSC, log BSC id known at the time
when request was made, not the one which is part of the reply.
Change-Id: I6acdfddb9a1132f978f2b55c769559b0c29eb3e8
Manual acquire()/release() of semaphore does not limit number of
concurrent requests when combined with explicit yield. Fix this by using
semaphore.run() and removing inilineCallbacks decorator.
Change-Id: I47b8b9f5b726ca0905bb7c023d63b325c7f7d85f
Related: SYS#4399
Previously command-line arguments without defaults took precedence over
config file variables while values from config file which had
command-line counterparts with default value were silently ignored.
Let's fix this by making config file option mandatory values and
removing overlap between command-line and config file parameters.
Change-Id: I471b5a6497eadce6456e835233fdaba88a593324
Related: SYS#4399
Since the scripts are intended to be used as systemd services, there's
no need in separate logging via syslog: systemd will take care of
properly collecting and storing script output. Hence we can drop extra
options and function parameters.
Change-Id: Ifcad1877d45d43b3a2e617775a1c9b256e190591
Related: SYS#4399
* reorder imports to make pylint3 happy
* drop unused imports
* use proper spacing for list constants
* don't use reserved names for internal variables
The check was run as follows:
pylint3 -d C0103,C0301,C0410,C0326,R0913,R0901 ...
to disable useless warnings.
Change-Id: I5b90ee790f73dc509081401776911f25e43f1801
Previously handle_reply() was marked as deferred callback unlike soap.py
where it's synchronous function. This seems to be causing issues where
some of the callbacks are not yield properly. Let's move to the
known-to-work semantics of soap.py where async functions are limited to
Trap() class.
Change-Id: Ib2c28dd7f79cbd28d475de93750703659ddd18f1
Related: SYS#4399
Sometimes when we set variable we might receive arbitrary number of TRAP
messages before we get SET_REPLY. Those could be either separate
messages or combined together with SET_REPLY depending on tcp buffering
at server side. Let's handle this gracefully by skipping over all TRAP
messages.
An example command which often triggers this behavior:
./osmo_ctrl.py -s -d 127.0.0.1 -p 4249 bts.0.location (date +%s)",fix2d,1,2,3"
Change-Id: Ia6de02c2f13a56f0381c97a9ab02c6c7a31cc32f
Related: SYS#4399
This allows to easy skip TRAP messages when we do not want to process
them (for example when waiting for REPLY to a single command). Update
documentation and version accordingly.
Change-Id: I51ce207c19a1ca96c3e2af7d5efd64f79b02fbb4
After further testing it turns out that Trap() have too many
implementation details which makes it cumbersome to be shared. Instead,
it's easier to make it into wrapper over shared functions.
Change-Id: I8a3c62bcdf4286f8127c5b6d8dee6d740aca23b9
Due to changes getting out of sync, changes from
I44035323b70f04eb8f5dc12123cb708f53eba188 and
I21ff593be420a374a00073953c9254a013c43164 were overwritten by
I7b59f2dbded9074d15f2d2f40bf5a92ed02601e2 moving code to different
file. Fix this by re-applying those changes in new location.
Change-Id: I811f307ded63e7e1544243921ee07dceae81e295
The ctrl2cgi.py is heavily based upon soap.py - let's move all the
shared code into separate file to make further modifications easier.
Change-Id: I7b59f2dbded9074d15f2d2f40bf5a92ed02601e2
Related: SYS#4399
RSPRO (Remote Sim PROtocol) is used by osmo-remsim and basd on the IPA
multiplex. Let's add knowledge about this stream identifier to osmopy.
Change-Id: I5c0e674390c5672ee1083b1226c206557f6a980b
systemd errors due to executabl path not being absolute:
systemd[1]: [/lib/systemd/system/osmo-ctrl2cgi.service:7] Executable path is not absolute, ignoring: python3 /usr/bin/ctrl2cgi.py
systemd[1]: osmo-ctrl2cgi.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Change-Id: I8e3d695951fb36d53c112b6dce10a275b757ca5a
If the VTY/CTRL output contains trailing newlines, do not cause those to
trigger mismatch errors, rather drop those.
Rationale: in transcript scripts, the amount of empty lines between expected
results is ignored, to allow cosmetically arranging into sections. So trailing
newlines are dropped, and there is no way to preserve those.
Change-Id: I1930868451c5738b17e318a9807590d948210b9a
Because the VTY logging target currently prints '\n\r' instead of '\r\n', the
python splitlines() separates those as interleaving empty lines. Ignore '\r' to
allow verifying VTY logging output as well.
Change-Id: I8de9cebaa9aad275f65c3672985b7cbca343b5a6
This scripts implements a similar proxy to the one already available in
soapy.py, but aiming at converting CTRl into a regular HTTP POST Request
to be handled by a CGI script in the HTTP server.
Furthermore, it includes several improvements over the soapy.py script,
such as using a token to authenticate users and capability to read some
parameters from a cfg file.
Change-Id: I7a83ecb379835e295c8cb4c27c39883783746544
twisted_ipa is a module expected to be used by other python scripts, so
move it to osmopy dir to be installed as a lib (in python path) so it
can be later used.
twisted_ipa has some features to use it standalone for testing purposes.
This feature can still be used from new installation path.
Change-Id: I33a0c4263297abd9e111bf43e6e9967c06474318
This allows us to package osmopy as debian package.
The package currently includes both the library as well as the
executables/scripts. It might make sense to separate that into
a pure library package and an "utils" package
Related: SYS#3028
Change-Id: I332fb82d0e8dd09c5cf53caafa6a63297a8e3881