summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-09-12 10:32:22 +0900
committerkali <kali@leap.se>2012-09-12 10:32:22 +0900
commit99058b9f6536a3717ab82a9d77b09d5489334eb5 (patch)
tree3ad3b3c32153b6d19d7a6c2b2dd17c30becc0c65 /src
parent65b953117765a88ec6fb6ba9f3b36bc1434133a4 (diff)
add openvpn-verb option to cli.
Closes #534. accepts int [1-6] that get passed to openvpn invocation. We should filter out the polling "state"/"status" commands from the log if we want it to be real useful.
Diffstat (limited to 'src')
-rw-r--r--src/leap/baseapp/eip.py3
-rw-r--r--src/leap/eip/config.py12
-rw-r--r--src/leap/eip/openvpnconnection.py22
-rw-r--r--src/leap/util/leap_argparse.py4
-rw-r--r--src/leap/util/tests/test_leap_argparse.py3
5 files changed, 23 insertions, 21 deletions
diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py
index afdb7adc..515ae58d 100644
--- a/src/leap/baseapp/eip.py
+++ b/src/leap/baseapp/eip.py
@@ -35,7 +35,8 @@ class EIPConductorAppMixin(object):
watcher_cb=self.newLogLine.emit,
config_file=config_file,
status_signals=(self.statusChange.emit, ),
- debug=self.debugmode)
+ debug=self.debugmode,
+ ovpn_verbosity=opts.openvpn_verb)
# XXX remove skip download when sample service is ready
self.conductor.run_checks(skip_download=True)
diff --git a/src/leap/eip/config.py b/src/leap/eip/config.py
index 833519ee..c0e17a19 100644
--- a/src/leap/eip/config.py
+++ b/src/leap/eip/config.py
@@ -48,7 +48,7 @@ def get_socket_path():
return socket_path
-def build_ovpn_options(daemon=False, socket_path=None):
+def build_ovpn_options(daemon=False, socket_path=None, **kwargs):
"""
build a list of options
to be passed in the
@@ -78,6 +78,11 @@ def build_ovpn_options(daemon=False, socket_path=None):
opts.append('--persist-tun')
opts.append('--persist-key')
+ verbosity = kwargs.get('ovpn_verbosity', None)
+ if verbosity and 1 <= verbosity <= 6:
+ opts.append('--verb')
+ opts.append("%s" % verbosity)
+
# remote
# XXX get remote from eip.json
opts.append('--remote')
@@ -136,7 +141,7 @@ def build_ovpn_options(daemon=False, socket_path=None):
def build_ovpn_command(debug=False, do_pkexec_check=True, vpnbin=None,
- socket_path=None):
+ socket_path=None, **kwargs):
"""
build a string with the
complete openvpn invocation
@@ -182,7 +187,8 @@ def build_ovpn_command(debug=False, do_pkexec_check=True, vpnbin=None,
command.append(vpn_command)
daemon_mode = not debug
- for opt in build_ovpn_options(daemon=daemon_mode, socket_path=socket_path):
+ for opt in build_ovpn_options(daemon=daemon_mode, socket_path=socket_path,
+ **kwargs):
command.append(opt)
# XXX check len and raise proper error
diff --git a/src/leap/eip/openvpnconnection.py b/src/leap/eip/openvpnconnection.py
index 2ab0622e..c280f70d 100644
--- a/src/leap/eip/openvpnconnection.py
+++ b/src/leap/eip/openvpnconnection.py
@@ -23,7 +23,8 @@ class OpenVPNConnection(Connection):
of the openvpn binary
"""
- def __init__(self, config_file=None,
+ def __init__(self,
+ #config_file=None,
watcher_cb=None,
debug=False,
host=None,
@@ -46,8 +47,9 @@ to be triggered for each one of them.
logger.debug('init openvpn connection')
self.debug = debug
# XXX if not host: raise ImproperlyConfigured
+ self.ovpn_verbosity = kwargs.get('ovpn_verbosity', None)
- self.config_file = config_file
+ #self.config_file = config_file
self.watcher_cb = watcher_cb
#self.signal_maps = signal_maps
@@ -58,19 +60,6 @@ to be triggered for each one of them.
self.port = None
self.proto = None
- ##################################
- # This is handled by Exception attrs
- # now (see #504)
- #self.missing_pkexec = False
- #self.missing_auth_agent = False
-
- #self.bad_keyfile_perms = False
- #self.missing_vpn_keyfile = False
- #self.missing_provider = False
- #self.missing_definition = False
- #self.bad_provider = False
- #################################
-
#XXX workaround for signaling
#the ui that we don't know how to
#manage a connection error
@@ -106,7 +95,8 @@ to be triggered for each one of them.
try:
command, args = eip_config.build_ovpn_command(
debug=self.debug,
- socket_path=self.host)
+ socket_path=self.host,
+ ovpn_verbosity=self.ovpn_verbosity)
except eip_exceptions.EIPNoPolkitAuthAgentAvailable:
command = args = None
# XXX deprecate
diff --git a/src/leap/util/leap_argparse.py b/src/leap/util/leap_argparse.py
index f329cf3e..3b38aa77 100644
--- a/src/leap/util/leap_argparse.py
+++ b/src/leap/util/leap_argparse.py
@@ -15,6 +15,10 @@ Launches main LEAP Client""", epilog=epilog)
action="store", dest="log_file",
#type=argparse.FileType('w'),
help='optional log file')
+ parser.add_argument('--openvpn-verbosity', nargs='?',
+ type=int,
+ action="store", dest="openvpn_verb",
+ help='verbosity level for openvpn logs [1-6]')
return parser
diff --git a/src/leap/util/tests/test_leap_argparse.py b/src/leap/util/tests/test_leap_argparse.py
index 8a275f89..173c87bb 100644
--- a/src/leap/util/tests/test_leap_argparse.py
+++ b/src/leap/util/tests/test_leap_argparse.py
@@ -26,7 +26,8 @@ class LeapArgParseTest(unittest.TestCase):
Namespace(
config_file=None,
debug=True,
- log_file=None))
+ log_file=None,
+ openvpn_verb=None))
if __name__ == "__main__":
unittest.main()