Changeset 19431
- Timestamp:
- Sep 8, 2008, 4:18:47 PM (18 years ago)
- Location:
- trunk/Nebulous-Server
- Files:
-
- 6 edited
-
docs/setup.txt (modified) (1 diff)
-
lib/Nebulous/Keys.pm (modified) (3 diffs)
-
lib/Nebulous/Server.pm (modified) (6 diffs)
-
t/03_server_create_object.t (modified) (10 diffs)
-
t/04_server_replicate_object.t (modified) (3 diffs)
-
t/75_parse_neb_key.t (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/docs/setup.txt
r13210 r19431 32 32 chmod 0770 /data/ipp00?.?/nebulous 33 33 ls -lad /data/ipp00?.?/nebulous 34 35 mkdir /data/`hostname`.0/nebulous 36 chown nobody:nebulous /data/`hostname`.0/nebulous 37 chmod 0770 /data/`hostname`.0/nebulous 34 38 35 39 =head2 Build and install the Nebulous Perl modules (see: README) -
trunk/Nebulous-Server/lib/Nebulous/Keys.pm
r18451 r19431 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Keys.pm,v 1. 2 2008-07-09 23:32:35jhoblitt Exp $3 # $Id: Keys.pm,v 1.3 2008-09-09 02:18:47 jhoblitt Exp $ 4 4 5 5 package Nebulous::Keys; … … 8 8 use warnings FATAL => qw( all ); 9 9 10 our $VERSION = '0.0 1';10 our $VERSION = '0.02'; 11 11 12 12 use base qw( Exporter Class::Accessor::Fast ); … … 99 99 my $soft_volume; 100 100 # check to see if there is a tilde and remove it if found 101 if(defined $volume and $volume =~ s/^~//) {101 unless (defined $volume and $volume =~ s/^~//) { 102 102 $soft_volume = 1; 103 103 } -
trunk/Nebulous-Server/lib/Nebulous/Server.pm
r19144 r19431 1 1 # Copyright (c) 2004-2008 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.8 3 2008-08-21 02:26:58jhoblitt Exp $3 # $Id: Server.pm,v 1.84 2008-09-09 02:18:47 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 150 150 { 151 151 type => SCALAR|UNDEF, 152 callbacks => {153 # check that the volume requested is valid154 'is valid volume name' => sub {155 return 1 if not defined $_[0];156 $self->_is_valid_volume_name($_[0])157 },158 },152 # callbacks => { 153 # # check that the volume requested is valid 154 # 'is valid volume name' => sub { 155 # return 1 if not defined $_[0]; 156 # $self->_is_valid_volume_name($_[0]) 157 # }, 158 # }, 159 159 optional => 1, 160 160 }, … … 167 167 $log->debug( "entered - @_" ); 168 168 169 # vol_name overrides the key implied volume 169 170 $key = parse_neb_key($key, $vol_name); 170 # vol_name overrides the key implied volume 171 $vol_name = $key->volume; 172 173 # the key isn't validiated on input for this method so we have to check it 174 # again after parsing the key 175 if (defined $vol_name and not $self->_is_valid_volume_name($vol_name)) { 171 172 if ($vol_name eq "99") { 173 use Data::Dumper; 174 print Dumper($key); 175 } 176 177 # the key's volume can't be validiated on input for this method so we have 178 # to check it after parsing the key 179 if (defined $key->volume 180 and not $key->soft_volume 181 and not $self->_is_valid_volume_name($key->volume) 182 ) { 176 183 $log->logdie("$vol_name is not a valid volume name"); 177 184 } 178 185 179 if (defined $key->soft_volume) {180 $vol_name = undef;181 }182 183 186 my ($vol_id, $vol_host, $vol_path, $vol_xattr) 184 = $self->_get_storage_volume($ vol_name);187 = $self->_get_storage_volume($key->volume, $key->soft_volume); 185 188 186 189 my $uri; … … 330 333 { 331 334 type => SCALAR|UNDEF, 332 callbacks => {333 # check that the volume name requested is valid334 'is valid volume name' => sub {335 return 1 if not defined $_[0];336 $self->_is_valid_volume_name($_[0])337 },338 },335 # callbacks => { 336 # # check that the volume name requested is valid 337 # 'is valid volume name' => sub { 338 # return 1 if not defined $_[0]; 339 # $self->_is_valid_volume_name($_[0]) 340 # }, 341 # }, 339 342 optional => 1, 340 343 }, … … 1164 1167 use warnings; 1165 1168 1166 my $name = shift;1169 my ($name, $soft_volume) = @_; 1167 1170 1168 1171 my ($vol_id, $vol_host, $vol_path, $xattr); … … 1178 1181 unless ($rows > 0) { 1179 1182 $query->finish; 1183 1184 # if a volume name was specified, and is soft, and we failed to 1185 # find it, fall back to any volume 1186 if ($soft_volume) { 1187 return $self->_get_storage_volume; 1188 } 1180 1189 $log->logdie("storage volume: $name is not available"); 1181 1190 } -
trunk/Nebulous-Server/t/03_server_create_object.t
r18452 r19431 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 03_server_create_object.t,v 1.2 7 2008-07-10 00:20:02jhoblitt Exp $5 # $Id: 03_server_create_object.t,v 1.28 2008-09-09 02:18:47 jhoblitt Exp $ 6 6 7 7 use strict; … … 353 353 354 354 eval { 355 $neb->create_object("foo", ' node03');355 $neb->create_object("foo", '~node03'); 356 356 }; 357 357 like($@, qr/node03 is not available/, "request volume this is full"); … … 360 360 361 361 eval { 362 $neb->create_object("neb:// node03/foo");362 $neb->create_object("neb://~node03/foo"); 363 363 }; 364 364 like($@, qr/node03 is not available/, "request volume this is full"); … … 367 367 368 368 eval { 369 $neb->create_object("foo", ' node04');369 $neb->create_object("foo", '~node04'); 370 370 }; 371 371 like($@, qr/node04 is not available/, "request volume with allocate = FALSE, available = FALSE"); … … 374 374 375 375 eval { 376 $neb->create_object("neb:// node04/foo");376 $neb->create_object("neb://~node04/foo"); 377 377 }; 378 378 like($@, qr/node04 is not available/, "request volume with allocate = FALSE, available = FALSE"); … … 381 381 382 382 eval { 383 $neb->create_object("foo", ' node05');383 $neb->create_object("foo", '~node05'); 384 384 }; 385 385 like($@, qr/node05 is not available/, "request volume with allocate = FALSE , available = TRUE"); … … 388 388 389 389 eval { 390 $neb->create_object("neb:// node05/foo");390 $neb->create_object("neb://~node05/foo"); 391 391 }; 392 392 like($@, qr/node05 is not available/, "request volume with allocate = FALSE , available = TRUE"); … … 395 395 396 396 eval { 397 $neb->create_object("foo", ' node06');397 $neb->create_object("foo", '~node06'); 398 398 }; 399 399 like($@, qr/node06 is not available/, "request volume with allocate = TRUE, available = FALSE"); … … 402 402 403 403 eval { 404 $neb->create_object("neb:// node06/foo");404 $neb->create_object("neb://~node06/foo"); 405 405 }; 406 406 like($@, qr/node06 is not available/, "request volume with allocate = TRUE, available = FALSE"); … … 408 408 Test::Nebulous->setup; 409 409 410 eval { 411 $neb->create_object("foo", 99); 412 }; 413 like($@, qr/did not pass the \'is valid volume name\'/, "volume name doesn't exist"); 410 { 411 ok($neb->create_object("foo", 99)); 412 } 413 414 Test::Nebulous->setup; 415 416 eval { 417 $neb->create_object("foo", "~99"); 418 }; 419 like($@, qr/is not a valid volume name/, "volume name doesn't exist"); 414 420 415 421 Test::Nebulous->setup; -
trunk/Nebulous-Server/t/04_server_replicate_object.t
r18452 r19431 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 04_server_replicate_object.t,v 1.1 4 2008-07-10 00:20:02jhoblitt Exp $5 # $Id: 04_server_replicate_object.t,v 1.15 2008-09-09 02:18:47 jhoblitt Exp $ 6 6 7 7 use strict; 8 8 use warnings FATAL => qw( all ); 9 9 10 use Test::More tests => 2 5;10 use Test::More tests => 26; 11 11 12 12 use lib qw( ./t ./lib ); … … 82 82 # key, $volume 83 83 $neb->create_object("foo"); 84 my $uri1 = $neb->replicate_object("foo", " node01");85 my $uri2 = $neb->replicate_object("foo", " node02");84 my $uri1 = $neb->replicate_object("foo", "~node01"); 85 my $uri2 = $neb->replicate_object("foo", "~node02"); 86 86 87 87 { … … 155 155 Test::Nebulous->setup; 156 156 157 { 158 $neb->create_object('foo'); 159 ok($neb->replicate_object('foo', 'bar'),'soft fake storage volume'); 160 } 161 162 Test::Nebulous->setup; 163 157 164 eval { 158 165 $neb->create_object('foo'); 159 $neb->replicate_object('foo', ' bar');166 $neb->replicate_object('foo', '~bar'); 160 167 }; 161 like($@, qr/is valid volume name/, 'storage volume does not exist');168 like($@, qr/is not a valid volume name/, 'storage volume does not exist'); 162 169 163 170 Test::Nebulous->setup; -
trunk/Nebulous-Server/t/75_parse_neb_key.t
r18451 r19431 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 75_parse_neb_key.t,v 1. 4 2008-07-09 23:32:35jhoblitt Exp $5 # $Id: 75_parse_neb_key.t,v 1.5 2008-09-09 02:18:47 jhoblitt Exp $ 6 6 7 7 use strict; … … 77 77 is($key->path, 'foo/bar/baz/quix', 'path'); 78 78 is($key->volume, 'boing', 'volume name'); 79 is($key->soft_volume, undef, 'soft volume name');79 is($key->soft_volume, 1, 'soft volume name'); 80 80 } 81 81 … … 85 85 is($key->path, 'foo/bar/baz/quix', 'path'); 86 86 is($key->volume, 'boing', 'volume name'); 87 is($key->soft_volume, 1, 'soft volume name');87 is($key->soft_volume, undef, 'soft volume name'); 88 88 } 89 89 … … 94 94 is($key->path, 'bar/baz/quix', 'path'); 95 95 is($key->volume, 'foo', 'volume name'); 96 is($key->soft_volume, undef, 'soft volume name');96 is($key->soft_volume, 1, 'soft volume name'); 97 97 } 98 98 … … 102 102 is($key->path, 'bar/baz/quix', 'path'); 103 103 is($key->volume, 'foo', 'volume name'); 104 is($key->soft_volume, undef, 'soft volume name');104 is($key->soft_volume, 1, 'soft volume name'); 105 105 } 106 106 … … 110 110 is($key->path, 'bar/baz/quix', 'path'); 111 111 is($key->volume, 'foo', 'volume name'); 112 is($key->soft_volume, undef, 'soft volume name');112 is($key->soft_volume, 1, 'soft volume name'); 113 113 } 114 114 … … 118 118 is($key->path, 'bar/baz/quix', 'path'); 119 119 is($key->volume, 'foo', 'volume name'); 120 is($key->soft_volume, undef, 'soft volume name');120 is($key->soft_volume, 1, 'soft volume name'); 121 121 } 122 122 … … 126 126 is($key->path, 'bar/baz/quix', 'path'); 127 127 is($key->volume, 'foo', 'volume name'); 128 is($key->soft_volume, undef, 'soft volume name');129 } 130 131 # URI w/ softvolume name128 is($key->soft_volume, 1, 'soft volume name'); 129 } 130 131 # URI w/ hard volume name 132 132 { 133 133 my $key = parse_neb_key('neb://~foo/bar/baz/quix/'); … … 135 135 is($key->path, 'bar/baz/quix', 'path'); 136 136 is($key->volume, 'foo', 'volume name'); 137 is($key->soft_volume, 1, 'soft volume name');137 is($key->soft_volume, undef, 'soft volume name'); 138 138 } 139 139 … … 144 144 is($key->path, 'bar/baz/quix', 'path'); 145 145 is($key->volume, 'boing', 'volume name'); 146 is($key->soft_volume, undef, 'soft volume name');146 is($key->soft_volume, 1, 'soft volume name'); 147 147 } 148 148 … … 152 152 is($key->path, 'bar/baz/quix', 'path'); 153 153 is($key->volume, 'boing', 'volume name'); 154 is($key->soft_volume, 1, 'soft volume name');154 is($key->soft_volume, undef, 'soft volume name'); 155 155 } 156 156 … … 160 160 is($key->path, 'bar/baz/quix', 'path'); 161 161 is($key->volume, 'foo', 'volume name'); 162 is($key->soft_volume, undef, 'soft volume name');162 is($key->soft_volume, 1, 'soft volume name'); 163 163 } 164 164 … … 189 189 } 190 190 191 # URI w/ softvolume name191 # URI w/ hard volume name 192 192 { 193 193 my $key = parse_neb_key('neb://~foo/bar/baz/quix/'); … … 195 195 is($key->path, 'bar/baz/quix', 'path'); 196 196 is($key->volume, 'foo', 'volume name'); 197 is($key->soft_volume, 1, 'soft volume name');197 is($key->soft_volume, undef, 'soft volume name'); 198 198 } 199 199
Note:
See TracChangeset
for help on using the changeset viewer.
