From be3573332b4bf4178823c9ca07c6de0a95436caf Mon Sep 17 00:00:00 2001 From: Alexander Lutay Date: Thu, 5 Jan 2017 13:58:32 +0100 Subject: [PATCH] TT#8760 Add a ngcpcfg helper get_ngcp_version for the future usage There are currently several places in templates where we do request ngcp version, lets create a helper here, then we will be able to switch on it after the next LTS is released (mr5.5). Unfortunately we cannot switch on it before the next LTS, otherwise upgrade mr4.4->mr5.5 may be corrupted by users. If sp1 has been upgraded already and sp2 is not while sp2 has received new templates already while ngcpcfg package is still old -> templates cannot be built as helper is not found. Change-Id: Icce966097335eddb7b09303ac2ef8081092bb8f3 --- lib/get_ngcp_version | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/get_ngcp_version diff --git a/lib/get_ngcp_version b/lib/get_ngcp_version new file mode 100644 index 00000000..b6c56e5a --- /dev/null +++ b/lib/get_ngcp_version @@ -0,0 +1,19 @@ +[% + # Returns the ngcp_version of the node calling this function. + # + # @return out one of ['spce', 'sppro', 'carrier'] +-%] +[% 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 -%]