forked from Mirror/pve-network
dns: dnsmasq: extract function to systemctl command.
systemctl_service() is a wrapper around PVE::Tools::run_command to allow mocking the systemctl interactions in tests. Signed-off-by: Stefan Lendl <s.lendl@proxmox.com> Reviewed-by: Max Carrara <m.carrara@proxmox.com> Tested-by: Max Carrara <m.carrara@proxmox.com> Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
This commit is contained in:
parent
2f37fddc0e
commit
cac88dfa47
|
@ -101,7 +101,7 @@ sub add_ip_mapping {
|
||||||
}
|
}
|
||||||
|
|
||||||
my $service_name = "dnsmasq\@$dhcpid";
|
my $service_name = "dnsmasq\@$dhcpid";
|
||||||
PVE::Tools::run_command(['systemctl', 'reload', $service_name]) if $reload;
|
systemctl_service('reload', $service_name) if $reload;
|
||||||
|
|
||||||
#update lease as ip could still be associated to an old removed mac
|
#update lease as ip could still be associated to an old removed mac
|
||||||
my $bus = Net::DBus->system();
|
my $bus = Net::DBus->system();
|
||||||
|
@ -163,6 +163,12 @@ sub configure_vnet {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub systemctl_service {
|
||||||
|
my ($action, $service) = @_;
|
||||||
|
|
||||||
|
PVE::Tools::run_command(['systemctl', $action, $service]);
|
||||||
|
}
|
||||||
|
|
||||||
sub before_configure {
|
sub before_configure {
|
||||||
my ($class, $dhcpid) = @_;
|
my ($class, $dhcpid) = @_;
|
||||||
|
|
||||||
|
@ -250,9 +256,9 @@ sub after_configure {
|
||||||
|
|
||||||
my $service_name = "dnsmasq\@$dhcpid";
|
my $service_name = "dnsmasq\@$dhcpid";
|
||||||
|
|
||||||
PVE::Tools::run_command(['systemctl', 'reload', 'dbus']);
|
systemctl_service('reload', 'dbus');
|
||||||
PVE::Tools::run_command(['systemctl', 'enable', $service_name]);
|
systemctl_service('enable', $service_name);
|
||||||
PVE::Tools::run_command(['systemctl', 'restart', $service_name]);
|
systemctl_service('restart', $service_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub before_regenerate {
|
sub before_regenerate {
|
||||||
|
@ -260,8 +266,8 @@ sub before_regenerate {
|
||||||
|
|
||||||
return if !assert_dnsmasq_installed($noerr);
|
return if !assert_dnsmasq_installed($noerr);
|
||||||
|
|
||||||
PVE::Tools::run_command(['systemctl', 'stop', "dnsmasq@*"]);
|
systemctl_service('stop', "dnsmasq@*");
|
||||||
PVE::Tools::run_command(['systemctl', 'disable', 'dnsmasq@']);
|
systemctl_service('disable', 'dnsmasq@');
|
||||||
}
|
}
|
||||||
|
|
||||||
sub after_regenerate {
|
sub after_regenerate {
|
||||||
|
|
Loading…
Reference in a new issue