device42 / Racktables-to-Device42-Migration

Migrate Racktables data to Device42
MIT License
6 stars 4 forks source link

AttributeError: __exit__ #8

Open jbcreek opened 4 years ago

jbcreek commented 4 years ago

Racktables 0.20.14 Device42 16.13.00.1591900201 Python 2.7 pymysql and requests installed

I believe my conf file is correct.

When I run the script, I receive the following:

[!] Version 5.33 Traceback (most recent call last): File "./racktables2device42.py", line 1265, in <module> main() File "./racktables2device42.py", line 1249, in main db.get_subnets() File "./racktables2device42.py", line 335, in get_subnets with self.con: AttributeError: __exit__

osanchez42 commented 4 years ago

Hello @jbcreek, this appears to be a connection issue with racktables DB. Please verify your configuration and that you can connect to your DB from a console. If you need more help with this, please contact us using any of our contact methods here and we would be happy to help.

https://www.device42.com/contact/

jbcreek commented 4 years ago

I can login from the console with the configuration in the conf file.

====== MySQL Source (Racktables) ======

DB_IP = '' DB_PORT = '3306' DB_NAME = 'racktables' DB_USER = 'device42' DB_PWD = 'dbpassword'

[root@racks2d42 ~]# mysql -u device42 -p -h ------- Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 1432762 Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]>

osanchez42 commented 4 years ago

please verify that racktables is listed as a database in your sql console and the user has the correct grants to read the tables.

show databases;

I highly recommend contacting Device42 support for any needs as I do not want to expose any of your information publicly. I will test the script to ensure that this is not a racktables issue. I will also get a list of dependency versions to make sure this is not the issue

jbcreek commented 4 years ago

I can access the database with that user.

[root@racks2d42 ~]# mysql -u device42 -p -h 10.1.245.11 Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 1433293 Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | racktables | +--------------------+ 3 rows in set (0.05 sec)

MySQL [(none)]> use racktables; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A

Database changed

I obfuscated the password.

I will try to contact Device42 support. I have not purchased the product yet so not sure how much help they will give.

osanchez42 commented 4 years ago

More than happy to help @jbcreek . Let me get a dependency list to be sure that everything is correct in your environment. We are currently in the process of updating our github scripts and this racktables script has some changes that have not been merged in with the master branch yet.

osanchez42 commented 4 years ago

@jbcreek This appears to be a sql version conflict with the pymysql version current used on the branch (Python 2.7). The changes to python 3 version include updated dependencies and can be found in the link below. I cannot move this over to the master branch on the D42 repo until it is approved by our QA team. You may use this script to meet your needs. I will look into getting this update expedited so you and any other customer using this script do no run into the same issue.

https://github.com/osanchez42/Racktables-to-Device42-Migration/tree/python-3-upgrade

Python 3.7.x

Here is the list of dependencies you will need.

certifi==2020.4.5.1 chardet==3.0.4 configparser==4.0.2 idna==2.9 ipaddress==1.0.23 PyMySQL==0.9.3 requests==2.23.0 urllib3==1.25.9

(you can add these to a file named requirements.txt) and in your python 3.7.x environment run pip install -r requirements.txt

jbcreek commented 4 years ago

@osanchez42 Followed your instructions and it is working great. Thanks!