add case insensitive system
This commit is contained in:
parent
457d99d25a
commit
668f6c03c3
|
@ -1,3 +1,8 @@
|
|||
2019-01-06 Quentin Garnier <qgarnier@centreon.com> - 3.0.0
|
||||
* Enhancement: checking intelligence is moved in centreon-plugins
|
||||
* Enhancement: autonomous daemon - remove dependency with centreon-plugins-base and perl centreon base library
|
||||
* Enhancement: update debian doc
|
||||
|
||||
2017-05-31 Quentin Garnier <qgarnier@centreon.com> - 2.4.0
|
||||
* Enhance: Use ZMQ4 library
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$self->{logger} = $options{logger};
|
||||
$self->{case_insensitive} = defined($options{case_insensitive}) ? $options{case_insensitive} : 0;
|
||||
$self->{global_case_insensitive} = defined($options{case_insensitive}) ? $options{case_insensitive} : 0;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
@ -75,6 +75,10 @@ sub initArgs {
|
|||
$self->{$_} = $options{arguments}->{$_};
|
||||
}
|
||||
centreon::vmware::common::init_response(identity => $options{arguments}->{identity});
|
||||
|
||||
if ($self->{global_case_insensitive} == 0 && defined($self->{case_insensitive})) {
|
||||
$self->{global_case_insensitive} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
sub build_filter {
|
||||
|
@ -82,7 +86,7 @@ sub build_filter {
|
|||
|
||||
my $filters = {};
|
||||
if (defined($self->{$options{search_option}}) && !defined($self->{$options{is_regexp}})) {
|
||||
if ($self->{case_insensitive} == 1) {
|
||||
if ($self->{global_case_insensitive} == 1) {
|
||||
$filters->{name} = qr/^\Q$self->{$options{search_option}}\E$/i;
|
||||
} else {
|
||||
$filters->{name} = qr/^\Q$self->{$options{search_option}}\E$/;
|
||||
|
@ -100,4 +104,16 @@ sub build_filter {
|
|||
return $filters;
|
||||
}
|
||||
|
||||
sub add_filter {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($self->{$options{search_option}}) && $self->{$options{search_option}} ne '') {
|
||||
if ($self->{global_case_insensitive} == 1) {
|
||||
$options{filters}->{$options{label}} = qr/$self->{$options{search_option}}/i;
|
||||
} else {
|
||||
$options{filters}->{$options{label}} = qr/$self->{$options{search_option}}/;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -54,9 +54,8 @@ sub run {
|
|||
}
|
||||
|
||||
my $filters = $self->build_filter(label => 'name', search_option => 'vm_hostname', is_regexp => 'filter');
|
||||
if (defined($self->{filter_description}) && $self->{filter_description} ne '') {
|
||||
$filters->{'config.annotation'} = qr/$self->{filter_description}/;
|
||||
}
|
||||
$self->add_filter(filters => $filters, label => 'config.annotation', search_option => 'filter_description');
|
||||
$self->add_filter(filters => $filters, label => 'config.guestFullName', search_option => 'filter_os');
|
||||
|
||||
my @properties = ('name', 'runtime.connectionState', 'runtime.powerState');
|
||||
if (defined($self->{display_description})) {
|
||||
|
|
|
@ -60,9 +60,8 @@ sub run {
|
|||
|
||||
my $multiple = 0;
|
||||
my $filters = $self->build_filter(label => 'name', search_option => 'vm_hostname', is_regexp => 'filter');
|
||||
if (defined($self->{filter_description}) && $self->{filter_description} ne '') {
|
||||
$filters->{'config.annotation'} = qr/$self->{filter_description}/;
|
||||
}
|
||||
$self->add_filter(filters => $filters, label => 'config.annotation', search_option => 'filter_description');
|
||||
$self->add_filter(filters => $filters, label => 'config.guestFullName', search_option => 'filter_os');
|
||||
|
||||
my @properties = ('name', 'datastore', 'runtime.connectionState', 'runtime.powerState');
|
||||
if (defined($self->{display_description})) {
|
||||
|
|
|
@ -53,9 +53,8 @@ sub run {
|
|||
}
|
||||
|
||||
my $filters = $self->build_filter(label => 'name', search_option => 'vm_hostname', is_regexp => 'filter');
|
||||
if (defined($self->{filter_description}) && $self->{filter_description} ne '') {
|
||||
$filters->{'config.annotation'} = qr/$self->{filter_description}/;
|
||||
}
|
||||
$self->add_filter(filters => $filters, label => 'config.annotation', search_option => 'filter_description');
|
||||
$self->add_filter(filters => $filters, label => 'config.guestFullName', search_option => 'filter_os');
|
||||
|
||||
my @properties = ('name', 'runtime.connectionState', 'runtime.powerState', 'config.hardware.device');
|
||||
if (defined($self->{display_description})) {
|
||||
|
|
|
@ -49,9 +49,8 @@ sub run {
|
|||
my $self = shift;
|
||||
|
||||
my $filters = $self->build_filter(label => 'name', search_option => 'vm_hostname', is_regexp => 'filter');
|
||||
if (defined($self->{filter_description}) && $self->{filter_description} ne '') {
|
||||
$filters->{'config.annotation'} = qr/$self->{filter_description}/;
|
||||
}
|
||||
$self->add_filter(filters => $filters, label => 'config.annotation', search_option => 'filter_description');
|
||||
$self->add_filter(filters => $filters, label => 'config.guestFullName', search_option => 'filter_os');
|
||||
|
||||
my @properties = ('name', 'runtime.connectionState', 'runtime.powerState', 'config.cpuAllocation.limit', 'config.memoryAllocation.limit');
|
||||
if (defined($self->{check_disk_limit})) {
|
||||
|
|
|
@ -54,9 +54,8 @@ sub run {
|
|||
}
|
||||
|
||||
my $filters = $self->build_filter(label => 'name', search_option => 'vm_hostname', is_regexp => 'filter');
|
||||
if (defined($self->{filter_description}) && $self->{filter_description} ne '') {
|
||||
$filters->{'config.annotation'} = qr/$self->{filter_description}/;
|
||||
}
|
||||
$self->add_filter(filters => $filters, label => 'config.annotation', search_option => 'filter_description');
|
||||
$self->add_filter(filters => $filters, label => 'config.guestFullName', search_option => 'filter_os');
|
||||
|
||||
my @properties = ('name', 'summary.config.memorySizeMB', 'runtime.connectionState', 'runtime.powerState');
|
||||
if (defined($self->{display_description})) {
|
||||
|
|
|
@ -49,9 +49,8 @@ sub run {
|
|||
my $self = shift;
|
||||
|
||||
my $filters = $self->build_filter(label => 'name', search_option => 'vm_hostname', is_regexp => 'filter');
|
||||
if (defined($self->{filter_description}) && $self->{filter_description} ne '') {
|
||||
$filters->{'config.annotation'} = qr/$self->{filter_description}/;
|
||||
}
|
||||
$self->add_filter(filters => $filters, label => 'config.annotation', search_option => 'filter_description');
|
||||
$self->add_filter(filters => $filters, label => 'config.guestFullName', search_option => 'filter_os');
|
||||
|
||||
my @properties = ('snapshot.rootSnapshotList', 'name', 'runtime.connectionState', 'runtime.powerState');
|
||||
if (defined($self->{check_consolidation}) == 1) {
|
||||
|
|
|
@ -49,9 +49,9 @@ sub run {
|
|||
my $self = shift;
|
||||
|
||||
my $filters = $self->build_filter(label => 'name', search_option => 'vm_hostname', is_regexp => 'filter');
|
||||
if (defined($self->{filter_description}) && $self->{filter_description} ne '') {
|
||||
$filters->{'config.annotation'} = qr/$self->{filter_description}/;
|
||||
}
|
||||
$self->add_filter(filters => $filters, label => 'config.annotation', search_option => 'filter_description');
|
||||
$self->add_filter(filters => $filters, label => 'config.guestFullName', search_option => 'filter_os');
|
||||
|
||||
my @properties = ('name', 'summary.overallStatus', 'runtime.connectionState', 'runtime.powerState');
|
||||
if (defined($self->{display_description})) {
|
||||
push @properties, 'config.annotation';
|
||||
|
|
|
@ -54,9 +54,8 @@ sub run {
|
|||
}
|
||||
|
||||
my $filters = $self->build_filter(label => 'name', search_option => 'vm_hostname', is_regexp => 'filter');
|
||||
if (defined($self->{filter_description}) && $self->{filter_description} ne '') {
|
||||
$filters->{'config.annotation'} = qr/$self->{filter_description}/;
|
||||
}
|
||||
$self->add_filter(filters => $filters, label => 'config.annotation', search_option => 'filter_description');
|
||||
$self->add_filter(filters => $filters, label => 'config.guestFullName', search_option => 'filter_os');
|
||||
|
||||
my @properties = ('name', 'runtime.connectionState', 'runtime.powerState');
|
||||
if (defined($self->{display_description})) {
|
||||
|
|
|
@ -49,9 +49,8 @@ sub run {
|
|||
my $self = shift;
|
||||
|
||||
my $filters = $self->build_filter(label => 'name', search_option => 'vm_hostname', is_regexp => 'filter');
|
||||
if (defined($self->{filter_description}) && $self->{filter_description} ne '') {
|
||||
$filters->{'config.annotation'} = qr/$self->{filter_description}/;
|
||||
}
|
||||
$self->add_filter(filters => $filters, label => 'config.annotation', search_option => 'filter_description');
|
||||
$self->add_filter(filters => $filters, label => 'config.guestFullName', search_option => 'filter_os');
|
||||
|
||||
my @properties = ('name', 'config.hardware.device', 'runtime.connectionState', 'runtime.powerState');
|
||||
if (defined($self->{display_description})) {
|
||||
|
|
|
@ -62,9 +62,8 @@ sub run {
|
|||
my $self = shift;
|
||||
|
||||
my $filters = $self->build_filter(label => 'name', search_option => 'vm_hostname', is_regexp => 'filter');
|
||||
if (defined($self->{filter_description}) && $self->{filter_description} ne '') {
|
||||
$filters->{'config.annotation'} = qr/$self->{filter_description}/;
|
||||
}
|
||||
$self->add_filter(filters => $filters, label => 'config.annotation', search_option => 'filter_description');
|
||||
$self->add_filter(filters => $filters, label => 'config.guestFullName', search_option => 'filter_os');
|
||||
|
||||
my @properties = ('name', 'summary.guest.toolsStatus', 'runtime.connectionState', 'runtime.powerState');
|
||||
if (defined($self->{display_description})) {
|
||||
|
|
Loading…
Reference in New Issue