Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
noblogsmv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ai
noblogsmv
Commits
d2f39e77
Commit
d2f39e77
authored
10 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
set some useful ssh options
parent
d7bef3b3
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
noblogsmv/main.py
+13
-12
13 additions, 12 deletions
noblogsmv/main.py
with
13 additions
and
12 deletions
noblogsmv/main.py
+
13
−
12
View file @
d2f39e77
...
@@ -24,7 +24,6 @@ def execute_gen(cmd, dry_run = False):
...
@@ -24,7 +24,6 @@ def execute_gen(cmd, dry_run = False):
return
subprocess
.
check_output
(
cmd
)
return
subprocess
.
check_output
(
cmd
)
def
init
(
blog_id
,
value
,
progress
):
def
init
(
blog_id
,
value
,
progress
):
return
'
move_data
'
return
'
move_data
'
...
@@ -41,7 +40,6 @@ class MysqlNoblogs(object):
...
@@ -41,7 +40,6 @@ class MysqlNoblogs(object):
self
.
old
=
self
.
conn
(
old_host
,
old_port
,
old_user
,
old_pass
,
old_db
)
self
.
old
=
self
.
conn
(
old_host
,
old_port
,
old_user
,
old_pass
,
old_db
)
self
.
new
=
self
.
conn
(
new_host
,
new_port
,
new_user
,
new_pass
,
new_db
)
self
.
new
=
self
.
conn
(
new_host
,
new_port
,
new_user
,
new_pass
,
new_db
)
def
options
(
self
,
conn
):
def
options
(
self
,
conn
):
return
'
-h%s -P%s -u%s -p%s
'
%
(
conn
.
host
,
conn
.
port
,
return
'
-h%s -P%s -u%s -p%s
'
%
(
conn
.
host
,
conn
.
port
,
conn
.
user
,
conn
.
password
)
conn
.
user
,
conn
.
password
)
...
@@ -57,20 +55,19 @@ class MysqlNoblogs(object):
...
@@ -57,20 +55,19 @@ class MysqlNoblogs(object):
def
find_tables
(
self
,
blog_id
):
def
find_tables
(
self
,
blog_id
):
find_tables
=
[
'
mysql
'
,
self
.
options
(
self
.
old
),
self
.
old
.
db
,
'
-NBe
'
,
find_tables
=
[
'
mysql
'
,
self
.
options
(
self
.
old
),
self
.
old
.
db
,
'
-NBe
'
,
"'
show tables like
\"
wp
\\
_%s
\\
_%%
\"
'"
%
blog_id
]
"'
show tables like
\"
wp
\\
_%s
\\
_%%
\"
'"
%
blog_id
]
cmd
=
[
'
ssh
'
,
'
root@%s
'
%
self
.
old
.
host
,
cmd
=
[
'
ssh
'
,
'
-o
'
,
'
BatchMode=yes
'
,
'
-o
'
,
'
StrictHostKeyChecking=no
'
,
"
%s
"
%
'
'
.
join
(
find_tables
)]
'
root@%s
'
%
self
.
old
.
host
,
'
%s
'
%
'
'
.
join
(
find_tables
)]
log
.
debug
(
'
Calling %s
'
,
'
'
.
join
(
cmd
))
log
.
debug
(
'
Calling %s
'
,
'
'
.
join
(
cmd
))
raw_tables
=
subprocess
.
check_output
(
cmd
)
raw_tables
=
subprocess
.
check_output
(
cmd
)
self
.
tables
=
[
t
.
strip
()
for
t
in
raw_tables
.
splitlines
()]
self
.
tables
=
[
t
.
strip
()
for
t
in
raw_tables
.
splitlines
()]
def
process_move_data
(
blog_id
,
value
,
progress
):
def
process_move_data
(
blog_id
,
value
,
progress
):
progress
.
update
(
'
moving blog data
'
)
progress
.
update
(
'
moving blog data
'
)
log
.
info
(
'
moving data for %s
'
,
blog_id
)
log
.
info
(
'
moving data for %s
'
,
blog_id
)
blog_dir
=
os
.
path
.
join
(
BLOGS_DIR
,
blog_id
)
blog_dir
=
os
.
path
.
join
(
BLOGS_DIR
,
blog_id
)
cmd
=
[
'
ssh
'
,
'
root@%s
'
%
value
[
'
old_host
'
],
'
rsync
'
,
'
-az
'
,
cmd
=
[
'
ssh
'
,
'
-o
'
,
'
BatchMode=yes
'
,
'
-o
'
,
'
StrictHostKeyChecking=no
'
,
'
root@%s
'
%
value
[
'
old_host
'
],
'
rsync
'
,
'
-az
'
,
'
%s/
'
%
blog_dir
,
'
root@%s:%s
'
%
(
value
[
'
new_host
'
],
blog_dir
)]
'
%s/
'
%
blog_dir
,
'
root@%s:%s
'
%
(
value
[
'
new_host
'
],
blog_dir
)]
log
.
debug
(
'
Calling %s
'
,
'
'
.
join
(
cmd
))
log
.
debug
(
'
Calling %s
'
,
'
'
.
join
(
cmd
))
try
:
try
:
...
@@ -106,7 +103,8 @@ def process_move_db(blog_id, value, progress):
...
@@ -106,7 +103,8 @@ def process_move_db(blog_id, value, progress):
tables
=
'
'
.
join
(
db
.
tables
)
tables
=
'
'
.
join
(
db
.
tables
)
move_db
=
[
'
mysqldump
'
,
'
--opt
'
,
db
.
old_options
,
value
[
'
old_db
'
],
tables
,
move_db
=
[
'
mysqldump
'
,
'
--opt
'
,
db
.
old_options
,
value
[
'
old_db
'
],
tables
,
'
|
'
,
'
mysql
'
,
db
.
new_options
,
value
[
'
new_db
'
]]
'
|
'
,
'
mysql
'
,
db
.
new_options
,
value
[
'
new_db
'
]]
cmd
=
[
'
ssh
'
,
'
root@%s
'
%
value
[
'
old_host
'
],
'
%s
'
%
'
'
.
join
(
move_db
)]
cmd
=
[
'
ssh
'
,
'
-o
'
,
'
BatchMode=yes
'
,
'
-o
'
,
'
StrictHostKeyChecking=no
'
,
'
root@%s
'
%
value
[
'
old_host
'
],
'
%s
'
%
'
'
.
join
(
move_db
)]
log
.
debug
(
'
Calling %s
'
,
'
'
.
join
(
cmd
))
log
.
debug
(
'
Calling %s
'
,
'
'
.
join
(
cmd
))
try
:
try
:
execute
(
cmd
)
execute
(
cmd
)
...
@@ -137,7 +135,8 @@ def process_rm_db(blog_id, value, progress):
...
@@ -137,7 +135,8 @@ def process_rm_db(blog_id, value, progress):
tables
=
'
,
'
.
join
(
db
.
tables
)
tables
=
'
,
'
.
join
(
db
.
tables
)
drop_db
=
[
'
mysql
'
,
db
.
old_options
,
db
.
old
.
db
,
'
-NBe
'
,
drop_db
=
[
'
mysql
'
,
db
.
old_options
,
db
.
old
.
db
,
'
-NBe
'
,
'"
DROP TABLE %s
"'
%
tables
]
'"
DROP TABLE %s
"'
%
tables
]
cmd
=
[
'
ssh
'
,
'
root@%s
'
%
value
[
'
old_host
'
],
'
%s
'
%
'
'
.
join
(
drop_db
)]
cmd
=
[
'
ssh
'
,
'
-o
'
,
'
BatchMode=yes
'
,
'
-o
'
,
'
StrictHostKeyChecking=no
'
,
'
root@%s
'
%
value
[
'
old_host
'
],
'
%s
'
%
'
'
.
join
(
drop_db
)]
try
:
try
:
execute
(
cmd
)
execute
(
cmd
)
except
(
subprocess
.
CalledProcessError
,
OSError
),
e
:
except
(
subprocess
.
CalledProcessError
,
OSError
),
e
:
...
@@ -147,11 +146,13 @@ def process_rm_db(blog_id, value, progress):
...
@@ -147,11 +146,13 @@ def process_rm_db(blog_id, value, progress):
progress
.
update
(
'
removed blog db; Done.
'
)
progress
.
update
(
'
removed blog db; Done.
'
)
return
state
.
STATE_DONE
return
state
.
STATE_DONE
def
process_rm_data
(
blog_id
,
value
,
progress
):
def
process_rm_data
(
blog_id
,
value
,
progress
):
progress
.
update
(
'
removing blog data files from old location
'
)
progress
.
update
(
'
removing blog data files from old location
'
)
log
.
info
(
'
Removing blog data files
'
)
log
.
info
(
'
Removing blog data files
'
)
blog_dir
=
os
.
path
.
join
(
BLOGS_DIR
,
blog_id
)
blog_dir
=
os
.
path
.
join
(
BLOGS_DIR
,
blog_id
)
cmd
=
[
'
ssh
'
,
'
root@%s
'
%
value
[
'
old_host
'
],
'
rm
'
,
'
-rf
'
,
cmd
=
[
'
ssh
'
,
'
-o
'
,
'
BatchMode=yes
'
,
'
-o
'
,
'
StrictHostKeyChecking=no
'
,
'
root@%s
'
%
value
[
'
old_host
'
],
'
rm
'
,
'
-rf
'
,
'
%s/
'
%
blog_dir
]
'
%s/
'
%
blog_dir
]
log
.
debug
(
'
Calling %s
'
,
'
'
.
join
(
cmd
))
log
.
debug
(
'
Calling %s
'
,
'
'
.
join
(
cmd
))
try
:
try
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment