From 975d7952b956ff004b5e97ecf2a52a86a034f567 Mon Sep 17 00:00:00 2001
From: Kenny Gryp <kenny.gryp@percona.com>
Date: Tue, 3 Nov 2015 16:44:00 +0100
Subject: [PATCH 1/3] including error code and error number when database
 connection creation fails

---
 database/mysql/mysql_replication.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/database/mysql/mysql_replication.py b/database/mysql/mysql_replication.py
index 348f49df6c2..c8e342a1d23 100644
--- a/database/mysql/mysql_replication.py
+++ b/database/mysql/mysql_replication.py
@@ -337,7 +337,8 @@ def main():
         else:
             db_connection = MySQLdb.connect(host=module.params["login_host"], port=module.params["login_port"], user=login_user, passwd=login_password)
     except Exception, e:
-        module.fail_json(msg="unable to connect to database, check login_user and login_password are correct or ~/.my.cnf has the credentials")
+        errno, errstr = e.args
+        module.fail_json(msg="unable to connect to database, check login_user and login_password are correct or ~/.my.cnf has the credentials (%s: %s)" % (errno, errstr) )
     try:
         cursor = db_connection.cursor(cursorclass=MySQLdb.cursors.DictCursor)
     except Exception, e:

From e1c1ea9013dcde6e66b8e21e35bbce9638fa4e7e Mon Sep 17 00:00:00 2001
From: Kenny Gryp <kenny.gryp@percona.com>
Date: Mon, 9 Nov 2015 10:05:53 +0100
Subject: [PATCH 2/3] in order for replication setup to work, some errors
 should be ignored

---
 database/mysql/mysql_replication.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/database/mysql/mysql_replication.py b/database/mysql/mysql_replication.py
index c8e342a1d23..f01ffa76dc3 100644
--- a/database/mysql/mysql_replication.py
+++ b/database/mysql/mysql_replication.py
@@ -311,7 +311,7 @@ def main():
     if not mysqldb_found:
         module.fail_json(msg="the python mysqldb module is required")
     else:
-        warnings.filterwarnings('error', category=MySQLdb.Warning)
+        warnings.filterwarnings('ignore', category=MySQLdb.Warning)
 
     # Either the caller passes both a username and password with which to connect to
     # mysql, or they pass neither and allow this module to read the credentials from

From 53d42cd8d870db500ff623c158365762c5b31a0b Mon Sep 17 00:00:00 2001
From: Kenny Gryp <kenny.gryp@percona.com>
Date: Mon, 9 Nov 2015 10:07:15 +0100
Subject: [PATCH 3/3] revert to unbreak pull request

---
 database/mysql/mysql_replication.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/database/mysql/mysql_replication.py b/database/mysql/mysql_replication.py
index f01ffa76dc3..c8e342a1d23 100644
--- a/database/mysql/mysql_replication.py
+++ b/database/mysql/mysql_replication.py
@@ -311,7 +311,7 @@ def main():
     if not mysqldb_found:
         module.fail_json(msg="the python mysqldb module is required")
     else:
-        warnings.filterwarnings('ignore', category=MySQLdb.Warning)
+        warnings.filterwarnings('error', category=MySQLdb.Warning)
 
     # Either the caller passes both a username and password with which to connect to
     # mysql, or they pass neither and allow this module to read the credentials from