MT#55472 NGCP::Template::Object: Add get_supported_roles() method

Change-Id: Ib2e82ea16d537fd2068cd880f8d49fb3d8e9661b
mr11.2
ngcp-config 3 years ago
parent 046cab57a3
commit 54b75c6ba9

@ -28,6 +28,20 @@ sub get_online_cpus
return $nproc // 1;
}
sub get_supported_roles
{
return [ qw(
db
lb
li
li_dist
mgmt
proxy
rtp
storage
) ];
}
sub has_role
{
my ($self, $hostname, $role) = @_;
@ -344,6 +358,10 @@ Returns the number of online CPUs on the system.
This can be used to compute values in templates that depend on the amount
of cores.
=item $bool = $t->get_supported_roles()
Returns the list of roles supported by NGCP.
=item $bool = $t->has_role($hostname, $role)
Checks whether the $hostname node has the $role.

@ -6,7 +6,7 @@ use warnings;
use Cwd;
use Test::More;
plan tests => 48;
plan tests => 49;
use_ok('NGCP::Template::Object');
@ -87,6 +87,20 @@ my $obj_carrier = NGCP::Template::Object->new($cfg_carrier);
is($obj_ce->get_online_cpus(), 8, 'number of online processors');
}
# Check get_supported_roles()
is_deeply($obj_ce->get_supported_roles(),
[ qw(
db
lb
li
li_dist
mgmt
proxy
rtp
storage
) ],
'list of supported roles');
# Check has_role().
ok(!$obj_ce->has_role('non-existent', 'storage'),
'host unknown has storage role');

Loading…
Cancel
Save