Blob Blame History Raw
From 3d4cf0365d520be81abfe3435fa9a8a56a933961 Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Mon, 20 Oct 2014 09:31:32 +0100
Subject: [PATCH 1/2] [mysql] obtain dbpass from the environment

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
 sos/plugins/mysql.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/sos/plugins/mysql.py b/sos/plugins/mysql.py
index 8bc6e72..1203f5c 100644
--- a/sos/plugins/mysql.py
+++ b/sos/plugins/mysql.py
@@ -13,7 +13,7 @@
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
-
+import os
 
 class Mysql(Plugin):
     """MySQL and MariaDB RDBMS
@@ -25,7 +25,7 @@ class Mysql(Plugin):
 
     option_list = [
         ("dbuser", "username for database dumps", "", "mysql"),
-        ("dbpass", "password for database dumps", "", ""),
+        ("dbpass", "password for database dumps", "", False),
         ("dbdump", "collect a database dump", "", False)
     ]
 
@@ -44,7 +44,14 @@ class Mysql(Plugin):
         if self.get_option("dbdump"):
             dbuser = self.get_option("dbuser")
             dbpass = self.get_option("dbpass")
-            opts = "--user=%s --password=%s --all-databases" % (dbuser, dbpass)
+            if dbpass == False and 'MYSQL_PWD' in os.environ:
+                dbpass = os.environ['MYSQL_PWD']
+            else:
+                # no MySQL password
+                return
+            os.environ['MYSQL_PWD'] = dbpass
+
+            opts = "--user=%s --all-databases" % dbuser
             name = "mysqldump_--all-databases"
             self.add_cmd_output("mysqldump %s" % opts, suggest_filename=name)
 
-- 
1.9.3


From 6ce502113f550c027424fa477edc091283c32e50 Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Mon, 20 Oct 2014 14:33:57 +0100
Subject: [PATCH 2/2] [mysql] fix pep8 violations

The previous commit had a couple of pep8 errors that were fixed
in the working tree but not added to the commit; fix them.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
 sos/plugins/mysql.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sos/plugins/mysql.py b/sos/plugins/mysql.py
index 1203f5c..d148472 100644
--- a/sos/plugins/mysql.py
+++ b/sos/plugins/mysql.py
@@ -15,6 +15,7 @@
 from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
 import os
 
+
 class Mysql(Plugin):
     """MySQL and MariaDB RDBMS
     """
@@ -44,7 +45,7 @@ class Mysql(Plugin):
         if self.get_option("dbdump"):
             dbuser = self.get_option("dbuser")
             dbpass = self.get_option("dbpass")
-            if dbpass == False and 'MYSQL_PWD' in os.environ:
+            if dbpass is False and 'MYSQL_PWD' in os.environ:
                 dbpass = os.environ['MYSQL_PWD']
             else:
                 # no MySQL password
-- 
1.9.3