MT#17623 Reload dialplan cache on rwr changes

In panel, the reload was missing for set clone/delete
In API, it was missing everywhere

Change-Id: Ib474d56cf3f1ace5e3e2eb66fdb109014a4ed756
changes/62/4362/5
Andreas Granig 10 years ago
parent 22607eedf3
commit 0562ab53f8

@ -10,6 +10,7 @@ use HTTP::Headers qw();
use HTTP::Status qw(:constants);
use MooseX::ClassAttribute qw(class_has);
use NGCP::Panel::Utils::DateTime;
use NGCP::Panel::Utils::Rewrite;
use Path::Tiny qw(path);
use Safe::Isa qw($_isa);
BEGIN { extends 'Catalyst::Controller::ActionRole'; }
@ -241,6 +242,7 @@ sub POST :Allow {
}
$guard->commit;
NGCP::Panel::Utils::Rewrite::sip_dialplan_reload($c);
$c->response->status(HTTP_CREATED);
$c->response->header(Location => sprintf('/%s%d', $c->request->path, $ruleset->id));

@ -11,6 +11,7 @@ use HTTP::Status qw(:constants);
use MooseX::ClassAttribute qw(class_has);
use NGCP::Panel::Utils::ValidateJSON qw();
use NGCP::Panel::Utils::DateTime;
use NGCP::Panel::Utils::Rewrite;
use Path::Tiny qw(path);
use Safe::Isa qw($_isa);
BEGIN { extends 'Catalyst::Controller::ActionRole'; }
@ -113,6 +114,7 @@ sub PATCH :Allow {
last unless $ruleset;
$guard->commit;
NGCP::Panel::Utils::Rewrite::sip_dialplan_reload($c);
if ('minimal' eq $preference) {
$c->response->status(HTTP_NO_CONTENT);
@ -153,6 +155,7 @@ sub PUT :Allow {
last unless $ruleset;
$guard->commit;
NGCP::Panel::Utils::Rewrite::sip_dialplan_reload($c);
if ('minimal' eq $preference) {
$c->response->status(HTTP_NO_CONTENT);
@ -186,6 +189,7 @@ sub DELETE :Allow {
last;
}
$guard->commit;
NGCP::Panel::Utils::Rewrite::sip_dialplan_reload($c);
$c->response->status(HTTP_NO_CONTENT);
$c->response->body(q());

@ -10,6 +10,7 @@ use HTTP::Headers qw();
use HTTP::Status qw(:constants);
use MooseX::ClassAttribute qw(class_has);
use NGCP::Panel::Utils::DateTime;
use NGCP::Panel::Utils::Rewrite;
BEGIN { extends 'Catalyst::Controller::ActionRole'; }
require Catalyst::ActionRole::ACL;
require Catalyst::ActionRole::CheckTrailingSlash;
@ -208,6 +209,7 @@ sub POST :Allow {
}
$guard->commit;
NGCP::Panel::Utils::Rewrite::sip_dialplan_reload($c);
$c->response->status(HTTP_CREATED);
$c->response->header(Location => sprintf('/%s%d', $c->request->path, $rule->id));

@ -11,6 +11,7 @@ use HTTP::Status qw(:constants);
use MooseX::ClassAttribute qw(class_has);
use NGCP::Panel::Utils::ValidateJSON qw();
use NGCP::Panel::Utils::DateTime;
use NGCP::Panel::Utils::Rewrite;
use Path::Tiny qw(path);
use Safe::Isa qw($_isa);
BEGIN { extends 'Catalyst::Controller::ActionRole'; }
@ -113,6 +114,7 @@ sub PATCH :Allow {
last unless $rule;
$guard->commit;
NGCP::Panel::Utils::Rewrite::sip_dialplan_reload($c);
if ('minimal' eq $preference) {
$c->response->status(HTTP_NO_CONTENT);
@ -153,6 +155,7 @@ sub PUT :Allow {
last unless $rule;
$guard->commit;
NGCP::Panel::Utils::Rewrite::sip_dialplan_reload($c);
if ('minimal' eq $preference) {
$c->response->status(HTTP_NO_CONTENT);
@ -185,6 +188,7 @@ sub DELETE :Allow {
last;
}
$guard->commit;
NGCP::Panel::Utils::Rewrite::sip_dialplan_reload($c);
$c->response->status(HTTP_NO_CONTENT);
$c->response->body(q());

@ -9,7 +9,7 @@ use NGCP::Panel::Form::RewriteRule::ResellerSet;
use NGCP::Panel::Form::RewriteRule::CloneSet;
use NGCP::Panel::Form::RewriteRule::Rule;
use NGCP::Panel::Utils::Message;
use NGCP::Panel::Utils::XMLDispatcher;
use NGCP::Panel::Utils::Rewrite;
use NGCP::Panel::Utils::Navigation;
sub auto :Does(ACL) :ACLDetachTo('/denied_page') :AllowedRole(admin) :AllowedRole(reseller) {
@ -130,6 +130,7 @@ sub set_delete :Chained('set_base') :PathPart('delete') {
try {
$c->stash->{set_result}->delete;
NGCP::Panel::Utils::Rewrite::sip_dialplan_reload($c);
NGCP::Panel::Utils::Message::info(
c => $c,
data => { $c->stash->{set_result}->get_inflated_columns },
@ -184,6 +185,7 @@ sub set_clone :Chained('set_base') :PathPart('clone') {
});
}
});
NGCP::Panel::Utils::Rewrite::sip_dialplan_reload($c);
NGCP::Panel::Utils::Message::info(
c => $c,
desc => $c->loc('Rewrite rule set successfully cloned'),
@ -301,7 +303,7 @@ sub rules_root :Chained('rules_list') :PathPart('') :Args(0) {
$elem->priority(int($last_priority) - 1);
$elem->update;
}
$self->_sip_dialplan_reload($c);
NGCP::Panel::Utils::Rewrite::sip_dialplan_reload($c);
} catch($e) {
NGCP::Panel::Utils::Message::error(
c => $c,
@ -402,7 +404,7 @@ sub rules_edit :Chained('rules_base') :PathPart('edit') {
if($posted && $form->validated) {
try {
$c->stash->{rule_result}->update($form->values);
$self->_sip_dialplan_reload($c);
NGCP::Panel::Utils::Rewrite::sip_dialplan_reload($c);
NGCP::Panel::Utils::Message::info(
c => $c,
desc => $c->loc('Rewrite rule successfully updated'),
@ -426,7 +428,7 @@ sub rules_delete :Chained('rules_base') :PathPart('delete') {
try {
$c->stash->{rule_result}->delete;
$self->_sip_dialplan_reload($c);
NGCP::Panel::Utils::Rewrite::sip_dialplan_reload($c);
NGCP::Panel::Utils::Message::info(
c => $c,
data => { $c->stash->{rule_result}->get_inflated_columns },
@ -462,7 +464,7 @@ sub rules_create :Chained('rules_list') :PathPart('create') :Args(0) {
my $last_priority = $c->stash->{rules_rs}->get_column('priority')->max() || 49;
$form->values->{priority} = int($last_priority) + 1;
$c->stash->{rules_rs}->create($form->values);
$self->_sip_dialplan_reload($c);
NGCP::Panel::Utils::Rewrite::sip_dialplan_reload($c);
NGCP::Panel::Utils::Message::info(
c => $c,
desc => $c->loc('Rewrite rule successfully created'),
@ -481,20 +483,6 @@ sub rules_create :Chained('rules_list') :PathPart('create') :Args(0) {
$c->stash(create_flag => 1);
}
sub _sip_dialplan_reload {
my ($self, $c) = @_;
my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new;
$dispatcher->dispatch($c, "proxy-ng", 1, 1, <<EOF );
<?xml version="1.0" ?>
<methodCall>
<methodName>dialplan.reload</methodName>
<params/>
</methodCall>
EOF
return 1;
}
__PACKAGE__->meta->make_immutable;
1;

@ -98,8 +98,6 @@ sub update_item {
$item->update($resource);
return $item;
}

@ -0,0 +1,24 @@
package NGCP::Panel::Utils::Rewrite;
use strict;
use warnings;
use NGCP::Panel::Utils::XMLDispatcher;
sub sip_dialplan_reload {
my ($c) = @_;
my $dispatcher = NGCP::Panel::Utils::XMLDispatcher->new;
$dispatcher->dispatch($c, "proxy-ng", 1, 1, <<EOF );
<?xml version="1.0" ?>
<methodCall>
<methodName>dialplan.reload</methodName>
<params/>
</methodCall>
EOF
return 1;
}
1;
# vim: set tabstop=4 expandtab:
Loading…
Cancel
Save