diff --git a/debian/control b/debian/control index 426c34d6..cef44dcb 100644 --- a/debian/control +++ b/debian/control @@ -35,6 +35,7 @@ Depends: etckeeper, libdata-validate-ip-perl, libdbd-mysql-perl, libdbi-perl, + libdpkg-perl, libhash-merge-perl, libio-interface-perl, libipc-system-simple-perl, diff --git a/lib/get_ngcp_type b/lib/get_ngcp_type new file mode 100644 index 00000000..5671beca --- /dev/null +++ b/lib/get_ngcp_type @@ -0,0 +1,29 @@ +[% + # Returns the ngcp_type of the node calling this function. + # + # @return out one of ['spce', 'sppro', 'carrier'] +-%] +[% PERL -%] +use Dpkg; +use Dpkg::Index; +use Dpkg::Control::Types; + +my $status = Dpkg::Index->new(type => CTRL_INFO_PKG); +$status->load("$Dpkg::ADMINDIR/status"); + +my $pkg = $status->get_by_key('ngcp-ngcp-ce'); +if ($pkg->{Status} =~ m/\s+ok\s+installed$/) { + $stash->set(out => 'spce'); + return; +} +$pkg = $status->get_by_key('ngcp-ngcp-pro'); +if ($pkg->{Status} =~ m/\s+ok\s+installed$/) { + $stash->set(out => 'sppro'); + return; +} +$pkg = $status->get_by_key('ngcp-ngcp-carrier'); +if ($pkg->{Status} =~ m/\s+ok\s+installed$/) { + $stash->set(out => 'carrier'); + return; +} +[% END -%]