The purpose of the Database Management tool (db_manage.py script) is to check, heal and clean inconsistent database entries.
This article explains how to use the latest version of db_manage.py script in various versions of Contrail Server
Segmentation fault (core dumped) while using db_manage.py script which comes as default with every version.
The following error is seen when using the latest version of the script:
(config-api)[root@sm4 /usr/lib/python2.7/site-packages/vnc_cfg_api_server]$ python db_manage.py
Traceback (most recent call last):
File "db_manage.py", line 5, in <module>
from builtins import filter
ImportError: No module named builtins
By default, in each version of Contrail, db_manage.py script is located inside the container 'config_api', located within container '/usr/lib/python2.7/site-packages/vnc_cfg_api_server'
To use the default version of db_manage.py script (which comes with every Contrail install version), refer to
KB36520 - [Contrail] Core dump while using db_manage.py
To use the latest version of the db_manage.py script:
-
Rename the existing db_manage.py - mv db_manage.py db_manage_original_1909.py
Note: Container name may vary as per deployment type.
Latest version of this script - https://raw.githubusercontent.com/tungstenfabric/tf-controller/master/src/config/api-server/vnc_cfg_api_server/db_manage.py
Use wget to pull latest version in the server/container.
-
wget "https://raw.githubusercontent.com/tungstenfabric/tf-controller/master/src/config/api-server/vnc_cfg_api_server/db_manage.py"
Note: In case where container does not have internet connectivity, host (BMS) can be used to download latest version. Then it can be copied into container using docker cp command.
Below is a snippet:
[root@sm4 ~]# wget "https://raw.githubusercontent.com/tungstenfabric/tf-controller/master/src/config/api-server/vnc_cfg_api_server/db_manage.py"
--2021-02-08 16:41:03-- https://raw.githubusercontent.com/tungstenfabric/tf-controller/master/src/config/api-server/vnc_cfg_api_server/db_manage.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.52.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.52.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 148534 (145K) [text/plain]
Saving to: ‘db_manage.py’
100%[============================================================================================================================>] 148,534 --.-K/s in 0.05s
2021-02-08 16:41:04 (2.88 MB/s) - ‘db_manage.py’ saved [148534/148534]
[root@sm4 ~]# ls -al | grep db_manage.py
-rw-r--r--. 1 root root 148534 Feb 8 16:41 db_manage.py
[root@sm4 ~]# docker ps | grep config_api
8ce340066b65 hub.juniper.net/contrail/contrail-controller-config-api:1909.30-ocata "/entrypoint.sh /usr…" 7 days ago Up 7 hours config_api_1
[root@sm4 ~]# docker cp db_manage.py config_api_1:/usr/lib/python2.7/site-packages/vnc_cfg_api_server/
-
Download and Install pip inside config_api container using the following command:
curl https://bootstrap.pypa.io/2.7/get-pip.py --output get-pip.py
Note: In case where container does not have internet connectivity, host (BMS) can be used to download pip and then can be copied into container using docker cp command. ( similar to step 2)
python get-pip.py
Below is a snippet from test server:
(config-api)[root@sm4 /usr/lib/python2.7/site-packages/vnc_cfg_api_server]$ curl https://bootstrap.pypa.io/2.7/get-pip.py --output get-pip.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1863k 100 1863k 0 0 1886k 0 --:--:-- --:--:-- --:--:-- 1886k
(config-api)[root@sm4 /usr/lib/python2.7/site-packages/vnc_cfg_api_server]$ python get-pip.py
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting pip<21.0
Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
|################################| 1.5 MB 812 kB/s
Collecting wheel
Downloading wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Installing collected packages: pip, wheel
Successfully installed pip-20.3.4 wheel-0.36.2
-
Install future using command: pip install future
(config-api)[root@sm4 /usr/lib/python2.7/site-packages/vnc_cfg_api_server]$ pip install future
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting future
Downloading future-0.18.2.tar.gz (829 kB)
|################################| 829 kB 3.2 MB/s
Building wheels for collected packages: future
Building wheel for future (setup.py) ... done
Created wheel for future: filename=future-0.18.2-py2-none-any.whl size=502536 sha256=960c2ca7e38e603c2f43fefa8fc42e2a59b2efc4c8203768137a76390e4ee4d9
Stored in directory: /root/.cache/pip/wheels/5f/11/0c/aad680baf5ef4fbcbab992c9f03e1130357e0c173a4fdabfff
Successfully built future
Installing collected packages: future
Successfully installed future-0.18.2
-
Run 'db_manage script - python db_manage.py <argument>'
. Detailed instruction can be found at Database management tool to check and fix inconsistencies.