Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
09f7b11d
Commit
09f7b11d
authored
Jan 14, 2014
by
jctanner
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5435 from jkleckner/fix-mysql-dump-import
mysql_db module: make dump and import to use port argument
parents
6e39adb8
dacef191
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
library/database/mysql_db
+8
-6
No files found.
library/database/mysql_db
View file @
09f7b11d
...
...
@@ -116,13 +116,13 @@ def db_delete(cursor, db):
cursor
.
execute
(
query
)
return
True
def
db_dump
(
module
,
host
,
user
,
password
,
db_name
,
target
,
socket
=
None
):
def
db_dump
(
module
,
host
,
user
,
password
,
db_name
,
target
,
port
,
socket
=
None
):
cmd
=
module
.
get_bin_path
(
'mysqldump'
,
True
)
cmd
+=
" --quick --user=
%
s --password=
%
s
"
%
(
user
,
password
)
cmd
+=
" --quick --user=
%
s --password=
'
%
s'
"
%
(
user
,
password
)
if
socket
is
not
None
:
cmd
+=
" --socket=
%
s"
%
socket
else
:
cmd
+=
" --host=
%
s
"
%
host
cmd
+=
" --host=
%
s
--port=
%
s"
%
(
host
,
port
)
cmd
+=
"
%
s"
%
db_name
if
os
.
path
.
splitext
(
target
)[
-
1
]
==
'.gz'
:
cmd
=
cmd
+
' | gzip > '
+
target
...
...
@@ -133,13 +133,13 @@ def db_dump(module, host, user, password, db_name, target, socket=None):
rc
,
stdout
,
stderr
=
module
.
run_command
(
cmd
)
return
rc
,
stdout
,
stderr
def
db_import
(
module
,
host
,
user
,
password
,
db_name
,
target
,
socket
=
None
):
def
db_import
(
module
,
host
,
user
,
password
,
db_name
,
target
,
port
,
socket
=
None
):
cmd
=
module
.
get_bin_path
(
'mysql'
,
True
)
cmd
+=
" --user=
%
s --password=
%
s
"
%
(
user
,
password
)
cmd
+=
" --user=
%
s --password=
'
%
s'
"
%
(
user
,
password
)
if
socket
is
not
None
:
cmd
+=
" --socket=
%
s"
%
socket
else
:
cmd
+=
" --host=
%
s
"
%
host
cmd
+=
" --host=
%
s
--port=
%
s"
%
(
host
,
port
)
cmd
+=
" -D
%
s"
%
db_name
if
os
.
path
.
splitext
(
target
)[
-
1
]
==
'.gz'
:
cmd
=
'gunzip < '
+
target
+
' | '
+
cmd
...
...
@@ -282,6 +282,7 @@ def main():
elif
state
==
"dump"
:
rc
,
stdout
,
stderr
=
db_dump
(
module
,
login_host
,
login_user
,
login_password
,
db
,
target
,
port
=
module
.
params
[
'login_port'
],
socket
=
module
.
params
[
'login_unix_socket'
])
if
rc
!=
0
:
module
.
fail_json
(
msg
=
"
%
s"
%
stderr
)
...
...
@@ -290,6 +291,7 @@ def main():
elif
state
==
"import"
:
rc
,
stdout
,
stderr
=
db_import
(
module
,
login_host
,
login_user
,
login_password
,
db
,
target
,
port
=
module
.
params
[
'login_port'
],
socket
=
module
.
params
[
'login_unix_socket'
])
if
rc
!=
0
:
module
.
fail_json
(
msg
=
"
%
s"
%
stderr
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment