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
cec4eff0
Commit
cec4eff0
authored
9 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
with dry_run, show usage of blog data
parent
bcfb972a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
noblogsmv/main.py
+28
-10
28 additions, 10 deletions
noblogsmv/main.py
with
28 additions
and
10 deletions
noblogsmv/main.py
+
28
−
10
View file @
cec4eff0
...
...
@@ -17,6 +17,8 @@ MYSQL_URI_RE = re.compile(
log
=
logging
.
getLogger
(
__name__
)
dry_run
=
False
def
execute_gen
(
cmd
,
dry_run
=
False
):
if
dry_run
:
...
...
@@ -89,16 +91,29 @@ def process_move_data(blog_id, value, progress):
progress
.
update
(
'
moving blog data
'
)
log
.
info
(
'
moving data for %s
'
,
blog_id
)
blog_dir
=
os
.
path
.
join
(
BLOGS_DIR
,
blog_id
)
cmd
=
sshcmd
(
'
root@%s
'
%
value
[
'
old_host
'
],
'
rsync
'
,
'
-az
'
,
'
%s/
'
%
blog_dir
,
'
root@%s:%s
'
%
(
value
[
'
new_host
'
],
blog_dir
))
log
.
debug
(
'
Calling %s
'
,
'
'
.
join
(
cmd
))
try
:
execute
(
cmd
)
except
(
subprocess
.
CalledProcessError
,
OSError
),
e
:
progress
.
update
(
'
moving blog data failed, retrying
'
)
log
.
info
(
'
Could not move data for blog %s: %s
'
,
blog_id
,
e
)
return
None
if
not
dry_run
:
cmd
=
sshcmd
(
'
root@%s
'
%
value
[
'
old_host
'
],
'
rsync
'
,
'
-az
'
,
'
%s/
'
%
blog_dir
,
'
root@%s:%s
'
%
(
value
[
'
new_host
'
],
blog_dir
))
log
.
debug
(
'
Calling %s
'
,
'
'
.
join
(
cmd
))
try
:
execute
(
cmd
)
except
(
subprocess
.
CalledProcessError
,
OSError
),
e
:
progress
.
update
(
'
moving blog data failed, retrying
'
)
log
.
info
(
'
Could not move data for blog %s: %s
'
,
blog_id
,
e
)
return
None
else
:
cmd
=
sshcmd
(
'
root@%s
'
%
value
[
'
old_host
'
],
'
du
'
,
'
-s
'
,
blog_dir
)
try
:
usage
=
int
(
subprocess
.
check_output
(
cmd
))
log
.
info
(
'
blog %s on %s usage: %d Kb
'
,
blog_id
,
value
[
'
old_host
'
],
usage
)
except
(
subprocess
.
CalledProcessError
,
OSError
),
e
:
log
.
error
(
'
error retrieving usage for blog %s@%s: %s
'
,
blog_id
,
value
[
'
old_host
'
],
e
)
progress
.
update
(
'
moved blog data
'
)
log
.
info
(
'
Moved data for blog %s
'
,
blog_id
)
...
...
@@ -258,6 +273,9 @@ use the `--recover' option.
global
execute
execute
=
partial
(
execute_gen
,
dry_run
=
opts
.
dry_run
)
global
dry_run
dry_run
=
opts
.
dry_run
if
opts
.
clean
:
statemachine
=
NoblogsCleanStateMachine
else
:
...
...
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