From 4d58f1b7def947b81ec387064008d2195ed09152 Mon Sep 17 00:00:00 2001 From: Prabuddha Chakraborty Date: Fri, 7 Aug 2015 16:08:14 +0530 Subject: [PATCH] Update credential issue of Mysql --- ee/cli/plugins/stack_migrate.py | 6 +++++- ee/core/mysql.py | 5 ++++- ee/core/variables.py | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ee/cli/plugins/stack_migrate.py b/ee/cli/plugins/stack_migrate.py index 5c474295..17a15123 100644 --- a/ee/cli/plugins/stack_migrate.py +++ b/ee/cli/plugins/stack_migrate.py @@ -46,7 +46,11 @@ class EEStackMigrateController(CementBaseController): keyserver="keyserver.ubuntu.com") config = configparser.ConfigParser() - config.read('/etc/mysql/conf.d/my.cnf') + if os.path.exists('/etc/mysql/conf.d/my.cnf'): + config.read('/etc/mysql/conf.d/my.cnf') + else: + config.read(os.path.expanduser("~")+'/.my.cnf') + try: chars = config['client']['password'] except Exception as e: diff --git a/ee/core/mysql.py b/ee/core/mysql.py index 7216dd22..b4aa231d 100644 --- a/ee/core/mysql.py +++ b/ee/core/mysql.py @@ -30,7 +30,10 @@ class EEMysql(): def connect(self): """Makes connection with MySQL server""" try: - connection = pymysql.connect(read_default_file='/etc/mysql/conf.d/my.cnf') + if os.path.exists('/etc/mysql/conf.d/my.cnf'): + connection = pymysql.connect(read_default_file='/etc/mysql/conf.d/my.cnf') + else: + connection = pymysql.connect(read_default_file='~/.my.cnf') return connection except ValueError as e: Log.debug(self, str(e)) diff --git a/ee/core/variables.py b/ee/core/variables.py index ea5d33a0..63fb9644 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -70,7 +70,10 @@ class EEVariables(): # MySQL hostname ee_mysql_host = "" config = configparser.RawConfigParser() - cnfpath = "/etc/mysql/conf.d/my.cnf" + if os.path.exists('/etc/mysql/conf.d/my.cnf'): + cnfpath = "/etc/mysql/conf.d/my.cnf" + else: + cnfpath = os.path.expanduser("~")+"/.my.cnf" if [cnfpath] == config.read(cnfpath): try: ee_mysql_host = config.get('client', 'host')