Skip to content

Commit

Permalink
prepare mysql login
Browse files Browse the repository at this point in the history
  • Loading branch information
mandarjog committed May 13, 2016
1 parent 3adbbb8 commit 1b866ed
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions opsmanapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,16 +389,19 @@ def copy_from_opsman(self, opts, source, target):

def create_ert_databases(self, opts):
file_name = 'create_dbs.ddl'
CMD = (
'mysql --host={PcfRdsAddress} '
'--user={PcfRdsUsername} '
'--password={PcfRdsPassword} '
'< {file_name}')
cmd = CMD.format(
file_name=file_name,
**self.var)

print cmd
cmd = 'mysql < {file_name}'.format(file_name=file_name)
MY_CNF = (
'[client]\n'
'host={PcfRdsAddress}\n'
'user={PcfRdsUsername}\n'
'password={PcfRdsPassword}\n\n'
).format(**self.var)

_, my_cnf_path = tempfile.mkstemp()
with open(my_cnf_path, "wt") as _fll:
_fll.write(MY_CNF)

self.copy_to_opsman(opts, my_cnf_path, ".my.cnf")
self.copy_to_opsman(opts, THIS_DIR+"/"+file_name, file_name)
self.execute_on_opsman(opts, cmd)

Expand Down

0 comments on commit 1b866ed

Please sign in to comment.