Skip to content

Commit

Permalink
Revert commit 4bd814c
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Nov 8, 2019
1 parent d38ea3c commit ecce9cd
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 18 deletions.
15 changes: 9 additions & 6 deletions IM/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@
SQLITE_AVAILABLE = False

try:
import mysql.connector as mdb
import MySQLdb as mdb
MYSQL_AVAILABLE = True
except:
MYSQL_AVAILABLE = False

if not MYSQL_AVAILABLE:
try:
import pymysql as mdb
MYSQL_AVAILABLE = True
except:
MYSQL_AVAILABLE = False

try:
from pymongo import MongoClient
MONGO_AVAILABLE = True
Expand Down Expand Up @@ -121,11 +128,7 @@ def _connect_mysql(self, url, db):
username, password, server, port = self._get_user_pass_host_port(url)
if not port:
port = 3306
self.connection = mdb.connect(host=server,
port=port,
user=username,
password=password,
database=db)
self.connection = mdb.connect(server, username, password, db, port)
self.db_type = DataBase.MYSQL
return True
else:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ distributions or ``boto`` pip package. It can also be downloaded from boto GitHu
Download the file and copy the boto subdirectory into the IM install path.

In case of using the a MySQL DB as the backend to store IM data. The Python interface to MySQL
must be installed, typically available as the package ``python-mysql.connector`` in Debian based
distributions or ``mysql-connector-python`` in RedHat ones. It is also available on pip as the
``mysql-connector-python`` package.
must be installed, typically available as the package ``python-mysqldb`` or ``MySQL-python`` package.
In case of using Python 3 use the PyMySQL package, available as the package ``python3-pymysql`` on
debian systems or ``PyMySQL`` package in pip.

In case of using the a MongoDB as the backend to store IM data. The Python interface to MongoDB
must be installed, typically available as the package ``python-pymongo``package in most distributions
Expand Down
2 changes: 1 addition & 1 deletion ansible_install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
ignore_errors: yes

- name: Install pip libraries
pip: executable=pip name=pycrypto,pyOpenSSL,mysql-connector-python,msrest,msrestazure,azure-common,azure-mgmt-storage,azure-mgmt-compute,azure-mgmt-network,azure-mgmt-resource,azure-mgmt-dns,azure-storage,xmltodict
pip: executable=pip name=pycrypto,pyOpenSSL,MySQL-python,msrest,msrestazure,azure-common,azure-mgmt-storage,azure-mgmt-compute,azure-mgmt-network,azure-mgmt-resource,azure-mgmt-dns,azure-storage,xmltodict

- name: Install IM dependencies for CentOS 6
pip: name=pysqlite version=2.7.0
Expand Down
6 changes: 3 additions & 3 deletions doc/source/manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ Optional Packages
with SSL certificates (see :confval:`REST_SSL`).
pyOpenSSL can be installed using pip.
* `The Python interface to MySQL <https://www.mysql.com/>`_, is needed to access MySQL server as IM data
backend. It is typically available as the package as the package 'python-mysql.connector' in Debian based
distributions or 'mysql-connector-python' in RedHat ones. It is also available on pip as the
'mysql-connector-python' package.
backend. It is typically available as the package 'python-mysqldb' or 'MySQL-python' package. In case of
using Python 3 use the PyMySQL package, available as the package 'python3-pymysql' on debian systems or PyMySQL
package in pip.
*`The Python interface to MongoDB <https://www.mongodb.com/>`_, is needed to access MongoDB server as IM data
backend. It is typically available as the package 'python-pymongo' package in most distributions or pymongo
package in pip.
Expand Down
2 changes: 1 addition & 1 deletion docker-devel/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN cd tmp \
&& pip install /tmp/im

# Install pip optional libraries
RUN pip install mysql-connector-python pyOpenSSL cheroot==8.1.0 pymongo msrest msrestazure azure-common azure-mgmt-storage azure-mgmt-compute azure-mgmt-network azure-mgmt-resource azure-mgmt-dns azure-storage
RUN pip install MySQL-python pyOpenSSL cheroot==8.1.0 pymongo msrest msrestazure azure-common azure-mgmt-storage azure-mgmt-compute azure-mgmt-network azure-mgmt-resource azure-mgmt-dns azure-storage

# Set the VM_NUM_USE_CTXT_DIST to 3 for the tests
RUN sed -i -e 's/VM_NUM_USE_CTXT_DIST = 30/VM_NUM_USE_CTXT_DIST = 3/g' /etc/im/im.cfg
Expand Down
4 changes: 2 additions & 2 deletions docker-py3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ LABEL description="Container image to run the IM service. (http://www.grycap.upv
EXPOSE 8899 8800

# Ensure system is up to date with mandatory python packages installed
RUN apt-get update && apt-get install --no-install-recommends -y python3 openssh-client sshpass vim libmysqlclient20 && \
RUN apt-get update && apt-get install --no-install-recommends -y python3 openssh-client sshpass vim libmysqlclient20 python3-mysqldb && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && rm -rf ~/.cache/

# Install IM
RUN apt-get update && apt-get install --no-install-recommends -y gcc git python3-dev python3-pip libssl-dev libffi-dev libsqlite3-dev && \
pip3 install setuptools --upgrade -I && \
pip3 install pip --upgrade -I && \
/usr/local/bin/pip3 install msrest msrestazure azure-common azure-mgmt-storage azure-mgmt-compute azure-mgmt-network azure-mgmt-resource azure-mgmt-dns azure-storage && \
/usr/local/bin/pip3 install mysql-connector-python pyOpenSSL pycrypto cheroot xmltodict pymongo ansible==2.7.13 && \
/usr/local/bin/pip3 install pyOpenSSL pycrypto cheroot xmltodict pymongo ansible==2.7.13 && \
/usr/local/bin/pip3 install IM==1.8.7 && \
/usr/local/bin/pip3 uninstall pip -y && \
apt-get purge -y gcc git libssl-dev libffi-dev libsqlite3-dev python3-dev python3-pip && \
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y gcc git python
pip install setuptools --upgrade -I && \
pip install pip --upgrade -I && \
/usr/local/bin/pip install msrest msrestazure azure-common azure-mgmt-storage azure-mgmt-compute azure-mgmt-network azure-mgmt-resource azure-mgmt-dns azure-storage && \
/usr/local/bin/pip install mysql-connector-python pyOpenSSL pycrypto xmltodict pymongo && \
/usr/local/bin/pip install MySQL-python pyOpenSSL pycrypto xmltodict pymongo && \
/usr/local/bin/pip install IM==1.8.7 && \
/usr/local/bin/pip uninstall pip -y && \
apt-get purge -y gcc git python-dev python-pip libmysqld-dev libssl-dev libffi-dev libsqlite3-dev && \
Expand Down
2 changes: 1 addition & 1 deletion packages/generate_rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

yum -y install rpm-build python-setuptools
echo "%_unpackaged_files_terminate_build 0" > ~/.rpmmacros
python setup.py bdist_rpm --release="$1" --requires="which, mysql-connector-python, python-sqlite3dbm, RADL, ansible, python-paramiko, PyYAML, python-suds, python-boto >= 2.29, python-libcloud, python-bottle, python-netaddr, python-scp, python-cherrypy, python-requests, python-xmltodict, tosca-parser"
python setup.py bdist_rpm --release="$1" --requires="which, MySQL-python, python-sqlite3dbm, RADL, ansible, python-paramiko, PyYAML, python-suds, python-boto >= 2.29, python-libcloud, python-bottle, python-netaddr, python-scp, python-cherrypy, python-requests, python-xmltodict, tosca-parser"
mkdir dist_pkg
cp dist/*.noarch.rpm dist_pkg

0 comments on commit ecce9cd

Please sign in to comment.