Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement additive inheritance. Fix a bug in multiple inheritance imp…
…lementation. * lib/Nagios/Object.pm (_set): Register additive attributes in the {_additive} hash. (_make_method) <get>: Implement additive inheritance. * t/additive_inheritance.cfg: New test config. * t/additive_inheritance.t: New testcase. * lib/Nagios/Template.pm (AUTOLOAD): Don't croak on undefined, but valid attributes. Return undef as expected. * t/multipletemplates.cfg: Add a sample of multiple additive inheritance. * t/multipletemplates.t: Check for the proper return of undefined attribute and for working multiple additive inheritance.
- Loading branch information
1 parent
e067fa9
commit bf5de4d
Showing
6 changed files
with
93 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# An example of additive inheritance from | ||
# https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/objectinheritance.html#add_string | ||
# | ||
define host { | ||
name generichosttemplate | ||
hostgroups all-servers | ||
register 0 | ||
} | ||
|
||
define host { | ||
host_name linuxserver1 | ||
hostgroups +linux-servers,web-servers | ||
use generichosttemplate | ||
} | ||
|
||
# The effective value of hostgroups in linuxserver1 is | ||
# all-servers,linux-servers,web-servers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/perl -w | ||
|
||
use strict; | ||
use Test::More qw(no_plan); | ||
use Test::NoWarnings; | ||
use lib qw( ../lib ./lib ); | ||
use Data::Dumper; | ||
|
||
$Data::Dumper::Terse = 1; | ||
$Data::Dumper::Indent = 0; | ||
|
||
eval { chdir('t') }; | ||
|
||
use Nagios::Config; | ||
|
||
my $config = Nagios::Object::Config->new(); | ||
$config->parse('additive_inheritance.cfg'); | ||
|
||
my $host = $config->find_object('linuxserver1','Nagios::Host'); | ||
is(Dumper([$host->hostgroups]),q{[['all-servers','linux-servers','web-servers']]}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters