TT#141100 NGCP::Template::Object: Add new get_version method

Base lib/get_ngcp_version on this new method.

Change-Id: I5bb4f1d4d1f50f8490bab41456563d1a1f5204a6
mr10.1
Guillem Jover 4 years ago
parent a9afbc4164
commit 8587969c42

@ -43,6 +43,24 @@ sub has_role
return 0;
}
sub get_version
{
my $self = shift;
my $filename = '/etc/ngcp_upgrade_version';
unless (-e $filename) {
$filename = '/etc/ngcp_version';
}
open my $hh, '<', $filename or die "Error opening $filename";
my $version = <$hh>;
close $hh;
chomp $version;
die "Fatal error retrieving ngcp_version [$version]" unless length $version;
return $version;
}
sub get_hostname
{
my $self = shift;
@ -210,6 +228,10 @@ The $config argument contains the deserialized ngcp-config YAML configuration.
Checks whether the $hostname node has the $role.
=item $version = $t->get_version()
Returns the NGCP version.
=item $hostname = $t->get_hostname()
Returns the hostname of the node calling this function.

@ -4,18 +4,7 @@
# Returns the NGCP version of the node calling this function.
#
# @return out The NGCP version (e.g. 'mr4.5.3' or 'trunk').
-%]
[% PERL -%]
my $filename = '/etc/ngcp_upgrade_version';
unless (-e $filename) {
$filename = '/etc/ngcp_version';
}
open my $hh, '<', $filename or die "Error opening $filename";
my $ngcp_version = <$hh>;
close $hh;
chomp $ngcp_version;
die "Fatal error retrieving ngcp_version [$ngcp_version]" unless length $ngcp_version;
$stash->set(out => $ngcp_version);
return;
[% END -%]
out = ngcp.get_version();
-%]

Loading…
Cancel
Save