Skip to content
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
2 changes: 1 addition & 1 deletion library/juniper_junos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ def main():

junos_module.logger.debug("Step 1 - Open a candidate configuration "
"database.")
junos_module.open_configuration(mode=config_mode)
junos_module.open_configuration(mode=config_mode, ignore_warning=ignore_warning)
results['msg'] += 'opened'

junos_module.logger.debug("Step 2 - Load configuration data into the "
Expand Down
17 changes: 14 additions & 3 deletions module_utils/juniper_junos_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1344,14 +1344,26 @@ def add_sw(self):
"""
self.sw = jnpr.junos.utils.sw.SW(self.dev)

def open_configuration(self, mode):
def open_configuration(self, mode, ignore_warning=None):
"""Open candidate configuration database in exclusive or private mode.

Failures:
- ConnectError: When there's a problem with the PyEZ connection.
- RpcError: When there's a RPC problem including an already locked
config or an already opened private config.
"""

ignore_warn=['uncommitted changes will be discarded on exit']
# if ignore_warning is a bool, pass the bool
# if ignore_warning is a string add to the list
# if ignore_warning is a list, merge them
if ignore_warning != None and isinstance(ignore_warning, bool):
ignore_warn = ignore_warning
elif ignore_warning != None and isinstance(ignore_warning, str):
ignore_warn.append(ignore_warning)
elif ignore_warning != None and isinstance(ignore_warning, list):
ignore_warn = ignore_warn + ignore_warning

# Already have an open configuration?
if self.config is None:
if mode not in CONFIG_MODE_CHOICES:
Expand All @@ -1365,8 +1377,7 @@ def open_configuration(self, mode):
elif config.mode == 'private':
self.dev.rpc.open_configuration(
private=True,
ignore_warning='uncommitted changes will be '
'discarded on exit')
ignore_warning=ignore_warn)
except (pyez_exception.ConnectError,
pyez_exception.RpcError) as ex:
self.fail_json(msg='Unable to open the configuration in %s '
Expand Down