Index: /trunk/Nebulous-Server/Changes
===================================================================
--- /trunk/Nebulous-Server/Changes	(revision 19492)
+++ /trunk/Nebulous-Server/Changes	(revision 19493)
@@ -1,3 +1,6 @@
 Revision history for Nebulous
+
+0.15
+    - invert soft volume semantics
 
 0.14 Wed Aug 20 16:25:43 HST 2008
Index: /trunk/Nebulous-Server/lib/Nebulous/Server.pm
===================================================================
--- /trunk/Nebulous-Server/lib/Nebulous/Server.pm	(revision 19492)
+++ /trunk/Nebulous-Server/lib/Nebulous/Server.pm	(revision 19493)
@@ -1,5 +1,5 @@
 # Copyright (c) 2004-2008  Joshua Hoblitt
 #
-# $Id: Server.pm,v 1.85 2008-09-10 23:55:54 bills Exp $
+# $Id: Server.pm,v 1.86 2008-09-11 22:35:52 jhoblitt Exp $
 
 package Nebulous::Server;
@@ -169,21 +169,20 @@
     # vol_name overrides the key implied volume
     $key = parse_neb_key($key, $vol_name);
-
-    if ($vol_name eq "99") {
-        use Data::Dumper;
-        print Dumper($key);
-    }
+    $vol_name = $key->volume;
 
     # the key's volume can't be validiated on input for this method so we have
     # to check it after parsing the key
-    if (defined $key->volume
-        and not $key->soft_volume
-        and not $self->_is_valid_volume_name($key->volume)
-    ) {
-        $log->logdie("$vol_name is not a valid volume name");
+    if (defined $vol_name
+        and not $self->_is_valid_volume_name($key->volume)) {
+        if ($key->soft_volume) {
+            $log->warn( "$vol_name is not a known volume name" );
+            $vol_name = undef;
+        } else {
+            die "$vol_name is not a valid volume name"
+        }
     }
         
     my ($vol_id, $vol_host, $vol_path, $vol_xattr)
-        = $self->_get_storage_volume($key->volume, $key->soft_volume);
+        = $self->_get_storage_volume($vol_name, $key->soft_volume);
 
     my $uri;
@@ -252,4 +251,5 @@
     };
     if ($@) {
+#        and not $key->soft_volume
         $db->rollback;
         $log->debug("rollback");
@@ -358,14 +358,16 @@
     $log->debug("entered - @_");
 
+    # vol_name overrides the key implied volume
     $key = parse_neb_key($key, $vol_name);
-    # vol_name overrides the key implied volume
     $vol_name = $key->volume;
 
-    if (defined $key->soft_volume) {
-        $vol_name = undef;
-    }
-
-    if (defined $vol_name and !$self->_is_valid_volume_name($vol_name)) {
-        die "$vol_name is not a valid volume name"
+    if (defined $vol_name
+        and not $self->_is_valid_volume_name($key->volume)) {
+        if ($key->soft_volume) {
+            $log->warn( "$vol_name is not a known volume name" );
+            $vol_name = undef;
+        } else {
+            die "$vol_name is not a valid volume name"
+        }
     }
         
@@ -430,4 +432,9 @@
     if ($@) {
         $db->rollback;
+        # handle soft volumes
+        if (defined $vol_name and defined $key->soft_volume) {
+            $log->debug("retrying with 'any' volume");
+            return $self->replicate_object($key->path, 'any');
+        }
         $log->debug("rollback");
         $log->logdie("error: $@");
@@ -928,11 +935,11 @@
         {
             type        => SCALAR|UNDEF,
-            callbacks   => {
-                # check that the volume name requested is valid
-                'is valid volume name' => sub {
-                    return 1 if not defined $_[0];
-                    $self->_is_valid_volume_name($_[0])
-                },
-            },
+#            callbacks   => {
+#                # check that the volume name requested is valid
+#                'is valid volume name' => sub {
+#                    return 1 if not defined $_[0];
+#                    $self->_is_valid_volume_name($_[0])
+#                },
+#            },
             optional    => 1,
         },
@@ -945,11 +952,18 @@
     $log->debug("entered - @_");
 
+    # vol_name overrides the key implied volume
     $key = parse_neb_key($key, $vol_name);
-    # vol_name overrides the key implied volume
     $vol_name = $key->volume;
 
-    # handle soft volumes
-    if (defined $key->soft_volume) {
-        $vol_name = undef;
+    # the key's volume can't be validiated on input for this method so we have
+    # to check it after parsing the key
+    if (defined $vol_name
+        and not $self->_is_valid_volume_name($key->volume)) {
+        if ($key->soft_volume) {
+            $log->warn( "$vol_name is not a known volume name" );
+            $vol_name = undef;
+        } else {
+            die "$vol_name is not a valid volume name"
+        }
     }
 
@@ -980,5 +994,13 @@
         }
     };
-    $log->logdie("database error: $@") if $@;
+    if ($@) {
+        $db->rollback;
+        # handle soft volumes
+        if (defined $vol_name and defined $key->soft_volume) {
+            $log->debug("retrying with 'any' volume");
+            return $self->find_instances($key->path, 'any');
+        }
+        $log->logdie("database error: $@");
+    }
 
     # XXX remove this?
@@ -1171,5 +1193,4 @@
     my ($vol_id, $vol_host, $vol_path, $xattr);
     eval {
-        # TODO cache this?
         my $query;
         my $rows;
Index: /trunk/Nebulous-Server/lib/Test/Nebulous.pm
===================================================================
--- /trunk/Nebulous-Server/lib/Test/Nebulous.pm	(revision 19492)
+++ /trunk/Nebulous-Server/lib/Test/Nebulous.pm	(revision 19493)
@@ -1,5 +1,5 @@
 # Copyright (C) 2004  Joshua Hoblitt
 #
-# $Id: Nebulous.pm,v 1.3 2008-09-11 21:18:35 bills Exp $
+# $Id: Nebulous.pm,v 1.4 2008-09-11 22:35:52 jhoblitt Exp $
 
 package Test::Nebulous;
@@ -32,4 +32,5 @@
 my $dir5 = "";
 my $dir6 = "";
+my $dir7 = "";
 
 sub setup {
@@ -45,4 +46,5 @@
     $dir5 = tempdir( CLEANUP => 0 );
     $dir6 = tempdir( CLEANUP => 0 );
+    $dir7 = tempdir( CLEANUP => 0 );
 
     foreach my $statement (@{ $sql->get_db_schema }) {
@@ -70,6 +72,10 @@
 
     # node06: allocate = TRUE, available = FALSE
-    $dbh->do(qq{ INSERT INTO volume (vol_id, name, host, path, allocate, available) VALUES (6, 'node06', 'node06', ?, TRUE, FALSE) }, undef, $dir4);
+    $dbh->do(qq{ INSERT INTO volume (vol_id, name, host, path, allocate, available) VALUES (6, 'node06', 'node06', ?, TRUE, FALSE) }, undef, $dir6);
     $dbh->do(qq{ INSERT INTO mount VALUES (?, 10e10, 10e7) }, undef, $dir6);
+
+    # node07: full
+    $dbh->do(qq{ INSERT INTO volume (vol_id, name, host, path, allocate, available) VALUES (7, 'node07', 'node07', ?, TRUE, TRUE) }, undef, $dir7);
+    $dbh->do(qq{ INSERT INTO mount VALUES (?, 10e10, 10e10) }, undef, $dir7);
 
     $dbh->do(qq{ call getmountedvol() });
@@ -88,4 +94,5 @@
     rmtree([$dir5], 0, 1) if -e $dir5;
     rmtree([$dir6], 0, 1) if -e $dir6;
+    rmtree([$dir7], 0, 1) if -e $dir7;
 }
 
Index: /trunk/Nebulous-Server/t/03_server_create_object.t
===================================================================
--- /trunk/Nebulous-Server/t/03_server_create_object.t	(revision 19492)
+++ /trunk/Nebulous-Server/t/03_server_create_object.t	(revision 19493)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 03_server_create_object.t,v 1.29 2008-09-10 23:53:23 bills Exp $
+# $Id: 03_server_create_object.t,v 1.30 2008-09-11 22:35:52 jhoblitt Exp $
 
 use strict;
@@ -353,14 +353,14 @@
 
 eval {
-    $neb->create_object("foo", '~node03');
-};
-like($@, qr/node03 is not available/, "request volume this is full");
-
-Test::Nebulous->setup;
-
-eval {
-    $neb->create_object("neb://~node03/foo");
-};
-like($@, qr/node03 is not available/, "request volume this is full");
+    $neb->create_object("foo", '~node07');
+};
+like($@, qr/node07 is not available/, "request volume this is full");
+
+Test::Nebulous->setup;
+
+eval {
+    $neb->create_object("neb://~node07/foo");
+};
+like($@, qr/node07 is not available/, "request volume this is full");
 
 Test::Nebulous->setup;
Index: /trunk/Nebulous-Server/t/04_server_replicate_object.t
===================================================================
--- /trunk/Nebulous-Server/t/04_server_replicate_object.t	(revision 19492)
+++ /trunk/Nebulous-Server/t/04_server_replicate_object.t	(revision 19493)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 04_server_replicate_object.t,v 1.15 2008-09-09 02:18:47 jhoblitt Exp $
+# $Id: 04_server_replicate_object.t,v 1.16 2008-09-11 22:35:52 jhoblitt Exp $
 
 use strict;
@@ -155,8 +155,8 @@
 Test::Nebulous->setup;
 
-{
+eval {
     $neb->create_object('foo');
     ok($neb->replicate_object('foo', 'bar'),'soft fake storage volume');
-}
+};
 
 Test::Nebulous->setup;
Index: /trunk/Nebulous-Server/t/07_server_find_instances.t
===================================================================
--- /trunk/Nebulous-Server/t/07_server_find_instances.t	(revision 19492)
+++ /trunk/Nebulous-Server/t/07_server_find_instances.t	(revision 19493)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 07_server_find_instances.t,v 1.15 2008-09-10 23:54:22 bills Exp $
+# $Id: 07_server_find_instances.t,v 1.16 2008-09-11 22:35:52 jhoblitt Exp $
 
 use strict;
@@ -121,7 +121,7 @@
 eval {
     $neb->create_object('foo');
-    $neb->find_instances('foo', 'bar');
+    $neb->find_instances('foo', '~bar');
 };
-like($@, qr/is valid volume name/, "storage volume does not exist");
+like($@, qr/is not a valid volume name/, "storage volume does not exist");
 
 Test::Nebulous->setup;
Index: /trunk/Nebulous-Server/t/15_mounts.t
===================================================================
--- /trunk/Nebulous-Server/t/15_mounts.t	(revision 19492)
+++ /trunk/Nebulous-Server/t/15_mounts.t	(revision 19493)
@@ -3,5 +3,5 @@
 # Copryight (C) 2008  Joshua Hoblitt
 #
-# $Id: 15_mounts.t,v 1.2 2008-07-01 00:28:07 jhoblitt Exp $
+# $Id: 15_mounts.t,v 1.3 2008-09-11 22:35:52 jhoblitt Exp $
 
 use strict;
@@ -28,5 +28,5 @@
     my $mounts = $neb->mounts();
 
-    is(scalar @$mounts, 6, "number of rows");
+    is(scalar @$mounts, 7, "number of rows");
 
     my %row;
