Add config_mode private to junos_config module
6 open threads
Closes NAT-1223
Merge request reports
Activity
assigned to @mohammad.torkashvand
added 1 commit
- 98b4b3de - Add config_mode private to junos_config module
389 390 if isinstance(candidate, string_types): 391 candidate = candidate.split("\n") 392 393 # this is done to filter out `delete ...` statements which map to 394 # nothing in the config as that will cause an exception to be raised 395 if any((module.params["lines"], config_format == "set")): 396 candidate = filter_delete_statements(module, candidate) 397 kwargs["format"] = "text" 398 kwargs["action"] = "set" 399 400 return load_config(module, candidate, warnings, **kwargs) 401 402 403 @contextmanager 404 def safe_locked_config(module): @simone.spinelli I added this function and the original one is here. Actually I replaced all locked_config with my safe_locked_config
@contextmanager def locked_config(module): try: lock_configuration(module) yield finally: unlock_configuration(module)
Edited by Mohammad Torkashvand
requested review from @simone.spinelli
472 update=dict( 473 default="merge", 474 choices=["merge", "override", "replace", "update"], 475 ), 476 # deprecated replace in Ansible 2.3 477 replace=dict(type="bool"), 478 confirm=dict(default=0, type="int"), 479 comment=dict(default=DEFAULT_COMMENT), 480 confirm_commit=dict(type="bool", default=False), 481 check_commit=dict(type="bool", default=False), 482 # config operations 483 backup=dict(type="bool", default=False), 484 backup_options=dict(type="dict", options=backup_spec), 485 rollback=dict(type="int"), 486 zeroize=dict(default=False, type="bool"), 487 config_mode=dict(type='str', choices=['private'], required=False, default=None), 535 kwargs = {"comment": module.params["comment"]} 536 with safe_locked_config(module): 537 load_configuration(module, rollback=rollback_id) 538 commit_configuration(module, **kwargs) 539 if module._diff: 540 result["diff"] = {"prepared": diff} 541 result["changed"] = True 542 543 elif module.params["zeroize"]: 544 if commit: 545 zeroize(module) 546 result["changed"] = True 547 548 else: 549 if candidate: 550 with safe_locked_config(module): I replaced
locked_config
with mine safe_locked_config and did this everywhere in this fileEdited by Mohammad Torkashvand
283 from ansible.module_utils.six import string_types 284 from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.netconf import ( 285 exec_rpc, 286 ) 287 from ansible.module_utils.connection import ConnectionError 288 from ansible_collections.junipernetworks.junos.plugins.module_utils.network.junos.junos import ( 289 commit_configuration, 290 discard_changes, 291 get_configuration, 292 get_diff, 293 load_config, 294 load_configuration, 295 tostring, 296 get_connection, 297 lock_configuration, 298 unlock_configuration, - Comment on lines +297 to +298
these 2 imports are also me
Edited by Mohammad Torkashvand
If you mean this repo https://github.com/ansible-collections/junipernetworks.junos, Yes!
All clear after @mohammad.torkashvand walked me though.
mentioned in commit a3954f7e
Please register or sign in to reply