IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 28, 2010, 2:59:29 PM (16 years ago)
Author:
watersc1
Message:

Final update to nebulous for this iteration. Changes:

  • nebdiskd reads its configuration from a sane location.
  • neb-ls is useful.
Location:
trunk/Nebulous-Server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/bin/nebdiskd

    r28492 r28525  
    5353# set the process name for easy pgrep-ability
    5454$0 = 'nebdiskd';
    55 my $rcfile = "$ENV{HOME}/.nebdiskrc";
     55#my $rcfile = "$ENV{HOME}/.nebdiskrc";
     56my $rcfile = $ENV{NEBDISKDRC};
     57unless (defined($rcfile)) {
     58    $rcfile = '/etc/nebdiskd.rc';
     59}
    5660$rcfile = File::Spec->canonpath($rcfile);
    5761
     
    7175my %host_removed = ();
    7276my $failure_limit = 5;
    73 
    74 
    7577
    7678#my $mounts = $c->get_mounts;
     
    143145$SIG{HUP}  = sub { $c = read_rcfile($rcfile) };
    144146
     147my $date = localtime();
     148$log->warn("BEGIN: $date with RCFILE: $rcfile");
    145149
    146150while (1) {
  • trunk/Nebulous-Server/lib/Nebulous/Server.pm

    r28446 r28525  
    99no warnings qw( uninitialized );
    1010
    11 our $VERSION = '0.17';
     11our $VERSION = '0.18';
    1212
    1313use base qw( Class::Accessor::Fast );
     
    15081508
    15091509    return \@keys;
     1510}
     1511
     1512sub find_objects_wildcard
     1513{
     1514    my $self = shift;
     1515
     1516    my $log = $self->log;
     1517    $log->debug( "entered - @_" );
     1518
     1519    my ($pattern) = validate_pos( @_,
     1520        {
     1521            type        => SCALAR,
     1522            optional    => 1,
     1523        },
     1524    );
     1525
     1526    my $sql = $self->sql;
     1527    my $db  = $self->_db_for_index(0);
     1528   
     1529    # validate that we have a key to deal with
     1530    eval {
     1531        $pattern = parse_neb_key($pattern) if defined $pattern;
     1532    };
     1533    $log->logdie("$@") if $@;
     1534
     1535    unless (defined $pattern) {
     1536        $log->debug( "leaving" );
     1537        $log->logdie("no keys found");
     1538    }
     1539
     1540    # parse out the directory we're working in, and decide if we are a directory
     1541    my $dir_id = $self->_resolve_dir_parent_id(key => $pattern, dir_id => 1);
     1542    my $work_dir;
     1543    my $file_pattern;
     1544    if (defined $dir_id) {
     1545        $work_dir = $pattern;
     1546        $file_pattern = '%';
     1547    }
     1548    else {
     1549        my $dir_plain = dirname($pattern);
     1550        if ($dir_plain eq 'neb:') {
     1551            $dir_plain = 'neb:///';
     1552        }
     1553        if ($dir_plain) {
     1554            $work_dir = parse_neb_key($dir_plain);
     1555        }
     1556        else {
     1557            $work_dir = parse_neb_key('/');
     1558        }
     1559        $log->warn("work dir: $work_dir " . $work_dir->path);
     1560        $file_pattern = basename $pattern;
     1561        unless ($file_pattern) {
     1562            $file_pattern = '%';
     1563        }
     1564       
     1565        $dir_id = $self->_resolve_dir_parent_id(key => $work_dir, dir_id => 1);
     1566        unless (defined $dir_id) {
     1567            $log->logdie("pattern $work_dir does not match any key or directory");
     1568        }
     1569    }
     1570   
     1571    # find dirs under dir
     1572    my @dir_keys;
     1573
     1574    eval {
     1575        $log->debug("looking for directories under dir: $dir_id");
     1576        $log->warn("dir_id: $dir_id pattern: $file_pattern");
     1577        my $query = $db->prepare_cached( $sql->find_dir_by_parent_id . " AND dirname LIKE ? ");
     1578        $query->execute( $dir_id, $file_pattern );
     1579
     1580        while ( my $row = $query->fetchrow_hashref ) {
     1581            next if $row->{'dir_id'} == 1;
     1582            my $dir = $row->{'dirname'};
     1583            if ($dir_id == 1) {
     1584                push @dir_keys, $dir . '/' if $dir;
     1585            } else {
     1586                push @dir_keys, $work_dir->path . '/' . $dir . '/' if $dir;
     1587            }
     1588            $log->debug( "matched $dir" ) if $dir;
     1589        }
     1590    };
     1591    $log->logdie("database error: $@") if $@;
     1592
     1593    # find files under dir
     1594    my @keys;
     1595    eval {
     1596        $log->debug("looking for objects under dir: $dir_id");
     1597        my $query = $db->prepare_cached( $sql->find_object_by_dir_id . " AND ext_id_basename LIKE ? ");
     1598        $query->execute( $dir_id , $file_pattern);
     1599
     1600        while ( my $row = $query->fetchrow_hashref ) {
     1601            my $key = $row->{ 'ext_id' };
     1602            push @keys, $key if $key;
     1603            $log->debug( "matched $key" ) if $key;
     1604        }
     1605    };
     1606    $log->logdie("database error: $@") if $@;
     1607
     1608    $log->debug( "leaving" );
     1609   
     1610    return [sort(@dir_keys), sort(@keys)];
     1611
    15101612}
    15111613
Note: See TracChangeset for help on using the changeset viewer.