Code Monkey home page Code Monkey logo

opensips-cli's Introduction

OpenSIPS CLI (Command Line Interface)

OpenSIPS CLI is an interactive command line tool that can be used to control and monitor OpenSIPS SIP servers. It uses the Management Interface exported by OpenSIPS over JSON-RPC to gather raw information from OpenSIPS and display it in a nicer, more structured manner to the user.

The tool is very flexible and has a modular design, consisting of multiple modules that implement different features. New modules can be easily added by creating a new module that implements the OpenSIPS CLI Module Interface.

OpenSIPS CLI is an interactive console that features auto-completion and reverse/forward command history search, but can also be used to execute one-liners for automation purposes.

OpenSIPS CLI can communicate with an OpenSIPS server using different transport methods, such as fifo or http.

Compatibility

This tool uses the new JSON-RPC interface added in OpenSIPS 3.0, therefore it can only be used with OpenSIPS versions higher than or equal to 3.0. For older versions of OpenSIPS, use the classic opensipsctl tool from the opensips project.

Usage

Tool

Simply run opensips-cli tool directly in your cli. By default the tool will start in interactive mode.

OpenSIPS CLI accepts the following arguments:

  • -h|--help - used to display information about running opensips-cli
  • -v|--version - displays the version of the running tool
  • -d|--debug - starts the opensips-cli tool with debugging enabled
  • -f|--config - specifies a configuration file (see Configuration Section for more information)
  • -i|--instance INSTANCE - changes the configuration instance (see Instance Module Documentation for more information)
  • -o|--option KEY=VALUE - sets/overwrites the KEY configuration parameter with the specified VALUE. Works for both core and modules parameters. Can be used multiple times, for different options
  • -x|--execute - executes the command specified and exits

In order to run opensips-cli without installing it, you have to export the PYTHONPATH variable to the root of the opensipscli package. If you are in the root of the project, simply do:

export PYTHONPATH=.
bin/opensips-cli

Python Module

The module can be used as a python module as well. A simple snippet of running an MI command using the tool is:

from opensipscli import cli

opensipscli = cli.OpenSIPSCLI()
print(opensipscli.mi('ps'))

The OpenSIPSCLI object can receive a set of arguments/modifiers through the OpenSIPSCLIArgs class, i.e.:

from opensipscli import args
...
args = OpenSIPSCLIArgs(debug=True)
opensipscli = cli.OpenSIPSCLI(args)
...

Custom settings can be provided thourgh the arguments, i.e.:

# run commands over http
args = OpenSIPSCLIArgs(communcation_type = "http",
                       url="http://127.0.0.1:8080/mi")
...

Configuration

OpenSIPS CLI accepts a configuration file, formatted as an ini or cfg file, that can store certain parameters that influence the behavior of the OpenSIPS CLI tool. You can find here an example of a configuration file that behaves exactly as the default parameters. The set of default values used, when no configuration file is specified, can be found here.

The configuration file can have multiple sections/instances, managed by the Instance module. One can choose different instances from the configuration file by specifying the -i INSTANCE argument when starting the cli tool.

If no configuration file is specified by the -f|--config argument, OpenSIPS CLI searches for one in the following locations:

  • ~/.opensips-cli.cfg (highest precedence)
  • /etc/opensips-cli.cfg
  • /etc/opensips/opensips-cli.cfg (lowest precedence)

If no file is found, it starts with the default configuration.

The OpenSIPS CLI core can use the following parameters:

  • prompt_name: The name of the OpenSIPS CLI prompt (Default: opensips-cli)
  • prompt_intro: Introduction message when entering the OpenSIPS CLI
  • prompt_emptyline_repeat_cmd: Repeat the last command on an emptyline (Default: False)
  • history_file: The path of the history file (Default: ~/.opensips-cli.history)
  • history_file_size: The backlog size of the history file (Default: 1000)
  • log_level: The level of the console logging (Default: WARNING)
  • communication_type: Communication transport used by OpenSIPS CLI (Default: fifo)
  • fifo_file: The OpenSIPS FIFO file to which the CLI will write commands (Default: /var/run/opensips/opensips_fifo)
  • fifo_file_fallback: A fallback FIFO file that is being used when the fifo_file is not found - this has been introduces for backwards compatibility when the default fifo_file has been changed from /tmp/opensips_fifo (Default: /tmp/opensips_fifo)
  • fifo_reply_dir: The default directory where opensips-cli will create the fifo used for the reply from OpenSIPS (Default: /tmp)
  • url: The default URL used when http communication_type is used (Default: http://127.0.0.1:8888/mi).

Each module can use each of the parameters above, but can also declare their own. You can find in each module's documentation page the parameters that they are using.

Configuration parameters can be overwritten using the -o/--option arguments, as described in the Usage section.

It is also possible to set a parameters dynamically, using the set command. This configuration is only available during the current interactive session, and also gets cleaned up when an instance is switched.

Modules

The OpenSIPS CLI tool consists of the following modules:

  • Management Interface - run MI commands
  • Database - commands to create, modify, drop, or migrate an OpenSIPS database
  • Diagnose - instantly diagnose OpenSIPS instances
  • Instance - used to switch through different instances/configuration within the config file
  • User - utility used to add and remove OpenSIPS users
  • Trace - trace calls information from users
  • Trap - use gdb to take snapshots of OpenSIPS workers
  • TLS - utility to generate certificates for TLS

Communication

OpenSIPS CLI can communicate with an OpenSIPS instance through MI using different transports. Supported transports at the moment are:

  • FIFO - communicate over the mi_fifo module
  • HTTP - use JSONRPC over HTTP through the mi_http module

Installation

Please follow the details provided in the Installation section, for a complete guide on how to install opensips-cli as a replacement for the deprecated opensipsctl shell script.

Contribute

Feel free to contribute to this project with any module, or functionality you find useful by opening a pull request.

History

This project was started by Dorin Geman (dorin98) as part of the ROSEdu 2018 program. It has later been adapted to the new OpenSIPS 3.0 MI interface and became the main external tool for managing OpenSIPS.

License

The opensips-cli source code is licensed under the GNU General Public License v3.0

All documentation files (i.e. .md extension) are licensed under the Creative Common License 4.0

Creative Common Logo

© 2018 - 2020 OpenSIPS Solutions

opensips-cli's People

Contributors

antonescualexandru avatar doringeman avatar fgast avatar ibotlold avatar liviuchircu avatar otoru avatar patrick330602 avatar razvancrainea avatar rvlad-patrascu avatar rzerres avatar spacetourist avatar vasilevalex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opensips-cli's Issues

MySQL: create the opensips / opensipsrw user

opensipsctl was using the following logic for this:

# user with full privileges over DBNAME database
DBRWUSER=${DBRWUSER:-opensips}

# password user with full privileges over DBNAME database
DBRWPW=${DBRWPW:-opensipsrw}

...............

if [ "$DBROOTUSER" != "$DBRWUSER" ] ; then
sql_query "" "
    GRANT ALL PRIVILEGES ON $1.* TO '$DBRWUSER' IDENTIFIED  BY '$DBRWPW';
    GRANT ALL PRIVILEGES ON $1.* TO '${DBRWUSER}'@'$DBHOST' IDENTIFIED BY '$DBRWPW';
"
fi

if [ $? -ne 0 ] ; then
    merr "Creating core database and grant privileges failed!"
    exit 1
fi

opensips-cli should have this feature as well: if the direct DB access user is anything other than "opensips:opensipsrw" (usually it's "root"), then we must also make sure that "opensips:opensipsrw" has full access to the newly created database.

Suggested by @danpascu

Cannot create database on Debian 10 using repository

opensips-cli installed from deb https://apt.opensips.org buster cli-nightly on Debian 10.

# opensips-cli -xd database create
DEBUG: no config file found in any of /root/.opensips-cli.cfg, /etc/opensips-cli.cfg, /etc/opensips/opensips-cli.cfg
INFO: no config file used!
DEBUG: Skipping module 'database' - excluded on purpose
DEBUG: Loaded module 'diagnose'
DEBUG: Loaded module 'instance'
DEBUG: Loaded module 'mi'
DEBUG: sent command ':opensips_fifo_reply_10860:{"jsonrpc": "2.0", "id": "18800", "method": "which", "params": []}'
DEBUG: Skipping module 'tls' - excluded on purpose
DEBUG: Loaded module 'trace'
DEBUG: Skipping module 'trap' - excluded on purpose
DEBUG: Skipping module 'user' - excluded on purpose
DEBUG: running in non-interactive mode '['database', 'create']'
ERROR: no module 'database' loaded

Add ability to create user

/usr/sbin/opensipsdbctl create asked for the root password and then created opensips user with all the proper DB permissions. It appears opensips-cli -x database create does not duplicate that behavior, requiring me to create the opensips DB user and permissions manually. Using root user is not a good idea so it would be nice if the previous behavior were duplicated.

SIP Trunk - functionality (table registrant)

since version v3.0.0 the admin tool opensipsctl is depreciated, there are quite some functional aspects that need to be adopted to opensips-cli.

SIP-Trunking is quite commen nowadays and registration of the SIP-Server to the PSTN-SIP provider is a must. opensipsctl could handle uac_registrant and I kindly request to get that functionaltiy on par with opensips-cli.

ERROR: no module 'mi' loaded

[root@localhost opensips-cli]# opensips-cli -i 135
OpenSIPS CLI for 192.168.2.135 instance
([email protected]):
clear database diagnose exit help history instance quit set tls trace trap user
([email protected]): mi
ERROR: no module 'mi' loaded

Why there is no module 'mi'?
I followed the procedure exactly.

[BUG] Fifo location

Some commands are not honor fifo location file

[root@hostname ~]# opensips-cli 
Welcome to OpenSIPS Command Line Interface!
(opensips-cli): diagnose 
ERROR: communication exception for 'get_statistics' returned: fifo file /tmp/opensips_fifo does not exist!
ERROR: Is OpenSIPS running?
(opensips-cli): exit
[root@hostname ~]# cat /etc/opensips-cli/opensips-cli.cfg 
[default]
log_level: WARNING
prompt_name: opensips-cli
prompt_intro: Welcome to OpenSIPS Command Line Interface!
prompt_emptyline_repeat_cmd: False
history_file: ~/.opensips-cli.history
history_file_size: 1000
output_type: pretty-print
communication_type: fifo
fifo_file: /var/run/opensips/opensips_fifo
[root@hostname ~]# 

user add fails

File "/usr/local/lib/python3.6/dist-packages/opensipscli-0.1-py3.6.egg/opensipscli/modules/user.py", line 55, in user_db_connect
db.use()
AttributeError: 'osdb' object has no attribute 'use'

osdb.use() is not longer available.

Location and ACC Tables fail

Thank you for the previous fix. The migration works with an exception of 2 tables now (not sure if this SQL structure issue in my db).

Logs are as follows:

opensips-cli -d -x database drop
DEBUG: using config file /etc/opensips/opensips-cli.cfg
DEBUG: Loaded module 'database'
DEBUG: Loaded module 'diagnose'
DEBUG: Loaded module 'instance'
DEBUG: fifo file /tmp/opensips_fifo does not exist!
DEBUG: Skipping module 'mi' - excluded on purpose
DEBUG: Loaded module 'tls'
DEBUG: Loaded module 'trace'
DEBUG: Skipping module 'trap' - excluded on purpose
DEBUG: Loaded module 'user'
DEBUG: running in non-interactive mode '['database', 'drop']'
DEBUG: running command 'drop' '[]'
DEBUG: admin DB URL: 'mysql://root:test@localhost'
DEBUG: connecting to mysql://root:test@localhost
DEBUG: check database URL 'mysql://root:test@localhost/opensips'
DEBUG: DB 'opensips' exists
DEBUG: database 'opensips' dropped
INFO: database 'opensips' dropped!
[root@kam-outside1-lab opensips-cli.bk]# opensips-cli -d -x database migrate opensips_24 opensips
DEBUG: using config file /etc/opensips/opensips-cli.cfg
DEBUG: Loaded module 'database'
DEBUG: Loaded module 'diagnose'
DEBUG: Loaded module 'instance'
DEBUG: fifo file /tmp/opensips_fifo does not exist!
DEBUG: Skipping module 'mi' - excluded on purpose
DEBUG: Loaded module 'tls'
DEBUG: Loaded module 'trace'
DEBUG: Skipping module 'trap' - excluded on purpose
DEBUG: Loaded module 'user'
DEBUG: running in non-interactive mode '['database', 'migrate', 'opensips_24', 'opensips']'
DEBUG: running command 'migrate' '['opensips_24', 'opensips']'
DEBUG: admin DB URL: 'mysql://root:test@localhost'
DEBUG: connecting to mysql://root:test@localhost
DEBUG: check database URL 'mysql://root:test@localhost/opensips_24'
DEBUG: DB 'opensips_24' exists
Creating database opensips...
DEBUG: check database URL 'mysql://root:test@localhost/opensips'
DEBUG: DB does not exist
DEBUG: Create Database 'opensips' for dialect 'mysql' ...
DEBUG: success
DEBUG: connecting to mysql://root:test@localhost/opensips
DEBUG: check database URL 'mysql://root:test@localhost/opensips'
DEBUG: DB 'opensips' exists
DEBUG: Creating all tables
DEBUG: checking tables: usrloc alias_db tls_mgm presence avpops domain rtpproxy permissions fraud_detection userblacklist registrant smpp call_center freeswitch_scripting carrierroute closeddial domainpolicy load_balancer emergency tracer cpl speeddial clusterer dispatcher rtpengine dialog dialplan auth_db group msilo acc rls standard b2b_sca imc drouting cachedb_sql b2b
INFO: Running standard-create.sql...
INFO: Running usrloc-create.sql...
INFO: Running alias_db-create.sql...
INFO: Running tls_mgm-create.sql...
INFO: Running presence-create.sql...
INFO: Running avpops-create.sql...
INFO: Running domain-create.sql...
INFO: Running rtpproxy-create.sql...
INFO: Running permissions-create.sql...
INFO: Running fraud_detection-create.sql...
INFO: Running userblacklist-create.sql...
INFO: Running registrant-create.sql...
INFO: Running smpp-create.sql...
INFO: Running call_center-create.sql...
INFO: Running freeswitch_scripting-create.sql...
INFO: Running carrierroute-create.sql...
INFO: Running closeddial-create.sql...
INFO: Running domainpolicy-create.sql...
INFO: Running load_balancer-create.sql...
INFO: Running emergency-create.sql...
INFO: Running tracer-create.sql...
INFO: Running cpl-create.sql...
INFO: Running speeddial-create.sql...
INFO: Running clusterer-create.sql...
INFO: Running dispatcher-create.sql...
INFO: Running rtpengine-create.sql...
INFO: Running dialog-create.sql...
INFO: Running dialplan-create.sql...
INFO: Running auth_db-create.sql...
INFO: Running group-create.sql...
INFO: Running msilo-create.sql...
INFO: Running acc-create.sql...
INFO: Running rls-create.sql...
INFO: Running b2b_sca-create.sql...
INFO: Running imc-create.sql...
INFO: Running drouting-create.sql...
INFO: Running cachedb_sql-create.sql...
INFO: Running b2b-create.sql...
DEBUG: migration scripts for ['/usr/share/opensips/mysql/table-migrate.sql', '/usr/share/opensips/mysql/db-migrate.sql']
Migrating all matching OpenSIPS tables...
DEBUG: Importing /usr/share/opensips/mysql/table-migrate.sql...
DEBUG: Importing /usr/share/opensips/mysql/db-migrate.sql...
INFO: Migrating registrant data...
INFO: Migrating tls_mgm data...
ERROR: (_mysql_exceptions.OperationalError) (1054, "Unknown column 'domain' in 'field list'")
[SQL: CALL opensips_24.OSIPS_TB_COPY_2_4_TO_3_0('opensips_24', 'opensips', 'tls_mgm')]
(Background on this error at: http://sqlalche.me/e/e3q8)
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute
res = self._query(query)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
db.query(q)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
_mysql.connection.query(self, query)
_mysql_exceptions.OperationalError: (1054, "Unknown column 'domain' in 'field list'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/db.py", line 715, in migrate
old_db, old_db, new_db, tb)))
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 988, in execute
return meth(self, multiparams, params)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement
distilled_params,
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1248, in _execute_context
e, statement, parameters, cursor, context
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 383, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 128, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute
res = self._query(query)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
db.query(q)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
_mysql.connection.query(self, query)
sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1054, "Unknown column 'domain' in 'field list'")
[SQL: CALL opensips_24.OSIPS_TB_COPY_2_4_TO_3_0('opensips_24', 'opensips', 'tls_mgm')]
(Background on this error at: http://sqlalche.me/e/e3q8)
ERROR: Failed to migrate 'tls_mgm' table data, see above errors!
INFO: Migrating acc data...
ERROR: (_mysql_exceptions.OperationalError) (1136, "Column count doesn't match value count at row 1")
[SQL: CALL opensips_24.OSIPS_TB_COPY_2_4_TO_3_0('opensips_24', 'opensips', 'acc')]
(Background on this error at: http://sqlalche.me/e/e3q8)
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute
res = self._query(query)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
db.query(q)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
_mysql.connection.query(self, query)
_mysql_exceptions.OperationalError: (1136, "Column count doesn't match value count at row 1")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/db.py", line 715, in migrate
old_db, old_db, new_db, tb)))
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 988, in execute
return meth(self, multiparams, params)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement
distilled_params,
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1248, in _execute_context
e, statement, parameters, cursor, context
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 383, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 128, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute
res = self._query(query)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
db.query(q)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
_mysql.connection.query(self, query)
sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1136, "Column count doesn't match value count at row 1")
[SQL: CALL opensips_24.OSIPS_TB_COPY_2_4_TO_3_0('opensips_24', 'opensips', 'acc')]
(Background on this error at: http://sqlalche.me/e/e3q8)
ERROR: Failed to migrate 'acc' table data, see above errors!
INFO: Migrating address data...
INFO: Migrating cachedb data...
INFO: Migrating carrierfailureroute data...
INFO: Migrating carrierroute data...
INFO: Migrating cc_agents data...
INFO: Migrating cc_calls data...
INFO: Migrating cc_cdrs data...
INFO: Migrating cc_flows data...
INFO: Migrating closeddial data...
INFO: Migrating clusterer data...
INFO: Migrating cpl data...
INFO: Migrating dbaliases data...
INFO: Migrating dialplan data...
INFO: Migrating dispatcher data...
INFO: Migrating domain data...
INFO: Migrating domainpolicy data...
INFO: Migrating dr_carriers data...
INFO: Migrating dr_gateways data...
INFO: Migrating dr_groups data...
INFO: Migrating dr_partitions data...
INFO: Migrating dr_rules data...
INFO: Migrating emergency_report data...
INFO: Migrating emergency_routing data...
INFO: Migrating emergency_service_provider data...
INFO: Migrating fraud_detection data...
INFO: Migrating freeswitch data...
INFO: Migrating globalblacklist data...
INFO: Migrating grp data...
INFO: Migrating imc_members data...
INFO: Migrating imc_rooms data...
INFO: Migrating load_balancer data...
INFO: Migrating location data...
ERROR: (_mysql_exceptions.OperationalError) (1136, "Column count doesn't match value count at row 1")
[SQL: CALL opensips_24.OSIPS_TB_COPY_2_4_TO_3_0('opensips_24', 'opensips', 'location')]
(Background on this error at: http://sqlalche.me/e/e3q8)
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute
res = self._query(query)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
db.query(q)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
_mysql.connection.query(self, query)
_mysql_exceptions.OperationalError: (1136, "Column count doesn't match value count at row 1")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/db.py", line 715, in migrate
old_db, old_db, new_db, tb)))
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 988, in execute
return meth(self, multiparams, params)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement
distilled_params,
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1248, in _execute_context
e, statement, parameters, cursor, context
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 383, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 128, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute
res = self._query(query)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
db.query(q)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
_mysql.connection.query(self, query)
sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1136, "Column count doesn't match value count at row 1")
[SQL: CALL opensips_24.OSIPS_TB_COPY_2_4_TO_3_0('opensips_24', 'opensips', 'location')]
(Background on this error at: http://sqlalche.me/e/e3q8)
ERROR: Failed to migrate 'location' table data, see above errors!
INFO: Migrating missed_calls data...
INFO: Migrating presentity data...
INFO: Migrating pua data...
INFO: Migrating re_grp data...
INFO: Migrating rls_presentity data...
INFO: Migrating rls_watchers data...
INFO: Migrating route_tree data...
INFO: Migrating rtpengine data...
INFO: Migrating rtpproxy_sockets data...
INFO: Migrating silo data...
INFO: Migrating sip_trace data...
INFO: Migrating smpp data...
INFO: Migrating speed_dial data...
INFO: Migrating subscriber data...
INFO: Migrating uri data...
INFO: Migrating userblacklist data...
INFO: Migrating usr_preferences data...
INFO: Migrating xcap data...
Finished copying OpenSIPS table data into database 'opensips'!

24 version DB tables are as follows:

MariaDB [opensips_24]> describe acc;
+-------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| method | char(16) | NO | | | |
| from_tag | char(64) | NO | | | |
| to_tag | char(64) | NO | | | |
| callid | char(64) | NO | MUL | | |
| sip_code | char(3) | NO | | | |
| sip_reason | char(32) | NO | | | |
| time | datetime | NO | | NULL | |
| duration | int(11) unsigned | NO | | 0 | |
| ms_duration | int(11) unsigned | NO | | 0 | |
| setuptime | int(11) unsigned | NO | | 0 | |
| created | datetime | YES | | NULL | |
| dest | varchar(35) | YES | | NULL | |
| clid | varchar(35) | YES | | NULL | |
| src_ip | varchar(25) | YES | | NULL | |
| drt_gw | varchar(5) | YES | | NULL | |
| drt_carrier | varchar(5) | YES | | NULL | |
+-------------+------------------+------+-----+---------+----------------+
17 rows in set (0.00 sec)

MariaDB [opensips_24]> describe location;
+---------------+---------------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------------------+----------------+
| contact_id | bigint(10) unsigned | NO | PRI | NULL | auto_increment |
| username | char(64) | NO | | | |
| domain | char(64) | YES | | NULL | |
| contact | char(255) | NO | | | |
| received | char(128) | YES | | NULL | |
| path | char(255) | YES | | NULL | |
| expires | datetime | NO | | 2020-05-28 21:32:15 | |
| q | float(10,2) | NO | | 1.00 | |
| callid | char(255) | NO | | Default-Call-ID | |
| cseq | int(11) | NO | | 13 | |
| last_modified | datetime | NO | | 1900-01-01 00:00:01 | |
| flags | int(11) | NO | | 0 | |
| cflags | char(255) | YES | | NULL | |
| user_agent | char(255) | NO | | | |
| socket | char(64) | YES | | NULL | |
| methods | int(11) | YES | | NULL | |
| sip_instance | char(255) | YES | | NULL | |
| attr | char(255) | YES | | NULL | |
+---------------+---------------------+------+-----+---------------------+----------------+
18 rows in set (0.01 sec)

MariaDB [opensips_24]>

Migrate database error

I'm trying to migrate my database from 2.4 to 3.0 and this error on 2 tables

opensips-cli -x database migrate 2.4_to_3.0 lbsip_glo_in_2_4 lbsip_glo_in_3_0
Password for admin MySQL user (root):
Creating database lbsip_glo_in_3_0...
ERROR: (_mysql_exceptions.OperationalError) (1136, "Column count doesn't match value count at row 1")
[SQL: CALL lbsip_glo_in_2_4.OSIPS_TB_COPY_2_4_TO_3_0('lbsip_glo_in_2_4', 'lbsip_glo_in_3_0', 'clusterer')]
(Background on this error at: http://sqlalche.me/e/e3q8)
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute
res = self._query(query)
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
db.query(q)
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
_mysql.connection.query(self, query)
_mysql_exceptions.OperationalError: (1136, "Column count doesn't match value count at row 1")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/db.py", line 755, in migrate
old_db, proc_tb_migrate, old_db, new_db, tb)))
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 988, in execute
return meth(self, multiparams, params)
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement
distilled_params,
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1248, in _execute_context
e, statement, parameters, cursor, context
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/util/compat.py", line 383, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/util/compat.py", line 128, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute
res = self._query(query)
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
db.query(q)
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
_mysql.connection.query(self, query)
sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1136, "Column count doesn't match value count at row 1")
[SQL: CALL lbsip_glo_in_2_4.OSIPS_TB_COPY_2_4_TO_3_0('lbsip_glo_in_2_4', 'lbsip_glo_in_3_0', 'clusterer')]
(Background on this error at: http://sqlalche.me/e/e3q8)
ERROR: Failed to migrate 'clusterer' table data, see above errors!
ERROR: (_mysql_exceptions.OperationalError) (1136, "Column count doesn't match value count at row 1")
[SQL: CALL lbsip_glo_in_2_4.OSIPS_TB_COPY_2_4_TO_3_0('lbsip_glo_in_2_4', 'lbsip_glo_in_3_0', 'location')]
(Background on this error at: http://sqlalche.me/e/e3q8)
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute
res = self._query(query)
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
db.query(q)
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
_mysql.connection.query(self, query)
_mysql_exceptions.OperationalError: (1136, "Column count doesn't match value count at row 1")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/db.py", line 755, in migrate
old_db, proc_tb_migrate, old_db, new_db, tb)))
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 988, in execute
return meth(self, multiparams, params)
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement
distilled_params,
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1248, in _execute_context
e, statement, parameters, cursor, context
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/util/compat.py", line 383, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/util/compat.py", line 128, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute
res = self._query(query)
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
db.query(q)
File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
_mysql.connection.query(self, query)
sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1136, "Column count doesn't match value count at row 1")
[SQL: CALL lbsip_glo_in_2_4.OSIPS_TB_COPY_2_4_TO_3_0('lbsip_glo_in_2_4', 'lbsip_glo_in_3_0', 'location')]
(Background on this error at: http://sqlalche.me/e/e3q8)
ERROR: Failed to migrate 'location' table data, see above errors!
Finished copying OpenSIPS table data into database 'lbsip_glo_in_3_0'!

Unable to create database tables with `opensips-cli`

Description

Tried to execute opensips-cli on my server (mysql 5.7 on debian 9), but the the python output shows there is no such table: "opensips.version".

I've installed all required dependencies and packages before running opensips-cli. And just confirmed the user for opensips has sufficient privilege to access MySQL database.

After seeing this issue, I checked MySQL. Under opensips database, there is no table. And I suspect the program didn't correctly create the tables.

Thanks for your help!

Details

Command line output

WARNING: database 'opensips' already exists!
INFO: database 'opensips' dropped!
INFO: access works, opensips user already exists
INFO: Running acc-create.sql...
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
    cursor, statement, parameters, context
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler
    raise errorvalue
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute
    res = self._query(query)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
    db.query(q)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
    _mysql.connection.query(self, query)
_mysql_exceptions.ProgrammingError: (1146, "Table 'opensips.version' doesn't exist")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/opensips-cli", line 4, in <module>
    __import__('pkg_resources').run_script('opensipscli==0.1.0', 'opensips-cli')
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 739, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1494, in run_script
    exec(code, namespace, namespace)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/EGG-INFO/scripts/opensips-cli", line 9, in <module>
    run_console()
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/EGG-INFO/scripts/opensips-cli", line 6, in run_console
    main.main()
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/main.py", line 78, in main
    sys.exit(shell.cmdloop())
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/cli.py", line 235, in cmdloop
    ret = self.run_command(self.command[0], command, params)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/cli.py", line 341, in run_command
    return mod[0].__invoke__(cmd, params)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/module.py", line 36, in __invoke__
    return f(params)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/modules/database.py", line 303, in do_create
    if self.create_tables(db_name, db_url, admin_db) < 0:
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/modules/database.py", line 405, in create_tables
    db.create_module(table_file)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/db.py", line 247, in create_module
    self.exec_sql_file(import_file)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/db.py", line 464, in exec_sql_file
    self.__conn.execute(sql)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 982, in execute
    return self._execute_text(object_, multiparams, params)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1155, in _execute_text
    parameters,
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1248, in _execute_context
    e, statement, parameters, cursor, context
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
    util.raise_from_cause(sqlalchemy_exception, exc_info)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/util/compat.py", line 383, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/util/compat.py", line 128, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
    cursor, statement, parameters, context
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler
    raise errorvalue
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute
    res = self._query(query)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
    db.query(q)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
    _mysql.connection.query(self, query)
sqlalchemy.exc.ProgrammingError: (_mysql_exceptions.ProgrammingError) (1146, "Table 'opensips.version' doesn't exist")
[SQL: INSERT INTO version (table_name, table_version) values ('acc','7')]
(Background on this error at: http://sqlalche.me/e/f405)
   Failed last operation
root@ecs-test:~/opensips# opensips-cli -x database drop
INFO: database 'opensips' dropped!
root@ecs-test:~/opensips# opensips-cli -x database create
INFO: access works, opensips user already exists
INFO: Running drouting-create.sql...
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
    cursor, statement, parameters, context
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler
    raise errorvalue
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute
    res = self._query(query)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
    db.query(q)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
    _mysql.connection.query(self, query)
_mysql_exceptions.ProgrammingError: (1146, "Table 'opensips.version' doesn't exist")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/opensips-cli", line 4, in <module>
    __import__('pkg_resources').run_script('opensipscli==0.1.0', 'opensips-cli')
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 739, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1494, in run_script
    exec(code, namespace, namespace)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/EGG-INFO/scripts/opensips-cli", line 9, in <module>
    run_console()
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/EGG-INFO/scripts/opensips-cli", line 6, in run_console
    main.main()
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/main.py", line 78, in main
    sys.exit(shell.cmdloop())
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/cli.py", line 235, in cmdloop
    ret = self.run_command(self.command[0], command, params)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/cli.py", line 341, in run_command
    return mod[0].__invoke__(cmd, params)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/module.py", line 36, in __invoke__
    return f(params)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/modules/database.py", line 303, in do_create
    if self.create_tables(db_name, db_url, admin_db) < 0:
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/modules/database.py", line 405, in create_tables
    db.create_module(table_file)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/db.py", line 247, in create_module
    self.exec_sql_file(import_file)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/db.py", line 464, in exec_sql_file
    self.__conn.execute(sql)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 982, in execute
    return self._execute_text(object_, multiparams, params)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1155, in _execute_text
    parameters,
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1248, in _execute_context
    e, statement, parameters, cursor, context
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
    util.raise_from_cause(sqlalchemy_exception, exc_info)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/util/compat.py", line 383, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/util/compat.py", line 128, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
    cursor, statement, parameters, context
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler
    raise errorvalue
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute
    res = self._query(query)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
    db.query(q)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
    _mysql.connection.query(self, query)
sqlalchemy.exc.ProgrammingError: (_mysql_exceptions.ProgrammingError) (1146, "Table 'opensips.version' doesn't exist")
[SQL: INSERT INTO version (table_name, table_version) values ('dr_gateways','6')]
(Background on this error at: http://sqlalche.me/e/f405)

Environment information

Content Version
Python3 python 3.7
MySQL mysql 5.7
Linux Distribution Debian 9.0

Installed software

opensips, opensips-mysql-module, opensips-cli (via source), mediaproxy-dispatcher, mediaproxy-relay, mediaproxy-web-sessions

OpenSIPS-CLI configuration

The #MYSQL_ROOT# is replaced with actual root password on my server.

[default]
database_name=opensips
database_url=mysql://opensipsuser:opensips_access@localhost
template_uri=mysql://opensipsuser:opensips_access@localhost
database_admin_url=mysql://root:#MYSQL_ROOT#@localhost
database_modules=ALL
database_force_drop=true

Thanks for reading!

opensips DB not creating using opensip-cli

Hi I am not able to create opensips DB using opensips-cli command. I was manully able to import mysql schema in opensips db. However not able to import all schema.

Installe Opensips in : /usr/src/opensips-3.0.2/
Opensips-cli: /usr/local/bin/opensips-cli

root@ip-xxxxxx:# python --version
Python 2.7.17
root@ip-xxxxxxx:
#
MYSQL version : 5.7
OS version: Ubuntu 18.04

root@ip-xxxxxxx:/usr/src/opensips-cli# opensips-cli -i opensips-1 -f /etc/opensips-cli.cfg -d
DEBUG: using config file /etc/opensips-cli.cfg
Welcome to OpenSIPS at SECUREVOIP
DEBUG: Loaded module 'database'
DEBUG: Loaded module 'diagnose'
DEBUG: Loaded module 'instance'
DEBUG: Loaded module 'mi'
DEBUG: sent command ':opensips_fifo_reply_2348:{"jsonrpc": "2.0", "id": "25302", "method": "which", "params": []}'
database create

I was also consistently getting this error:
root@ip-xxxxx:/usr/local/bin# opensips-cli -i opensips-1 -f /etc/opensips-cli.cfg
Welcome to OpenSIPS at SECUREVOIP
(opensips-cli): database create
Password for admin MySQL user (root):
ERROR: path '/usr/share/opensips' to OpenSIPS DB scripts does not exist!
(opensips-cli): exit
root@ip-xxxxxxxxxx:/usr/local/bin#

More info:
root@ip-xxxxxxxxxx:/usr/src/opensips-cli# cat /etc/opensips-cli.cfg
[opensips-1]
log_level: WARNING
prompt_name: opensips-cli
prompt_intro: Welcome to OpenSIPS at SECUREVOIP
prompt_emptyline_repeat_cmd: False
history_file: ~/.opensips-cli.history
history_file_size: 1000
output_type: pretty-print
communication_type: fifo
fifo_file: /tmp/opensips_fifo
database_path: /usr/src/opensips-3.0.2/scripts/
database_url: mysql://root:password@localhost
database_name: opensips
root@ip-xxxxxx:/usr/src/opensips-cli#

root@ip-xxxxxxxxxx:# opensips -V
version: opensips 3.0.2 (x86_64/linux)
flags: STATS: On, DISABLE_NAGLE, USE_MCAST, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, HP_MALLOC, DBG_MALLOC, FAST_LOCK-ADAPTIVE_WAIT
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535
poll method support: poll, epoll, sigio_rt, select.
git revision: 7e8167853
main.c compiled on 05:37:12 Jun 3 2020 with gcc 7
root@ip-xxxxxxxxx:
#

root@ip-xxxxxxxxxx:# dpkg -L opensips-mysql-module
/.
/usr
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/opensips
/usr/lib/x86_64-linux-gnu/opensips/modules
/usr/lib/x86_64-linux-gnu/opensips/modules/db_mysql.so
/usr/lib/x86_64-linux-gnu/opensips/opensipsctl
/usr/lib/x86_64-linux-gnu/opensips/opensipsctl/opensipsctl.mysql
/usr/lib/x86_64-linux-gnu/opensips/opensipsctl/opensipsdbctl.mysql
/usr/share
/usr/share/doc
/usr/share/doc/opensips-mysql-module
/usr/share/doc/opensips-mysql-module/README.db_mysql
/usr/share/doc/opensips-mysql-module/copyright
/usr/share/opensips
/usr/share/opensips/mysql
/usr/share/opensips/mysql/acc-create.sql
/usr/share/opensips/mysql/alias_db-create.sql
/usr/share/opensips/mysql/auth_db-create.sql
/usr/share/opensips/mysql/avpops-create.sql
/usr/share/opensips/mysql/b2b-create.sql
/usr/share/opensips/mysql/b2b_sca-create.sql
/usr/share/opensips/mysql/cachedb_sql-create.sql
/usr/share/opensips/mysql/call_center-create.sql
/usr/share/opensips/mysql/carrierroute-create.sql
/usr/share/opensips/mysql/closeddial-create.sql
/usr/share/opensips/mysql/clusterer-create.sql
/usr/share/opensips/mysql/cpl-create.sql
/usr/share/opensips/mysql/dialog-create.sql
/usr/share/opensips/mysql/dialplan-create.sql
/usr/share/opensips/mysql/dispatcher-create.sql
/usr/share/opensips/mysql/domain-create.sql
/usr/share/opensips/mysql/domainpolicy-create.sql
/usr/share/opensips/mysql/drouting-create.sql
/usr/share/opensips/mysql/emergency-create.sql
/usr/share/opensips/mysql/fraud_detection-create.sql
/usr/share/opensips/mysql/group-create.sql
/usr/share/opensips/mysql/imc-create.sql
/usr/share/opensips/mysql/load_balancer-create.sql
/usr/share/opensips/mysql/msilo-create.sql
/usr/share/opensips/mysql/permissions-create.sql
/usr/share/opensips/mysql/presence-create.sql
/usr/share/opensips/mysql/registrant-create.sql
/usr/share/opensips/mysql/registrar-create.sql
/usr/share/opensips/mysql/rls-create.sql
/usr/share/opensips/mysql/rtpproxy-create.sql
/usr/share/opensips/mysql/siptrace-create.sql
/usr/share/opensips/mysql/speeddial-create.sql
/usr/share/opensips/mysql/standard-create.sql
/usr/share/opensips/mysql/tls_mgm-create.sql
/usr/share/opensips/mysql/uri_db-create.sql
/usr/share/opensips/mysql/userblacklist-create.sql
/usr/share/opensips/mysql/usrloc-create.sql
/usr/share/doc/opensips-mysql-module/changelog.Debian.gz
root@ip-xxxxxxxxx:
#

Please suggest
Thanks

OpenSIPS CLI not printing binary output

Commit ed710d5

$ opensips-cli -x mi ul_dump
SQLAlchemy version: 1.3.3
Traceback (most recent call last):
File "/usr/local/bin/opensips-cli", line 4, in
import('pkg_resources').run_script('opensipscli==0.1', 'opensips-cli')
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 534, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1438, in run_script
execfile(script_filename, namespace, namespace)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 59, in execfile
exec(compile(open(fn).read(), fn, 'exec'), globs, locs)
File "/usr/local/lib/python3.4/dist-packages/opensipscli-0.1-py3.4.egg/EGG-INFO/scripts/opensips-cli", line 9, in
run_console()
File "/usr/local/lib/python3.4/dist-packages/opensipscli-0.1-py3.4.egg/EGG-INFO/scripts/opensips-cli", line 6, in run_console
main.main()
File "/usr/local/lib/python3.4/dist-packages/opensipscli-0.1-py3.4.egg/opensipscli/main.py", line 78, in main
sys.exit(shell.cmdloop())
File "/usr/local/lib/python3.4/dist-packages/opensipscli-0.1-py3.4.egg/opensipscli/cli.py", line 225, in cmdloop
ret = self.run_command(self.command[0], command, params)
File "/usr/local/lib/python3.4/dist-packages/opensipscli-0.1-py3.4.egg/opensipscli/cli.py", line 331, in run_command
return mod[0].invoke(cmd, params)
File "/usr/local/lib/python3.4/dist-packages/opensipscli-0.1-py3.4.egg/opensipscli/modules/mi.py", line 126, in invoke
res = comm.execute(cmd, params)
File "/usr/local/lib/python3.4/dist-packages/opensipscli-0.1-py3.4.egg/opensipscli/comm.py", line 40, in execute
ret = comm_handler.execute(cmd, params)
File "/usr/local/lib/python3.4/dist-packages/opensipscli-0.1-py3.4.egg/opensipscli/communication/fifo.py", line 64, in execute
replycmd = reply_fifo.readline()
File "/usr/lib/python3.4/codecs.py", line 313, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 87-88: invalid continuation byte

Other commands are OK:

$ opensips-cli -x mi ul_show_contact location [email protected]
SQLAlchemy version: 1.3.3
ERROR: command 'ul_show_contact' returned: 404: AOR not found

$ opensips-cli -x mi get_statistics tm:
SQLAlchemy version: 1.3.3
{
"tm:received_replies": 0,
"tm:relayed_replies": 0,
"tm:local_replies": 0,
"tm:UAS_transactions": 0,
"tm:UAC_transactions": 0,
"tm:2xx_transactions": 0,
"tm:3xx_transactions": 0,
"tm:4xx_transactions": 0,
"tm:5xx_transactions": 0,
"tm:6xx_transactions": 0,
"tm:inuse_transactions": 0
}

database creation fails with 'OpenSIPSCLIShell' object has no attribute 'do_database'

Hello, i'm runnig centos 7 with python3.6.8
whenever i try to create the database using opensips-cli with database create cmd, i get the following error:

Creating all tables ...
Running standard-create.sql...
Running tracer-create.sql...

ERROR: Error closing cursor
Traceback (most recent call last):
  File "/usr/lib64/python3.6/cmd.py", line 214, in onecmd
    func = getattr(self, 'do_' + cmd)
AttributeError: 'OpenSIPSCLIShell' object has no attribute 'do_database'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1333, in _safe_close_cursor
    cursor.close()
  File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 85, in close
    while self.nextset():
  File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 178, in nextset
    self._warning_check()
  File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 149, in _warning_check
    warnings = db.show_warnings()
  File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 382, in show_warnings
    self.query("SHOW WARNINGS")
  File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
    _mysql.connection.query(self, query)
_mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now")
ERROR: Error closing cursor
Traceback (most recent call last):
  File "/usr/lib64/python3.6/cmd.py", line 214, in onecmd
    func = getattr(self, 'do_' + cmd)
AttributeError: 'OpenSIPSCLIShell' object has no attribute 'do_database'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1333, in _safe_close_cursor
    cursor.close()
  File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 85, in close
    while self.nextset():
  File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 178, in nextset
    self._warning_check()
  File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/cursors.py", line 149, in _warning_check
    warnings = db.show_warnings()
  File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 382, in show_warnings
    self.query("SHOW WARNINGS")
  File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
    _mysql.connection.query(self, query)
_mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now")
Traceback (most recent call last):
  File "/usr/lib64/python3.6/cmd.py", line 214, in onecmd
    func = getattr(self, 'do_' + cmd)
AttributeError: 'OpenSIPSCLIShell' object has no attribute 'do_database'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 761, in _commit_impl
    self.engine.dialect.do_commit(self.connection)
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/dialects/mysql/base.py", line 2215, in do_commit
    dbapi_connection.commit()
_mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/opensips-cli", line 4, in <module>
    __import__('pkg_resources').run_script('opensipscli==0.1', 'opensips-cli')
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 654, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1434, in run_script
    exec(code, namespace, namespace)
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/EGG-INFO/scripts/opensips-cli", line 9, in <module>
    run_console()
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/EGG-INFO/scripts/opensips-cli", line 6, in run_console
    main.main()
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/main.py", line 78, in main
    sys.exit(shell.cmdloop())
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/cli.py", line 232, in cmdloop
    super(OpenSIPSCLIShell, self).cmdloop(intro='')
  File "/usr/lib64/python3.6/cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib64/python3.6/cmd.py", line 216, in onecmd
    return self.default(line)
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/cli.py", line 342, in default
    self.run_command(module, cmd, params)
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/cli.py", line 331, in run_command
    return mod[0].__invoke__(cmd, params)
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/module.py", line 36, in __invoke__
    return f(params)
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/modules/database.py", line 376, in do_create
    if self.create_tables(db_name, db_url=db_url) < 0:
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/modules/database.py", line 515, in create_tables
    db.create_module(table_file)
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/db.py", line 204, in create_module
    self.exec_sql_file(import_file)
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/db.py", line 325, in exec_sql_file
    self.__conn.execute(sql)
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 982, in execute
    return self._execute_text(object_, multiparams, params)
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1155, in _execute_text
    parameters,
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1272, in _execute_context
    self._root._commit_impl(autocommit=True)
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 763, in _commit_impl
    self._handle_dbapi_exception(e, None, None, None, None)
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
    util.raise_from_cause(sqlalchemy_exception, exc_info)
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 383, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 128, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 761, in _commit_impl
    self.engine.dialect.do_commit(self.connection)
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/dialects/mysql/base.py", line 2215, in do_commit
    dbapi_connection.commit()
sqlalchemy.exc.ProgrammingError: (_mysql_exceptions.ProgrammingError) (2014, "Commands out of sync; you can't run this command now")
(Background on this error at: http://sqlalche.me/e/f405)

running with -f, it keeps complaining of missing section headers despite the file was generated by "make menuconfig"

To replicate:

  1. install opensips 3.0
  2. run "make menuconfig"
  3. Generate any conf file. In my case, a residential file.
  4. Install opensips-cli . Run "opensips -f "
  5. Error is thrown as below:

✘ ⚡ root@localhost  /opt/opensips  ➦ 6a49622 ● opensips-cli -f etc/opensips_residential_2020-3-4_13:11:2.cfg
Traceback (most recent call last):
File "/usr/local/bin/opensips-cli", line 4, in
import('pkg_resources').run_script('opensipscli==0.1.0', 'opensips-cli')
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 654, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 1434, in run_script
exec(code, namespace, namespace)
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/EGG-INFO/scripts/opensips-cli", line 9, in
run_console()
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/EGG-INFO/scripts/opensips-cli", line 6, in run_console
main.main()
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/main.py", line 77, in main
shell = cli.OpenSIPSCLIShell(args)
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/cli.py", line 69, in init
cfg.parse(cfg_file)
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/config.py", line 41, in parse
self.config.read(in_file)
File "/usr/lib64/python3.6/configparser.py", line 697, in read
self._read(fp, filename)
File "/usr/lib64/python3.6/configparser.py", line 1080, in _read
raise MissingSectionHeaderError(fpname, lineno, line)
configparser.MissingSectionHeaderError: File contains no section headers.
file: 'etc/opensips_residential_2020-3-4_13:11:2.cfg', line: 18
'log_level=3\n'
✘ ⚡ root@localhost  /opt/opensips  ➦ 6a49622 ● 

I read another post online and i tried to feed it a [default] tag on the top line to no success.

opensips_residential_2020-3-4_13%3A11%3A2.cfg.txt

Install on debian/ubuntu

I followed the instructions in the Installation section, but the instructions never say how to install the actual tool through a .deb package, only its dependencies. Am I missing something ?

'database create/add' do not work with PostgreSQL

Create [a]ll tables or just the [c]urrently configured ones? (Default value is a):
Creating all tables ...
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
psycopg2.InternalError: CREATE DATABASE cannot run inside a transaction block


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/opensips-cli", line 4, in <module>
    __import__('pkg_resources').run_script('opensipscli==0.1', 'opensips-cli')
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 654, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1434, in run_script
    exec(code, namespace, namespace)
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/EGG-INFO/scripts/opensips-cli", line 9, in <module>
    run_console()
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/EGG-INFO/scripts/opensips-cli", line 6, in run_console
    main.main()
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/main.py", line 78, in main
    sys.exit(shell.cmdloop())
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/cli.py", line 199, in cmdloop
    ret = self.run_command(self.command[0], command, params)
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/cli.py", line 293, in run_command
    return mod[0].__invoke__(cmd, params)
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/module.py", line 30, in __invoke__
    return f(params)
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/modules/database.py", line 243, in do_create
    self._do_create(db)
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/modules/database.py", line 298, in _do_create
    db.create(db_name)
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/db.py", line 138, in create
    self.__conn.execute("CREATE DATABASE {}".format(db_name))
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 982, in execute
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1155, in _execute_text
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1248, in _execute_context
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 383, in raise_from_cause
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 128, in reraise
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
  File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
sqlalchemy.exc.InternalError: (psycopg2.InternalError) CREATE DATABASE cannot run inside a transaction block

[SQL: CREATE DATABASE opensips]
(Background on this error at: http://sqlalche.me/e/2j85)

Reported by @acheraime here.

The problem seems to be that the PGSQL support has a separate set of sub-commands, namely create_db (instead of the already existing create) and create_module (instead of the already existing add). This creates confusion for users, since it's hard to know which sub-command to call for each backend: "should I call database create or database create_db?"

I suggest we merge these duplicate commands into a solution that works for any backend, regardless of how you invoke it from the console.

database creation fails

When I try to create a database with opensips-cli, the program just crashes:

sqlalchemy.exc.ProgrammingError: (MySQLdb._exceptions.ProgrammingError) unsupported operand type(s) for %: 'bytes' and 'tuple'
[SQL: SHOW VARIABLES LIKE 'sql_mode']
(Background on this error at: http://sqlalche.me/e/f405)

OpenSIPS 3.0 is freshly installed from source in a custom location. Honestly I am just trying this project as I can neither find opensipsdbctl nor opensipsctl in my installation's location.

Full log of opensips-cli here

TLS Certificate Error

I am trying to create the TLS certificate by opensips-cli but it is returning the error. Same error occur with other python versions.

(opensips-cli): tls rootCA

Traceback (most recent call last):
  File "/usr/lib64/python3.6/cmd.py", line 214, in onecmd
    func = getattr(self, 'do_' + cmd)
AttributeError: 'OpenSIPSCLIShell' object has no attribute 'do_tls'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/opensips-cli", line 4, in <module>
    __import__('pkg_resources').run_script('opensipscli==0.1.0', 'opensips-cli')
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 654, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1434, in run_script
    exec(code, namespace, namespace)
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/EGG-INFO/scripts/opensips-cli", line 9, in <module>
    run_console()
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/EGG-INFO/scripts/opensips-cli", line 6, in run_console
    main.main()
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/main.py", line 78, in main
    sys.exit(shell.cmdloop())
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/cli.py", line 242, in cmdloop
    super(OpenSIPSCLIShell, self).cmdloop(intro='')
  File "/usr/lib64/python3.6/cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib64/python3.6/cmd.py", line 216, in onecmd
    return self.default(line)
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/cli.py", line 358, in default
    self.run_command(module, cmd, params)
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/cli.py", line 341, in run_command
    return mod[0].__invoke__(cmd, params)
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/module.py", line 36, in __invoke__
    return f(params)
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/modules/tls.py", line 39, in do_rootCA
    ca_cfg = cfg.get("tls_ca_config")
  File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/config.py", line 64, in get
    return self.config[self.current_instance][key]
  File "/usr/lib64/python3.6/configparser.py", line 1233, in __getitem__
    raise KeyError(key)
KeyError: 'tls_ca_config'

/etc/opensips/opensips-cli.cfg

[default]
database_url: mysql://user:password@localhost
database_name: opensips
database_modules: dialog usrloc
database_path: /usr/src/opensips-3.0/scripts/mysql

Restart opensip3.x by opensips-cli

there is a cmd opensipctl restart in 2.x , so how can i restart opensips3.x by opensips-cli ?

now i'm using /usr/local/bin/opensips-cli -x mi kill and then opensip -f ...

opensips-cli add acc failed

opensips-cli -x database create

opensips-cli -x database add acc

both failed.

Error:

opensips-cli -x database add acc

Please provide us the URL of the database: mysql://opensips:opensipsrw@mysql
ERROR: Error closing cursor
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/SQLAlchemy-1.3.3-py3.7-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1333, in _safe_close_cursor
cursor.close()
File "/usr/local/lib/python3.7/dist-packages/mysqlclient-1.3.14-py3.7-linux-x86_64.egg/MySQLdb/cursors.py", line 85, in close
while self.nextset():
File "/usr/local/lib/python3.7/dist-packages/mysqlclient-1.3.14-py3.7-linux-x86_64.egg/MySQLdb/cursors.py", line 178, in nextset
self._warning_check()
File "/usr/local/lib/python3.7/dist-packages/mysqlclient-1.3.14-py3.7-linux-x86_64.egg/MySQLdb/cursors.py", line 149, in _warning_check
warnings = db.show_warnings()
File "/usr/local/lib/python3.7/dist-packages/mysqlclient-1.3.14-py3.7-linux-x86_64.egg/MySQLdb/connections.py", line 382, in show_warnings
self.query("SHOW WARNINGS")
File "/usr/local/lib/python3.7/dist-packages/mysqlclient-1.3.14-py3.7-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
_mysql.connection.query(self, query)
_mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now")
ERROR: Error closing cursor
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/SQLAlchemy-1.3.3-py3.7-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1333, in _safe_close_cursor
cursor.close()
File "/usr/local/lib/python3.7/dist-packages/mysqlclient-1.3.14-py3.7-linux-x86_64.egg/MySQLdb/cursors.py", line 85, in close
while self.nextset():
File "/usr/local/lib/python3.7/dist-packages/mysqlclient-1.3.14-py3.7-linux-x86_64.egg/MySQLdb/cursors.py", line 178, in nextset
self._warning_check()
File "/usr/local/lib/python3.7/dist-packages/mysqlclient-1.3.14-py3.7-linux-x86_64.egg/MySQLdb/cursors.py", line 149, in _warning_check
warnings = db.show_warnings()
File "/usr/local/lib/python3.7/dist-packages/mysqlclient-1.3.14-py3.7-linux-x86_64.egg/MySQLdb/connections.py", line 382, in show_warnings
self.query("SHOW WARNINGS")
File "/usr/local/lib/python3.7/dist-packages/mysqlclient-1.3.14-py3.7-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
_mysql.connection.query(self, query)
_mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now")
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/SQLAlchemy-1.3.3-py3.7-linux-x86_64.egg/sqlalchemy/engine/base.py", line 761, in _commit_impl
self.engine.dialect.do_commit(self.connection)
File "/usr/local/lib/python3.7/dist-packages/SQLAlchemy-1.3.3-py3.7-linux-x86_64.egg/sqlalchemy/dialects/mysql/base.py", line 2215, in do_commit
dbapi_connection.commit()
_mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/bin/opensips-cli", line 4, in
import('pkg_resources').run_script('opensipscli==0.1.0', 'opensips-cli')
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 666, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 1446, in run_script
exec(code, namespace, namespace)
File "/usr/local/lib/python3.7/dist-packages/opensipscli-0.1.0-py3.7.egg/EGG-INFO/scripts/opensips-cli", line 9, in
run_console()
File "/usr/local/lib/python3.7/dist-packages/opensipscli-0.1.0-py3.7.egg/EGG-INFO/scripts/opensips-cli", line 6, in run_console
main.main()
File "/usr/local/lib/python3.7/dist-packages/opensipscli-0.1.0-py3.7.egg/opensipscli/main.py", line 78, in main
sys.exit(shell.cmdloop())
File "/usr/local/lib/python3.7/dist-packages/opensipscli-0.1.0-py3.7.egg/opensipscli/cli.py", line 225, in cmdloop
ret = self.run_command(self.command[0], command, params)
File "/usr/local/lib/python3.7/dist-packages/opensipscli-0.1.0-py3.7.egg/opensipscli/cli.py", line 331, in run_command
return mod[0].invoke(cmd, params)
File "/usr/local/lib/python3.7/dist-packages/opensipscli-0.1.0-py3.7.egg/opensipscli/module.py", line 36, in invoke
return f(params)
File "/usr/local/lib/python3.7/dist-packages/opensipscli-0.1.0-py3.7.egg/opensipscli/modules/database.py", line 284, in do_add
db.create_module(module_file_path)
File "/usr/local/lib/python3.7/dist-packages/opensipscli-0.1.0-py3.7.egg/opensipscli/db.py", line 206, in create_module
self.exec_sql_file(import_file)
File "/usr/local/lib/python3.7/dist-packages/opensipscli-0.1.0-py3.7.egg/opensipscli/db.py", line 332, in exec_sql_file
self.__conn.execute(sql)
File "/usr/local/lib/python3.7/dist-packages/SQLAlchemy-1.3.3-py3.7-linux-x86_64.egg/sqlalchemy/engine/base.py", line 982, in execute
return self.execute_text(object, multiparams, params)
File "/usr/local/lib/python3.7/dist-packages/SQLAlchemy-1.3.3-py3.7-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1155, in _execute_text
parameters,
File "/usr/local/lib/python3.7/dist-packages/SQLAlchemy-1.3.3-py3.7-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1272, in _execute_context
self._root._commit_impl(autocommit=True)
File "/usr/local/lib/python3.7/dist-packages/SQLAlchemy-1.3.3-py3.7-linux-x86_64.egg/sqlalchemy/engine/base.py", line 763, in _commit_impl
self._handle_dbapi_exception(e, None, None, None, None)
File "/usr/local/lib/python3.7/dist-packages/SQLAlchemy-1.3.3-py3.7-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "/usr/local/lib/python3.7/dist-packages/SQLAlchemy-1.3.3-py3.7-linux-x86_64.egg/sqlalchemy/util/compat.py", line 383, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/local/lib/python3.7/dist-packages/SQLAlchemy-1.3.3-py3.7-linux-x86_64.egg/sqlalchemy/util/compat.py", line 128, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.7/dist-packages/SQLAlchemy-1.3.3-py3.7-linux-x86_64.egg/sqlalchemy/engine/base.py", line 761, in _commit_impl
self.engine.dialect.do_commit(self.connection)
File "/usr/local/lib/python3.7/dist-packages/SQLAlchemy-1.3.3-py3.7-linux-x86_64.egg/sqlalchemy/dialects/mysql/base.py", line 2215, in do_commit
dbapi_connection.commit()
sqlalchemy.exc.ProgrammingError: (_mysql_exceptions.ProgrammingError) (2014, "Commands out of sync; you can't run this command now")
(Background on this error at: http://sqlalche.me/e/f405)

==================================
Environment
debian 10
Python 3.7.3

pip3 freeze
asn1crypto==0.24.0
cffi==1.13.2
cryptography==2.8
entrypoints==0.3
keyring==17.1.1
keyrings.alt==3.1.1
mysqlclient==1.4.6
opensipscli==0.1.0
pycparser==2.19
pycrypto==2.6.1
PyGObject==3.30.4
pyOpenSSL==19.1.0
pyxdg==0.25
SecretStorage==2.3.1
six==1.12.0
SQLAlchemy==1.3.12
SQLAlchemy-Utils==0.36.1

opensips-cli shouldn't exit on SIGINT (^C)

Similarly to some popular, battle-hardened console environments out there (bash, mysql, to name a few), opensips-cli should not die after receiving a SIGINT signal generated via Ctrl + C.

AttributeError: 'osdb' object has no attribute 'use'

SQLAlchemy version: 1.3.3
Please provide us the URL of the database: mysql://root:[email protected]
Traceback (most recent call last):
File "/usr/local/bin/opensips-cli", line 4, in
import('pkg_resources').run_script('opensipscli==0.1', 'opensips-cli')
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 534, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1438, in run_script
execfile(script_filename, namespace, namespace)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 59, in execfile
exec(compile(open(fn).read(), fn, 'exec'), globs, locs)
File "/usr/local/lib/python3.4/dist-packages/opensipscli-0.1-py3.4.egg/EGG-INFO/scripts/opensips-cli", line 9, in
run_console()
File "/usr/local/lib/python3.4/dist-packages/opensipscli-0.1-py3.4.egg/EGG-INFO/scripts/opensips-cli", line 6, in run_console
main.main()
File "/usr/local/lib/python3.4/dist-packages/opensipscli-0.1-py3.4.egg/opensipscli/main.py", line 78, in main
sys.exit(shell.cmdloop())
File "/usr/local/lib/python3.4/dist-packages/opensipscli-0.1-py3.4.egg/opensipscli/cli.py", line 225, in cmdloop
ret = self.run_command(self.command[0], command, params)
File "/usr/local/lib/python3.4/dist-packages/opensipscli-0.1-py3.4.egg/opensipscli/cli.py", line 331, in run_command
return mod[0].invoke(cmd, params)
File "/usr/local/lib/python3.4/dist-packages/opensipscli-0.1-py3.4.egg/opensipscli/module.py", line 36, in invoke
return f(params)
File "/usr/local/lib/python3.4/dist-packages/opensipscli-0.1-py3.4.egg/opensipscli/modules/user.py", line 103, in do_add
db = self.user_db_connect()
File "/usr/local/lib/python3.4/dist-packages/opensipscli-0.1-py3.4.egg/opensipscli/modules/user.py", line 55, in user_db_connect
db.use()
AttributeError: 'osdb' object has no attribute 'use'

config file doesn't take effect

Hi,I'm using opensips3.0.2 and OpenSIPS CLI 0.1.0 with mysql8.0.19-0ubuntu0.19.10.3
and I have config file in /etc/opensips/opensips.cfg,but config file seems take no effect.
when I run" opensips-cli -x user add user@domain password"
it still require the URL of the database and try to insert into the default database"opensips" instead of the database in the config file,thus cause the err"Access denied for user 'opensips'@'localhost' to database 'opensips'.

Error during opensips-cli installation and execution

Hello,
Try to install opensip-cli but something wrong
`byte-compiling build/bdist.linux-x86_64/egg/opensipscli/cli.py to cli.pyc
File "build/bdist.linux-x86_64/egg/opensipscli/cli.py", line 309
print(num, line, end='')
^
SyntaxError: invalid syntax

byte-compiling build/bdist.linux-x86_64/egg/opensipscli/db.py to db.pyc
File "build/bdist.linux-x86_64/egg/opensipscli/db.py", line 61
raise osdbError("unable to connect to the database") from None
^
SyntaxError: invalid syntax

byte-compiling build/bdist.linux-x86_64/egg/opensipscli/defaults.py to defaults.pyc`

Then, when I excecute opensips-cli, I got errors:

root@pstn-2:~/opensips-cli# opensips-cli Traceback (most recent call last): File "/usr/local/bin/opensips-cli", line 4, in <module> __import__('pkg_resources').run_script('opensipscli==0.1', 'opensips-cli') File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 666, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1444, in run_script .format(**locals()), pkg_resources.ResolutionError: Script 'scripts/opensips-cli' not found in metadata at None root@pstn-2:~/opensips-cli#
Regards

'database create' works weirdly with PostgreSQL

hi, when working with postgresql, if there's no database 'opensips', using the URL of the SQL database:'postgres://opensips:[email protected]/opensips' reports "fatal error: database 'opensips' doesn't exist", but if there's a database 'opensips' already created, using the URL of the SQL database:'postgres://opensips:[email protected]/opensips' reports "error: database 'opensips' already exists". Futher more, when there's no database 'opensips', using the URL of the SQL database:'postgres://opensips:[email protected]/postgres' turns out no error, but creates the database named 'opensips' and all related tables are created into database 'postgres'. My environment: CentOS6.7, postgres9.6, opensips3.0-stable.

opensips-cli errors.txt

Cannot find SQL scripts to execute

Hi, thanks for your great work! I've noticed in my instance (Debian 9) with MySql, I am unable to create database properly. Here is my configuration file content:

database_name=opensips
database_url=mysql://root:xxx@localhost
template_url=mysql://root:xxx@localhost
database_modules=acc auth_db avpops clusterer drouting group load_balancer

I always run into this prompt during opensips-cli -x database create:

Please provide the path to the OpenSIPS DB scripts:

Currently, I think it might because the program was trying to find the SQL scripts to execute. But I found them nowhere.

"ImportError: No module named opensipscli" after last commits

Hi, opensips-cli doesn't work after last changes. It builds fine, but 'opensips-cli' doesn't executed, failed with error:

/usr/src/opensips-cli/bin# ./opensips-cli 
Traceback (most recent call last):
File "./opensips-cli", line 3, in <module>
from opensipscli import main
ImportError: No module named opensipscli

Tested on Debian 10.

Unit Testing

Although it is not possible with all modules (e.g. diagnose), I would opine that most of them are unit testable. Some examples:

  • user add
  • database create opensips
  • database migrate opensips opensips_new

We should have a unit testing suite for all of these commands, which will speed up the merging of all PRs, prevent regressions such as #16 and make it more fun for developers to confirm their additions and sleep well, knowing they didn't break the whole damn thing! :)

CentOS 7 MySQL 8 Can't get past create database

I have a newly installed mysql database server on CentOS 7, when I try running opensips-cli and then "database create" It creates the database, then shows

ERROR: failed to connect to DB as root, please provide or fix the 'database_admin_url'

my opensips-cli.cfg looks like this

[default]
log_level: WARNING
prompt_name: opensips-cli
prompt_intro: Welcome to OpenSIPS Command Line Interface!
prompt_emptyline_repeat_cmd: False
history_file: ~/.opensips-cli.history
history_file_size: 1000
output_type: pretty-print
communication_type: fifo
fifo_file: /tmp/opensips_fifo
database_modules: ALL
[mysql]
database_admin_url: mysql://[email protected]:3306/opensips

Migrate Script fails

Output log:
opensips-cli -d -x database migrate opensips_24 opensips
DEBUG: using config file /etc/opensips/opensips-cli.cfg
DEBUG: Loaded module 'database'
DEBUG: Loaded module 'diagnose'
DEBUG: Loaded module 'instance'
DEBUG: fifo file /tmp/opensips_fifo does not exist!
DEBUG: Skipping module 'mi' - excluded on purpose
DEBUG: Loaded module 'tls'
DEBUG: Loaded module 'trace'
DEBUG: Skipping module 'trap' - excluded on purpose
DEBUG: Loaded module 'user'
DEBUG: running in non-interactive mode '['database', 'migrate', 'opensips_24', 'opensips']'
DEBUG: running command 'migrate' '['opensips_24', 'opensips']'
DEBUG: admin DB URL: 'mysql://root:test@localhost'
DEBUG: connecting to mysql://root:test@localhost
ERROR: DEBUG_INSIDE SET_URL url: mysql://root:test@localhost
ERROR: DEBUG_INSIDE SET_URL db: opensips_24
DEBUG: check database URL 'mysql://root:test@localhost/opensips_24'
DEBUG: DB 'opensips_24' exists
Creating database opensips...
ERROR: D url: mysql://root:test@localhost
ERROR: DEBUG_INSIDE SET_URL db: opensips
DEBUG: check database URL 'mysql://root:test@localhost/opensips'
DEBUG: DB does not exist
DEBUG: Create Database 'opensips' for dialect 'mysql' ...
DEBUG: success
ERROR: DEBUG_INSIDE SET_URL url: <opensipscli.db.osdb object at 0x7f9ab08d8550>
ERROR: DEBUG_INSIDE SET_URL db: opensips
Traceback (most recent call last):
File "/usr/local/bin/opensips-cli", line 4, in
import('pkg_resources').run_script('opensipscli==0.1.0', 'opensips-cli')
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 654, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 1434, in run_script
exec(code, namespace, namespace)
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/EGG-INFO/scripts/opensips-cli", line 9, in
run_console()
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/EGG-INFO/scripts/opensips-cli", line 6, in run_console
main.main()
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/main.py", line 78, in main
sys.exit(shell.cmdloop())
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/cli.py", line 235, in cmdloop
ret = self.run_command(self.command[0], command, params)
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/cli.py", line 341, in run_command
return mod[0].invoke(cmd, params)
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/module.py", line 36, in invoke
return f(params)
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/modules/database.py", line 520, in do_migrate
if self.create_tables(new_db, db, admin_url) < 0:
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/modules/database.py", line 340, in create_tables
db_url = osdb.set_url_db(db_url, 'opensips')
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/db.py", line 790, in set_url_db
at_idx = url.find('@')
-==============================
cat /etc/opensips/opensips-cli.cfg
[default]
log_level: DEBUG
prompt_name: opensips-cli
prompt_intro: Alex Welcome to OpenSIPS Command Line Interface!
prompt_emptyline_repeat_cmd: False
history_file: ~/.opensips-cli.history
history_file_size: 1000
output_type: pretty-print
communication_type: fifo
fifo_file: /tmp/opensips_fifo
database_admin_url: mysql://root:test@localhost
database_url: mysql://opensips:opensipsrw@localhost
database_modules: all
database_force_drop: True

=======================
Looks like osdb.set_url_db is passed a string most of the time, however in migrate script, it's passed as a object, hence find method starts conflicting...

opensips-cli cannot start w/o SQLAlchemy

The recent Postgres PR has introduced a regression, where the CLI is no longer able to run without SQLAlchemy installed. Previously, it would work and simply not provide the database module at all. To reproduce:

diff --git a/setup.py b/setup.py
index 3f0e1d7..7b7facd 100644
--- a/setup.py
+++ b/setup.py
@@ -64,8 +64,6 @@ setup(
     ],
     install_requires=[
         'mysqlclient<1.4.0rc1',
-        'sqlalchemy==1.3.3',
-        'sqlalchemy-utils'
     ],
     classifiers = [
         "Programming Language :: Python :: 3",

and install it again. Now, when running opensips-cli, we get:

Traceback (most recent call last):
  File "/usr/local/bin/opensips-cli", line 4, in <module>
    __import__('pkg_resources').run_script('opensipscli==0.1', 'opensips-cli')
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 658, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1438, in run_script
    exec(code, namespace, namespace)
  File "/usr/local/lib/python3.6/dist-packages/opensipscli-0.1-py3.6.egg/EGG-INFO/scripts/opensips-cli", line 3, in <module>
    from opensipscli import main
  File "/home/liviu/src/opensips-cli/opensipscli/main.py", line 22, in <module>
    from opensipscli import cli, defaults
  File "/home/liviu/src/opensips-cli/opensipscli/cli.py", line 31, in <module>
    from opensipscli.modules import *
  File "/home/liviu/src/opensips-cli/opensipscli/modules/__init__.py", line 24, in <module>
    __import__(modname)
  File "/home/liviu/src/opensips-cli/opensipscli/modules/database.py", line 23, in <module>
    from opensipscli.db import (
  File "/home/liviu/src/opensips-cli/opensipscli/db.py", line 38, in <module>
    Base = declarative_base()
NameError: name 'declarative_base' is not defined

Reported by @danpascu

Error on database create: Unable to lock control file /var/lib/mysql/aria_log_control

Hi,

I am unable to run the database create command when setting up opensips with opensips-cli. I first get this error:

Got ERROR: "unknown: Can't lock aria control file '/var/lib/mysql/aria_log_control' for exclusive use, error: 11. Will retry for 30 seconds" errno: 2000

Followed by loads of:
Got ERROR: "InnoDB: Unable to lock /var/lib/mysql/ibdata1 error: 11" errno: 2000

and eventually an error with a traceback:
Got ERROR: "Could not open mysql.plugin table. Some plugins may be not loaded" errno: 2000

Any suggestions on the possible cause?

Thanks
Carel

opensips -V
version: opensips 3.0.2 (x86_64/linux)
flags: STATS: On, DISABLE_NAGLE, USE_MCAST, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, HP_MALLOC, DBG_MALLOC, FAST_LOCK-ADAPTIVE_WAIT
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535
poll method support: poll, epoll, sigio_rt, select.
git revision: 7e8167853
main.c compiled on 06:54:45 Jun 26 2020 with gcc 4.8.5

opensips-cli -v
OpenSIPS CLI 0.1.0

MariaDB [mysql]> select @@Version;
+-----------------+
| @@Version |
+-----------------+
| 10.4.13-MariaDB |
+-----------------+
1 row in set (0.001 sec)

cat /etc/redhat-release

CentOS Linux release 7.8.2003 (Core)

python --version

Python 3.6.8

Output:
DEBUG: Loaded module 'database'
DEBUG: Loaded module 'diagnose'
DEBUG: Loaded module 'instance'
DEBUG: fifo file /tmp/opensips_fifo does not exist!
DEBUG: Skipping module 'mi' - excluded on purpose
DEBUG: Loaded module 'tls'
DEBUG: Loaded module 'trace'
DEBUG: Loaded module 'trap'
DEBUG: Loaded module 'user'
DEBUG: running in non-interactive mode '['database', 'create']'
DEBUG: running command 'create' '[]'
DEBUG: db_name: 'opensips'
DEBUG: read password: ''
DEBUG: admin DB URL: 'mysql://root:
@localhost'
DEBUG: connecting to mysql://root:******@localhost
Got ERROR: "unknown: Can't lock aria control file '/var/lib/mysql/aria_log_control' for exclusive use, error: 11. Will retry for 30 seconds" errno: 2000
Got ERROR: "unknown: Got error 'Could not get an exclusive lock; file is probably in use by another process' when trying to use aria control file '/var/lib/mysql/aria_log_control'" errno: 2000
Got ERROR: "Plugin 'Aria' init function returned error." errno: 2000
Got ERROR: "Plugin 'Aria' registration as a STORAGE ENGINE failed." errno: 2000
Got ERROR: "InnoDB: Unable to lock /var/lib/mysql/ibdata1 error: 11" errno: 2000
Got ERROR: "InnoDB: Unable to lock /var/lib/mysql/ibdata1 error: 11" errno: 2000
...
approx 100 lines of InnoDB Unable to lock...
...
Got ERROR: "InnoDB: Unable to lock /var/lib/mysql/ibdata1 error: 11" errno: 2000
Got ERROR: "InnoDB: Operating system error number 11 in a file operation." errno: 2000
Got ERROR: "InnoDB: Error number 11 means 'Resource temporarily unavailable'" errno: 2000
Got ERROR: "InnoDB: Cannot open datafile '/var/lib/mysql/ibdata1'" errno: 2000
Got ERROR: "InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created i
n this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!" errno: 2000
Got ERROR: "InnoDB: Plugin initialization aborted with error Cannot open a file" errno: 2000
Got ERROR: "Plugin 'InnoDB' init function returned error." errno: 2000
Got ERROR: "Plugin 'InnoDB' registration as a STORAGE ENGINE failed." errno: 2000
Got ERROR: "Could not open mysql.plugin table. Some plugins may be not loaded" errno: 2000
Got ERROR: "Failed to initialize plugins." errno: 2000
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2262, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 303, in unique_connection
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 760, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 492, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/impl.py", line 139, in _do_get
self._dec_overflow()
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/langhelpers.py", line 68, in exit
compat.reraise(exc_type, exc_value, exc_tb)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 129, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/impl.py", line 136, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 308, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 437, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 639, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 453, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/init.py", line 85, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 192, in init
client_version = tuple([ numeric_part(n) for n in _mysql.get_client_info().split('.')[:2] ])
_mysql_exceptions.InternalError: (-1, 'server not initialized')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/bin/opensips-cli", line 4, in
import('pkg_resources').run_script('opensipscli==0.1.0', 'opensips-cli')
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 654, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 1434, in run_script
exec(code, namespace, namespace)
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/EGG-INFO/scripts/opensips-cli", line 9, in
run_console()
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/EGG-INFO/scripts/opensips-cli", line 6, in run_console
main.main()
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/main.py", line 78, in main
sys.exit(shell.cmdloop())
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/cli.py", line 242, in cmdloop
ret = self.run_command(self.command[0], command, params)
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/cli.py", line 357, in run_command
return mod[0].invoke(cmd, params)
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/module.py", line 36, in invoke
return f(params)
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/modules/database.py", line 369, in do_create
admin_db = self.get_db(admin_url, db_name)
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/modules/database.py", line 630, in get_db
return osdb(db_url, db_name)
File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/db.py", line 136, in init
self.__conn = self.__engine.connect().
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2193, in connect
return self._connection_cls(self, **kwargs)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 103, in init
else engine.raw_connection()
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2293, in raw_connection
self.pool.unique_connection, _connection
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2266, in _wrap_pool_connect
e, dialect, self
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1536, in _handle_dbapi_exception_noconnection
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 383, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 128, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2262, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 303, in unique_connection
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 760, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 492, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/impl.py", line 139, in _do_get
self._dec_overflow()
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/langhelpers.py", line 68, in exit
compat.reraise(exc_type, exc_value, exc_tb)
compat.reraise(exc_type, exc_value, exc_tb)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 129, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/impl.py", line 136, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 308, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 437, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 639, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 453, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/init.py", line 85, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 192, in init
client_version = tuple([ numeric_part(n) for n in _mysql.get_client_info().split('.')[:2] ])
sqlalchemy.exc.InternalError: (_mysql_exceptions.InternalError) (-1, 'server not initialized')
(Background on this error at: http://sqlalche.me/e/2j85)

'database create' can't be run silently

I'm trying automate my opensips deployment, including using opensips-cli to setup the database. The documentation for the database module suggests it should be possible to do this silently by defining the database parameters in a config file (or in-line with '-o') but it seems like this is not the case - running 'database create' will always prompt for the database url and whether to create all/current tables.

cat /etc/opensips/db.conf
[default]
database_url=mysql://root:rootpw@localhost
database_name=opensips
database_modules=acc auth_db avpops clusterer drouting group load_balancer

opensips-cli -xd database create -f /etc/opensips/db.conf
DEBUG: using config file /etc/opensips/db.conf
DEBUG: Loaded module 'database'
DEBUG: Loaded module 'diagnose'
DEBUG: Loaded module 'instance'
DEBUG: fifo file /tmp/opensips_fifo does not exist!
DEBUG: Skipping module 'mi' - excluded on purpose
DEBUG: Loaded module 'tls'
DEBUG: Loaded module 'trace'
DEBUG: Skipping module 'trap' - excluded on purpose
DEBUG: Loaded module 'user'
DEBUG: running in non-interactive mode '['database', 'create']'
DEBUG: running command 'create' '[]'
DEBUG: db_name: 'opensips'
Please provide the URL of the SQL database:

Running on Debian 10 with latest release of opensip-cli

diagnose: Refactor code

Currently, all the logic is built within __invoke__. After some discussions with Ralf Zerres, it seems the code should be placed within a separate, do_diagnose method.

Database creation fails with opensips-cli and MariaDB 10.1

I'm running this inside a Docker container running Ubuntu 18.04 and OpenSIPs 3.0.2-1 from apt.opensips.org. opensips-cli is from master.

Why is it trying to connect to the local mysqld.sock?

After this error, if I inspect the database I have an opensips user and an opensips database with no tables.

My goal is to replace opensipsdbctl create which I was running from an automated script, and using the credentials from ENV.

opensips@sip:/$ opensips-cli -o database_admin_url='mysql://root:Y_Op=6>[email protected]:3306/' -x database create
INFO: creating access user for opensips ...
INFO: created user 'opensips'@'localhost'
INFO: set password for 'opensips'@'localhost'
INFO: granted access to 'opensips'@'localhost' on 'opensips'
INFO: flushed privileges
ERROR: 
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2262, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 303, in unique_connection
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 760, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/langhelpers.py", line 68, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 129, in reraise
    raise value
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 639, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 453, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.6/dist-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/__init__.py", line 85, in Connect
    return Connection(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 208, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2006, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/db.py", line 136, in __init__
    self.__conn = self.__engine.connect().\
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2193, in connect
    return self._connection_cls(self, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 103, in __init__
    else engine.raw_connection()
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2293, in raw_connection
    self.pool.unique_connection, _connection
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2266, in _wrap_pool_connect
    e, dialect, self
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1536, in _handle_dbapi_exception_noconnection
    util.raise_from_cause(sqlalchemy_exception, exc_info)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 383, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 128, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2262, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 303, in unique_connection
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 760, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/langhelpers.py", line 68, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 129, in reraise
    raise value
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 639, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 453, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.6/dist-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/__init__.py", line 85, in Connect
    return Connection(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 208, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (2006, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
(Background on this error at: http://sqlalche.me/e/e3q8)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/modules/database.py", line 428, in ensure_user
    db = self.get_db(db_url, db_name, check_access=True)
  File "/usr/local/lib/python3.6/dist-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/modules/database.py", line 551, in get_db
    return osdb(db_url, db_name)
  File "/usr/local/lib/python3.6/dist-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/db.py", line 149, in __init__
    raise osdbAccessDeniedError
opensipscli.db.osdbAccessDeniedError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2262, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 303, in unique_connection
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 760, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/langhelpers.py", line 68, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 129, in reraise
    raise value
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 639, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 453, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.6/dist-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/__init__.py", line 85, in Connect
    return Connection(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 208, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2006, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/db.py", line 136, in __init__
    self.__conn = self.__engine.connect().\
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2193, in connect
    return self._connection_cls(self, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 103, in __init__
    else engine.raw_connection()
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2293, in raw_connection
    self.pool.unique_connection, _connection
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2266, in _wrap_pool_connect
    e, dialect, self
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1536, in _handle_dbapi_exception_noconnection
    util.raise_from_cause(sqlalchemy_exception, exc_info)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 383, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 128, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2262, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 303, in unique_connection
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 760, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 492, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/impl.py", line 139, in _do_get
    self._dec_overflow()
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/langhelpers.py", line 68, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/util/compat.py", line 129, in reraise
    raise value
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/impl.py", line 136, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 308, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 437, in __init__
    self.__connect(first_connect_check=True)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/pool/base.py", line 639, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.6/dist-packages/SQLAlchemy-1.3.3-py3.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 453, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.6/dist-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/__init__.py", line 85, in Connect
    return Connection(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/mysqlclient-1.3.14-py3.6-linux-x86_64.egg/MySQLdb/connections.py", line 208, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (2006, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
(Background on this error at: http://sqlalche.me/e/e3q8)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/modules/database.py", line 437, in ensure_user
    db = self.get_db(db_url, db_name, check_access=True)
  File "/usr/local/lib/python3.6/dist-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/modules/database.py", line 551, in get_db
    return osdb(db_url, db_name)
  File "/usr/local/lib/python3.6/dist-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/db.py", line 149, in __init__
    raise osdbAccessDeniedError
opensipscli.db.osdbAccessDeniedError
ERROR: failed to connect to {} with non-admin user

'user add' occurs error with PostgreSQL

hi, when using with postgresql, executing 'user add' reports error "'osdb' object has no attribute 'use'". The detail information is as follows:
[root@localhost opensips-cli]# python3 bin/opensips-cli -x user add [email protected]:5060 123456
SQLAlchemy version: 1.3.4
Please provide us the URL of the database: postgres://opensips:[email protected]/postgres
Traceback (most recent call last):
File "bin/opensips-cli", line 9, in
run_console()
File "bin/opensips-cli", line 6, in run_console
main.main()
File "/usr/local/python3/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/main.py", line 78, in main
sys.exit(shell.cmdloop())
File "/usr/local/python3/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/cli.py", line 225, in cmdloop
ret = self.run_command(self.command[0], command, params)
File "/usr/local/python3/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/cli.py", line 331, in run_command
return mod[0].invoke(cmd, params)
File "/usr/local/python3/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/module.py", line 36, in invoke
return f(params)
File "/usr/local/python3/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/modules/user.py", line 103, in do_add
db = self.user_db_connect()
File "/usr/local/python3/lib/python3.6/site-packages/opensipscli-0.1-py3.6.egg/opensipscli/modules/user.py", line 55, in user_db_connect
db.use()
AttributeError: 'osdb' object has no attribute 'use'

ERROR:xcap:mod_init: error during table version check.

Apr 25 16:41:35 opensips systemd[1]: opensips.service: Service RestartSec=100ms expired, scheduling restart.
Apr 25 16:41:35 opensips systemd[1]: opensips.service: Scheduled restart job, restart counter is at 4.
Apr 25 16:41:35 opensips systemd[1]: Stopped OpenSIPS is a very fast and flexible SIP (RFC3261) server.
Apr 25 16:41:35 opensips systemd[1]: Starting OpenSIPS is a very fast and flexible SIP (RFC3261) server...
Apr 25 16:41:35 opensips opensips: INFO:tls_mgm:mod_load: openssl version: OpenSSL 1.1.1d 10 Sep 2019
Apr 25 16:41:35 opensips opensips: INFO:core:fix_poll_method: using epoll as the IO watch method (auto detected)
Apr 25 16:41:35 opensips opensips[28933]: Listening on
Apr 25 16:41:35 opensips opensips[28933]: udp: 192.168.7.243 [192.168.7.243]:5060
Apr 25 16:41:35 opensips opensips[28933]: tcp: 192.168.7.243 [192.168.7.243]:5060
Apr 25 16:41:35 opensips opensips[28933]: tls: 192.168.7.243 [192.168.7.243]:5061
Apr 25 16:41:35 opensips opensips[28933]: Aliases:
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: NOTICE:core:main: version: opensips 3.1.0-dev (x86_64/linux)
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:main: using 512 Mb of shared memory
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:main: using 32 Mb of private process memory
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: WARNING:core:init_reactor_size: shrinking reactor size from 262144 (autodetected via rlimit) to 83886 (limited by memory of 10% from 32Mb)
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: WARNING:core:init_reactor_size: use 'open_files_limit' to enforce other limit or increase pkg memory
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:init_reactor_size: reactor size 83886 (using up to 3.20Mb of memory per process)
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:evi_publish_event: Registered event <E_CORE_THRESHOLD(0)>
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:evi_publish_event: Registered event <E_CORE_SHM_THRESHOLD(1)>
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:evi_publish_event: Registered event <E_CORE_PKG_THRESHOLD(2)>
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:evi_publish_event: Registered event <E_CORE_PROC_AUTO_SCALE(3)>
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:tm:mod_init: TM - initializing...
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:sl:mod_init: Initializing StateLess engine
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: NOTICE:signaling:mod_init: initializing module ...
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:rr:mod_init: rr - initializing
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:maxfwd:mod_init: initializing...
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:sipmsgops:mod_init: initializing...
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:evi_publish_event: Registered event <E_MYSQL_CONNECTION(4)>
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: WARNING:usrloc:check_runtime_config: 'db_mode' is now deprecated, use 'working_mode_preset'!
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:usrloc:ul_init_locks: locks array size 512
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:evi_publish_event: Registered event <E_UL_AOR_INSERT(5)>
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:evi_publish_event: Registered event <E_UL_AOR_DELETE(6)>
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:evi_publish_event: Registered event <E_UL_CONTACT_INSERT(7)>
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:evi_publish_event: Registered event <E_UL_CONTACT_DELETE(8)>
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:evi_publish_event: Registered event <E_UL_CONTACT_UPDATE(9)>
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:evi_publish_event: Registered event <E_UL_LATENCY_UPDATE(10)>
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:registrar:mod_init: initializing...
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:dialog:mod_init: Dialog module - initializing
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:evi_publish_event: Registered event <E_DLG_STATE_CHANGED(11)>
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:acc:mod_init: initializing...
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:evi_publish_event: Registered event <E_ACC_EVENT(12)>
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:evi_publish_event: Registered event <E_ACC_CDR(13)>
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:evi_publish_event: Registered event <E_ACC_MISSED_EVENT(14)>
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:auth:mod_init: initializing...
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:auth_db:mod_init: initializing...
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:alias_db:mod_init: initializing...
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: ERROR:core:db_check_table_version: invalid version 1 for table xcap found, expected 4
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: ERROR:xcap:mod_init: error during table version check.
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: ERROR:core:init_mod: failed to initialize module xcap
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: ERROR:core:main: error while initializing modules
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: INFO:core:cleanup: cleanup
Apr 25 16:41:35 opensips /usr/local/opensips/sbin/opensips[28935]: NOTICE:core:main: Exiting....

History file does not rotate

The history file seems to be getting stuck at 1000 entries by default. Once this is reached, the "recording" functionality stops working, discarding all new commands.

mysqlclient install error

Hi
I am installing opensips-cli on debian 9 and already installed mysql and opensips.
I done installation according procedure but when installing mysqlclient I see this errors:

`` Collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/4d/38/c5f8bac9c50f3042c8f05615f84206f77f03db79781db841898fde1bb284/mysqlclient-1.4.4.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: 1: mysql_config: not found
/bin/sh: 1: mariadb_config: not found
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-x6068whh/mysqlclient/setup.py", line 16, in
metadata, options = get_config()
File "/tmp/pip-build-x6068whh/mysqlclient/setup_posix.py", line 61, in get_config
libs = mysql_config("libs")
File "/tmp/pip-build-x6068whh/mysqlclient/setup_posix.py", line 29, in mysql_config
raise EnvironmentError("%s not found" % (_mysql_config_path,))
OSError: mysql_config not found

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-x6068whh/mysqlclient/``

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.