MT#16637 get_ngcp_type helper

Detect NGCP installation using dpkg status

Change-Id: I38e9e0d24eed3ecf12d9b95f65c13dacecccf8fa
changes/31/3531/8
Victor Seva 10 years ago
parent 301cb7cd3c
commit 95051acb23

1
debian/control vendored

@ -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,

@ -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 -%]
Loading…
Cancel
Save