From accfff0c66489a62eeea291bd126ed6fe12e3d07 Mon Sep 17 00:00:00 2001 From: Peter Janes Date: Tue, 12 Mar 2013 12:07:16 -0400 Subject: [PATCH] Use login_host for import and dump operations --- mysql_db | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mysql_db b/mysql_db index 53ad2661324..b26fc9c889d 100644 --- a/mysql_db +++ b/mysql_db @@ -103,14 +103,14 @@ def db_delete(cursor, db): cursor.execute(query) return True -def db_dump(user, password, db_name, target): - res = os.system("/usr/bin/mysqldump -q -u "+user+ " -p"+password+" " +def db_dump(host, user, password, db_name, target): + res = os.system("/usr/bin/mysqldump -q -h "+host+"-u "+user+ " -p"+password+" " +db_name+" > " +target) return (res == 0) -def db_import(user, password, db_name, target): - res = os.system("/usr/bin/mysql -u "+user+ " -p"+password+" " +def db_import(host, user, password, db_name, target): + res = os.system("/usr/bin/mysql -h "+host+" -u "+user+ " -p"+password+" " +db_name+" < " +target) return (res == 0) @@ -191,6 +191,7 @@ def main(): login_password = mycnf_creds["passwd"] elif login_password is None or login_user is None: module.fail_json(msg="when supplying login arguments, both login_user and login_password must be provided") + login_host = module.params["login_host"] if state in ['dump','import']: if target is None: @@ -212,11 +213,11 @@ def main(): if state == "absent": changed = db_delete(cursor, db) elif state == "dump": - changed = db_dump(login_user, login_password, db, target) + changed = db_dump(login_host, login_user, login_password, db, target) if not changed: module.fail_json(msg="dump failed!") elif state == "import": - changed = db_import(login_user, login_password, db, target) + changed = db_import(login_host, login_user, login_password, db, target) if not changed: module.fail_json(msg="import failed!") else: