Ejemplo n.º 1
0
    def run(self):
        os_version = (get_capabilities(
            self._module).get("device_info").get("network_os_version"))
        self.map_params_to_obj()
        self.map_obj_to_xml_rpc(os_version)

        return self._result
Ejemplo n.º 2
0
    def platform_facts(self):
        platform_facts = {}

        resp = get_capabilities(self.module)
        device_info = resp["device_info"]

        platform_facts["system"] = device_info["network_os"]

        for item in ("model", "image", "version", "platform", "hostname"):
            val = device_info.get("network_os_%s" % item)
            if val:
                platform_facts[item] = val

        platform_facts["api"] = resp["network_api"]
        platform_facts["python_version"] = platform.python_version()

        return platform_facts
Ejemplo n.º 3
0
    def platform_facts(self):
        platform_facts = {}

        resp = get_capabilities(self.module)
        device_info = resp['device_info']

        platform_facts['system'] = device_info['network_os']

        for item in ('model', 'image', 'version', 'platform', 'hostname'):
            val = device_info.get('network_os_%s' % item)
            if val:
                platform_facts[item] = val

        platform_facts['api'] = resp['network_api']
        platform_facts['python_version'] = platform.python_version()

        return platform_facts
Ejemplo n.º 4
0
def main():
    """ main entry point for module execution
    """
    element_spec = dict(
        dest=dict(
            type="str",
            choices=["host", "console", "monitor", "buffered", "file"],
        ),
        name=dict(type="str"),
        size=dict(type="int"),
        path=dict(type="str"),
        vrf=dict(type="str", default="default"),
        facility=dict(type="str", default="local7"),
        hostnameprefix=dict(type="str"),
        level=dict(
            type="str",
            default="debugging",
            aliases=["severity"],
            choices=[
                "emergencies",
                "alerts",
                "critical",
                "errors",
                "warning",
                "notifications",
                "informational",
                "debugging",
            ],
        ),
        state=dict(default="present", choices=["present", "absent"]),
    )

    aggregate_spec = deepcopy(element_spec)

    # remove default in aggregate spec, to handle common arguments
    remove_default_spec(aggregate_spec)

    mutually_exclusive = [("dest", "facility", "hostnameprefix")]

    required_if = [
        ("dest", "host", ["name"]),
        ("dest", "file", ["name"]),
        ("dest", "buffered", ["size"]),
        ("dest", "console", ["level"]),
        ("dest", "monitor", ["level"]),
    ]

    argument_spec = dict(aggregate=dict(
        type="list",
        elements="dict",
        options=aggregate_spec,
        mutually_exclusive=mutually_exclusive,
        required_if=required_if,
    ))

    argument_spec.update(element_spec)
    argument_spec.update(iosxr_argument_spec)

    module = AnsibleModule(
        argument_spec=argument_spec,
        mutually_exclusive=mutually_exclusive,
        required_if=required_if,
        supports_check_mode=True,
    )
    config_object = None
    if is_cliconf(module):
        config_object = CliConfiguration(module)
        os_version = get_os_version(module)
    elif is_netconf(module):
        config_object = NCConfiguration(module)
        os_version = (get_capabilities(module).get("device_info").get(
            "network_os_version"))

    if config_object:
        result = config_object.run(os_version)
    module.exit_json(**result)