blob: 1726e73ab1ca60890c8b16e5b3e44d6ac5da2b7c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
import logging
logger = logging.getLogger(name=__name__)
import os
from leap.base import config as baseconfig
from leap.eip import config as eipconfig
from leap.eip import constants as eipconstants
class EIPChecker(object):
"""
Several tests needed
to ensure a EIPConnection
can be sucessful
"""
#def __init__(self):
## no init needed atm..
#pass
def run_all(self, checker=None):
"""
runs all checks in a row.
will raise if some error encountered.
catching those exceptions is not
our responsibility at this moment
"""
if not checker:
checker = self
# let's call all tests
# needed for a sane eip session.
checker.check_default_eipconfig()
checker.check_is_there_default_provider()
checker.fetch_definition()
checker.fetch_eip_config()
checker.check_complete_eip_config()
checker.ping_gateway()
# public checks
def check_default_eipconfig(self):
"""
checks if default eipconfig exists,
and dumps a default file if not
"""
# it *really* does not make sense to
# dump it right now, we can get an in-memory
# config object and dump it to disk in a
# later moment
if not self._is_there_default_eipconfig():
self._dump_default_eipconfig()
def check_is_there_default_provider(self):
raise NotImplementedError
def fetch_definition(self):
# check_and_get_definition_file
raise NotImplementedError
def fetch_eip_config(self):
raise NotImplementedError
def check_complete_eip_config(self):
raise NotImplementedError
def ping_gateway(self):
raise NotImplementedError
# private helpers
def _get_default_eipconfig_path(self):
return baseconfig.get_config_file(eipconstants.EIP_CONFIG)
def _is_there_default_eipconfig(self):
return os.path.isfile(
self._get_default_eipconfig_path())
def _dump_default_eipconfig(self):
eipconfig.dump_default_eipconfig(
self._get_default_eipconfig_path())
|