Skip to content
Snippets Groups Projects

Add config_mode private to junos_config module

Closes NAT-1223

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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):
  • 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):
  • 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,
  • Simone Spinelli approved this merge request

    approved this merge request

  • All clear after @mohammad.torkashvand walked me though.

  • mentioned in commit a3954f7e

  • Please register or sign in to reply
    Loading