mirror of
https://github.com/duncs/clusterssh.git
synced 2025-04-21 09:09:06 +00:00
Fixed the default cluster not being opened
This was due to a method being called in scalar context, which returned incorrect detail Reported by Aaron C. de Bruyn
This commit is contained in:
parent
e825bc17ca
commit
583c8bbe53
5 changed files with 56 additions and 7 deletions
1
Changes
1
Changes
|
@ -4,6 +4,7 @@
|
|||
- Add in key shortcut for local hostname macro (ALT-l)
|
||||
- Fixed a bug with 'show history' key shortcut
|
||||
- Fixed "uninitialised errors in hash element" bug [clusterssh support-requests:#38]
|
||||
- Fixed the default cluster not being opened
|
||||
|
||||
2013-04-16 Duncan Ferguson <duncan_ferguson@user.sf.net> - v4.02_01
|
||||
- Refactured file loading code
|
||||
|
|
|
@ -291,7 +291,9 @@ sub load_keyboard_map() {
|
|||
# try to associate $keyboard=X11->GetKeyboardMapping table with X11::Keysyms
|
||||
foreach my $i ( 0 .. $#keyboard ) {
|
||||
for my $modifier ( 0 .. 3 ) {
|
||||
if ( defined( $keyboard[$i][$modifier] ) && defined( $keycodetosym{ $keyboard[$i][$modifier] } ) ) {
|
||||
if ( defined( $keyboard[$i][$modifier] )
|
||||
&& defined( $keycodetosym{ $keyboard[$i][$modifier] } ) )
|
||||
{
|
||||
|
||||
# keyboard layout contains the keycode at $modifier level
|
||||
if (defined(
|
||||
|
@ -328,7 +330,9 @@ sub load_keyboard_map() {
|
|||
else {
|
||||
|
||||
# we didn't get the code from X11::Keysyms
|
||||
if ( defined( $keyboard[$i][$modifier] ) && $keyboard[$i][$modifier] != 0 ) {
|
||||
if ( defined( $keyboard[$i][$modifier] )
|
||||
&& $keyboard[$i][$modifier] != 0 )
|
||||
{
|
||||
|
||||
# ignore code=0
|
||||
logmsg( 2, "Unknown keycode ", $keyboard[$i][$modifier] );
|
||||
|
@ -384,6 +388,9 @@ sub resolve_names(@) {
|
|||
my ( $self, @servers ) = @_;
|
||||
logmsg( 2, 'Resolving cluster names: started' );
|
||||
|
||||
use Data::Dump qw(dump);
|
||||
warn dump \@servers;
|
||||
|
||||
foreach (@servers) {
|
||||
my $dirty = $_;
|
||||
my $username = q{};
|
||||
|
@ -1620,7 +1627,7 @@ sub key_event {
|
|||
$self->retile_hosts("force")
|
||||
if ( $hotkey eq "key_retilehosts" );
|
||||
$self->show_history() if ( $hotkey eq "key_history" );
|
||||
exit_prog() if ( $hotkey eq "key_quit" );
|
||||
exit_prog() if ( $hotkey eq "key_quit" );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1937,9 +1944,18 @@ sub run {
|
|||
@servers = $self->resolve_names(@ARGV);
|
||||
}
|
||||
else {
|
||||
|
||||
#if ( my @default = $self->cluster->get_tag('default') ) {
|
||||
if ( $self->cluster->get_tag('default') ) {
|
||||
@servers
|
||||
|
||||
# = $self->resolve_names( @default );
|
||||
= $self->resolve_names( $self->cluster->get_tag('default') );
|
||||
warn "blip";
|
||||
}
|
||||
else {
|
||||
warn "blop";
|
||||
warn scalar $self->cluster->get_tag('default');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,10 @@ sub get_tag {
|
|||
join( ' ', sort @{ $self->{tags}->{$tag} } )
|
||||
);
|
||||
|
||||
return sort @{ $self->{tags}->{$tag} };
|
||||
return
|
||||
wantarray
|
||||
? sort @{ $self->{tags}->{$tag} }
|
||||
: scalar @{ $self->{tags}->{$tag} };
|
||||
}
|
||||
|
||||
$self->debug( 2, "Tag $tag is not registered" );
|
||||
|
@ -240,7 +243,10 @@ Register the given host on the provided tags.
|
|||
|
||||
=item @entries = $cluster->get_tag('tag');
|
||||
|
||||
Retrieve all entries for the given tag
|
||||
=item $entries = $cluster->get_tag('tag');
|
||||
|
||||
Retrieve all entries for the given tag. Returns an array of hosts or
|
||||
the number of hosts in the array depending on context.
|
||||
|
||||
=item @tags = $cluster->list_tags();
|
||||
|
||||
|
|
10
t/30cluster.file3
Normal file
10
t/30cluster.file3
Normal file
|
@ -0,0 +1,10 @@
|
|||
# a comment
|
||||
tag1 host1
|
||||
tag2 host2
|
||||
|
||||
#line wrapped
|
||||
tag3 host3 \
|
||||
host4
|
||||
|
||||
|
||||
default host7 host8 host9
|
|
@ -76,6 +76,18 @@ $expected{tag50} = [ 'host30', ];
|
|||
$cluster1->read_tag_file( $Bin . '/30cluster.tag1' );
|
||||
test_expected( 'tag 1', %expected );
|
||||
|
||||
$cluster1->read_cluster_file( $Bin . '/30cluster.file3' );
|
||||
my @default_expected = (qw/ host7 host8 host9 /);
|
||||
$expected{default} = \@default_expected;
|
||||
test_expected( 'file 3', %expected );
|
||||
my @default = $cluster1->get_tag('default');
|
||||
is_deeply( \@default, \@default_expected, 'default cluster ok' );
|
||||
|
||||
is( scalar $cluster1->get_tag('default'),
|
||||
scalar @default_expected,
|
||||
'Count correct'
|
||||
);
|
||||
|
||||
# now checks against running an external command
|
||||
|
||||
my @external_expected;
|
||||
|
@ -125,7 +137,9 @@ trap {
|
|||
@external_expected = $cluster1->get_external_clusters(
|
||||
"$Bin/external_cluster_command -x $redirect");
|
||||
};
|
||||
like( $trap->die, qr/External command failure.*external_cluster_command.*Return Code: 5/ms,
|
||||
like(
|
||||
$trap->die,
|
||||
qr/External command failure.*external_cluster_command.*Return Code: 5/ms,
|
||||
'External command: caught exception message'
|
||||
);
|
||||
is( $trap->stdout, '', 'External command: no stdout from perl code' );
|
||||
|
@ -135,7 +149,9 @@ trap {
|
|||
@external_expected = $cluster1->get_external_clusters(
|
||||
"$Bin/external_cluster_command -q $redirect");
|
||||
};
|
||||
like( $trap->die, qr/External command failure.*external_cluster_command.*Return Code: 255/ms,
|
||||
like(
|
||||
$trap->die,
|
||||
qr/External command failure.*external_cluster_command.*Return Code: 255/ms,
|
||||
'External command: caught exception message'
|
||||
);
|
||||
is( $trap->stdout, '', 'External command: no stdout from perl code' );
|
||||
|
|
Loading…
Add table
Reference in a new issue