IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 26, 2009, 3:28:02 PM (17 years ago)
Author:
jhoblitt
Message:

fwv of console-config

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/console/lib/Console.pm

    r24600 r24610  
    88
    99use Config::YAML;
     10use Params::Validate qw(:all);
     11
    1012
    1113sub find_rcfile
    1214{
     15    validate_pos(@_);
     16
    1317    my $rcname = "." . __PACKAGE__ . "rc";
    1418    my $rcfile;
     
    2529sub read_rcfile
    2630{
     31    validate_pos(@_, 1);
     32
    2733    my $rcfile = shift;
    2834
     
    4046}
    4147
     48sub add_host
     49{
     50    my %p = validate(@_,
     51        {
     52            config      => { isa => 'Config::YAML', },
     53            hostname    => { type => SCALAR, },
     54            console     => { type => SCALAR, },
     55         },
     56    );
     57
     58    my $c = $p{config};
     59
     60    my $hosts = $c->get_hosts;
     61    $hosts->{$p{hostname}} = { console => $p{console} };
     62    $c->set_hosts($hosts);
     63    $c->write;
     64
     65    return 1;
     66}
     67
     68sub delete_host
     69{
     70    my %p = validate(@_,
     71        {
     72            config      => { isa => 'Config::YAML', },
     73            hostname    => { type => SCALAR, },
     74         },
     75    );
     76
     77    my $c = $p{config};
     78
     79    my $hosts = $c->get_hosts;
     80    delete $hosts->{$p{hostname}};
     81    $c->set_hosts($hosts);
     82    $c->write;
     83
     84    return 1;
     85}
     86
    4287
    43881;
Note: See TracChangeset for help on using the changeset viewer.