From d07a3318440d0dd2e9a9b52e2171b9a26c4f0c09 Mon Sep 17 00:00:00 2001 From: erzetpe Date: Tue, 17 Sep 2019 16:38:34 +0200 Subject: [PATCH 1/2] Add offline-mode flag to epicli --- core/src/epicli/cli/epicli.py | 3 +++ core/src/epicli/cli/helpers/Config.py | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/core/src/epicli/cli/epicli.py b/core/src/epicli/cli/epicli.py index 2b6158c457..2ee34afd73 100644 --- a/core/src/epicli/cli/epicli.py +++ b/core/src/epicli/cli/epicli.py @@ -78,6 +78,7 @@ def main(): config.log_type = args.log_type config.log_count = args.log_count config.validate_certs = True if args.validate_certs == 'true' else False + config.offline_mode = args.offline_mode config.debug = args.debug config.auto_approve = args.auto_approve @@ -114,6 +115,8 @@ def apply_parser(subparsers): help='File with infrastructure/configuration definitions to use.') sub_parser.add_argument('--no-infra', dest='no_infra', action="store_true", help='Skip infrastructure provisioning.') + sub_parser.add_argument('--offline-mode', dest='offline_mode', action="store_true", + help='Should Epiphany run with offline packages.') def run_apply(args): adjust_paths_from_file(args) diff --git a/core/src/epicli/cli/helpers/Config.py b/core/src/epicli/cli/helpers/Config.py index 5bd6583e35..ae305e97f4 100644 --- a/core/src/epicli/cli/helpers/Config.py +++ b/core/src/epicli/cli/helpers/Config.py @@ -1,5 +1,6 @@ import os + class Config: class __ConfigBase: def __init__(self): @@ -18,6 +19,7 @@ def __init__(self): self._validate_certs = True self._debug = False self._auto_approve = False + self._offline_mode = False @property def docker_cli(self): @@ -93,8 +95,8 @@ def debug(self): @debug.setter def debug(self, debug): if not debug is None: - self._debug = debug - + self._debug = debug + @property def auto_approve(self): return self._auto_approve @@ -102,8 +104,17 @@ def auto_approve(self): @auto_approve.setter def auto_approve(self, auto_approve): if not auto_approve is None: - self._auto_approve = auto_approve - + self._auto_approve = auto_approve + + @property + def offline_mode(self): + return self._offline_mode + + @offline_mode.setter + def offline_mode(self, offline_mode): + if not offline_mode is None: + self._offline_mode = offline_mode + instance = None def __new__(cls): From faf33f7cd973d905def6b53171a5604d5d67dd71 Mon Sep 17 00:00:00 2001 From: erzetpe Date: Tue, 17 Sep 2019 17:49:42 +0200 Subject: [PATCH 2/2] Add offline mode to AnsibleVarsGenerator --- .../epicli/cli/engine/ansible/AnsibleVarsGenerator.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/src/epicli/cli/engine/ansible/AnsibleVarsGenerator.py b/core/src/epicli/cli/engine/ansible/AnsibleVarsGenerator.py index b4447d7b70..b9539fc769 100644 --- a/core/src/epicli/cli/engine/ansible/AnsibleVarsGenerator.py +++ b/core/src/epicli/cli/engine/ansible/AnsibleVarsGenerator.py @@ -53,6 +53,7 @@ def populate_group_vars(self, ansible_dir): main_vars = self.add_validate_certs(main_vars) main_vars = self.add_dependencies_info(main_vars) main_vars = self.add_shared_config(main_vars) + main_vars = self.add_offline_mode(main_vars) vars_dir = os.path.join(ansible_dir, 'group_vars') if not os.path.exists(vars_dir): @@ -79,6 +80,14 @@ def add_validate_certs(self, document): return document + def add_offline_mode(self, document): + if document is None: + raise Exception('Config is empty for: ' + 'group_vars/all.yml') + + document['offline_mode'] = Config().offline_mode + + return document + def add_dependencies_info(self, document): if document is None: raise Exception('Config is empty for: ' + 'group_vars/all.yml')