Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backup/recovery: adding optional -b build_directory parameter #1301

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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