[Bps-public-commit] r14934 - in Pushmi/trunk: . Pushmi-Admin/lib/Pushmi/Admin/Action Pushmi-Admin/lib/Pushmi/Admin/Model Pushmi-Admin/share/web/static/css Pushmi-Admin/share/web/static/images/silk
alexmv at bestpractical.com
alexmv at bestpractical.com
Fri Aug 8 19:00:49 EDT 2008
Author: alexmv
Date: Fri Aug 8 19:00:48 2008
New Revision: 14934
Added:
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Unlock.pm
Pushmi/trunk/Pushmi-Admin/share/web/static/images/silk/database_add.png (contents, props changed)
Pushmi/trunk/Pushmi-Admin/share/web/static/images/silk/database_lightning.png (contents, props changed)
Modified:
Pushmi/trunk/ (props changed)
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Sync.pm
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm
Pushmi/trunk/Pushmi-Admin/share/web/static/css/app.css
Log:
r35587 at kohr-ah: chmrr | 2008-08-08 19:00:44 -0400
* Unlock action, and lock detection
* Some css cleanups
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Sync.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Sync.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Sync.pm Fri Aug 8 19:00:48 2008
@@ -47,8 +47,13 @@
$replica->sync($self->argument_value("bootstrap"));
- if ( $replica->status eq "behind" ) {
+ my $status = $replica->status;
+ if ( $status =~ /^(behind|loading)$/) {
$self->result->message("Synchronization started");
+ } elsif ($status eq "ok") {
+ $self->result->message("Nothing to synchronize");
+ } else {
+ $self->result->error("Synchronization failed");
}
}
Added: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Unlock.pm
==============================================================================
--- (empty file)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Unlock.pm Fri Aug 8 19:00:48 2008
@@ -0,0 +1,32 @@
+use strict;
+use warnings;
+
+=head1 NAME
+
+Pushmi::Admin::Action::Unlock
+
+=cut
+
+package Pushmi::Admin::Action::Unlock;
+use base qw/Pushmi::Admin::Action Jifty::Action/;
+
+use Jifty::Param::Schema;
+use Jifty::Action schema {
+
+ param replica =>
+ type is 'integer',
+ render as 'hidden', is mandatory;
+
+};
+
+sub take_action {
+ my $self = shift;
+
+ my $replica = Pushmi::Admin::Model::Replica->load(
+ $self->argument_value("replica") );
+
+ $replica->unlock;
+ $self->result->message("Replica unlocked");
+}
+
+1;
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm Fri Aug 8 19:00:48 2008
@@ -30,7 +30,7 @@
column status =>
type is 'text',
- is protected, valid_values are [qw/loading ok behind offline failed/];
+ is protected, valid_values are [qw/loading locked ok behind offline failed/];
column dav_root =>
type is 'text',
@@ -130,20 +130,31 @@
$self->sync;
}
-sub sync {
+sub exec_pushmi {
my $self = shift;
- return if $self->pushmi and $self->pushmi->locked;
- my ($bootstrap) = @_;
-
+ my @args = @_;
unless (fork) {
$ENV{PUSHMI_CONFIG} = $self->config_file;
- my @args = ($^X, "-I/home/chmrr/work/bps/Pushmi/lib", Jifty->config->app("pushmi_bin"), "sync", $self->svn_root, "--silent");
- push @args, "--bootstrap", $bootstrap if $bootstrap;
- exec(@args);
+ exec($^X, "-I/home/chmrr/work/bps/Pushmi/lib", Jifty->config->app("pushmi_bin"), @args, "--silent");
}
$self->clear_cache;
}
+sub sync {
+ my $self = shift;
+ my ($bootstrap) = @_;
+ return if $self->pushmi and $self->pushmi->locked;
+ my @args = ("sync", $self->svn_root);
+ push @args, "--bootstrap", $bootstrap if $bootstrap;
+ $self->exec_pushmi(@args);
+}
+
+sub unlock {
+ my $self = shift;
+ return if $self->pushmi and not $self->pushmi->locked;
+ $self->exec_pushmi( unlock => $self->svn_root )
+}
+
sub dump {
my $self = shift;
my($fh) = @_;
@@ -187,7 +198,7 @@
my $c = {};
my $local = Pushmi::Admin->svn_info_for( "file://" . $self->svn_root );
my $remote = Pushmi::Admin->svn_info_for( $self->url );
- if ( not $local or not $self->pushmi ) {
+ if ( not $local or not $self->pushmi or not $self->pushmi->master ) {
$self->set_status("failed");
} elsif ( not $remote ) {
$c->{local_revision} = $local->{rev};
@@ -199,8 +210,14 @@
$c->{latency} = $remote->{latency};
$c->{local_revision} = $local->{rev};
$c->{local_date} = $local->{date};
- if ( $self->pushmi->locked ) {
- $self->set_status("loading");
+ if ( my $lock = $self->pushmi->locked ) {
+ my $host = `hostname`;
+ chomp $host;
+ if ($lock =~ /^$host:(\d+)/ and not kill 0, $1) {
+ $self->set_status("locked");
+ } else {
+ $self->set_status("loading");
+ }
} elsif ( $local->{rev} < $remote->{rev} ) {
$self->set_status("behind");
} else {
@@ -281,6 +298,8 @@
. $self->local_revision
. " revisions locally, last is "
. $self->last_local;
+ } elsif ( $status eq "locked" ) {
+ return "Local repository is locked, but no mirror process is running!";
} elsif ( $status eq "failed" ) {
return "Local repository error!";
}
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm Fri Aug 8 19:00:48 2008
@@ -50,6 +50,7 @@
$check->next_page_button(
label => "Create",
url => "/create",
+ class => "replica create",
)
);
}
@@ -90,7 +91,13 @@
render_param( $new => "dav_root" );
div {
{class is "submit_button"};
- outs_raw( $new->finish_button( label => "Create", url => "/created", class => "submit" ) );
+ outs_raw(
+ $new->finish_button(
+ label => "Create",
+ url => "/created",
+ class => "replica create submit"
+ )
+ );
}
};
}
@@ -158,6 +165,17 @@
form_submit( label => "Start mirroring", onclick => {submit => $sync} );
}
+ } elsif ( $replica->status eq "locked" ) {
+ h2 {"Replica health"};
+ p { "The local replica is locked for updates, but no running process appears to have the lock. If this persists for any length of time, you may wish to explicitly unlock the repository." };
+
+ form {
+ my $sync = Jifty->web->new_action( class => "Unlock", );
+ render_param(
+ $sync => "replica" => default_value => $replica->id );
+
+ form_submit( label => "Force unlock the replica", onclick => {submit => $sync}, class => "replica unlock" );
+ }
} elsif ( $replica->status ne "failed" ) {
h2 {"Replica health"};
p {
@@ -269,17 +287,34 @@
my $replica = get 'replica';
div {
- { class is 'roundbox' };
+ { class is 'roundbox advanced_options' };
h2 { "Advanced options for " . $replica->name . " replica" };
form {
div {
- { class is "delete_replica" };
+ { class is "option" };
+ my $unlock = Jifty->web->new_action( class => "Unlock" );
+ outs_raw(
+ $unlock->button(
+ label => "Force unlock replica",
+ arguments => { replica => $replica->id },
+ url => "/replica/" . $replica->clean_name,
+ class => "replica unlock",
+ )
+ );
+ p {
+ "This will forcably remove the update lock from the replica. This should only be used if the process updating the replica has crashed."
+ };
+ }
+
+ div {
+ { class is "option" };
my $delete = $replica->as_delete_action;
outs_raw(
$delete->button(
- label => "Delete replica",
- url => "/",
+ label => "Delete replica",
+ url => "/",
+ class => "replica delete",
onclick =>
{ confirm => 'Really delete this replica?', }
)
@@ -290,13 +325,14 @@
}
div {
- { class is "remirror_replica" };
+ { class is "option" };
my $remirror = Jifty->web->new_action( class => "Remirror" );
outs_raw(
$remirror->button(
label => "Delete and remirror",
arguments => { replica => $replica->id },
url => "/replica/" . $replica->clean_name,
+ class => "replica remirror",
onclick => {
confirm =>
'Really delete and re-mirror this replica?',
@@ -310,12 +346,13 @@
}
div {
- { class is "backup_replica" }
+ { class is "last option" }
hyperlink(
url => "/replica/"
. $replica->clean_name . "-"
. DateTime->now->ymd . ".gz",
label => "Download backup",
+ class => "replica backup",
as_button => 1
);
p {
Modified: Pushmi/trunk/Pushmi-Admin/share/web/static/css/app.css
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/share/web/static/css/app.css (original)
+++ Pushmi/trunk/Pushmi-Admin/share/web/static/css/app.css Fri Aug 8 19:00:48 2008
@@ -82,6 +82,13 @@
font-weight: normal;
}
+input.button {
+ border: 1px solid #334;
+ background: #223;
+ color: #ddd;
+ -moz-border-radius: 5px; -webkit-border-radius: 5px;
+ padding: 0.5em;
+}
/* Rounded boxes and titles */
@@ -139,6 +146,7 @@
.status-light.behind { background-image: url(/static/images/status/orange.png); }
.status-light.offline { background-image: url(/static/images/status/red.png); }
.status-light.failed { background-image: url(/static/images/status/red.png); }
+.status-light.locked { background-image: url(/static/images/status/red.png); }
/* Progressbar */
@@ -159,37 +167,33 @@
-moz-border-radius: 5px; -webkit-border-radius: 5px;
}
-.delete_replica, .remirror_replica, .backup_replica {
+.advanced_options .option {
padding: 1em;
}
-input.button {
- border: 1px solid #334;
- background: #223;
- color: #ddd;
- -moz-border-radius: 5px; -webkit-border-radius: 5px;
- padding: 0.5em;
-}
-
-.delete_replica input, .remirror_replica input, .backup_replica input {
+input.replica {
padding-left: 2.5em;
background-repeat: no-repeat;
background-position: 10px 7px;
}
-.delete_replica input { background-image: url(/static/images/silk/database_delete.png); }
-.remirror_replica input { background-image: url(/static/images/silk/database_refresh.png); }
-.backup_replica input { background-image: url(/static/images/silk/database_save.png); }
+input.replica.create { background-image: url(/static/images/silk/database_add.png); }
+input.replica.unlock { background-image: url(/static/images/silk/database_lightning.png); }
+input.replica.delete { background-image: url(/static/images/silk/database_delete.png); }
+input.replica.remirror { background-image: url(/static/images/silk/database_refresh.png); }
+input.replica.backup { background-image: url(/static/images/silk/database_save.png); }
-.delete_replica p, .remirror_replica p, .backup_replica p {
+.advanced_options .option p {
margin: 0;
padding-left: 1em;
padding-top: 1em;
}
-.delete_replica, .remirror_replica {
+.advanced_options .option {
border-bottom: 1px solid #334;
}
-
+.advanced_options .option.last {
+ border-bottom: none;
+}
/* */
\ No newline at end of file
Added: Pushmi/trunk/Pushmi-Admin/share/web/static/images/silk/database_add.png
==============================================================================
Binary file. No diff available.
Added: Pushmi/trunk/Pushmi-Admin/share/web/static/images/silk/database_lightning.png
==============================================================================
Binary file. No diff available.
More information about the Bps-public-commit
mailing list