summaryrefslogtreecommitdiff
path: root/src/leap/eip/checks.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-08-27 23:21:43 +0900
committerkali <kali@leap.se>2012-08-27 23:31:39 +0900
commit4a46723219e5284bec21b9dccd6589a670babc63 (patch)
treeb2d435b0c7e616c91cbf92b185f097985aec041e /src/leap/eip/checks.py
parente896190d159342d9819f0ad6f11fe01deb8eb9e5 (diff)
add test_dump_default_eipconfig to eip.test_checks
plus a little bit of cleaning around (created constants file). added some notes about inminent deprecation *work in progress*
Diffstat (limited to 'src/leap/eip/checks.py')
-rw-r--r--src/leap/eip/checks.py49
1 files changed, 40 insertions, 9 deletions
diff --git a/src/leap/eip/checks.py b/src/leap/eip/checks.py
index bb588cf7..1726e73a 100644
--- a/src/leap/eip/checks.py
+++ b/src/leap/eip/checks.py
@@ -1,20 +1,26 @@
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):
"""
- Executes all tests needed
+ Several tests needed
to ensure a EIPConnection
can be sucessful
"""
- def __init__(self):
- pass
+ #def __init__(self):
+ ## no init needed atm..
+ #pass
- def do_all_checks(self, checker=None):
+ def run_all(self, checker=None):
"""
- just runs all tests in a row.
- will raise if some error encounter.
+ runs all checks in a row.
+ will raise if some error encountered.
catching those exceptions is not
our responsibility at this moment
"""
@@ -24,20 +30,32 @@ class EIPChecker(object):
# let's call all tests
# needed for a sane eip session.
- checker.dump_default_eipconfig()
+ 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()
- def dump_default_eipconfig(self):
- raise NotImplementedError
+ # 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):
@@ -48,3 +66,16 @@ class EIPChecker(object):
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())