From fadbd2d9b0ae42b8f0a5571b50daa18f6a6cd29e Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Mon, 30 Jul 2012 12:16:33 +0000 Subject: [PATCH] Adjust ngcp-ossbss-clients-perl scripts to use new cmd auth data 80% of https://bugtracker.sipwise.com/view.php?id=1835 done From: Michael Prokop --- bin/ngcp-create_subscriber | 21 ++++++++++++++++++--- bin/ngcp-terminate_subscriber | 20 +++++++++++++++++--- 2 files changed, 35 insertions(+), 6 deletions(-) mode change 100644 => 100755 bin/ngcp-create_subscriber diff --git a/bin/ngcp-create_subscriber b/bin/ngcp-create_subscriber old mode 100644 new mode 100755 index 7fd20f1..14c0996 --- a/bin/ngcp-create_subscriber +++ b/bin/ngcp-create_subscriber @@ -3,11 +3,26 @@ use strict; use Getopt::Std; use Sipwise::Provisioning::Billing; +use YAML::Tiny; + +my $yaml = YAML::Tiny->new; +my $inputfile = '/etc/ngcp-config/constants.yml'; +my $password; +my $user = 'cmd'; + +$yaml = YAML::Tiny->read($inputfile) or die "File $inputfile could not be read"; + +unless (my ($user) = grep { $_->{user} eq $user && defined $_->{pass} } @{$yaml->[0]->{ossbss}->{provisioning}->{acl}}) { + die "Error: No password set for user cmd in $inputfile\n"; +} else { + $password = $user->{pass}; +} my %CONFIG = ( - admin => 'administrator', - password => 'administrator', + admin => 'cmd', + password => $password, ); + my %BILLING = ( billing_profile => 'default', # not needed, but may be set if desired @@ -72,7 +87,7 @@ sub call_prov { $result = $bprov->handle_request( $function, { authentication => { - type => 'admin', + type => 'system', username => $CONFIG{admin}, password => $CONFIG{password}, }, diff --git a/bin/ngcp-terminate_subscriber b/bin/ngcp-terminate_subscriber index 37beca1..14eedbd 100755 --- a/bin/ngcp-terminate_subscriber +++ b/bin/ngcp-terminate_subscriber @@ -3,10 +3,24 @@ use strict; use Getopt::Std; use Sipwise::Provisioning::Billing; +use YAML::Tiny; + +my $yaml = YAML::Tiny->new; +my $inputfile = '/etc/ngcp-config/constants.yml'; +my $password; +my $user = 'cmd'; + +$yaml = YAML::Tiny->read($inputfile) or die "File $inputfile could not be read"; + +unless (my ($user) = grep { $_->{user} eq $user && defined $_->{pass} } @{$yaml->[0]->{ossbss}->{provisioning}->{acl}}) { + die "Error: No password set for user cmd in $inputfile\n"; +} else { + $password = $user->{pass}; +} my %CONFIG = ( - admin => 'administrator', - password => 'administrator', + admin => 'cmd', + password => $password, ); sub main; @@ -54,7 +68,7 @@ sub call_prov { $result = $bprov->handle_request( $function, { authentication => { - type => 'admin', + type => 'system', username => $CONFIG{admin}, password => $CONFIG{password}, },