[Bps-public-commit] r15559 - in Pushmi/trunk: Pushmi-Admin Pushmi-Admin/etc Pushmi-Admin/lib/Pushmi Pushmi-Admin/lib/Pushmi/Admin Pushmi-Admin/lib/Pushmi/Admin/Action Pushmi-Admin/lib/Pushmi/Admin/Model Pushmi-Admin/share/web/static/css
alexmv at bestpractical.com
alexmv at bestpractical.com
Wed Aug 27 14:35:05 EDT 2008
Author: alexmv
Date: Wed Aug 27 14:35:04 2008
New Revision: 15559
Modified:
Pushmi/trunk/ (props changed)
Pushmi/trunk/Pushmi-Admin/Makefile.PL
Pushmi/trunk/Pushmi-Admin/etc/config.yml
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin.pm
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/CreateReplica.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:
r36630 at kohr-ah: chmrr | 2008-08-27 14:34:44 -0400
* Username and password for read auth
* Make sure to clean out apache after deleting a replica
Modified: Pushmi/trunk/Pushmi-Admin/Makefile.PL
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/Makefile.PL (original)
+++ Pushmi/trunk/Pushmi-Admin/Makefile.PL Wed Aug 27 14:35:04 2008
@@ -3,5 +3,6 @@
name 'Pushmi-Admin';
version '0.01';
requires 'Jifty' => '0.80408';
+requires 'Pushmi';
WriteAll;
Modified: Pushmi/trunk/Pushmi-Admin/etc/config.yml
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/etc/config.yml (original)
+++ Pushmi/trunk/Pushmi-Admin/etc/config.yml Wed Aug 27 14:35:04 2008
@@ -14,7 +14,7 @@
Password: ''
RecordBaseClass: Jifty::DBI::Record::Memcached
User: ''
- Version: 0.0.1
+ Version: 0.0.2
DevelMode: 1
L10N:
PoDir: share/po
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin.pm Wed Aug 27 14:35:04 2008
@@ -13,9 +13,33 @@
));
}
+sub svn_auth_open {
+ my $class = shift;
+ my ($url, $user, $password) = @_;
+ my $auth = sub {
+ my ($cred) = @_;
+ warn "Doing >$user< >$password< $url auth\n";
+ $cred->username($user);
+ $cred->password($password);
+ $cred->may_save(0);
+ return $SVN::_Core::SVN_NO_ERROR;
+ };
+ my ($baton, $ref) = SVN::Core::auth_open_helper([ SVN::Client::get_simple_prompt_provider( $auth, 0 ) ]);
+ my $ra;
+ local $SIG{ALRM} = sub { die "Timeout!" };
+ alarm 10;
+ eval {
+ $ra = SVN::Ra->new( url => $url, config => undef, auth => $baton);
+ $ra->get_repos_root;
+ };
+ alarm 0;
+ warn "$@" if $@;
+ return ($baton, $ref, $ra);
+}
+
sub svn_info_for {
my $class = shift;
- my ($url) = @_;
+ my ($url, $user, $password) = @_;
$url =~ s{/+$}{};
my $memcached = $Jifty::DBI::Record::Memcached::MEMCACHED;
@@ -23,29 +47,30 @@
return $props if defined $props;
my $start = Time::HiRes::time;
- local $SIG{ALRM} = sub { die "Timeout!" };
- alarm 10;
- eval {
- my ($baton, $ref) = SVN::Core::auth_open_helper(undef);
- my $ra = SVN::Ra->new( url => $url, config => undef, auth => $baton);
+ my ($baton, $ref, $ra) = $class->svn_auth_open($url, $user, $password);
+ my $error = "$@";
+ if ($ra and not $error) {
$props->{root} = $ra->get_repos_root; $props->{root} =~ s{/+$}{};
$props->{rev} = $ra->get_latest_revnum;
$props->{date} = str2time($ra->rev_prop($props->{rev}, 'svn:date'));
- };
- warn "$@" if $@;
- alarm 0;
+ }
my $for;
if ($props) {
$props->{latency} = Time::HiRes::time - $start;
$for = $props->{latency} * 5;
$for = 2 if $for < 2;
+ } elsif ($error =~ /authorization failed/) {
+ $props = { failure => "authorization failed", error => $error };
+ $for = 0; # Don't cache auth failures
+ warn "Not caching auth failure";
} else {
+ warn "Caching connection failure";
$props = '';
$for = 3;
}
$for *= ($url =~ /^file:/) ? 5 : 60;
- $memcached->set( $url => $props, $for );
+ $memcached->set( $url => $props, $for ) if $for > 0;
return $props;
}
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/CreateReplica.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/CreateReplica.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/CreateReplica.pm Wed Aug 27 14:35:04 2008
@@ -17,9 +17,11 @@
$url =~ s{/+$}{};
- my $props = Pushmi::Admin->svn_info_for($url);
-
+ my $username = $self->argument_value("username");
+ my $password = $self->argument_value("password");
+ my $props = Pushmi::Admin->svn_info_for($url, $username, $password);
return $self->validation_error( url => "Read of $url failed" ) unless $props;
+ return $self->validation_error( url => ucfirst($props->{failure})) if $props->{failure};
$self->argument_value( url => $props->{root} );
return $self->validation_ok("url");
}
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 Wed Aug 27 14:35:04 2008
@@ -34,6 +34,14 @@
type is 'text',
is protected, valid_values are [qw/loading locked ok behind offline failed/];
+ column username =>
+ type is 'text',
+ since '0.0.2';
+
+ column password =>
+ type is 'text',
+ since '0.0.2';
+
column dav_root =>
type is 'text',
is unique, ajax validates;
@@ -90,7 +98,7 @@
my $err = $@;
warn $err if $err;
- YAML::DumpFile( $self->config_file, { username => undef, password => undef, authproxy_port => 11211 });
+ YAML::DumpFile( $self->config_file, { username => $self->username, password => $self->password, authproxy_port => 11211 });
open(LOG, ">", $self->log_config_file ) or die "Can't write log config file @{[$self->log_config_file]}: $!";
print LOG <<EOT;
log4perl.rootLogger=DEBUG, Logfile, Event
@@ -125,6 +133,7 @@
$self->stop_watcher;
$self->clear_cache;
rmtree( $self->file_root );
+ Pushmi::Admin->update_apache;
return $self->SUPER::delete;
}
@@ -201,8 +210,8 @@
sub remote_bootstrap {
my $self = shift;
- my ($baton, $ref) = SVN::Core::auth_open_helper(undef); # XXX Auth
- my $ra = SVN::Ra->new( url => $self->url, config => undef, auth => $baton);
+ my ($baton, $ref, $ra) = Pushmi::Admin->svn_auth_open($self->url, $self->username, $self->password);
+ return unless $ra;
my $data = [$ra->get_file('', $ra->get_latest_revnum, undef)];
return $data->[1]{'svk:dump-url'} || '';
}
@@ -214,12 +223,13 @@
my $c = {};
my $local = Pushmi::Admin->svn_info_for( "file://" . $self->svn_root );
- my $remote = Pushmi::Admin->svn_info_for( $self->url );
+ my $remote = Pushmi::Admin->svn_info_for( $self->url, $self->username, $self->password );
if ( not $local or not $self->pushmi or not $self->pushmi->master ) {
$self->set_status("failed");
- } elsif ( not $remote ) {
+ } elsif ( not $remote or $remote->{failure} ) {
$c->{local_revision} = $local->{rev};
$c->{local_date} = $local->{date};
+ $c->{failure} = $remote->{failure} if $remote;
$self->set_status("offline");
} else {
$c->{remote_revision} = $remote->{rev};
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 Wed Aug 27 14:35:04 2008
@@ -64,6 +64,8 @@
);
render_param( $check => "name" );
render_param( $check => "url" );
+ render_param( $check => "username" );
+ render_param( $check => "password", render_as => 'password' );
div {
{class is "submit_button"};
outs_raw(
@@ -123,7 +125,7 @@
);
my $url = $new->argument_value('url'); $url =~ s{/+$}{};
- my $data = Pushmi::Admin->svn_info_for( $url );
+ my $data = Pushmi::Admin->svn_info_for( $url, $new->argument_value("user"), $new->argument_value("password") );
navigation("home");
div {
{ class is 'roundbox' };
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 Wed Aug 27 14:35:04 2008
@@ -182,7 +182,7 @@
.status-light {
background-repeat: no-repeat;
- background-position: 0 20px;
+ background-position: 0 10px;
width: 50px;
height: 70px;
position: absolute;
More information about the Bps-public-commit
mailing list