This package can be used to execute OpenSIPS Management Interface (MI) commands.
The following communication types are supported:
http- uses the HTTP protocol to communicate with the MI interface. Requires theurlparameter to be set.datagram- uses the UDP protocol to communicate with the MI interface. Requires thedatagram_ipanddatagram_portparameters to be set.fifo- uses a FIFO file to communicate with the MI interface. Requires 3 parameters:fifo_file,fifo_file_fallbackandfifo_reply_dir.
To instantiate the OpenSIPSMI class, you need to provide the communication type and the required parameters in a key-value format. For example:
mi = OpenSIPSMI('http', url='http://localhost:8888/mi')
# or
mi = OpenSIPSMI('datagram', datagram_ip='127.0.0.1', datagram_port=8080)
# or
mi = OpenSIPSMI('fifo', fifo_file='/tmp/opensips_fifo', fifo_file_fallback='/tmp/opensips_fifo_fallback', fifo_reply_dir='/tmp/opensips/')By default, fifo communication type is used with the following parameters:
fifo_file-/var/run/opensips/opensips_fifofifo_file_fallback-/tmp/opensips_fifofifo_reply_dir-/tmp
The OpenSIPSMI class provides the following methods:
execute- to run an MI command and get the response. If an error occurs, anOpenSIPSMIExceptionis raised.valid- to check if the MI connection is valid. Returns a tuple with a boolean value and a list of error messages.