mirror of
https://github.com/duncs/clusterssh.git
synced 2025-07-03 09:53:23 +00:00
Start using new cluster module
This commit is contained in:
parent
cd4c59b12e
commit
015e130d77
3 changed files with 70 additions and 130 deletions
|
@ -24,18 +24,21 @@ sub new {
|
|||
}
|
||||
|
||||
sub get_clusters {
|
||||
my ($self) = @_;
|
||||
my ( $self, @files ) = @_;
|
||||
|
||||
$self->read_cluster_file('/etc/clusters');
|
||||
for my $file ( '/etc/clusters', @files ) {
|
||||
$self->debug(3, 'Loading in config from: ', $file);
|
||||
$self->read_cluster_file($file);
|
||||
}
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub read_cluster_file {
|
||||
my ( $self, $filename ) = @_;
|
||||
$self->debug( 2, 'Reading clusters from file ', $filename );
|
||||
|
||||
if ( -f $filename ) {
|
||||
$self->debug( 2, 'Reading clusters from file ', $filename );
|
||||
open( my $fh, '<', $filename )
|
||||
|| croak(
|
||||
App::ClusterSSH::Exception::Cluster->throw(
|
||||
|
@ -56,7 +59,7 @@ sub read_cluster_file {
|
|||
$line .= <$fh>;
|
||||
redo unless eof($fh);
|
||||
}
|
||||
my @line = split( /\s/, $line );
|
||||
my @line = split( /\s+/, $line );
|
||||
|
||||
#s/^([\w-]+)\s*//; # remote first word and stick into $1
|
||||
|
||||
|
@ -66,6 +69,9 @@ sub read_cluster_file {
|
|||
|
||||
close($fh);
|
||||
}
|
||||
else {
|
||||
$self->debug( 2, 'No file found to read');
|
||||
}
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -85,13 +91,19 @@ sub get_tag {
|
|||
if ( $self->{$tag} ) {
|
||||
$self->debug( 2, "Retrieving tag $tag: ",
|
||||
join( ' ', $self->{$tag} ) );
|
||||
return $self->{$tag};
|
||||
|
||||
return @{ $self->{$tag} };
|
||||
}
|
||||
|
||||
$self->debug( 2, "Tag $tag is not registered" );
|
||||
return;
|
||||
}
|
||||
|
||||
sub list_tags {
|
||||
my ($self) = @_;
|
||||
return keys(%$self);
|
||||
}
|
||||
|
||||
sub resolve_all_tags {
|
||||
my ($self) = @_;
|
||||
|
||||
|
|
|
@ -12,8 +12,9 @@ use Try::Tiny;
|
|||
use FindBin qw($Script);
|
||||
|
||||
use base qw/ App::ClusterSSH::Base /;
|
||||
use App::ClusterSSH::Cluster;
|
||||
|
||||
my %clusters;
|
||||
my $clusters;
|
||||
my @app_specific = (qw/ command title comms method ssh rsh telnet ccon /);
|
||||
my %default_config = (
|
||||
terminal => "xterm",
|
||||
|
@ -94,6 +95,8 @@ sub new {
|
|||
|
||||
$self->{title} = uc($Script);
|
||||
|
||||
$clusters=App::ClusterSSH::Cluster->new();
|
||||
|
||||
return $self->validate_args(%args);
|
||||
}
|
||||
|
||||
|
@ -175,10 +178,12 @@ sub parse_config_file {
|
|||
|
||||
# grab any clusters from the config before validating it
|
||||
if ( $read_config{clusters} ) {
|
||||
carp("TODO: deal with clusters");
|
||||
$self->debug( 3, "Picked up clusters defined in $config_file" );
|
||||
foreach my $cluster ( sort split / /, $read_config{clusters} ) {
|
||||
if($read_config{$cluster}) {
|
||||
$clusters->register_tag($cluster,$read_config{$cluster});
|
||||
delete( $read_config{$cluster} );
|
||||
}
|
||||
}
|
||||
delete( $read_config{clusters} );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue