add sudo option throughout client lib

This commit is contained in:
Stefan Midjich 2017-11-16 23:56:15 +01:00
parent 82b5e46159
commit 6a9fcb9f0c
2 changed files with 7 additions and 3 deletions

View file

@ -16,6 +16,7 @@ class Client(object):
# Required parameters
self.storage = kw.pop('storage')
self.ipset_name = kw.pop('ipset_name')
self.use_sudo = kw.pop('use_sudo', False)
self.ip_address = kw.pop('ip_address', '127.0.0.1')
self.protocol = kw.pop('protocol', 'tcp')
@ -89,7 +90,8 @@ class Client(object):
'del',
'-exist',
self.ipset_name,
self.ip_address
self.ip_address,
use_sudo=self.use_sudo
)
@ -98,7 +100,8 @@ class Client(object):
'add',
'-exist',
self.ipset_name,
self.ip_address
self.ip_address,
use_sudo=self.use_sudo
)

View file

@ -136,7 +136,8 @@ if args.refresh:
client = Client(
storage=sr,
ip_address=client_ip,
ipset_name=config.get('ipset', 'ipset_name')
ipset_name=config.get('ipset', 'ipset_name'),
use_sudo=use_sudo
)
except Exception as e:
if args.verbose: