Skip to content

Commit 3394a05

Browse files
committed
minor backups changes
Modified pluggable module exports to allow for the overwrite of an existing file. Backups of pluggables using the backups module now overwrite an already exported pluggable module
1 parent 40b2029 commit 3394a05

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

onefuse/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
Enables the execution of OneFuse policies via Python
55
"""
66

7-
__version__ = "9.4.7.2"
7+
__version__ = "9.4.7.3"
88
__credits__ = 'Cloudbolt Software, Inc.'

onefuse/admin.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,8 @@ def deprovision_ipam(self, ipam_id: int):
437437
return path
438438

439439
# Pluggable Modules
440-
def export_pluggable_module(self, module_name: str, save_path: str):
440+
def export_pluggable_module(self, module_name: str, save_path: str,
441+
overwrite: bool = False):
441442
"""
442443
Export a Pluggable Module to a file path. The exported module will be
443444
saved to a file
@@ -450,6 +451,9 @@ def export_pluggable_module(self, module_name: str, save_path: str):
450451
File path to save the exported module zip file to
451452
Windows: 'C:\\temp\\onefuse_backups\\'
452453
Linux: '/tmp/onefuse_backups/'
454+
overwrite : bool
455+
Boolean value whether to overwrite an existing file in save_path
456+
Defaults to False
453457
"""
454458
path = 'modules'
455459
module = self.get_policy_by_name(path, module_name)
@@ -465,7 +469,10 @@ def export_pluggable_module(self, module_name: str, save_path: str):
465469
raise
466470
file_path = f'{save_path}{module_name}.zip'
467471
if os.path.isfile(file_path):
468-
raise OneFuseError(f'Zip file already exists for module_name: '
472+
if overwrite:
473+
os.remove(file_path)
474+
else:
475+
raise OneFuseError(f'Zip file already exists for module_name: '
469476
f'{module_name} in save_path: {save_path}')
470477
with open(file_path, 'wb') as fd:
471478
for chunk in response.iter_content(chunk_size=128):

onefuse/backups.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ def create_json_files(self, response, policy_type: str, backups_path: str):
137137
f'{policy["name"]}')
138138
file_path = f'{backups_path}{policy_type}{path_char}'
139139
if policy_type == 'modules':
140-
self.ofm.export_pluggable_module(policy["name"], file_path)
140+
# Modules will overwrite existing modules in the file path if
141+
# found
142+
self.ofm.export_pluggable_module(policy["name"], file_path,
143+
True)
141144
continue
142145
if policy_type == "endpoints":
143146
if "credential" in policy["_links"]:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name='onefuse',
8-
version='9.4.7.2',
8+
version='9.4.7.3',
99
author='Cloudbolt Software, Inc.',
1010
author_email='support@cloudbolt.io',
1111
description='OneFuse upstream provider package for Python',

0 commit comments

Comments
 (0)