Skip to content

Commit

Permalink
Ctor 146 escalation microsoft hyperv 2012 add option for powershell m…
Browse files Browse the repository at this point in the history
…odule version in node integration service mode (centreon#5080)
  • Loading branch information
omercier authored Jul 1, 2024
1 parent 5ff0fd9 commit eca3644
Show file tree
Hide file tree
Showing 7 changed files with 489 additions and 13 deletions.
7 changes: 4 additions & 3 deletions .github/scripts/pod_spell_check.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use Test::More;
use Test::Spelling;

if (!@ARGV) {
die "Missing perl file to check.";
die "Usage: perl pod_spell_check.t module.pm stopwords.t";
}

my $stopword_filename='tests/resources/spellcheck/stopwords.t';
Expand All @@ -14,9 +14,10 @@ if(defined($ARGV[1])){
}
open(FILE, "<", $stopword_filename)
or die "Could not open $stopword_filename";
printf("stopword file use : ".$stopword_filename." \n");
printf("Using dictionary: ".$stopword_filename." \n");

add_stopwords(<FILE>);
close(FILE);
set_spell_cmd('hunspell -l');
all_pod_files_spelling_ok($ARGV[0]);
close(FILE);

Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,20 @@ sub check_options {
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
}

sub determine_operational_status {
my ($operational_status) = @_;

if ( defined($operational_status) ) {
if ( defined($node_vm_integration_service_operational_status->{ $operational_status}) ) {
return $node_vm_integration_service_operational_status->{ $operational_status };
} else {
return $operational_status;
}
} else {
return '-';
}
}

sub manage_selection {
my ($self, %options) = @_;

Expand Down Expand Up @@ -235,16 +249,13 @@ sub manage_selection {
my $services = (ref($node->{services}) eq 'ARRAY') ? $node->{services} : [ $node->{services} ];

foreach my $service (@$services) {

$self->{vm}->{$id}->{service}->{$id2} = {
vm => $node->{name},
service => $service->{service},
enabled => $service->{enabled} =~ /True|1/i ? 1 : 0,
primary_status =>
defined($service->{primary_operational_status}) && defined($node_vm_integration_service_operational_status->{ $service->{primary_operational_status} }) ?
$node_vm_integration_service_operational_status->{ $service->{primary_operational_status} } : '-',
secondary_status =>
defined($service->{secondary_operational_status}) && defined($node_vm_integration_service_operational_status->{ $service->{secondary_operational_status} }) ?
$node_vm_integration_service_operational_status->{ $service->{secondary_operational_status} } : '-'
primary_status => determine_operational_status($service->{primary_operational_status}),
secondary_status => determine_operational_status($service->{secondary_operational_status})
};
$id2++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/apps/trendmicro/iwsva/snmp/plugin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ __END__
=head1 PLUGIN DESCRIPTION
Check TendMicro Iwsva equipments in SNMP.
Check TrendMicro Iwsva equipments in SNMP.
=cut
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ $culture = new-object "System.Globalization.CultureInfo" "en-us"
$ps .= centreon::common::powershell::functions::escape_jsonstring(%options);
$ps .= centreon::common::powershell::functions::convert_to_json(%options);

# if the version of HyperV Powershell module is higher than 2.0.0 and not compatible with
# the following script, then use this Import-Module instead:
# Import-Module -Name "Hyper-V" -MaximumVersion "2.0.0"
$ps .= '
$ProgressPreference = "SilentlyContinue"
Expand Down Expand Up @@ -68,8 +71,19 @@ Try {
$item_service.service = $service.Name
$item_service.enabled = $service.Enabled
# this works for sure on v1.1 of HyperV Powershell module
$item_service.primary_operational_status = $service.PrimaryOperationalStatus.value__
$item_service.secondary_operational_status = $service.SecondaryOperationalStatus.value__
# this works for sure on v2.0.0 of HyperV Powershell module
if (($service.PrimaryStatusDescription -ne $null) -and ($service.PrimaryStatusDescription -ne "")) {
$item_service.primary_operational_status = $service.PrimaryStatusDescription
}
if (($service.SecondaryStatusDescription -ne $null) -and ($service.SecondaryStatusDescription -ne "")) {
$item_service.secondary_operational_status = $service.SecondaryStatusDescription
}
$services.Add($item_service)
}
Expand All @@ -96,6 +110,6 @@ __END__
=head1 DESCRIPTION
Method to get hyper-v informations.
Method to get Hyper-V information.
=cut
10 changes: 8 additions & 2 deletions tests/resources/spellcheck/stopwords.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
--exclude-fs
--filter-fs
--filter-vdom
--filter-vm
--force-counters32
--force-counters64
--force-oid
Expand All @@ -37,6 +38,9 @@
--oid-filter
--urlpath
--warning-bytesallocatedpercentage
-EncodedCommand
-InputFormat
-NoLogo
2c
ADSL
Avigilon
Expand Down Expand Up @@ -64,10 +68,11 @@ SSH
Sansymphony
SureBackup
TCP
TendMicro
TrendMicro
VDSL2
VPN
VM
Veeam
VPN
WSMAN
XPath
api.meraki.com
Expand Down Expand Up @@ -95,6 +100,7 @@ out-mcast
out-ucast
perfdata
powershell
powershell.exe
proto
psu
queue-messages-inflighted
Expand Down
Loading

0 comments on commit eca3644

Please sign in to comment.