Index: trunk/Nebulous-Server/lib/Nebulous/Server/Config.pm
===================================================================
--- trunk/Nebulous-Server/lib/Nebulous/Server/Config.pm	(revision 20972)
+++ trunk/Nebulous-Server/lib/Nebulous/Server/Config.pm	(revision 20990)
@@ -1,5 +1,5 @@
 # Copyright (C) 2005  Joshua Hoblitt
 #
-# $Id: Config.pm,v 1.4 2008-12-12 21:13:41 jhoblitt Exp $
+# $Id: Config.pm,v 1.5 2008-12-14 22:54:25 eugene Exp $
 
 package Nebulous::Server::Config;
@@ -8,10 +8,10 @@
 use warnings FATAL => qw( all );
 
-our $VERSION = 0.03;
+our $VERSION = 0.02;
 
 use base qw( Class::Accessor::Fast );
 
 use Log::Log4perl qw( :levels );
-use Params::Validate qw( validate validate_pos SCALAR );
+use Params::Validate qw( validate SCALAR );
 
 our %LEVELS = (
@@ -25,15 +25,8 @@
 );
 
-my $db_validate = {
-    dbindex       => {
-        type => SCALAR,
-        regex => qr/^\d+$/,
-    },
+my $new_validate = {
     dsn         => { type => SCALAR },
     dbuser      => { type => SCALAR },
     dbpasswd    => { type => SCALAR },
-};
-
-my $new_validate = {
     log_level   => {
         type        => SCALAR,
@@ -46,14 +39,9 @@
         },
     },
-    dsn         => { type => SCALAR, optional => 1 },
-    dbuser      => { type => SCALAR, optional => 1 },
-    dbpasswd    => { type => SCALAR, optional => 1 },
 };
 
 __PACKAGE__->mk_ro_accessors( keys %$new_validate );
 
-
-sub new
-{
+sub init {
     my $class = shift;
 
@@ -61,74 +49,13 @@
 
     # normalize log levels to lower-case
-    my $self ={ log_level => lc $p{ log_level } };
+    $p{ log_level } = lc $p{ log_level };
+
+    my $self = \%p;
 
     bless $self, $class || ref $class;
-
-    my @dbs;
-    $self->{dbs} = \@dbs;
-
-    if (defined $p{dsn} or defined $p{dbuser} or defined $p{dbpasswd}) {
-        $self->add_db(
-            dbindex     => 0,
-            dsn         => $p{dsn},
-            dbuser      => $p{dbuser},
-            dbpasswd    => $p{dbpasswd},
-        );
-    }
 
     return $self;
 }
 
-
-sub add_db
-{
-    my $self = shift;
-    
-    my %p = validate( @_, $db_validate );
-
-    my $config_db = Nebulous::Server::Config::DB->new({
-        dsn         => $p{dsn},
-        dbuser      => $p{dbuser},
-        dbpasswd    => $p{dbpasswd},
-    });
-
-    $self->{dbs}->[$p{dbindex}] = $config_db;
-
-    return $self;
-}
-
-
-sub db 
-{
-    my $self = shift;
-
-    my ($db_index) = validate_pos( @_, { type => SCALAR, optional => 1, });
-
-    # default to 0
-    $db_index ||= 0;
-
-    return $self->{dbs}->[$db_index];
-}
-
-
-sub n_db 
-{
-    my $self = shift;
-
-    return scalar @{ $self->{dbs} };
-}
-
-
-package Nebulous::Server::Config::DB;
-
-use strict;
-use warnings FATAL => qw( all );
-
-our $VERSION = 0.01;
-
-use base qw( Class::Accessor::Fast );
-
-__PACKAGE__->mk_ro_accessors(qw( dsn dbuser dbpasswd )); 
-
 1;
 
Index: trunk/Nebulous-Server/lib/Nebulous/Server/Log.pm
===================================================================
--- trunk/Nebulous-Server/lib/Nebulous/Server/Log.pm	(revision 20972)
+++ trunk/Nebulous-Server/lib/Nebulous/Server/Log.pm	(revision 20990)
@@ -1,5 +1,5 @@
 # Copyright (c) 2004  Joshua Hoblitt
 #
-# $Id: Log.pm,v 1.8 2008-12-12 21:13:41 jhoblitt Exp $
+# $Id: Log.pm,v 1.9 2008-12-14 22:54:25 eugene Exp $
 
 package Nebulous::Server::Log;
@@ -16,7 +16,7 @@
     my ($self, $config) = @_;
 
-#    my $dsn         = $config->db->dsn;
-#    my $dbuser      = $config->db->dbuser;
-#    my $dbpasswd    = $config->db->dbpasswd;
+    my $dsn         = $config->dsn;
+    my $dbuser      = $config->dbuser;
+    my $dbpasswd    = $config->dbpasswd;
 
     my $conf = <<END;
@@ -30,9 +30,9 @@
 #   date | hostname | priority | method/sub - message\n
 
-#    log4perl.appender.SQLLOG            = Log::Log4perl::Appender::DBI
-#    log4perl.appender.SQLLOG.sql        = \
-#    log4perl.appender.SQLLOG.datasource = 
-#    log4perl.appender.SQLLOG.username   = 
-#    log4perl.appender.SQLLOG.password   = 
+    log4perl.appender.SQLLOG            = Log::Log4perl::Appender::DBI
+    log4perl.appender.SQLLOG.datasource = $dsn
+    log4perl.appender.SQLLOG.username   = $dbuser
+    log4perl.appender.SQLLOG.password   = $dbpasswd
+    log4perl.appender.SQLLOG.sql        = \
     INSERT INTO log (timestamp, hostname, level, sub, message) \
     VALUES          (%d,        %H,       %p,    %M,  %m)
Index: trunk/Nebulous-Server/lib/Nebulous/Server/SOAP.pm
===================================================================
--- trunk/Nebulous-Server/lib/Nebulous/Server/SOAP.pm	(revision 20972)
+++ trunk/Nebulous-Server/lib/Nebulous/Server/SOAP.pm	(revision 20990)
@@ -1,5 +1,5 @@
 # Copyright (c) 2004  Joshua Hoblitt
 #
-# $Id: SOAP.pm,v 1.5 2008-12-13 00:41:15 jhoblitt Exp $
+# $Id: SOAP.pm,v 1.6 2008-12-14 22:54:25 eugene Exp $
 
 package Nebulous::Server::SOAP;
@@ -17,10 +17,8 @@
 our $AUTOLOAD;
 
-our $config;
+our @args;
 our $neb;
 
-
-sub new_on_init
-{
+sub new_on_init {
     my $self = shift;
 
@@ -29,5 +27,5 @@
     require Apache2::ServerUtil;
 
-    $config = shift;
+    @args = @_;
 
     my $s = Apache2::ServerUtil->server;
@@ -37,17 +35,13 @@
 }
 
-
-sub init
-{
+sub init {
     my $self = shift;
 
-    $neb = Nebulous::Server->new_from_config($config);        
+    $neb = Nebulous::Server->new(@args);        
 
     return Apache2::Const::OK;
 }
 
-
-sub AUTOLOAD
-{
+sub AUTOLOAD {
     my $self = shift;
 
@@ -82,4 +76,3 @@
 }
 
-
 1;
Index: trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm
===================================================================
--- trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm	(revision 20972)
+++ trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm	(revision 20990)
@@ -1,5 +1,5 @@
 # Copyright (c) 2004  Joshua Hoblitt
 #
-# $Id: SQL.pm,v 1.77 2008-12-12 21:41:07 jhoblitt Exp $
+# $Id: SQL.pm,v 1.78 2008-12-14 22:54:25 eugene Exp $
 
 package Nebulous::Server::SQL;
@@ -8,5 +8,5 @@
 use warnings FATAL => qw( all );
 
-our $VERSION = '0.03';
+our $VERSION = '0.02';
 
 use base qw( Class::Accessor::Fast );
@@ -47,8 +47,4 @@
         (so_id, vol_id, uri)
         VALUES (?, ?, 'error')
-    },
-    get_all_instances   => qq{
-        SELECT * FROM INSTANCE
-        WHERE so_id = ?
     },
     get_object          => qq{
@@ -328,26 +324,28 @@
         HAVING available_instances < instances OR instances < copies
     },
-    find_objects_with_extra_instances_by_xattr => qq{
-        SELECT
-            so.so_id,
-            so.ext_id,
+    find_objects_with_extra_instances => qq{
+        SELECT
+            storage_object.so_id,
+            ext_id,
             count(ins_id) as instances,
-            mv.name as volume_name,
-            mv.host as volume_host,
-            count(mv.vol_id) as available_instances,
-            xattr.value as copies
-        FROM storage_object AS so
-        JOIN storage_object_xattr as xattr
-            ON so.so_id = xattr.so_id
-            AND xattr.name = 'user.copies'
-        JOIN instance AS i
-            ON so.so_id = i.so_id
-        JOIN mountedvol AS mv
+            volume.name as volume_name,
+            volume.host as volume_host,
+            count(mymountedvol.vol_id) as available_instances,
+            count(mymountedvol.vol_id) > 0 as recoverable,
+            storage_object_xattr.value as copies
+        FROM storage_object
+        JOIN instance
+            USING(so_id)
+        JOIN volume
+            USING(vol_id)
+        LEFT JOIN storage_object_xattr
+            ON storage_object.so_id = storage_object_xattr.so_id
+        JOIN mymountedvol
             USING(vol_id)
         WHERE
-            mv.available = 1
+            mymountedvol.available = 1
+            AND storage_object_xattr.name = 'user.copies'
         GROUP BY so_id
         HAVING available_instances > copies
-        limit 5;
     },
     get_mounted_volumes => qq{
