Index: /trunk/Nebulous-Server/Changes
===================================================================
--- /trunk/Nebulous-Server/Changes	(revision 10545)
+++ /trunk/Nebulous-Server/Changes	(revision 10546)
@@ -1,3 +1,9 @@
 Revision history for Perl module Poi::PixelData
+
+0.03
+    - change Nebulous::Server instantiate objects (init -> new) instead of
+      working with class data
+    - add a DESTROY method to Nebulous::Server to tear down the database
+      connection
 
 0.02 Fri Dec  2 17:36:59 HST 2005
Index: /trunk/Nebulous-Server/lib/Nebulous/Server.pm
===================================================================
--- /trunk/Nebulous-Server/lib/Nebulous/Server.pm	(revision 10545)
+++ /trunk/Nebulous-Server/lib/Nebulous/Server.pm	(revision 10546)
@@ -1,5 +1,5 @@
 # Copyright (c) 2004  Joshua Hoblitt
 #
-# $Id: Server.pm,v 1.19 2005-12-03 02:32:56 jhoblitt Exp $
+# $Id: Server.pm,v 1.20 2006-12-08 03:29:19 jhoblitt Exp $
 
 package Nebulous::Server;
@@ -8,5 +8,7 @@
 use warnings FATAL => qw( all );
 
-our $VERSION = '0.02';
+our $VERSION = '0.03';
+
+use base qw( Class::Accessor::Fast );
 
 use DBI;
@@ -18,10 +20,8 @@
 use Params::Validate qw( validate_pos SCALAR );
 
-my $log;
-my $sql;
-my $db;
-
-sub init {
-    my $self = shift;
+__PACKAGE__->mk_accessors(qw( log sql db ));
+
+sub new {
+    my $class = shift;
 
     # let Nebulous::Server::Config validate our params
@@ -31,9 +31,10 @@
     Nebulous::Server::Log->init;
 
-    $log = Log::Log4perl::get_logger( "Nebulous::Server" );
-    $sql = Nebulous::Server::SQL->new;
-
-    $log->debug( "entered - @_" );
-
+    my $log = Log::Log4perl::get_logger( "Nebulous::Server" );
+    my $sql = Nebulous::Server::SQL->new;
+
+    $log->debug( "entered - @_" );
+
+    my $db;
     eval {
         $db = DBI->connect(
@@ -61,5 +62,10 @@
     $log->debug( "leaving" );
 
-    return 1;
+    my $self = bless {}, ref $class || $class;
+    $self->log($log);
+    $self->sql($sql);
+    $self->db($db);
+
+    return $self;
 }
 
@@ -76,5 +82,5 @@
                 'is + integer' => sub { $_[0] =~ /^\d+$/ },
                 # check that the class requested is valid
-                'is valid class id' => sub { _is_valid_class_id( $_[0] ) },
+                'is valid class id' => sub { $self->_is_valid_class_id( $_[0] ) },
             },
             default     => 0,
@@ -84,5 +90,5 @@
             callbacks   => {
                 # check that the volume requested is valid
-                'is valid volume name' => sub { _is_valid_volume_name($_[0]) },
+                'is valid volume name' => sub { $self->_is_valid_volume_name($_[0]) },
             },
             optional    => 1,
@@ -98,9 +104,13 @@
     );
 
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
+
     $log->debug( "entered - @_" );
 
     # TODO do some intelligent volume allocated 
     # add hooks to make this decision based on avaiable space
-    $volume = _get_storage_volume( $volume );
+    $volume = $self->_get_storage_volume( $volume );
 
     my $uri;
@@ -194,8 +204,12 @@
     );
 
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
+
     $log->debug( "entered - @_" );
 
     # TODO
-    $volume = _get_storage_volume();
+    $volume = $self->_get_storage_volume();
 
     my $path;
@@ -277,4 +291,8 @@
         },
     );
+
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
 
     $log->debug( "entered - @_" );
@@ -393,4 +411,8 @@
     );
 
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
+
     $log->debug( "entered - @_" );
 
@@ -514,4 +536,8 @@
     );
 
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
+
     $log->debug( "entered - @_" );
 
@@ -548,4 +574,8 @@
         },
     );
+
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
 
     $log->debug( "entered - @_" );
@@ -622,4 +652,8 @@
     );
 
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
+
     $log->debug( "entered - @_" );
 
@@ -649,4 +683,10 @@
 
 sub _get_storage_volume {
+    my $self = shift;
+
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
+
     no warnings qw( uninitialized );
     $log->debug( "entered - @_" );
@@ -690,5 +730,9 @@
 
 sub _is_valid_class_id {
-    my $class_id = shift;
+    my ($self, $class_id) = @_;
+
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  = $self->db;
 
     my $class;
@@ -709,9 +753,13 @@
 
 sub _is_valid_volume_name  {
-    my $vol_name = shift;
+    my ($self, $vol_name) = @_;
+
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
 
     my $volume;
     eval {
-        my $query = $db->prepare_cached( $sql->get_volume_by_name  ); 
+        my $query = $db->prepare_cached( $sql->get_volume_by_name ); 
         $query->execute( $vol_name );
         ( $volume ) = $query->fetchrow_array;
@@ -727,4 +775,20 @@
 }
 
+sub DESTROY {
+    my $self = shift;
+
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
+
+    $log->debug( "entered" );
+
+    $self->db->disconnect;        
+
+    $log->debug( "disconnected from database: ", sub { $db->data_sources; } );
+
+    $log->debug( "leaving" );
+}
+
 1;
 
Index: /trunk/Nebulous-Server/t/02_server_setup.t
===================================================================
--- /trunk/Nebulous-Server/t/02_server_setup.t	(revision 10545)
+++ /trunk/Nebulous-Server/t/02_server_setup.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 02_server_setup.t,v 1.4 2005-08-25 01:40:04 jhoblitt Exp $
+# $Id: 02_server_setup.t,v 1.5 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -17,11 +17,11 @@
 Test::Nebulous->setup;
 
-ok(
-    Nebulous::Server->init(
+isa_ok(
+    Nebulous::Server->new(
         dsn         => "DBI:mysql:database=test:host=localhost",
         dbuser      => "test",
         dbpasswd    => "",
     ),
-    "connect",
+    "Nebulous::Server"
 );
 
@@ -29,5 +29,5 @@
 
 eval {
-    Nebulous::Server->init(
+    Nebulous::Server->new(
         dsn         => "DBI:mysql:database=foobar:host=localhost",
         dbuser      => "baz",
Index: /trunk/Nebulous-Server/t/03_server_create_object.t
===================================================================
--- /trunk/Nebulous-Server/t/03_server_create_object.t	(revision 10545)
+++ /trunk/Nebulous-Server/t/03_server_create_object.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 03_server_create_object.t,v 1.10 2005-11-10 22:07:53 jhoblitt Exp $
+# $Id: 03_server_create_object.t,v 1.11 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
Index: /trunk/Nebulous-Server/t/04_server_replicate_object.t
===================================================================
--- /trunk/Nebulous-Server/t/04_server_replicate_object.t	(revision 10545)
+++ /trunk/Nebulous-Server/t/04_server_replicate_object.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 04_server_replicate_object.t,v 1.5 2005-08-25 01:40:04 jhoblitt Exp $
+# $Id: 04_server_replicate_object.t,v 1.6 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
Index: /trunk/Nebulous-Server/t/05_server_lock_object.t
===================================================================
--- /trunk/Nebulous-Server/t/05_server_lock_object.t	(revision 10545)
+++ /trunk/Nebulous-Server/t/05_server_lock_object.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 05_server_lock_object.t,v 1.5 2005-08-25 01:40:04 jhoblitt Exp $
+# $Id: 05_server_lock_object.t,v 1.6 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
Index: /trunk/Nebulous-Server/t/06_server_unlock_object.t
===================================================================
--- /trunk/Nebulous-Server/t/06_server_unlock_object.t	(revision 10545)
+++ /trunk/Nebulous-Server/t/06_server_unlock_object.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 06_server_unlock_object.t,v 1.5 2005-08-25 01:40:04 jhoblitt Exp $
+# $Id: 06_server_unlock_object.t,v 1.6 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
Index: /trunk/Nebulous-Server/t/07_server_find_instances.t
===================================================================
--- /trunk/Nebulous-Server/t/07_server_find_instances.t	(revision 10545)
+++ /trunk/Nebulous-Server/t/07_server_find_instances.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 07_server_find_instances.t,v 1.5 2005-08-25 01:40:04 jhoblitt Exp $
+# $Id: 07_server_find_instances.t,v 1.6 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
Index: /trunk/Nebulous-Server/t/08_server_delete_instance.t
===================================================================
--- /trunk/Nebulous-Server/t/08_server_delete_instance.t	(revision 10545)
+++ /trunk/Nebulous-Server/t/08_server_delete_instance.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 08_server_delete_instance.t,v 1.5 2005-08-25 01:40:04 jhoblitt Exp $
+# $Id: 08_server_delete_instance.t,v 1.6 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
Index: /trunk/Nebulous-Server/t/09_server_is_valid_class_id.t
===================================================================
--- /trunk/Nebulous-Server/t/09_server_is_valid_class_id.t	(revision 10545)
+++ /trunk/Nebulous-Server/t/09_server_is_valid_class_id.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 09_server_is_valid_class_id.t,v 1.1 2005-11-10 21:31:26 jhoblitt Exp $
+# $Id: 09_server_is_valid_class_id.t,v 1.2 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
@@ -24,19 +22,17 @@
 );
 
-*_is_valid_class_id = \&Nebulous::Server::_is_valid_class_id;
-
 Test::Nebulous->setup;
 
 # 0 is the default and is guarenteed to exist
-ok( _is_valid_class_id( 0 ), "default class id");
+ok( $neb->_is_valid_class_id( 0 ), "default class id");
 
 Test::Nebulous->setup;
 
 # the test setup adds class id 1
-ok( _is_valid_class_id( 1 ), "custom class id");
+ok( $neb->_is_valid_class_id( 1 ), "custom class id");
 
 Test::Nebulous->setup;
 
-is( _is_valid_class_id( 99 ), undef, "invalid class id");
+is( $neb->_is_valid_class_id( 99 ), undef, "invalid class id");
 
 Test::Nebulous->cleanup;
Index: /trunk/Nebulous-Server/t/09_server_stat_object.t
===================================================================
--- /trunk/Nebulous-Server/t/09_server_stat_object.t	(revision 10545)
+++ /trunk/Nebulous-Server/t/09_server_stat_object.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 09_server_stat_object.t,v 1.7 2005-11-09 01:35:59 jhoblitt Exp $
+# $Id: 09_server_stat_object.t,v 1.8 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
Index: /trunk/Nebulous-Server/t/10_server_is_valid_volume_name.t
===================================================================
--- /trunk/Nebulous-Server/t/10_server_is_valid_volume_name.t	(revision 10545)
+++ /trunk/Nebulous-Server/t/10_server_is_valid_volume_name.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 10_server_is_valid_volume_name.t,v 1.1 2005-12-03 02:52:31 jhoblitt Exp $
+# $Id: 10_server_is_valid_volume_name.t,v 1.2 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
@@ -24,17 +22,15 @@
 );
 
-*_is_valid_volume_name = \&Nebulous::Server::_is_valid_volume_name;
+Test::Nebulous->setup;
+
+ok( $neb->_is_valid_volume_name( 'node01' ), "valid volume name" );
 
 Test::Nebulous->setup;
 
-ok( _is_valid_volume_name( 'node01' ), "valid volume name" );
+ok( $neb->_is_valid_volume_name( 'node02' ), "valid volume name" );
 
 Test::Nebulous->setup;
 
-ok( _is_valid_volume_name( 'node02' ), "valid volume name" );
-
-Test::Nebulous->setup;
-
-is( _is_valid_volume_name( 'node99' ), undef, "invalid volume name" );
+is( $neb->_is_valid_volume_name( 'node99' ), undef, "invalid volume name" );
 
 Test::Nebulous->cleanup;
Index: /trunk/Nebulous-Server/t/11_server_is_valid_class_id.t
===================================================================
--- /trunk/Nebulous-Server/t/11_server_is_valid_class_id.t	(revision 10545)
+++ /trunk/Nebulous-Server/t/11_server_is_valid_class_id.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 11_server_is_valid_class_id.t,v 1.1 2005-12-03 02:52:31 jhoblitt Exp $
+# $Id: 11_server_is_valid_class_id.t,v 1.2 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
@@ -24,19 +22,17 @@
 );
 
-*_is_valid_class_id = \&Nebulous::Server::_is_valid_class_id;
-
 Test::Nebulous->setup;
 
 # 0 is the default and is guarenteed to exist
-ok( _is_valid_class_id( 0 ), "default class id");
+ok( $neb->_is_valid_class_id( 0 ), "default class id");
 
 Test::Nebulous->setup;
 
 # the test setup adds class id 1
-ok( _is_valid_class_id( 1 ), "custom class id");
+ok( $neb->_is_valid_class_id( 1 ), "custom class id");
 
 Test::Nebulous->setup;
 
-is( _is_valid_class_id( 99 ), undef, "invalid class id");
+is( $neb->_is_valid_class_id( 99 ), undef, "invalid class id");
 
 Test::Nebulous->cleanup;
Index: /trunk/Nebulous/Changes
===================================================================
--- /trunk/Nebulous/Changes	(revision 10545)
+++ /trunk/Nebulous/Changes	(revision 10546)
@@ -1,3 +1,9 @@
 Revision history for Perl module Poi::PixelData
+
+0.03
+    - change Nebulous::Server instantiate objects (init -> new) instead of
+      working with class data
+    - add a DESTROY method to Nebulous::Server to tear down the database
+      connection
 
 0.02 Fri Dec  2 17:36:59 HST 2005
Index: /trunk/Nebulous/lib/Nebulous/Server.pm
===================================================================
--- /trunk/Nebulous/lib/Nebulous/Server.pm	(revision 10545)
+++ /trunk/Nebulous/lib/Nebulous/Server.pm	(revision 10546)
@@ -1,5 +1,5 @@
 # Copyright (c) 2004  Joshua Hoblitt
 #
-# $Id: Server.pm,v 1.19 2005-12-03 02:32:56 jhoblitt Exp $
+# $Id: Server.pm,v 1.20 2006-12-08 03:29:19 jhoblitt Exp $
 
 package Nebulous::Server;
@@ -8,5 +8,7 @@
 use warnings FATAL => qw( all );
 
-our $VERSION = '0.02';
+our $VERSION = '0.03';
+
+use base qw( Class::Accessor::Fast );
 
 use DBI;
@@ -18,10 +20,8 @@
 use Params::Validate qw( validate_pos SCALAR );
 
-my $log;
-my $sql;
-my $db;
-
-sub init {
-    my $self = shift;
+__PACKAGE__->mk_accessors(qw( log sql db ));
+
+sub new {
+    my $class = shift;
 
     # let Nebulous::Server::Config validate our params
@@ -31,9 +31,10 @@
     Nebulous::Server::Log->init;
 
-    $log = Log::Log4perl::get_logger( "Nebulous::Server" );
-    $sql = Nebulous::Server::SQL->new;
-
-    $log->debug( "entered - @_" );
-
+    my $log = Log::Log4perl::get_logger( "Nebulous::Server" );
+    my $sql = Nebulous::Server::SQL->new;
+
+    $log->debug( "entered - @_" );
+
+    my $db;
     eval {
         $db = DBI->connect(
@@ -61,5 +62,10 @@
     $log->debug( "leaving" );
 
-    return 1;
+    my $self = bless {}, ref $class || $class;
+    $self->log($log);
+    $self->sql($sql);
+    $self->db($db);
+
+    return $self;
 }
 
@@ -76,5 +82,5 @@
                 'is + integer' => sub { $_[0] =~ /^\d+$/ },
                 # check that the class requested is valid
-                'is valid class id' => sub { _is_valid_class_id( $_[0] ) },
+                'is valid class id' => sub { $self->_is_valid_class_id( $_[0] ) },
             },
             default     => 0,
@@ -84,5 +90,5 @@
             callbacks   => {
                 # check that the volume requested is valid
-                'is valid volume name' => sub { _is_valid_volume_name($_[0]) },
+                'is valid volume name' => sub { $self->_is_valid_volume_name($_[0]) },
             },
             optional    => 1,
@@ -98,9 +104,13 @@
     );
 
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
+
     $log->debug( "entered - @_" );
 
     # TODO do some intelligent volume allocated 
     # add hooks to make this decision based on avaiable space
-    $volume = _get_storage_volume( $volume );
+    $volume = $self->_get_storage_volume( $volume );
 
     my $uri;
@@ -194,8 +204,12 @@
     );
 
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
+
     $log->debug( "entered - @_" );
 
     # TODO
-    $volume = _get_storage_volume();
+    $volume = $self->_get_storage_volume();
 
     my $path;
@@ -277,4 +291,8 @@
         },
     );
+
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
 
     $log->debug( "entered - @_" );
@@ -393,4 +411,8 @@
     );
 
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
+
     $log->debug( "entered - @_" );
 
@@ -514,4 +536,8 @@
     );
 
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
+
     $log->debug( "entered - @_" );
 
@@ -548,4 +574,8 @@
         },
     );
+
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
 
     $log->debug( "entered - @_" );
@@ -622,4 +652,8 @@
     );
 
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
+
     $log->debug( "entered - @_" );
 
@@ -649,4 +683,10 @@
 
 sub _get_storage_volume {
+    my $self = shift;
+
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
+
     no warnings qw( uninitialized );
     $log->debug( "entered - @_" );
@@ -690,5 +730,9 @@
 
 sub _is_valid_class_id {
-    my $class_id = shift;
+    my ($self, $class_id) = @_;
+
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  = $self->db;
 
     my $class;
@@ -709,9 +753,13 @@
 
 sub _is_valid_volume_name  {
-    my $vol_name = shift;
+    my ($self, $vol_name) = @_;
+
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
 
     my $volume;
     eval {
-        my $query = $db->prepare_cached( $sql->get_volume_by_name  ); 
+        my $query = $db->prepare_cached( $sql->get_volume_by_name ); 
         $query->execute( $vol_name );
         ( $volume ) = $query->fetchrow_array;
@@ -727,4 +775,20 @@
 }
 
+sub DESTROY {
+    my $self = shift;
+
+    my $log = $self->log;
+    my $sql = $self->sql;
+    my $db  =$self->db;
+
+    $log->debug( "entered" );
+
+    $self->db->disconnect;        
+
+    $log->debug( "disconnected from database: ", sub { $db->data_sources; } );
+
+    $log->debug( "leaving" );
+}
+
 1;
 
Index: /trunk/Nebulous/t/02_server_setup.t
===================================================================
--- /trunk/Nebulous/t/02_server_setup.t	(revision 10545)
+++ /trunk/Nebulous/t/02_server_setup.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 02_server_setup.t,v 1.4 2005-08-25 01:40:04 jhoblitt Exp $
+# $Id: 02_server_setup.t,v 1.5 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -17,11 +17,11 @@
 Test::Nebulous->setup;
 
-ok(
-    Nebulous::Server->init(
+isa_ok(
+    Nebulous::Server->new(
         dsn         => "DBI:mysql:database=test:host=localhost",
         dbuser      => "test",
         dbpasswd    => "",
     ),
-    "connect",
+    "Nebulous::Server"
 );
 
@@ -29,5 +29,5 @@
 
 eval {
-    Nebulous::Server->init(
+    Nebulous::Server->new(
         dsn         => "DBI:mysql:database=foobar:host=localhost",
         dbuser      => "baz",
Index: /trunk/Nebulous/t/03_server_create_object.t
===================================================================
--- /trunk/Nebulous/t/03_server_create_object.t	(revision 10545)
+++ /trunk/Nebulous/t/03_server_create_object.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 03_server_create_object.t,v 1.10 2005-11-10 22:07:53 jhoblitt Exp $
+# $Id: 03_server_create_object.t,v 1.11 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
Index: /trunk/Nebulous/t/04_server_replicate_object.t
===================================================================
--- /trunk/Nebulous/t/04_server_replicate_object.t	(revision 10545)
+++ /trunk/Nebulous/t/04_server_replicate_object.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 04_server_replicate_object.t,v 1.5 2005-08-25 01:40:04 jhoblitt Exp $
+# $Id: 04_server_replicate_object.t,v 1.6 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
Index: /trunk/Nebulous/t/05_server_lock_object.t
===================================================================
--- /trunk/Nebulous/t/05_server_lock_object.t	(revision 10545)
+++ /trunk/Nebulous/t/05_server_lock_object.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 05_server_lock_object.t,v 1.5 2005-08-25 01:40:04 jhoblitt Exp $
+# $Id: 05_server_lock_object.t,v 1.6 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
Index: /trunk/Nebulous/t/06_server_unlock_object.t
===================================================================
--- /trunk/Nebulous/t/06_server_unlock_object.t	(revision 10545)
+++ /trunk/Nebulous/t/06_server_unlock_object.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 06_server_unlock_object.t,v 1.5 2005-08-25 01:40:04 jhoblitt Exp $
+# $Id: 06_server_unlock_object.t,v 1.6 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
Index: /trunk/Nebulous/t/07_server_find_instances.t
===================================================================
--- /trunk/Nebulous/t/07_server_find_instances.t	(revision 10545)
+++ /trunk/Nebulous/t/07_server_find_instances.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 07_server_find_instances.t,v 1.5 2005-08-25 01:40:04 jhoblitt Exp $
+# $Id: 07_server_find_instances.t,v 1.6 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
Index: /trunk/Nebulous/t/08_server_delete_instance.t
===================================================================
--- /trunk/Nebulous/t/08_server_delete_instance.t	(revision 10545)
+++ /trunk/Nebulous/t/08_server_delete_instance.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 08_server_delete_instance.t,v 1.5 2005-08-25 01:40:04 jhoblitt Exp $
+# $Id: 08_server_delete_instance.t,v 1.6 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
Index: /trunk/Nebulous/t/09_server_is_valid_class_id.t
===================================================================
--- /trunk/Nebulous/t/09_server_is_valid_class_id.t	(revision 10545)
+++ /trunk/Nebulous/t/09_server_is_valid_class_id.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 09_server_is_valid_class_id.t,v 1.1 2005-11-10 21:31:26 jhoblitt Exp $
+# $Id: 09_server_is_valid_class_id.t,v 1.2 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
@@ -24,19 +22,17 @@
 );
 
-*_is_valid_class_id = \&Nebulous::Server::_is_valid_class_id;
-
 Test::Nebulous->setup;
 
 # 0 is the default and is guarenteed to exist
-ok( _is_valid_class_id( 0 ), "default class id");
+ok( $neb->_is_valid_class_id( 0 ), "default class id");
 
 Test::Nebulous->setup;
 
 # the test setup adds class id 1
-ok( _is_valid_class_id( 1 ), "custom class id");
+ok( $neb->_is_valid_class_id( 1 ), "custom class id");
 
 Test::Nebulous->setup;
 
-is( _is_valid_class_id( 99 ), undef, "invalid class id");
+is( $neb->_is_valid_class_id( 99 ), undef, "invalid class id");
 
 Test::Nebulous->cleanup;
Index: /trunk/Nebulous/t/09_server_stat_object.t
===================================================================
--- /trunk/Nebulous/t/09_server_stat_object.t	(revision 10545)
+++ /trunk/Nebulous/t/09_server_stat_object.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 09_server_stat_object.t,v 1.7 2005-11-09 01:35:59 jhoblitt Exp $
+# $Id: 09_server_stat_object.t,v 1.8 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
Index: /trunk/Nebulous/t/10_server_is_valid_volume_name.t
===================================================================
--- /trunk/Nebulous/t/10_server_is_valid_volume_name.t	(revision 10545)
+++ /trunk/Nebulous/t/10_server_is_valid_volume_name.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 10_server_is_valid_volume_name.t,v 1.1 2005-12-03 02:52:31 jhoblitt Exp $
+# $Id: 10_server_is_valid_volume_name.t,v 1.2 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
@@ -24,17 +22,15 @@
 );
 
-*_is_valid_volume_name = \&Nebulous::Server::_is_valid_volume_name;
+Test::Nebulous->setup;
+
+ok( $neb->_is_valid_volume_name( 'node01' ), "valid volume name" );
 
 Test::Nebulous->setup;
 
-ok( _is_valid_volume_name( 'node01' ), "valid volume name" );
+ok( $neb->_is_valid_volume_name( 'node02' ), "valid volume name" );
 
 Test::Nebulous->setup;
 
-ok( _is_valid_volume_name( 'node02' ), "valid volume name" );
-
-Test::Nebulous->setup;
-
-is( _is_valid_volume_name( 'node99' ), undef, "invalid volume name" );
+is( $neb->_is_valid_volume_name( 'node99' ), undef, "invalid volume name" );
 
 Test::Nebulous->cleanup;
Index: /trunk/Nebulous/t/11_server_is_valid_class_id.t
===================================================================
--- /trunk/Nebulous/t/11_server_is_valid_class_id.t	(revision 10545)
+++ /trunk/Nebulous/t/11_server_is_valid_class_id.t	(revision 10546)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 11_server_is_valid_class_id.t,v 1.1 2005-12-03 02:52:31 jhoblitt Exp $
+# $Id: 11_server_is_valid_class_id.t,v 1.2 2006-12-08 03:29:19 jhoblitt Exp $
 
 use strict;
@@ -16,7 +16,5 @@
 use Test::Nebulous;
 
-my $neb = "Nebulous::Server";
-
-$neb->init(
+my $neb = Nebulous::Server->new(
     dsn         => "DBI:mysql:database=test:host=localhost",
     dbuser      => "test",
@@ -24,19 +22,17 @@
 );
 
-*_is_valid_class_id = \&Nebulous::Server::_is_valid_class_id;
-
 Test::Nebulous->setup;
 
 # 0 is the default and is guarenteed to exist
-ok( _is_valid_class_id( 0 ), "default class id");
+ok( $neb->_is_valid_class_id( 0 ), "default class id");
 
 Test::Nebulous->setup;
 
 # the test setup adds class id 1
-ok( _is_valid_class_id( 1 ), "custom class id");
+ok( $neb->_is_valid_class_id( 1 ), "custom class id");
 
 Test::Nebulous->setup;
 
-is( _is_valid_class_id( 99 ), undef, "invalid class id");
+is( $neb->_is_valid_class_id( 99 ), undef, "invalid class id");
 
 Test::Nebulous->cleanup;
