-
Notifications
You must be signed in to change notification settings - Fork 0
API Documentation
class
This class represents the Osmocom Control Interface connection, and is used to GET and SET vars.
Parameters:
-
server (
str) - The IP address of the Osmocom Control Interface host. -
port (
int) - The port of the Osmocom Control Interface. -
timeout (
int|10) - The maximum time to wait for a response to a message. Defaults to 10 seconds.
Properties:
-
TRAPS (
list) - A list of TRAP messages received over the lifetime of theCtrlInterface()object.
Note: Retrieval of TRAP messages is handled by popping all messages out of the
TRAPSlist. This means that the list is functionally a queue, and is emptied when called.
Usage Example:
ctrl = CtrlInterface('127.0.0.1', 4259)method
Get a variable via the Osmocom Control Interface.
Parameters:
-
var (
str) - The variable to retrieve. -
parse_val (
bool|True) - Should the returned value be parsed? Defaults toTrue.
Note: When
parse_valisTrue,pyosmoctrlattempts to parse the response value from the CTRL interface into a dict.Given the non-standard responses returned by the CTRL interface, this may sometimes fail. This option is provided so that the raw unparsed string response can be returned, if required.
Usage Example:
ctrl = CtrlInterface('127.0.0.1', 4259)
ctrl.get('subscriber.by-id-1.info-all')method
Set a variable via the Osmocom Control Interface.
Parameters:
-
var (
str) - The variable to set. -
val (
str) - The new value of the variable. -
parse_val (
bool|True) - Should the returned value be parsed? Defaults toTrue.
Note: When
parse_valisTrue,pyosmoctrlattempts to parse the response value from the CTRL interface into a dict.Given the non-standard responses returned by the CTRL interface, this may sometimes fail. This option is provided so that the raw unparsed string response can be returned, if required.
Usage Example:
ctrl = CtrlInterface('127.0.0.1', 4259)
ctrl.set('subscriber.by-id-1.msisdn', '123')exception
Raised when the control interface returns an error.
Arguments:
-
decoded_ctrl_msg['outcome'] (
str) - The returned "operation". -
decoded_ctrl_msg['reason'] (
str) - The error reason text, if available. -
decoded_ctrl_msg (
dict) - The full returned message.
Example:
pyosmoctrl.osmoctrl.CtrlError: ('ERROR', 'No such subscriber.', {'outcome': 'ERROR', 'cmd_id': '2753991230658678373', 'reason': 'No such subscriber.'})