TT#130659 Stop calling systemd openvpn status twice on every HTTP request

The ngcp-panel<=>openvpn functionality has never been finished but on every
HTTP requset ngcp-panel was asking systemd about openvpn status. Twice!

From /var/log/ngcp/panel-debug.log :
> Jul 19 09:36:32 sp1 ngcp-panel: DEBUG: Path: dashboard
> Jul 19 09:36:32 sp1 ngcp-panel: DEBUG: systemctl list-unit-files openvpn.service
> Jul 19 09:36:32 sp1 ngcp-panel: DEBUG: systemctl is-enabled openvpn@ovpn
> ...
> Jul 19 09:36:33 sp1 ngcp-panel: DEBUG: Path: dashboard/ajax/peering_sum
> Jul 19 09:36:33 sp1 ngcp-panel: DEBUG: systemctl list-unit-files openvpn.service
> Jul 19 09:36:33 sp1 ngcp-panel: DEBUG: systemctl is-enabled openvpn@ovpn
> ...
> Jul 19 09:36:33 sp1 ngcp-panel: DEBUG: Path: dashboard/ajax/emergency_mode
> Jul 19 09:36:33 sp1 ngcp-panel: DEBUG: systemctl list-unit-files openvpn.service
> Jul 19 09:36:33 sp1 ngcp-panel: DEBUG: systemctl is-enabled openvpn@ovpn

It is unnecessary load, moreover for not-yet finished feature.
Let's move openvpn WIP functionality into 'NGCP Support Status' page and
finish it there one day. The goal of this commit is to stop DOS'ing systemd.

Change-Id: I6c9ba9e1b218e58b5adffe741f4490b3729d17e7
mr10.0
Alexander Lutay 4 years ago
parent fc9c71a88e
commit 6263f167e2

@ -342,12 +342,6 @@ sub auto :Private {
# load top menu widgets
my $topmenu_templates = [];
$topmenu_templates = ['widgets/'.$c->user->roles.'_topmenu_settings.tt'];
if ($c->user->roles eq 'admin') {
if (!$c->stash->{openvpn_info}) {
my $openvpn_info = NGCP::Panel::Utils::Auth::check_openvpn_status($c);
$c->stash(openvpn_info => $openvpn_info);
}
}
$c->stash(topmenu => $topmenu_templates);
$self->include_framed($c);

@ -49,6 +49,12 @@ sub supportstatus :Chained('/') :PathPart('statistics/supportstatus') :Args() {
$c->stash(support_status_code => $support_status_code,
#template => 'statistics/supportstatus.tt',
);
if (!$c->stash->{openvpn_info}) {
my $openvpn_info = NGCP::Panel::Utils::Auth::check_openvpn_status($c);
$c->stash(openvpn_info => $openvpn_info);
}
return;
}

@ -62,17 +62,6 @@
<li>
[% IF c.user && c.session.user_tz_name; '(' _ c.session.user_tz.name _ ' ' _ c.loc('time') _ ')'; END; %]
</li>
[%- IF ( c.user && ( c.user.roles == 'admin' || c.user.is_superuser ) ) && openvpn_info.allowed -%]
[%- IF !openvpn_info.active %]
<li>
<a class="btn btn-small btn-secondary" href="javascript:toggleOpenvpn('confirm');void(0);"><i class="icon-off"></i>Openvpn</a>
</li>
[% ELSE -%]
<li>
<a class="btn btn-small btn-success" href="javascript:toggleOpenvpn('confirm');void(0);"><i class="icon-ok"></i>Openvpn</a>
</li>
[% END -%]
[% END -%]
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="icon-globe"></i> [% c.loc('Language') %]

@ -30,4 +30,14 @@
[% END -%]
<br/>
[% IF openvpn_info.allowed -%]
[% IF openvpn_info.active -%]
<p>[% c.loc('Sipwise VPN service is') %] <a class="btn btn-small btn-success" href="javascript:toggleOpenvpn('confirm');void(0);"><i class="icon-ok"></i>Running</a></p>
[% ELSE -%]
<p>[% c.loc('Sipwise VPN service is') %] <a class="btn btn-small btn-secondary" href="javascript:toggleOpenvpn('confirm');void(0);"><i class="icon-off"></i>Stopped</a></p>
[% END -%]
[% END -%]
[% # vim: set tabstop=4 syntax=html expandtab: -%]

Loading…
Cancel
Save