Skip to content

Commit

Permalink
backup/recovery: adding optional -b build_directory parameter (#1301)
Browse files Browse the repository at this point in the history
  • Loading branch information
sk4zuzu committed Jun 29, 2020
1 parent 77dcc8d commit 1219315
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
11 changes: 8 additions & 3 deletions core/src/epicli/cli/engine/PatchEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class PatchEngine(Step):
def __init__(self, input_data):
super().__init__(__name__)
self.file = input_data.file
self.build_directory = input_data.build_directory # can be None
self.parsed_components = None if input_data.components is None else set(input_data.components)
self.component_dict = dict()
self.input_docs = list()
self.cluster_model = None
self.backup_doc = None
self.recovery_doc = None
self.build_directory = None
self.ansible_command = AnsibleCommand()

def __enter__(self):
Expand Down Expand Up @@ -67,11 +67,16 @@ def _process_input_docs(self):
# Get recovery config document
self.recovery_doc = select_single(self.input_docs, lambda x: x.kind == 'configuration/recovery')

# Derive the build directory path
self.build_directory = get_build_path(self.cluster_model.specification.name)
if self.build_directory is None:
# Derive the build directory path (if not provided)
self.build_directory = get_build_path(self.cluster_model.specification.name)

if not os.path.exists(self.build_directory):
raise Exception('Provided build directory path does not exist')

def _process_component_config(self, document):
if self.parsed_components is not None:
# Overwrite enable/disable settings from yaml config
available_components = set(document.specification.components.keys())
self.component_dict = components_to_dict(self.parsed_components, available_components)

Expand Down
10 changes: 8 additions & 2 deletions core/src/epicli/cli/epicli.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,11 @@ def backup_parser(subparsers):

sub_parser = subparsers.add_parser('backup',
description='Create backup of cluster components.')
sub_parser.add_argument('-f', '--file', dest='file', type=str,
sub_parser.add_argument('-f', '--file', dest='file', type=str, required=True,
help='File with infrastructure/configuration definitions to use.')
sub_parser.add_argument('-b', '--build', dest='build_directory', type=str, required=False,
help='Absolute path to directory with build artifacts.',
default=None)

available_components = {'kubernetes', 'load_balancer', 'logging', 'monitoring', 'postgresql', 'rabbitmq'}

Expand All @@ -290,8 +293,11 @@ def recovery_parser(subparsers):

sub_parser = subparsers.add_parser('recovery',
description='Recover from existing backup.')
sub_parser.add_argument('-f', '--file', dest='file', type=str,
sub_parser.add_argument('-f', '--file', dest='file', type=str, required=True,
help='File with infrastructure/configuration definitions to use.')
sub_parser.add_argument('-b', '--build', dest='build_directory', type=str, required=False,
help='Absolute path to directory with build artifacts.',
default=None)

available_components = {'kubernetes', 'load_balancer', 'logging', 'monitoring', 'postgresql', 'rabbitmq'}

Expand Down

0 comments on commit 1219315

Please sign in to comment.