MT#7571 provisioning via REST API step two

* API: fix get_*_preferences URL
* bin/set_preferences.pl:
  - don't use Hash::Merge and implement our merge()
  - fix rewriteruleset preference fieldname
* migrate provisioning:
  - ncos
  - speeddial
  - callforward
  - peering
* enable peer scenarios
  - MT#17185 support rfc3325
* add 'lock' property support for subscriber

Change-Id: I15e9afb744f6f4700dd863bfe226944ea4c3ecf7
changes/49/4249/14
Victor Seva 9 years ago
parent b0e001609b
commit 8fcba2e079

@ -6,13 +6,7 @@ Requeriments:
- A working NGCP
- sip-tester. sipp with ssl enabled ( needed for auth ).
We provide a version backported to wheezy
- python-yaml
- libgraphviz-perl
- libtemplate-perl
- libtext-csv-perl
- ngcp-ossbss-clients-perl
- parallel
- tcpdump
See debian/control for the actual list of dependences
Usage:
------

@ -126,6 +126,8 @@ function create_voip_prefs
if [ -f "${SCEN_CHECK_DIR}/peer.yml" ]; then
echo "$(date) - Creating peers"
"${BIN_DIR}/create_peers.pl" "${SCEN_CHECK_DIR}/peer.yml"
# REMOVE ME!! fix for REST API
ngcp-sercmd proxy lcr.reload
fi
if [ -f "${SCEN_CHECK_DIR}/prefs.json" ]; then
@ -141,12 +143,12 @@ function delete_voip
if [ -f "${SCEN_CHECK_DIR}/peer.yml" ]; then
echo "$(date) - Deleting peers"
"${BIN_DIR}/create_peers.pl" -d "${SCEN_CHECK_DIR}/peer.yml"
"${BIN_DIR}/create_peers.pl" -delete "${SCEN_CHECK_DIR}/peer.yml"
fi
if [ -f "${SCEN_CHECK_DIR}/ncos.yml" ]; then
echo "$(date) - Deleting ncos levels"
"${BIN_DIR}/create_ncos.pl" -d "${SCEN_CHECK_DIR}/ncos.yml"
"${BIN_DIR}/create_ncos.pl" -delete "${SCEN_CHECK_DIR}/ncos.yml"
fi
if [ -f "${SCEN_CHECK_DIR}/rewrite.yml" ]; then
@ -325,9 +327,12 @@ function run_sipp
if [ "${peer_host}" != "" ]; then
echo "$(date) - Update peer_host:${peer_host} ${ip}:${PORT} info"
if ! "${BIN_DIR}/update_peer_host.pl" --ip="${ip}" --port="${PORT}" \
"${peer_host}" "${SCEN_CHECK_DIR}/scenario.yml" ;
"${peer_host}" ;
then
error_helper "$(date) - error updating peer info" 15
else
# REMOVE ME!! fix for REST API
ngcp-sercmd proxy lcr.reload
fi
fi
if [ "${foreign_dom}" == "yes" ]; then

@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# Copyright: 2013 Sipwise Development Team <support@sipwise.com>
# Copyright: 2013-2016 Sipwise Development Team <support@sipwise.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -22,105 +22,119 @@ use strict;
use warnings;
use English;
use Getopt::Std;
use Cwd 'abs_path';
use YAML;
use Getopt::Long;
use Sipwise::Provisioning::Billing;
use Sipwise::Provisioning::Config;
our %CONFIG = ( admin => 'cmd' );
my $config = Sipwise::Provisioning::Config->new()->get_config();
unless ($CONFIG{password} = $config->{acl}->{$CONFIG{admin}}->{password}) {
die "Error: No provisioning password found for user $CONFIG{admin}\n";
use Cwd 'abs_path';
use Config::Tiny;
use Sipwise::API qw(all);
use Data::Dumper;
my $config = Config::Tiny->read('/etc/default/ngcp-api');
my $opts;
if ($config) {
$opts = {};
$opts->{host} = $config->{_}->{NGCP_API_IP};
$opts->{port} = $config->{_}->{NGCP_API_PORT};
$opts->{sslverify} = $config->{_}->{NGCP_API_SSLVERIFY};
}
my $api = Sipwise::API->new($opts);
$opts = $api->opts;
sub usage;
sub call_prov;
sub usage {
return "Usage:\n$PROGRAM_NAME ncos.yml\n".
"Options:\n".
" -delete remove ncos\n".
" -d debug\n".
" -h this help\n";
}
my $help = 0;
my $del = 0;
GetOptions ("h|help" => \$help,
"d|delete" => \$del)
or die("Error in command line arguments\n".usage());
my $del;
GetOptions(
"h|help" => \$help,
"d|debug" => \$opts->{verbose},
"delete" => \$del
) or die("Error in command line arguments\n".usage());
die(usage()) unless (!$help);
die("Wrong number of arguments\n".usage()) unless ($#ARGV == 0);
our $bprov = Sipwise::Provisioning::Billing->new();
die("Error: wrong number of arguments\n".usage()) unless ($#ARGV == 0);
my $filename = abs_path($ARGV[0]);
my $r = YAML::LoadFile($filename);
if ($del)
sub manage_ncons
{
do_delete($r);
my $data = shift;
my $param = {
level => $data->{level},
reseller_id => $data->{reseller_id}
};
my $id = $api->check_ncoslevel_exists($param);
if($id) {
$data->{id} = $id;
print "ncos [$data->{level}] already there [$id]\n";
} else {
$data->{id} = $api->create_ncoslevel($data);
print "ncos [$data->{level}]: created [$data->{id}]\n";
}
return;
}
else
sub manage_ncons_patterns
{
do_create($r);
my $data = shift;
my $ncos_id = shift;
foreach my $pattern (@{$data}) {
$pattern->{ncos_level_id} = $ncos_id;
my $id = $api->check_ncospattern_exists($pattern);
if($id) {
print "ncos_pattern [$pattern->{description}] already there [$id]\n";
} else {
$pattern->{id} = $api->create_ncospattern($pattern);
print "ncos_pattern [$pattern->{description}]: created [$pattern->{id}]\n";
}
}
return;
}
sub do_delete
{
my ($data) = @_;
my $result = call_prov( $bprov, 'get_ncos_levels');
foreach (@{$result})
{
if (exists($data->{$_->{level}}))
{
call_prov($bprov, 'delete_ncos_level', { level => $_->{level}});
}
my ($data) = @_;
foreach (keys %{$data})
{
my $ncos = $data->{$_}->{data};
my $param = {
level => $_,
reseller_id => $ncos->{reseller_id}
};
my $id = $api->check_ncoslevel_exists($param);
if($id) {
if($api->delete_ncoslevel($id)) {
print "ncos: deleted [$param->{level}]\n";
} else {
die("Error: ncos: can't delete [$param->{level}]");
}
} else {
print "ncos: already gone [$param->{level}]\n";
}
exit;
}
exit;
}
sub do_create
{
my ($data) = @_;
for (keys $data)
{
my $ncos = $data->{$_};
# level
my $param = { level => $_, data => $ncos->{data} };
call_prov( $bprov, 'create_ncos_level', $param );
# patterns
$param = { level => $_, patterns => $ncos->{patterns}, purge_existing => 1};
call_prov( $bprov, 'set_ncos_pattern_list', $param );
}
exit;
my ($data) = @_;
foreach (keys %{$data})
{
my $ncos = $data->{$_}->{data};
$ncos->{level} = $_;
manage_ncons($ncos);
manage_ncons_patterns($data->{$_}->{patterns}, $ncos->{id});
}
exit;
}
sub call_prov {
# scalar, scalar, hash-ref
my ($prov, $function, $parameter) = @_;
my $result;
eval {
$result = $prov->handle_request( $function,
{
authentication => {
type => 'system',
username => $CONFIG{admin},
password => $CONFIG{password},
},
parameters => $parameter,
});
};
if($EVAL_ERROR) {
if(ref $EVAL_ERROR eq 'SOAP::Fault') {
die "Voip\::$function failed: ". $EVAL_ERROR->faultstring;
} else {
die "Voip\::$function failed: $EVAL_ERROR";
}
}
return $result;
my $r = YAML::LoadFile(abs_path($ARGV[0]));
if ($del) {
do_delete($r);
}
sub usage {
return "Usage:\n$PROGRAM_NAME ncos.yml\n";
else {
do_create($r);
}

@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# Copyright: 2013 Sipwise Development Team <support@sipwise.com>
# Copyright: 2013-2016 Sipwise Development Team <support@sipwise.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -21,169 +21,192 @@
use strict;
use warnings;
die("Not implemented in REST");
use English;
use Getopt::Std;
use Getopt::Long;
use Cwd 'abs_path';
use Config::Tiny;
use Sipwise::API qw(all);
use YAML;
use Getopt::Long;
use Sipwise::Provisioning::Voip;
use Sipwise::Provisioning::Billing;
use Sipwise::Provisioning::Config;
our %CONFIG = ( admin => 'cmd' );
my $config = Sipwise::Provisioning::Config->new()->get_config();
unless ($CONFIG{password} = $config->{acl}->{$CONFIG{admin}}->{password}) {
die "Error: No provisioning password found for user $CONFIG{admin}\n";
my $config = Config::Tiny->read('/etc/default/ngcp-api');
my $opts;
if ($config) {
$opts = {};
$opts->{host} = $config->{_}->{NGCP_API_IP};
$opts->{port} = $config->{_}->{NGCP_API_PORT};
$opts->{sslverify} = $config->{_}->{NGCP_API_SSLVERIFY};
}
my $api = Sipwise::API->new($opts);
$opts = $api->opts;
my $del;
sub usage;
sub call_prov;
sub usage {
return "Usage:\n$PROGRAM_NAME peer.yml\n".
"Options:\n".
" -delete\n".
" -d debug\n".
" -h this help\n";
}
my $help = 0;
my $del = 0;
GetOptions ("h|help" => \$help,
"d|delete" => \$del)
or die("Error in command line arguments\n".usage());
"d|debug" => \$opts->{verbose},
"delete" => \$del)
or die("Error in command line arguments\n".usage());
die(usage()) unless (!$help);
die("Wrong number of arguments\n".usage()) unless ($#ARGV == 0);
die("Error: wrong number of arguments\n".usage()) unless ($#ARGV == 0);
our $bprov = Sipwise::Provisioning::Billing->new();
our $vprov = Sipwise::Provisioning::Voip->new();
sub manage_contact
{
my $contact = shift;
my $type = shift;
$contact->{id} = $api->check_contact_exists($contact, $type);
if(defined $contact->{id}) {
print "contact_$type [$contact->{email}] already there [$contact->{id}]\n";
} else {
$contact->{id} = $api->create_contact($contact, $type);
print "contact_$type [$contact->{email}]: created [$contact->{id}]\n";
}
return;
}
if ($del)
sub manage_contract
{
do_delete();
my $contract = shift;
if(defined $contract->{contact_id})
{
$contract->{id} = $api->check_contract_exists($contract);
if(defined $contract->{id}) {
print "contract: already there [$contract->{id}]\n";
} else {
$contract->{id} = $api->create_contract($contract);
print "contract : created [$contract->{id}]\n";
}
}
else {
die("Error: contract: No contact_id");
}
return;
}
else
sub manage_groups
{
do_create();
my $data = shift;
foreach my $group (@{$data})
{
$group->{id} = $api->check_peeringgroup_exists($group);
if(defined $group->{id}) {
print "peer_group: already there [$group->{id}]\n";
} else {
$group->{id} = $api->create_peeringgroup($group);
print "peer_group: created [$group->{id}]\n";
}
}
return;
}
sub do_delete
sub manage_rules
{
my $filename = abs_path($ARGV[0]);
my $r = YAML::LoadFile($filename);
for (keys $r)
{
my $peer_name = $_;
my $peer = $r->{$peer_name};
# groups
my $group = {};
my $result = call_prov( $vprov, 'get_peer_groups');
foreach (@{$result})
{
$group->{$_->{name}} = $_->{id};
}
foreach (@{$peer->{groups}})
{
if (exists($group->{$_->{name}}))
{
call_prov($vprov, 'delete_peer_group', {id => $group->{$_->{name}}});
}
}
# contracts
$result = call_prov( $bprov, 'get_sip_peering_contracts');
foreach (@{$result})
{
my $contact = $_->{contact};
if(defined($contact->{company}))
{
if ($contact->{company} eq $peer_name)
{
call_prov($bprov, 'delete_sip_peering_contract', { id => $_->{id}});
}
}
}
my $data = shift;
foreach my $rule (@{$data})
{
$rule->{id} = $api->check_peeringrule_exists($rule);
if(defined $rule->{id}) {
print "rule: already there [$rule->{id}]\n";
} else {
$rule->{id} = $api->create_peeringrule($rule);
print "rule: created [$rule->{id}]\n";
}
exit;
}
return;
}
sub do_create {
my $filename = abs_path($ARGV[0]);
my $r = YAML::LoadFile($filename);
for (keys $r)
{
my $peer = $r->{$_};
# contract
my $param = { data => $peer->{contract} };
my $contract_id = call_prov( $bprov, 'create_sip_peering_contract', $param );
# groups
my $group = {}; # name = id
foreach (@{$peer->{groups}})
{
$_->{peering_contract_id} = $contract_id;
call_prov( $vprov, 'create_peer_group', $_ );
}
my $result = call_prov( $vprov, 'get_peer_groups');
foreach (@{$result})
{
$group->{$_->{name}}->{id} = $_->{id};
}
# rules
foreach (@{$peer->{rules}})
{
$_->{group_id} = $group->{$_->{group_id}}->{id};
call_prov($vprov, 'create_peer_rule', $_);
}
# hosts
my $host = {};
foreach (@{$peer->{hosts}})
{
$host->{$_->{data}->{name}} = { preferences => delete $_->{preferences}};
$_->{group_id} = $group->{$_->{group_id}}->{id};
call_prov($vprov, 'create_peer_host', $_);
}
foreach (keys $group)
{
my $result = call_prov( $vprov, 'get_peer_group_details', {id=>$group->{$_}->{id}});
foreach (@{$result->{peers}})
{
if(exists($host->{$_->{name}}))
{
$param = { id => $_->{id}, preferences => $host->{$_->{name}}->{preferences}};
call_prov($vprov, 'set_peer_preferences', $param);
}
}
}
sub manage_hosts
{
my $data = shift;
foreach my $host (@{$data})
{
my $param = {name => $host->{name}, contract_id => $host->{contract_id}};
$host->{id} = $api->check_peeringserver_exists($param);
if(defined $host->{id}) {
print "peer: $host->{name} already there [$host->{id}]\n";
} else {
$host->{id} = $api->create_peeringserver($host);
print "peer: $host->{name} created [$host->{id}]\n";
}
exit;
}
return;
}
sub call_prov {
# scalar, scalar, hash-ref
my ($prov, $function, $parameter) = @_;
my $result;
eval {
$result = $prov->handle_request( $function,
{
authentication => {
type => 'system',
username => $CONFIG{admin},
password => $CONFIG{password},
},
parameters => $parameter,
});
};
if($EVAL_ERROR) {
if(ref $EVAL_ERROR eq 'SOAP::Fault') {
die "Voip\::$function failed: ". $EVAL_ERROR->faultstring;
sub do_delete
{
my $r = shift;
foreach (keys %{$r})
{
my $peer = $r->{$_};
$peer->{contact}->{id} = $api->check_contact_exists($peer->{contact},'system');
my $contract_id = $api->check_contract_exists($peer->{contract});
foreach my $group (@{$peer->{groups}}) {
$group->{contract_id} = $contract_id;
$group->{id} = $api->check_peeringgroup_exists($group);
if(defined $group->{id}) {
if($api->delete_peeringgroup($group->{id})) {
print "peer_group: deleted [$group->{name}]\n";
} else {
die "Voip\::$function failed: $EVAL_ERROR";
die("Error: peer_group: can't delete [$group->{name}]");
}
} else {
print "peer_group: already gone [$group->{name}]\n";
}
}
}
return;
}
return $result;
sub do_create {
my $r = shift;
foreach (keys %{$r})
{
print "processing $_\n";
my $peer = $r->{$_};
manage_contact($peer->{contact}, 'system');
$peer->{contract}->{contact_id} = $peer->{contact}->{id};
manage_contract($peer->{contract});
my $group = {};
foreach (@{$peer->{groups}}) {
$_->{contract_id} = $peer->{contract}->{id};
$group->{$_->{name}} = $_;
}
manage_groups($peer->{groups});
foreach (@{$peer->{rules}}) {
$_->{group_id} = $group->{$_->{group_id}}->{id};
}
manage_rules($peer->{rules});
foreach (@{$peer->{hosts}}) {
$_->{group_id} = $group->{$_->{group_id}}->{id};
}
manage_hosts($peer->{hosts});
}
exit;
}
sub usage {
return "Usage:\n$PROGRAM_NAME peer.yml\n";
sub main {
my $r = shift;
if ($del) {
print "delete peers\n" unless $opts->{debug};
return do_delete($r);
} else {
print "create peers\n" unless $opts->{debug};
return do_create($r);
}
}
main(YAML::LoadFile(abs_path($ARGV[0])));

@ -54,7 +54,7 @@ GetOptions ("h|help" => \$help,
or die("Error in command line arguments\n".usage());
die(usage()) unless (!$help);
die("Wrong number of arguments\n".usage()) unless ($#ARGV == 0);
die("Error: Wrong number of arguments\n".usage()) unless ($#ARGV == 0);
sub do_delete
{
@ -68,7 +68,7 @@ sub do_delete
print "rewriteruleset [$rule_set_name] deleted [$rws_id]\n";
}
else {
die "rewriteruleset [$rule_set_name] can't be removed [$rws_id]\n";
die "Error: rewriteruleset [$rule_set_name] can't be removed [$rws_id]\n";
}
} else {
print "rewriteruleset [$rule_set_name] not there\n";
@ -99,7 +99,7 @@ sub do_create
"] created [$rw_id]\n";
}
else {
die "Can't create rewriterule"
die "Error: Can't create rewriterule"
}
}
}

@ -66,6 +66,7 @@ sub get_data {
ac => $val->{ac},
sn => $val->{sn}
},
lock => $val->{lock},
};
my @aliases = ();
foreach (@{$val->{alias_numbers}}) {
@ -175,8 +176,8 @@ sub main
$s->{username} = $username;
$s->{domain_id} = $data->{domains}->{$domain}->{domain_id};
$s->{customer_id} = $data->{customers}->{$s->{customer}}->{customer_id};
$api->create_subscriber(get_data($s));
print("$username\@$domain created\n");
my $id = $api->create_subscriber(get_data($s));
print("$username\@$domain created [$id]\n");
}
}
return;

@ -27,7 +27,7 @@ use Getopt::Long;
use List::MoreUtils qw{ none };
use Config::Tiny;
use Sipwise::API qw(all);
use Hash::Merge qw( merge );
use Storable 'dclone';
use Data::Dumper;
my $config = Config::Tiny->read('/etc/default/ngcp-api');
@ -52,7 +52,19 @@ GetOptions ("h|help" => \$help, "d|debug" => \$opts->{verbose})
or die("Error in command line arguments\n".usage());
die(usage()) unless (!$help);
die("Wrong number of arguments\n".usage()) unless ($#ARGV == 0);
die("Error: wrong number of arguments\n".usage()) unless ($#ARGV == 0);
sub merge
{
my $a = shift;
my $b = shift;
my $result = dclone($a);
for my $key (keys %{$b}) {
$result->{$key} = $b->{$key} unless(exists $a->{$key});
}
return $result;
}
sub set_subscriber_preferences
{
@ -60,23 +72,29 @@ sub set_subscriber_preferences
my $domain = shift;
my $prefs = shift;
my $subs_id = $api->check_subscriber_exists({
'domain'=>$domain,
'username'=>$subscriber});
if(defined $subs_id) {
domain => $domain,
username => $subscriber});
if($subs_id) {
my $subs_prefs = $api->get_subscriber_preferences($subs_id);
delete $subs_prefs->{_links};
my $subs_prefs_id = $subs_prefs->{id};
my $merged_prefs = merge($prefs, $subs_prefs);
my $res = $api->set_subscriber_preferences($subs_prefs_id,
merge($prefs, $subs_prefs));
$merged_prefs);
if($opts->{verbose}) {
print Dumper $prefs;
print Dumper $subs_prefs;
print Dumper $merged_prefs;
print Dumper $res;
}
if(defined $res) {
if($res) {
print "prefs created for ${subscriber}\@${domain}\n";
} else {
die("Error: pref failed for ${subscriber}\@${domain}");
}
}
else {
die("No subscriber ${subscriber}\@${domain} found");
die("Error: No subscriber ${subscriber}\@${domain} found");
}
return;
}
@ -85,42 +103,60 @@ sub set_domain_preferences
{
my $domain = shift;
my $prefs = shift;
my $domain_id = $api->check_domain_exists({'domain' => $domain});
my $domain_id = $api->check_domain_exists({ domain => $domain });
if(defined $domain_id) {
if($domain_id) {
my $dom_prefs = $api->get_domain_preferences($domain_id);
my $links = delete $dom_prefs->{_links};
delete $dom_prefs->{_links};
my $dom_prefs_id = $dom_prefs->{id};
my $merged_prefs = merge($prefs, $dom_prefs);
my $res = $api->set_domain_preferences($dom_prefs_id,
merge($prefs, $dom_prefs));
$merged_prefs);
if($opts->{verbose}) {
print Dumper $prefs;
print Dumper $dom_prefs;
print Dumper $merged_prefs;
print Dumper $res;
}
if(defined $res) {
if($res) {
print "prefs created for ${domain}\n";
} else {
die("Error: pref failed for ${domain}");
}
}
else {
die("No domain ${domain} found");
die("Error: No domain ${domain} found");
}
return;
}
sub set_peer_preferences
{
my $id = shift;
my $name = shift;
my $prefs = shift;
my $peer_id = $api->check_peer_exists($id);
my $peer_id = $api->check_peeringserver_exists({ name => $name });
if(defined $peer_id) {
my $peer_prefs = $api->get_peer_preferences($peer_id);
if($peer_id) {
my $peer_prefs = $api->get_peeringserver_preferences($peer_id);
delete $peer_prefs->{_links};
my $peer_prefs_id = $peer_prefs->{id};
return $api->set_peer_preferences($peer_prefs_id,
merge($prefs, $peer_prefs));
my $merged_prefs = merge($prefs, $peer_prefs);
my $res = $api->set_peeringserver_preferences($peer_prefs_id,
$merged_prefs);
if($opts->{verbose}) {
print Dumper($prefs);
print Dumper($peer_prefs);
print Dumper($merged_prefs);
print Dumper($res);
}
if($res) {
print "prefs created for ${name}\n";
} else {
die("Error: pref failed for ${name}");
}
}
else {
die("No peer ${id} found");
die("Error: No peer ${name} found");
}
return;
}
@ -132,38 +168,29 @@ sub main {
for my $key (keys %{$prefs})
{
print "processing $key\n";
if (exists($prefs->{$key}->{rewrite_rule_set}))
{
my $rule_set_id = $api->check_rewriterule_exists(
$prefs->{$key}->{rewrite_rule_set});
if (defined $rule_set_id)
{
$prefs->{$key}->{rewrite_rule_set} = $rule_set->{$prefs->{$key}->{rewrite_rule_set}};
}
else
{
die("No rewrite_rule_set:$prefs->{$key}->{rewrite_rule_set} found");
my $param = { reseller_id => 1,
name => $prefs->{$key}->{rewrite_rule_set} };
my $rule_set_id = $api->check_rewriteruleset_exists($param);
if (defined $rule_set_id) {
$prefs->{$key}->{rewriteruleset_id} = $rule_set_id;
} else {
die("Error: No rewrite_rule_set:$prefs->{$key}->{rewrite_rule_set} found");
}
}
if ( $key =~ /@/ )
{
if ( $key =~ /@/ ) {
my @fields = split /@/, $key;
if (!$fields[0])
{
if (!$fields[0]) {
set_domain_preferences($fields[1], $prefs->{$key});
}
else
{
} else {
set_subscriber_preferences($fields[0], $fields[1], $prefs->{$key});
}
}
else
{
#set_peer_preferences($key, $prefs->{$key});
die "API peer preferences *Not* implemented";
} else {
set_peer_preferences($key, $prefs->{$key});
}
}
exit;
}
@ -171,7 +198,7 @@ sub get_json {
my $filename = shift;
my $json_text = do {
open(my $json_fh, "<:encoding(UTF-8)", $filename)
or die("Can't open \$filename\": $ERRNO\n");
or die("Error: Can't open \$filename\": $ERRNO\n");
undef $RS; # enable "slurp" mode
<$json_fh>
};

@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# Copyright: 2013 Sipwise Development Team <support@sipwise.com>
# Copyright: 2013-2016 Sipwise Development Team <support@sipwise.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -22,115 +22,102 @@ use strict;
use warnings;
use English;
use Getopt::Std;
use Cwd 'abs_path';
use YAML;
use Sipwise::Provisioning::Voip;
use Sipwise::Provisioning::Config;
our %CONFIG = ( admin => 'cmd' );
my $config = Sipwise::Provisioning::Config->new()->get_config();
use Getopt::Long;
use Cwd 'abs_path';
use Config::Tiny;
use Sipwise::API qw(all);
use Data::Dumper;
unless ($CONFIG{password} = $config->{acl}->{$CONFIG{admin}}->{password}) {
die "Error: No provisioning password found for user $CONFIG{admin}\n";
my $config = Config::Tiny->read('/etc/default/ngcp-api');
my $opts;
if ($config) {
$opts = {};
$opts->{host} = $config->{_}->{NGCP_API_IP};
$opts->{port} = $config->{_}->{NGCP_API_PORT};
$opts->{sslverify} = $config->{_}->{NGCP_API_SSLVERIFY};
}
my $api = Sipwise::API->new($opts);
$opts = $api->opts;
sub main;
sub usage;
sub call_prov;
sub usage {
return "Usage:\n$PROGRAM_NAME callforward.yml\n".
"Options:\n".
" -d debug\n".
" -h this help\n";
}
my $help = 0;
GetOptions(
"h|help" => \$help,
"d|debug" => \$opts->{verbose}
) or die("Error in command line arguments\n".usage());
die usage() unless ($#ARGV == 0);
die(usage()) unless (!$help);
die("Wrong number of arguments\n".usage()) unless ($#ARGV == 0);
my $bprov = Sipwise::Provisioning::Voip->new();
sub set_subscriber_callforward
{
my $subscriber = shift;
my $domain = shift;
my $prefs = shift;
my $subs_id = $api->check_subscriber_exists({
domain => $domain,
username => $subscriber});
if($subs_id) {
my $res = $api->set_subscriber_callforward($subs_id, $prefs);
if($opts->{verbose}) {
print Dumper $res;
}
if($res) {
print "callforward created for ${subscriber}\@${domain} [$subs_id]\n";
} else {
die("Error: callforward failed for ${subscriber}\@${domain} [$subs_id]");
}
}
else {
die("Error: No subscriber ${subscriber}\@${domain} found");
}
return;
}
main;
sub set_subscriber_voicemailsettings
{
my $subscriber = shift;
my $domain = shift;
my $prefs = shift;
my $subs_id = $api->check_subscriber_exists({
domain => $domain,
username => $subscriber});
if($subs_id) {
my $res = $api->set_subscriber_voicemailsettings($subs_id, $prefs);
if($opts->{verbose}) {
print Dumper $res;
}
if($res) {
print "voicemailsetting created for ${subscriber}\@${domain} [$subs_id]\n";
} else {
die("Error: voicemailsetting failed for ${subscriber}\@${domain} [$subs_id]");
}
}
else {
die("Error: No subscriber ${subscriber}\@${domain} found");
}
return;
}
sub main {
my $filename = abs_path($ARGV[0]);
my $cf = YAML::LoadFile($filename);
my $r = YAML::LoadFile(abs_path($ARGV[0]));
for my $key (keys $cf)
for my $key (keys %{$r})
{
my @fields = split /@/, $key;
my $param;
# cf_set
my $set = {}; # name -> set_id
my $time = {}; # name -> time_id
foreach my $s (@{$cf->{$key}->{'destination_set'}})
{
$param = { username => $fields[0], domain => $fields[1], data => $s };
call_prov( 'create_subscriber_cf_destination_set', $param);
}
$param = { username => $fields[0], domain => $fields[1] };
my $result = call_prov('get_subscriber_cf_destination_sets', $param);
# name -> set_id
foreach my $r (@{$result})
{
$set->{$r->{'name'}} = $r->{'id'};
}
# time_set
foreach my $t (@{$cf->{$key}->{'time_set'}})
{
$param = { username => $fields[0], domain => $fields[1], data => $t };
call_prov( 'create_subscriber_cf_time_set', $param);
}
$param = { username => $fields[0], domain => $fields[1] };
$result = call_prov('get_subscriber_cf_time_sets', $param);
# name -> time_id
foreach my $r (@{$result})
{
$time->{$r->{'name'}} = $r->{'id'};
}
# cf_map
foreach my $m (@{$cf->{$key}->{'map'}})
{
$m->{'destination_set_id'} = $set->{$m->{'destination_set_id'}};
if(exists($m->{'time_set_id'}))
{
$m->{'time_set_id'} = $time->{$m->{'time_set_id'}};
}
$param = { username => $fields[0], domain => $fields[1], data => $m };
call_prov( 'create_subscriber_cf_map', $param);
}
# voicebox
if (exists($cf->{$key}->{voicebox}))
{
$param = { username => $fields[0], domain => $fields[1], preferences => $cf->{$key}->{voicebox}};
call_prov( 'set_subscriber_voicebox_preferences', $param);
my $voicemail = delete $r->{$key}->{voicebox};
set_subscriber_callforward($fields[0], $fields[1], $r->{$key});
if ($voicemail) {
set_subscriber_voicemailsettings($fields[0], $fields[1], $voicemail);
}
}
exit;
return;
}
sub call_prov {
# scalar, scalar, hash-ref
my ($function, $parameter) = @_;
my $result;
eval {
$result = $bprov->handle_request( $function,
{
authentication => {
type => 'system',
username => $CONFIG{admin},
password => $CONFIG{password},
},
parameters => $parameter,
});
};
if($EVAL_ERROR) {
if(ref $EVAL_ERROR eq 'SOAP::Fault') {
die "Voip\::$function failed: ". $EVAL_ERROR->faultstring;
} else {
die "Voip\::$function failed: $EVAL_ERROR";
}
}
return $result;
}
sub usage {
die "Usage:\n$PROGRAM_NAME callforward.yml\n";
}
main();

@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# Copyright: 2013 Sipwise Development Team <support@sipwise.com>
# Copyright: 2013-2016 Sipwise Development Team <support@sipwise.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -22,76 +22,74 @@ use strict;
use warnings;
use English;
use Getopt::Std;
use Cwd 'abs_path';
use YAML;
use DateTime;
use Sipwise::Provisioning::Voip;
use Sipwise::Provisioning::Config;
our %CONFIG = ( admin => 'cmd' );
my $config = Sipwise::Provisioning::Config->new()->get_config();
use Getopt::Long;
use Cwd 'abs_path';
use Config::Tiny;
use Sipwise::API qw(all);
use Data::Dumper;
unless ($CONFIG{password} = $config->{acl}->{$CONFIG{admin}}->{password}) {
die "Error: No provisioning password found for user $CONFIG{admin}\n";
my $config = Config::Tiny->read('/etc/default/ngcp-api');
my $opts;
if ($config) {
$opts = {};
$opts->{host} = $config->{_}->{NGCP_API_IP};
$opts->{port} = $config->{_}->{NGCP_API_PORT};
$opts->{sslverify} = $config->{_}->{NGCP_API_SSLVERIFY};
}
my $api = Sipwise::API->new($opts);
$opts = $api->opts;
sub main;
sub usage;
sub call_prov;
die usage() unless ($#ARGV == 0);
my $bprov = Sipwise::Provisioning::Voip->new();
main;
sub usage {
return "Usage:\n$PROGRAM_NAME speeddial.yml\n".
"Options:\n".
" -d debug\n".
" -h this help\n";
}
my $help = 0;
GetOptions(
"h|help" => \$help,
"d|debug" => \$opts->{verbose}
) or die("Error in command line arguments\n".usage());
sub main {
my $filename = abs_path($ARGV[0]);
my $r = YAML::LoadFile($filename);
die(usage()) unless (!$help);
die("Error: wrong number of arguments\n".usage()) unless ($#ARGV == 0);
my $now = DateTime->now();
for my $key (keys $r)
{
my @fields = split /@/, $key;
foreach (@{$r->{$key}})
{
my $param = { username => $fields[0], domain => $fields[1], data => $_ };
call_prov( 'create_speed_dial_slot', $param);
}
sub set_subscriber_speeddial
{
my $subscriber = shift;
my $domain = shift;
my $prefs = shift;
my $subs_id = $api->check_subscriber_exists({
domain => $domain,
username => $subscriber});
if($subs_id) {
my $res = $api->set_subscriber_speeddial($subs_id, {speeddials => $prefs});
if($opts->{verbose}) {
print Dumper $res;
}
exit;
if($res) {
print "speeddial created for ${subscriber}\@${domain} [$subs_id]\n";
} else {
die("Error: speeddial failed for ${subscriber}\@${domain} [$subs_id]");
}
}
else {
die("Error: No subscriber ${subscriber}\@${domain} found");
}
return;
}
sub call_prov {
# scalar, scalar, hash-ref
my ($function, $parameter) = @_;
my $result;
eval {
$result = $bprov->handle_request( $function,
{
authentication => {
type => 'system',
username => $CONFIG{admin},
password => $CONFIG{password},
},
parameters => $parameter,
});
};
if($EVAL_ERROR) {
if(ref $EVAL_ERROR eq 'SOAP::Fault') {
die "Voip\::$function failed: ". $EVAL_ERROR->faultstring;
} else {
die "Voip\::$function failed: $EVAL_ERROR";
}
}
sub main {
my $r = YAML::LoadFile(abs_path($ARGV[0]));
return $result;
for my $key (keys %{$r})
{
my @fields = split /@/, $key;
set_subscriber_speeddial($fields[0], $fields[1], $r->{$key});
}
exit;
}
sub usage {
die "Usage:\n$PROGRAM_NAME speeddial.yml\n";
}
main();

@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# Copyright: 2013 Sipwise Development Team <support@sipwise.com>
# Copyright: 2013-2016 Sipwise Development Team <support@sipwise.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -22,24 +22,26 @@ use strict;
use warnings;
use English;
use Cwd 'abs_path';
use YAML;
use Getopt::Long;
use Sipwise::Provisioning::Voip;
use Sipwise::Provisioning::Billing;
use Sipwise::Provisioning::Config;
use Data::Dumper;
our %CONFIG = ( admin => 'cmd' );
my $config = Sipwise::Provisioning::Config->new()->get_config();
unless ($CONFIG{password} = $config->{acl}->{$CONFIG{admin}}->{password}) {
die "Error: No provisioning password found for user $CONFIG{admin}\n";
use Cwd 'abs_path';
use Config::Tiny;
use Sipwise::API qw(all);
my $config = Config::Tiny->read('/etc/default/ngcp-api');
my $opts;
if ($config) {
$opts = {};
$opts->{host} = $config->{_}->{NGCP_API_IP};
$opts->{port} = $config->{_}->{NGCP_API_PORT};
$opts->{sslverify} = $config->{_}->{NGCP_API_SSLVERIFY};
}
my $api = Sipwise::API->new($opts);
$opts = $api->opts;
sub usage;
sub call_prov;
sub usage {
return "Usage:\n$PROGRAM_NAME [-h] [-i IP] [-p PORT]" .
" peer_host_name\n";
}
my $help = 0;
my $ip;
@ -50,82 +52,30 @@ GetOptions ("h|help" => \$help,
or die("Error in command line arguments\n".usage());
die(usage()) unless (!$help);
die("Wrong number of arguments\n".usage()) unless ($#ARGV == 1);
die("Wrong number of arguments\n".usage()) unless ($#ARGV == 0);
our $bprov = Sipwise::Provisioning::Billing->new();
our $vprov = Sipwise::Provisioning::Voip->new();
my $data;
my $data = {};
$data->{ip} = $ip unless !defined($ip);
$data->{port} = $port unless !defined($port);
die("ip or port option has to be set\n".usage()) unless defined($data);
print Dumper($data), "\n";
do_update($data);
sub do_update {
my ($data) = @_;
my $filename = abs_path($ARGV[1]);
my $r = YAML::LoadFile($filename);
for (keys $r)
{
my $peer = $r->{$_};
# groups
my $group = {}; # name = id
my $result = call_prov( $vprov, 'get_peer_groups');
foreach (@{$result})
{
$group->{$_->{name}} = $_->{id};
}
for (keys $group)
{
$result = call_prov( $vprov, 'get_peer_group_details', { id => $group->{$_} });
foreach (@{$result->{peers}})
{
if ($_->{name} eq $ARGV[0])
{
my $param = {
id => $_->{id},
data => $data
};
call_prov( $vprov, 'update_peer_host', $param);
}
}
}
}
exit;
}
sub call_prov {
# scalar, scalar, hash-ref
my ($prov, $function, $parameter) = @_;
my $result;
eval {
$result = $prov->handle_request( $function,
{
authentication => {
type => 'system',
username => $CONFIG{admin},
password => $CONFIG{password},
},
parameters => $parameter,
});
};
if($EVAL_ERROR) {
if(ref $EVAL_ERROR eq 'SOAP::Fault') {
die "Voip\::$function failed: ". $EVAL_ERROR->faultstring;
my $host_id = $api->check_peeringserver_exists({ name => $ARGV[0] });
if($host_id) {
my $peer_data = $api->get_peeringserver($host_id);
if($peer_data) {
$peer_data->{ip} = $data->{ip};
$peer_data->{port} = $data->{port};
$api->set_peeringserver($host_id, $peer_data) or
die("Can't update peer $_->{name}");
print "peer $ARGV[0] updated [$host_id]\n";
} else {
die "Voip\::$function failed: $EVAL_ERROR";
die("Can't get peer data");
}
} else {
die("peer $_->{name} not found");
}
return $result;
return;
}
sub usage {
return "Usage:\n$PROGRAM_NAME [-h] [-i IP] [-p PORT]" .
" peer_host_name peer.yml\n";
}
do_update();

3
debian/control vendored

@ -10,11 +10,10 @@ Package: kamailio-config-tests
Architecture: all
Depends: curl,
libgraphviz-perl,
libhash-merge-perl,
libjson-perl,
libtemplate-perl,
libtext-csv-perl,
ngcp-ossbss-clients-perl,
ngcp-provisioning-tools,
parallel,
python,
python-pyinotify,

@ -278,7 +278,7 @@ sub check_domain_exists {
sub get_domain_preferences {
my $self = shift;
my $id = shift;
my $urldata = "/api/domains/${id}";
my $urldata = "/api/domainpreferences/${id}";
my $collection_id = 'ngcp:domainpreferences';
return $self->_get_content(undef, $urldata);
@ -331,7 +331,7 @@ sub check_subscriber_exists {
sub get_subscriber_preferences {
my $self = shift;
my $id = shift;
my $urldata = "/api/subscribers/${id}";
my $urldata = "/api/subscriberpreferences/${id}";
my $collection_id = 'ngcp:subscriberpreferences';
return $self->_get_content(undef, $urldata);
@ -347,6 +347,63 @@ sub set_subscriber_preferences {
return $self->_set_content($data, $urldata);
}
sub set_subscriber_speeddial {
my $self = shift;
my $id = shift;
my $data = shift;
my $urldata = "/api/speeddials/${id}";
my $collection_id = 'ngcp:speeddials';
return $self->_set_content($data, $urldata);
}
sub get_subscriber_speeddial {
my $self = shift;
my $id = shift;
my $urldata = "/api/speeddials/${id}";
my $collection_id = 'ngcp:speeddials';
return $self->_get_content(undef, $urldata);
}
sub set_subscriber_callforward {
my $self = shift;
my $id = shift;
my $data = shift;
my $urldata = "/api/callforwards/${id}";
my $collection_id = 'ngcp:callforwards';
return $self->_set_content($data, $urldata);
}
sub get_subscriber_callforward {
my $self = shift;
my $id = shift;
my $urldata = "/api/callforwards/${id}";
my $collection_id = 'ngcp:callforwards';
return $self->_get_content(undef, $urldata);
}
sub set_subscriber_voicemailsettings {
my $self = shift;
my $id = shift;
my $data = shift;
my $urldata = "/api/voicemailsettings/${id}";
my $collection_id = 'ngcp:voicemailsettings';
return $self->_set_content($data, $urldata);
}
sub get_subscriber_voicemailsettings {
my $self = shift;
my $id = shift;
my $urldata = "/api/voicemailsettings/${id}";
my $collection_id = 'ngcp:voicemailsettings';
return $self->_get_content(undef, $urldata);
}
sub create_subscriber {
my $self = shift;
my $data = shift;
@ -396,3 +453,167 @@ sub delete_rewriteruleset {
return $self->_delete($urldata);
}
sub check_peeringgroup_exists {
my $self = shift;
my $data = shift;
my $urldata = '/api/peeringgroups/';
my $collection_id = 'ngcp:peeringgroups';
return $self->_exists($data, $urldata, $collection_id);
}
sub create_peeringgroup {
my $self = shift;
my $data = shift;
my $urldata = '/api/peeringgroups/';
return $self->_create($data, $urldata);
}
sub delete_peeringgroup {
my $self = shift;
my $id = shift;
my $urldata = "/api/peeringgroups/${id}";
return $self->_delete($urldata);
}
sub check_peeringserver_exists {
my $self = shift;
my $data = shift;
my $urldata = '/api/peeringservers/';
my $collection_id = 'ngcp:peeringservers';
return $self->_exists($data, $urldata, $collection_id);
}
sub get_peeringserver_preferences {
my $self = shift;
my $id = shift;
my $urldata = "/api/peeringserverpreferences/${id}";
my $collection_id = 'ngcp:peeringserverpreferences';
return $self->_get_content(undef, $urldata);
}
sub set_peeringserver_preferences {
my $self = shift;
my $id = shift;
my $data = shift;
my $urldata = "/api/peeringserverpreferences/${id}";
my $collection_id = 'ngcp:peeringserverpreferences';
return $self->_set_content($data, $urldata);
}
sub create_peeringserver {
my $self = shift;
my $data = shift;
my $urldata = '/api/peeringservers/';
return $self->_create($data, $urldata);
}
sub set_peeringserver {
my $self = shift;
my $id = shift;
my $data = shift;
my $urldata = "/api/peeringservers/${id}";
my $collection_id = 'ngcp:peeringservers';
return $self->_set_content($data, $urldata);
}
sub get_peeringserver {
my $self = shift;
my $id = shift;
my $urldata = "/api/peeringservers/${id}";
my $collection_id = 'ngcp:peeringservers';
return $self->_get_content(undef, $urldata);
}
sub delete_peeringserver {
my $self = shift;
my $id = shift;
my $urldata = "/api/peeringservers/${id}";
return $self->_delete($urldata);
}
sub check_peeringrule_exists {
my $self = shift;
my $data = shift;
my $urldata = '/api/peeringrules/';
my $collection_id = 'ngcp:peeringrules';
return $self->_exists($data, $urldata, $collection_id);
}
sub create_peeringrule {
my $self = shift;
my $data = shift;
my $urldata = '/api/peeringrules/';
return $self->_create($data, $urldata);
}
sub delete_peeringrule {
my $self = shift;
my $id = shift;
my $urldata = "/api/peeringrules/${id}";
return $self->_delete($urldata);
}
sub check_ncoslevel_exists {
my $self = shift;
my $data = shift;
my $urldata = "/api/ncoslevels/";
my $collection_id = 'ngcp:ncoslevels';
return $self->_exists($data, $urldata, $collection_id);
}
sub create_ncoslevel {
my $self = shift;
my $data = shift;
my $urldata = '/api/ncoslevels/';
return $self->_create($data, $urldata);
}
sub delete_ncoslevel {
my $self = shift;
my $id = shift;
my $urldata = "/api/ncoslevels/${id}";
return $self->_delete($urldata);
}
sub check_ncospattern_exists {
my $self = shift;
my $data = shift;
my $urldata = "/api/ncospatterns/";
my $collection_id = 'ngcp:ncospatterns';
return $self->_exists($data, $urldata, $collection_id);
}
sub create_ncospattern {
my $self = shift;
my $data = shift;
my $urldata = '/api/ncospatterns/';
return $self->_create($data, $urldata);
}
sub delete_ncospattern {
my $self = shift;
my $id = shift;
my $urldata = "/api/ncospatterns/${id}";
return $self->_delete($urldata);
}

@ -0,0 +1,27 @@
---
peer_00:
contact:
company: peer_00
email: peer_00@host0.not
contract:
billing_profile_id: 1
status: active
type: sippeering
groups:
- name: peer_00_group
priority: 1
description:
rules:
- group_id: peer_00_group
callee_prefix: ""
callee_pattern: ""
caller_pattern: "^sip:.+@spce.test"
description: ""
hosts:
- group_id: peer_00_group
name: peer_00_host0
ip: 127.0.2.1
port: 50602
host:
transport: 1
weight: 1

@ -0,0 +1,5 @@
{
"peer_00_host0": {
"concurrent_max": 1
}
}

@ -3,6 +3,7 @@ ncos_test_00:
mode: blacklist
local_ac: 0
description: test ncos level
reseller_id: 1
patterns:
- pattern: "^431"
description: block local area calls

@ -1,27 +1,19 @@
---
testuser1001@spce.test:
destination_set:
- destinations:
- destination: sip:4311003@spce.test
priority: 0
timeout: 2
- destination: sip:testuser1003@spce.test
priority: 1
timeout: 2
name: cf_set_1001_00
map:
- destination_set_id: cf_set_1001_00
type: cfu
cfu:
destinations:
- destination: sip:4311003@spce.test
priority: 0
timeout: 2
- destination: sip:testuser1003@spce.test
priority: 1
timeout: 2
testuser1004@spce.test:
destination_set:
- destinations:
- destination: sip:4311005@spce.test
priority: 0
timeout: 2
- destination: sip:testuser1005@spce.test
priority: 1
timeout: 2
name: cf_set_1004_00
map:
- destination_set_id: cf_set_1004_00
type: cfb
cfb:
destinations:
- destination: sip:4311005@spce.test
priority: 0
timeout: 2
- destination: sip:testuser1005@spce.test
priority: 1
timeout: 2

@ -12,6 +12,8 @@ flow:
- return|ROUTE_LOAD_CALLEE_DOMAIN_PREF:
- start|ROUTE_FIND_CALLER:
- start|ROUTE_AUTH:
- start|ROUTE_AUTH_HELPER:
- return|ROUTE_AUTH_HELPER:
- start|ROUTE_ADD_CALLINFO_REPLY:
- return|ROUTE_ADD_CALLINFO_REPLY:
- return|ROUTE_AUTH:

@ -12,6 +12,8 @@ flow:
- return|ROUTE_LOAD_CALLEE_DOMAIN_PREF:
- start|ROUTE_FIND_CALLER:
- start|ROUTE_AUTH:
- start|ROUTE_AUTH_HELPER:
- return|ROUTE_AUTH_HELPER:
- start|ROUTE_ADD_CALLINFO_REPLY:
- return|ROUTE_ADD_CALLINFO_REPLY:
- return|ROUTE_AUTH:

@ -0,0 +1,53 @@
---
peer_00:
contact:
company: peer_00
email: peer_00@host0.not
contract:
billing_profile_id: 1
status: active
type: sippeering
groups:
- name: peer_00_group
priority: 1
description:
rules:
- group_id: peer_00_group
callee_prefix: ""
callee_pattern: ""
caller_pattern: "^sip:.+@spce.test"
description: ""
hosts:
- group_id: peer_00_group
name: peer_00_host0
ip: 127.0.2.1
port: 50602
host:
transport: 1
weight: 1
peer_01:
contact:
company: peer_01
email: peer_01@host1.not
contract:
billing_profile_id: 1
status: active
type: sippeering
groups:
- name: peer_01_group
priority: 1
description:
rules:
- group_id: peer_01_group
callee_prefix: ""
callee_pattern: "^44.+"
caller_pattern: "^sip:.+@spce.test"
description: ""
hosts:
- group_id: peer_01_group
name: peer_01_host0
ip: 127.0.3.1
port: 50607
host:
transport: 1
weight: 2

@ -0,0 +1,12 @@
{
"testuser1002@spce.test": {
"concurrent_max": 2,
"concurrent_max_out": 1
},
"peer_00_host0": {
"concurrent_max": 10
},
"peer_01_host0": {
"concurrent_max": 10
}
}

@ -12,6 +12,8 @@ flow:
- return|ROUTE_LOAD_CALLEE_DOMAIN_PREF:
- start|ROUTE_FIND_CALLER:
- start|ROUTE_AUTH:
- start|ROUTE_AUTH_HELPER:
- return|ROUTE_AUTH_HELPER:
- start|ROUTE_ADD_CALLINFO_REPLY:
- return|ROUTE_ADD_CALLINFO_REPLY:
- return|ROUTE_AUTH:

@ -12,6 +12,8 @@ flow:
- return|ROUTE_LOAD_CALLEE_DOMAIN_PREF:
- start|ROUTE_FIND_CALLER:
- start|ROUTE_AUTH:
- start|ROUTE_AUTH_HELPER:
- return|ROUTE_AUTH_HELPER:
- start|ROUTE_ADD_CALLINFO_REPLY:
- return|ROUTE_ADD_CALLINFO_REPLY:
- return|ROUTE_AUTH:

@ -0,0 +1,53 @@
---
peer_00:
contact:
company: peer_00
email: peer_00@host0.not
contract:
billing_profile_id: 1
status: active
type: sippeering
groups:
- name: peer_00_group
priority: 1
description:
rules:
- group_id: peer_00_group
callee_prefix: ""
callee_pattern: ""
caller_pattern: "^sip:.+@spce.test"
description: ""
hosts:
- group_id: peer_00_group
name: peer_00_host0
ip: 127.0.2.1
port: 50602
host:
transport: 1
weight: 1
peer_01:
contact:
company: peer_01
email: peer_01@host1.not
contract:
billing_profile_id: 1
status: active
type: sippeering
groups:
- name: peer_01_group
priority: 1
description:
rules:
- group_id: peer_01_group
callee_prefix: ""
callee_pattern: "^44.+"
caller_pattern: "^sip:.+@spce.test"
description: ""
hosts:
- group_id: peer_01_group
name: peer_01_host0
ip: 127.0.3.1
port: 50607
host:
transport: 1
weight: 2

@ -0,0 +1,11 @@
{
"testuser1002@spce.test": {
"concurrent_max_out_per_account": 1
},
"peer_00_host0": {
"concurrent_max": 10
},
"peer_01_host0": {
"concurrent_max": 10
}
}

@ -12,6 +12,8 @@ flow:
- return|ROUTE_LOAD_CALLEE_DOMAIN_PREF:
- start|ROUTE_FIND_CALLER:
- start|ROUTE_AUTH:
- start|ROUTE_AUTH_HELPER:
- return|ROUTE_AUTH_HELPER:
- start|ROUTE_ADD_CALLINFO_REPLY:
- return|ROUTE_ADD_CALLINFO_REPLY:
- return|ROUTE_AUTH:

@ -12,6 +12,8 @@ flow:
- return|ROUTE_LOAD_CALLEE_DOMAIN_PREF:
- start|ROUTE_FIND_CALLER:
- start|ROUTE_AUTH:
- start|ROUTE_AUTH_HELPER:
- return|ROUTE_AUTH_HELPER:
- start|ROUTE_ADD_CALLINFO_REPLY:
- return|ROUTE_ADD_CALLINFO_REPLY:
- return|ROUTE_AUTH:

@ -0,0 +1,27 @@
---
peer_00:
contact:
company: peer_00
email: peer_00@host0.not
contract:
billing_profile_id: 1
status: active
type: sippeering
groups:
- name: peer_00_group
priority: 1
description:
rules:
- group_id: peer_00_group
callee_prefix: ""
callee_pattern: ""
caller_pattern: "^sip:.+@spce.test"
description: ""
hosts:
- group_id: peer_00_group
name: peer_00_host0
ip: 127.0.2.1
port: 50602
host:
transport: 1
weight: 1

@ -0,0 +1,5 @@
{
"peer_00_host0": {
"concurrent_max": 1
}
}

@ -12,6 +12,8 @@ flow:
- return|ROUTE_LOAD_CALLEE_DOMAIN_PREF:
- start|ROUTE_FIND_CALLER:
- start|ROUTE_AUTH:
- start|ROUTE_AUTH_HELPER:
- return|ROUTE_AUTH_HELPER:
- start|ROUTE_ADD_CALLINFO_REPLY:
- return|ROUTE_ADD_CALLINFO_REPLY:
- return|ROUTE_AUTH:

@ -0,0 +1,27 @@
---
peer_00:
contact:
company: peer_00
email: peer_00@host0.not
contract:
billing_profile: 1
status: active
type: sippeering
groups:
- name: peer_00_group
priority: 1
description:
rules:
- group_id: peer_00_group
callee_prefix: ""
callee_pattern: ""
caller_pattern: "^sip:.+@spce.test"
description: ""
hosts:
- group_id: peer_00_group
name: peer_00_host0
ip: 127.0.2.1
port: 50602
host:
transport: 1
weight: 1

@ -3,6 +3,7 @@
"rewrite_rule_set": "rw_00"
},
"peer_00_host0": {
"rewrite_rule_set": "rw_00"
"rewrite_rule_set": "rw_00",
"concurrent_max": 1
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save