From 43dd945c5a45c86c491892f30546d0179751bf4a Mon Sep 17 00:00:00 2001 From: Thomas Mangin Date: Tue, 19 May 2020 21:13:40 +0100 Subject: util: T2467: add systemctl to autosudo --- src/conf_mode/http-api.py | 4 ++-- src/conf_mode/https.py | 4 ++-- src/conf_mode/igmp_proxy.py | 2 +- src/conf_mode/lldp.py | 4 ++-- src/conf_mode/ntp.py | 4 ++-- src/conf_mode/ssh.py | 4 ++-- src/conf_mode/vrrp.py | 6 +++--- src/op_mode/flow_accounting_op.py | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/conf_mode/http-api.py b/src/conf_mode/http-api.py index 26f4aea7f..3b8a67ef6 100755 --- a/src/conf_mode/http-api.py +++ b/src/conf_mode/http-api.py @@ -92,9 +92,9 @@ def generate(http_api): def apply(http_api): if http_api is not None: - call('sudo systemctl restart vyos-http-api.service') + call('systemctl restart vyos-http-api.service') else: - call('sudo systemctl stop vyos-http-api.service') + call('systemctl stop vyos-http-api.service') for dep in dependencies: cmd(f'{vyos_conf_scripts_dir}/{dep}', raising=ConfigError) diff --git a/src/conf_mode/https.py b/src/conf_mode/https.py index 7d3a1b9cb..718e8375c 100755 --- a/src/conf_mode/https.py +++ b/src/conf_mode/https.py @@ -141,9 +141,9 @@ def generate(https): def apply(https): if https is not None: - call('sudo systemctl restart nginx.service') + call('systemctl restart nginx.service') else: - call('sudo systemctl stop nginx.service') + call('systemctl stop nginx.service') if __name__ == '__main__': try: diff --git a/src/conf_mode/igmp_proxy.py b/src/conf_mode/igmp_proxy.py index 9fa591a2c..9cd7163f0 100755 --- a/src/conf_mode/igmp_proxy.py +++ b/src/conf_mode/igmp_proxy.py @@ -121,7 +121,7 @@ def generate(igmp_proxy): def apply(igmp_proxy): if igmp_proxy is None or igmp_proxy['disable']: # IGMP Proxy support is removed in the commit - call('sudo systemctl stop igmpproxy.service') + call('systemctl stop igmpproxy.service') if os.path.exists(config_file): os.unlink(config_file) else: diff --git a/src/conf_mode/lldp.py b/src/conf_mode/lldp.py index d128c1fe6..6446074d8 100755 --- a/src/conf_mode/lldp.py +++ b/src/conf_mode/lldp.py @@ -228,10 +228,10 @@ def generate(lldp): def apply(lldp): if lldp: # start/restart lldp service - call('sudo systemctl restart lldpd.service') + call('systemctl restart lldpd.service') else: # LLDP service has been terminated - call('sudo systemctl stop lldpd.service') + call('systemctl stop lldpd.service') os.unlink(config_file) os.unlink(vyos_config_file) diff --git a/src/conf_mode/ntp.py b/src/conf_mode/ntp.py index 6d32f7fd6..85f60293d 100755 --- a/src/conf_mode/ntp.py +++ b/src/conf_mode/ntp.py @@ -103,10 +103,10 @@ def generate(ntp): def apply(ntp): if ntp is not None: - call('sudo systemctl restart ntp.service') + call('systemctl restart ntp.service') else: # NTP support is removed in the commit - call('sudo systemctl stop ntp.service') + call('systemctl stop ntp.service') os.unlink(config_file) return None diff --git a/src/conf_mode/ssh.py b/src/conf_mode/ssh.py index ae79eac2d..76fdad8ae 100755 --- a/src/conf_mode/ssh.py +++ b/src/conf_mode/ssh.py @@ -124,10 +124,10 @@ def generate(ssh): def apply(ssh): if ssh is not None and 'port' in ssh.keys(): - call("sudo systemctl restart ssh.service") + call("systemctl restart ssh.service") else: # SSH access is removed in the commit - call("sudo systemctl stop ssh.service") + call("systemctl stop ssh.service") if os.path.isfile(config_file): os.unlink(config_file) diff --git a/src/conf_mode/vrrp.py b/src/conf_mode/vrrp.py index f358891a5..1a5ad1f8c 100755 --- a/src/conf_mode/vrrp.py +++ b/src/conf_mode/vrrp.py @@ -227,17 +227,17 @@ def apply(data): if not VRRP.is_running(): print("Starting the VRRP process") - ret = call("sudo systemctl restart keepalived.service") + ret = call("systemctl restart keepalived.service") else: print("Reloading the VRRP process") - ret = call("sudo systemctl reload keepalived.service") + ret = call("systemctl reload keepalived.service") if ret != 0: raise ConfigError("keepalived failed to start") else: # VRRP is removed in the commit print("Stopping the VRRP process") - call("sudo systemctl stop keepalived.service") + call("systemctl stop keepalived.service") os.unlink(VRRP.location['daemon']) return None diff --git a/src/op_mode/flow_accounting_op.py b/src/op_mode/flow_accounting_op.py index 219ad6316..bf8c39fd6 100755 --- a/src/op_mode/flow_accounting_op.py +++ b/src/op_mode/flow_accounting_op.py @@ -195,7 +195,7 @@ if not _uacctd_running(): # restart pmacct daemon if cmd_args.action == 'restart': # run command to restart flow-accounting - cmd('sudo systemctl restart uacctd.service', + cmd('systemctl restart uacctd.service', message='Failed to restart flow-accounting') # clear in-memory collected flows -- cgit v1.2.3