Ensure ssh_args in config file is honored

Because the default value is defined for --options parameter, the config file value was always overwritten

Only use --options if config file option is not defined and --options is not the default value
This commit is contained in:
Duncan Ferguson 2014-09-19 23:01:41 +01:00
parent 26e783be1c
commit 8aaea928d7
3 changed files with 34 additions and 20 deletions

View file

@ -1,6 +1,7 @@
4.03_03 0000-00-00 Duncan Ferguson <duncan_ferguson@user.sf.net>
- Force tests to have English locale when user has something else set (Github issue: 10) (thanks to Emanuele Tomasi)
- Skip permissions check test when run as root as the results are invalid (Github issue: 11) (thanks to Deny Dias)
- Ensure config file option for ssh_args is not lost when options is not used on command line (Github issue: 14)
4.03_02 2014-08-10 Duncan Ferguson <duncan_ferguson@user.sf.net>
- Fix behaviour when external cluster command is not defined or doesn't exist

View file

@ -5,7 +5,7 @@ use warnings;
use strict;
use version; our $VERSION = version->new('4.03_03');
use Carp;
use Carp qw/cluck/;
use base qw/ App::ClusterSSH::Base /;
use App::ClusterSSH::Host;
@ -55,8 +55,8 @@ sub new {
my $self = $class->SUPER::new(%args);
$self->{cluster} = App::ClusterSSH::Cluster->new( parent => $self, );
$self->{config} = App::ClusterSSH::Config->new( parent => $self, );
$self->{helper} = App::ClusterSSH::Helper->new( parent => $self, );
$self->{config} = App::ClusterSSH::Config->new( parent => $self, );
$self->{helper} = App::ClusterSSH::Helper->new( parent => $self, );
$self->{options} = App::ClusterSSH::Getopt->new( parent => $self, );
# catch and reap any zombies
@ -412,8 +412,7 @@ sub resolve_names(@) {
# out entries are not lost
my @new_servers;
eval {
@new_servers
= $self->cluster->get_external_clusters( @servers );
@new_servers = $self->cluster->get_external_clusters(@servers);
};
if ($@) {
@ -703,6 +702,7 @@ sub open_client_windows(@) {
}
if ( $servers{$server}{pid} == 0 ) {
# this is the child
# Since this is the child, we can mark any server unresolved without
# affecting the main program
@ -1165,9 +1165,9 @@ sub set_half_inactive() {
my ($self) = @_;
logmsg( 2, "Setting approx half of all hosts to inactive" );
my(@keys) = keys(%servers);
$#keys /= 2;
foreach my $svr ( @keys ) {
my (@keys) = keys(%servers);
$#keys /= 2;
foreach my $svr (@keys) {
$servers{$svr}{active} = 0;
}
}
@ -1462,14 +1462,13 @@ sub create_windows() {
);
my @tags = $self->cluster->list_tags();
my @external_tags = map { "$_ *" } $self->cluster->list_external_clusters();
push (@tags, @external_tags);
my @external_tags = map {"$_ *"} $self->cluster->list_external_clusters();
push( @tags, @external_tags );
if ( $self->config->{max_addhost_menu_cluster_items}
&& scalar @tags )
{
if (scalar @tags
< $self->config->{max_addhost_menu_cluster_items} )
if ( scalar @tags < $self->config->{max_addhost_menu_cluster_items} )
{
$menus{listbox} = $windows{addhost}->Listbox(
-selectmode => 'extended',
@ -1488,11 +1487,11 @@ sub create_windows() {
}
$menus{listbox}->insert( 'end', sort @tags );
if(@external_tags) {
if (@external_tags) {
$menus{addhost_text} = $windows{addhost}->add(
'Label',
-class => 'cssh',
-text => '* is external',
'Label',
-class => 'cssh',
-text => '* is external',
)->pack();
#$menus{addhost_text}->insert('end','lkjh lkjj sdfl jklsj dflj ');
@ -1911,8 +1910,20 @@ sub run {
$self->debug( 2, "VERSION: $VERSION" );
$self->config->{ssh_args} = $self->options->options
if ( $self->options->options );
# only use ssh_args from options if config file ssh_args not set AND
# options is not the default value otherwise the default options
# value is used instead of the config file
if ( $self->config->{ssh_args} ) {
if ( $self->options->options
&& $self->options->options ne $self->options->options_default )
{
$self->config->{ssh_args} = $self->options->options;
}
}
else {
$self->config->{ssh_args} = $self->options->options
if ( $self->options->options );
}
$self->config->{terminal_args} = $self->options->term_args
if ( $self->options->term_args );
@ -1946,9 +1957,9 @@ sub run {
print "\t", $_, $/ foreach ( sort( $self->cluster->list_tags ) );
my @external_clusters = $self->cluster->list_external_clusters;
if(@external_clusters) {
if (@external_clusters) {
print( 'Available external command tags:', $/ );
print "\t", $_, $/ foreach ( sort( @external_clusters ) );
print "\t", $_, $/ foreach ( sort(@external_clusters) );
}
$self->debug(

View file

@ -307,6 +307,8 @@ sub getopts {
# ? $self->{command_options}->{$acc}->{default}
# : undef;
};
my $accessor_default=$accessor.'_default';
*$accessor_default = sub { return $default; };
}
}