+ Enhance custom mode load: if there is only one custommode we load it (simple)
This commit is contained in:
parent
c080f651b3
commit
8da8362e1a
|
@ -66,6 +66,15 @@ sub new {
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub load_custom_mode {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->is_custommode(custommode => $self->{custommode_name});
|
||||||
|
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{custom_modes}{$self->{custommode_name}},
|
||||||
|
error_msg => "Cannot load module --custommode.");
|
||||||
|
$self->{custommode_current} = $self->{custom_modes}{$self->{custommode_name}}->new(options => $self->{options}, output => $self->{output}, mode => $self->{custommode_name});
|
||||||
|
}
|
||||||
|
|
||||||
sub init {
|
sub init {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
# $options{version} = string version
|
# $options{version} = string version
|
||||||
|
@ -92,10 +101,10 @@ sub init {
|
||||||
$self->{options}->add_help(package => 'centreon::plugins::output', sections => 'OUTPUT OPTIONS');
|
$self->{options}->add_help(package => 'centreon::plugins::output', sections => 'OUTPUT OPTIONS');
|
||||||
|
|
||||||
if (defined($self->{custommode_name}) && $self->{custommode_name} ne '') {
|
if (defined($self->{custommode_name}) && $self->{custommode_name} ne '') {
|
||||||
$self->is_custommode(custommode => $self->{custommode_name});
|
$self->load_custom_mode();
|
||||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{custom_modes}{$self->{custommode_name}},
|
} elsif (scalar(%{$self->{custom_modes}}) == 1) {
|
||||||
error_msg => "Cannot load module --custommode.");
|
$self->{custommode_name} = keys(%{$self->{custom_modes}})[0];
|
||||||
$self->{custommode_current} = $self->{custom_modes}{$self->{custommode_name}}->new(options => $self->{options}, output => $self->{output}, mode => $self->{custommode_name});
|
$self->load_custom_mode();
|
||||||
} else {
|
} else {
|
||||||
$self->{output}->add_option_msg(short_msg => "Need to specify '--custommode'.");
|
$self->{output}->add_option_msg(short_msg => "Need to specify '--custommode'.");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
|
|
Loading…
Reference in New Issue