mirror of
https://github.com/duncs/clusterssh.git
synced 2025-07-03 09:53:23 +00:00
Start of tags file handling
Refactor file loading code into one place since it should all work in a similar way. Added in tag functionality. - Cluster files are: tag host host host host - Tag files are: host tag tag tag Yes to add in remainder of code to load in the files automatically
This commit is contained in:
parent
2ab7527633
commit
b2ba4daa46
8 changed files with 255 additions and 92 deletions
|
@ -183,42 +183,45 @@ sub parse_config_file {
|
|||
|
||||
$self->debug( 2, 'Loading in config file: ', $config_file );
|
||||
|
||||
if ( !-e $config_file || !-r $config_file ) {
|
||||
croak(
|
||||
App::ClusterSSH::Exception::Config->throw(
|
||||
error => $self->loc(
|
||||
'File [_1] does not exist or cannot be read' . $/,
|
||||
$config_file
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
# if ( !-e $config_file || !-r $config_file ) {
|
||||
# croak(
|
||||
# App::ClusterSSH::Exception::Config->throw(
|
||||
# error => $self->loc(
|
||||
# 'File [_1] does not exist or cannot be read' . $/,
|
||||
# $config_file
|
||||
# ),
|
||||
# ),
|
||||
# );
|
||||
# }
|
||||
#
|
||||
# open( CFG, $config_file ) or die("Couldnt open $config_file: $!");
|
||||
# my $l;
|
||||
# my %read_config;
|
||||
# while ( defined( $l = <CFG> ) ) {
|
||||
# next
|
||||
# if ( $l =~ /^\s*$/ || $l =~ /^#/ )
|
||||
# ; # ignore blank lines & commented lines
|
||||
# $l =~ s/#.*//; # remove comments from remaining lines
|
||||
# $l =~ s/\s*$//; # remove trailing whitespace
|
||||
#
|
||||
# # look for continuation lines
|
||||
# chomp $l;
|
||||
# if ( $l =~ s/\\\s*$// ) {
|
||||
# $l .= <CFG>;
|
||||
# redo unless eof(CFG);
|
||||
# }
|
||||
#
|
||||
# next unless $l =~ m/\s*(\S+)\s*=\s*(.*)\s*/;
|
||||
# my ( $key, $value ) = ( $1, $2 );
|
||||
# if ( defined $key && defined $value ) {
|
||||
# $read_config{$key} = $value;
|
||||
# $self->debug( 3, "$key=$value" );
|
||||
# }
|
||||
# }
|
||||
# close(CFG);
|
||||
|
||||
open( CFG, $config_file ) or die("Couldnt open $config_file: $!");
|
||||
my $l;
|
||||
my %read_config;
|
||||
while ( defined( $l = <CFG> ) ) {
|
||||
next
|
||||
if ( $l =~ /^\s*$/ || $l =~ /^#/ )
|
||||
; # ignore blank lines & commented lines
|
||||
$l =~ s/#.*//; # remove comments from remaining lines
|
||||
$l =~ s/\s*$//; # remove trailing whitespace
|
||||
|
||||
# look for continuation lines
|
||||
chomp $l;
|
||||
if ( $l =~ s/\\\s*$// ) {
|
||||
$l .= <CFG>;
|
||||
redo unless eof(CFG);
|
||||
}
|
||||
|
||||
next unless $l =~ m/\s*(\S+)\s*=\s*(.*)\s*/;
|
||||
my ( $key, $value ) = ( $1, $2 );
|
||||
if ( defined $key && defined $value ) {
|
||||
$read_config{$key} = $value;
|
||||
$self->debug( 3, "$key=$value" );
|
||||
}
|
||||
}
|
||||
close(CFG);
|
||||
%read_config = $self->load_file( type => 'config', filename => $config_file );
|
||||
|
||||
# grab any clusters from the config before validating it
|
||||
if ( $read_config{clusters} ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue