From 9e8c09083036cd0a412509cb9eceb514d65256e1 Mon Sep 17 00:00:00 2001 From: acichon Date: Tue, 23 Apr 2024 16:06:20 +0200 Subject: [PATCH 01/18] initial work for templates --- plugins/doc_fragments/__init__.py | 0 plugins/doc_fragments/device_models.py | 47 +++++ .../feature_template_cisco_aaa.py | 154 ++++++++++++++ .../feature_template_cisco_banner.py | 30 +++ .../cisco_aaa.py | 72 +++++++ plugins/modules/feature_templates.py | 151 ++++++++++++++ plugins/modules/feature_templates_info.py | 107 ++++++++++ tools/feature_template_docs_generator.py | 62 ++++++ .../feature_template_module_args_generator.py | 197 ++++++++++++++++++ 9 files changed, 820 insertions(+) create mode 100644 plugins/doc_fragments/__init__.py create mode 100644 plugins/doc_fragments/device_models.py create mode 100644 plugins/doc_fragments/feature_template_cisco_aaa.py create mode 100644 plugins/doc_fragments/feature_template_cisco_banner.py create mode 100644 plugins/module_utils/feature_templates_definitions/cisco_aaa.py create mode 100644 plugins/modules/feature_templates.py create mode 100644 plugins/modules/feature_templates_info.py create mode 100644 tools/feature_template_docs_generator.py create mode 100644 tools/feature_template_module_args_generator.py diff --git a/plugins/doc_fragments/__init__.py b/plugins/doc_fragments/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/plugins/doc_fragments/device_models.py b/plugins/doc_fragments/device_models.py new file mode 100644 index 0000000..3bae409 --- /dev/null +++ b/plugins/doc_fragments/device_models.py @@ -0,0 +1,47 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +from enum import Enum +import yaml + +from catalystwan.utils.device_model import DeviceModel + + +enum_values_str = ', '.join(f'\"{model.value}\"' for model in DeviceModel) + + +with_list = f"[{enum_values_str}]" + +DOCUMENTATION = rf""" + options: + device_model: + description: + - Type of device for which to create the template. + type: str + required: true + choices: {with_list} + """ + +with open('plugins/doc_fragments/device_models.yml', 'w') as file: + file.write(DOCUMENTATION) + + +values = yaml.safe_load(with_list) + +class ModuleDocFragment(object): + DOCUMENTATION = rf""" + options: + device_models: + description: + - Type of device for which to create the template. + type: str + required: true + choices: {with_list} + """ \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_cisco_aaa.py b/plugins/doc_fragments/feature_template_cisco_aaa.py new file mode 100644 index 0000000..a92dcad --- /dev/null +++ b/plugins/doc_fragments/feature_template_cisco_aaa.py @@ -0,0 +1,154 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, annotations, division, print_function + +__metaclass__ = type + + +class ModuleDocFragment(object): + DOCUMENTATION = r''' +options: + cisco_aaa: + description: Cisco AAA Feature Template configuration. + type: dict + suboptions: + user: + description: + - List of user configurations + required: false + default: false + type: list + elements: dict + suboptions: + name: + description: + - The name of the user + required: true + default: null + type: str + password: + description: + - The password for the user + required: false + default: null + type: str + secret: + description: + - The secret for the user + required: false + default: null + type: str + privilege: + description: + - The privilege level for the user + required: false + default: null + type: str + pubkey_chain: + description: + - List of public keys for the user + required: false + default: [] + type: list + elements: str + authentication_group: + description: + - Whether to enable the authentication group + required: false + default: false + type: bool + accounting_group: + description: + - Whether to enable the accounting group + required: false + default: true + type: bool + radius: + description: + - List of Radius group configurations + required: false + default: null + type: list + elements: dict + suboptions: + group_name: + description: + - The name of the RADIUS group + required: true + default: null + type: str + vpn: + description: + - The VPN ID for the RADIUS group + required: true + default: null + type: str + source_interface: + description: + - The source interface for the RADIUS group + required: true + default: null + type: str + server: + description: + - The list of RADIUS servers for the group + required: false + default: [] + type: list + elements: str + domain_stripping: + description: + - The domain stripping configuration + required: false + default: null + type: str + port: + description: + - The port number for AAA + required: false + default: 1700 + type: str + tacacs: + description: + - List of TACACS group configurations + required: false + default: null + type: list + elements: dict + suboptions: + group_name: + description: + - The name of the TACACS+ group + required: true + default: null + type: str + vpn: + description: + - The VPN ID for the TACACS+ group + required: false + default: 0 + type: str + source_interface: + description: + - The source interface for the TACACS+ group + required: false + default: null + type: str + server: + description: + - The list of TACACS+ servers for the group + required: false + default: [] + type: list + elements: str + server_auth_order: + description: + - Authentication order to user access + required: false + default: local + type: str + ''' diff --git a/plugins/doc_fragments/feature_template_cisco_banner.py b/plugins/doc_fragments/feature_template_cisco_banner.py new file mode 100644 index 0000000..ec251fb --- /dev/null +++ b/plugins/doc_fragments/feature_template_cisco_banner.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, annotations, division, print_function + +__metaclass__ = type + + +class ModuleDocFragment(object): + DOCUMENTATION = r''' +options: + cisco_banner: + description: + - This module allows you to configure the login and message of the day (MOTD) banners on Cisco devices. + required: false + type: dict + suboptions: + login_banner: + description: + - The text to be set as the login banner. If set to None, the login banner will be removed. + type: str + required: false + motd_banner: + description: + - The text to be set as the MOTD banner. If set to None, the MOTD banner will be removed. + type: str + required: false + ''' diff --git a/plugins/module_utils/feature_templates_definitions/cisco_aaa.py b/plugins/module_utils/feature_templates_definitions/cisco_aaa.py new file mode 100644 index 0000000..c9d30d9 --- /dev/null +++ b/plugins/module_utils/feature_templates_definitions/cisco_aaa.py @@ -0,0 +1,72 @@ +cisco_aaa_definition = { 'cisco_aaa': { 'default': None, + 'options': { 'accounting_group': { 'default': True, + 'required': False, + 'type': 'bool'}, + 'authentication_group': { 'default': False, + 'required': False, + 'type': 'bool'}, + 'domain_stripping': { 'default': None, + 'required': False, + 'type': 'str'}, + 'port': { 'default': 1700, + 'required': False, + 'type': 'str'}, + 'radius': { 'default': None, + 'elements': 'dict', + 'options': { 'group_name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'server': { 'default': [ ], + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'source_interface': { 'default': None, + 'required': True, + 'type': 'str'}, + 'vpn': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'server_auth_order': { 'default': 'local', + 'required': False, + 'type': 'str'}, + 'tacacs': { 'default': None, + 'elements': 'dict', + 'options': { 'group_name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'server': { 'default': [ ], + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'source_interface': { 'default': None, + 'required': False, + 'type': 'str'}, + 'vpn': { 'default': 0, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'user': { 'default': False, + 'elements': 'dict', + 'options': { 'name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'password': { 'default': None, + 'required': False, + 'type': 'str'}, + 'privilege': { 'default': None, + 'required': False, + 'type': 'str'}, + 'pubkey_chain': { 'default': [ ], + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'secret': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}}, + 'required': False, + 'type': 'dict'}} diff --git a/plugins/modules/feature_templates.py b/plugins/modules/feature_templates.py new file mode 100644 index 0000000..cec168a --- /dev/null +++ b/plugins/modules/feature_templates.py @@ -0,0 +1,151 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +from catalystwan.utils.device_model import DeviceModel + +import pkgutil +import importlib + +def import_all_classes_from_library(library_name): + imported_classes = {} + + # Find the library's location and iterate through its modules + library_path = importlib.import_module(library_name).__path__ + for _, module_name, _ in pkgutil.iter_modules(library_path): + # Import the module + module = importlib.import_module(f'{library_name}.{module_name}') + + # Iterate through the module's attributes and import classes + for attribute_name in dir(module): + attribute = getattr(module, attribute_name) + if isinstance(attribute, type): # Check if it is a class + imported_classes[attribute_name] = attribute + + return imported_classes + +# Usage example: +# Let's say you want to import all classes from a library called 'external_library' +all_classes = import_all_classes_from_library('catalystwan.api.templates.models') +all_device_models = [device_model.value for device_model in DeviceModel] + +DOCUMENTATION = r""" +--- +module: vmanage_feature_template + +short_description: Manage feature templates for Cisco vManage SD-WAN + +version_added: "1.0.0" + +description: + - This module can be used to create, modify, and delete feature templates in Cisco vManage SD-WAN. + - The feature template configuration is defined via Python Pydantic models. + +options: + template_name: + description: + - The name for the Feature Template. + type: str + required: true + template_description: + description: + - Description for the Feature Template. + type: str + required: true + device_models: + description: + - The model of the device. + required: true + type: list + default: [] + elements: str + choices: + - "vmanage" + - "vedge-cloud" + - "vsmart" +extends_documentation_fragment: + - cisco.catalystwan.feature_template_cisco_aaa + - cisco.catalystwan.feature_template_cisco_banner +author: + - Arkadiusz Cichon (acichon@cisco.com) +""" + +from typing import Optional, Dict +from pydantic import Field + +from catalystwan.api.template_api import FeatureTemplate +from catalystwan.dataclasses import FeatureTemplateInfo +from catalystwan.typed_list import DataSequence +from catalystwan.utils.creation_tools import asdict +from catalystwan.utils.device_model import DeviceModel +from catalystwan.api.templates.models.supported import available_models + +from ..module_utils.result import ModuleResult +from ..module_utils.vmanage_module import AnsibleCatalystwanModule +from ..module_utils.feature_templates_definitions.cisco_aaa import cisco_aaa_definition + + +class ExtendedModuleResult(ModuleResult): + templates_info: Optional[Dict] = Field(default={}) + + +def run_module(): + module_args = dict( + template_name=dict(type="str", default=None, required=True), + template_description=dict(type="str", default=None, required=True), + device_models=dict( + type="list", + required=True, + choices=[device_model.value for device_model in DeviceModel]), + **cisco_aaa_definition, + debug=dict(type="bool", default=False), # if to dump templates payload + ) + result = ExtendedModuleResult() + result.state = None + result.response = None + + module = AnsibleCatalystwanModule(argument_spec=module_args) + + # Code for checking if template name exists already, if yes, do we need some force method or we just inform user and exit? + + for model_name, model_module in available_models.items(): + if model_name in module.params.keys(): + # Perform action with template + template = model_module( + template_name=module.params.get("template_name"), + template_description=module.params.get("template_description"), + device_models=module.params.get("device_models"), + **module.params_without_none_values[model_name]) + + module.logger.info(f"Prepared template for sending to vManage: \n{template}\n") + + module.session.api.templates.create(template=template, debug=module.params.get("debug") + result.changed = True + result.msg = f"Created template model for {model_name}: {template}" + + # all_templates: DataSequence[FeatureTemplateInfo] = module.get_response_safely(module.session.api.templates.get, template=FeatureTemplate) + + # if filters: + # filtered_templates = all_templates.filter(**filters) + # if filtered_templates: + # module.logger.info(f"All Feature Templates filtered with filters: {filters}:\n{filtered_templates}") + # result.msg = "Succesfully got all requested Feature Templates Info from vManage" + # result.templates_info = [asdict(template) for template in filtered_templates] + # else: + # module.logger.warning(msg=f"Feature templates filtered with `{filters}` not present.") + # result.msg = f"Feature templates filtered with `{filters}` not present on vManage." + # else: + # result.msg = "Succesfully got all Feature Templates Info from vManage" + # result.templates_info = [asdict(template) for template in all_templates] + + module.exit_json(**result.model_dump(mode="json")) + + +def main(): + run_module() + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/feature_templates_info.py b/plugins/modules/feature_templates_info.py new file mode 100644 index 0000000..4c262a4 --- /dev/null +++ b/plugins/modules/feature_templates_info.py @@ -0,0 +1,107 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: feature_templates_info +short_description: Get information about Feature Templates on vManage. +version_added: "0.1.0" +description: + - This module allows you to get and filter Feature Templates from vManage. +options: + filters: + description: + - A dictionary of filters used to select devices for module action. + type: dict + required: false +author: + - Arkadiusz Cichon (acichon@cisco.com) +extends_documentation_fragment: + - cisco.catalystwan.manager_authentication +notes: + - Ensure that the provided credentials have sufficient permissions to manage templates and devices in vManage. +""" + +EXAMPLES = r""" +- name: Attach default CLI template to the specified devices + cisco.catalystwan.feature_templates_info: + filters: + name: "trial-template" +""" + +RETURN = r""" +template_info: + description: A dictionary of templates with the key as template name and value as device hostname. + type: dict + returned: on success + sample: | + { + "Default_device1": "device1", + "Default_device2": "device2" + } +msg: + description: Messages that indicate actions taken or any errors that have occurred. + type: str + returned: always + sample: "Successfully fetched information about template: trial-template" +changed: + description: Indicates whether any change was made. + type: bool + returned: always + sample: false +""" +from typing import Optional, Dict +from pydantic import Field + +from catalystwan.api.template_api import FeatureTemplate +from catalystwan.dataclasses import FeatureTemplateInfo +from catalystwan.typed_list import DataSequence +from catalystwan.utils.creation_tools import asdict + +from ..module_utils.result import ModuleResult +from ..module_utils.vmanage_module import AnsibleCatalystwanModule + + +class ExtendedModuleResult(ModuleResult): + templates_info: Optional[Dict] = Field(default={}) + + +def run_module(): + module_args = dict( + filters=dict(type="dict", default=None, required=False), + ) + result = ExtendedModuleResult() + result.state = None + result.response = None + + module = AnsibleCatalystwanModule(argument_spec=module_args) + + filters = module.params.get('filters') + + all_templates: DataSequence[FeatureTemplateInfo] = module.get_response_safely(module.session.api.templates.get, template=FeatureTemplate) + + if filters: + filtered_templates = all_templates.filter(**filters) + if filtered_templates: + module.logger.info(f"All Feature Templates filtered with filters: {filters}:\n{filtered_templates}") + result.msg = "Succesfully got all requested Feature Templates Info from vManage" + result.templates_info = [asdict(template) for template in filtered_templates] + else: + module.logger.warning(msg=f"Feature templates filtered with `{filters}` not present.") + result.msg = f"Feature templates filtered with `{filters}` not present on vManage." + else: + result.msg = "Succesfully got all Feature Templates Info from vManage" + result.templates_info = [asdict(template) for template in all_templates] + + module.exit_json(**result.model_dump(mode="json")) + + +def main(): + run_module() + + +if __name__ == "__main__": + main() diff --git a/tools/feature_template_docs_generator.py b/tools/feature_template_docs_generator.py new file mode 100644 index 0000000..cd0f54a --- /dev/null +++ b/tools/feature_template_docs_generator.py @@ -0,0 +1,62 @@ +import inspect + +from pydantic import BaseModel +from enum import Enum +from typing import get_type_hints, List, Optional + +# Import the Pydantic models (assuming they are defined in the same file or are accessible from the script) +from catalystwan.api.templates.models.cisco_aaa_model import CiscoAAAModel + +# Your Pydantic models should be defined here (as provided in your example) + +# Function to convert a Pydantic model to YAML documentation +def model_to_yaml_docs(model_class, depth=0, is_suboption=False): + indent = ' ' * depth + # type_hints = get_type_hints(model_class) + + # Begin the options block + docs = f"{indent}options:\n" if not is_suboption else "" + + for field_name, field_type in model_class.__annotations__.items(): + default_value = getattr(model_class, field_name, None) + is_required = default_value is None and not issubclass(field_type, (Optional, List)) + is_list = issubclass(field_type, List) + field_info = model_class.__fields__[field_name] + + # Skip if excluded + if field_info.field_info.exclude: + continue + + description = field_info.field_info.description + docs += f"{indent}- name: {field_name}\n" + docs += f"{indent} description: {description}\n" + docs += f"{indent} type: {'list' if is_list else 'dict' if issubclass(field_type, BaseModel) else 'str'}\n" + + if is_required: + docs += f"{indent} required: True\n" + else: + docs += f"{indent} required: False\n" + if default_value is not None and not is_list: + docs += f"{indent} default: {default_value}\n" + + if issubclass(field_type, BaseModel): + docs += f"{indent} suboptions:\n" + docs += model_to_yaml_docs(field_type, depth=depth + 2, is_suboption=True) + elif is_list: + element_type = next(iter(field_type.__args__), None) + if issubclass(element_type, BaseModel): + docs += f"{indent} elements: dict\n" + docs += f"{indent} suboptions:\n" + docs += model_to_yaml_docs(element_type, depth=depth + 2, is_suboption=True) + elif issubclass(element_type, (str, int, Enum)): + docs += f"{indent} elements: {'str' if issubclass(element_type, (str, Enum)) else 'int'}\n" + + if issubclass(field_type, Enum): + choices = [e.value for e in field_type] + docs += f"{indent} choices: {choices}\n" + + return docs + +# Generate the YAML documentation for the CiscoAAAModel +yaml_docs = model_to_yaml_docs(CiscoAAAModel, depth=1) +print(yaml_docs) diff --git a/tools/feature_template_module_args_generator.py b/tools/feature_template_module_args_generator.py new file mode 100644 index 0000000..a0736c4 --- /dev/null +++ b/tools/feature_template_module_args_generator.py @@ -0,0 +1,197 @@ +import yaml + +yaml_data = """ +options: + cisco_aaa: + description: Cisco AAA Feature Template configuration. + type: dict + suboptions: + user: + description: + - List of user configurations + required: false + default: false + type: list + elements: dict + suboptions: + name: + description: + - The name of the user + required: true + default: null + type: str + password: + description: + - The password for the user + required: false + default: null + type: str + secret: + description: + - The secret for the user + required: false + default: null + type: str + privilege: + description: + - The privilege level for the user + required: false + default: null + type: str + pubkey_chain: + description: + - List of public keys for the user + required: false + default: [] + type: list + elements: str + authentication_group: + description: + - Whether to enable the authentication group + required: false + default: false + type: bool + accounting_group: + description: + - Whether to enable the accounting group + required: false + default: true + type: bool + radius: + description: + - List of Radius group configurations + required: false + default: null + type: list + elements: dict + suboptions: + group_name: + description: + - The name of the RADIUS group + required: true + default: null + type: str + vpn: + description: + - The VPN ID for the RADIUS group + required: true + default: null + type: str + source_interface: + description: + - The source interface for the RADIUS group + required: true + default: null + type: str + server: + description: + - The list of RADIUS servers for the group + required: false + default: [] + type: list + elements: str + domain_stripping: + description: + - The domain stripping configuration + required: false + default: null + type: str + port: + description: + - The port number for AAA + required: false + default: 1700 + type: str + tacacs: + description: + - List of TACACS group configurations + required: false + default: null + type: list + elements: dict + suboptions: + group_name: + description: + - The name of the TACACS+ group + required: true + default: null + type: str + vpn: + description: + - The VPN ID for the TACACS+ group + required: false + default: 0 + type: str + source_interface: + description: + - The source interface for the TACACS+ group + required: false + default: null + type: str + server: + description: + - The list of TACACS+ servers for the group + required: false + default: [] + type: list + elements: str + server_auth_order: + description: + - Authentication order to user access + required: false + default: local + type: str +""" + +# Function to parse YAML data and return the argument spec +def generate_arg_spec(yaml_data): + # Load the YAML data + data = yaml.safe_load(yaml_data) + + # Function to recursively parse the options + def parse_options(options): + arg_spec = {} + for opt_name, opt_info in options.items(): + if 'type' in opt_info: + # Basic fields + arg_spec[opt_name] = { + 'type': opt_info['type'], + 'required': opt_info.get('required', False), + 'default': opt_info.get('default', None) + } + + # Special case for 'list' type + if opt_info['type'] == 'list' and 'elements' in opt_info: + arg_spec[opt_name]['elements'] = opt_info['elements'] + + # Recursively handle suboptions if present + if 'suboptions' in opt_info: + arg_spec[opt_name]['options'] = parse_options(opt_info['suboptions']) + + return arg_spec + + # Get the top-level options and parse them + options = data.get('options', {}) + return parse_options(options) + +# Generate the argument spec +arg_spec = generate_arg_spec(yaml_data) + +# Define the variable name +variable_name = "cisco_aaa_definition" + +# Write the generated dictionary to a Python file +output_file = f"./plugins/module_args/cisco_aaa.py" +with open(output_file, 'w') as file: + file.write(f"{variable_name} = ") + # Use pformat to get a string representation of the dictionary + from pprint import pformat + file.write(pformat(arg_spec, indent=2, width=80)) + file.write("\n") + +print(f"Argument spec saved to {output_file} under the variable {variable_name}") + + +# Printing the generated code in a Python syntax +import pprint +pprint.pprint(arg_spec) \ No newline at end of file From b48b0bdac0cb2b8e39db123727c1c5485a8093b6 Mon Sep 17 00:00:00 2001 From: acichon Date: Thu, 25 Apr 2024 15:18:22 +0200 Subject: [PATCH 02/18] next step in modules generation --- plugins/doc_fragments/device_models.py | 47 - .../device_models_feature_template.py | 88 ++ .../feature_template_cisco_aaa.py | 382 ++++-- .../feature_template_cisco_banner.py | 41 +- .../feature_template_cisco_bfd.py | 100 ++ .../feature_template_cisco_logging.py | 195 +++ .../feature_template_cisco_ntp.py | 109 ++ .../feature_template_cisco_omp.py | 172 +++ .../feature_template_cisco_ospf.py | 325 +++++ ..._template_cisco_secure_internet_gateway.py | 490 +++++++ .../feature_template_cisco_snmp.py | 225 ++++ .../feature_template_cisco_system.py | 929 +++++++++++++ .../feature_template_cisco_vpn.py | 987 ++++++++++++++ .../feature_template_cisco_vpn_interface.py | 1179 +++++++++++++++++ .../feature_template_omp_vsmart.py | 81 ++ .../feature_template_security_vsmart.py | 35 + .../feature_template_system_vsmart.py | 557 ++++++++ .../feature_templates/cisco_aaa.py | 80 ++ .../feature_templates/cisco_banner.py | 11 + .../feature_templates/cisco_bfd.py | 25 + .../feature_templates/cisco_logging.py | 54 + .../feature_templates/cisco_ntp.py | 37 + .../feature_templates/cisco_omp.py | 41 + .../feature_templates/cisco_ospf.py | 94 ++ .../cisco_secure_internet_gateway.py | 104 ++ .../feature_templates/cisco_snmp.py | 81 ++ .../feature_templates/cisco_system.py | 128 ++ .../feature_templates/cisco_vpn.py | 326 +++++ .../feature_templates/cisco_vpn_interface.py | 272 ++++ .../feature_templates/omp_vsmart.py | 19 + .../feature_templates/security_vsmart.py | 11 + .../feature_templates/system_vsmart.py | 29 + .../cisco_aaa.py | 72 - plugins/modules/feature_templates.py | 179 ++- tools/feature_template_docs_generator.py | 62 - .../feature_template_module_args_generator.py | 197 --- utils/ft_device_model.j2 | 26 + utils/ft_docs_template.j2 | 16 + utils/ft_generator.py | 210 +++ 39 files changed, 7410 insertions(+), 606 deletions(-) delete mode 100644 plugins/doc_fragments/device_models.py create mode 100644 plugins/doc_fragments/device_models_feature_template.py create mode 100644 plugins/doc_fragments/feature_template_cisco_bfd.py create mode 100644 plugins/doc_fragments/feature_template_cisco_logging.py create mode 100644 plugins/doc_fragments/feature_template_cisco_ntp.py create mode 100644 plugins/doc_fragments/feature_template_cisco_omp.py create mode 100644 plugins/doc_fragments/feature_template_cisco_ospf.py create mode 100644 plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py create mode 100644 plugins/doc_fragments/feature_template_cisco_snmp.py create mode 100644 plugins/doc_fragments/feature_template_cisco_system.py create mode 100644 plugins/doc_fragments/feature_template_cisco_vpn.py create mode 100644 plugins/doc_fragments/feature_template_cisco_vpn_interface.py create mode 100644 plugins/doc_fragments/feature_template_omp_vsmart.py create mode 100644 plugins/doc_fragments/feature_template_security_vsmart.py create mode 100644 plugins/doc_fragments/feature_template_system_vsmart.py create mode 100644 plugins/module_utils/feature_templates/cisco_aaa.py create mode 100644 plugins/module_utils/feature_templates/cisco_banner.py create mode 100644 plugins/module_utils/feature_templates/cisco_bfd.py create mode 100644 plugins/module_utils/feature_templates/cisco_logging.py create mode 100644 plugins/module_utils/feature_templates/cisco_ntp.py create mode 100644 plugins/module_utils/feature_templates/cisco_omp.py create mode 100644 plugins/module_utils/feature_templates/cisco_ospf.py create mode 100644 plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py create mode 100644 plugins/module_utils/feature_templates/cisco_snmp.py create mode 100644 plugins/module_utils/feature_templates/cisco_system.py create mode 100644 plugins/module_utils/feature_templates/cisco_vpn.py create mode 100644 plugins/module_utils/feature_templates/cisco_vpn_interface.py create mode 100644 plugins/module_utils/feature_templates/omp_vsmart.py create mode 100644 plugins/module_utils/feature_templates/security_vsmart.py create mode 100644 plugins/module_utils/feature_templates/system_vsmart.py delete mode 100644 plugins/module_utils/feature_templates_definitions/cisco_aaa.py delete mode 100644 tools/feature_template_docs_generator.py delete mode 100644 tools/feature_template_module_args_generator.py create mode 100644 utils/ft_device_model.j2 create mode 100644 utils/ft_docs_template.j2 create mode 100644 utils/ft_generator.py diff --git a/plugins/doc_fragments/device_models.py b/plugins/doc_fragments/device_models.py deleted file mode 100644 index 3bae409..0000000 --- a/plugins/doc_fragments/device_models.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# Copyright 2024 Cisco Systems, Inc. and its affiliates -# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - - -from enum import Enum -import yaml - -from catalystwan.utils.device_model import DeviceModel - - -enum_values_str = ', '.join(f'\"{model.value}\"' for model in DeviceModel) - - -with_list = f"[{enum_values_str}]" - -DOCUMENTATION = rf""" - options: - device_model: - description: - - Type of device for which to create the template. - type: str - required: true - choices: {with_list} - """ - -with open('plugins/doc_fragments/device_models.yml', 'w') as file: - file.write(DOCUMENTATION) - - -values = yaml.safe_load(with_list) - -class ModuleDocFragment(object): - DOCUMENTATION = rf""" - options: - device_models: - description: - - Type of device for which to create the template. - type: str - required: true - choices: {with_list} - """ \ No newline at end of file diff --git a/plugins/doc_fragments/device_models_feature_template.py b/plugins/doc_fragments/device_models_feature_template.py new file mode 100644 index 0000000..3d30451 --- /dev/null +++ b/plugins/doc_fragments/device_models_feature_template.py @@ -0,0 +1,88 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" +options: + device_models: + description: + - Defines the SD-WAN device type for template application. + required: true + type: list + default: [] + elements: str + choices: + - "vsmart" + - "vedge-cloud" + - "vmanage" + - "vedge-ISR1100-6G" + - "vedge-ISR1100X-6G" + - "vedge-ISR1100-4G" + - "vedge-ISR1100X-4G" + - "vedge-ISR1100-4GLTE" + - "vedge-1000" + - "vedge-2000" + - "vedge-100" + - "vedge-100-B" + - "vedge-100-WM" + - "vedge-100-M" + - "vedge-5000" + - "vedge-IR-1101" + - "vedge-ESR-6300" + - "vedge-IR-1821" + - "vedge-IR-1831" + - "vedge-IR-1833" + - "vedge-IR-1835" + - "vedge-ASR-1001-X" + - "vedge-ASR-1002-X" + - "vedge-ASR-1002-HX" + - "vedge-ASR-1001-HX" + - "vedge-C8500L-8G4X" + - "vedge-C8500-12X4QC" + - "vedge-C8500-12X" + - "vedge-C8500L-8S4X" + - "vedge-ASR-1006-X" + - "vedge-C8500-20X6C" + - "vedge-CSR-1000v" + - "vedge-C8000V" + - "vedge-ISR-4331" + - "vedge-ISR-4431" + - "vedge-ISR-4461" + - "vedge-ISR-4451-X" + - "vedge-ISR-4321" + - "vedge-ISR-4351" + - "vedge-ISR-4221" + - "vedge-ISR-4221X" + - "vedge-C1111-8PW" + - "vedge-C1111-8PLTELAW" + - "vedge-C1111-8PLTEEAW" + - "vedge-C1113-8PMLTEEA" + - "vedge-C1116-4P" + - "vedge-C1116-4PLTEEA" + - "vedge-C1117-4P" + - "vedge-C1117-4PM" + - "vedge-C1117-4PLTEEA" + - "vedge-C1111-8PLTELA" + - "vedge-C1111-8PLTEEA" + - "vedge-C1121-8PLTEPW" + - "vedge-C1121-8PLTEP" + - "vedge-C1121X-8PLTEP" + - "vedge-C1111-4PLTEEA" + - "vedge-C1161X-8PLTEP" + - "vedge-C8300-2N2S-6T" + - "vedge-C8300-1N1S-6T" + - "vedge-C8300-1N1S-4T2X" + - "vedge-C8300-2N2S-4T2X" + - "vedge-C8200-1N-4T" + - "vedge-C8200L-1N-4T" + - "vedge-ISRv" + """ diff --git a/plugins/doc_fragments/feature_template_cisco_aaa.py b/plugins/doc_fragments/feature_template_cisco_aaa.py index a92dcad..5d91fb7 100644 --- a/plugins/doc_fragments/feature_template_cisco_aaa.py +++ b/plugins/doc_fragments/feature_template_cisco_aaa.py @@ -4,151 +4,249 @@ # Copyright 2024 Cisco Systems, Inc. and its affiliates # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) -from __future__ import absolute_import, annotations, division, print_function +# This file is autogenerated by `utils/feature_template_docs_generator.py` -__metaclass__ = type + +from __future__ import annotations class ModuleDocFragment(object): - DOCUMENTATION = r''' + DOCUMENTATION = r""" options: - cisco_aaa: - description: Cisco AAA Feature Template configuration. - type: dict - suboptions: - user: - description: - - List of user configurations - required: false - default: false - type: list - elements: dict - suboptions: - name: - description: - - The name of the user - required: true - default: null - type: str - password: - description: - - The password for the user - required: false - default: null - type: str - secret: - description: - - The secret for the user - required: false - default: null - type: str - privilege: - description: - - The privilege level for the user - required: false - default: null - type: str - pubkey_chain: - description: - - List of public keys for the user - required: false - default: [] - type: list - elements: str - authentication_group: - description: - - Whether to enable the authentication group - required: false - default: false - type: bool - accounting_group: - description: - - Whether to enable the accounting group - required: false - default: true - type: bool - radius: - description: - - List of Radius group configurations - required: false - default: null - type: list - elements: dict - suboptions: - group_name: - description: - - The name of the RADIUS group - required: true - default: null - type: str - vpn: - description: - - The VPN ID for the RADIUS group - required: true - default: null - type: str - source_interface: - description: - - The source interface for the RADIUS group - required: true - default: null - type: str - server: - description: - - The list of RADIUS servers for the group - required: false - default: [] - type: list - elements: str - domain_stripping: - description: - - The domain stripping configuration - required: false - default: null - type: str - port: - description: - - The port number for AAA - required: false - default: 1700 - type: str - tacacs: - description: - - List of TACACS group configurations - required: false - default: null - type: list - elements: dict + cisco_aaa: + description: Cisco AAA Feature Template configuration + type: dict suboptions: - group_name: - description: - - The name of the TACACS+ group - required: true - default: null - type: str - vpn: - description: - - The VPN ID for the TACACS+ group - required: false - default: 0 - type: str - source_interface: - description: - - The source interface for the TACACS+ group - required: false - default: null - type: str - server: - description: - - The list of TACACS+ servers for the group - required: false - default: [] - type: list - elements: str - server_auth_order: - description: - - Authentication order to user access - required: false - default: local - type: str - ''' + user: + description: + - List of user configurations + required: false + default: null + type: list + elements: dict + suboptions: + name: + description: + - The name of the user + required: true + default: null + type: str + password: + description: + - The password for the user + required: false + default: null + type: str + secret: + description: + - The secret for the user + required: false + default: null + type: str + privilege: + description: + - The privilege level for the user + required: false + default: null + type: str + pubkey_chain: + description: + - List of public keys for the user + required: false + default: [] + type: list + elements: str + authentication_group: + description: + - Whether to enable the authentication group + required: false + default: null + type: bool + accounting_group: + description: + - Whether to enable the accounting group + required: false + default: null + type: bool + radius: + description: + - List of Radius group configurations + required: false + default: null + type: list + elements: dict + suboptions: + group_name: + description: + - The name of the RADIUS group + required: true + default: null + type: str + vpn: + description: + - The VPN ID for the RADIUS group + required: true + default: null + type: str + source_interface: + description: + - The source interface for the RADIUS group + required: true + default: null + type: str + server: + description: + - The list of RADIUS servers for the group + required: false + default: [] + type: list + elements: dict + suboptions: + address: + description: + - The IP address or hostname of the RADIUS server + required: true + default: null + type: str + auth_port: + description: + - The authentication port for the RADIUS server + required: false + default: null + type: str + acct_port: + description: + - The accounting port for the RADIUS server + required: false + default: null + type: str + timeout: + description: + - The timeout period in seconds for the RADIUS server + required: false + default: null + type: str + retransmit: + description: + - The number of retransmit attempts for the RADIUS + server + required: false + default: null + type: str + key: + description: + - The key for the RADIUS server + required: true + default: null + type: str + secret_key: + description: + - The secret key for the RADIUS server + required: false + default: null + type: str + key_enum: + description: + - The key enumeration for the RADIUS server + required: false + default: null + type: str + key_type: + description: + - The key type for the RADIUS server + required: false + default: null + type: str + domain_stripping: + description: + - The domain stripping configuration + required: false + default: null + type: str + choices: + - 'yes' + - 'no' + - right-to-left + port: + description: + - The port number for AAA + required: false + default: null + type: str + tacacs: + description: + - List of TACACS group configurations + required: false + default: null + type: list + elements: dict + suboptions: + group_name: + description: + - The name of the TACACS+ group + required: true + default: null + type: str + vpn: + description: + - The VPN ID for the TACACS+ group + required: false + default: null + type: str + source_interface: + description: + - The source interface for the TACACS+ group + required: false + default: null + type: str + server: + description: + - The list of TACACS+ servers for the group + required: false + default: [] + type: list + elements: dict + suboptions: + address: + description: + - The IP address or hostname of the TACACS+ server + required: true + default: null + type: str + port: + description: + - The port for the TACACS+ server + required: false + default: null + type: str + timeout: + description: + - The timeout period in seconds for the TACACS+ server + required: false + default: null + type: str + key: + description: + - The key for the TACACS+ server + required: true + default: null + type: str + secret_key: + description: + - The secret key for the TACACS+ server + required: false + default: null + type: str + key_enum: + description: + - The key enumeration for the TACACS+ server + required: false + default: null + type: str + server_auth_order: + description: + - Authentication order to user access + required: false + default: null + type: str + """ diff --git a/plugins/doc_fragments/feature_template_cisco_banner.py b/plugins/doc_fragments/feature_template_cisco_banner.py index ec251fb..458aea4 100644 --- a/plugins/doc_fragments/feature_template_cisco_banner.py +++ b/plugins/doc_fragments/feature_template_cisco_banner.py @@ -1,30 +1,33 @@ +#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright 2024 Cisco Systems, Inc. and its affiliates # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) -from __future__ import absolute_import, annotations, division, print_function +# This file is autogenerated by `utils/feature_template_docs_generator.py` -__metaclass__ = type + +from __future__ import annotations class ModuleDocFragment(object): - DOCUMENTATION = r''' + DOCUMENTATION = r""" options: cisco_banner: - description: - - This module allows you to configure the login and message of the day (MOTD) banners on Cisco devices. - required: false - type: dict - suboptions: - login_banner: - description: - - The text to be set as the login banner. If set to None, the login banner will be removed. - type: str - required: false - motd_banner: - description: - - The text to be set as the MOTD banner. If set to None, the MOTD banner will be removed. - type: str - required: false - ''' + description: Cisco Banner configuration for login and message of the day (MOTD) + type: dict + suboptions: + login_banner: + description: + - The login banner text displayed before authentication + required: false + default: null + type: str + motd_banner: + description: + - The message of the day (MOTD) banner text displayed after successful + authentication + required: false + default: null + type: str + """ diff --git a/plugins/doc_fragments/feature_template_cisco_bfd.py b/plugins/doc_fragments/feature_template_cisco_bfd.py new file mode 100644 index 0000000..1568fa2 --- /dev/null +++ b/plugins/doc_fragments/feature_template_cisco_bfd.py @@ -0,0 +1,100 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" +options: + cisco_bfd: + description: Cisco Bidirectional Forwarding Detection (BFD) configuration + type: dict + suboptions: + multiplier: + description: + - The default BFD multiplier for all colors + required: false + default: null + type: str + poll_interval: + description: + - The BFD poll interval in milliseconds + required: false + default: null + type: str + default_dscp: + description: + - The default DSCP value for BFD packets + required: false + default: null + type: str + color: + description: + - List of color-specific BFD configurations + required: false + default: null + type: list + elements: dict + suboptions: + color: + description: + - The color of the BFD session, representing various transport + types + required: true + default: null + type: str + choices: + - default + - mpls + - metro-ethernet + - biz-internet + - public-internet + - lte + - 3g + - red + - green + - blue + - gold + - silver + - bronze + - custom1 + - custom2 + - custom3 + - private1 + - private2 + - private3 + - private4 + - private5 + - private6 + hello_interval: + description: + - The BFD hello interval in milliseconds + required: false + default: null + type: str + multiplier: + description: + - The BFD multiplier for the color + required: false + default: null + type: str + pmtu_discovery: + description: + - Whether to enable Path MTU Discovery + required: false + default: null + type: str + dscp: + description: + - The DSCP value used for BFD packets + required: false + default: null + type: str + """ diff --git a/plugins/doc_fragments/feature_template_cisco_logging.py b/plugins/doc_fragments/feature_template_cisco_logging.py new file mode 100644 index 0000000..7fed9ac --- /dev/null +++ b/plugins/doc_fragments/feature_template_cisco_logging.py @@ -0,0 +1,195 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" +options: + cisco_logging: + description: Cisco Logging Feature Template configuration + type: dict + suboptions: + enable: + description: + - Whether logging to disk is enabled + required: false + default: null + type: str + size: + description: + - The maximum file size for the log file + required: false + default: null + type: str + rotate: + description: + - The number of log files to maintain before rotating + required: false + default: null + type: str + tls_profile: + description: + - List of TLS profiles configurations + required: false + default: null + type: list + elements: dict + suboptions: + profile: + description: + - The name of the TLS profile + required: true + default: null + type: str + version: + description: + - The TLS version + required: false + default: TLSv1.1 + type: str + choices: + - TLSv1.1 + - TLSv1.2 + auth_type: + description: + - The authentication type for the TLS connection + required: true + default: null + type: str + choices: + - Server + - Mutual + ciphersuite_list: + description: + - The list of ciphersuites for the TLS connection + required: false + default: null + type: list + elements: str + server: + description: + - List of server configurations for logging + required: false + default: null + type: list + elements: dict + suboptions: + name: + description: + - The name of the server + required: true + default: null + type: str + vpn: + description: + - The VPN ID for the server + required: true + default: null + type: str + source_interface: + description: + - The source interface for the server + required: false + default: null + type: str + priority: + description: + - The priority level for logging messages + required: false + default: information + type: str + choices: + - information + - debugging + - notice + - warn + - error + - critical + - alert + - emergency + enable_tls: + description: + - Whether to enable TLS encryption + required: false + default: null + type: str + custom_profile: + description: + - Whether to use a custom TLS profile + required: false + default: null + type: str + profile: + description: + - The custom TLS profile to use + required: false + default: null + type: str + ipv6_server: + description: + - List of IPv6 server configurations for logging + required: false + default: null + type: list + elements: dict + suboptions: + name: + description: + - The name of the IPv6 server + required: true + default: null + type: str + vpn: + description: + - The VPN ID for the IPv6 server + required: true + default: null + type: str + source_interface: + description: + - The source interface for the IPv6 server + required: false + default: null + type: str + priority: + description: + - The priority level for logging messages to the IPv6 server + required: false + default: information + type: str + choices: + - information + - debugging + - notice + - warn + - error + - critical + - alert + - emergency + enable_tls: + description: + - Whether to enable TLS encryption for the IPv6 server + required: false + default: null + type: str + custom_profile: + description: + - Whether to use a custom TLS profile for the IPv6 server + required: false + default: null + type: str + profile: + description: + - The custom TLS profile to use for the IPv6 server + required: false + default: null + type: str + """ diff --git a/plugins/doc_fragments/feature_template_cisco_ntp.py b/plugins/doc_fragments/feature_template_cisco_ntp.py new file mode 100644 index 0000000..f76477e --- /dev/null +++ b/plugins/doc_fragments/feature_template_cisco_ntp.py @@ -0,0 +1,109 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" +options: + cisco_ntp: + description: Cisco NTP Feature Template configuration + type: dict + suboptions: + server: + description: + - List of NTP servers + required: false + default: [] + type: list + elements: dict + suboptions: + name: + description: + - The hostname or IP address of the NTP server + required: true + default: null + type: str + key: + description: + - The identifier for the authentication key + required: true + default: null + type: str + vpn: + description: + - The VPN ID associated with the NTP server + required: true + default: null + type: str + version: + description: + - The NTP version used + required: true + default: null + type: str + source_interface: + description: + - The source interface for NTP messages + required: false + default: null + type: str + prefer: + description: + - Whether this server is preferred over others + required: true + default: null + type: str + authentication: + description: + - List of authentication keys + required: false + default: null + type: list + elements: dict + suboptions: + number: + description: + - The authentication key number + required: true + default: null + type: str + md5: + description: + - The MD5 hash used for authentication + required: true + default: null + type: str + trusted: + description: + - List of trusted key numbers + required: false + default: null + type: list + elements: str + enable: + description: + - Whether the device is an NTP master + required: false + default: null + type: str + stratum: + description: + - The stratum level if the device is an NTP master + required: false + default: null + type: str + source: + description: + - The source interface for NTP messages if the device is an NTP master + required: false + default: null + type: str + """ diff --git a/plugins/doc_fragments/feature_template_cisco_omp.py b/plugins/doc_fragments/feature_template_cisco_omp.py new file mode 100644 index 0000000..2ab3c0f --- /dev/null +++ b/plugins/doc_fragments/feature_template_cisco_omp.py @@ -0,0 +1,172 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" +options: + cisco_omp: + description: Configuration settings for the Cisco Overlay Management Protocol + (OMP) feature template. + type: dict + suboptions: + graceful_restart: + description: + - Enable or disable graceful restart for OMP. + required: false + default: null + type: str + overlay_as: + description: + - The autonomous system number used for the overlay. + required: false + default: null + type: str + send_path_limit: + description: + - The maximum number of paths that can be sent for each prefix. + required: false + default: null + type: str + ecmp_limit: + description: + - The maximum number of equal-cost multi-path routes. + required: false + default: null + type: str + shutdown: + description: + - Enable or disable the shutdown of OMP. + required: false + default: null + type: str + omp_admin_distance_ipv4: + description: + - The administrative distance for IPv4 routes learned via OMP. + required: false + default: null + type: str + omp_admin_distance_ipv6: + description: + - The administrative distance for IPv6 routes learned via OMP. + required: false + default: null + type: str + advertisement_interval: + description: + - The interval between sending unsolicited OMP route advertisements. + required: false + default: null + type: str + graceful_restart_timer: + description: + - The timer for graceful restart, specifying the period during which + peerings are preserved. + required: false + default: null + type: str + eor_timer: + description: + - End-of-RIB (EOR) timer which indicates stability of the route table. + required: false + default: null + type: str + holdtime: + description: + - The amount of time that the routes are preserved while the peer + is unreachable. + required: false + default: null + type: str + advertise: + description: + - A list of IPv4 advertise rules. + required: false + default: null + type: list + elements: dict + suboptions: + protocol: + description: + - The IPv4 routing protocol whose routes are to be advertised. + required: true + default: null + type: str + choices: + - bgp + - ospf + - ospfv3 + - connected + - static + - eigrp + - lisp + - isis + route: + description: + - The type of IPv4 routes to be advertised. For example, 'external' + for external routes. + required: false + default: null + type: str + choices: + - external + ipv6_advertise: + description: + - A list of IPv6 advertise rules. + required: false + default: null + type: list + elements: dict + suboptions: + protocol: + description: + - The IPv6 routing protocol whose routes are to be advertised. + required: true + default: null + type: str + choices: + - bgp + - ospf + - connected + - static + - eigrp + - lisp + - isis + ignore_region_path_length: + description: + - Whether to ignore the region part of the path length for OMP routes. + required: false + default: null + type: str + transport_gateway: + description: + - Specifies the preferred transport gateway selection strategy. + required: false + default: null + type: str + choices: + - prefer + - ecmp-with-direct-path + site_types: + description: + - A list of site types that are allowed to participate in the overlay + network. + required: false + default: null + type: list + elements: str + auto_translate: + description: + - Enable or disable automatic translation of network settings. + required: false + default: null + type: str + """ diff --git a/plugins/doc_fragments/feature_template_cisco_ospf.py b/plugins/doc_fragments/feature_template_cisco_ospf.py new file mode 100644 index 0000000..a39c2ff --- /dev/null +++ b/plugins/doc_fragments/feature_template_cisco_ospf.py @@ -0,0 +1,325 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" +options: + cisco_ospf: + description: Cisco OSPF (Open Shortest Path First) configuration + type: dict + suboptions: + router_id: + description: + - The router ID of the OSPF process. + required: false + default: null + type: str + reference_bandwidth: + description: + - The reference bandwidth used by OSPF for cost calculation. + required: false + default: null + type: str + rfc1583: + description: + - Compatibility switch for RFC 1583. + required: false + default: null + type: str + originate: + description: + - Controls the origination of default information into the OSPF domain. + required: false + default: null + type: str + always: + description: + - Ensures that the default route is always advertised, regardless + of the existence of a default route in the routing table. + required: false + default: null + type: str + metric: + description: + - The metric value to be set for the default route advertised by OSPF. + required: false + default: null + type: str + metric_type: + description: + - The metric type (Type 1 or Type 2) for OSPF external routes. + required: false + default: null + type: str + choices: + - type1 + - type2 + external: + description: + - The OSPF external route metric. + required: false + default: null + type: str + inter_area: + description: + - The OSPF inter-area route metric. + required: false + default: null + type: str + intra_area: + description: + - The OSPF intra-area route metric. + required: false + default: null + type: str + delay: + description: + - The OSPF Shortest Path First (SPF) delay time. + required: false + default: null + type: str + initial_hold: + description: + - The initial hold time between consecutive SPF calculations. + required: false + default: null + type: str + max_hold: + description: + - The maximum hold time between consecutive SPF calculations. + required: false + default: null + type: str + redistribute: + description: + - A list of OSPF redistribution configurations. + required: false + default: null + type: list + elements: dict + suboptions: + protocol: + description: + - The routing protocol from which routes are to be redistributed + into OSPF. + required: true + default: null + type: str + choices: + - static + - connected + - bgp + - omp + - nat + - eigrp + route_policy: + description: + - Name of the route policy to control the redistribution. + required: false + default: null + type: str + dia: + description: + - Default information originate, which controls the advertisement + of default route. + required: false + default: null + type: str + router_lsa: + description: + - Configuration options for the Router LSA in OSPF. + required: false + default: null + type: list + elements: dict + suboptions: + ad_type: + description: + - Type of advertisement for the router LSA. + required: true + default: null + type: str + choices: + - administrative + - on-startup + time: + description: + - Time in seconds for advertisement. + required: true + default: null + type: str + route_policy: + description: + - A list of OSPF route policies. + required: false + default: null + type: list + elements: dict + suboptions: + direction: + description: + - Direction of the route policy (e.g., 'in' for incoming). + required: true + default: null + type: str + choices: + - in + pol_name: + description: + - Name of the route policy. + required: true + default: null + type: str + area: + description: + - A list of OSPF areas and their configurations. + required: false + default: null + type: list + elements: dict + suboptions: + a_num: + description: + - The OSPF area number. + required: true + default: null + type: str + stub: + description: + - Configuration for the OSPF area to be a stub area. If set, + no-summary can be applied. + required: false + default: null + type: str + nssa: + description: + - Configuration for the OSPF area to be a Not-So-Stubby Area + (NSSA). If set, no-summary can be applied. + required: false + default: null + type: str + interface: + description: + - A list of OSPF interface configurations associated with + this area. + required: false + default: null + type: list + elements: dict + suboptions: + name: + description: + - The name of the OSPF interface. + required: true + default: null + type: str + hello_interval: + description: + - The interval between the OSPF Hello packets that + the router sends on the interface. + required: false + default: null + type: str + dead_interval: + description: + - The time interval an OSPF router waits for a Hello + packet before declaring the sending router down. + required: false + default: null + type: str + retransmit_interval: + description: + - The interval between LSA retransmissions for adjacencies + belonging to the interface. + required: false + default: null + type: str + cost: + description: + - The OSPF cost (metric) for this interface. + required: false + default: null + type: str + priority: + description: + - The OSPF priority of the interface. + required: false + default: null + type: str + network: + description: + - The OSPF network type for the interface. + required: false + default: broadcast + type: str + choices: + - broadcast + - point-to-point + - non-broadcast + - point-to-multipoint + passive_interface: + description: + - Whether the interface is a passive OSPF interface. + required: false + default: null + type: str + type: + description: + - The OSPF authentication type for the interface. + required: false + default: null + type: str + choices: + - simple + - message-digest + - 'null' + message_digest_key: + description: + - The message-digest key ID for OSPF authentication. + required: false + default: null + type: str + md5: + description: + - The MD5 string for OSPF message-digest authentication. + required: false + default: null + type: str + range: + description: + - A list of OSPF range entries to be associated with this + area. + required: false + default: null + type: list + elements: dict + suboptions: + address: + description: + - The IPv4 network address to be advertised as an + OSPF range. + required: true + default: null + type: str + cost: + description: + - The OSPF cost (metric) for this range. + required: false + default: null + type: str + no_advertise: + description: + - Whether to suppress advertising this range. + required: false + default: null + type: str + """ diff --git a/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py b/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py new file mode 100644 index 0000000..6abf586 --- /dev/null +++ b/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py @@ -0,0 +1,490 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" +options: + cisco_secure_internet_gateway: + description: Cisco Secure Internet Gateway feature template configuration + type: dict + suboptions: + vpn_id: + description: + - VPN ID associated with the Cisco Secure Internet Gateway service. + required: false + default: null + type: str + interface: + description: + - List of interface configurations associated with the service. + required: true + default: null + type: list + elements: dict + suboptions: + if_name: + description: + - Name of the interface. + required: true + default: null + type: str + auto: + description: + - Flag to indicate if the interface should be automatically + configured. + required: true + default: null + type: bool + shutdown: + description: + - Flag to indicate if the interface is administratively down + (shutdown). + required: true + default: null + type: bool + description: + description: + - Description for the interface. + required: false + default: null + type: str + unnumbered: + description: + - Flag to indicate if the interface should be unnumbered. + required: false + default: null + type: bool + address: + description: + - IPv4 address and subnet mask for the interface. + required: false + default: null + type: str + tunnel_source: + description: + - IPv4 address used as the source of the tunnel. + required: false + default: null + type: str + tunnel_source_interface: + description: + - Interface name used as the source of the tunnel. + required: false + default: null + type: str + tunnel_route_via: + description: + - The route via which tunnel traffic should be sent. + required: false + default: null + type: str + tunnel_destination: + description: + - The destination address for the tunnel. + required: true + default: null + type: str + application: + description: + - Application type for the Secure Internet Gateway. + required: false + default: sig + type: str + choices: + - sig + tunnel_set: + description: + - Tunnel set used for the Secure Internet Gateway. + required: false + default: secure-internet-gateway-umbrella + type: str + choices: + - secure-internet-gateway-umbrella + - secure-internet-gateway-zscaler + tunnel_dc_preference: + description: + - Data center preference for the tunnel. + required: false + default: primary-dc + type: str + choices: + - primary-dc + - secondary-dc + tcp_mss_adjust: + description: + - TCP Maximum Segment Size (MSS) adjust value. + required: false + default: null + type: str + mtu: + description: + - MTU (Maximum Transmission Unit) size for the interface. + required: false + default: null + type: str + dpd_interval: + description: + - Dead Peer Detection (DPD) interval in seconds. + required: false + default: null + type: str + dpd_retries: + description: + - Number of retries for Dead Peer Detection (DPD). + required: false + default: null + type: str + ike_version: + description: + - Internet Key Exchange (IKE) protocol version. + required: false + default: null + type: str + pre_shared_secret: + description: + - Pre-shared secret key for IKE authentication. + required: false + default: null + type: str + ike_rekey_interval: + description: + - Interval for rekeying the IKE security association. + required: false + default: null + type: str + ike_ciphersuite: + description: + - Ciphersuite for IKE security association establishment. + required: false + default: aes256-cbc-sha1 + type: str + choices: + - aes256-cbc-sha1 + - aes256-cbc-sha2 + - aes128-cbc-sha1 + - aes128-cbc-sha2 + ike_group: + description: + - Diffie-Hellman group used for IKE key exchange. + required: false + default: '14' + type: str + choices: + - '2' + - '14' + - '15' + - '16' + pre_shared_key_dynamic: + description: + - Flag indicating if the pre-shared key is dynamic. + required: false + default: null + type: bool + ike_local_id: + description: + - Local identifier for IKE authentication. + required: false + default: null + type: str + ike_remote_id: + description: + - Remote identifier for IKE authentication. + required: false + default: null + type: str + ipsec_rekey_interval: + description: + - Interval for rekeying the IPsec security association. + required: false + default: null + type: str + ipsec_replay_window: + description: + - Replay window size for IPsec security association. + required: false + default: null + type: str + ipsec_ciphersuite: + description: + - Ciphersuite for IPsec security association establishment. + required: false + default: aes256-gcm + type: str + choices: + - aes256-cbc-sha1 + - aes256-cbc-sha384 + - aes256-cbc-sha256 + - aes256-cbc-sha512 + - aes256-gcm + - null-sha1 + - null-sha384 + - null-sha256 + - null-sha512 + perfect_forward_secrecy: + description: + - Perfect Forward Secrecy (PFS) setting for IPsec key exchange. + required: false + default: none + type: str + choices: + - group-2 + - group-14 + - group-15 + - group-16 + - none + tracker: + description: + - Flag indicating if interface tracking is enabled. + required: false + default: null + type: str + track_enable: + description: + - Flag indicating if tracking is enabled for the interface. + required: false + default: null + type: str + service: + description: + - List of service configurations for the Cisco Secure Internet Gateway. + required: true + default: null + type: list + elements: dict + suboptions: + svc_type: + description: + - Type of service configured. + required: false + default: sig + type: str + choices: + - sig + interface_pair: + description: + - List of high-availability interface pairs. + required: true + default: null + type: list + elements: dict + suboptions: + active_interface: + description: + - Name of the active interface. + required: true + default: null + type: str + active_interface_weight: + description: + - Weighting factor for the active interface, used + in failover decisions. + required: false + default: null + type: str + backup_interface: + description: + - Name of the backup interface. Can be 'None' if no + backup interface is defined. + required: false + default: null + type: str + backup_interface_weight: + description: + - Weighting factor for the backup interface, used + in failover decisions. + required: false + default: null + type: str + auth_required: + description: + - Flag indicating if authentication is required for the service. + required: false + default: null + type: str + xff_forward_enabled: + description: + - Flag indicating if X-Forwarded-For HTTP header is enabled. + required: false + default: null + type: str + ofw_enabled: + description: + - Flag indicating if on-premise firewall is enabled. + required: false + default: null + type: str + ips_control: + description: + - Flag indicating if Intrusion Prevention System (IPS) control + is enabled. + required: false + default: null + type: str + caution_enabled: + description: + - Flag indicating if caution warnings are enabled. + required: false + default: null + type: str + primary_data_center: + description: + - Primary data center for the service. 'Auto' for automatic + selection. + required: false + default: null + type: str + secondary_data_center: + description: + - Secondary data center for the service. 'Auto' for automatic + selection. + required: false + default: null + type: str + ip: + description: + - Flag indicating if IP filtering or processing is enabled + for the service. + required: false + default: null + type: str + idle_time: + description: + - Idle time before a session is considered inactive. + required: false + default: null + type: str + display_time_unit: + description: + - Unit of time used for displaying time-related settings. + required: false + default: MINUTE + type: str + choices: + - MINUTE + - HOUR + - DAY + ip_enforced_for_known_browsers: + description: + - Flag indicating if IP is enforced for known browsers. + required: false + default: null + type: str + refresh_time: + description: + - Time after which the service information is refreshed. + required: false + default: null + type: str + refresh_time_unit: + description: + - Unit of time used for the refresh time setting. + required: false + default: MINUTE + type: str + choices: + - MINUTE + - HOUR + - DAY + enabled: + description: + - Flag indicating if the service is enabled. + required: false + default: null + type: str + block_internet_until_accepted: + description: + - Flag indicating if Internet access is blocked until the + service is accepted. + required: false + default: null + type: str + force_ssl_inspection: + description: + - Flag indicating if SSL inspection is forced. + required: false + default: null + type: str + timeout: + description: + - Timeout value for the service, after which the session is + considered inactive. + required: false + default: null + type: str + data_center_primary: + description: + - Alias for the primary data center setting. + required: false + default: null + type: str + data_center_secondary: + description: + - Secondary data center for the service. 'Auto' for automatic + selection or a specific identifier for a manual selection. + required: false + default: null + type: str + tracker_src_ip: + description: + - Source IP address used by the tracker for sending health check packets. + required: false + default: null + type: str + tracker: + description: + - List of trackers for monitoring the health of the Cisco Secure Internet + Gateway service. + required: false + default: null + type: list + elements: dict + suboptions: + name: + description: + - Name of the tracker. + required: true + default: null + type: str + endpoint_api_url: + description: + - URL of the endpoint API used by the tracker for health checks. + required: true + default: null + type: str + threshold: + description: + - Threshold value for the tracker to trigger an alert or action. + required: false + default: null + type: str + interval: + description: + - Interval at which the tracker performs health checks. + required: false + default: null + type: str + multiplier: + description: + - Multiplier value used by the tracker to escalate repeated + failures. + required: false + default: null + type: str + tracker_type: + description: + - Type of tracker used for monitoring. + required: true + default: null + type: str + choices: + - SIG + """ diff --git a/plugins/doc_fragments/feature_template_cisco_snmp.py b/plugins/doc_fragments/feature_template_cisco_snmp.py new file mode 100644 index 0000000..5ea160a --- /dev/null +++ b/plugins/doc_fragments/feature_template_cisco_snmp.py @@ -0,0 +1,225 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" +options: + cisco_snmp: + description: Cisco SNMP Feature Template configuration + type: dict + suboptions: + shutdown: + description: + - Indicates whether SNMP is administratively shut down + required: false + default: null + type: str + contact: + description: + - The contact information for the SNMP administrator + required: true + default: null + type: str + location: + description: + - The physical location information for the SNMP agent + required: true + default: null + type: str + view: + description: + - List of SNMP views for controlling access to OIDs + required: false + default: null + type: list + elements: dict + suboptions: + name: + description: + - The name of the SNMP view + required: true + default: null + type: str + oid: + description: + - List of OIDs to include or exclude in the view + required: true + default: null + type: list + elements: dict + suboptions: + id: + description: + - The OID (Object Identifier) to include or exclude + in the view + required: true + default: null + type: str + exclude: + description: + - Indicates whether the OID should be excluded from + the view + required: true + default: null + type: str + community: + description: + - List of SNMP communities for different access rights + required: false + default: null + type: list + elements: dict + suboptions: + name: + description: + - The name of the SNMP community + required: true + default: null + type: str + view: + description: + - The SNMP view associated with the community + required: true + default: null + type: str + authorization: + description: + - The authorization level of the community + required: true + default: null + type: str + choices: + - read-only + group: + description: + - List of SNMP groups defining security models and access rights + required: false + default: null + type: list + elements: dict + suboptions: + name: + description: + - The name of the SNMP group + required: true + default: null + type: str + security_level: + description: + - The security level associated with the group + required: true + default: null + type: str + choices: + - no-auth-no-priv + - auth-no-priv + - auth-priv + view: + description: + - The SNMP view associated with the group + required: true + default: null + type: str + user: + description: + - List of SNMP users with authentication and privacy configurations + required: false + default: null + type: list + elements: dict + suboptions: + name: + description: + - The name of the SNMP user + required: true + default: null + type: str + auth: + description: + - The authentication protocol used + required: true + default: null + type: str + choices: + - md5 + - sha + auth_password: + description: + - The password for authentication + required: true + default: null + type: str + priv: + description: + - The privacy (encryption) protocol used + required: true + default: null + type: str + choices: + - aes-cfb-128 + priv_password: + description: + - The password for privacy + required: true + default: null + type: str + group: + description: + - The group to which the user belongs + required: true + default: null + type: str + target: + description: + - List of SNMP targets for sending traps + required: false + default: null + type: list + elements: dict + suboptions: + vpn_id: + description: + - The VPN ID where the SNMP target resides + required: true + default: null + type: str + ip: + description: + - The IP address of the SNMP target + required: true + default: null + type: str + port: + description: + - The port number for the SNMP target + required: true + default: null + type: str + community_name: + description: + - The community name for the SNMP target + required: true + default: null + type: str + user: + description: + - The user name for the SNMP target + required: true + default: null + type: str + source_interface: + description: + - The source interface for sending SNMP traps + required: true + default: null + type: str + """ diff --git a/plugins/doc_fragments/feature_template_cisco_system.py b/plugins/doc_fragments/feature_template_cisco_system.py new file mode 100644 index 0000000..5b8d14f --- /dev/null +++ b/plugins/doc_fragments/feature_template_cisco_system.py @@ -0,0 +1,929 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" +options: + cisco_system: + description: Cisco System configuration settings for SD-WAN devices. + type: dict + suboptions: + timezone: + description: + - The timezone setting for the system. + required: false + default: null + type: str + choices: + - Europe/Andorra + - Asia/Dubai + - Asia/Kabul + - America/Antigua + - America/Anguilla + - Europe/Tirane + - Asia/Yerevan + - Africa/Luanda + - Antarctica/McMurdo + - Antarctica/Rothera + - Antarctica/Palmer + - Antarctica/Mawson + - Antarctica/Davis + - Antarctica/Casey + - Antarctica/Vostok + - Antarctica/DumontDUrville + - Antarctica/Syowa + - America/Argentina/Buenos_Aires + - America/Argentina/Cordoba + - America/Argentina/Salta + - America/Argentina/Jujuy + - America/Argentina/Tucuman + - America/Argentina/Catamarca + - America/Argentina/La_Rioja + - America/Argentina/San_Juan + - America/Argentina/Mendoza + - America/Argentina/San_Luis + - America/Argentina/Rio_Gallegos + - America/Argentina/Ushuaia + - Pacific/Pago_Pago + - Europe/Vienna + - Australia/Lord_Howe + - Antarctica/Macquarie + - Australia/Hobart + - Australia/Currie + - Australia/Melbourne + - Australia/Sydney + - Australia/Broken_Hill + - Australia/Brisbane + - Australia/Lindeman + - Australia/Adelaide + - Australia/Darwin + - Australia/Perth + - Australia/Eucla + - America/Aruba + - Europe/Mariehamn + - Asia/Baku + - Europe/Sarajevo + - America/Barbados + - Asia/Dhaka + - Europe/Brussels + - Africa/Ouagadougou + - Europe/Sofia + - Asia/Bahrain + - Africa/Bujumbura + - Africa/Porto-Novo + - America/St_Barthelemy + - Atlantic/Bermuda + - Asia/Brunei + - America/La_Paz + - America/Kralendijk + - America/Noronha + - America/Belem + - America/Fortaleza + - America/Recife + - America/Araguaina + - America/Maceio + - America/Bahia + - America/Sao_Paulo + - America/Campo_Grande + - America/Cuiaba + - America/Santarem + - America/Porto_Velho + - America/Boa_Vista + - America/Manaus + - America/Eirunepe + - America/Rio_Branco + - America/Nassau + - Asia/Thimphu + - Africa/Gaborone + - Europe/Minsk + - America/Belize + - America/St_Johns + - America/Halifax + - America/Glace_Bay + - America/Moncton + - America/Goose_Bay + - America/Blanc-Sablon + - America/Toronto + - America/Nipigon + - America/Thunder_Bay + - America/Iqaluit + - America/Pangnirtung + - America/Resolute + - America/Atikokan + - America/Rankin_Inlet + - America/Winnipeg + - America/Rainy_River + - America/Regina + - America/Swift_Current + - America/Edmonton + - America/Cambridge_Bay + - America/Yellowknife + - America/Inuvik + - America/Creston + - America/Dawson_Creek + - America/Vancouver + - America/Whitehorse + - America/Dawson + - Indian/Cocos + - Africa/Kinshasa + - Africa/Lubumbashi + - Africa/Bangui + - Africa/Brazzaville + - Europe/Zurich + - Africa/Abidjan + - Pacific/Rarotonga + - America/Santiago + - Pacific/Easter + - Africa/Douala + - Asia/Shanghai + - Asia/Harbin + - Asia/Chongqing + - Asia/Urumqi + - Asia/Kashgar + - America/Bogota + - America/Costa_Rica + - America/Havana + - Atlantic/Cape_Verde + - America/Curacao + - Indian/Christmas + - Asia/Nicosia + - Europe/Prague + - Europe/Berlin + - Europe/Busingen + - Africa/Djibouti + - Europe/Copenhagen + - America/Dominica + - America/Santo_Domingo + - Africa/Algiers + - America/Guayaquil + - Pacific/Galapagos + - Europe/Tallinn + - Africa/Cairo + - Africa/El_Aaiun + - Africa/Asmara + - Europe/Madrid + - Africa/Ceuta + - Atlantic/Canary + - Africa/Addis_Ababa + - Europe/Helsinki + - Pacific/Fiji + - Atlantic/Stanley + - Pacific/Chuuk + - Pacific/Pohnpei + - Pacific/Kosrae + - Atlantic/Faroe + - Europe/Paris + - Africa/Libreville + - Europe/London + - America/Grenada + - Asia/Tbilisi + - America/Cayenne + - Europe/Guernsey + - Africa/Accra + - Europe/Gibraltar + - America/Godthab + - America/Danmarkshavn + - America/Scoresbysund + - America/Thule + - Africa/Banjul + - Africa/Conakry + - America/Guadeloupe + - Africa/Malabo + - Europe/Athens + - Atlantic/South_Georgia + - America/Guatemala + - Pacific/Guam + - Africa/Bissau + - America/Guyana + - Asia/Hong_Kong + - America/Tegucigalpa + - Europe/Zagreb + - America/Port-au-Prince + - Europe/Budapest + - Asia/Jakarta + - Asia/Pontianak + - Asia/Makassar + - Asia/Jayapura + - Europe/Dublin + - Asia/Jerusalem + - Europe/Isle_of_Man + - Asia/Kolkata + - Indian/Chagos + - Asia/Baghdad + - Asia/Tehran + - Atlantic/Reykjavik + - Europe/Rome + - Europe/Jersey + - America/Jamaica + - Asia/Amman + - Asia/Tokyo + - Africa/Nairobi + - Asia/Bishkek + - Asia/Phnom_Penh + - Pacific/Tarawa + - Pacific/Enderbury + - Pacific/Kiritimati + - Indian/Comoro + - America/St_Kitts + - Asia/Pyongyang + - Asia/Seoul + - Asia/Kuwait + - America/Cayman + - Asia/Almaty + - Asia/Qyzylorda + - Asia/Aqtobe + - Asia/Aqtau + - Asia/Oral + - Asia/Vientiane + - Asia/Beirut + - America/St_Lucia + - Europe/Vaduz + - Asia/Colombo + - Africa/Monrovia + - Africa/Maseru + - Europe/Vilnius + - Europe/Luxembourg + - Europe/Riga + - Africa/Tripoli + - Africa/Casablanca + - Europe/Monaco + - Europe/Chisinau + - Europe/Podgorica + - America/Marigot + - Indian/Antananarivo + - Pacific/Majuro + - Pacific/Kwajalein + - Europe/Skopje + - Africa/Bamako + - Asia/Rangoon + - Asia/Ulaanbaatar + - Asia/Hovd + - Asia/Choibalsan + - Asia/Macau + - Pacific/Saipan + - America/Martinique + - Africa/Nouakchott + - America/Montserrat + - Europe/Malta + - Indian/Mauritius + - Indian/Maldives + - Africa/Blantyre + - America/Mexico_City + - America/Cancun + - America/Merida + - America/Monterrey + - America/Matamoros + - America/Mazatlan + - America/Chihuahua + - America/Ojinaga + - America/Hermosillo + - America/Tijuana + - America/Santa_Isabel + - America/Bahia_Banderas + - Asia/Kuala_Lumpur + - Asia/Kuching + - Africa/Maputo + - Africa/Windhoek + - Pacific/Noumea + - Africa/Niamey + - Pacific/Norfolk + - Africa/Lagos + - America/Managua + - Europe/Amsterdam + - Europe/Oslo + - Asia/Kathmandu + - Pacific/Nauru + - Pacific/Niue + - Pacific/Auckland + - Pacific/Chatham + - Asia/Muscat + - America/Panama + - America/Lima + - Pacific/Tahiti + - Pacific/Marquesas + - Pacific/Gambier + - Pacific/Port_Moresby + - Asia/Manila + - Asia/Karachi + - Europe/Warsaw + - America/Miquelon + - Pacific/Pitcairn + - America/Puerto_Rico + - Asia/Gaza + - Asia/Hebron + - Europe/Lisbon + - Atlantic/Madeira + - Atlantic/Azores + - Pacific/Palau + - America/Asuncion + - Asia/Qatar + - Indian/Reunion + - Europe/Bucharest + - Europe/Belgrade + - Europe/Kaliningrad + - Europe/Moscow + - Europe/Volgograd + - Europe/Samara + - Asia/Yekaterinburg + - Asia/Omsk + - Asia/Novosibirsk + - Asia/Novokuznetsk + - Asia/Krasnoyarsk + - Asia/Irkutsk + - Asia/Yakutsk + - Asia/Khandyga + - Asia/Vladivostok + - Asia/Sakhalin + - Asia/Ust-Nera + - Asia/Magadan + - Asia/Kamchatka + - Asia/Anadyr + - Africa/Kigali + - Asia/Riyadh + - Pacific/Guadalcanal + - Indian/Mahe + - Africa/Khartoum + - Europe/Stockholm + - Asia/Singapore + - Atlantic/St_Helena + - Europe/Ljubljana + - Arctic/Longyearbyen + - Europe/Bratislava + - Africa/Freetown + - Europe/San_Marino + - Africa/Dakar + - Africa/Mogadishu + - America/Paramaribo + - Africa/Juba + - Africa/Sao_Tome + - America/El_Salvador + - America/Lower_Princes + - Asia/Damascus + - Africa/Mbabane + - America/Grand_Turk + - Africa/Ndjamena + - Indian/Kerguelen + - Africa/Lome + - Asia/Bangkok + - Asia/Dushanbe + - Pacific/Fakaofo + - Asia/Dili + - Asia/Ashgabat + - Africa/Tunis + - Pacific/Tongatapu + - Europe/Istanbul + - America/Port_of_Spain + - Pacific/Funafuti + - Asia/Taipei + - Africa/Dar_es_Salaam + - Europe/Kiev + - Europe/Uzhgorod + - Europe/Zaporozhye + - Europe/Simferopol + - Africa/Kampala + - Pacific/Johnston + - Pacific/Midway + - Pacific/Wake + - America/New_York + - America/Detroit + - America/Kentucky/Louisville + - America/Kentucky/Monticello + - America/Indiana/Indianapolis + - America/Indiana/Vincennes + - America/Indiana/Winamac + - America/Indiana/Marengo + - America/Indiana/Petersburg + - America/Indiana/Vevay + - America/Chicago + - America/Indiana/Tell_City + - America/Indiana/Knox + - America/Menominee + - America/North_Dakota/Center + - America/North_Dakota/New_Salem + - America/North_Dakota/Beulah + - America/Denver + - America/Boise + - America/Phoenix + - America/Los_Angeles + - America/Anchorage + - America/Juneau + - America/Sitka + - America/Yakutat + - America/Nome + - America/Adak + - America/Metlakatla + - Pacific/Honolulu + - America/Montevideo + - Asia/Samarkand + - Asia/Tashkent + - Europe/Vatican + - America/St_Vincent + - America/Caracas + - America/Tortola + - America/St_Thomas + - Asia/Ho_Chi_Minh + - Pacific/Efate + - Pacific/Wallis + - Pacific/Apia + - Asia/Aden + - Indian/Mayotte + - Africa/Johannesburg + - Africa/Lusaka + - Africa/Harare + - UTC + hostname: + description: + - The hostname for the device. + required: false + default: null + type: dict + suboptions: + name: + description: + - null + required: true + default: null + type: str + location: + description: + - The physical location of the device. + required: false + default: null + type: str + latitude: + description: + - The latitude coordinate for the device's location. + required: false + default: null + type: str + longitude: + description: + - The longitude coordinate for the device's location. + required: false + default: null + type: str + range: + description: + - The range for geo-fencing feature. + required: false + default: null + type: str + enable_fencing: + description: + - Enable or disable geo-fencing. + required: false + default: null + type: str + mobile_number: + description: + - List of mobile numbers for SMS notifications. + required: false + default: null + type: list + elements: dict + suboptions: + number: + description: + - The mobile phone number used for notification or security + purposes. + required: true + default: null + type: str + enable_sms: + description: + - Enable or disable SMS notifications. + required: false + default: null + type: str + device_groups: + description: + - List of device groups the device belongs to. + required: false + default: null + type: list + elements: str + controller_group_list: + description: + - List of controller groups the device is associated with. + required: false + default: null + type: list + elements: str + system_ip: + description: + - The system IP address of the device. + required: false + default: null + type: dict + suboptions: + name: + description: + - null + required: true + default: null + type: str + overlay_id: + description: + - The overlay ID of the device. + required: false + default: null + type: str + site_id: + description: + - The site ID of the device. + required: false + default: null + type: str + site_type: + description: + - The site type classification for the device. + required: false + default: null + type: list + elements: str + port_offset: + description: + - The port offset for the device. + required: false + default: null + type: str + port_hop: + description: + - Enable or disable port hopping. + required: false + default: null + type: str + control_session_pps: + description: + - Control session packets per second setting. + required: false + default: null + type: str + track_transport: + description: + - Enable or disable transport tracking. + required: false + default: null + type: str + track_interface_tag: + description: + - The tag of the interface to be tracked. + required: false + default: null + type: str + console_baud_rate: + description: + - The console baud rate setting for the device. + required: false + default: null + type: str + choices: + - '1200' + - '2400' + - '4800' + - '9600' + - '19200' + - '38400' + - '57600' + - '115200' + max_omp_sessions: + description: + - The maximum number of OMP (Overlay Management Protocol) sessions. + required: false + default: null + type: str + multi_tenant: + description: + - Enable or disable multi-tenant support. + required: false + default: null + type: str + track_default_gateway: + description: + - Enable or disable default gateway tracking. + required: false + default: null + type: str + admin_tech_on_failure: + description: + - Enable or disable automatic generation of admin technical details + on failure. + required: false + default: null + type: str + enable_tunnel: + description: + - Enable or disable tunnel functionality. + required: false + default: null + type: str + idle_timeout: + description: + - The idle timeout setting for tunnels. + required: false + default: null + type: str + on_demand_idle_timeout_min: + description: + - The minimum idle timeout for on-demand tunnels. + required: false + default: null + type: str + tracker: + description: + - List of tracker configurations. + required: false + default: null + type: list + elements: dict + suboptions: + name: + description: + - null + required: true + default: null + type: str + endpoint_ip: + description: + - The IP address of the endpoint to track. + required: false + default: null + type: str + endpoint_ip_transport_port: + description: + - The transport port of the endpoint IP address. + required: false + default: null + type: str + protocol: + description: + - The protocol used for the tracker (TCP or UDP). + required: false + default: null + type: str + choices: + - tcp + - udp + port: + description: + - The port number used for the tracker. + required: false + default: null + type: str + endpoint_dns_name: + description: + - The DNS name of the endpoint to track. + required: false + default: null + type: str + endpoint_api_url: + description: + - The API URL of the endpoint to track. + required: false + default: null + type: str + elements: + description: + - A list of elements to track. + required: false + default: null + type: list + elements: str + boolean: + description: + - The boolean condition to use when evaluating multiple elements. + required: false + default: or + type: str + choices: + - or + - and + threshold: + description: + - The threshold for triggering the tracker. + required: false + default: null + type: str + interval: + description: + - The interval at which the tracker checks the elements. + required: false + default: null + type: str + multiplier: + description: + - The multiplier used for determining the loss threshold. + required: false + default: null + type: str + type: + description: + - The type of tracker (interface or static route). + required: false + default: interface + type: str + choices: + - interface + - static-route + object_track: + description: + - List of object tracking configurations. + required: false + default: null + type: list + elements: dict + suboptions: + object_number: + description: + - The tracking object number. + required: true + default: null + type: str + interface: + description: + - The name of the interface to track. + required: true + default: null + type: str + sig: + description: + - The signature associated with the tracking object. + required: true + default: null + type: str + ip: + description: + - The IP address used for tracking. + required: true + default: null + type: str + mask: + description: + - The subnet mask associated with the IP address for tracking. + required: false + default: null + type: str + vpn: + description: + - The VPN instance associated with the tracking object. + required: true + default: null + type: str + object: + description: + - A list of objects related to the tracking. + required: true + default: null + type: list + elements: dict + suboptions: + number: + description: + - The unique identifier for the object. + required: true + default: null + type: str + boolean: + description: + - The boolean condition to use when evaluating multiple objects. + required: true + default: null + type: str + choices: + - or + - and + region_id: + description: + - The region ID of the device. + required: false + default: null + type: str + secondary_region: + description: + - The secondary region ID of the device. + required: false + default: null + type: str + role: + description: + - The role of the device in the network. + required: false + default: null + type: str + choices: + - edge-router + - border-router + affinity_group_number: + description: + - The affinity group number for VRF binding. + required: false + default: null + type: str + preference: + description: + - List of affinity group preferences. + required: false + default: null + type: list + elements: str + preference_auto: + description: + - Enable or disable automatic preference setting for affinity groups. + required: false + default: null + type: str + affinity_per_vrf: + description: + - List of affinity configurations per VRF. + required: false + default: null + type: list + elements: dict + suboptions: + affinity_group_number: + description: + - The affinity group number for VRF binding. + required: false + default: null + type: str + vrf_range: + description: + - The range of VRFs associated with the affinity group. + required: false + default: null + type: str + transport_gateway: + description: + - Enable or disable the transport gateway feature. + required: false + default: null + type: str + enable_mrf_migration: + description: + - Enable Multicast Routing Framework (MRF) migration settings. + required: false + default: null + type: str + choices: + - enabled + - enabled-from-bgp-core + migration_bgp_community: + description: + - BGP community value for MRF migration. + required: false + default: null + type: str + enable_management_region: + description: + - Enable or disable management region configuration. + required: false + default: null + type: str + vrf: + description: + - List of VRF configurations. + required: false + default: null + type: list + elements: dict + suboptions: + vrf_id: + description: + - The VRF (VPN Routing and Forwarding) instance ID. + required: true + default: null + type: str + gateway_preference: + description: + - A list of preferred gateway values for the VRF. + required: false + default: null + type: list + elements: str + management_gateway: + description: + - Enable or disable the management gateway feature. + required: false + default: null + type: str + epfr: + description: + - Edge Policy-based Framework Routing (EPFR) setting. + required: false + default: null + type: str + choices: + - disabled + - aggressive + - moderate + - conservative + """ diff --git a/plugins/doc_fragments/feature_template_cisco_vpn.py b/plugins/doc_fragments/feature_template_cisco_vpn.py new file mode 100644 index 0000000..c1ee1b7 --- /dev/null +++ b/plugins/doc_fragments/feature_template_cisco_vpn.py @@ -0,0 +1,987 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" +options: + cisco_vpn: + description: Cisco VPN Feature Template configuration. + type: dict + suboptions: + vpn_id: + description: + - The unique identifier for the VPN instance (VRF). + required: false + default: null + type: str + vpn_name: + description: + - The name of the VPN instance. + required: false + default: null + type: str + tenant_vpn_id: + description: + - The tenant-specific identifier for the VPN instance, used in multi-tenant + environments. + required: false + default: null + type: str + org_name: + description: + - The name of the organization to which the VPN instance belongs. + required: false + default: null + type: str + omp_admin_distance_ipv4: + description: + - The administrative distance for IPv4 routes received over the Overlay + Management Protocol (OMP). + required: false + default: null + type: str + omp_admin_distance_ipv6: + description: + - The administrative distance for IPv6 routes received over OMP. + required: false + default: null + type: str + dns: + description: + - A list of DNS configurations for the VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + dns_addr: + description: + - The IP address of the DNS server. + required: false + default: null + type: str + role: + description: + - The role of the DNS server, either 'PRIMARY' or 'SECONDARY'. + required: false + default: primary + type: str + choices: + - primary + - secondary + dns_ipv6: + description: + - A list of DNS configurations for IPv6 within the VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + dns_addr: + description: + - The IPv6 address of the DNS server. + required: false + default: null + type: str + role: + description: + - The role of the DNS server for IPv6, optionally either 'PRIMARY' + or 'SECONDARY'. + required: false + default: primary + type: str + choices: + - primary + - secondary + layer4: + description: + - A flag indicating whether Layer 4 information is included in the + ECMP hash key. + required: false + default: null + type: str + host: + description: + - A list of host configurations within the VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + hostname: + description: + - The hostname of the device. + required: true + default: null + type: str + ip: + description: + - A list of IP addresses associated with the hostname. + required: true + default: null + type: list + elements: str + service: + description: + - A list of service configurations associated with the VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + svc_type: + description: + - The type of service to be configured. + required: true + default: null + type: str + choices: + - FW + - IDS + - IDP + - netsvc1 + - netsvc2 + - netsvc3 + - netsvc4 + - TE + - appqoe + address: + description: + - A list of IP addresses for the service. + required: false + default: null + type: list + elements: str + interface: + description: + - The interface associated with the service. + required: false + default: null + type: str + track_enable: + description: + - Indicates whether tracking is enabled for the service. + required: false + default: null + type: bool + service_route: + description: + - A list of service route configurations for directing traffic to + services within the VPN. + required: false + default: null + type: list + elements: dict + suboptions: + prefix: + description: + - The network prefix for the service route. + required: true + default: null + type: str + vpn: + description: + - The VPN identifier where the service route is to be applied. + required: true + default: null + type: str + service: + description: + - The service associated with the route. + required: false + default: sig + type: str + choices: + - sig + route_v4: + description: + - A list of IPv4 route configurations within the VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + prefix: + description: + - The IPv4 network prefix for the static route. + required: false + default: null + type: str + next_hop: + description: + - A list of IPv4 next hops for the route. + required: false + default: null + type: list + elements: dict + suboptions: + address: + description: + - The IP address of the next hop for the route. + required: false + default: null + type: str + distance: + description: + - The administrative distance of the next hop. + required: false + default: null + type: str + next_hop_with_track: + description: + - A list of IPv4 next hops with tracking for the route. + required: false + default: null + type: list + elements: dict + suboptions: + address: + description: + - The IP address of the next hop for the route that + requires tracking. + required: false + default: null + type: str + distance: + description: + - The administrative distance of the next hop that + requires tracking. + required: false + default: null + type: str + tracker: + description: + - The tracker associated with this next hop. + required: true + default: null + type: str + route_interface: + description: + - The interface configuration for the IPv4 static route. + required: false + default: null + type: str + null0: + description: + - A flag indicating whether to route traffic to null0 for + this static route. + required: false + default: null + type: str + distance: + description: + - The administrative distance for the static route. + required: false + default: null + type: str + vpn: + description: + - The VPN instance identifier associated with the static route. + required: false + default: null + type: str + dhcp: + description: + - A flag indicating whether DHCP is used for this static route. + required: false + default: null + type: str + route_v6: + description: + - A list of IPv6 route configurations within the VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + prefix: + description: + - The IPv6 network prefix for the static route. + required: true + default: null + type: str + next_hop: + description: + - A list of IPv6 next hops for the route. + required: false + default: null + type: list + elements: dict + suboptions: + address: + description: + - The IPv6 address of the next hop for the route. + required: true + default: null + type: str + distance: + description: + - The administrative distance of the IPv6 next hop. + required: false + default: null + type: str + null0: + description: + - A flag indicating whether to route IPv6 traffic to null0 + for this static route. + required: false + default: null + type: str + vpn: + description: + - The VPN instance identifier associated with the IPv6 static + route. + required: false + default: null + type: str + nat: + description: + - The type of NAT to apply for the IPv6 static route, if applicable. + required: false + default: null + type: str + choices: + - NAT64 + - NAT66 + gre_route: + description: + - A list of GRE tunnel route configurations within the VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + prefix: + description: + - The network prefix for the GRE (Generic Routing Encapsulation) + route. + required: true + default: null + type: str + vpn: + description: + - The VPN identifier where the GRE route is to be applied. + required: true + default: null + type: str + interface: + description: + - A list of interfaces associated with the GRE route. + required: false + default: null + type: list + elements: str + ipsec_route: + description: + - A list of IPSec route configurations within the VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + prefix: + description: + - The network prefix for the IPSec (Internet Protocol Security) + route. + required: true + default: null + type: str + vpn: + description: + - The VPN identifier where the IPSec route is to be applied. + required: true + default: null + type: str + interface: + description: + - A list of interfaces associated with the IPSec route. + required: false + default: null + type: list + elements: str + advertise: + description: + - A list of configurations for advertising routes via OMP within the + VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + protocol: + description: + - The protocol used for route advertisement. + required: true + default: null + type: str + choices: + - bgp + - ospf + - ospfv3 + - connected + - static + - network + - aggregate + - eigrp + - lisp + - isis + route_policy: + description: + - The route policy associated with advertisement. + required: false + default: null + type: str + protocol_sub_type: + description: + - A list of subtypes for the advertisement protocol. + required: false + default: null + type: list + elements: str + prefix_list: + description: + - A list of prefix lists associated with the advertisement + settings. + required: false + default: null + type: list + elements: dict + suboptions: + prefix_entry: + description: + - The network prefix entry for the prefix list. + required: true + default: null + type: str + aggregate_only: + description: + - A flag indicating if only aggregate routes should + be considered. + required: false + default: null + type: str + region: + description: + - The network region where the prefix list is applied. + required: false + default: null + type: str + choices: + - core + - access + ipv6_advertise: + description: + - A list of configurations for advertising IPv6 routes via OMP within + the VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + protocol: + description: + - The IPv6 protocol used for route advertisement. + required: true + default: null + type: str + choices: + - bgp + - ospf + - connected + - static + - network + - aggregate + route_policy: + description: + - The IPv6 route policy associated with advertisement. + required: false + default: null + type: str + protocol_sub_type: + description: + - A list of subtypes for the IPv6 advertisement protocol. + required: false + default: null + type: list + elements: str + prefix_list: + description: + - A list of IPv6 prefix lists associated with the advertisement + settings. + required: false + default: null + type: list + elements: dict + suboptions: + prefix_entry: + description: + - The network prefix entry for the prefix list. + required: true + default: null + type: str + aggregate_only: + description: + - A flag indicating if only aggregate routes should + be considered. + required: false + default: null + type: str + region: + description: + - The network region where the prefix list is applied. + required: false + default: null + type: str + choices: + - core + - access + pool: + description: + - A list of NAT64 pool configurations within the VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + name: + description: + - The name of the IP address pool. + required: true + default: null + type: str + start_address: + description: + - The starting IP address of the pool. + required: true + default: null + type: str + end_address: + description: + - The ending IP address of the pool. + required: true + default: null + type: str + overload: + description: + - A flag indicating whether address overload is allowed. + required: false + default: null + type: str + leak_from_global: + description: + - A flag indicating whether leaking from the global table + is enabled. + required: true + default: null + type: bool + leak_from_global_protocol: + description: + - The protocol used for leaking from the global routing table. + required: true + default: null + type: str + choices: + - all + - static + - mobile + - connected + - rip + - odr + leak_to_global: + description: + - A flag indicating whether leaking to the global table is + enabled. + required: true + default: null + type: bool + natpool: + description: + - A list of NAT pool configurations within the VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + name: + description: + - The identifier for the NAT pool. + required: true + default: null + type: str + prefix_length: + description: + - The length of the network prefix for the NAT pool. + required: false + default: null + type: str + range_start: + description: + - The starting IP address for the NAT pool range. + required: false + default: null + type: str + range_end: + description: + - The ending IP address for the NAT pool range. + required: false + default: null + type: str + overload: + description: + - Flag indicating whether NAT overload (PAT) is enabled for + the pool. + required: false + default: 'true' + type: str + choices: + - 'true' + - 'false' + direction: + description: + - The direction (inside or outside) associated with the NAT + pool. + required: true + default: null + type: str + choices: + - inside + - outside + tracker_id: + description: + - The tracker identifier associated with the NAT pool. + required: false + default: null + type: str + static: + description: + - A list of static configurations within the VPN instance for NAT. + required: false + default: null + type: list + elements: dict + suboptions: + pool_name: + description: + - The identifier for the NAT pool associated with the static + NAT rule. + required: false + default: null + type: str + source_ip: + description: + - The original source IP address to be translated by static + NAT. + required: false + default: null + type: str + translate_ip: + description: + - The translated IP address used by static NAT. + required: false + default: null + type: str + static_nat_direction: + description: + - The direction (inside or outside) for the static NAT rule. + required: true + default: null + type: str + choices: + - inside + - outside + tracker_id: + description: + - The tracker identifier associated with the static NAT rule. + required: false + default: null + type: str + subnet_static: + description: + - A list of subnet-specific static configurations within the VPN instance + for NAT. + required: false + default: null + type: list + elements: dict + suboptions: + source_ip_subnet: + description: + - The original source IP subnet to be translated by static + NAT. + required: true + default: null + type: str + translate_ip_subnet: + description: + - The translated IP subnet used by static NAT. + required: true + default: null + type: str + prefix_length: + description: + - The prefix length for the translated IP subnet in static + NAT. + required: true + default: null + type: str + static_nat_direction: + description: + - The direction (inside or outside) for the subnet static + NAT rule. + required: true + default: null + type: str + choices: + - inside + - outside + tracker_id: + description: + - The tracker identifier associated with the subnet static + NAT rule. + required: false + default: null + type: str + port_forward: + description: + - A list of port forwarding configurations within the VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + pool_name: + description: + - The identifier for the NAT pool associated with the port + forwarding rule. + required: false + default: null + type: str + source_port: + description: + - The source port number for the port forwarding rule. + required: true + default: null + type: str + translate_port: + description: + - The destination port number to which the source port is + translated. + required: true + default: null + type: str + source_ip: + description: + - The source IP address for the port forwarding rule. + required: true + default: null + type: str + translate_ip: + description: + - The destination IP address to which the source IP is translated. + required: true + default: null + type: str + proto: + description: + - The protocol used in the port forwarding rule (TCP/UDP). + required: true + default: null + type: str + choices: + - tcp + - udp + route_import: + description: + - A list of route import configurations within the VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + protocol: + description: + - The protocol from which routes are to be imported. + required: true + default: null + type: str + choices: + - static + - connected + - bgp + - ospf + protocol_sub_type: + description: + - The list of subtypes for the import protocol. + required: true + default: null + type: list + elements: str + route_policy: + description: + - The route policy that specifies the conditions for route + import. + required: false + default: null + type: str + redistribute: + description: + - A list of redistribute configurations that define how routes + from other protocols are imported. + required: false + default: null + type: list + elements: dict + suboptions: + protocol: + description: + - The protocol from which routes are to be redistributed. + required: true + default: null + type: str + choices: + - bgp + - eigrp + - ospf + route_policy: + description: + - The route policy that specifies the conditions for + route redistribution. + required: false + default: null + type: str + route_import_from: + description: + - A list of configurations specifying routes to import from other + sources into the VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + source_vpn: + description: + - The VPN instance (VRF) from which routes are to be imported. + required: true + default: null + type: str + protocol: + description: + - The routing protocol from which routes are to be imported. + required: true + default: null + type: str + choices: + - static + - connected + - bgp + - ospf + - eigrp + protocol_sub_type: + description: + - The list of protocol subtypes for route importation. + required: true + default: null + type: list + elements: str + route_policy: + description: + - The route policy that specifies the criteria for route importation. + required: false + default: null + type: str + redistribute: + description: + - A list of route redistribution configurations specifying + how routes from other protocols are imported. + required: false + default: null + type: list + elements: dict + suboptions: + protocol: + description: + - The protocol from which routes are to be redistributed + into the local routing table. + required: true + default: null + type: str + choices: + - bgp + - eigrp + - ospf + route_policy: + description: + - The route policy that defines the conditions for + route redistribution. + required: false + default: null + type: str + route_export: + description: + - A list of route export configurations within the VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + protocol: + description: + - The routing protocol to which routes are to be exported. + required: true + default: null + type: str + choices: + - static + - connected + - bgp + - eigrp + - ospf + protocol_sub_type: + description: + - The list of protocol subtypes for route exportation. + required: true + default: null + type: list + elements: str + route_policy: + description: + - The route policy that specifies the criteria for route exportation. + required: false + default: null + type: str + redistribute: + description: + - A list of route redistribution configurations specifying + how routes from other protocols are exported. + required: false + default: null + type: list + elements: dict + suboptions: + protocol: + description: + - The protocol from which routes are to be redistributed + out of the local routing table. + required: true + default: null + type: str + choices: + - bgp + - ospf + route_policy: + description: + - The route policy that defines the conditions for + route redistribution. + required: false + default: null + type: str + """ diff --git a/plugins/doc_fragments/feature_template_cisco_vpn_interface.py b/plugins/doc_fragments/feature_template_cisco_vpn_interface.py new file mode 100644 index 0000000..6106f81 --- /dev/null +++ b/plugins/doc_fragments/feature_template_cisco_vpn_interface.py @@ -0,0 +1,1179 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" +options: + cisco_vpn_interface: + description: Cisco VPN Interface Feature Template configuration + type: dict + suboptions: + if_name: + description: + - The name of the interface. + required: false + default: null + type: str + interface_description: + description: + - A description for the interface. + required: false + default: null + type: str + poe: + description: + - Power over Ethernet setting for the interface. True if enabled, + False otherwise. + required: false + default: null + type: str + ipv4_address: + description: + - The primary IPv4 address assigned to the interface. + required: false + default: null + type: str + secondary_ipv4_address: + description: + - A list of secondary IPv4 addresses assigned to the interface. + required: false + default: null + type: list + elements: dict + suboptions: + address: + description: + - IPv4 address with CIDR notation for the secondary interface. + required: false + default: null + type: str + dhcp_ipv4_client: + description: + - Whether DHCP client is enabled on the interface for IPv4 addressing. + True if enabled, False otherwise. + required: false + default: null + type: str + dhcp_distance: + description: + - Administrative distance for DHCP routes on the interface. + required: false + default: null + type: str + ipv6_address: + description: + - The primary IPv6 address assigned to the interface. + required: false + default: null + type: str + dhcp_ipv6_client: + description: + - Whether DHCP client is enabled on the interface for IPv6 addressing. + True if enabled, False otherwise. + required: false + default: null + type: str + secondary_ipv6_address: + description: + - A list of secondary IPv6 addresses assigned to the interface. + required: false + default: null + type: list + elements: dict + suboptions: + address: + description: + - IPv6 address with CIDR notation for the secondary interface. + required: false + default: null + type: str + access_list_ipv4: + description: + - A list of IPv4 access control lists (ACLs) applied to the interface. + required: false + default: null + type: list + elements: dict + suboptions: + direction: + description: + - Direction of the traffic flow for applying the ACL ('in' + or 'out'). + required: true + default: null + type: str + choices: + - in + - out + acl_name: + description: + - Name of the access control list. + required: true + default: null + type: str + dhcp_helper: + description: + - A list of DHCP helper addresses configured on the interface. + required: false + default: null + type: list + elements: str + dhcp_helper_v6: + description: + - A list of DHCPv6 helper configurations applied to the interface. + required: false + default: null + type: list + elements: dict + suboptions: + address: + description: + - IPv6 address of the DHCP server or relay. + required: true + default: null + type: str + vpn: + description: + - Optional VPN ID where the DHCP helper is configured. + required: false + default: null + type: str + tracker: + description: + - A list of tracker identifiers associated with the interface. + required: false + default: null + type: list + elements: str + auto_bandwidth_detect: + description: + - Whether automatic bandwidth detection is enabled on the interface. + True if enabled, False otherwise. + required: false + default: null + type: str + iperf_server: + description: + - The IP address of the iPerf server used for performance testing + from this interface. + required: false + default: null + type: str + nat: + description: + - Indicates whether Network Address Translation (NAT) is enabled on + the interface. + required: false + default: null + type: str + nat_choice: + description: + - The type of NAT configured on the interface, if applicable. + required: false + default: null + type: str + choices: + - Interface + - Pool + - Loopback + udp_timeout: + description: + - The timeout value in seconds for UDP connections through the NAT + on this interface. + required: false + default: null + type: str + tcp_timeout: + description: + - The timeout value in seconds for TCP connections through the NAT + on this interface. + required: false + default: null + type: str + nat_range_start: + description: + - The starting IP address in the range used for NAT on this interface. + required: false + default: null + type: str + nat_range_end: + description: + - The ending IP address in the range used for NAT on this interface. + required: false + default: null + type: str + overload: + description: + - Indicates if NAT overload (PAT - Port Address Translation) is enabled. + required: false + default: null + type: str + loopback_interface: + description: + - The associated loopback interface, if any, for the VPN interface. + required: false + default: null + type: str + prefix_length: + description: + - The prefix length for the interface's IP address, indicating the + size of the subnet. + required: false + default: null + type: str + enable: + description: + - Indicates whether the interface is enabled or disabled. + required: false + default: null + type: str + nat64: + description: + - Indicates whether NAT64 is enabled on the interface, allowing IPv6 + addresses to communicate with IPv4 services. + required: false + default: null + type: str + nat66: + description: + - Indicates whether NAT66 is enabled on the interface, translating + IPv6 addresses into IPv6 addresses. + required: false + default: null + type: str + static_nat66: + description: + - List of static NAT66 entries for translating IPv6 addresses into + other IPv6 addresses. + required: false + default: null + type: list + elements: dict + suboptions: + source_prefix: + description: + - IPv6 network prefix that is to be translated. + required: true + default: null + type: str + translated_source_prefix: + description: + - IPv6 network prefix to which the source prefix is translated. + required: true + default: null + type: str + source_vpn_id: + description: + - VPN ID associated with the source network prefix. + required: false + default: null + type: str + static: + description: + - List of static NAT entries for configuring one-to-one address mappings. + required: false + default: null + type: list + elements: dict + suboptions: + source_ip: + description: + - IPv4 address of the source IP for static NAT. + required: true + default: null + type: str + translate_ip: + description: + - IPv4 address used for translation in static NAT. + required: true + default: null + type: str + static_nat_direction: + description: + - Direction of static NAT mapping ('inside' or 'outside'). + required: false + default: inside + type: str + choices: + - inside + - outside + source_vpn: + description: + - VPN ID associated with the source IP for static NAT. + required: false + default: null + type: str + static_port_forward: + description: + - List of static port forwarding entries for the interface. + required: false + default: null + type: list + elements: dict + suboptions: + source_ip: + description: + - IPv4 address of the source IP for port forwarding. + required: true + default: null + type: str + translate_ip: + description: + - IPv4 address used for translation in port forwarding. + required: true + default: null + type: str + static_nat_direction: + description: + - Direction of port forwarding mapping ('inside' or 'outside'). + required: false + default: inside + type: str + choices: + - inside + - outside + source_port: + description: + - Source port number for port forwarding. + required: false + default: null + type: str + translate_port: + description: + - Translated port number for port forwarding. + required: false + default: null + type: str + proto: + description: + - Protocol used for port forwarding (TCP/UDP). + required: true + default: null + type: str + choices: + - tcp + - udp + source_vpn: + description: + - VPN ID associated with the source IP for port forwarding. + required: false + default: null + type: str + enable_core_region: + description: + - Indicates if the interface is part of the core network region for + centralized services. + required: false + default: null + type: str + core_region: + description: + - Configuration details for the core region. + required: false + default: null + type: str + choices: + - core + - core-shared + secondary_region: + description: + - Configuration details for a secondary region. + required: false + default: null + type: str + choices: + - 'off' + - secondary-only + - secondary-shared + tloc_encapsulation: + description: + - Transport Location (TLOC) encapsulation settings. + required: false + default: null + type: list + elements: dict + suboptions: + encap: + description: + - Type of encapsulation used for the VPN tunnel (GRE/IPsec). + required: true + default: null + type: str + choices: + - gre + - ipsec + preference: + description: + - Preference value for the encapsulation type (lower values + have higher priority). + required: false + default: null + type: str + weight: + description: + - Weight for the encapsulation type used in load balancing + decisions. + required: false + default: null + type: str + border: + description: + - Defines if the interface is at the border of a network segment. + required: false + default: null + type: str + per_tunnel_qos: + description: + - Enable or disable per-tunnel Quality of Service (QoS). + required: false + default: null + type: str + per_tunnel_qos_aggregator: + description: + - Enable or disable per-tunnel QoS aggregator. + required: false + default: null + type: str + mode: + description: + - Defines the operating mode for the interface. + required: false + default: null + type: str + choices: + - hub + - spoke + tunnels_bandwidth: + description: + - Specifies the total bandwidth available across all tunnels. + required: false + default: null + type: str + group: + description: + - Identifies the group or groups the interface belongs to. + required: false + default: null + type: list + elements: str + value: + description: + - The value field often corresponds to a specific attribute or setting, + such as color in this context. + required: false + default: null + type: str + choices: + - default + - mpls + - metro-ethernet + - biz-internet + - public-internet + - lte + - 3g + - red + - green + - blue + - gold + - silver + - bronze + - custom1 + - custom2 + - custom3 + - private1 + - private2 + - private3 + - private4 + - private5 + - private6 + max_control_connections: + description: + - Maximum number of control connections that can be established on + the interface. + required: false + default: null + type: str + control_connections: + description: + - Enables or disables control connections on the interface. + required: false + default: null + type: str + vbond_as_stun_server: + description: + - Configures the vBond orchestrator to act as a STUN server for the + interface. + required: false + default: null + type: str + exclude_controller_group_list: + description: + - List of controller groups to exclude from connections. + required: false + default: null + type: list + elements: str + vmanage_connection_preference: + description: + - Preference value for establishing vManage connections. + required: false + default: null + type: str + port_hop: + description: + - Enables or disables port hopping for the interface to evade port + blocking. + required: false + default: null + type: str + restrict: + description: + - Indicates whether the interface color is restricted for use. + required: false + default: null + type: str + dst_ip: + description: + - Destination IP address for GRE (Generic Routing Encapsulation) tunnel + extension. + required: false + default: null + type: str + carrier: + description: + - Specifies the carrier information for the tunnel interface. + required: false + default: null + type: str + choices: + - default + - carrier1 + - carrier2 + - carrier3 + - carrier4 + - carrier5 + - carrier6 + - carrier7 + - carrier8 + nat_refresh_interval: + description: + - Interval in seconds to refresh NAT (Network Address Translation) + mappings. + required: false + default: null + type: str + hello_interval: + description: + - Time interval in seconds between successive hello packets sent over + the tunnel interface. + required: false + default: null + type: str + hello_tolerance: + description: + - Time in seconds to wait before declaring a neighbor down due to + missing hello packets. + required: false + default: null + type: str + bind: + description: + - Interface or IP address to which the tunnel interface is bound. + required: false + default: null + type: str + last_resort_circuit: + description: + - Marks the interface as a last resort circuit for traffic to fall + back to. + required: false + default: null + type: str + low_bandwidth_link: + description: + - Indicates if the link is considered a low bandwidth link. + required: false + default: null + type: str + tunnel_tcp_mss_adjust: + description: + - Adjusts the Maximum Segment Size (MSS) value for TCP connections + over the tunnel. + required: false + default: null + type: str + clear_dont_fragment: + description: + - Enables or disables the clearing of the 'Don't Fragment' (DF) bit + in the IP header. + required: false + default: null + type: str + propagate_sgt: + description: + - Enables or disables the propagation of Security Group Tags (SGTs) + across the tunnel interface. + required: false + default: null + type: str + network_broadcast: + description: + - Allows or disallows network broadcast traffic through the tunnel + interface. + required: false + default: null + type: str + all: + description: + - Permits or denies all services through the tunnel interface. + required: false + default: null + type: str + bgp: + description: + - Allows or disallows Border Gateway Protocol (BGP) traffic through + the tunnel interface. + required: false + default: null + type: str + dhcp: + description: + - Enables or disables Dynamic Host Configuration Protocol (DHCP) on + the tunnel interface. + required: false + default: null + type: str + dns: + description: + - Allows or disallows Domain Name System (DNS) queries through the + tunnel interface. + required: false + default: null + type: str + icmp: + description: + - Enables or disables Internet Control Message Protocol (ICMP) for + ping and traceroute through the tunnel interface. + required: false + default: null + type: str + sshd: + description: + - Allows or disallows Secure Shell (SSH) daemon access through the + tunnel interface. + required: false + default: null + type: str + netconf: + description: + - Enables or disables NETCONF protocol support on the tunnel interface. + required: false + default: null + type: str + ntp: + description: + - Allows or disallows Network Time Protocol (NTP) synchronization + through the tunnel interface. + required: false + default: null + type: str + ospf: + description: + - Permits or denies Open Shortest Path First (OSPF) routing protocol + traffic through the tunnel interface. + required: false + default: null + type: str + stun: + description: + - Enables or disables Session Traversal Utilities for NAT (STUN) on + the tunnel interface. + required: false + default: null + type: str + snmp: + description: + - Allows or disallows Simple Network Management Protocol (SNMP) through + the tunnel interface. + required: false + default: null + type: str + https: + description: + - Permits or denies HTTPS traffic through the tunnel interface. + required: false + default: null + type: str + media_type: + description: + - Specifies the media type used by the interface, such as copper or + fiber. + required: false + default: null + type: str + choices: + - auto-select + - rj45 + - sfp + intrf_mtu: + description: + - Sets the Maximum Transmission Unit (MTU) size for the interface. + required: false + default: null + type: str + mtu: + description: + - Specifies the MTU size for the tunnel or logical interface. + required: false + default: null + type: str + tcp_mss_adjust: + description: + - Adjusts the TCP Maximum Segment Size (MSS) value for connections + over the interface. + required: false + default: null + type: str + tloc_extension: + description: + - Defines the Transport Location (TLOC) extension for the interface. + required: false + default: null + type: str + load_interval: + description: + - Sets the time interval in seconds for calculating interface load + statistics. + required: false + default: null + type: str + src_ip: + description: + - Source IP address for GRE tunnel extension. + required: false + default: null + type: str + xconnect: + description: + - Cross-connect identifier for the GRE tunnel extension. + required: false + default: null + type: str + mac_address: + description: + - Specifies the MAC address for the interface. + required: false + default: null + type: str + speed: + description: + - Defines the speed of the interface, such as 10Mbps, 100Mbps, or + 1Gbps. + required: false + default: null + type: str + choices: + - '10' + - '100' + - '1000' + - '2500' + - '10000' + duplex: + description: + - Sets the duplex mode for the interface, such as full or half duplex. + required: false + default: null + type: str + choices: + - full + - half + - auto + shutdown: + description: + - Enables or disables (shuts down) the interface. + required: false + default: null + type: str + arp_timeout: + description: + - Time in seconds before an ARP cache entry is timed out. + required: false + default: null + type: str + autonegotiate: + description: + - Enables or disables autonegotiation of speed and duplex settings + on the interface. + required: false + default: null + type: str + ip_directed_broadcast: + description: + - Allows or disallows IP directed broadcasts on the interface. + required: false + default: null + type: str + icmp_redirect_disable: + description: + - Enables or disables ICMP redirect messages on the interface. + required: false + default: null + type: str + qos_adaptive: + description: + - Activates or deactivates adaptive QoS on the interface. + required: false + default: null + type: str + period: + description: + - Time period in seconds for measuring and adapting QoS settings. + required: false + default: null + type: str + bandwidth_down: + description: + - Specifies the downstream bandwidth in Kbps for adaptive QoS calculations. + required: false + default: null + type: str + dmin: + description: + - Specifies the minimum downstream bandwidth in Kbps for adaptive + QoS. + required: false + default: null + type: str + dmax: + description: + - Specifies the maximum downstream bandwidth in Kbps for adaptive + QoS. + required: false + default: null + type: str + bandwidth_up: + description: + - Specifies the upstream bandwidth in Kbps for adaptive QoS calculations. + required: false + default: null + type: str + umin: + description: + - Specifies the minimum upstream bandwidth in Kbps for adaptive QoS. + required: false + default: null + type: str + umax: + description: + - Specifies the maximum upstream bandwidth in Kbps for adaptive QoS. + required: false + default: null + type: str + shaping_rate: + description: + - Defines the traffic shaping rate for the interface. + required: false + default: null + type: str + qos_map: + description: + - Associates a QoS map with the interface for traffic classification + and prioritization. + required: false + default: null + type: str + qos_map_vpn: + description: + - Associates a QoS map with a VPN for traffic classification and prioritization + within the VPN. + required: false + default: null + type: str + service_provider: + description: + - Identifies the service provider associated with the interface. + required: false + default: null + type: str + bandwidth_upstream: + description: + - Specifies the upstream bandwidth in Kbps available on the interface. + required: false + default: null + type: str + bandwidth_downstream: + description: + - Specifies the downstream bandwidth in Kbps available on the interface. + required: false + default: null + type: str + block_non_source_ip: + description: + - Enables or disables blocking of traffic with non-matching source + IP addresses. + required: false + default: null + type: str + rule_name: + description: + - Specifies the name of the rewrite rule applied to the interface. + required: false + default: null + type: str + access_list_ipv6: + description: + - Defines a list of access control entries for IPv6 traffic filtering. + required: false + default: null + type: list + elements: dict + suboptions: + direction: + description: + - Direction of the traffic flow for applying the ACL ('in' + or 'out'). + required: true + default: null + type: str + choices: + - in + - out + acl_name: + description: + - Name of the access control list. + required: true + default: null + type: str + ip: + description: + - A list of IP configurations for Address Resolution Protocol (ARP) + settings. + required: false + default: null + type: list + elements: dict + suboptions: + addr: + description: + - IPv4 address for the interface. + required: true + default: null + type: str + mac: + description: + - MAC address associated with the IPv4 address. + required: true + default: null + type: str + vrrp: + description: + - A list of Virtual Router Redundancy Protocol (VRRP) configurations + for IPv4. + required: false + default: null + type: list + elements: dict + suboptions: + grp_id: + description: + - VRRP group ID. + required: true + default: null + type: str + priority: + description: + - Priority value for the VRRP group (higher values take precedence). + required: false + default: null + type: str + timer: + description: + - VRRP advertisement interval timer in milliseconds. + required: false + default: null + type: str + track_omp: + description: + - Flag to track Overlay Management Protocol (OMP) session + state. + required: false + default: null + type: bool + track_prefix_list: + description: + - Name of the prefix-list used for tracking specific routes. + required: false + default: null + type: str + address: + description: + - Virtual IP address used by the VRRP group. + required: false + default: null + type: str + ipv4_secondary: + description: + - List of secondary IPv4 addresses for the VRRP group. + required: false + default: null + type: list + elements: dict + suboptions: + address: + description: + - IPv4 address for the secondary interface. + required: true + default: null + type: str + tloc_change_pref: + description: + - Flag to change preference based on TLOC status. + required: false + default: null + type: bool + value: + description: + - VRRP value to determine the primary node for the VRRP group. + required: true + default: null + type: str + tracking_object: + description: + - List of tracking objects associated with the VRRP configuration. + required: false + default: null + type: list + elements: dict + suboptions: + name: + description: + - Unique identifier for the tracking object. + required: true + default: null + type: str + track_action: + description: + - Action to take when the tracked object state changes + (e.g., decrement priority or shutdown). + required: false + default: Decrement + type: str + choices: + - Decrement + - Shutdown + decrement: + description: + - Value by which to decrement the VRRP priority when + the tracked object is down. + required: true + default: null + type: str + ipv6_vrrp: + description: + - A list of Virtual Router Redundancy Protocol (VRRP) configurations + for IPv6. + required: false + default: null + type: list + elements: dict + suboptions: + grp_id: + description: + - IPv6 VRRP group ID. + required: true + default: null + type: str + priority: + description: + - Priority value for the IPv6 VRRP group (higher values take + precedence). + required: false + default: null + type: str + timer: + description: + - IPv6 VRRP advertisement interval timer in milliseconds. + required: false + default: null + type: str + track_omp: + description: + - Flag to track Overlay Management Protocol (OMP) session + state for IPv6. + required: false + default: null + type: bool + track_prefix_list: + description: + - Name of the IPv6 prefix-list used for tracking specific + routes. + required: false + default: null + type: str + ipv6: + description: + - List of IPv6 configurations associated with the VRRP group. + required: false + default: null + type: list + elements: dict + suboptions: + ipv6_link_local: + description: + - IPv6 link-local address for the interface. + required: true + default: null + type: str + prefix: + description: + - Optional IPv6 prefix for the interface, with CIDR + notation. + required: false + default: null + type: str + enable_sgt_propagation: + description: + - Enables or disables Security Group Tag (SGT) propagation. + required: false + default: null + type: str + security_group_tag: + description: + - Specifies a static Security Group Tag (SGT) for the interface. + required: false + default: null + type: str + trusted: + description: + - Marks the interface as trusted or untrusted for TrustSec. + required: false + default: null + type: str + enable_sgt_authorization_and_forwarding: + description: + - Enables or disables Security Group Tag (SGT) authorization and forwarding. + required: false + default: null + type: str + enable_sgt_enforcement: + description: + - Activates or deactivates Security Group Tag (SGT) enforcement. + required: false + default: null + type: str + enforcement_sgt: + description: + - Specifies the Security Group Tag (SGT) to be enforced on the interface. + required: false + default: null + type: str + """ diff --git a/plugins/doc_fragments/feature_template_omp_vsmart.py b/plugins/doc_fragments/feature_template_omp_vsmart.py new file mode 100644 index 0000000..9c23168 --- /dev/null +++ b/plugins/doc_fragments/feature_template_omp_vsmart.py @@ -0,0 +1,81 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" +options: + omp_vsmart: + description: Overlay Management Protocol (OMP) settings for vSmart controller + type: dict + suboptions: + graceful_restart: + description: + - Enable or disable graceful restart for the OMP session + required: false + default: null + type: str + send_path_limit: + description: + - The maximum number of paths that can be sent to a TLOC + required: false + default: null + type: str + send_backup_paths: + description: + - Enable or disable sending additional backup paths + required: false + default: null + type: str + discard_rejected: + description: + - Discard routes that are rejected by policy instead of marking them + as rejected + required: false + default: null + type: str + shutdown: + description: + - Enable or disable the shutdown of the OMP session + required: false + default: null + type: str + graceful_restart_timer: + description: + - The time interval for graceful restart of OMP sessions + required: false + default: null + type: str + eor_timer: + description: + - The End of Routes (EOR) timer value + required: false + default: null + type: str + holdtime: + description: + - The hold time interval for OMP sessions + required: false + default: null + type: str + affinity_group_preference: + description: + - Prefer routes from the same affinity group + required: false + default: null + type: str + advertisement_interval: + description: + - Interval between sending OMP route advertisements + required: false + default: null + type: str + """ diff --git a/plugins/doc_fragments/feature_template_security_vsmart.py b/plugins/doc_fragments/feature_template_security_vsmart.py new file mode 100644 index 0000000..2db1233 --- /dev/null +++ b/plugins/doc_fragments/feature_template_security_vsmart.py @@ -0,0 +1,35 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" +options: + security_vsmart: + description: Security settings for vSmart controller + type: dict + suboptions: + protocol: + description: + - The security protocol used for control plane communication + required: false + default: null + type: str + choices: + - dtls + - tls + tls_port: + description: + - The port used for TLS communications + required: false + default: null + type: str + """ diff --git a/plugins/doc_fragments/feature_template_system_vsmart.py b/plugins/doc_fragments/feature_template_system_vsmart.py new file mode 100644 index 0000000..2450009 --- /dev/null +++ b/plugins/doc_fragments/feature_template_system_vsmart.py @@ -0,0 +1,557 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" +options: + system_vsmart: + description: Security settings for vSmart controller + type: dict + suboptions: + timezone: + description: + - The timezone setting for the vSmart controller + required: false + default: null + type: str + choices: + - Europe/Andorra + - Asia/Dubai + - Asia/Kabul + - America/Antigua + - America/Anguilla + - Europe/Tirane + - Asia/Yerevan + - Africa/Luanda + - Antarctica/McMurdo + - Antarctica/Rothera + - Antarctica/Palmer + - Antarctica/Mawson + - Antarctica/Davis + - Antarctica/Casey + - Antarctica/Vostok + - Antarctica/DumontDUrville + - Antarctica/Syowa + - America/Argentina/Buenos_Aires + - America/Argentina/Cordoba + - America/Argentina/Salta + - America/Argentina/Jujuy + - America/Argentina/Tucuman + - America/Argentina/Catamarca + - America/Argentina/La_Rioja + - America/Argentina/San_Juan + - America/Argentina/Mendoza + - America/Argentina/San_Luis + - America/Argentina/Rio_Gallegos + - America/Argentina/Ushuaia + - Pacific/Pago_Pago + - Europe/Vienna + - Australia/Lord_Howe + - Antarctica/Macquarie + - Australia/Hobart + - Australia/Currie + - Australia/Melbourne + - Australia/Sydney + - Australia/Broken_Hill + - Australia/Brisbane + - Australia/Lindeman + - Australia/Adelaide + - Australia/Darwin + - Australia/Perth + - Australia/Eucla + - America/Aruba + - Europe/Mariehamn + - Asia/Baku + - Europe/Sarajevo + - America/Barbados + - Asia/Dhaka + - Europe/Brussels + - Africa/Ouagadougou + - Europe/Sofia + - Asia/Bahrain + - Africa/Bujumbura + - Africa/Porto-Novo + - America/St_Barthelemy + - Atlantic/Bermuda + - Asia/Brunei + - America/La_Paz + - America/Kralendijk + - America/Noronha + - America/Belem + - America/Fortaleza + - America/Recife + - America/Araguaina + - America/Maceio + - America/Bahia + - America/Sao_Paulo + - America/Campo_Grande + - America/Cuiaba + - America/Santarem + - America/Porto_Velho + - America/Boa_Vista + - America/Manaus + - America/Eirunepe + - America/Rio_Branco + - America/Nassau + - Asia/Thimphu + - Africa/Gaborone + - Europe/Minsk + - America/Belize + - America/St_Johns + - America/Halifax + - America/Glace_Bay + - America/Moncton + - America/Goose_Bay + - America/Blanc-Sablon + - America/Toronto + - America/Nipigon + - America/Thunder_Bay + - America/Iqaluit + - America/Pangnirtung + - America/Resolute + - America/Atikokan + - America/Rankin_Inlet + - America/Winnipeg + - America/Rainy_River + - America/Regina + - America/Swift_Current + - America/Edmonton + - America/Cambridge_Bay + - America/Yellowknife + - America/Inuvik + - America/Creston + - America/Dawson_Creek + - America/Vancouver + - America/Whitehorse + - America/Dawson + - Indian/Cocos + - Africa/Kinshasa + - Africa/Lubumbashi + - Africa/Bangui + - Africa/Brazzaville + - Europe/Zurich + - Africa/Abidjan + - Pacific/Rarotonga + - America/Santiago + - Pacific/Easter + - Africa/Douala + - Asia/Shanghai + - Asia/Harbin + - Asia/Chongqing + - Asia/Urumqi + - Asia/Kashgar + - America/Bogota + - America/Costa_Rica + - America/Havana + - Atlantic/Cape_Verde + - America/Curacao + - Indian/Christmas + - Asia/Nicosia + - Europe/Prague + - Europe/Berlin + - Europe/Busingen + - Africa/Djibouti + - Europe/Copenhagen + - America/Dominica + - America/Santo_Domingo + - Africa/Algiers + - America/Guayaquil + - Pacific/Galapagos + - Europe/Tallinn + - Africa/Cairo + - Africa/El_Aaiun + - Africa/Asmara + - Europe/Madrid + - Africa/Ceuta + - Atlantic/Canary + - Africa/Addis_Ababa + - Europe/Helsinki + - Pacific/Fiji + - Atlantic/Stanley + - Pacific/Chuuk + - Pacific/Pohnpei + - Pacific/Kosrae + - Atlantic/Faroe + - Europe/Paris + - Africa/Libreville + - Europe/London + - America/Grenada + - Asia/Tbilisi + - America/Cayenne + - Europe/Guernsey + - Africa/Accra + - Europe/Gibraltar + - America/Godthab + - America/Danmarkshavn + - America/Scoresbysund + - America/Thule + - Africa/Banjul + - Africa/Conakry + - America/Guadeloupe + - Africa/Malabo + - Europe/Athens + - Atlantic/South_Georgia + - America/Guatemala + - Pacific/Guam + - Africa/Bissau + - America/Guyana + - Asia/Hong_Kong + - America/Tegucigalpa + - Europe/Zagreb + - America/Port-au-Prince + - Europe/Budapest + - Asia/Jakarta + - Asia/Pontianak + - Asia/Makassar + - Asia/Jayapura + - Europe/Dublin + - Asia/Jerusalem + - Europe/Isle_of_Man + - Asia/Kolkata + - Indian/Chagos + - Asia/Baghdad + - Asia/Tehran + - Atlantic/Reykjavik + - Europe/Rome + - Europe/Jersey + - America/Jamaica + - Asia/Amman + - Asia/Tokyo + - Africa/Nairobi + - Asia/Bishkek + - Asia/Phnom_Penh + - Pacific/Tarawa + - Pacific/Enderbury + - Pacific/Kiritimati + - Indian/Comoro + - America/St_Kitts + - Asia/Pyongyang + - Asia/Seoul + - Asia/Kuwait + - America/Cayman + - Asia/Almaty + - Asia/Qyzylorda + - Asia/Aqtobe + - Asia/Aqtau + - Asia/Oral + - Asia/Vientiane + - Asia/Beirut + - America/St_Lucia + - Europe/Vaduz + - Asia/Colombo + - Africa/Monrovia + - Africa/Maseru + - Europe/Vilnius + - Europe/Luxembourg + - Europe/Riga + - Africa/Tripoli + - Africa/Casablanca + - Europe/Monaco + - Europe/Chisinau + - Europe/Podgorica + - America/Marigot + - Indian/Antananarivo + - Pacific/Majuro + - Pacific/Kwajalein + - Europe/Skopje + - Africa/Bamako + - Asia/Rangoon + - Asia/Ulaanbaatar + - Asia/Hovd + - Asia/Choibalsan + - Asia/Macau + - Pacific/Saipan + - America/Martinique + - Africa/Nouakchott + - America/Montserrat + - Europe/Malta + - Indian/Mauritius + - Indian/Maldives + - Africa/Blantyre + - America/Mexico_City + - America/Cancun + - America/Merida + - America/Monterrey + - America/Matamoros + - America/Mazatlan + - America/Chihuahua + - America/Ojinaga + - America/Hermosillo + - America/Tijuana + - America/Santa_Isabel + - America/Bahia_Banderas + - Asia/Kuala_Lumpur + - Asia/Kuching + - Africa/Maputo + - Africa/Windhoek + - Pacific/Noumea + - Africa/Niamey + - Pacific/Norfolk + - Africa/Lagos + - America/Managua + - Europe/Amsterdam + - Europe/Oslo + - Asia/Kathmandu + - Pacific/Nauru + - Pacific/Niue + - Pacific/Auckland + - Pacific/Chatham + - Asia/Muscat + - America/Panama + - America/Lima + - Pacific/Tahiti + - Pacific/Marquesas + - Pacific/Gambier + - Pacific/Port_Moresby + - Asia/Manila + - Asia/Karachi + - Europe/Warsaw + - America/Miquelon + - Pacific/Pitcairn + - America/Puerto_Rico + - Asia/Gaza + - Asia/Hebron + - Europe/Lisbon + - Atlantic/Madeira + - Atlantic/Azores + - Pacific/Palau + - America/Asuncion + - Asia/Qatar + - Indian/Reunion + - Europe/Bucharest + - Europe/Belgrade + - Europe/Kaliningrad + - Europe/Moscow + - Europe/Volgograd + - Europe/Samara + - Asia/Yekaterinburg + - Asia/Omsk + - Asia/Novosibirsk + - Asia/Novokuznetsk + - Asia/Krasnoyarsk + - Asia/Irkutsk + - Asia/Yakutsk + - Asia/Khandyga + - Asia/Vladivostok + - Asia/Sakhalin + - Asia/Ust-Nera + - Asia/Magadan + - Asia/Kamchatka + - Asia/Anadyr + - Africa/Kigali + - Asia/Riyadh + - Pacific/Guadalcanal + - Indian/Mahe + - Africa/Khartoum + - Europe/Stockholm + - Asia/Singapore + - Atlantic/St_Helena + - Europe/Ljubljana + - Arctic/Longyearbyen + - Europe/Bratislava + - Africa/Freetown + - Europe/San_Marino + - Africa/Dakar + - Africa/Mogadishu + - America/Paramaribo + - Africa/Juba + - Africa/Sao_Tome + - America/El_Salvador + - America/Lower_Princes + - Asia/Damascus + - Africa/Mbabane + - America/Grand_Turk + - Africa/Ndjamena + - Indian/Kerguelen + - Africa/Lome + - Asia/Bangkok + - Asia/Dushanbe + - Pacific/Fakaofo + - Asia/Dili + - Asia/Ashgabat + - Africa/Tunis + - Pacific/Tongatapu + - Europe/Istanbul + - America/Port_of_Spain + - Pacific/Funafuti + - Asia/Taipei + - Africa/Dar_es_Salaam + - Europe/Kiev + - Europe/Uzhgorod + - Europe/Zaporozhye + - Europe/Simferopol + - Africa/Kampala + - Pacific/Johnston + - Pacific/Midway + - Pacific/Wake + - America/New_York + - America/Detroit + - America/Kentucky/Louisville + - America/Kentucky/Monticello + - America/Indiana/Indianapolis + - America/Indiana/Vincennes + - America/Indiana/Winamac + - America/Indiana/Marengo + - America/Indiana/Petersburg + - America/Indiana/Vevay + - America/Chicago + - America/Indiana/Tell_City + - America/Indiana/Knox + - America/Menominee + - America/North_Dakota/Center + - America/North_Dakota/New_Salem + - America/North_Dakota/Beulah + - America/Denver + - America/Boise + - America/Phoenix + - America/Los_Angeles + - America/Anchorage + - America/Juneau + - America/Sitka + - America/Yakutat + - America/Nome + - America/Adak + - America/Metlakatla + - Pacific/Honolulu + - America/Montevideo + - Asia/Samarkand + - Asia/Tashkent + - Europe/Vatican + - America/St_Vincent + - America/Caracas + - America/Tortola + - America/St_Thomas + - Asia/Ho_Chi_Minh + - Pacific/Efate + - Pacific/Wallis + - Pacific/Apia + - Asia/Aden + - Indian/Mayotte + - Africa/Johannesburg + - Africa/Lusaka + - Africa/Harare + - UTC + idle_timeout: + description: + - Idle timeout in minutes for user sessions + required: false + default: null + type: str + admin_tech_on_failure: + description: + - Enable automatic generation of tech-support file on failure + required: false + default: null + type: str + iptables_enable: + description: + - Enable or disable iptables for security + required: false + default: null + type: str + track_default_gateway: + description: + - Enable or disable tracking of the default gateway + required: false + default: null + type: str + dns_cache_timeout: + description: + - DNS cache timeout in minutes + required: false + default: null + type: str + track_transport: + description: + - Enable or disable tracking of transport connections + required: false + default: null + type: str + controller_group_id: + description: + - Group ID for the vSmart controller + required: false + default: null + type: str + control_session_pps: + description: + - Control session packets per second limit + required: false + default: null + type: str + port_hop: + description: + - Enable or disable port hopping + required: false + default: null + type: str + port_offset: + description: + - Port offset for port hopping + required: false + default: null + type: str + overlay_id: + description: + - Overlay ID for the vSmart controller + required: false + default: null + type: str + site_id: + description: + - Site ID for the vSmart controller + required: false + default: null + type: str + system_ip: + description: + - System IP address for the vSmart controller + required: false + default: null + type: str + device_groups: + description: + - Device group names for the vSmart controller + required: false + default: null + type: str + longitude: + description: + - Geographical longitude of the vSmart controller + required: false + default: null + type: str + latitude: + description: + - Geographical latitude of the vSmart controller + required: false + default: null + type: str + system_tunnel_mtu: + description: + - MTU size for system tunnels + required: false + default: null + type: str + location: + description: + - A description of the physical location of the vSmart controller + required: false + default: null + type: str + host_name: + description: + - The hostname for the vSmart controller + required: false + default: null + type: str + """ diff --git a/plugins/module_utils/feature_templates/cisco_aaa.py b/plugins/module_utils/feature_templates/cisco_aaa.py new file mode 100644 index 0000000..c86e137 --- /dev/null +++ b/plugins/module_utils/feature_templates/cisco_aaa.py @@ -0,0 +1,80 @@ +cisco_aaa_definition = { + "cisco_aaa": { + "default": None, + "options": { + "accounting_group": {"default": None, "required": False, "type": "bool"}, + "authentication_group": {"default": None, "required": False, "type": "bool"}, + "domain_stripping": {"default": None, "required": False, "type": "str"}, + "port": {"default": None, "required": False, "type": "str"}, + "radius": { + "default": None, + "elements": "dict", + "options": { + "group_name": {"default": None, "required": True, "type": "str"}, + "server": { + "default": [], + "elements": "dict", + "options": { + "acct_port": {"default": None, "required": False, "type": "str"}, + "address": {"default": None, "required": True, "type": "str"}, + "auth_port": {"default": None, "required": False, "type": "str"}, + "key": {"default": None, "required": True, "type": "str"}, + "key_enum": {"default": None, "required": False, "type": "str"}, + "key_type": {"default": None, "required": False, "type": "str"}, + "retransmit": {"default": None, "required": False, "type": "str"}, + "secret_key": {"default": None, "required": False, "type": "str"}, + "timeout": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "source_interface": {"default": None, "required": True, "type": "str"}, + "vpn": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "server_auth_order": {"default": None, "required": False, "type": "str"}, + "tacacs": { + "default": None, + "elements": "dict", + "options": { + "group_name": {"default": None, "required": True, "type": "str"}, + "server": { + "default": [], + "elements": "dict", + "options": { + "address": {"default": None, "required": True, "type": "str"}, + "key": {"default": None, "required": True, "type": "str"}, + "key_enum": {"default": None, "required": False, "type": "str"}, + "port": {"default": None, "required": False, "type": "str"}, + "secret_key": {"default": None, "required": False, "type": "str"}, + "timeout": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "source_interface": {"default": None, "required": False, "type": "str"}, + "vpn": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "user": { + "default": None, + "elements": "dict", + "options": { + "name": {"default": None, "required": True, "type": "str"}, + "password": {"default": None, "required": False, "type": "str"}, + "privilege": {"default": None, "required": False, "type": "str"}, + "pubkey_chain": {"default": [], "elements": "str", "required": False, "type": "list"}, + "secret": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_banner.py b/plugins/module_utils/feature_templates/cisco_banner.py new file mode 100644 index 0000000..94dc562 --- /dev/null +++ b/plugins/module_utils/feature_templates/cisco_banner.py @@ -0,0 +1,11 @@ +cisco_banner_definition = { + "cisco_banner": { + "default": None, + "options": { + "login_banner": {"default": None, "required": False, "type": "str"}, + "motd_banner": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_bfd.py b/plugins/module_utils/feature_templates/cisco_bfd.py new file mode 100644 index 0000000..d6a621e --- /dev/null +++ b/plugins/module_utils/feature_templates/cisco_bfd.py @@ -0,0 +1,25 @@ +cisco_bfd_definition = { + "cisco_bfd": { + "default": None, + "options": { + "color": { + "default": None, + "elements": "dict", + "options": { + "color": {"default": None, "required": True, "type": "str"}, + "dscp": {"default": None, "required": False, "type": "str"}, + "hello_interval": {"default": None, "required": False, "type": "str"}, + "multiplier": {"default": None, "required": False, "type": "str"}, + "pmtu_discovery": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "default_dscp": {"default": None, "required": False, "type": "str"}, + "multiplier": {"default": None, "required": False, "type": "str"}, + "poll_interval": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_logging.py b/plugins/module_utils/feature_templates/cisco_logging.py new file mode 100644 index 0000000..2b3e154 --- /dev/null +++ b/plugins/module_utils/feature_templates/cisco_logging.py @@ -0,0 +1,54 @@ +cisco_logging_definition = { + "cisco_logging": { + "default": None, + "options": { + "enable": {"default": None, "required": False, "type": "str"}, + "ipv6_server": { + "default": None, + "elements": "dict", + "options": { + "custom_profile": {"default": None, "required": False, "type": "str"}, + "enable_tls": {"default": None, "required": False, "type": "str"}, + "name": {"default": None, "required": True, "type": "str"}, + "priority": {"default": "information", "required": False, "type": "str"}, + "profile": {"default": None, "required": False, "type": "str"}, + "source_interface": {"default": None, "required": False, "type": "str"}, + "vpn": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "rotate": {"default": None, "required": False, "type": "str"}, + "server": { + "default": None, + "elements": "dict", + "options": { + "custom_profile": {"default": None, "required": False, "type": "str"}, + "enable_tls": {"default": None, "required": False, "type": "str"}, + "name": {"default": None, "required": True, "type": "str"}, + "priority": {"default": "information", "required": False, "type": "str"}, + "profile": {"default": None, "required": False, "type": "str"}, + "source_interface": {"default": None, "required": False, "type": "str"}, + "vpn": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "size": {"default": None, "required": False, "type": "str"}, + "tls_profile": { + "default": None, + "elements": "dict", + "options": { + "auth_type": {"default": None, "required": True, "type": "str"}, + "ciphersuite_list": {"default": None, "elements": "str", "required": False, "type": "list"}, + "profile": {"default": None, "required": True, "type": "str"}, + "version": {"default": "TLSv1.1", "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_ntp.py b/plugins/module_utils/feature_templates/cisco_ntp.py new file mode 100644 index 0000000..b633f12 --- /dev/null +++ b/plugins/module_utils/feature_templates/cisco_ntp.py @@ -0,0 +1,37 @@ +cisco_ntp_definition = { + "cisco_ntp": { + "default": None, + "options": { + "authentication": { + "default": None, + "elements": "dict", + "options": { + "md5": {"default": None, "required": True, "type": "str"}, + "number": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "enable": {"default": None, "required": False, "type": "str"}, + "server": { + "default": [], + "elements": "dict", + "options": { + "key": {"default": None, "required": True, "type": "str"}, + "name": {"default": None, "required": True, "type": "str"}, + "prefer": {"default": None, "required": True, "type": "str"}, + "source_interface": {"default": None, "required": False, "type": "str"}, + "version": {"default": None, "required": True, "type": "str"}, + "vpn": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "source": {"default": None, "required": False, "type": "str"}, + "stratum": {"default": None, "required": False, "type": "str"}, + "trusted": {"default": None, "elements": "str", "required": False, "type": "list"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_omp.py b/plugins/module_utils/feature_templates/cisco_omp.py new file mode 100644 index 0000000..275c96e --- /dev/null +++ b/plugins/module_utils/feature_templates/cisco_omp.py @@ -0,0 +1,41 @@ +cisco_omp_definition = { + "cisco_omp": { + "default": None, + "options": { + "advertise": { + "default": None, + "elements": "dict", + "options": { + "protocol": {"default": None, "required": True, "type": "str"}, + "route": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "advertisement_interval": {"default": None, "required": False, "type": "str"}, + "auto_translate": {"default": None, "required": False, "type": "str"}, + "ecmp_limit": {"default": None, "required": False, "type": "str"}, + "eor_timer": {"default": None, "required": False, "type": "str"}, + "graceful_restart": {"default": None, "required": False, "type": "str"}, + "graceful_restart_timer": {"default": None, "required": False, "type": "str"}, + "holdtime": {"default": None, "required": False, "type": "str"}, + "ignore_region_path_length": {"default": None, "required": False, "type": "str"}, + "ipv6_advertise": { + "default": None, + "elements": "dict", + "options": {"protocol": {"default": None, "required": True, "type": "str"}}, + "required": False, + "type": "list", + }, + "omp_admin_distance_ipv4": {"default": None, "required": False, "type": "str"}, + "omp_admin_distance_ipv6": {"default": None, "required": False, "type": "str"}, + "overlay_as": {"default": None, "required": False, "type": "str"}, + "send_path_limit": {"default": None, "required": False, "type": "str"}, + "shutdown": {"default": None, "required": False, "type": "str"}, + "site_types": {"default": None, "elements": "str", "required": False, "type": "list"}, + "transport_gateway": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_ospf.py b/plugins/module_utils/feature_templates/cisco_ospf.py new file mode 100644 index 0000000..668e9c6 --- /dev/null +++ b/plugins/module_utils/feature_templates/cisco_ospf.py @@ -0,0 +1,94 @@ +cisco_ospf_definition = { + "cisco_ospf": { + "default": None, + "options": { + "always": {"default": None, "required": False, "type": "str"}, + "area": { + "default": None, + "elements": "dict", + "options": { + "a_num": {"default": None, "required": True, "type": "str"}, + "interface": { + "default": None, + "elements": "dict", + "options": { + "cost": {"default": None, "required": False, "type": "str"}, + "dead_interval": {"default": None, "required": False, "type": "str"}, + "hello_interval": {"default": None, "required": False, "type": "str"}, + "md5": {"default": None, "required": False, "type": "str"}, + "message_digest_key": {"default": None, "required": False, "type": "str"}, + "name": {"default": None, "required": True, "type": "str"}, + "network": {"default": "broadcast", "required": False, "type": "str"}, + "passive_interface": {"default": None, "required": False, "type": "str"}, + "priority": {"default": None, "required": False, "type": "str"}, + "retransmit_interval": {"default": None, "required": False, "type": "str"}, + "type": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "nssa": {"default": None, "required": False, "type": "str"}, + "range": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": True, "type": "str"}, + "cost": {"default": None, "required": False, "type": "str"}, + "no_advertise": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "stub": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "delay": {"default": None, "required": False, "type": "str"}, + "external": {"default": None, "required": False, "type": "str"}, + "initial_hold": {"default": None, "required": False, "type": "str"}, + "inter_area": {"default": None, "required": False, "type": "str"}, + "intra_area": {"default": None, "required": False, "type": "str"}, + "max_hold": {"default": None, "required": False, "type": "str"}, + "metric": {"default": None, "required": False, "type": "str"}, + "metric_type": {"default": None, "required": False, "type": "str"}, + "originate": {"default": None, "required": False, "type": "str"}, + "redistribute": { + "default": None, + "elements": "dict", + "options": { + "dia": {"default": None, "required": False, "type": "str"}, + "protocol": {"default": None, "required": True, "type": "str"}, + "route_policy": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "reference_bandwidth": {"default": None, "required": False, "type": "str"}, + "rfc1583": {"default": None, "required": False, "type": "str"}, + "route_policy": { + "default": None, + "elements": "dict", + "options": { + "direction": {"default": None, "required": True, "type": "str"}, + "pol_name": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "router_id": {"default": None, "required": False, "type": "str"}, + "router_lsa": { + "default": None, + "elements": "dict", + "options": { + "ad_type": {"default": None, "required": True, "type": "str"}, + "time": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py b/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py new file mode 100644 index 0000000..53a1f24 --- /dev/null +++ b/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py @@ -0,0 +1,104 @@ +cisco_secure_internet_gateway_definition = { + "cisco_secure_internet_gateway": { + "default": None, + "options": { + "interface": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": False, "type": "str"}, + "application": {"default": "sig", "required": False, "type": "str"}, + "auto": {"default": None, "required": True, "type": "bool"}, + "description": {"default": None, "required": False, "type": "str"}, + "dpd_interval": {"default": None, "required": False, "type": "str"}, + "dpd_retries": {"default": None, "required": False, "type": "str"}, + "if_name": {"default": None, "required": True, "type": "str"}, + "ike_ciphersuite": {"default": "aes256-cbc-sha1", "required": False, "type": "str"}, + "ike_group": {"default": "14", "required": False, "type": "str"}, + "ike_local_id": {"default": None, "required": False, "type": "str"}, + "ike_rekey_interval": {"default": None, "required": False, "type": "str"}, + "ike_remote_id": {"default": None, "required": False, "type": "str"}, + "ike_version": {"default": None, "required": False, "type": "str"}, + "ipsec_ciphersuite": {"default": "aes256-gcm", "required": False, "type": "str"}, + "ipsec_rekey_interval": {"default": None, "required": False, "type": "str"}, + "ipsec_replay_window": {"default": None, "required": False, "type": "str"}, + "mtu": {"default": None, "required": False, "type": "str"}, + "perfect_forward_secrecy": {"default": "none", "required": False, "type": "str"}, + "pre_shared_key_dynamic": {"default": None, "required": False, "type": "bool"}, + "pre_shared_secret": {"default": None, "required": False, "type": "str"}, + "shutdown": {"default": None, "required": True, "type": "bool"}, + "tcp_mss_adjust": {"default": None, "required": False, "type": "str"}, + "track_enable": {"default": None, "required": False, "type": "str"}, + "tracker": {"default": None, "required": False, "type": "str"}, + "tunnel_dc_preference": {"default": "primary-dc", "required": False, "type": "str"}, + "tunnel_destination": {"default": None, "required": True, "type": "str"}, + "tunnel_route_via": {"default": None, "required": False, "type": "str"}, + "tunnel_set": {"default": "secure-internet-gateway-umbrella", "required": False, "type": "str"}, + "tunnel_source": {"default": None, "required": False, "type": "str"}, + "tunnel_source_interface": {"default": None, "required": False, "type": "str"}, + "unnumbered": {"default": None, "required": False, "type": "bool"}, + }, + "required": True, + "type": "list", + }, + "service": { + "default": None, + "elements": "dict", + "options": { + "auth_required": {"default": None, "required": False, "type": "str"}, + "block_internet_until_accepted": {"default": None, "required": False, "type": "str"}, + "caution_enabled": {"default": None, "required": False, "type": "str"}, + "data_center_primary": {"default": None, "required": False, "type": "str"}, + "data_center_secondary": {"default": None, "required": False, "type": "str"}, + "display_time_unit": {"default": "MINUTE", "required": False, "type": "str"}, + "enabled": {"default": None, "required": False, "type": "str"}, + "force_ssl_inspection": {"default": None, "required": False, "type": "str"}, + "idle_time": {"default": None, "required": False, "type": "str"}, + "interface_pair": { + "default": None, + "elements": "dict", + "options": { + "active_interface": {"default": None, "required": True, "type": "str"}, + "active_interface_weight": {"default": None, "required": False, "type": "str"}, + "backup_interface": {"default": None, "required": False, "type": "str"}, + "backup_interface_weight": {"default": None, "required": False, "type": "str"}, + }, + "required": True, + "type": "list", + }, + "ip": {"default": None, "required": False, "type": "str"}, + "ip_enforced_for_known_browsers": {"default": None, "required": False, "type": "str"}, + "ips_control": {"default": None, "required": False, "type": "str"}, + "ofw_enabled": {"default": None, "required": False, "type": "str"}, + "primary_data_center": {"default": None, "required": False, "type": "str"}, + "refresh_time": {"default": None, "required": False, "type": "str"}, + "refresh_time_unit": {"default": "MINUTE", "required": False, "type": "str"}, + "secondary_data_center": {"default": None, "required": False, "type": "str"}, + "svc_type": {"default": "sig", "required": False, "type": "str"}, + "timeout": {"default": None, "required": False, "type": "str"}, + "xff_forward_enabled": {"default": None, "required": False, "type": "str"}, + }, + "required": True, + "type": "list", + }, + "tracker": { + "default": None, + "elements": "dict", + "options": { + "endpoint_api_url": {"default": None, "required": True, "type": "str"}, + "interval": {"default": None, "required": False, "type": "str"}, + "multiplier": {"default": None, "required": False, "type": "str"}, + "name": {"default": None, "required": True, "type": "str"}, + "threshold": {"default": None, "required": False, "type": "str"}, + "tracker_type": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "tracker_src_ip": {"default": None, "required": False, "type": "str"}, + "vpn_id": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_snmp.py b/plugins/module_utils/feature_templates/cisco_snmp.py new file mode 100644 index 0000000..44ce1f3 --- /dev/null +++ b/plugins/module_utils/feature_templates/cisco_snmp.py @@ -0,0 +1,81 @@ +cisco_snmp_definition = { + "cisco_snmp": { + "default": None, + "options": { + "community": { + "default": None, + "elements": "dict", + "options": { + "authorization": {"default": None, "required": True, "type": "str"}, + "name": {"default": None, "required": True, "type": "str"}, + "view": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "contact": {"default": None, "required": True, "type": "str"}, + "group": { + "default": None, + "elements": "dict", + "options": { + "name": {"default": None, "required": True, "type": "str"}, + "security_level": {"default": None, "required": True, "type": "str"}, + "view": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "location": {"default": None, "required": True, "type": "str"}, + "shutdown": {"default": None, "required": False, "type": "str"}, + "target": { + "default": None, + "elements": "dict", + "options": { + "community_name": {"default": None, "required": True, "type": "str"}, + "ip": {"default": None, "required": True, "type": "str"}, + "port": {"default": None, "required": True, "type": "str"}, + "source_interface": {"default": None, "required": True, "type": "str"}, + "user": {"default": None, "required": True, "type": "str"}, + "vpn_id": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "user": { + "default": None, + "elements": "dict", + "options": { + "auth": {"default": None, "required": True, "type": "str"}, + "auth_password": {"default": None, "required": True, "type": "str"}, + "group": {"default": None, "required": True, "type": "str"}, + "name": {"default": None, "required": True, "type": "str"}, + "priv": {"default": None, "required": True, "type": "str"}, + "priv_password": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "view": { + "default": None, + "elements": "dict", + "options": { + "name": {"default": None, "required": True, "type": "str"}, + "oid": { + "default": None, + "elements": "dict", + "options": { + "exclude": {"default": None, "required": True, "type": "str"}, + "id": {"default": None, "required": True, "type": "str"}, + }, + "required": True, + "type": "list", + }, + }, + "required": False, + "type": "list", + }, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_system.py b/plugins/module_utils/feature_templates/cisco_system.py new file mode 100644 index 0000000..3934dfd --- /dev/null +++ b/plugins/module_utils/feature_templates/cisco_system.py @@ -0,0 +1,128 @@ +cisco_system_definition = { + "cisco_system": { + "default": None, + "options": { + "admin_tech_on_failure": {"default": None, "required": False, "type": "str"}, + "affinity_group_number": {"default": None, "required": False, "type": "str"}, + "affinity_per_vrf": { + "default": None, + "elements": "dict", + "options": { + "affinity_group_number": {"default": None, "required": False, "type": "str"}, + "vrf_range": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "console_baud_rate": {"default": None, "required": False, "type": "str"}, + "control_session_pps": {"default": None, "required": False, "type": "str"}, + "controller_group_list": {"default": None, "elements": "str", "required": False, "type": "list"}, + "device_groups": {"default": None, "elements": "str", "required": False, "type": "list"}, + "enable_fencing": {"default": None, "required": False, "type": "str"}, + "enable_management_region": {"default": None, "required": False, "type": "str"}, + "enable_mrf_migration": {"default": None, "required": False, "type": "str"}, + "enable_sms": {"default": None, "required": False, "type": "str"}, + "enable_tunnel": {"default": None, "required": False, "type": "str"}, + "epfr": {"default": None, "required": False, "type": "str"}, + "hostname": { + "default": None, + "options": {"name": {"default": None, "required": True, "type": "str"}}, + "required": False, + "type": "dict", + }, + "idle_timeout": {"default": None, "required": False, "type": "str"}, + "latitude": {"default": None, "required": False, "type": "str"}, + "location": {"default": None, "required": False, "type": "str"}, + "longitude": {"default": None, "required": False, "type": "str"}, + "management_gateway": {"default": None, "required": False, "type": "str"}, + "max_omp_sessions": {"default": None, "required": False, "type": "str"}, + "migration_bgp_community": {"default": None, "required": False, "type": "str"}, + "mobile_number": { + "default": None, + "elements": "dict", + "options": {"number": {"default": None, "required": True, "type": "str"}}, + "required": False, + "type": "list", + }, + "multi_tenant": {"default": None, "required": False, "type": "str"}, + "object_track": { + "default": None, + "elements": "dict", + "options": { + "boolean": {"default": None, "required": True, "type": "str"}, + "interface": {"default": None, "required": True, "type": "str"}, + "ip": {"default": None, "required": True, "type": "str"}, + "mask": {"default": None, "required": False, "type": "str"}, + "object": { + "default": None, + "elements": "dict", + "options": {"number": {"default": None, "required": True, "type": "str"}}, + "required": True, + "type": "list", + }, + "object_number": {"default": None, "required": True, "type": "str"}, + "sig": {"default": None, "required": True, "type": "str"}, + "vpn": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "on_demand_idle_timeout_min": {"default": None, "required": False, "type": "str"}, + "overlay_id": {"default": None, "required": False, "type": "str"}, + "port_hop": {"default": None, "required": False, "type": "str"}, + "port_offset": {"default": None, "required": False, "type": "str"}, + "preference": {"default": None, "elements": "str", "required": False, "type": "list"}, + "preference_auto": {"default": None, "required": False, "type": "str"}, + "range": {"default": None, "required": False, "type": "str"}, + "region_id": {"default": None, "required": False, "type": "str"}, + "role": {"default": None, "required": False, "type": "str"}, + "secondary_region": {"default": None, "required": False, "type": "str"}, + "site_id": {"default": None, "required": False, "type": "str"}, + "site_type": {"default": None, "elements": "str", "required": False, "type": "list"}, + "system_ip": { + "default": None, + "options": {"name": {"default": None, "required": True, "type": "str"}}, + "required": False, + "type": "dict", + }, + "timezone": {"default": None, "required": False, "type": "str"}, + "track_default_gateway": {"default": None, "required": False, "type": "str"}, + "track_interface_tag": {"default": None, "required": False, "type": "str"}, + "track_transport": {"default": None, "required": False, "type": "str"}, + "tracker": { + "default": None, + "elements": "dict", + "options": { + "boolean": {"default": "or", "required": False, "type": "str"}, + "elements": {"default": None, "elements": "str", "required": False, "type": "list"}, + "endpoint_api_url": {"default": None, "required": False, "type": "str"}, + "endpoint_dns_name": {"default": None, "required": False, "type": "str"}, + "endpoint_ip": {"default": None, "required": False, "type": "str"}, + "endpoint_ip_transport_port": {"default": None, "required": False, "type": "str"}, + "interval": {"default": None, "required": False, "type": "str"}, + "multiplier": {"default": None, "required": False, "type": "str"}, + "name": {"default": None, "required": True, "type": "str"}, + "port": {"default": None, "required": False, "type": "str"}, + "protocol": {"default": None, "required": False, "type": "str"}, + "threshold": {"default": None, "required": False, "type": "str"}, + "type": {"default": "interface", "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "transport_gateway": {"default": None, "required": False, "type": "str"}, + "vrf": { + "default": None, + "elements": "dict", + "options": { + "gateway_preference": {"default": None, "elements": "str", "required": False, "type": "list"}, + "vrf_id": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_vpn.py b/plugins/module_utils/feature_templates/cisco_vpn.py new file mode 100644 index 0000000..4aeae49 --- /dev/null +++ b/plugins/module_utils/feature_templates/cisco_vpn.py @@ -0,0 +1,326 @@ +cisco_vpn_definition = { + "cisco_vpn": { + "default": None, + "options": { + "advertise": { + "default": None, + "elements": "dict", + "options": { + "prefix_list": { + "default": None, + "elements": "dict", + "options": { + "aggregate_only": {"default": None, "required": False, "type": "str"}, + "prefix_entry": {"default": None, "required": True, "type": "str"}, + "region": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "protocol": {"default": None, "required": True, "type": "str"}, + "protocol_sub_type": {"default": None, "elements": "str", "required": False, "type": "list"}, + "route_policy": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "dns": { + "default": None, + "elements": "dict", + "options": { + "dns_addr": {"default": None, "required": False, "type": "str"}, + "role": {"default": "primary", "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "dns_ipv6": { + "default": None, + "elements": "dict", + "options": { + "dns_addr": {"default": None, "required": False, "type": "str"}, + "role": {"default": "primary", "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "gre_route": { + "default": None, + "elements": "dict", + "options": { + "interface": {"default": None, "elements": "str", "required": False, "type": "list"}, + "prefix": {"default": None, "required": True, "type": "str"}, + "vpn": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "host": { + "default": None, + "elements": "dict", + "options": { + "hostname": {"default": None, "required": True, "type": "str"}, + "ip": {"default": None, "elements": "str", "required": True, "type": "list"}, + }, + "required": False, + "type": "list", + }, + "ipsec_route": { + "default": None, + "elements": "dict", + "options": { + "interface": {"default": None, "elements": "str", "required": False, "type": "list"}, + "prefix": {"default": None, "required": True, "type": "str"}, + "vpn": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "ipv6_advertise": { + "default": None, + "elements": "dict", + "options": { + "prefix_list": { + "default": None, + "elements": "dict", + "options": { + "aggregate_only": {"default": None, "required": False, "type": "str"}, + "prefix_entry": {"default": None, "required": True, "type": "str"}, + "region": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "protocol": {"default": None, "required": True, "type": "str"}, + "protocol_sub_type": {"default": None, "elements": "str", "required": False, "type": "list"}, + "route_policy": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "layer4": {"default": None, "required": False, "type": "str"}, + "natpool": { + "default": None, + "elements": "dict", + "options": { + "direction": {"default": None, "required": True, "type": "str"}, + "name": {"default": None, "required": True, "type": "str"}, + "overload": {"default": "true", "required": False, "type": "str"}, + "prefix_length": {"default": None, "required": False, "type": "str"}, + "range_end": {"default": None, "required": False, "type": "str"}, + "range_start": {"default": None, "required": False, "type": "str"}, + "tracker_id": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "omp_admin_distance_ipv4": {"default": None, "required": False, "type": "str"}, + "omp_admin_distance_ipv6": {"default": None, "required": False, "type": "str"}, + "org_name": {"default": None, "required": False, "type": "str"}, + "pool": { + "default": None, + "elements": "dict", + "options": { + "end_address": {"default": None, "required": True, "type": "str"}, + "leak_from_global": {"default": None, "required": True, "type": "bool"}, + "leak_from_global_protocol": {"default": None, "required": True, "type": "str"}, + "leak_to_global": {"default": None, "required": True, "type": "bool"}, + "name": {"default": None, "required": True, "type": "str"}, + "overload": {"default": None, "required": False, "type": "str"}, + "start_address": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "port_forward": { + "default": None, + "elements": "dict", + "options": { + "pool_name": {"default": None, "required": False, "type": "str"}, + "proto": {"default": None, "required": True, "type": "str"}, + "source_ip": {"default": None, "required": True, "type": "str"}, + "source_port": {"default": None, "required": True, "type": "str"}, + "translate_ip": {"default": None, "required": True, "type": "str"}, + "translate_port": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "route_export": { + "default": None, + "elements": "dict", + "options": { + "protocol": {"default": None, "required": True, "type": "str"}, + "protocol_sub_type": {"default": None, "elements": "str", "required": True, "type": "list"}, + "redistribute": { + "default": None, + "elements": "dict", + "options": { + "protocol": {"default": None, "required": True, "type": "str"}, + "route_policy": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "route_policy": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "route_import": { + "default": None, + "elements": "dict", + "options": { + "protocol": {"default": None, "required": True, "type": "str"}, + "protocol_sub_type": {"default": None, "elements": "str", "required": True, "type": "list"}, + "redistribute": { + "default": None, + "elements": "dict", + "options": { + "protocol": {"default": None, "required": True, "type": "str"}, + "route_policy": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "route_policy": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "route_import_from": { + "default": None, + "elements": "dict", + "options": { + "protocol": {"default": None, "required": True, "type": "str"}, + "protocol_sub_type": {"default": None, "elements": "str", "required": True, "type": "list"}, + "redistribute": { + "default": None, + "elements": "dict", + "options": { + "protocol": {"default": None, "required": True, "type": "str"}, + "route_policy": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "route_policy": {"default": None, "required": False, "type": "str"}, + "source_vpn": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "route_v4": { + "default": None, + "elements": "dict", + "options": { + "dhcp": {"default": None, "required": False, "type": "str"}, + "distance": {"default": None, "required": False, "type": "str"}, + "next_hop": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": False, "type": "str"}, + "distance": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "next_hop_with_track": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": False, "type": "str"}, + "distance": {"default": None, "required": False, "type": "str"}, + "tracker": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "null0": {"default": None, "required": False, "type": "str"}, + "prefix": {"default": None, "required": False, "type": "str"}, + "route_interface": {"default": None, "required": False, "type": "str"}, + "vpn": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "route_v6": { + "default": None, + "elements": "dict", + "options": { + "nat": {"default": None, "required": False, "type": "str"}, + "next_hop": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": True, "type": "str"}, + "distance": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "null0": {"default": None, "required": False, "type": "str"}, + "prefix": {"default": None, "required": True, "type": "str"}, + "vpn": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "service": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "elements": "str", "required": False, "type": "list"}, + "interface": {"default": None, "required": False, "type": "str"}, + "svc_type": {"default": None, "required": True, "type": "str"}, + "track_enable": {"default": None, "required": False, "type": "bool"}, + }, + "required": False, + "type": "list", + }, + "service_route": { + "default": None, + "elements": "dict", + "options": { + "prefix": {"default": None, "required": True, "type": "str"}, + "service": {"default": "sig", "required": False, "type": "str"}, + "vpn": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "static": { + "default": None, + "elements": "dict", + "options": { + "pool_name": {"default": None, "required": False, "type": "str"}, + "source_ip": {"default": None, "required": False, "type": "str"}, + "static_nat_direction": {"default": None, "required": True, "type": "str"}, + "tracker_id": {"default": None, "required": False, "type": "str"}, + "translate_ip": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "subnet_static": { + "default": None, + "elements": "dict", + "options": { + "prefix_length": {"default": None, "required": True, "type": "str"}, + "source_ip_subnet": {"default": None, "required": True, "type": "str"}, + "static_nat_direction": {"default": None, "required": True, "type": "str"}, + "tracker_id": {"default": None, "required": False, "type": "str"}, + "translate_ip_subnet": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "tenant_vpn_id": {"default": None, "required": False, "type": "str"}, + "vpn_id": {"default": None, "required": False, "type": "str"}, + "vpn_name": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_vpn_interface.py b/plugins/module_utils/feature_templates/cisco_vpn_interface.py new file mode 100644 index 0000000..94ccaf7 --- /dev/null +++ b/plugins/module_utils/feature_templates/cisco_vpn_interface.py @@ -0,0 +1,272 @@ +cisco_vpn_interface_definition = { + "cisco_vpn_interface": { + "default": None, + "options": { + "access_list_ipv4": { + "default": None, + "elements": "dict", + "options": { + "acl_name": {"default": None, "required": True, "type": "str"}, + "direction": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "access_list_ipv6": { + "default": None, + "elements": "dict", + "options": { + "acl_name": {"default": None, "required": True, "type": "str"}, + "direction": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "all": {"default": None, "required": False, "type": "str"}, + "arp_timeout": {"default": None, "required": False, "type": "str"}, + "auto_bandwidth_detect": {"default": None, "required": False, "type": "str"}, + "autonegotiate": {"default": None, "required": False, "type": "str"}, + "bandwidth_down": {"default": None, "required": False, "type": "str"}, + "bandwidth_downstream": {"default": None, "required": False, "type": "str"}, + "bandwidth_up": {"default": None, "required": False, "type": "str"}, + "bandwidth_upstream": {"default": None, "required": False, "type": "str"}, + "bgp": {"default": None, "required": False, "type": "str"}, + "bind": {"default": None, "required": False, "type": "str"}, + "block_non_source_ip": {"default": None, "required": False, "type": "str"}, + "border": {"default": None, "required": False, "type": "str"}, + "carrier": {"default": None, "required": False, "type": "str"}, + "clear_dont_fragment": {"default": None, "required": False, "type": "str"}, + "control_connections": {"default": None, "required": False, "type": "str"}, + "core_region": {"default": None, "required": False, "type": "str"}, + "dhcp": {"default": None, "required": False, "type": "str"}, + "dhcp_distance": {"default": None, "required": False, "type": "str"}, + "dhcp_helper": {"default": None, "elements": "str", "required": False, "type": "list"}, + "dhcp_helper_v6": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": True, "type": "str"}, + "vpn": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "dhcp_ipv4_client": {"default": None, "required": False, "type": "str"}, + "dhcp_ipv6_client": {"default": None, "required": False, "type": "str"}, + "dmax": {"default": None, "required": False, "type": "str"}, + "dmin": {"default": None, "required": False, "type": "str"}, + "dns": {"default": None, "required": False, "type": "str"}, + "dst_ip": {"default": None, "required": False, "type": "str"}, + "duplex": {"default": None, "required": False, "type": "str"}, + "enable": {"default": None, "required": False, "type": "str"}, + "enable_core_region": {"default": None, "required": False, "type": "str"}, + "enable_sgt_authorization_and_forwarding": {"default": None, "required": False, "type": "str"}, + "enable_sgt_enforcement": {"default": None, "required": False, "type": "str"}, + "enable_sgt_propagation": {"default": None, "required": False, "type": "str"}, + "enforcement_sgt": {"default": None, "required": False, "type": "str"}, + "exclude_controller_group_list": {"default": None, "elements": "str", "required": False, "type": "list"}, + "group": {"default": None, "elements": "str", "required": False, "type": "list"}, + "hello_interval": {"default": None, "required": False, "type": "str"}, + "hello_tolerance": {"default": None, "required": False, "type": "str"}, + "https": {"default": None, "required": False, "type": "str"}, + "icmp": {"default": None, "required": False, "type": "str"}, + "icmp_redirect_disable": {"default": None, "required": False, "type": "str"}, + "if_name": {"default": None, "required": False, "type": "str"}, + "interface_description": {"default": None, "required": False, "type": "str"}, + "intrf_mtu": {"default": None, "required": False, "type": "str"}, + "ip": { + "default": None, + "elements": "dict", + "options": { + "addr": {"default": None, "required": True, "type": "str"}, + "mac": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "ip_directed_broadcast": {"default": None, "required": False, "type": "str"}, + "iperf_server": {"default": None, "required": False, "type": "str"}, + "ipv4_address": {"default": None, "required": False, "type": "str"}, + "ipv6_address": {"default": None, "required": False, "type": "str"}, + "ipv6_vrrp": { + "default": None, + "elements": "dict", + "options": { + "grp_id": {"default": None, "required": True, "type": "str"}, + "ipv6": { + "default": None, + "elements": "dict", + "options": { + "ipv6_link_local": {"default": None, "required": True, "type": "str"}, + "prefix": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "priority": {"default": None, "required": False, "type": "str"}, + "timer": {"default": None, "required": False, "type": "str"}, + "track_omp": {"default": None, "required": False, "type": "bool"}, + "track_prefix_list": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "last_resort_circuit": {"default": None, "required": False, "type": "str"}, + "load_interval": {"default": None, "required": False, "type": "str"}, + "loopback_interface": {"default": None, "required": False, "type": "str"}, + "low_bandwidth_link": {"default": None, "required": False, "type": "str"}, + "mac_address": {"default": None, "required": False, "type": "str"}, + "max_control_connections": {"default": None, "required": False, "type": "str"}, + "media_type": {"default": None, "required": False, "type": "str"}, + "mode": {"default": None, "required": False, "type": "str"}, + "mtu": {"default": None, "required": False, "type": "str"}, + "nat": {"default": None, "required": False, "type": "str"}, + "nat64": {"default": None, "required": False, "type": "str"}, + "nat66": {"default": None, "required": False, "type": "str"}, + "nat_choice": {"default": None, "required": False, "type": "str"}, + "nat_range_end": {"default": None, "required": False, "type": "str"}, + "nat_range_start": {"default": None, "required": False, "type": "str"}, + "nat_refresh_interval": {"default": None, "required": False, "type": "str"}, + "netconf": {"default": None, "required": False, "type": "str"}, + "network_broadcast": {"default": None, "required": False, "type": "str"}, + "ntp": {"default": None, "required": False, "type": "str"}, + "ospf": {"default": None, "required": False, "type": "str"}, + "overload": {"default": None, "required": False, "type": "str"}, + "per_tunnel_qos": {"default": None, "required": False, "type": "str"}, + "per_tunnel_qos_aggregator": {"default": None, "required": False, "type": "str"}, + "period": {"default": None, "required": False, "type": "str"}, + "poe": {"default": None, "required": False, "type": "str"}, + "port_hop": {"default": None, "required": False, "type": "str"}, + "prefix_length": {"default": None, "required": False, "type": "str"}, + "propagate_sgt": {"default": None, "required": False, "type": "str"}, + "qos_adaptive": {"default": None, "required": False, "type": "str"}, + "qos_map": {"default": None, "required": False, "type": "str"}, + "qos_map_vpn": {"default": None, "required": False, "type": "str"}, + "restrict": {"default": None, "required": False, "type": "str"}, + "rule_name": {"default": None, "required": False, "type": "str"}, + "secondary_ipv4_address": { + "default": None, + "elements": "dict", + "options": {"address": {"default": None, "required": False, "type": "str"}}, + "required": False, + "type": "list", + }, + "secondary_ipv6_address": { + "default": None, + "elements": "dict", + "options": {"address": {"default": None, "required": False, "type": "str"}}, + "required": False, + "type": "list", + }, + "secondary_region": {"default": None, "required": False, "type": "str"}, + "security_group_tag": {"default": None, "required": False, "type": "str"}, + "service_provider": {"default": None, "required": False, "type": "str"}, + "shaping_rate": {"default": None, "required": False, "type": "str"}, + "shutdown": {"default": None, "required": False, "type": "str"}, + "snmp": {"default": None, "required": False, "type": "str"}, + "speed": {"default": None, "required": False, "type": "str"}, + "src_ip": {"default": None, "required": False, "type": "str"}, + "sshd": {"default": None, "required": False, "type": "str"}, + "static": { + "default": None, + "elements": "dict", + "options": { + "source_ip": {"default": None, "required": True, "type": "str"}, + "source_vpn": {"default": None, "required": False, "type": "str"}, + "static_nat_direction": {"default": "inside", "required": False, "type": "str"}, + "translate_ip": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "static_nat66": { + "default": None, + "elements": "dict", + "options": { + "source_prefix": {"default": None, "required": True, "type": "str"}, + "source_vpn_id": {"default": None, "required": False, "type": "str"}, + "translated_source_prefix": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "static_port_forward": { + "default": None, + "elements": "dict", + "options": { + "proto": {"default": None, "required": True, "type": "str"}, + "source_ip": {"default": None, "required": True, "type": "str"}, + "source_port": {"default": None, "required": False, "type": "str"}, + "source_vpn": {"default": None, "required": False, "type": "str"}, + "static_nat_direction": {"default": "inside", "required": False, "type": "str"}, + "translate_ip": {"default": None, "required": True, "type": "str"}, + "translate_port": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "stun": {"default": None, "required": False, "type": "str"}, + "tcp_mss_adjust": {"default": None, "required": False, "type": "str"}, + "tcp_timeout": {"default": None, "required": False, "type": "str"}, + "tloc_encapsulation": { + "default": None, + "elements": "dict", + "options": { + "encap": {"default": None, "required": True, "type": "str"}, + "preference": {"default": None, "required": False, "type": "str"}, + "weight": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "tloc_extension": {"default": None, "required": False, "type": "str"}, + "tracker": {"default": None, "elements": "str", "required": False, "type": "list"}, + "trusted": {"default": None, "required": False, "type": "str"}, + "tunnel_tcp_mss_adjust": {"default": None, "required": False, "type": "str"}, + "tunnels_bandwidth": {"default": None, "required": False, "type": "str"}, + "udp_timeout": {"default": None, "required": False, "type": "str"}, + "umax": {"default": None, "required": False, "type": "str"}, + "umin": {"default": None, "required": False, "type": "str"}, + "value": {"default": None, "required": False, "type": "str"}, + "vbond_as_stun_server": {"default": None, "required": False, "type": "str"}, + "vmanage_connection_preference": {"default": None, "required": False, "type": "str"}, + "vrrp": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": False, "type": "str"}, + "grp_id": {"default": None, "required": True, "type": "str"}, + "ipv4_secondary": { + "default": None, + "elements": "dict", + "options": {"address": {"default": None, "required": True, "type": "str"}}, + "required": False, + "type": "list", + }, + "priority": {"default": None, "required": False, "type": "str"}, + "timer": {"default": None, "required": False, "type": "str"}, + "tloc_change_pref": {"default": None, "required": False, "type": "bool"}, + "track_omp": {"default": None, "required": False, "type": "bool"}, + "track_prefix_list": {"default": None, "required": False, "type": "str"}, + "tracking_object": { + "default": None, + "elements": "dict", + "options": { + "decrement": {"default": None, "required": True, "type": "str"}, + "name": {"default": None, "required": True, "type": "str"}, + "track_action": {"default": "Decrement", "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "value": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "xconnect": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/omp_vsmart.py b/plugins/module_utils/feature_templates/omp_vsmart.py new file mode 100644 index 0000000..98c2061 --- /dev/null +++ b/plugins/module_utils/feature_templates/omp_vsmart.py @@ -0,0 +1,19 @@ +omp_vsmart_definition = { + "omp_vsmart": { + "default": None, + "options": { + "advertisement_interval": {"default": None, "required": False, "type": "str"}, + "affinity_group_preference": {"default": None, "required": False, "type": "str"}, + "discard_rejected": {"default": None, "required": False, "type": "str"}, + "eor_timer": {"default": None, "required": False, "type": "str"}, + "graceful_restart": {"default": None, "required": False, "type": "str"}, + "graceful_restart_timer": {"default": None, "required": False, "type": "str"}, + "holdtime": {"default": None, "required": False, "type": "str"}, + "send_backup_paths": {"default": None, "required": False, "type": "str"}, + "send_path_limit": {"default": None, "required": False, "type": "str"}, + "shutdown": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/security_vsmart.py b/plugins/module_utils/feature_templates/security_vsmart.py new file mode 100644 index 0000000..b6af55d --- /dev/null +++ b/plugins/module_utils/feature_templates/security_vsmart.py @@ -0,0 +1,11 @@ +security_vsmart_definition = { + "security_vsmart": { + "default": None, + "options": { + "protocol": {"default": None, "required": False, "type": "str"}, + "tls_port": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/system_vsmart.py b/plugins/module_utils/feature_templates/system_vsmart.py new file mode 100644 index 0000000..5cf4abc --- /dev/null +++ b/plugins/module_utils/feature_templates/system_vsmart.py @@ -0,0 +1,29 @@ +system_vsmart_definition = { + "system_vsmart": { + "default": None, + "options": { + "admin_tech_on_failure": {"default": None, "required": False, "type": "str"}, + "control_session_pps": {"default": None, "required": False, "type": "str"}, + "controller_group_id": {"default": None, "required": False, "type": "str"}, + "device_groups": {"default": None, "required": False, "type": "str"}, + "dns_cache_timeout": {"default": None, "required": False, "type": "str"}, + "host_name": {"default": None, "required": False, "type": "str"}, + "idle_timeout": {"default": None, "required": False, "type": "str"}, + "iptables_enable": {"default": None, "required": False, "type": "str"}, + "latitude": {"default": None, "required": False, "type": "str"}, + "location": {"default": None, "required": False, "type": "str"}, + "longitude": {"default": None, "required": False, "type": "str"}, + "overlay_id": {"default": None, "required": False, "type": "str"}, + "port_hop": {"default": None, "required": False, "type": "str"}, + "port_offset": {"default": None, "required": False, "type": "str"}, + "site_id": {"default": None, "required": False, "type": "str"}, + "system_ip": {"default": None, "required": False, "type": "str"}, + "system_tunnel_mtu": {"default": None, "required": False, "type": "str"}, + "timezone": {"default": None, "required": False, "type": "str"}, + "track_default_gateway": {"default": None, "required": False, "type": "str"}, + "track_transport": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates_definitions/cisco_aaa.py b/plugins/module_utils/feature_templates_definitions/cisco_aaa.py deleted file mode 100644 index c9d30d9..0000000 --- a/plugins/module_utils/feature_templates_definitions/cisco_aaa.py +++ /dev/null @@ -1,72 +0,0 @@ -cisco_aaa_definition = { 'cisco_aaa': { 'default': None, - 'options': { 'accounting_group': { 'default': True, - 'required': False, - 'type': 'bool'}, - 'authentication_group': { 'default': False, - 'required': False, - 'type': 'bool'}, - 'domain_stripping': { 'default': None, - 'required': False, - 'type': 'str'}, - 'port': { 'default': 1700, - 'required': False, - 'type': 'str'}, - 'radius': { 'default': None, - 'elements': 'dict', - 'options': { 'group_name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'server': { 'default': [ ], - 'elements': 'str', - 'required': False, - 'type': 'list'}, - 'source_interface': { 'default': None, - 'required': True, - 'type': 'str'}, - 'vpn': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'server_auth_order': { 'default': 'local', - 'required': False, - 'type': 'str'}, - 'tacacs': { 'default': None, - 'elements': 'dict', - 'options': { 'group_name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'server': { 'default': [ ], - 'elements': 'str', - 'required': False, - 'type': 'list'}, - 'source_interface': { 'default': None, - 'required': False, - 'type': 'str'}, - 'vpn': { 'default': 0, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'user': { 'default': False, - 'elements': 'dict', - 'options': { 'name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'password': { 'default': None, - 'required': False, - 'type': 'str'}, - 'privilege': { 'default': None, - 'required': False, - 'type': 'str'}, - 'pubkey_chain': { 'default': [ ], - 'elements': 'str', - 'required': False, - 'type': 'list'}, - 'secret': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}}, - 'required': False, - 'type': 'dict'}} diff --git a/plugins/modules/feature_templates.py b/plugins/modules/feature_templates.py index cec168a..aef1a0a 100644 --- a/plugins/modules/feature_templates.py +++ b/plugins/modules/feature_templates.py @@ -4,33 +4,6 @@ # Copyright 2024 Cisco Systems, Inc. and its affiliates # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) -from catalystwan.utils.device_model import DeviceModel - -import pkgutil -import importlib - -def import_all_classes_from_library(library_name): - imported_classes = {} - - # Find the library's location and iterate through its modules - library_path = importlib.import_module(library_name).__path__ - for _, module_name, _ in pkgutil.iter_modules(library_path): - # Import the module - module = importlib.import_module(f'{library_name}.{module_name}') - - # Iterate through the module's attributes and import classes - for attribute_name in dir(module): - attribute = getattr(module, attribute_name) - if isinstance(attribute, type): # Check if it is a class - imported_classes[attribute_name] = attribute - - return imported_classes - -# Usage example: -# Let's say you want to import all classes from a library called 'external_library' -all_classes = import_all_classes_from_library('catalystwan.api.templates.models') -all_device_models = [device_model.value for device_model in DeviceModel] - DOCUMENTATION = r""" --- module: vmanage_feature_template @@ -44,6 +17,13 @@ def import_all_classes_from_library(library_name): - The feature template configuration is defined via Python Pydantic models. options: + state: + description: + - Desired state of for the template. + - 0(state=present) is equivalent of create template in GUI + type: str + choices: ["absent", "present", "modified"] + default: "present" template_name: description: - The name for the Feature Template. @@ -54,78 +34,143 @@ def import_all_classes_from_library(library_name): - Description for the Feature Template. type: str required: true - device_models: - description: - - The model of the device. - required: true - type: list - default: [] - elements: str - choices: - - "vmanage" - - "vedge-cloud" - - "vsmart" + debug: + description: + - If to write payload of created template and response from vmanage as json to file. + - Files will be written to C(CWD) as I("payload_{template.type}.json") and I("response_{template.type}.json"). + type: bool + default: false extends_documentation_fragment: - cisco.catalystwan.feature_template_cisco_aaa - cisco.catalystwan.feature_template_cisco_banner + - cisco.catalystwan.feature_template_cisco_bfd + - cisco.catalystwan.feature_template_cisco_logging + - cisco.catalystwan.feature_template_cisco_ntp + - cisco.catalystwan.device_models_feature_template author: - Arkadiusz Cichon (acichon@cisco.com) """ -from typing import Optional, Dict + +from enum import Enum from pydantic import Field +from typing import Optional, Dict from catalystwan.api.template_api import FeatureTemplate from catalystwan.dataclasses import FeatureTemplateInfo from catalystwan.typed_list import DataSequence -from catalystwan.utils.creation_tools import asdict from catalystwan.utils.device_model import DeviceModel from catalystwan.api.templates.models.supported import available_models from ..module_utils.result import ModuleResult from ..module_utils.vmanage_module import AnsibleCatalystwanModule -from ..module_utils.feature_templates_definitions.cisco_aaa import cisco_aaa_definition +from ..module_utils.feature_templates.cisco_aaa import cisco_aaa_definition +from ..module_utils.feature_templates.cisco_banner import cisco_banner_definition +from ..module_utils.feature_templates.cisco_bfd import cisco_bfd_definition +from ..module_utils.feature_templates.cisco_logging import cisco_logging_definition +from ..module_utils.feature_templates.cisco_ntp import cisco_ntp_definition class ExtendedModuleResult(ModuleResult): templates_info: Optional[Dict] = Field(default={}) +class State(str, Enum): + PRESENT = "present" + MODIFIED = "modified" + ABSENT = "absent" + + def run_module(): module_args = dict( - template_name=dict(type="str", default=None, required=True), - template_description=dict(type="str", default=None, required=True), - device_models=dict( - type="list", - required=True, - choices=[device_model.value for device_model in DeviceModel]), + state=dict( + type=str, + choices=[State.PRESENT, State.ABSENT, State.MODIFIED], + default=State.PRESENT.value, + ), + template_name=dict(type="str", required=True), + template_description=dict(type="str", default=None), + device_models=dict(type="list", choices=[device_model.value for device_model in DeviceModel]), + debug=dict(type="bool", default=False), + device=dict(type="str", default=None), # For this we need to think how to pass devices **cisco_aaa_definition, - debug=dict(type="bool", default=False), # if to dump templates payload + **cisco_banner_definition, + **cisco_bfd_definition, + **cisco_logging_definition, + **cisco_ntp_definition, ) + result = ExtendedModuleResult() result.state = None result.response = None - module = AnsibleCatalystwanModule(argument_spec=module_args) - - # Code for checking if template name exists already, if yes, do we need some force method or we just inform user and exit? - - for model_name, model_module in available_models.items(): - if model_name in module.params.keys(): - # Perform action with template - template = model_module( - template_name=module.params.get("template_name"), - template_description=module.params.get("template_description"), - device_models=module.params.get("device_models"), - **module.params_without_none_values[model_name]) - - module.logger.info(f"Prepared template for sending to vManage: \n{template}\n") - - module.session.api.templates.create(template=template, debug=module.params.get("debug") - result.changed = True - result.msg = f"Created template model for {model_name}: {template}" + module = AnsibleCatalystwanModule( + argument_spec=module_args, + required_if=[ + ( + "state", + State.PRESENT.value, + ( + "template_name", + "template_description", + "device_models", + ), + True, + ), + ( + "modified", + State.MODIFIED.value, + ( + "template_name", + "template_description", + "device_models", + ), + True, + ), + ("state", State.ABSENT.value, ("template_name",), True), + ], + ) + # Verify if we are dealing with one or more templates + template_name = module.params.get("template_name") + module.logger.info(f"Module input: \n{module.params}\n") - # all_templates: DataSequence[FeatureTemplateInfo] = module.get_response_safely(module.session.api.templates.get, template=FeatureTemplate) + all_templates: DataSequence[FeatureTemplateInfo] = module.get_response_safely( + module.session.api.templates.get, template=FeatureTemplate + ) + target_template = all_templates.filter(name=template_name) + + # Code for checking if template name exists already + # if yes, do we need some force method or we just inform user and exit? + if module.params.get("state") == "present": + if target_template: + module.logger.debug(f"Detected existing template:\n{target_template}\n") + result.msg = ( + f"Template with name {template_name} already present on vManage," "skipping create template operation." + ) + else: + for model_name, model_module in available_models.items(): + if model_name in module.params.keys() and module.params[model_name] is not None: + module.logger.debug(f"Template input:\n{module.params_without_none_values[model_name]}\n") + # Perform action with template + template = model_module( + template_name=template_name, + template_description=module.params.get("template_description"), + device_models=module.params.get("device_models"), + **module.params_without_none_values[model_name], + ) + + module.logger.debug( + f"Prepared template for sending to vManage, template configuration:\n{template}\n" + ) + + module.session.api.templates.create(template=template, debug=module.params.get("debug")) + result.changed = True + result.msg += f"Created template {model_name}: {template}" + + if module.params.get("state") == "absent": + module.session.api.templates.delete(template=FeatureTemplate, name=template_name) + result.changed = True + result.msg = f"Deleted template {template_name}" # if filters: # filtered_templates = all_templates.filter(**filters) diff --git a/tools/feature_template_docs_generator.py b/tools/feature_template_docs_generator.py deleted file mode 100644 index cd0f54a..0000000 --- a/tools/feature_template_docs_generator.py +++ /dev/null @@ -1,62 +0,0 @@ -import inspect - -from pydantic import BaseModel -from enum import Enum -from typing import get_type_hints, List, Optional - -# Import the Pydantic models (assuming they are defined in the same file or are accessible from the script) -from catalystwan.api.templates.models.cisco_aaa_model import CiscoAAAModel - -# Your Pydantic models should be defined here (as provided in your example) - -# Function to convert a Pydantic model to YAML documentation -def model_to_yaml_docs(model_class, depth=0, is_suboption=False): - indent = ' ' * depth - # type_hints = get_type_hints(model_class) - - # Begin the options block - docs = f"{indent}options:\n" if not is_suboption else "" - - for field_name, field_type in model_class.__annotations__.items(): - default_value = getattr(model_class, field_name, None) - is_required = default_value is None and not issubclass(field_type, (Optional, List)) - is_list = issubclass(field_type, List) - field_info = model_class.__fields__[field_name] - - # Skip if excluded - if field_info.field_info.exclude: - continue - - description = field_info.field_info.description - docs += f"{indent}- name: {field_name}\n" - docs += f"{indent} description: {description}\n" - docs += f"{indent} type: {'list' if is_list else 'dict' if issubclass(field_type, BaseModel) else 'str'}\n" - - if is_required: - docs += f"{indent} required: True\n" - else: - docs += f"{indent} required: False\n" - if default_value is not None and not is_list: - docs += f"{indent} default: {default_value}\n" - - if issubclass(field_type, BaseModel): - docs += f"{indent} suboptions:\n" - docs += model_to_yaml_docs(field_type, depth=depth + 2, is_suboption=True) - elif is_list: - element_type = next(iter(field_type.__args__), None) - if issubclass(element_type, BaseModel): - docs += f"{indent} elements: dict\n" - docs += f"{indent} suboptions:\n" - docs += model_to_yaml_docs(element_type, depth=depth + 2, is_suboption=True) - elif issubclass(element_type, (str, int, Enum)): - docs += f"{indent} elements: {'str' if issubclass(element_type, (str, Enum)) else 'int'}\n" - - if issubclass(field_type, Enum): - choices = [e.value for e in field_type] - docs += f"{indent} choices: {choices}\n" - - return docs - -# Generate the YAML documentation for the CiscoAAAModel -yaml_docs = model_to_yaml_docs(CiscoAAAModel, depth=1) -print(yaml_docs) diff --git a/tools/feature_template_module_args_generator.py b/tools/feature_template_module_args_generator.py deleted file mode 100644 index a0736c4..0000000 --- a/tools/feature_template_module_args_generator.py +++ /dev/null @@ -1,197 +0,0 @@ -import yaml - -yaml_data = """ -options: - cisco_aaa: - description: Cisco AAA Feature Template configuration. - type: dict - suboptions: - user: - description: - - List of user configurations - required: false - default: false - type: list - elements: dict - suboptions: - name: - description: - - The name of the user - required: true - default: null - type: str - password: - description: - - The password for the user - required: false - default: null - type: str - secret: - description: - - The secret for the user - required: false - default: null - type: str - privilege: - description: - - The privilege level for the user - required: false - default: null - type: str - pubkey_chain: - description: - - List of public keys for the user - required: false - default: [] - type: list - elements: str - authentication_group: - description: - - Whether to enable the authentication group - required: false - default: false - type: bool - accounting_group: - description: - - Whether to enable the accounting group - required: false - default: true - type: bool - radius: - description: - - List of Radius group configurations - required: false - default: null - type: list - elements: dict - suboptions: - group_name: - description: - - The name of the RADIUS group - required: true - default: null - type: str - vpn: - description: - - The VPN ID for the RADIUS group - required: true - default: null - type: str - source_interface: - description: - - The source interface for the RADIUS group - required: true - default: null - type: str - server: - description: - - The list of RADIUS servers for the group - required: false - default: [] - type: list - elements: str - domain_stripping: - description: - - The domain stripping configuration - required: false - default: null - type: str - port: - description: - - The port number for AAA - required: false - default: 1700 - type: str - tacacs: - description: - - List of TACACS group configurations - required: false - default: null - type: list - elements: dict - suboptions: - group_name: - description: - - The name of the TACACS+ group - required: true - default: null - type: str - vpn: - description: - - The VPN ID for the TACACS+ group - required: false - default: 0 - type: str - source_interface: - description: - - The source interface for the TACACS+ group - required: false - default: null - type: str - server: - description: - - The list of TACACS+ servers for the group - required: false - default: [] - type: list - elements: str - server_auth_order: - description: - - Authentication order to user access - required: false - default: local - type: str -""" - -# Function to parse YAML data and return the argument spec -def generate_arg_spec(yaml_data): - # Load the YAML data - data = yaml.safe_load(yaml_data) - - # Function to recursively parse the options - def parse_options(options): - arg_spec = {} - for opt_name, opt_info in options.items(): - if 'type' in opt_info: - # Basic fields - arg_spec[opt_name] = { - 'type': opt_info['type'], - 'required': opt_info.get('required', False), - 'default': opt_info.get('default', None) - } - - # Special case for 'list' type - if opt_info['type'] == 'list' and 'elements' in opt_info: - arg_spec[opt_name]['elements'] = opt_info['elements'] - - # Recursively handle suboptions if present - if 'suboptions' in opt_info: - arg_spec[opt_name]['options'] = parse_options(opt_info['suboptions']) - - return arg_spec - - # Get the top-level options and parse them - options = data.get('options', {}) - return parse_options(options) - -# Generate the argument spec -arg_spec = generate_arg_spec(yaml_data) - -# Define the variable name -variable_name = "cisco_aaa_definition" - -# Write the generated dictionary to a Python file -output_file = f"./plugins/module_args/cisco_aaa.py" -with open(output_file, 'w') as file: - file.write(f"{variable_name} = ") - # Use pformat to get a string representation of the dictionary - from pprint import pformat - file.write(pformat(arg_spec, indent=2, width=80)) - file.write("\n") - -print(f"Argument spec saved to {output_file} under the variable {variable_name}") - - -# Printing the generated code in a Python syntax -import pprint -pprint.pprint(arg_spec) \ No newline at end of file diff --git a/utils/ft_device_model.j2 b/utils/ft_device_model.j2 new file mode 100644 index 0000000..f793e31 --- /dev/null +++ b/utils/ft_device_model.j2 @@ -0,0 +1,26 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + +class ModuleDocFragment(object): + DOCUMENTATION = r''' +options: + device_models: + description: + - Defines the SD-WAN device type for template application. + required: true + type: list + default: [] + elements: str + choices: +{% for model in DeviceModel %} + - "{{ model.value }}" +{% endfor %} + ''' diff --git a/utils/ft_docs_template.j2 b/utils/ft_docs_template.j2 new file mode 100644 index 0000000..c9167c4 --- /dev/null +++ b/utils/ft_docs_template.j2 @@ -0,0 +1,16 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r''' +{{ yaml_data | to_nice_yaml | trim }} + ''' diff --git a/utils/ft_generator.py b/utils/ft_generator.py new file mode 100644 index 0000000..ca244ee --- /dev/null +++ b/utils/ft_generator.py @@ -0,0 +1,210 @@ +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + + +import yaml + +from enum import Enum +from typing import Type, Union, get_args, get_origin +from pathlib import Path, PurePath +from pprint import pformat +from jinja2 import Environment, FileSystemLoader +from pydantic import BaseModel +from pydantic.fields import FieldInfo + +from catalystwan.api.templates.models.supported import available_models +from catalystwan.utils.device_model import DeviceModel + +PROJECT_ROOT_DIR = PurePath(Path.cwd()) + + +def safe_issubclass(type_, class_): + try: + return issubclass(type_, class_) + except TypeError: + return False + + +def is_pydantic_model(type_): + try: + return issubclass(type_, BaseModel) + except TypeError: + return False + + +def field_to_ansible_option(field: FieldInfo): + # # if field.description == "List of public keys for the user": + # if field.description == "List of user configurations": + # from IPython import embed; embed() + option = { + "description": [field.description], + "required": field.is_required(), + "default": None, + "type": "str", # default type is str, will be overwritten as needed + } + if not field.is_required(): + if safe_issubclass(field.default, str) or safe_issubclass(field.default, str): + option["default"] = field.default + if safe_issubclass(type(field.default), Enum): + option["default"] = field.default.value + if safe_issubclass(type(field.default), list): + option["default"] = field.default + + field_type = get_origin(field.annotation) or field.annotation + args = get_args(field.annotation) + subargs_base_types = [get_origin(annotation) for annotation in args] + + if field_type == bool: + option["type"] = "bool" + + elif is_pydantic_model(field_type): + option["type"] = "dict" + option["suboptions"] = model_to_ansible_options(field_type) + + elif field_type == list or (field_type == Union and list in subargs_base_types): + elements_type = next((arg for arg in args if arg is not None), None) + if is_pydantic_model(elements_type): + # from IPython import embed; embed() + option["type"] = "list" + option["elements"] = "dict" + option["suboptions"] = model_to_ansible_options(elements_type) + else: + origin_type = get_origin(elements_type) + if origin_type == list: + user_class = get_args(elements_type)[0] + else: + user_class = None + if is_pydantic_model(user_class): + option["type"] = "list" + option["elements"] = "dict" + option["suboptions"] = model_to_ansible_options(user_class) + else: + option["type"] = "list" + option["elements"] = "str" + elif is_pydantic_model(field_type): + option["type"] = "dict" + option["suboptions"] = model_to_ansible_options(field_type) + elif safe_issubclass(field_type, Enum): + option["type"] = "str" + option["choices"] = [item.value for item in field_type] + elif field_type == Union and safe_issubclass(next((arg for arg in args if arg is not None), None), Enum): + option["type"] = "str" + option["choices"] = [item.value for item in args[0]] + return option + + +def model_to_ansible_options(model: Type[BaseModel]): + options = {} + for field_name, field in model.model_fields.items(): + if field_name in [ + "template_name", + "template_description", + "device_models", + "device_specific_variables", + ]: + continue + options[field_name] = field_to_ansible_option(field) + return options + + +def generate_ansible_docs(model: Type[BaseModel], model_name: str): + if not hasattr(model, "_docs_description"): + raise ValueError(f"Missing '_docs_description' documentation field for model {model_name}!") + ansible_docs = { + "options": { + model_name: { + "description": model._docs_description.default, + "type": "dict", + "suboptions": model_to_ansible_options(model), + } + } + } + return ansible_docs + + +# Function to parse YAML data and return the argument spec +def generate_arg_spec(yaml_data): + # Load the YAML data + data = yaml.safe_load(yaml_data) + + # Function to recursively parse the options + def parse_options(options): + arg_spec = {} + for opt_name, opt_info in options.items(): + if "type" in opt_info: + # Basic fields + # if opt_name == "pubkey_chain": + # from IPython import embed; embed() + arg_spec[opt_name] = { + "type": opt_info["type"], + "required": opt_info.get("required", False), + "default": opt_info.get("default", None), + } + + # Special case for 'list' type + if opt_info["type"] == "list" and "elements" in opt_info: + arg_spec[opt_name]["elements"] = opt_info["elements"] + + # Recursively handle suboptions if present + if "suboptions" in opt_info: + arg_spec[opt_name]["options"] = parse_options(opt_info["suboptions"]) + + return arg_spec + + # Get the top-level options and parse them + options = data.get("options", {}) + return parse_options(options) + + +for model_name, model_module in available_models.items(): + # Part for Ansible documentation + ansible_docs = generate_ansible_docs(model_module, model_name) + + def to_nice_yaml(data): + return yaml.dump(data, allow_unicode=True, default_flow_style=False, indent=4, sort_keys=False) + + template_dir = PROJECT_ROOT_DIR / "utils" + env = Environment(loader=FileSystemLoader(template_dir), trim_blocks=True, lstrip_blocks=True) + env.filters["to_nice_yaml"] = to_nice_yaml + + template_file = PurePath("ft_docs_template.j2") + template = env.get_template(str(template_file)) + + output = template.render(yaml_data=ansible_docs) + + filename = f"{PROJECT_ROOT_DIR}/plugins/doc_fragments/feature_template_{model_name}.py" + with open(filename, "w") as f: + f.write(output) + + print(f"File '{filename}' has been written successfully.") + + # Part for Ansible module arguments specification + yaml_str = yaml.dump(ansible_docs, sort_keys=False) + + # Generate the argument spec + arg_spec = generate_arg_spec(yaml_str) + + # Define the variable name + variable_name = f"{model_name}_definition" + + # Write the generated dictionary to a Python file + output_file = f"{PROJECT_ROOT_DIR}/plugins/module_utils/feature_templates/{model_name}.py" + with open(output_file, "w") as file: + file.write(f"{variable_name} = ") + # Use pformat to get a string representation of the dictionary + file.write(pformat(arg_spec, indent=2, width=80)) + file.write("\n") + print(f"Argument spec saved to {output_file} under the variable {variable_name}") + + # Part for Ansible DeviceModel docs fragment + # Load the template file + template_file = "ft_device_model.j2" + template = env.get_template(template_file) + + # Render the template with the DeviceModel enum + output = template.render(DeviceModel=DeviceModel) + + # Write the output to a file + file_name = f"{PROJECT_ROOT_DIR}/plugins/doc_fragments/device_models_feature_template.py" + with open(file_name, "w") as f: + f.write(output) From 71c5f1168ec22dfca7e3776bd39d0435dd416076 Mon Sep 17 00:00:00 2001 From: acichon Date: Thu, 25 Apr 2024 17:29:39 +0200 Subject: [PATCH 03/18] fixed generator --- plugins/doc_fragments/feature_template_cisco_ntp.py | 8 ++++---- plugins/module_utils/feature_templates/cisco_ntp.py | 8 ++++---- plugins/modules/feature_templates.py | 1 + utils/ft_generator.py | 11 +++++++++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/plugins/doc_fragments/feature_template_cisco_ntp.py b/plugins/doc_fragments/feature_template_cisco_ntp.py index f76477e..5c53148 100644 --- a/plugins/doc_fragments/feature_template_cisco_ntp.py +++ b/plugins/doc_fragments/feature_template_cisco_ntp.py @@ -34,19 +34,19 @@ class ModuleDocFragment(object): key: description: - The identifier for the authentication key - required: true + required: false default: null type: str vpn: description: - The VPN ID associated with the NTP server - required: true + required: false default: null type: str version: description: - The NTP version used - required: true + required: false default: null type: str source_interface: @@ -58,7 +58,7 @@ class ModuleDocFragment(object): prefer: description: - Whether this server is preferred over others - required: true + required: false default: null type: str authentication: diff --git a/plugins/module_utils/feature_templates/cisco_ntp.py b/plugins/module_utils/feature_templates/cisco_ntp.py index b633f12..25f1eff 100644 --- a/plugins/module_utils/feature_templates/cisco_ntp.py +++ b/plugins/module_utils/feature_templates/cisco_ntp.py @@ -17,12 +17,12 @@ "default": [], "elements": "dict", "options": { - "key": {"default": None, "required": True, "type": "str"}, + "key": {"default": None, "required": False, "type": "str"}, "name": {"default": None, "required": True, "type": "str"}, - "prefer": {"default": None, "required": True, "type": "str"}, + "prefer": {"default": None, "required": False, "type": "str"}, "source_interface": {"default": None, "required": False, "type": "str"}, - "version": {"default": None, "required": True, "type": "str"}, - "vpn": {"default": None, "required": True, "type": "str"}, + "version": {"default": None, "required": False, "type": "str"}, + "vpn": {"default": None, "required": False, "type": "str"}, }, "required": False, "type": "list", diff --git a/plugins/modules/feature_templates.py b/plugins/modules/feature_templates.py index aef1a0a..90ce23d 100644 --- a/plugins/modules/feature_templates.py +++ b/plugins/modules/feature_templates.py @@ -47,6 +47,7 @@ - cisco.catalystwan.feature_template_cisco_logging - cisco.catalystwan.feature_template_cisco_ntp - cisco.catalystwan.device_models_feature_template + - cisco.catalystwan.manager_authentication author: - Arkadiusz Cichon (acichon@cisco.com) """ diff --git a/utils/ft_generator.py b/utils/ft_generator.py index ca244ee..e83cff3 100644 --- a/utils/ft_generator.py +++ b/utils/ft_generator.py @@ -34,7 +34,7 @@ def is_pydantic_model(type_): def field_to_ansible_option(field: FieldInfo): # # if field.description == "List of public keys for the user": - # if field.description == "List of user configurations": + # if field.description == "The identifier for the authentication key": # from IPython import embed; embed() option = { "description": [field.description], @@ -122,6 +122,13 @@ def generate_ansible_docs(model: Type[BaseModel], model_name: str): return ansible_docs +# from catalystwan.api.templates.models.cisco_ntp_model import CiscoNTPModel + +# available_models = { +# "cisco_ntp": CiscoNTPModel, +# } + + # Function to parse YAML data and return the argument spec def generate_arg_spec(yaml_data): # Load the YAML data @@ -133,7 +140,7 @@ def parse_options(options): for opt_name, opt_info in options.items(): if "type" in opt_info: # Basic fields - # if opt_name == "pubkey_chain": + # if opt_name == "key": # from IPython import embed; embed() arg_spec[opt_name] = { "type": opt_info["type"], From 67a264846c8c0fa589f225d0a2f8f8b5718ac93d Mon Sep 17 00:00:00 2001 From: acichon Date: Fri, 26 Apr 2024 17:20:34 +0200 Subject: [PATCH 04/18] plugins before next generator version --- .../device_models_feature_template.py | 5 +- .../feature_template_cisco_aaa.py | 7 +- .../feature_template_cisco_banner.py | 4 +- .../feature_template_cisco_bfd.py | 4 +- .../feature_template_cisco_logging.py | 4 +- .../feature_template_cisco_ntp.py | 4 +- .../feature_template_cisco_omp.py | 4 +- .../feature_template_cisco_ospf.py | 4 +- ..._template_cisco_secure_internet_gateway.py | 4 +- .../feature_template_cisco_snmp.py | 4 +- .../feature_template_cisco_system.py | 4 +- .../feature_template_cisco_vpn.py | 4 +- .../feature_template_cisco_vpn_interface.py | 4 +- .../feature_template_omp_vsmart.py | 4 +- .../feature_template_security_vsmart.py | 4 +- .../feature_template_system_vsmart.py | 4 +- .../feature_templates/cisco_aaa.py | 198 +++-- .../feature_templates/cisco_banner.py | 20 +- .../feature_templates/cisco_bfd.py | 56 +- .../feature_templates/cisco_logging.py | 133 +-- .../feature_templates/cisco_ntp.py | 85 +- .../feature_templates/cisco_omp.py | 107 ++- .../feature_templates/cisco_ospf.py | 232 +++--- .../cisco_secure_internet_gateway.py | 312 ++++--- .../feature_templates/cisco_snmp.py | 180 ++-- .../feature_templates/cisco_system.py | 362 +++++--- .../feature_templates/cisco_vpn.py | 749 +++++++++-------- .../feature_templates/cisco_vpn_interface.py | 786 ++++++++++++------ .../feature_templates/omp_vsmart.py | 52 +- .../feature_templates/security_vsmart.py | 20 +- .../feature_templates/system_vsmart.py | 92 +- plugins/modules/feature_templates.py | 22 +- plugins/modules/feature_templates_info.py | 6 + ...template.j2 => docs_fragments_template.j2} | 0 utils/ft_device_model.j2 | 2 +- utils/ft_generator.py | 9 +- 36 files changed, 2136 insertions(+), 1355 deletions(-) rename utils/{ft_docs_template.j2 => docs_fragments_template.j2} (100%) diff --git a/plugins/doc_fragments/device_models_feature_template.py b/plugins/doc_fragments/device_models_feature_template.py index 3d30451..1102418 100644 --- a/plugins/doc_fragments/device_models_feature_template.py +++ b/plugins/doc_fragments/device_models_feature_template.py @@ -11,12 +11,11 @@ class ModuleDocFragment(object): - DOCUMENTATION = r""" + DOCUMENTATION = r''' options: device_models: description: - Defines the SD-WAN device type for template application. - required: true type: list default: [] elements: str @@ -85,4 +84,4 @@ class ModuleDocFragment(object): - "vedge-C8200-1N-4T" - "vedge-C8200L-1N-4T" - "vedge-ISRv" - """ + ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_cisco_aaa.py b/plugins/doc_fragments/feature_template_cisco_aaa.py index 5d91fb7..256c8f0 100644 --- a/plugins/doc_fragments/feature_template_cisco_aaa.py +++ b/plugins/doc_fragments/feature_template_cisco_aaa.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r""" + DOCUMENTATION = r''' options: cisco_aaa: description: Cisco AAA Feature Template configuration @@ -248,5 +248,6 @@ class ModuleDocFragment(object): - Authentication order to user access required: false default: null - type: str - """ + type: list + elements: str + ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_cisco_banner.py b/plugins/doc_fragments/feature_template_cisco_banner.py index 458aea4..c8586f2 100644 --- a/plugins/doc_fragments/feature_template_cisco_banner.py +++ b/plugins/doc_fragments/feature_template_cisco_banner.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r""" + DOCUMENTATION = r''' options: cisco_banner: description: Cisco Banner configuration for login and message of the day (MOTD) @@ -30,4 +30,4 @@ class ModuleDocFragment(object): required: false default: null type: str - """ + ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_cisco_bfd.py b/plugins/doc_fragments/feature_template_cisco_bfd.py index 1568fa2..f06e3d0 100644 --- a/plugins/doc_fragments/feature_template_cisco_bfd.py +++ b/plugins/doc_fragments/feature_template_cisco_bfd.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r""" + DOCUMENTATION = r''' options: cisco_bfd: description: Cisco Bidirectional Forwarding Detection (BFD) configuration @@ -97,4 +97,4 @@ class ModuleDocFragment(object): required: false default: null type: str - """ + ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_cisco_logging.py b/plugins/doc_fragments/feature_template_cisco_logging.py index 7fed9ac..07c6338 100644 --- a/plugins/doc_fragments/feature_template_cisco_logging.py +++ b/plugins/doc_fragments/feature_template_cisco_logging.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r""" + DOCUMENTATION = r''' options: cisco_logging: description: Cisco Logging Feature Template configuration @@ -192,4 +192,4 @@ class ModuleDocFragment(object): required: false default: null type: str - """ + ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_cisco_ntp.py b/plugins/doc_fragments/feature_template_cisco_ntp.py index 5c53148..5d6593b 100644 --- a/plugins/doc_fragments/feature_template_cisco_ntp.py +++ b/plugins/doc_fragments/feature_template_cisco_ntp.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r""" + DOCUMENTATION = r''' options: cisco_ntp: description: Cisco NTP Feature Template configuration @@ -106,4 +106,4 @@ class ModuleDocFragment(object): required: false default: null type: str - """ + ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_cisco_omp.py b/plugins/doc_fragments/feature_template_cisco_omp.py index 2ab3c0f..92c4638 100644 --- a/plugins/doc_fragments/feature_template_cisco_omp.py +++ b/plugins/doc_fragments/feature_template_cisco_omp.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r""" + DOCUMENTATION = r''' options: cisco_omp: description: Configuration settings for the Cisco Overlay Management Protocol @@ -169,4 +169,4 @@ class ModuleDocFragment(object): required: false default: null type: str - """ + ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_cisco_ospf.py b/plugins/doc_fragments/feature_template_cisco_ospf.py index a39c2ff..dbfccba 100644 --- a/plugins/doc_fragments/feature_template_cisco_ospf.py +++ b/plugins/doc_fragments/feature_template_cisco_ospf.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r""" + DOCUMENTATION = r''' options: cisco_ospf: description: Cisco OSPF (Open Shortest Path First) configuration @@ -322,4 +322,4 @@ class ModuleDocFragment(object): required: false default: null type: str - """ + ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py b/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py index 6abf586..5fa822a 100644 --- a/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py +++ b/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r""" + DOCUMENTATION = r''' options: cisco_secure_internet_gateway: description: Cisco Secure Internet Gateway feature template configuration @@ -487,4 +487,4 @@ class ModuleDocFragment(object): type: str choices: - SIG - """ + ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_cisco_snmp.py b/plugins/doc_fragments/feature_template_cisco_snmp.py index 5ea160a..876c04d 100644 --- a/plugins/doc_fragments/feature_template_cisco_snmp.py +++ b/plugins/doc_fragments/feature_template_cisco_snmp.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r""" + DOCUMENTATION = r''' options: cisco_snmp: description: Cisco SNMP Feature Template configuration @@ -222,4 +222,4 @@ class ModuleDocFragment(object): required: true default: null type: str - """ + ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_cisco_system.py b/plugins/doc_fragments/feature_template_cisco_system.py index 5b8d14f..f0cadb9 100644 --- a/plugins/doc_fragments/feature_template_cisco_system.py +++ b/plugins/doc_fragments/feature_template_cisco_system.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r""" + DOCUMENTATION = r''' options: cisco_system: description: Cisco System configuration settings for SD-WAN devices. @@ -926,4 +926,4 @@ class ModuleDocFragment(object): - aggressive - moderate - conservative - """ + ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_cisco_vpn.py b/plugins/doc_fragments/feature_template_cisco_vpn.py index c1ee1b7..91d98cf 100644 --- a/plugins/doc_fragments/feature_template_cisco_vpn.py +++ b/plugins/doc_fragments/feature_template_cisco_vpn.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r""" + DOCUMENTATION = r''' options: cisco_vpn: description: Cisco VPN Feature Template configuration. @@ -984,4 +984,4 @@ class ModuleDocFragment(object): required: false default: null type: str - """ + ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_cisco_vpn_interface.py b/plugins/doc_fragments/feature_template_cisco_vpn_interface.py index 6106f81..431e4a1 100644 --- a/plugins/doc_fragments/feature_template_cisco_vpn_interface.py +++ b/plugins/doc_fragments/feature_template_cisco_vpn_interface.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r""" + DOCUMENTATION = r''' options: cisco_vpn_interface: description: Cisco VPN Interface Feature Template configuration @@ -1176,4 +1176,4 @@ class ModuleDocFragment(object): required: false default: null type: str - """ + ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_omp_vsmart.py b/plugins/doc_fragments/feature_template_omp_vsmart.py index 9c23168..ca94a83 100644 --- a/plugins/doc_fragments/feature_template_omp_vsmart.py +++ b/plugins/doc_fragments/feature_template_omp_vsmart.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r""" + DOCUMENTATION = r''' options: omp_vsmart: description: Overlay Management Protocol (OMP) settings for vSmart controller @@ -78,4 +78,4 @@ class ModuleDocFragment(object): required: false default: null type: str - """ + ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_security_vsmart.py b/plugins/doc_fragments/feature_template_security_vsmart.py index 2db1233..009c33a 100644 --- a/plugins/doc_fragments/feature_template_security_vsmart.py +++ b/plugins/doc_fragments/feature_template_security_vsmart.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r""" + DOCUMENTATION = r''' options: security_vsmart: description: Security settings for vSmart controller @@ -32,4 +32,4 @@ class ModuleDocFragment(object): required: false default: null type: str - """ + ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_system_vsmart.py b/plugins/doc_fragments/feature_template_system_vsmart.py index 2450009..e9e6339 100644 --- a/plugins/doc_fragments/feature_template_system_vsmart.py +++ b/plugins/doc_fragments/feature_template_system_vsmart.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r""" + DOCUMENTATION = r''' options: system_vsmart: description: Security settings for vSmart controller @@ -554,4 +554,4 @@ class ModuleDocFragment(object): required: false default: null type: str - """ + ''' \ No newline at end of file diff --git a/plugins/module_utils/feature_templates/cisco_aaa.py b/plugins/module_utils/feature_templates/cisco_aaa.py index c86e137..bf07afe 100644 --- a/plugins/module_utils/feature_templates/cisco_aaa.py +++ b/plugins/module_utils/feature_templates/cisco_aaa.py @@ -1,80 +1,118 @@ -cisco_aaa_definition = { - "cisco_aaa": { - "default": None, - "options": { - "accounting_group": {"default": None, "required": False, "type": "bool"}, - "authentication_group": {"default": None, "required": False, "type": "bool"}, - "domain_stripping": {"default": None, "required": False, "type": "str"}, - "port": {"default": None, "required": False, "type": "str"}, - "radius": { - "default": None, - "elements": "dict", - "options": { - "group_name": {"default": None, "required": True, "type": "str"}, - "server": { - "default": [], - "elements": "dict", - "options": { - "acct_port": {"default": None, "required": False, "type": "str"}, - "address": {"default": None, "required": True, "type": "str"}, - "auth_port": {"default": None, "required": False, "type": "str"}, - "key": {"default": None, "required": True, "type": "str"}, - "key_enum": {"default": None, "required": False, "type": "str"}, - "key_type": {"default": None, "required": False, "type": "str"}, - "retransmit": {"default": None, "required": False, "type": "str"}, - "secret_key": {"default": None, "required": False, "type": "str"}, - "timeout": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "source_interface": {"default": None, "required": True, "type": "str"}, - "vpn": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "server_auth_order": {"default": None, "required": False, "type": "str"}, - "tacacs": { - "default": None, - "elements": "dict", - "options": { - "group_name": {"default": None, "required": True, "type": "str"}, - "server": { - "default": [], - "elements": "dict", - "options": { - "address": {"default": None, "required": True, "type": "str"}, - "key": {"default": None, "required": True, "type": "str"}, - "key_enum": {"default": None, "required": False, "type": "str"}, - "port": {"default": None, "required": False, "type": "str"}, - "secret_key": {"default": None, "required": False, "type": "str"}, - "timeout": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "source_interface": {"default": None, "required": False, "type": "str"}, - "vpn": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "user": { - "default": None, - "elements": "dict", - "options": { - "name": {"default": None, "required": True, "type": "str"}, - "password": {"default": None, "required": False, "type": "str"}, - "privilege": {"default": None, "required": False, "type": "str"}, - "pubkey_chain": {"default": [], "elements": "str", "required": False, "type": "list"}, - "secret": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - }, - "required": False, - "type": "dict", - } -} +cisco_aaa_definition = { 'cisco_aaa': { 'default': None, + 'options': { 'accounting_group': { 'default': None, + 'required': False, + 'type': 'bool'}, + 'authentication_group': { 'default': None, + 'required': False, + 'type': 'bool'}, + 'domain_stripping': { 'default': None, + 'required': False, + 'type': 'str'}, + 'port': { 'default': None, + 'required': False, + 'type': 'str'}, + 'radius': { 'default': None, + 'elements': 'dict', + 'options': { 'group_name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'server': { 'default': [ ], + 'elements': 'dict', + 'options': { 'acct_port': { 'default': None, + 'required': False, + 'type': 'str'}, + 'address': { 'default': None, + 'required': True, + 'type': 'str'}, + 'auth_port': { 'default': None, + 'required': False, + 'type': 'str'}, + 'key': { 'default': None, + 'required': True, + 'type': 'str'}, + 'key_enum': { 'default': None, + 'required': False, + 'type': 'str'}, + 'key_type': { 'default': None, + 'required': False, + 'type': 'str'}, + 'retransmit': { 'default': None, + 'required': False, + 'type': 'str'}, + 'secret_key': { 'default': None, + 'required': False, + 'type': 'str'}, + 'timeout': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'source_interface': { 'default': None, + 'required': True, + 'type': 'str'}, + 'vpn': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'server_auth_order': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'tacacs': { 'default': None, + 'elements': 'dict', + 'options': { 'group_name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'server': { 'default': [ ], + 'elements': 'dict', + 'options': { 'address': { 'default': None, + 'required': True, + 'type': 'str'}, + 'key': { 'default': None, + 'required': True, + 'type': 'str'}, + 'key_enum': { 'default': None, + 'required': False, + 'type': 'str'}, + 'port': { 'default': None, + 'required': False, + 'type': 'str'}, + 'secret_key': { 'default': None, + 'required': False, + 'type': 'str'}, + 'timeout': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'source_interface': { 'default': None, + 'required': False, + 'type': 'str'}, + 'vpn': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'user': { 'default': None, + 'elements': 'dict', + 'options': { 'name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'password': { 'default': None, + 'required': False, + 'type': 'str'}, + 'privilege': { 'default': None, + 'required': False, + 'type': 'str'}, + 'pubkey_chain': { 'default': [ ], + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'secret': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}}, + 'required': False, + 'type': 'dict'}} diff --git a/plugins/module_utils/feature_templates/cisco_banner.py b/plugins/module_utils/feature_templates/cisco_banner.py index 94dc562..f0d96d8 100644 --- a/plugins/module_utils/feature_templates/cisco_banner.py +++ b/plugins/module_utils/feature_templates/cisco_banner.py @@ -1,11 +1,9 @@ -cisco_banner_definition = { - "cisco_banner": { - "default": None, - "options": { - "login_banner": {"default": None, "required": False, "type": "str"}, - "motd_banner": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "dict", - } -} +cisco_banner_definition = { 'cisco_banner': { 'default': None, + 'options': { 'login_banner': { 'default': None, + 'required': False, + 'type': 'str'}, + 'motd_banner': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'dict'}} diff --git a/plugins/module_utils/feature_templates/cisco_bfd.py b/plugins/module_utils/feature_templates/cisco_bfd.py index d6a621e..93b4f37 100644 --- a/plugins/module_utils/feature_templates/cisco_bfd.py +++ b/plugins/module_utils/feature_templates/cisco_bfd.py @@ -1,25 +1,31 @@ -cisco_bfd_definition = { - "cisco_bfd": { - "default": None, - "options": { - "color": { - "default": None, - "elements": "dict", - "options": { - "color": {"default": None, "required": True, "type": "str"}, - "dscp": {"default": None, "required": False, "type": "str"}, - "hello_interval": {"default": None, "required": False, "type": "str"}, - "multiplier": {"default": None, "required": False, "type": "str"}, - "pmtu_discovery": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "default_dscp": {"default": None, "required": False, "type": "str"}, - "multiplier": {"default": None, "required": False, "type": "str"}, - "poll_interval": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "dict", - } -} +cisco_bfd_definition = { 'cisco_bfd': { 'default': None, + 'options': { 'color': { 'default': None, + 'elements': 'dict', + 'options': { 'color': { 'default': None, + 'required': True, + 'type': 'str'}, + 'dscp': { 'default': None, + 'required': False, + 'type': 'str'}, + 'hello_interval': { 'default': None, + 'required': False, + 'type': 'str'}, + 'multiplier': { 'default': None, + 'required': False, + 'type': 'str'}, + 'pmtu_discovery': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'default_dscp': { 'default': None, + 'required': False, + 'type': 'str'}, + 'multiplier': { 'default': None, + 'required': False, + 'type': 'str'}, + 'poll_interval': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'dict'}} diff --git a/plugins/module_utils/feature_templates/cisco_logging.py b/plugins/module_utils/feature_templates/cisco_logging.py index 2b3e154..423d827 100644 --- a/plugins/module_utils/feature_templates/cisco_logging.py +++ b/plugins/module_utils/feature_templates/cisco_logging.py @@ -1,54 +1,79 @@ -cisco_logging_definition = { - "cisco_logging": { - "default": None, - "options": { - "enable": {"default": None, "required": False, "type": "str"}, - "ipv6_server": { - "default": None, - "elements": "dict", - "options": { - "custom_profile": {"default": None, "required": False, "type": "str"}, - "enable_tls": {"default": None, "required": False, "type": "str"}, - "name": {"default": None, "required": True, "type": "str"}, - "priority": {"default": "information", "required": False, "type": "str"}, - "profile": {"default": None, "required": False, "type": "str"}, - "source_interface": {"default": None, "required": False, "type": "str"}, - "vpn": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "rotate": {"default": None, "required": False, "type": "str"}, - "server": { - "default": None, - "elements": "dict", - "options": { - "custom_profile": {"default": None, "required": False, "type": "str"}, - "enable_tls": {"default": None, "required": False, "type": "str"}, - "name": {"default": None, "required": True, "type": "str"}, - "priority": {"default": "information", "required": False, "type": "str"}, - "profile": {"default": None, "required": False, "type": "str"}, - "source_interface": {"default": None, "required": False, "type": "str"}, - "vpn": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "size": {"default": None, "required": False, "type": "str"}, - "tls_profile": { - "default": None, - "elements": "dict", - "options": { - "auth_type": {"default": None, "required": True, "type": "str"}, - "ciphersuite_list": {"default": None, "elements": "str", "required": False, "type": "list"}, - "profile": {"default": None, "required": True, "type": "str"}, - "version": {"default": "TLSv1.1", "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - }, - "required": False, - "type": "dict", - } -} +cisco_logging_definition = { 'cisco_logging': { 'default': None, + 'options': { 'enable': { 'default': None, + 'required': False, + 'type': 'str'}, + 'ipv6_server': { 'default': None, + 'elements': 'dict', + 'options': { 'custom_profile': { 'default': None, + 'required': False, + 'type': 'str'}, + 'enable_tls': { 'default': None, + 'required': False, + 'type': 'str'}, + 'name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'priority': { 'default': 'information', + 'required': False, + 'type': 'str'}, + 'profile': { 'default': None, + 'required': False, + 'type': 'str'}, + 'source_interface': { 'default': None, + 'required': False, + 'type': 'str'}, + 'vpn': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'rotate': { 'default': None, + 'required': False, + 'type': 'str'}, + 'server': { 'default': None, + 'elements': 'dict', + 'options': { 'custom_profile': { 'default': None, + 'required': False, + 'type': 'str'}, + 'enable_tls': { 'default': None, + 'required': False, + 'type': 'str'}, + 'name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'priority': { 'default': 'information', + 'required': False, + 'type': 'str'}, + 'profile': { 'default': None, + 'required': False, + 'type': 'str'}, + 'source_interface': { 'default': None, + 'required': False, + 'type': 'str'}, + 'vpn': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'size': { 'default': None, + 'required': False, + 'type': 'str'}, + 'tls_profile': { 'default': None, + 'elements': 'dict', + 'options': { 'auth_type': { 'default': None, + 'required': True, + 'type': 'str'}, + 'ciphersuite_list': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'profile': { 'default': None, + 'required': True, + 'type': 'str'}, + 'version': { 'default': 'TLSv1.1', + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}}, + 'required': False, + 'type': 'dict'}} diff --git a/plugins/module_utils/feature_templates/cisco_ntp.py b/plugins/module_utils/feature_templates/cisco_ntp.py index 25f1eff..321b93a 100644 --- a/plugins/module_utils/feature_templates/cisco_ntp.py +++ b/plugins/module_utils/feature_templates/cisco_ntp.py @@ -1,37 +1,48 @@ -cisco_ntp_definition = { - "cisco_ntp": { - "default": None, - "options": { - "authentication": { - "default": None, - "elements": "dict", - "options": { - "md5": {"default": None, "required": True, "type": "str"}, - "number": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "enable": {"default": None, "required": False, "type": "str"}, - "server": { - "default": [], - "elements": "dict", - "options": { - "key": {"default": None, "required": False, "type": "str"}, - "name": {"default": None, "required": True, "type": "str"}, - "prefer": {"default": None, "required": False, "type": "str"}, - "source_interface": {"default": None, "required": False, "type": "str"}, - "version": {"default": None, "required": False, "type": "str"}, - "vpn": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "source": {"default": None, "required": False, "type": "str"}, - "stratum": {"default": None, "required": False, "type": "str"}, - "trusted": {"default": None, "elements": "str", "required": False, "type": "list"}, - }, - "required": False, - "type": "dict", - } -} +cisco_ntp_definition = { 'cisco_ntp': { 'default': None, + 'options': { 'authentication': { 'default': None, + 'elements': 'dict', + 'options': { 'md5': { 'default': None, + 'required': True, + 'type': 'str'}, + 'number': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'enable': { 'default': None, + 'required': False, + 'type': 'str'}, + 'server': { 'default': [], + 'elements': 'dict', + 'options': { 'key': { 'default': None, + 'required': False, + 'type': 'str'}, + 'name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'prefer': { 'default': None, + 'required': False, + 'type': 'str'}, + 'source_interface': { 'default': None, + 'required': False, + 'type': 'str'}, + 'version': { 'default': None, + 'required': False, + 'type': 'str'}, + 'vpn': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'source': { 'default': None, + 'required': False, + 'type': 'str'}, + 'stratum': { 'default': None, + 'required': False, + 'type': 'str'}, + 'trusted': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}}, + 'required': False, + 'type': 'dict'}} diff --git a/plugins/module_utils/feature_templates/cisco_omp.py b/plugins/module_utils/feature_templates/cisco_omp.py index 275c96e..358c5c0 100644 --- a/plugins/module_utils/feature_templates/cisco_omp.py +++ b/plugins/module_utils/feature_templates/cisco_omp.py @@ -1,41 +1,66 @@ -cisco_omp_definition = { - "cisco_omp": { - "default": None, - "options": { - "advertise": { - "default": None, - "elements": "dict", - "options": { - "protocol": {"default": None, "required": True, "type": "str"}, - "route": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "advertisement_interval": {"default": None, "required": False, "type": "str"}, - "auto_translate": {"default": None, "required": False, "type": "str"}, - "ecmp_limit": {"default": None, "required": False, "type": "str"}, - "eor_timer": {"default": None, "required": False, "type": "str"}, - "graceful_restart": {"default": None, "required": False, "type": "str"}, - "graceful_restart_timer": {"default": None, "required": False, "type": "str"}, - "holdtime": {"default": None, "required": False, "type": "str"}, - "ignore_region_path_length": {"default": None, "required": False, "type": "str"}, - "ipv6_advertise": { - "default": None, - "elements": "dict", - "options": {"protocol": {"default": None, "required": True, "type": "str"}}, - "required": False, - "type": "list", - }, - "omp_admin_distance_ipv4": {"default": None, "required": False, "type": "str"}, - "omp_admin_distance_ipv6": {"default": None, "required": False, "type": "str"}, - "overlay_as": {"default": None, "required": False, "type": "str"}, - "send_path_limit": {"default": None, "required": False, "type": "str"}, - "shutdown": {"default": None, "required": False, "type": "str"}, - "site_types": {"default": None, "elements": "str", "required": False, "type": "list"}, - "transport_gateway": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "dict", - } -} +cisco_omp_definition = { 'cisco_omp': { 'default': None, + 'options': { 'advertise': { 'default': None, + 'elements': 'dict', + 'options': { 'protocol': { 'default': None, + 'required': True, + 'type': 'str'}, + 'route': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'advertisement_interval': { 'default': None, + 'required': False, + 'type': 'str'}, + 'auto_translate': { 'default': None, + 'required': False, + 'type': 'str'}, + 'ecmp_limit': { 'default': None, + 'required': False, + 'type': 'str'}, + 'eor_timer': { 'default': None, + 'required': False, + 'type': 'str'}, + 'graceful_restart': { 'default': None, + 'required': False, + 'type': 'str'}, + 'graceful_restart_timer': { 'default': None, + 'required': False, + 'type': 'str'}, + 'holdtime': { 'default': None, + 'required': False, + 'type': 'str'}, + 'ignore_region_path_length': { 'default': None, + 'required': False, + 'type': 'str'}, + 'ipv6_advertise': { 'default': None, + 'elements': 'dict', + 'options': { 'protocol': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'omp_admin_distance_ipv4': { 'default': None, + 'required': False, + 'type': 'str'}, + 'omp_admin_distance_ipv6': { 'default': None, + 'required': False, + 'type': 'str'}, + 'overlay_as': { 'default': None, + 'required': False, + 'type': 'str'}, + 'send_path_limit': { 'default': None, + 'required': False, + 'type': 'str'}, + 'shutdown': { 'default': None, + 'required': False, + 'type': 'str'}, + 'site_types': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'transport_gateway': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'dict'}} diff --git a/plugins/module_utils/feature_templates/cisco_ospf.py b/plugins/module_utils/feature_templates/cisco_ospf.py index 668e9c6..fae5255 100644 --- a/plugins/module_utils/feature_templates/cisco_ospf.py +++ b/plugins/module_utils/feature_templates/cisco_ospf.py @@ -1,94 +1,138 @@ -cisco_ospf_definition = { - "cisco_ospf": { - "default": None, - "options": { - "always": {"default": None, "required": False, "type": "str"}, - "area": { - "default": None, - "elements": "dict", - "options": { - "a_num": {"default": None, "required": True, "type": "str"}, - "interface": { - "default": None, - "elements": "dict", - "options": { - "cost": {"default": None, "required": False, "type": "str"}, - "dead_interval": {"default": None, "required": False, "type": "str"}, - "hello_interval": {"default": None, "required": False, "type": "str"}, - "md5": {"default": None, "required": False, "type": "str"}, - "message_digest_key": {"default": None, "required": False, "type": "str"}, - "name": {"default": None, "required": True, "type": "str"}, - "network": {"default": "broadcast", "required": False, "type": "str"}, - "passive_interface": {"default": None, "required": False, "type": "str"}, - "priority": {"default": None, "required": False, "type": "str"}, - "retransmit_interval": {"default": None, "required": False, "type": "str"}, - "type": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "nssa": {"default": None, "required": False, "type": "str"}, - "range": { - "default": None, - "elements": "dict", - "options": { - "address": {"default": None, "required": True, "type": "str"}, - "cost": {"default": None, "required": False, "type": "str"}, - "no_advertise": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "stub": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "delay": {"default": None, "required": False, "type": "str"}, - "external": {"default": None, "required": False, "type": "str"}, - "initial_hold": {"default": None, "required": False, "type": "str"}, - "inter_area": {"default": None, "required": False, "type": "str"}, - "intra_area": {"default": None, "required": False, "type": "str"}, - "max_hold": {"default": None, "required": False, "type": "str"}, - "metric": {"default": None, "required": False, "type": "str"}, - "metric_type": {"default": None, "required": False, "type": "str"}, - "originate": {"default": None, "required": False, "type": "str"}, - "redistribute": { - "default": None, - "elements": "dict", - "options": { - "dia": {"default": None, "required": False, "type": "str"}, - "protocol": {"default": None, "required": True, "type": "str"}, - "route_policy": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "reference_bandwidth": {"default": None, "required": False, "type": "str"}, - "rfc1583": {"default": None, "required": False, "type": "str"}, - "route_policy": { - "default": None, - "elements": "dict", - "options": { - "direction": {"default": None, "required": True, "type": "str"}, - "pol_name": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "router_id": {"default": None, "required": False, "type": "str"}, - "router_lsa": { - "default": None, - "elements": "dict", - "options": { - "ad_type": {"default": None, "required": True, "type": "str"}, - "time": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - }, - "required": False, - "type": "dict", - } -} +cisco_ospf_definition = { 'cisco_ospf': { 'default': None, + 'options': { 'always': { 'default': None, + 'required': False, + 'type': 'str'}, + 'area': { 'default': None, + 'elements': 'dict', + 'options': { 'a_num': { 'default': None, + 'required': True, + 'type': 'str'}, + 'interface': { 'default': None, + 'elements': 'dict', + 'options': { 'cost': { 'default': None, + 'required': False, + 'type': 'str'}, + 'dead_interval': { 'default': None, + 'required': False, + 'type': 'str'}, + 'hello_interval': { 'default': None, + 'required': False, + 'type': 'str'}, + 'md5': { 'default': None, + 'required': False, + 'type': 'str'}, + 'message_digest_key': { 'default': None, + 'required': False, + 'type': 'str'}, + 'name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'network': { 'default': 'broadcast', + 'required': False, + 'type': 'str'}, + 'passive_interface': { 'default': None, + 'required': False, + 'type': 'str'}, + 'priority': { 'default': None, + 'required': False, + 'type': 'str'}, + 'retransmit_interval': { 'default': None, + 'required': False, + 'type': 'str'}, + 'type': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'nssa': { 'default': None, + 'required': False, + 'type': 'str'}, + 'range': { 'default': None, + 'elements': 'dict', + 'options': { 'address': { 'default': None, + 'required': True, + 'type': 'str'}, + 'cost': { 'default': None, + 'required': False, + 'type': 'str'}, + 'no_advertise': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'stub': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'delay': { 'default': None, + 'required': False, + 'type': 'str'}, + 'external': { 'default': None, + 'required': False, + 'type': 'str'}, + 'initial_hold': { 'default': None, + 'required': False, + 'type': 'str'}, + 'inter_area': { 'default': None, + 'required': False, + 'type': 'str'}, + 'intra_area': { 'default': None, + 'required': False, + 'type': 'str'}, + 'max_hold': { 'default': None, + 'required': False, + 'type': 'str'}, + 'metric': { 'default': None, + 'required': False, + 'type': 'str'}, + 'metric_type': { 'default': None, + 'required': False, + 'type': 'str'}, + 'originate': { 'default': None, + 'required': False, + 'type': 'str'}, + 'redistribute': { 'default': None, + 'elements': 'dict', + 'options': { 'dia': { 'default': None, + 'required': False, + 'type': 'str'}, + 'protocol': { 'default': None, + 'required': True, + 'type': 'str'}, + 'route_policy': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'reference_bandwidth': { 'default': None, + 'required': False, + 'type': 'str'}, + 'rfc1583': { 'default': None, + 'required': False, + 'type': 'str'}, + 'route_policy': { 'default': None, + 'elements': 'dict', + 'options': { 'direction': { 'default': None, + 'required': True, + 'type': 'str'}, + 'pol_name': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'router_id': { 'default': None, + 'required': False, + 'type': 'str'}, + 'router_lsa': { 'default': None, + 'elements': 'dict', + 'options': { 'ad_type': { 'default': None, + 'required': True, + 'type': 'str'}, + 'time': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}}, + 'required': False, + 'type': 'dict'}} diff --git a/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py b/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py index 53a1f24..860ab51 100644 --- a/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py +++ b/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py @@ -1,104 +1,208 @@ -cisco_secure_internet_gateway_definition = { - "cisco_secure_internet_gateway": { - "default": None, - "options": { - "interface": { - "default": None, - "elements": "dict", - "options": { - "address": {"default": None, "required": False, "type": "str"}, - "application": {"default": "sig", "required": False, "type": "str"}, - "auto": {"default": None, "required": True, "type": "bool"}, - "description": {"default": None, "required": False, "type": "str"}, - "dpd_interval": {"default": None, "required": False, "type": "str"}, - "dpd_retries": {"default": None, "required": False, "type": "str"}, - "if_name": {"default": None, "required": True, "type": "str"}, - "ike_ciphersuite": {"default": "aes256-cbc-sha1", "required": False, "type": "str"}, - "ike_group": {"default": "14", "required": False, "type": "str"}, - "ike_local_id": {"default": None, "required": False, "type": "str"}, - "ike_rekey_interval": {"default": None, "required": False, "type": "str"}, - "ike_remote_id": {"default": None, "required": False, "type": "str"}, - "ike_version": {"default": None, "required": False, "type": "str"}, - "ipsec_ciphersuite": {"default": "aes256-gcm", "required": False, "type": "str"}, - "ipsec_rekey_interval": {"default": None, "required": False, "type": "str"}, - "ipsec_replay_window": {"default": None, "required": False, "type": "str"}, - "mtu": {"default": None, "required": False, "type": "str"}, - "perfect_forward_secrecy": {"default": "none", "required": False, "type": "str"}, - "pre_shared_key_dynamic": {"default": None, "required": False, "type": "bool"}, - "pre_shared_secret": {"default": None, "required": False, "type": "str"}, - "shutdown": {"default": None, "required": True, "type": "bool"}, - "tcp_mss_adjust": {"default": None, "required": False, "type": "str"}, - "track_enable": {"default": None, "required": False, "type": "str"}, - "tracker": {"default": None, "required": False, "type": "str"}, - "tunnel_dc_preference": {"default": "primary-dc", "required": False, "type": "str"}, - "tunnel_destination": {"default": None, "required": True, "type": "str"}, - "tunnel_route_via": {"default": None, "required": False, "type": "str"}, - "tunnel_set": {"default": "secure-internet-gateway-umbrella", "required": False, "type": "str"}, - "tunnel_source": {"default": None, "required": False, "type": "str"}, - "tunnel_source_interface": {"default": None, "required": False, "type": "str"}, - "unnumbered": {"default": None, "required": False, "type": "bool"}, - }, - "required": True, - "type": "list", - }, - "service": { - "default": None, - "elements": "dict", - "options": { - "auth_required": {"default": None, "required": False, "type": "str"}, - "block_internet_until_accepted": {"default": None, "required": False, "type": "str"}, - "caution_enabled": {"default": None, "required": False, "type": "str"}, - "data_center_primary": {"default": None, "required": False, "type": "str"}, - "data_center_secondary": {"default": None, "required": False, "type": "str"}, - "display_time_unit": {"default": "MINUTE", "required": False, "type": "str"}, - "enabled": {"default": None, "required": False, "type": "str"}, - "force_ssl_inspection": {"default": None, "required": False, "type": "str"}, - "idle_time": {"default": None, "required": False, "type": "str"}, - "interface_pair": { - "default": None, - "elements": "dict", - "options": { - "active_interface": {"default": None, "required": True, "type": "str"}, - "active_interface_weight": {"default": None, "required": False, "type": "str"}, - "backup_interface": {"default": None, "required": False, "type": "str"}, - "backup_interface_weight": {"default": None, "required": False, "type": "str"}, - }, - "required": True, - "type": "list", - }, - "ip": {"default": None, "required": False, "type": "str"}, - "ip_enforced_for_known_browsers": {"default": None, "required": False, "type": "str"}, - "ips_control": {"default": None, "required": False, "type": "str"}, - "ofw_enabled": {"default": None, "required": False, "type": "str"}, - "primary_data_center": {"default": None, "required": False, "type": "str"}, - "refresh_time": {"default": None, "required": False, "type": "str"}, - "refresh_time_unit": {"default": "MINUTE", "required": False, "type": "str"}, - "secondary_data_center": {"default": None, "required": False, "type": "str"}, - "svc_type": {"default": "sig", "required": False, "type": "str"}, - "timeout": {"default": None, "required": False, "type": "str"}, - "xff_forward_enabled": {"default": None, "required": False, "type": "str"}, - }, - "required": True, - "type": "list", - }, - "tracker": { - "default": None, - "elements": "dict", - "options": { - "endpoint_api_url": {"default": None, "required": True, "type": "str"}, - "interval": {"default": None, "required": False, "type": "str"}, - "multiplier": {"default": None, "required": False, "type": "str"}, - "name": {"default": None, "required": True, "type": "str"}, - "threshold": {"default": None, "required": False, "type": "str"}, - "tracker_type": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "tracker_src_ip": {"default": None, "required": False, "type": "str"}, - "vpn_id": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "dict", - } -} +cisco_secure_internet_gateway_definition = { 'cisco_secure_internet_gateway': { 'default': None, + 'options': { 'interface': { 'default': None, + 'elements': 'dict', + 'options': { 'address': { 'default': None, + 'required': False, + 'type': 'str'}, + 'application': { 'default': 'sig', + 'required': False, + 'type': 'str'}, + 'auto': { 'default': None, + 'required': True, + 'type': 'bool'}, + 'description': { 'default': None, + 'required': False, + 'type': 'str'}, + 'dpd_interval': { 'default': None, + 'required': False, + 'type': 'str'}, + 'dpd_retries': { 'default': None, + 'required': False, + 'type': 'str'}, + 'if_name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'ike_ciphersuite': { 'default': 'aes256-cbc-sha1', + 'required': False, + 'type': 'str'}, + 'ike_group': { 'default': '14', + 'required': False, + 'type': 'str'}, + 'ike_local_id': { 'default': None, + 'required': False, + 'type': 'str'}, + 'ike_rekey_interval': { 'default': None, + 'required': False, + 'type': 'str'}, + 'ike_remote_id': { 'default': None, + 'required': False, + 'type': 'str'}, + 'ike_version': { 'default': None, + 'required': False, + 'type': 'str'}, + 'ipsec_ciphersuite': { 'default': 'aes256-gcm', + 'required': False, + 'type': 'str'}, + 'ipsec_rekey_interval': { 'default': None, + 'required': False, + 'type': 'str'}, + 'ipsec_replay_window': { 'default': None, + 'required': False, + 'type': 'str'}, + 'mtu': { 'default': None, + 'required': False, + 'type': 'str'}, + 'perfect_forward_secrecy': { 'default': 'none', + 'required': False, + 'type': 'str'}, + 'pre_shared_key_dynamic': { 'default': None, + 'required': False, + 'type': 'bool'}, + 'pre_shared_secret': { 'default': None, + 'required': False, + 'type': 'str'}, + 'shutdown': { 'default': None, + 'required': True, + 'type': 'bool'}, + 'tcp_mss_adjust': { 'default': None, + 'required': False, + 'type': 'str'}, + 'track_enable': { 'default': None, + 'required': False, + 'type': 'str'}, + 'tracker': { 'default': None, + 'required': False, + 'type': 'str'}, + 'tunnel_dc_preference': { 'default': 'primary-dc', + 'required': False, + 'type': 'str'}, + 'tunnel_destination': { 'default': None, + 'required': True, + 'type': 'str'}, + 'tunnel_route_via': { 'default': None, + 'required': False, + 'type': 'str'}, + 'tunnel_set': { 'default': 'secure-internet-gateway-umbrella', + 'required': False, + 'type': 'str'}, + 'tunnel_source': { 'default': None, + 'required': False, + 'type': 'str'}, + 'tunnel_source_interface': { 'default': None, + 'required': False, + 'type': 'str'}, + 'unnumbered': { 'default': None, + 'required': False, + 'type': 'bool'}}, + 'required': True, + 'type': 'list'}, + 'service': { 'default': None, + 'elements': 'dict', + 'options': { 'auth_required': { 'default': None, + 'required': False, + 'type': 'str'}, + 'block_internet_until_accepted': { 'default': None, + 'required': False, + 'type': 'str'}, + 'caution_enabled': { 'default': None, + 'required': False, + 'type': 'str'}, + 'data_center_primary': { 'default': None, + 'required': False, + 'type': 'str'}, + 'data_center_secondary': { 'default': None, + 'required': False, + 'type': 'str'}, + 'display_time_unit': { 'default': 'MINUTE', + 'required': False, + 'type': 'str'}, + 'enabled': { 'default': None, + 'required': False, + 'type': 'str'}, + 'force_ssl_inspection': { 'default': None, + 'required': False, + 'type': 'str'}, + 'idle_time': { 'default': None, + 'required': False, + 'type': 'str'}, + 'interface_pair': { 'default': None, + 'elements': 'dict', + 'options': { 'active_interface': { 'default': None, + 'required': True, + 'type': 'str'}, + 'active_interface_weight': { 'default': None, + 'required': False, + 'type': 'str'}, + 'backup_interface': { 'default': None, + 'required': False, + 'type': 'str'}, + 'backup_interface_weight': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': True, + 'type': 'list'}, + 'ip': { 'default': None, + 'required': False, + 'type': 'str'}, + 'ip_enforced_for_known_browsers': { 'default': None, + 'required': False, + 'type': 'str'}, + 'ips_control': { 'default': None, + 'required': False, + 'type': 'str'}, + 'ofw_enabled': { 'default': None, + 'required': False, + 'type': 'str'}, + 'primary_data_center': { 'default': None, + 'required': False, + 'type': 'str'}, + 'refresh_time': { 'default': None, + 'required': False, + 'type': 'str'}, + 'refresh_time_unit': { 'default': 'MINUTE', + 'required': False, + 'type': 'str'}, + 'secondary_data_center': { 'default': None, + 'required': False, + 'type': 'str'}, + 'svc_type': { 'default': 'sig', + 'required': False, + 'type': 'str'}, + 'timeout': { 'default': None, + 'required': False, + 'type': 'str'}, + 'xff_forward_enabled': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': True, + 'type': 'list'}, + 'tracker': { 'default': None, + 'elements': 'dict', + 'options': { 'endpoint_api_url': { 'default': None, + 'required': True, + 'type': 'str'}, + 'interval': { 'default': None, + 'required': False, + 'type': 'str'}, + 'multiplier': { 'default': None, + 'required': False, + 'type': 'str'}, + 'name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'threshold': { 'default': None, + 'required': False, + 'type': 'str'}, + 'tracker_type': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'tracker_src_ip': { 'default': None, + 'required': False, + 'type': 'str'}, + 'vpn_id': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'dict'}} diff --git a/plugins/module_utils/feature_templates/cisco_snmp.py b/plugins/module_utils/feature_templates/cisco_snmp.py index 44ce1f3..37957a9 100644 --- a/plugins/module_utils/feature_templates/cisco_snmp.py +++ b/plugins/module_utils/feature_templates/cisco_snmp.py @@ -1,81 +1,99 @@ -cisco_snmp_definition = { - "cisco_snmp": { - "default": None, - "options": { - "community": { - "default": None, - "elements": "dict", - "options": { - "authorization": {"default": None, "required": True, "type": "str"}, - "name": {"default": None, "required": True, "type": "str"}, - "view": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "contact": {"default": None, "required": True, "type": "str"}, - "group": { - "default": None, - "elements": "dict", - "options": { - "name": {"default": None, "required": True, "type": "str"}, - "security_level": {"default": None, "required": True, "type": "str"}, - "view": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "location": {"default": None, "required": True, "type": "str"}, - "shutdown": {"default": None, "required": False, "type": "str"}, - "target": { - "default": None, - "elements": "dict", - "options": { - "community_name": {"default": None, "required": True, "type": "str"}, - "ip": {"default": None, "required": True, "type": "str"}, - "port": {"default": None, "required": True, "type": "str"}, - "source_interface": {"default": None, "required": True, "type": "str"}, - "user": {"default": None, "required": True, "type": "str"}, - "vpn_id": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "user": { - "default": None, - "elements": "dict", - "options": { - "auth": {"default": None, "required": True, "type": "str"}, - "auth_password": {"default": None, "required": True, "type": "str"}, - "group": {"default": None, "required": True, "type": "str"}, - "name": {"default": None, "required": True, "type": "str"}, - "priv": {"default": None, "required": True, "type": "str"}, - "priv_password": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "view": { - "default": None, - "elements": "dict", - "options": { - "name": {"default": None, "required": True, "type": "str"}, - "oid": { - "default": None, - "elements": "dict", - "options": { - "exclude": {"default": None, "required": True, "type": "str"}, - "id": {"default": None, "required": True, "type": "str"}, - }, - "required": True, - "type": "list", - }, - }, - "required": False, - "type": "list", - }, - }, - "required": False, - "type": "dict", - } -} +cisco_snmp_definition = { 'cisco_snmp': { 'default': None, + 'options': { 'community': { 'default': None, + 'elements': 'dict', + 'options': { 'authorization': { 'default': None, + 'required': True, + 'type': 'str'}, + 'name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'view': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'contact': { 'default': None, + 'required': True, + 'type': 'str'}, + 'group': { 'default': None, + 'elements': 'dict', + 'options': { 'name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'security_level': { 'default': None, + 'required': True, + 'type': 'str'}, + 'view': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'location': { 'default': None, + 'required': True, + 'type': 'str'}, + 'shutdown': { 'default': None, + 'required': False, + 'type': 'str'}, + 'target': { 'default': None, + 'elements': 'dict', + 'options': { 'community_name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'ip': { 'default': None, + 'required': True, + 'type': 'str'}, + 'port': { 'default': None, + 'required': True, + 'type': 'str'}, + 'source_interface': { 'default': None, + 'required': True, + 'type': 'str'}, + 'user': { 'default': None, + 'required': True, + 'type': 'str'}, + 'vpn_id': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'user': { 'default': None, + 'elements': 'dict', + 'options': { 'auth': { 'default': None, + 'required': True, + 'type': 'str'}, + 'auth_password': { 'default': None, + 'required': True, + 'type': 'str'}, + 'group': { 'default': None, + 'required': True, + 'type': 'str'}, + 'name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'priv': { 'default': None, + 'required': True, + 'type': 'str'}, + 'priv_password': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'view': { 'default': None, + 'elements': 'dict', + 'options': { 'name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'oid': { 'default': None, + 'elements': 'dict', + 'options': { 'exclude': { 'default': None, + 'required': True, + 'type': 'str'}, + 'id': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': True, + 'type': 'list'}}, + 'required': False, + 'type': 'list'}}, + 'required': False, + 'type': 'dict'}} diff --git a/plugins/module_utils/feature_templates/cisco_system.py b/plugins/module_utils/feature_templates/cisco_system.py index 3934dfd..7e67ea7 100644 --- a/plugins/module_utils/feature_templates/cisco_system.py +++ b/plugins/module_utils/feature_templates/cisco_system.py @@ -1,128 +1,234 @@ -cisco_system_definition = { - "cisco_system": { - "default": None, - "options": { - "admin_tech_on_failure": {"default": None, "required": False, "type": "str"}, - "affinity_group_number": {"default": None, "required": False, "type": "str"}, - "affinity_per_vrf": { - "default": None, - "elements": "dict", - "options": { - "affinity_group_number": {"default": None, "required": False, "type": "str"}, - "vrf_range": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "console_baud_rate": {"default": None, "required": False, "type": "str"}, - "control_session_pps": {"default": None, "required": False, "type": "str"}, - "controller_group_list": {"default": None, "elements": "str", "required": False, "type": "list"}, - "device_groups": {"default": None, "elements": "str", "required": False, "type": "list"}, - "enable_fencing": {"default": None, "required": False, "type": "str"}, - "enable_management_region": {"default": None, "required": False, "type": "str"}, - "enable_mrf_migration": {"default": None, "required": False, "type": "str"}, - "enable_sms": {"default": None, "required": False, "type": "str"}, - "enable_tunnel": {"default": None, "required": False, "type": "str"}, - "epfr": {"default": None, "required": False, "type": "str"}, - "hostname": { - "default": None, - "options": {"name": {"default": None, "required": True, "type": "str"}}, - "required": False, - "type": "dict", - }, - "idle_timeout": {"default": None, "required": False, "type": "str"}, - "latitude": {"default": None, "required": False, "type": "str"}, - "location": {"default": None, "required": False, "type": "str"}, - "longitude": {"default": None, "required": False, "type": "str"}, - "management_gateway": {"default": None, "required": False, "type": "str"}, - "max_omp_sessions": {"default": None, "required": False, "type": "str"}, - "migration_bgp_community": {"default": None, "required": False, "type": "str"}, - "mobile_number": { - "default": None, - "elements": "dict", - "options": {"number": {"default": None, "required": True, "type": "str"}}, - "required": False, - "type": "list", - }, - "multi_tenant": {"default": None, "required": False, "type": "str"}, - "object_track": { - "default": None, - "elements": "dict", - "options": { - "boolean": {"default": None, "required": True, "type": "str"}, - "interface": {"default": None, "required": True, "type": "str"}, - "ip": {"default": None, "required": True, "type": "str"}, - "mask": {"default": None, "required": False, "type": "str"}, - "object": { - "default": None, - "elements": "dict", - "options": {"number": {"default": None, "required": True, "type": "str"}}, - "required": True, - "type": "list", - }, - "object_number": {"default": None, "required": True, "type": "str"}, - "sig": {"default": None, "required": True, "type": "str"}, - "vpn": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "on_demand_idle_timeout_min": {"default": None, "required": False, "type": "str"}, - "overlay_id": {"default": None, "required": False, "type": "str"}, - "port_hop": {"default": None, "required": False, "type": "str"}, - "port_offset": {"default": None, "required": False, "type": "str"}, - "preference": {"default": None, "elements": "str", "required": False, "type": "list"}, - "preference_auto": {"default": None, "required": False, "type": "str"}, - "range": {"default": None, "required": False, "type": "str"}, - "region_id": {"default": None, "required": False, "type": "str"}, - "role": {"default": None, "required": False, "type": "str"}, - "secondary_region": {"default": None, "required": False, "type": "str"}, - "site_id": {"default": None, "required": False, "type": "str"}, - "site_type": {"default": None, "elements": "str", "required": False, "type": "list"}, - "system_ip": { - "default": None, - "options": {"name": {"default": None, "required": True, "type": "str"}}, - "required": False, - "type": "dict", - }, - "timezone": {"default": None, "required": False, "type": "str"}, - "track_default_gateway": {"default": None, "required": False, "type": "str"}, - "track_interface_tag": {"default": None, "required": False, "type": "str"}, - "track_transport": {"default": None, "required": False, "type": "str"}, - "tracker": { - "default": None, - "elements": "dict", - "options": { - "boolean": {"default": "or", "required": False, "type": "str"}, - "elements": {"default": None, "elements": "str", "required": False, "type": "list"}, - "endpoint_api_url": {"default": None, "required": False, "type": "str"}, - "endpoint_dns_name": {"default": None, "required": False, "type": "str"}, - "endpoint_ip": {"default": None, "required": False, "type": "str"}, - "endpoint_ip_transport_port": {"default": None, "required": False, "type": "str"}, - "interval": {"default": None, "required": False, "type": "str"}, - "multiplier": {"default": None, "required": False, "type": "str"}, - "name": {"default": None, "required": True, "type": "str"}, - "port": {"default": None, "required": False, "type": "str"}, - "protocol": {"default": None, "required": False, "type": "str"}, - "threshold": {"default": None, "required": False, "type": "str"}, - "type": {"default": "interface", "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "transport_gateway": {"default": None, "required": False, "type": "str"}, - "vrf": { - "default": None, - "elements": "dict", - "options": { - "gateway_preference": {"default": None, "elements": "str", "required": False, "type": "list"}, - "vrf_id": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - }, - "required": False, - "type": "dict", - } -} +cisco_system_definition = { 'cisco_system': { 'default': None, + 'options': { 'admin_tech_on_failure': { 'default': None, + 'required': False, + 'type': 'str'}, + 'affinity_group_number': { 'default': None, + 'required': False, + 'type': 'str'}, + 'affinity_per_vrf': { 'default': None, + 'elements': 'dict', + 'options': { 'affinity_group_number': { 'default': None, + 'required': False, + 'type': 'str'}, + 'vrf_range': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'console_baud_rate': { 'default': None, + 'required': False, + 'type': 'str'}, + 'control_session_pps': { 'default': None, + 'required': False, + 'type': 'str'}, + 'controller_group_list': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'device_groups': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'enable_fencing': { 'default': None, + 'required': False, + 'type': 'str'}, + 'enable_management_region': { 'default': None, + 'required': False, + 'type': 'str'}, + 'enable_mrf_migration': { 'default': None, + 'required': False, + 'type': 'str'}, + 'enable_sms': { 'default': None, + 'required': False, + 'type': 'str'}, + 'enable_tunnel': { 'default': None, + 'required': False, + 'type': 'str'}, + 'epfr': { 'default': None, + 'required': False, + 'type': 'str'}, + 'hostname': { 'default': None, + 'options': { 'name': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'dict'}, + 'idle_timeout': { 'default': None, + 'required': False, + 'type': 'str'}, + 'latitude': { 'default': None, + 'required': False, + 'type': 'str'}, + 'location': { 'default': None, + 'required': False, + 'type': 'str'}, + 'longitude': { 'default': None, + 'required': False, + 'type': 'str'}, + 'management_gateway': { 'default': None, + 'required': False, + 'type': 'str'}, + 'max_omp_sessions': { 'default': None, + 'required': False, + 'type': 'str'}, + 'migration_bgp_community': { 'default': None, + 'required': False, + 'type': 'str'}, + 'mobile_number': { 'default': None, + 'elements': 'dict', + 'options': { 'number': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'multi_tenant': { 'default': None, + 'required': False, + 'type': 'str'}, + 'object_track': { 'default': None, + 'elements': 'dict', + 'options': { 'boolean': { 'default': None, + 'required': True, + 'type': 'str'}, + 'interface': { 'default': None, + 'required': True, + 'type': 'str'}, + 'ip': { 'default': None, + 'required': True, + 'type': 'str'}, + 'mask': { 'default': None, + 'required': False, + 'type': 'str'}, + 'object': { 'default': None, + 'elements': 'dict', + 'options': { 'number': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': True, + 'type': 'list'}, + 'object_number': { 'default': None, + 'required': True, + 'type': 'str'}, + 'sig': { 'default': None, + 'required': True, + 'type': 'str'}, + 'vpn': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'on_demand_idle_timeout_min': { 'default': None, + 'required': False, + 'type': 'str'}, + 'overlay_id': { 'default': None, + 'required': False, + 'type': 'str'}, + 'port_hop': { 'default': None, + 'required': False, + 'type': 'str'}, + 'port_offset': { 'default': None, + 'required': False, + 'type': 'str'}, + 'preference': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'preference_auto': { 'default': None, + 'required': False, + 'type': 'str'}, + 'range': { 'default': None, + 'required': False, + 'type': 'str'}, + 'region_id': { 'default': None, + 'required': False, + 'type': 'str'}, + 'role': { 'default': None, + 'required': False, + 'type': 'str'}, + 'secondary_region': { 'default': None, + 'required': False, + 'type': 'str'}, + 'site_id': { 'default': None, + 'required': False, + 'type': 'str'}, + 'site_type': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'system_ip': { 'default': None, + 'options': { 'name': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'dict'}, + 'timezone': { 'default': None, + 'required': False, + 'type': 'str'}, + 'track_default_gateway': { 'default': None, + 'required': False, + 'type': 'str'}, + 'track_interface_tag': { 'default': None, + 'required': False, + 'type': 'str'}, + 'track_transport': { 'default': None, + 'required': False, + 'type': 'str'}, + 'tracker': { 'default': None, + 'elements': 'dict', + 'options': { 'boolean': { 'default': 'or', + 'required': False, + 'type': 'str'}, + 'elements': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'endpoint_api_url': { 'default': None, + 'required': False, + 'type': 'str'}, + 'endpoint_dns_name': { 'default': None, + 'required': False, + 'type': 'str'}, + 'endpoint_ip': { 'default': None, + 'required': False, + 'type': 'str'}, + 'endpoint_ip_transport_port': { 'default': None, + 'required': False, + 'type': 'str'}, + 'interval': { 'default': None, + 'required': False, + 'type': 'str'}, + 'multiplier': { 'default': None, + 'required': False, + 'type': 'str'}, + 'name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'port': { 'default': None, + 'required': False, + 'type': 'str'}, + 'protocol': { 'default': None, + 'required': False, + 'type': 'str'}, + 'threshold': { 'default': None, + 'required': False, + 'type': 'str'}, + 'type': { 'default': 'interface', + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'transport_gateway': { 'default': None, + 'required': False, + 'type': 'str'}, + 'vrf': { 'default': None, + 'elements': 'dict', + 'options': { 'gateway_preference': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'vrf_id': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}}, + 'required': False, + 'type': 'dict'}} diff --git a/plugins/module_utils/feature_templates/cisco_vpn.py b/plugins/module_utils/feature_templates/cisco_vpn.py index 4aeae49..f6ae887 100644 --- a/plugins/module_utils/feature_templates/cisco_vpn.py +++ b/plugins/module_utils/feature_templates/cisco_vpn.py @@ -1,326 +1,423 @@ -cisco_vpn_definition = { - "cisco_vpn": { - "default": None, - "options": { - "advertise": { - "default": None, - "elements": "dict", - "options": { - "prefix_list": { - "default": None, - "elements": "dict", - "options": { - "aggregate_only": {"default": None, "required": False, "type": "str"}, - "prefix_entry": {"default": None, "required": True, "type": "str"}, - "region": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "protocol": {"default": None, "required": True, "type": "str"}, - "protocol_sub_type": {"default": None, "elements": "str", "required": False, "type": "list"}, - "route_policy": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "dns": { - "default": None, - "elements": "dict", - "options": { - "dns_addr": {"default": None, "required": False, "type": "str"}, - "role": {"default": "primary", "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "dns_ipv6": { - "default": None, - "elements": "dict", - "options": { - "dns_addr": {"default": None, "required": False, "type": "str"}, - "role": {"default": "primary", "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "gre_route": { - "default": None, - "elements": "dict", - "options": { - "interface": {"default": None, "elements": "str", "required": False, "type": "list"}, - "prefix": {"default": None, "required": True, "type": "str"}, - "vpn": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "host": { - "default": None, - "elements": "dict", - "options": { - "hostname": {"default": None, "required": True, "type": "str"}, - "ip": {"default": None, "elements": "str", "required": True, "type": "list"}, - }, - "required": False, - "type": "list", - }, - "ipsec_route": { - "default": None, - "elements": "dict", - "options": { - "interface": {"default": None, "elements": "str", "required": False, "type": "list"}, - "prefix": {"default": None, "required": True, "type": "str"}, - "vpn": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "ipv6_advertise": { - "default": None, - "elements": "dict", - "options": { - "prefix_list": { - "default": None, - "elements": "dict", - "options": { - "aggregate_only": {"default": None, "required": False, "type": "str"}, - "prefix_entry": {"default": None, "required": True, "type": "str"}, - "region": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "protocol": {"default": None, "required": True, "type": "str"}, - "protocol_sub_type": {"default": None, "elements": "str", "required": False, "type": "list"}, - "route_policy": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "layer4": {"default": None, "required": False, "type": "str"}, - "natpool": { - "default": None, - "elements": "dict", - "options": { - "direction": {"default": None, "required": True, "type": "str"}, - "name": {"default": None, "required": True, "type": "str"}, - "overload": {"default": "true", "required": False, "type": "str"}, - "prefix_length": {"default": None, "required": False, "type": "str"}, - "range_end": {"default": None, "required": False, "type": "str"}, - "range_start": {"default": None, "required": False, "type": "str"}, - "tracker_id": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "omp_admin_distance_ipv4": {"default": None, "required": False, "type": "str"}, - "omp_admin_distance_ipv6": {"default": None, "required": False, "type": "str"}, - "org_name": {"default": None, "required": False, "type": "str"}, - "pool": { - "default": None, - "elements": "dict", - "options": { - "end_address": {"default": None, "required": True, "type": "str"}, - "leak_from_global": {"default": None, "required": True, "type": "bool"}, - "leak_from_global_protocol": {"default": None, "required": True, "type": "str"}, - "leak_to_global": {"default": None, "required": True, "type": "bool"}, - "name": {"default": None, "required": True, "type": "str"}, - "overload": {"default": None, "required": False, "type": "str"}, - "start_address": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "port_forward": { - "default": None, - "elements": "dict", - "options": { - "pool_name": {"default": None, "required": False, "type": "str"}, - "proto": {"default": None, "required": True, "type": "str"}, - "source_ip": {"default": None, "required": True, "type": "str"}, - "source_port": {"default": None, "required": True, "type": "str"}, - "translate_ip": {"default": None, "required": True, "type": "str"}, - "translate_port": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "route_export": { - "default": None, - "elements": "dict", - "options": { - "protocol": {"default": None, "required": True, "type": "str"}, - "protocol_sub_type": {"default": None, "elements": "str", "required": True, "type": "list"}, - "redistribute": { - "default": None, - "elements": "dict", - "options": { - "protocol": {"default": None, "required": True, "type": "str"}, - "route_policy": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "route_policy": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "route_import": { - "default": None, - "elements": "dict", - "options": { - "protocol": {"default": None, "required": True, "type": "str"}, - "protocol_sub_type": {"default": None, "elements": "str", "required": True, "type": "list"}, - "redistribute": { - "default": None, - "elements": "dict", - "options": { - "protocol": {"default": None, "required": True, "type": "str"}, - "route_policy": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "route_policy": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "route_import_from": { - "default": None, - "elements": "dict", - "options": { - "protocol": {"default": None, "required": True, "type": "str"}, - "protocol_sub_type": {"default": None, "elements": "str", "required": True, "type": "list"}, - "redistribute": { - "default": None, - "elements": "dict", - "options": { - "protocol": {"default": None, "required": True, "type": "str"}, - "route_policy": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "route_policy": {"default": None, "required": False, "type": "str"}, - "source_vpn": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "route_v4": { - "default": None, - "elements": "dict", - "options": { - "dhcp": {"default": None, "required": False, "type": "str"}, - "distance": {"default": None, "required": False, "type": "str"}, - "next_hop": { - "default": None, - "elements": "dict", - "options": { - "address": {"default": None, "required": False, "type": "str"}, - "distance": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "next_hop_with_track": { - "default": None, - "elements": "dict", - "options": { - "address": {"default": None, "required": False, "type": "str"}, - "distance": {"default": None, "required": False, "type": "str"}, - "tracker": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "null0": {"default": None, "required": False, "type": "str"}, - "prefix": {"default": None, "required": False, "type": "str"}, - "route_interface": {"default": None, "required": False, "type": "str"}, - "vpn": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "route_v6": { - "default": None, - "elements": "dict", - "options": { - "nat": {"default": None, "required": False, "type": "str"}, - "next_hop": { - "default": None, - "elements": "dict", - "options": { - "address": {"default": None, "required": True, "type": "str"}, - "distance": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "null0": {"default": None, "required": False, "type": "str"}, - "prefix": {"default": None, "required": True, "type": "str"}, - "vpn": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "service": { - "default": None, - "elements": "dict", - "options": { - "address": {"default": None, "elements": "str", "required": False, "type": "list"}, - "interface": {"default": None, "required": False, "type": "str"}, - "svc_type": {"default": None, "required": True, "type": "str"}, - "track_enable": {"default": None, "required": False, "type": "bool"}, - }, - "required": False, - "type": "list", - }, - "service_route": { - "default": None, - "elements": "dict", - "options": { - "prefix": {"default": None, "required": True, "type": "str"}, - "service": {"default": "sig", "required": False, "type": "str"}, - "vpn": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "static": { - "default": None, - "elements": "dict", - "options": { - "pool_name": {"default": None, "required": False, "type": "str"}, - "source_ip": {"default": None, "required": False, "type": "str"}, - "static_nat_direction": {"default": None, "required": True, "type": "str"}, - "tracker_id": {"default": None, "required": False, "type": "str"}, - "translate_ip": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "subnet_static": { - "default": None, - "elements": "dict", - "options": { - "prefix_length": {"default": None, "required": True, "type": "str"}, - "source_ip_subnet": {"default": None, "required": True, "type": "str"}, - "static_nat_direction": {"default": None, "required": True, "type": "str"}, - "tracker_id": {"default": None, "required": False, "type": "str"}, - "translate_ip_subnet": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "tenant_vpn_id": {"default": None, "required": False, "type": "str"}, - "vpn_id": {"default": None, "required": False, "type": "str"}, - "vpn_name": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "dict", - } -} +cisco_vpn_definition = { 'cisco_vpn': { 'default': None, + 'options': { 'advertise': { 'default': None, + 'elements': 'dict', + 'options': { 'prefix_list': { 'default': None, + 'elements': 'dict', + 'options': { 'aggregate_only': { 'default': None, + 'required': False, + 'type': 'str'}, + 'prefix_entry': { 'default': None, + 'required': True, + 'type': 'str'}, + 'region': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'protocol': { 'default': None, + 'required': True, + 'type': 'str'}, + 'protocol_sub_type': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'route_policy': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'dns': { 'default': None, + 'elements': 'dict', + 'options': { 'dns_addr': { 'default': None, + 'required': False, + 'type': 'str'}, + 'role': { 'default': 'primary', + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'dns_ipv6': { 'default': None, + 'elements': 'dict', + 'options': { 'dns_addr': { 'default': None, + 'required': False, + 'type': 'str'}, + 'role': { 'default': 'primary', + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'gre_route': { 'default': None, + 'elements': 'dict', + 'options': { 'interface': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'prefix': { 'default': None, + 'required': True, + 'type': 'str'}, + 'vpn': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'host': { 'default': None, + 'elements': 'dict', + 'options': { 'hostname': { 'default': None, + 'required': True, + 'type': 'str'}, + 'ip': { 'default': None, + 'elements': 'str', + 'required': True, + 'type': 'list'}}, + 'required': False, + 'type': 'list'}, + 'ipsec_route': { 'default': None, + 'elements': 'dict', + 'options': { 'interface': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'prefix': { 'default': None, + 'required': True, + 'type': 'str'}, + 'vpn': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'ipv6_advertise': { 'default': None, + 'elements': 'dict', + 'options': { 'prefix_list': { 'default': None, + 'elements': 'dict', + 'options': { 'aggregate_only': { 'default': None, + 'required': False, + 'type': 'str'}, + 'prefix_entry': { 'default': None, + 'required': True, + 'type': 'str'}, + 'region': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'protocol': { 'default': None, + 'required': True, + 'type': 'str'}, + 'protocol_sub_type': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'route_policy': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'layer4': { 'default': None, + 'required': False, + 'type': 'str'}, + 'natpool': { 'default': None, + 'elements': 'dict', + 'options': { 'direction': { 'default': None, + 'required': True, + 'type': 'str'}, + 'name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'overload': { 'default': 'true', + 'required': False, + 'type': 'str'}, + 'prefix_length': { 'default': None, + 'required': False, + 'type': 'str'}, + 'range_end': { 'default': None, + 'required': False, + 'type': 'str'}, + 'range_start': { 'default': None, + 'required': False, + 'type': 'str'}, + 'tracker_id': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'omp_admin_distance_ipv4': { 'default': None, + 'required': False, + 'type': 'str'}, + 'omp_admin_distance_ipv6': { 'default': None, + 'required': False, + 'type': 'str'}, + 'org_name': { 'default': None, + 'required': False, + 'type': 'str'}, + 'pool': { 'default': None, + 'elements': 'dict', + 'options': { 'end_address': { 'default': None, + 'required': True, + 'type': 'str'}, + 'leak_from_global': { 'default': None, + 'required': True, + 'type': 'bool'}, + 'leak_from_global_protocol': { 'default': None, + 'required': True, + 'type': 'str'}, + 'leak_to_global': { 'default': None, + 'required': True, + 'type': 'bool'}, + 'name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'overload': { 'default': None, + 'required': False, + 'type': 'str'}, + 'start_address': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'port_forward': { 'default': None, + 'elements': 'dict', + 'options': { 'pool_name': { 'default': None, + 'required': False, + 'type': 'str'}, + 'proto': { 'default': None, + 'required': True, + 'type': 'str'}, + 'source_ip': { 'default': None, + 'required': True, + 'type': 'str'}, + 'source_port': { 'default': None, + 'required': True, + 'type': 'str'}, + 'translate_ip': { 'default': None, + 'required': True, + 'type': 'str'}, + 'translate_port': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'route_export': { 'default': None, + 'elements': 'dict', + 'options': { 'protocol': { 'default': None, + 'required': True, + 'type': 'str'}, + 'protocol_sub_type': { 'default': None, + 'elements': 'str', + 'required': True, + 'type': 'list'}, + 'redistribute': { 'default': None, + 'elements': 'dict', + 'options': { 'protocol': { 'default': None, + 'required': True, + 'type': 'str'}, + 'route_policy': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'route_policy': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'route_import': { 'default': None, + 'elements': 'dict', + 'options': { 'protocol': { 'default': None, + 'required': True, + 'type': 'str'}, + 'protocol_sub_type': { 'default': None, + 'elements': 'str', + 'required': True, + 'type': 'list'}, + 'redistribute': { 'default': None, + 'elements': 'dict', + 'options': { 'protocol': { 'default': None, + 'required': True, + 'type': 'str'}, + 'route_policy': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'route_policy': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'route_import_from': { 'default': None, + 'elements': 'dict', + 'options': { 'protocol': { 'default': None, + 'required': True, + 'type': 'str'}, + 'protocol_sub_type': { 'default': None, + 'elements': 'str', + 'required': True, + 'type': 'list'}, + 'redistribute': { 'default': None, + 'elements': 'dict', + 'options': { 'protocol': { 'default': None, + 'required': True, + 'type': 'str'}, + 'route_policy': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'route_policy': { 'default': None, + 'required': False, + 'type': 'str'}, + 'source_vpn': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'route_v4': { 'default': None, + 'elements': 'dict', + 'options': { 'dhcp': { 'default': None, + 'required': False, + 'type': 'str'}, + 'distance': { 'default': None, + 'required': False, + 'type': 'str'}, + 'next_hop': { 'default': None, + 'elements': 'dict', + 'options': { 'address': { 'default': None, + 'required': False, + 'type': 'str'}, + 'distance': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'next_hop_with_track': { 'default': None, + 'elements': 'dict', + 'options': { 'address': { 'default': None, + 'required': False, + 'type': 'str'}, + 'distance': { 'default': None, + 'required': False, + 'type': 'str'}, + 'tracker': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'null0': { 'default': None, + 'required': False, + 'type': 'str'}, + 'prefix': { 'default': None, + 'required': False, + 'type': 'str'}, + 'route_interface': { 'default': None, + 'required': False, + 'type': 'str'}, + 'vpn': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'route_v6': { 'default': None, + 'elements': 'dict', + 'options': { 'nat': { 'default': None, + 'required': False, + 'type': 'str'}, + 'next_hop': { 'default': None, + 'elements': 'dict', + 'options': { 'address': { 'default': None, + 'required': True, + 'type': 'str'}, + 'distance': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'null0': { 'default': None, + 'required': False, + 'type': 'str'}, + 'prefix': { 'default': None, + 'required': True, + 'type': 'str'}, + 'vpn': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'service': { 'default': None, + 'elements': 'dict', + 'options': { 'address': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'interface': { 'default': None, + 'required': False, + 'type': 'str'}, + 'svc_type': { 'default': None, + 'required': True, + 'type': 'str'}, + 'track_enable': { 'default': None, + 'required': False, + 'type': 'bool'}}, + 'required': False, + 'type': 'list'}, + 'service_route': { 'default': None, + 'elements': 'dict', + 'options': { 'prefix': { 'default': None, + 'required': True, + 'type': 'str'}, + 'service': { 'default': 'sig', + 'required': False, + 'type': 'str'}, + 'vpn': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'static': { 'default': None, + 'elements': 'dict', + 'options': { 'pool_name': { 'default': None, + 'required': False, + 'type': 'str'}, + 'source_ip': { 'default': None, + 'required': False, + 'type': 'str'}, + 'static_nat_direction': { 'default': None, + 'required': True, + 'type': 'str'}, + 'tracker_id': { 'default': None, + 'required': False, + 'type': 'str'}, + 'translate_ip': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'subnet_static': { 'default': None, + 'elements': 'dict', + 'options': { 'prefix_length': { 'default': None, + 'required': True, + 'type': 'str'}, + 'source_ip_subnet': { 'default': None, + 'required': True, + 'type': 'str'}, + 'static_nat_direction': { 'default': None, + 'required': True, + 'type': 'str'}, + 'tracker_id': { 'default': None, + 'required': False, + 'type': 'str'}, + 'translate_ip_subnet': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'tenant_vpn_id': { 'default': None, + 'required': False, + 'type': 'str'}, + 'vpn_id': { 'default': None, + 'required': False, + 'type': 'str'}, + 'vpn_name': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'dict'}} diff --git a/plugins/module_utils/feature_templates/cisco_vpn_interface.py b/plugins/module_utils/feature_templates/cisco_vpn_interface.py index 94ccaf7..0568658 100644 --- a/plugins/module_utils/feature_templates/cisco_vpn_interface.py +++ b/plugins/module_utils/feature_templates/cisco_vpn_interface.py @@ -1,272 +1,514 @@ -cisco_vpn_interface_definition = { - "cisco_vpn_interface": { - "default": None, - "options": { - "access_list_ipv4": { - "default": None, - "elements": "dict", - "options": { - "acl_name": {"default": None, "required": True, "type": "str"}, - "direction": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "access_list_ipv6": { - "default": None, - "elements": "dict", - "options": { - "acl_name": {"default": None, "required": True, "type": "str"}, - "direction": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "all": {"default": None, "required": False, "type": "str"}, - "arp_timeout": {"default": None, "required": False, "type": "str"}, - "auto_bandwidth_detect": {"default": None, "required": False, "type": "str"}, - "autonegotiate": {"default": None, "required": False, "type": "str"}, - "bandwidth_down": {"default": None, "required": False, "type": "str"}, - "bandwidth_downstream": {"default": None, "required": False, "type": "str"}, - "bandwidth_up": {"default": None, "required": False, "type": "str"}, - "bandwidth_upstream": {"default": None, "required": False, "type": "str"}, - "bgp": {"default": None, "required": False, "type": "str"}, - "bind": {"default": None, "required": False, "type": "str"}, - "block_non_source_ip": {"default": None, "required": False, "type": "str"}, - "border": {"default": None, "required": False, "type": "str"}, - "carrier": {"default": None, "required": False, "type": "str"}, - "clear_dont_fragment": {"default": None, "required": False, "type": "str"}, - "control_connections": {"default": None, "required": False, "type": "str"}, - "core_region": {"default": None, "required": False, "type": "str"}, - "dhcp": {"default": None, "required": False, "type": "str"}, - "dhcp_distance": {"default": None, "required": False, "type": "str"}, - "dhcp_helper": {"default": None, "elements": "str", "required": False, "type": "list"}, - "dhcp_helper_v6": { - "default": None, - "elements": "dict", - "options": { - "address": {"default": None, "required": True, "type": "str"}, - "vpn": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "dhcp_ipv4_client": {"default": None, "required": False, "type": "str"}, - "dhcp_ipv6_client": {"default": None, "required": False, "type": "str"}, - "dmax": {"default": None, "required": False, "type": "str"}, - "dmin": {"default": None, "required": False, "type": "str"}, - "dns": {"default": None, "required": False, "type": "str"}, - "dst_ip": {"default": None, "required": False, "type": "str"}, - "duplex": {"default": None, "required": False, "type": "str"}, - "enable": {"default": None, "required": False, "type": "str"}, - "enable_core_region": {"default": None, "required": False, "type": "str"}, - "enable_sgt_authorization_and_forwarding": {"default": None, "required": False, "type": "str"}, - "enable_sgt_enforcement": {"default": None, "required": False, "type": "str"}, - "enable_sgt_propagation": {"default": None, "required": False, "type": "str"}, - "enforcement_sgt": {"default": None, "required": False, "type": "str"}, - "exclude_controller_group_list": {"default": None, "elements": "str", "required": False, "type": "list"}, - "group": {"default": None, "elements": "str", "required": False, "type": "list"}, - "hello_interval": {"default": None, "required": False, "type": "str"}, - "hello_tolerance": {"default": None, "required": False, "type": "str"}, - "https": {"default": None, "required": False, "type": "str"}, - "icmp": {"default": None, "required": False, "type": "str"}, - "icmp_redirect_disable": {"default": None, "required": False, "type": "str"}, - "if_name": {"default": None, "required": False, "type": "str"}, - "interface_description": {"default": None, "required": False, "type": "str"}, - "intrf_mtu": {"default": None, "required": False, "type": "str"}, - "ip": { - "default": None, - "elements": "dict", - "options": { - "addr": {"default": None, "required": True, "type": "str"}, - "mac": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "ip_directed_broadcast": {"default": None, "required": False, "type": "str"}, - "iperf_server": {"default": None, "required": False, "type": "str"}, - "ipv4_address": {"default": None, "required": False, "type": "str"}, - "ipv6_address": {"default": None, "required": False, "type": "str"}, - "ipv6_vrrp": { - "default": None, - "elements": "dict", - "options": { - "grp_id": {"default": None, "required": True, "type": "str"}, - "ipv6": { - "default": None, - "elements": "dict", - "options": { - "ipv6_link_local": {"default": None, "required": True, "type": "str"}, - "prefix": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "priority": {"default": None, "required": False, "type": "str"}, - "timer": {"default": None, "required": False, "type": "str"}, - "track_omp": {"default": None, "required": False, "type": "bool"}, - "track_prefix_list": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "last_resort_circuit": {"default": None, "required": False, "type": "str"}, - "load_interval": {"default": None, "required": False, "type": "str"}, - "loopback_interface": {"default": None, "required": False, "type": "str"}, - "low_bandwidth_link": {"default": None, "required": False, "type": "str"}, - "mac_address": {"default": None, "required": False, "type": "str"}, - "max_control_connections": {"default": None, "required": False, "type": "str"}, - "media_type": {"default": None, "required": False, "type": "str"}, - "mode": {"default": None, "required": False, "type": "str"}, - "mtu": {"default": None, "required": False, "type": "str"}, - "nat": {"default": None, "required": False, "type": "str"}, - "nat64": {"default": None, "required": False, "type": "str"}, - "nat66": {"default": None, "required": False, "type": "str"}, - "nat_choice": {"default": None, "required": False, "type": "str"}, - "nat_range_end": {"default": None, "required": False, "type": "str"}, - "nat_range_start": {"default": None, "required": False, "type": "str"}, - "nat_refresh_interval": {"default": None, "required": False, "type": "str"}, - "netconf": {"default": None, "required": False, "type": "str"}, - "network_broadcast": {"default": None, "required": False, "type": "str"}, - "ntp": {"default": None, "required": False, "type": "str"}, - "ospf": {"default": None, "required": False, "type": "str"}, - "overload": {"default": None, "required": False, "type": "str"}, - "per_tunnel_qos": {"default": None, "required": False, "type": "str"}, - "per_tunnel_qos_aggregator": {"default": None, "required": False, "type": "str"}, - "period": {"default": None, "required": False, "type": "str"}, - "poe": {"default": None, "required": False, "type": "str"}, - "port_hop": {"default": None, "required": False, "type": "str"}, - "prefix_length": {"default": None, "required": False, "type": "str"}, - "propagate_sgt": {"default": None, "required": False, "type": "str"}, - "qos_adaptive": {"default": None, "required": False, "type": "str"}, - "qos_map": {"default": None, "required": False, "type": "str"}, - "qos_map_vpn": {"default": None, "required": False, "type": "str"}, - "restrict": {"default": None, "required": False, "type": "str"}, - "rule_name": {"default": None, "required": False, "type": "str"}, - "secondary_ipv4_address": { - "default": None, - "elements": "dict", - "options": {"address": {"default": None, "required": False, "type": "str"}}, - "required": False, - "type": "list", - }, - "secondary_ipv6_address": { - "default": None, - "elements": "dict", - "options": {"address": {"default": None, "required": False, "type": "str"}}, - "required": False, - "type": "list", - }, - "secondary_region": {"default": None, "required": False, "type": "str"}, - "security_group_tag": {"default": None, "required": False, "type": "str"}, - "service_provider": {"default": None, "required": False, "type": "str"}, - "shaping_rate": {"default": None, "required": False, "type": "str"}, - "shutdown": {"default": None, "required": False, "type": "str"}, - "snmp": {"default": None, "required": False, "type": "str"}, - "speed": {"default": None, "required": False, "type": "str"}, - "src_ip": {"default": None, "required": False, "type": "str"}, - "sshd": {"default": None, "required": False, "type": "str"}, - "static": { - "default": None, - "elements": "dict", - "options": { - "source_ip": {"default": None, "required": True, "type": "str"}, - "source_vpn": {"default": None, "required": False, "type": "str"}, - "static_nat_direction": {"default": "inside", "required": False, "type": "str"}, - "translate_ip": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "static_nat66": { - "default": None, - "elements": "dict", - "options": { - "source_prefix": {"default": None, "required": True, "type": "str"}, - "source_vpn_id": {"default": None, "required": False, "type": "str"}, - "translated_source_prefix": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "static_port_forward": { - "default": None, - "elements": "dict", - "options": { - "proto": {"default": None, "required": True, "type": "str"}, - "source_ip": {"default": None, "required": True, "type": "str"}, - "source_port": {"default": None, "required": False, "type": "str"}, - "source_vpn": {"default": None, "required": False, "type": "str"}, - "static_nat_direction": {"default": "inside", "required": False, "type": "str"}, - "translate_ip": {"default": None, "required": True, "type": "str"}, - "translate_port": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "stun": {"default": None, "required": False, "type": "str"}, - "tcp_mss_adjust": {"default": None, "required": False, "type": "str"}, - "tcp_timeout": {"default": None, "required": False, "type": "str"}, - "tloc_encapsulation": { - "default": None, - "elements": "dict", - "options": { - "encap": {"default": None, "required": True, "type": "str"}, - "preference": {"default": None, "required": False, "type": "str"}, - "weight": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "tloc_extension": {"default": None, "required": False, "type": "str"}, - "tracker": {"default": None, "elements": "str", "required": False, "type": "list"}, - "trusted": {"default": None, "required": False, "type": "str"}, - "tunnel_tcp_mss_adjust": {"default": None, "required": False, "type": "str"}, - "tunnels_bandwidth": {"default": None, "required": False, "type": "str"}, - "udp_timeout": {"default": None, "required": False, "type": "str"}, - "umax": {"default": None, "required": False, "type": "str"}, - "umin": {"default": None, "required": False, "type": "str"}, - "value": {"default": None, "required": False, "type": "str"}, - "vbond_as_stun_server": {"default": None, "required": False, "type": "str"}, - "vmanage_connection_preference": {"default": None, "required": False, "type": "str"}, - "vrrp": { - "default": None, - "elements": "dict", - "options": { - "address": {"default": None, "required": False, "type": "str"}, - "grp_id": {"default": None, "required": True, "type": "str"}, - "ipv4_secondary": { - "default": None, - "elements": "dict", - "options": {"address": {"default": None, "required": True, "type": "str"}}, - "required": False, - "type": "list", - }, - "priority": {"default": None, "required": False, "type": "str"}, - "timer": {"default": None, "required": False, "type": "str"}, - "tloc_change_pref": {"default": None, "required": False, "type": "bool"}, - "track_omp": {"default": None, "required": False, "type": "bool"}, - "track_prefix_list": {"default": None, "required": False, "type": "str"}, - "tracking_object": { - "default": None, - "elements": "dict", - "options": { - "decrement": {"default": None, "required": True, "type": "str"}, - "name": {"default": None, "required": True, "type": "str"}, - "track_action": {"default": "Decrement", "required": False, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "value": {"default": None, "required": True, "type": "str"}, - }, - "required": False, - "type": "list", - }, - "xconnect": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "dict", - } -} +cisco_vpn_interface_definition = { 'cisco_vpn_interface': { 'default': None, + 'options': { 'access_list_ipv4': { 'default': None, + 'elements': 'dict', + 'options': { 'acl_name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'direction': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'access_list_ipv6': { 'default': None, + 'elements': 'dict', + 'options': { 'acl_name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'direction': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'all': { 'default': None, + 'required': False, + 'type': 'str'}, + 'arp_timeout': { 'default': None, + 'required': False, + 'type': 'str'}, + 'auto_bandwidth_detect': { 'default': None, + 'required': False, + 'type': 'str'}, + 'autonegotiate': { 'default': None, + 'required': False, + 'type': 'str'}, + 'bandwidth_down': { 'default': None, + 'required': False, + 'type': 'str'}, + 'bandwidth_downstream': { 'default': None, + 'required': False, + 'type': 'str'}, + 'bandwidth_up': { 'default': None, + 'required': False, + 'type': 'str'}, + 'bandwidth_upstream': { 'default': None, + 'required': False, + 'type': 'str'}, + 'bgp': { 'default': None, + 'required': False, + 'type': 'str'}, + 'bind': { 'default': None, + 'required': False, + 'type': 'str'}, + 'block_non_source_ip': { 'default': None, + 'required': False, + 'type': 'str'}, + 'border': { 'default': None, + 'required': False, + 'type': 'str'}, + 'carrier': { 'default': None, + 'required': False, + 'type': 'str'}, + 'clear_dont_fragment': { 'default': None, + 'required': False, + 'type': 'str'}, + 'control_connections': { 'default': None, + 'required': False, + 'type': 'str'}, + 'core_region': { 'default': None, + 'required': False, + 'type': 'str'}, + 'dhcp': { 'default': None, + 'required': False, + 'type': 'str'}, + 'dhcp_distance': { 'default': None, + 'required': False, + 'type': 'str'}, + 'dhcp_helper': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'dhcp_helper_v6': { 'default': None, + 'elements': 'dict', + 'options': { 'address': { 'default': None, + 'required': True, + 'type': 'str'}, + 'vpn': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'dhcp_ipv4_client': { 'default': None, + 'required': False, + 'type': 'str'}, + 'dhcp_ipv6_client': { 'default': None, + 'required': False, + 'type': 'str'}, + 'dmax': { 'default': None, + 'required': False, + 'type': 'str'}, + 'dmin': { 'default': None, + 'required': False, + 'type': 'str'}, + 'dns': { 'default': None, + 'required': False, + 'type': 'str'}, + 'dst_ip': { 'default': None, + 'required': False, + 'type': 'str'}, + 'duplex': { 'default': None, + 'required': False, + 'type': 'str'}, + 'enable': { 'default': None, + 'required': False, + 'type': 'str'}, + 'enable_core_region': { 'default': None, + 'required': False, + 'type': 'str'}, + 'enable_sgt_authorization_and_forwarding': { 'default': None, + 'required': False, + 'type': 'str'}, + 'enable_sgt_enforcement': { 'default': None, + 'required': False, + 'type': 'str'}, + 'enable_sgt_propagation': { 'default': None, + 'required': False, + 'type': 'str'}, + 'enforcement_sgt': { 'default': None, + 'required': False, + 'type': 'str'}, + 'exclude_controller_group_list': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'group': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'hello_interval': { 'default': None, + 'required': False, + 'type': 'str'}, + 'hello_tolerance': { 'default': None, + 'required': False, + 'type': 'str'}, + 'https': { 'default': None, + 'required': False, + 'type': 'str'}, + 'icmp': { 'default': None, + 'required': False, + 'type': 'str'}, + 'icmp_redirect_disable': { 'default': None, + 'required': False, + 'type': 'str'}, + 'if_name': { 'default': None, + 'required': False, + 'type': 'str'}, + 'interface_description': { 'default': None, + 'required': False, + 'type': 'str'}, + 'intrf_mtu': { 'default': None, + 'required': False, + 'type': 'str'}, + 'ip': { 'default': None, + 'elements': 'dict', + 'options': { 'addr': { 'default': None, + 'required': True, + 'type': 'str'}, + 'mac': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'ip_directed_broadcast': { 'default': None, + 'required': False, + 'type': 'str'}, + 'iperf_server': { 'default': None, + 'required': False, + 'type': 'str'}, + 'ipv4_address': { 'default': None, + 'required': False, + 'type': 'str'}, + 'ipv6_address': { 'default': None, + 'required': False, + 'type': 'str'}, + 'ipv6_vrrp': { 'default': None, + 'elements': 'dict', + 'options': { 'grp_id': { 'default': None, + 'required': True, + 'type': 'str'}, + 'ipv6': { 'default': None, + 'elements': 'dict', + 'options': { 'ipv6_link_local': { 'default': None, + 'required': True, + 'type': 'str'}, + 'prefix': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'priority': { 'default': None, + 'required': False, + 'type': 'str'}, + 'timer': { 'default': None, + 'required': False, + 'type': 'str'}, + 'track_omp': { 'default': None, + 'required': False, + 'type': 'bool'}, + 'track_prefix_list': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'last_resort_circuit': { 'default': None, + 'required': False, + 'type': 'str'}, + 'load_interval': { 'default': None, + 'required': False, + 'type': 'str'}, + 'loopback_interface': { 'default': None, + 'required': False, + 'type': 'str'}, + 'low_bandwidth_link': { 'default': None, + 'required': False, + 'type': 'str'}, + 'mac_address': { 'default': None, + 'required': False, + 'type': 'str'}, + 'max_control_connections': { 'default': None, + 'required': False, + 'type': 'str'}, + 'media_type': { 'default': None, + 'required': False, + 'type': 'str'}, + 'mode': { 'default': None, + 'required': False, + 'type': 'str'}, + 'mtu': { 'default': None, + 'required': False, + 'type': 'str'}, + 'nat': { 'default': None, + 'required': False, + 'type': 'str'}, + 'nat64': { 'default': None, + 'required': False, + 'type': 'str'}, + 'nat66': { 'default': None, + 'required': False, + 'type': 'str'}, + 'nat_choice': { 'default': None, + 'required': False, + 'type': 'str'}, + 'nat_range_end': { 'default': None, + 'required': False, + 'type': 'str'}, + 'nat_range_start': { 'default': None, + 'required': False, + 'type': 'str'}, + 'nat_refresh_interval': { 'default': None, + 'required': False, + 'type': 'str'}, + 'netconf': { 'default': None, + 'required': False, + 'type': 'str'}, + 'network_broadcast': { 'default': None, + 'required': False, + 'type': 'str'}, + 'ntp': { 'default': None, + 'required': False, + 'type': 'str'}, + 'ospf': { 'default': None, + 'required': False, + 'type': 'str'}, + 'overload': { 'default': None, + 'required': False, + 'type': 'str'}, + 'per_tunnel_qos': { 'default': None, + 'required': False, + 'type': 'str'}, + 'per_tunnel_qos_aggregator': { 'default': None, + 'required': False, + 'type': 'str'}, + 'period': { 'default': None, + 'required': False, + 'type': 'str'}, + 'poe': { 'default': None, + 'required': False, + 'type': 'str'}, + 'port_hop': { 'default': None, + 'required': False, + 'type': 'str'}, + 'prefix_length': { 'default': None, + 'required': False, + 'type': 'str'}, + 'propagate_sgt': { 'default': None, + 'required': False, + 'type': 'str'}, + 'qos_adaptive': { 'default': None, + 'required': False, + 'type': 'str'}, + 'qos_map': { 'default': None, + 'required': False, + 'type': 'str'}, + 'qos_map_vpn': { 'default': None, + 'required': False, + 'type': 'str'}, + 'restrict': { 'default': None, + 'required': False, + 'type': 'str'}, + 'rule_name': { 'default': None, + 'required': False, + 'type': 'str'}, + 'secondary_ipv4_address': { 'default': None, + 'elements': 'dict', + 'options': { 'address': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'secondary_ipv6_address': { 'default': None, + 'elements': 'dict', + 'options': { 'address': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'secondary_region': { 'default': None, + 'required': False, + 'type': 'str'}, + 'security_group_tag': { 'default': None, + 'required': False, + 'type': 'str'}, + 'service_provider': { 'default': None, + 'required': False, + 'type': 'str'}, + 'shaping_rate': { 'default': None, + 'required': False, + 'type': 'str'}, + 'shutdown': { 'default': None, + 'required': False, + 'type': 'str'}, + 'snmp': { 'default': None, + 'required': False, + 'type': 'str'}, + 'speed': { 'default': None, + 'required': False, + 'type': 'str'}, + 'src_ip': { 'default': None, + 'required': False, + 'type': 'str'}, + 'sshd': { 'default': None, + 'required': False, + 'type': 'str'}, + 'static': { 'default': None, + 'elements': 'dict', + 'options': { 'source_ip': { 'default': None, + 'required': True, + 'type': 'str'}, + 'source_vpn': { 'default': None, + 'required': False, + 'type': 'str'}, + 'static_nat_direction': { 'default': 'inside', + 'required': False, + 'type': 'str'}, + 'translate_ip': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'static_nat66': { 'default': None, + 'elements': 'dict', + 'options': { 'source_prefix': { 'default': None, + 'required': True, + 'type': 'str'}, + 'source_vpn_id': { 'default': None, + 'required': False, + 'type': 'str'}, + 'translated_source_prefix': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'static_port_forward': { 'default': None, + 'elements': 'dict', + 'options': { 'proto': { 'default': None, + 'required': True, + 'type': 'str'}, + 'source_ip': { 'default': None, + 'required': True, + 'type': 'str'}, + 'source_port': { 'default': None, + 'required': False, + 'type': 'str'}, + 'source_vpn': { 'default': None, + 'required': False, + 'type': 'str'}, + 'static_nat_direction': { 'default': 'inside', + 'required': False, + 'type': 'str'}, + 'translate_ip': { 'default': None, + 'required': True, + 'type': 'str'}, + 'translate_port': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'stun': { 'default': None, + 'required': False, + 'type': 'str'}, + 'tcp_mss_adjust': { 'default': None, + 'required': False, + 'type': 'str'}, + 'tcp_timeout': { 'default': None, + 'required': False, + 'type': 'str'}, + 'tloc_encapsulation': { 'default': None, + 'elements': 'dict', + 'options': { 'encap': { 'default': None, + 'required': True, + 'type': 'str'}, + 'preference': { 'default': None, + 'required': False, + 'type': 'str'}, + 'weight': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'tloc_extension': { 'default': None, + 'required': False, + 'type': 'str'}, + 'tracker': { 'default': None, + 'elements': 'str', + 'required': False, + 'type': 'list'}, + 'trusted': { 'default': None, + 'required': False, + 'type': 'str'}, + 'tunnel_tcp_mss_adjust': { 'default': None, + 'required': False, + 'type': 'str'}, + 'tunnels_bandwidth': { 'default': None, + 'required': False, + 'type': 'str'}, + 'udp_timeout': { 'default': None, + 'required': False, + 'type': 'str'}, + 'umax': { 'default': None, + 'required': False, + 'type': 'str'}, + 'umin': { 'default': None, + 'required': False, + 'type': 'str'}, + 'value': { 'default': None, + 'required': False, + 'type': 'str'}, + 'vbond_as_stun_server': { 'default': None, + 'required': False, + 'type': 'str'}, + 'vmanage_connection_preference': { 'default': None, + 'required': False, + 'type': 'str'}, + 'vrrp': { 'default': None, + 'elements': 'dict', + 'options': { 'address': { 'default': None, + 'required': False, + 'type': 'str'}, + 'grp_id': { 'default': None, + 'required': True, + 'type': 'str'}, + 'ipv4_secondary': { 'default': None, + 'elements': 'dict', + 'options': { 'address': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'priority': { 'default': None, + 'required': False, + 'type': 'str'}, + 'timer': { 'default': None, + 'required': False, + 'type': 'str'}, + 'tloc_change_pref': { 'default': None, + 'required': False, + 'type': 'bool'}, + 'track_omp': { 'default': None, + 'required': False, + 'type': 'bool'}, + 'track_prefix_list': { 'default': None, + 'required': False, + 'type': 'str'}, + 'tracking_object': { 'default': None, + 'elements': 'dict', + 'options': { 'decrement': { 'default': None, + 'required': True, + 'type': 'str'}, + 'name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'track_action': { 'default': 'Decrement', + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'value': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'xconnect': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'dict'}} diff --git a/plugins/module_utils/feature_templates/omp_vsmart.py b/plugins/module_utils/feature_templates/omp_vsmart.py index 98c2061..ee29739 100644 --- a/plugins/module_utils/feature_templates/omp_vsmart.py +++ b/plugins/module_utils/feature_templates/omp_vsmart.py @@ -1,19 +1,33 @@ -omp_vsmart_definition = { - "omp_vsmart": { - "default": None, - "options": { - "advertisement_interval": {"default": None, "required": False, "type": "str"}, - "affinity_group_preference": {"default": None, "required": False, "type": "str"}, - "discard_rejected": {"default": None, "required": False, "type": "str"}, - "eor_timer": {"default": None, "required": False, "type": "str"}, - "graceful_restart": {"default": None, "required": False, "type": "str"}, - "graceful_restart_timer": {"default": None, "required": False, "type": "str"}, - "holdtime": {"default": None, "required": False, "type": "str"}, - "send_backup_paths": {"default": None, "required": False, "type": "str"}, - "send_path_limit": {"default": None, "required": False, "type": "str"}, - "shutdown": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "dict", - } -} +omp_vsmart_definition = { 'omp_vsmart': { 'default': None, + 'options': { 'advertisement_interval': { 'default': None, + 'required': False, + 'type': 'str'}, + 'affinity_group_preference': { 'default': None, + 'required': False, + 'type': 'str'}, + 'discard_rejected': { 'default': None, + 'required': False, + 'type': 'str'}, + 'eor_timer': { 'default': None, + 'required': False, + 'type': 'str'}, + 'graceful_restart': { 'default': None, + 'required': False, + 'type': 'str'}, + 'graceful_restart_timer': { 'default': None, + 'required': False, + 'type': 'str'}, + 'holdtime': { 'default': None, + 'required': False, + 'type': 'str'}, + 'send_backup_paths': { 'default': None, + 'required': False, + 'type': 'str'}, + 'send_path_limit': { 'default': None, + 'required': False, + 'type': 'str'}, + 'shutdown': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'dict'}} diff --git a/plugins/module_utils/feature_templates/security_vsmart.py b/plugins/module_utils/feature_templates/security_vsmart.py index b6af55d..2d9b9b1 100644 --- a/plugins/module_utils/feature_templates/security_vsmart.py +++ b/plugins/module_utils/feature_templates/security_vsmart.py @@ -1,11 +1,9 @@ -security_vsmart_definition = { - "security_vsmart": { - "default": None, - "options": { - "protocol": {"default": None, "required": False, "type": "str"}, - "tls_port": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "dict", - } -} +security_vsmart_definition = { 'security_vsmart': { 'default': None, + 'options': { 'protocol': { 'default': None, + 'required': False, + 'type': 'str'}, + 'tls_port': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'dict'}} diff --git a/plugins/module_utils/feature_templates/system_vsmart.py b/plugins/module_utils/feature_templates/system_vsmart.py index 5cf4abc..a761824 100644 --- a/plugins/module_utils/feature_templates/system_vsmart.py +++ b/plugins/module_utils/feature_templates/system_vsmart.py @@ -1,29 +1,63 @@ -system_vsmart_definition = { - "system_vsmart": { - "default": None, - "options": { - "admin_tech_on_failure": {"default": None, "required": False, "type": "str"}, - "control_session_pps": {"default": None, "required": False, "type": "str"}, - "controller_group_id": {"default": None, "required": False, "type": "str"}, - "device_groups": {"default": None, "required": False, "type": "str"}, - "dns_cache_timeout": {"default": None, "required": False, "type": "str"}, - "host_name": {"default": None, "required": False, "type": "str"}, - "idle_timeout": {"default": None, "required": False, "type": "str"}, - "iptables_enable": {"default": None, "required": False, "type": "str"}, - "latitude": {"default": None, "required": False, "type": "str"}, - "location": {"default": None, "required": False, "type": "str"}, - "longitude": {"default": None, "required": False, "type": "str"}, - "overlay_id": {"default": None, "required": False, "type": "str"}, - "port_hop": {"default": None, "required": False, "type": "str"}, - "port_offset": {"default": None, "required": False, "type": "str"}, - "site_id": {"default": None, "required": False, "type": "str"}, - "system_ip": {"default": None, "required": False, "type": "str"}, - "system_tunnel_mtu": {"default": None, "required": False, "type": "str"}, - "timezone": {"default": None, "required": False, "type": "str"}, - "track_default_gateway": {"default": None, "required": False, "type": "str"}, - "track_transport": {"default": None, "required": False, "type": "str"}, - }, - "required": False, - "type": "dict", - } -} +system_vsmart_definition = { 'system_vsmart': { 'default': None, + 'options': { 'admin_tech_on_failure': { 'default': None, + 'required': False, + 'type': 'str'}, + 'control_session_pps': { 'default': None, + 'required': False, + 'type': 'str'}, + 'controller_group_id': { 'default': None, + 'required': False, + 'type': 'str'}, + 'device_groups': { 'default': None, + 'required': False, + 'type': 'str'}, + 'dns_cache_timeout': { 'default': None, + 'required': False, + 'type': 'str'}, + 'host_name': { 'default': None, + 'required': False, + 'type': 'str'}, + 'idle_timeout': { 'default': None, + 'required': False, + 'type': 'str'}, + 'iptables_enable': { 'default': None, + 'required': False, + 'type': 'str'}, + 'latitude': { 'default': None, + 'required': False, + 'type': 'str'}, + 'location': { 'default': None, + 'required': False, + 'type': 'str'}, + 'longitude': { 'default': None, + 'required': False, + 'type': 'str'}, + 'overlay_id': { 'default': None, + 'required': False, + 'type': 'str'}, + 'port_hop': { 'default': None, + 'required': False, + 'type': 'str'}, + 'port_offset': { 'default': None, + 'required': False, + 'type': 'str'}, + 'site_id': { 'default': None, + 'required': False, + 'type': 'str'}, + 'system_ip': { 'default': None, + 'required': False, + 'type': 'str'}, + 'system_tunnel_mtu': { 'default': None, + 'required': False, + 'type': 'str'}, + 'timezone': { 'default': None, + 'required': False, + 'type': 'str'}, + 'track_default_gateway': { 'default': None, + 'required': False, + 'type': 'str'}, + 'track_transport': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'dict'}} diff --git a/plugins/modules/feature_templates.py b/plugins/modules/feature_templates.py index 90ce23d..b7e6af1 100644 --- a/plugins/modules/feature_templates.py +++ b/plugins/modules/feature_templates.py @@ -46,6 +46,8 @@ - cisco.catalystwan.feature_template_cisco_bfd - cisco.catalystwan.feature_template_cisco_logging - cisco.catalystwan.feature_template_cisco_ntp + - cisco.catalystwan.feature_template_cisco_omp + - cisco.catalystwan.feature_template_cisco_ospf - cisco.catalystwan.device_models_feature_template - cisco.catalystwan.manager_authentication author: @@ -61,6 +63,7 @@ from catalystwan.dataclasses import FeatureTemplateInfo from catalystwan.typed_list import DataSequence from catalystwan.utils.device_model import DeviceModel +from catalystwan.session import ManagerHTTPError from catalystwan.api.templates.models.supported import available_models from ..module_utils.result import ModuleResult @@ -70,7 +73,8 @@ from ..module_utils.feature_templates.cisco_bfd import cisco_bfd_definition from ..module_utils.feature_templates.cisco_logging import cisco_logging_definition from ..module_utils.feature_templates.cisco_ntp import cisco_ntp_definition - +from ..module_utils.feature_templates.cisco_omp import cisco_omp_definition +from ..module_utils.feature_templates.cisco_ospf import cisco_ospf_definition class ExtendedModuleResult(ModuleResult): templates_info: Optional[Dict] = Field(default={}) @@ -91,7 +95,7 @@ def run_module(): ), template_name=dict(type="str", required=True), template_description=dict(type="str", default=None), - device_models=dict(type="list", choices=[device_model.value for device_model in DeviceModel]), + device_models=dict(type="list", choices=[device_model.value for device_model in DeviceModel], default=[]), debug=dict(type="bool", default=False), device=dict(type="str", default=None), # For this we need to think how to pass devices **cisco_aaa_definition, @@ -99,6 +103,8 @@ def run_module(): **cisco_bfd_definition, **cisco_logging_definition, **cisco_ntp_definition, + **cisco_omp_definition, + **cisco_ospf_definition, ) result = ExtendedModuleResult() @@ -138,7 +144,7 @@ def run_module(): all_templates: DataSequence[FeatureTemplateInfo] = module.get_response_safely( module.session.api.templates.get, template=FeatureTemplate ) - target_template = all_templates.filter(name=template_name) + target_template: FeatureTemplateInfo = all_templates.filter(name=template_name) # Code for checking if template name exists already # if yes, do we need some force method or we just inform user and exit? @@ -146,7 +152,7 @@ def run_module(): if target_template: module.logger.debug(f"Detected existing template:\n{target_template}\n") result.msg = ( - f"Template with name {template_name} already present on vManage," "skipping create template operation." + f"Template with name {template_name} already present on vManage, skipping create template operation." ) else: for model_name, model_module in available_models.items(): @@ -163,8 +169,12 @@ def run_module(): module.logger.debug( f"Prepared template for sending to vManage, template configuration:\n{template}\n" ) - - module.session.api.templates.create(template=template, debug=module.params.get("debug")) + try: + module.session.api.templates.create(template=template, debug=module.params.get("debug")) + except ManagerHTTPError as ex: + module.fail_json( + msg=f"Could not perform create Feature Template {template_name}.\nManager error: {ex.info}" + ) result.changed = True result.msg += f"Created template {model_name}: {template}" diff --git a/plugins/modules/feature_templates_info.py b/plugins/modules/feature_templates_info.py index 4c262a4..f957b38 100644 --- a/plugins/modules/feature_templates_info.py +++ b/plugins/modules/feature_templates_info.py @@ -17,6 +17,12 @@ - A dictionary of filters used to select devices for module action. type: dict required: false + # suboptions: + # description: + # - The login banner text displayed before authentication + # required: false + # default: null + # type: str author: - Arkadiusz Cichon (acichon@cisco.com) extends_documentation_fragment: diff --git a/utils/ft_docs_template.j2 b/utils/docs_fragments_template.j2 similarity index 100% rename from utils/ft_docs_template.j2 rename to utils/docs_fragments_template.j2 diff --git a/utils/ft_device_model.j2 b/utils/ft_device_model.j2 index f793e31..88c4b48 100644 --- a/utils/ft_device_model.j2 +++ b/utils/ft_device_model.j2 @@ -9,13 +9,13 @@ from __future__ import annotations + class ModuleDocFragment(object): DOCUMENTATION = r''' options: device_models: description: - Defines the SD-WAN device type for template application. - required: true type: list default: [] elements: str diff --git a/utils/ft_generator.py b/utils/ft_generator.py index e83cff3..97e9b35 100644 --- a/utils/ft_generator.py +++ b/utils/ft_generator.py @@ -34,7 +34,7 @@ def is_pydantic_model(type_): def field_to_ansible_option(field: FieldInfo): # # if field.description == "List of public keys for the user": - # if field.description == "The identifier for the authentication key": + # if field.description == "A list of site types that are allowed to participate in the overlay network.": # from IPython import embed; embed() option = { "description": [field.description], @@ -78,9 +78,14 @@ def field_to_ansible_option(field: FieldInfo): option["type"] = "list" option["elements"] = "dict" option["suboptions"] = model_to_ansible_options(user_class) + elif safe_issubclass(user_class, Enum): + option["type"] = "list" + option["elements"] = "str" + option["choices"] = [item.value for item in user_class] else: option["type"] = "list" option["elements"] = "str" + elif is_pydantic_model(field_type): option["type"] = "dict" option["suboptions"] = model_to_ansible_options(field_type) @@ -174,7 +179,7 @@ def to_nice_yaml(data): env = Environment(loader=FileSystemLoader(template_dir), trim_blocks=True, lstrip_blocks=True) env.filters["to_nice_yaml"] = to_nice_yaml - template_file = PurePath("ft_docs_template.j2") + template_file = PurePath("docs_fragments_template.j2") template = env.get_template(str(template_file)) output = template.render(yaml_data=ansible_docs) From beb85f94a89cfd3e861598138712ed6cd0abbec4 Mon Sep 17 00:00:00 2001 From: acichon Date: Fri, 26 Apr 2024 17:27:37 +0200 Subject: [PATCH 05/18] incude playbook to test feature tempalte creation --- playbooks/tests/test_feature_templates.yml | 251 ++++++++++++++++++ .../feature_template_cisco_omp.py | 8 + .../feature_template_cisco_system.py | 8 + .../feature_template_cisco_vpn.py | 4 + 4 files changed, 271 insertions(+) create mode 100644 playbooks/tests/test_feature_templates.yml diff --git a/playbooks/tests/test_feature_templates.yml b/playbooks/tests/test_feature_templates.yml new file mode 100644 index 0000000..6a33807 --- /dev/null +++ b/playbooks/tests/test_feature_templates.yml @@ -0,0 +1,251 @@ +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +--- + +# Helper playbooks to test modules and flows while developing them + +# Tested operations: + +# --- Feature Templates creation --- # + + +- name: Testing playbook to verify cisco.catalystwan.feature_template module operations + hosts: localhost + gather_facts: false + vars_files: + - configuration_file_dev_vars.yml + vars: + manager_authentication: &manager_authentication + url: "{{ (vmanage_instances | first).mgmt_public_ip }}" + username: "{{ (vmanage_instances | first).admin_username }}" + password: "{{ (vmanage_instances | first).admin_password }}" + tasks: + - name: Get all Non-Default Feature Templates available + cisco.catalystwan.feature_templates_info: + filters: + factory_default: false + manager_credentials: + <<: *manager_authentication + register: feature_templates + + - name: Delete all Non-Default Feature templates + cisco.catalystwan.feature_templates: + state: absent + template_name: "{{ template.templateName }}" + manager_credentials: + <<: *manager_authentication + loop: "{{ feature_templates.templates_info | default([], true)}}" + loop_control: + loop_var: template + label: "template: {{ template.templateName }}" + + - name: Create Comprehensive AAA Template with TACACS+ and RADIUS + cisco.catalystwan.feature_templates: + state: present + template_name: "ComprehensiveAAATemplate" + template_description: "AAA Template with both TACACS+ and RADIUS servers" + device_models: + - vmanage + cisco_aaa: + user: + - name: "local_admin" + password: "admin_password" + privilege: "15" + tacacs: + - group_name: "TACACSGroup1" + vpn: "0" + source_interface: "GigabitEthernet0/1" + server: + - address: "192.168.2.10" + port: "49" + timeout: "5" + key: "tacacs_key" + radius: + - group_name: "RADIUSGroup1" + vpn: "0" + source_interface: "GigabitEthernet0/0" + server: + - address: "192.168.1.10" + auth_port: "1812" + acct_port: "1813" + timeout: "5" + retransmit: "3" + key: "radius_key" + secret_key: "secret" + server_auth_order: + - "local" + - "RADIUSGroup1" + - "TACACSGroup1" + authentication_group: true + accounting_group: true + domain_stripping: 'yes' + manager_credentials: + <<: *manager_authentication + + - name: Create Cisco Banner Feature Template + cisco.catalystwan.feature_templates: + state: present + template_name: "CiscoBannerConfigTemplate" + template_description: "Banner configuration for login and MOTD" + device_models: + - "vedge-C8000V" + cisco_banner: + login_banner: | + **************************************************************** + * Unauthorized access to this device is prohibited. * + * You must have explicit permission to access or configure this * + * device. All activities performed on this device are logged and * + * violations of this policy may result in disciplinary action, * + * and may be reported to law enforcement. There is no right to * + * privacy on this device. Use of this system constitutes consent * + * to monitoring for these purposes. * + **************************************************************** + motd_banner: | + **************************************************************** + * Welcome to Company XYZ Network! * + * All connections are monitored and recorded for audit purposes. * + * Disconnect IMMEDIATELY if you are not an authorized user! * + **************************************************************** + manager_credentials: + <<: *manager_authentication + + - name: Create Cisco BFD Feature Template + cisco.catalystwan.feature_templates: + state: present + template_name: "CiscoBFDFeatureTemplate" + template_description: "Comprehensive BFD configuration" + device_models: + - "vedge-C8000V" + cisco_bfd: + multiplier: "3" + poll_interval: "500" + default_dscp: "46" + color: + - color: "mpls" + hello_interval: "50" + multiplier: "3" + pmtu_discovery: "yes" + dscp: "48" + - color: "biz-internet" + hello_interval: "100" + multiplier: "4" + pmtu_discovery: "no" + dscp: "46" + - color: "private1" + hello_interval: "150" + multiplier: "5" + pmtu_discovery: "yes" + dscp: "44" + manager_credentials: + <<: *manager_authentication + + - name: Configure Cisco Logging Feature Template + cisco.catalystwan.feature_templates: + state: present + template_name: "CiscoLoggingFeatureTemplate" + template_description: "Comprehensive Logging Configuration" + device_models: + - "vedge-C8000V" + cisco_logging: + enable: "yes" + size: "10240" + rotate: "5" + tls_profile: + - profile: "StrictTLSProfile" + version: "TLSv1.2" + auth_type: "Mutual" + ciphersuite_list: + - "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" + - "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" + server: + - name: "LogServer1" + vpn: "10" + source_interface: "GigabitEthernet0/0/0" + priority: "information" + enable_tls: "yes" + custom_profile: "yes" + profile: "StrictTLSProfile" + ipv6_server: + - name: "LogServerIPv6_1" + vpn: "10" + source_interface: "GigabitEthernet0/0/0" + priority: "error" + enable_tls: "yes" + custom_profile: "yes" + profile: "StrictTLSProfile" + manager_credentials: + <<: *manager_authentication + + - name: Configure Cisco NTP Feature Template + cisco.catalystwan.feature_templates: + state: present + template_name: "CiscoNTPFeatureTemplate" + template_description: "Comprehensive NTP Configuration" + device_models: + - "vmanage" + cisco_ntp: + server: + - name: "0.pool.ntp.org" + key: "10" + vpn: "1" + version: "4" + source_interface: "GigabitEthernet0/0/0" + prefer: "yes" + - name: "1.pool.ntp.org" + key: "20" + vpn: "1" + version: "4" + source_interface: "GigabitEthernet0/0/1" + authentication: + - number: "10" + md5: "44b9d6ee8faafed3" + - number: "20" + md5: "f7a1a7e81e4567d9" + trusted: + - "10" + - "20" + enable: "yes" + stratum: "2" + source: "Loopback0" + manager_credentials: + <<: *manager_authentication + + - name: Configure Cisco OMP Feature Template + cisco.catalystwan.feature_templates: + state: present + template_name: "CiscoOMPFeatureTemplate" + template_description: "Comprehensive OMP Configuration" + device_models: + - "vmanage" + cisco_omp: + graceful_restart: true + overlay_as: "65530" + send_path_limit: "5" + ecmp_limit: "2" + shutdown: false + omp_admin_distance_ipv4: "130" + omp_admin_distance_ipv6: "130" + advertisement_interval: "30" + graceful_restart_timer: "120" + eor_timer: "300" + holdtime: "180" + advertise: + - protocol: "bgp" + route: "external" + - protocol: "ospf" + - protocol: "static" + ipv6_advertise: + - protocol: "bgp" + - protocol: "ospf" + - protocol: "connected" + ignore_region_path_length: "true" + transport_gateway: "prefer" + site_types: + - "type-1" + - "type-2" + - "branch" + auto_translate: true + manager_credentials: + <<: *manager_authentication + diff --git a/plugins/doc_fragments/feature_template_cisco_omp.py b/plugins/doc_fragments/feature_template_cisco_omp.py index 92c4638..827ed95 100644 --- a/plugins/doc_fragments/feature_template_cisco_omp.py +++ b/plugins/doc_fragments/feature_template_cisco_omp.py @@ -163,6 +163,14 @@ class ModuleDocFragment(object): default: null type: list elements: str + choices: + - type-1 + - type-2 + - type-3 + - cloud + - branch + - br + - spoke auto_translate: description: - Enable or disable automatic translation of network settings. diff --git a/plugins/doc_fragments/feature_template_cisco_system.py b/plugins/doc_fragments/feature_template_cisco_system.py index f0cadb9..acf3b61 100644 --- a/plugins/doc_fragments/feature_template_cisco_system.py +++ b/plugins/doc_fragments/feature_template_cisco_system.py @@ -550,6 +550,14 @@ class ModuleDocFragment(object): default: null type: list elements: str + choices: + - type-1 + - type-2 + - type-3 + - cloud + - branch + - br + - spoke port_offset: description: - The port offset for the device. diff --git a/plugins/doc_fragments/feature_template_cisco_vpn.py b/plugins/doc_fragments/feature_template_cisco_vpn.py index 91d98cf..3c4f78e 100644 --- a/plugins/doc_fragments/feature_template_cisco_vpn.py +++ b/plugins/doc_fragments/feature_template_cisco_vpn.py @@ -447,6 +447,8 @@ class ModuleDocFragment(object): default: null type: list elements: str + choices: + - external prefix_list: description: - A list of prefix lists associated with the advertisement @@ -513,6 +515,8 @@ class ModuleDocFragment(object): default: null type: list elements: str + choices: + - external prefix_list: description: - A list of IPv6 prefix lists associated with the advertisement From 1d4c16da6cc12ab5c1d3f87cd738065ce66d4986 Mon Sep 17 00:00:00 2001 From: acichon Date: Mon, 29 Apr 2024 09:44:14 +0200 Subject: [PATCH 06/18] next batch of tests for templates --- playbooks/tests/test_feature_templates.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/playbooks/tests/test_feature_templates.yml b/playbooks/tests/test_feature_templates.yml index 6a33807..ffce744 100644 --- a/playbooks/tests/test_feature_templates.yml +++ b/playbooks/tests/test_feature_templates.yml @@ -35,7 +35,7 @@ template_name: "{{ template.templateName }}" manager_credentials: <<: *manager_authentication - loop: "{{ feature_templates.templates_info | default([], true)}}" + loop: "{{ feature_templates.templates_info | default([], true) }}" loop_control: loop_var: template label: "template: {{ template.templateName }}" @@ -219,11 +219,11 @@ device_models: - "vmanage" cisco_omp: - graceful_restart: true + graceful_restart: "enabled" overlay_as: "65530" send_path_limit: "5" ecmp_limit: "2" - shutdown: false + shutdown: "enabled" # TODO omp_admin_distance_ipv4: "130" omp_admin_distance_ipv6: "130" advertisement_interval: "30" @@ -245,7 +245,6 @@ - "type-1" - "type-2" - "branch" - auto_translate: true + auto_translate: "enabled" manager_credentials: <<: *manager_authentication - From e0215075f696e31d9542669c53574a746371f5ad Mon Sep 17 00:00:00 2001 From: acichon Date: Mon, 6 May 2024 19:05:56 +0200 Subject: [PATCH 07/18] next batch of templates --- playbooks/tests/test_feature_templates.yml | 583 ++++++++++++------ .../feature_template_cisco_aaa.py | 236 ++++++- .../feature_template_cisco_bfd.py | 4 +- .../feature_template_cisco_logging.py | 18 +- .../feature_template_cisco_ntp.py | 6 +- .../feature_template_cisco_omp.py | 14 +- .../feature_template_cisco_ospf.py | 28 +- ..._template_cisco_secure_internet_gateway.py | 18 +- .../feature_template_cisco_snmp.py | 30 +- .../feature_template_cisco_system.py | 44 +- .../feature_template_cisco_vpn.py | 18 +- .../feature_template_cisco_vpn_interface.py | 120 ++-- .../feature_template_omp_vsmart.py | 10 +- .../feature_templates/cisco_aaa.py | 106 +++- .../feature_templates/cisco_bfd.py | 4 +- .../feature_templates/cisco_logging.py | 18 +- .../feature_templates/cisco_ntp.py | 6 +- .../feature_templates/cisco_omp.py | 14 +- .../feature_templates/cisco_ospf.py | 28 +- .../cisco_secure_internet_gateway.py | 18 +- .../feature_templates/cisco_snmp.py | 30 +- .../feature_templates/cisco_system.py | 44 +- .../feature_templates/cisco_vpn.py | 18 +- .../feature_templates/cisco_vpn_interface.py | 120 ++-- .../feature_templates/omp_vsmart.py | 10 +- plugins/modules/feature_templates.py | 2 + utils/ft_generator.py | 74 ++- 27 files changed, 1076 insertions(+), 545 deletions(-) diff --git a/playbooks/tests/test_feature_templates.yml b/playbooks/tests/test_feature_templates.yml index ffce744..a35ae63 100644 --- a/playbooks/tests/test_feature_templates.yml +++ b/playbooks/tests/test_feature_templates.yml @@ -40,192 +40,250 @@ loop_var: template label: "template: {{ template.templateName }}" - - name: Create Comprehensive AAA Template with TACACS+ and RADIUS - cisco.catalystwan.feature_templates: - state: present - template_name: "ComprehensiveAAATemplate" - template_description: "AAA Template with both TACACS+ and RADIUS servers" - device_models: - - vmanage - cisco_aaa: - user: - - name: "local_admin" - password: "admin_password" - privilege: "15" - tacacs: - - group_name: "TACACSGroup1" - vpn: "0" - source_interface: "GigabitEthernet0/1" - server: - - address: "192.168.2.10" - port: "49" - timeout: "5" - key: "tacacs_key" - radius: - - group_name: "RADIUSGroup1" - vpn: "0" - source_interface: "GigabitEthernet0/0" - server: - - address: "192.168.1.10" - auth_port: "1812" - acct_port: "1813" - timeout: "5" - retransmit: "3" - key: "radius_key" - secret_key: "secret" - server_auth_order: - - "local" - - "RADIUSGroup1" - - "TACACSGroup1" - authentication_group: true - accounting_group: true - domain_stripping: 'yes' - manager_credentials: - <<: *manager_authentication + # vedge-C8000V templates - - name: Create Cisco Banner Feature Template - cisco.catalystwan.feature_templates: - state: present - template_name: "CiscoBannerConfigTemplate" - template_description: "Banner configuration for login and MOTD" - device_models: - - "vedge-C8000V" - cisco_banner: - login_banner: | - **************************************************************** - * Unauthorized access to this device is prohibited. * - * You must have explicit permission to access or configure this * - * device. All activities performed on this device are logged and * - * violations of this policy may result in disciplinary action, * - * and may be reported to law enforcement. There is no right to * - * privacy on this device. Use of this system constitutes consent * - * to monitoring for these purposes. * - **************************************************************** - motd_banner: | - **************************************************************** - * Welcome to Company XYZ Network! * - * All connections are monitored and recorded for audit purposes. * - * Disconnect IMMEDIATELY if you are not an authorized user! * - **************************************************************** - manager_credentials: - <<: *manager_authentication + # - name: "Create Comprehensive AAA Template with TACACS+ and RADIUS" + # cisco.catalystwan.feature_templates: + # state: present + # template_name: "ComprehensiveAAATemplate" + # template_description: "AAA Template with both TACACS+ and RADIUS servers" + # debug: true + # device_models: + # - vedge-C8000V + # cisco_aaa: + # user: + # - name: "local_admin" + # password: "admin_password" + # secret: "admin_secret" + # privilege: "15" + # pubkey_chain: + # - key_string: "AAAAB3NzaC1yc2EAAAADAQABAAABAQC3myRj5L6ZFLdRnOEZdUd+4Qq0XPLW9RfO6qD7DJ2t4ZzLh6Oz+IUJg8d8bJDfxO9zGKs5uUQ9f2H5yTGX5G8Z5kKp8QDp1MkDVqwGJ4UM7JqH8s8kD7xcl8SyPc5TjzK4s4W+8LPNOPXmIKtHh1Qlvkp5N7w3M/Rm5ZVX5/3+Hk8Ib5syigQQd/5u5xJj9k3i2x3m3LZ7v5e7YlCpRdCQGf6ZCwvbVQHdJp5nlU0HxJbqjOTL4IcDj09G3Dq2C5JnohKJb7E7HVCUl7F5vYpC/4iNjges65GgdzaFJsT9qA8CgxyF+7J3PpLk5qPAQDT5OjArJj4x9Bw3j3lZdH example@example.com" + # key_type: "ssh-rsa" + # authentication_group: true + # accounting_group: true + # radius: + # - group_name: "radius_group1" + # vpn: "1" + # source_interface: "GigabitEthernet0/0" + # server: + # - address: "192.0.2.1" + # auth_port: 1812 + # acct_port: 1813 + # timeout: 5 + # retransmit: 3 + # key: "secure_radius_server_key" + # secret_key: "radius_secret" + # key_enum: "key_enum_value" + # key_type: "key_type_value" + # domain_stripping: "right-to-left" + # port: 1234 + # authentication_type: any + # server_auth_order: "local radius_group1 tacacs_group1" + # server_key_password: "secure_server_key_password" + # cts_authorization_list: "example_element" + # radius_trustsec_group: "radius_group1" + # radius_client: + # - ip: 2.2.2.2 + # vpn: + # - name: example_radius_client + # server_key: secure_radius_client_key + # accounting_rules: + # - rule_id: 0 + # method: network + # level: "1" + # group: "radius_group1,tacacs_group1" + # start_stop: false + # authorization_console: true + # authorization_config_commands: true + # authorization_rules: + # - rule_id: 111 + # method: commands + # group: "radius_group1,tacacs_group1" + # authenticated: true + # tacacs: + # - group_name: "tacacs_group1" + # vpn: 2 + # source_interface: "GigabitEthernet0/1" + # server: + # - address: "192.0.2.2" + # port: 49 + # timeout: 10 + # key: "tacacs_key" + # secret_key: "tacacs_secret" + # key_enum: "key_enum_value" + # manager_credentials: + # <<: *manager_authentication - - name: Create Cisco BFD Feature Template - cisco.catalystwan.feature_templates: - state: present - template_name: "CiscoBFDFeatureTemplate" - template_description: "Comprehensive BFD configuration" - device_models: - - "vedge-C8000V" - cisco_bfd: - multiplier: "3" - poll_interval: "500" - default_dscp: "46" - color: - - color: "mpls" - hello_interval: "50" - multiplier: "3" - pmtu_discovery: "yes" - dscp: "48" - - color: "biz-internet" - hello_interval: "100" - multiplier: "4" - pmtu_discovery: "no" - dscp: "46" - - color: "private1" - hello_interval: "150" - multiplier: "5" - pmtu_discovery: "yes" - dscp: "44" - manager_credentials: - <<: *manager_authentication + # - name: Create Cisco Banner Feature Template + # cisco.catalystwan.feature_templates: + # state: present + # template_name: "CiscoBannerConfigTemplate" + # template_description: "Banner configuration for login and MOTD" + # debug: true + # device_models: + # - "vedge-C8000V" + # cisco_banner: + # login_banner: | + # **************************************************************** + # * Unauthorized access to this device is prohibited. * + # * You must have explicit permission to access or configure this * + # * device. All activities performed on this device are logged and * + # * violations of this policy may result in disciplinary action, * + # * and may be reported to law enforcement. There is no right to * + # * privacy on this device. Use of this system constitutes consent * + # * to monitoring for these purposes. * + # **************************************************************** + # motd_banner: | + # **************************************************************** + # * Welcome to Company XYZ Network! * + # * All connections are monitored and recorded for audit purposes. * + # * Disconnect IMMEDIATELY if you are not an authorized user! * + # **************************************************************** + # manager_credentials: + # <<: *manager_authentication - - name: Configure Cisco Logging Feature Template - cisco.catalystwan.feature_templates: - state: present - template_name: "CiscoLoggingFeatureTemplate" - template_description: "Comprehensive Logging Configuration" - device_models: - - "vedge-C8000V" - cisco_logging: - enable: "yes" - size: "10240" - rotate: "5" - tls_profile: - - profile: "StrictTLSProfile" - version: "TLSv1.2" - auth_type: "Mutual" - ciphersuite_list: - - "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" - - "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" - server: - - name: "LogServer1" - vpn: "10" - source_interface: "GigabitEthernet0/0/0" - priority: "information" - enable_tls: "yes" - custom_profile: "yes" - profile: "StrictTLSProfile" - ipv6_server: - - name: "LogServerIPv6_1" - vpn: "10" - source_interface: "GigabitEthernet0/0/0" - priority: "error" - enable_tls: "yes" - custom_profile: "yes" - profile: "StrictTLSProfile" - manager_credentials: - <<: *manager_authentication + # - name: Create Cisco BFD Feature Template + # cisco.catalystwan.feature_templates: + # state: present + # template_name: "CiscoBFDFeatureTemplate" + # template_description: "Comprehensive BFD configuration" + # debug: true + # device_models: + # - "vedge-C8000V" + # cisco_bfd: + # multiplier: "3" + # poll_interval: "500" + # default_dscp: "46" + # color: + # - color: "mpls" + # hello_interval: "200" + # multiplier: "4" + # pmtu_discovery: true + # dscp: "46" + # - color: "biz-internet" + # hello_interval: "300" + # multiplier: "5" + # pmtu_discovery: false + # dscp: "34" + # - color: "private1" + # hello_interval: "250" + # multiplier: "3" + # pmtu_discovery: true + # dscp: "26" + # - color: "custom3" + # hello_interval: "350" + # multiplier: "6" + # pmtu_discovery: true + # dscp: "18" + # manager_credentials: + # <<: *manager_authentication - - name: Configure Cisco NTP Feature Template - cisco.catalystwan.feature_templates: - state: present - template_name: "CiscoNTPFeatureTemplate" - template_description: "Comprehensive NTP Configuration" - device_models: - - "vmanage" - cisco_ntp: - server: - - name: "0.pool.ntp.org" - key: "10" - vpn: "1" - version: "4" - source_interface: "GigabitEthernet0/0/0" - prefer: "yes" - - name: "1.pool.ntp.org" - key: "20" - vpn: "1" - version: "4" - source_interface: "GigabitEthernet0/0/1" - authentication: - - number: "10" - md5: "44b9d6ee8faafed3" - - number: "20" - md5: "f7a1a7e81e4567d9" - trusted: - - "10" - - "20" - enable: "yes" - stratum: "2" - source: "Loopback0" - manager_credentials: - <<: *manager_authentication + # - name: Configure Cisco Logging Feature Template + # cisco.catalystwan.feature_templates: + # state: present + # template_name: "CiscoLoggingFeatureTemplate" + # template_description: "Comprehensive Logging Configuration" + # debug: true + # device_models: + # - "vedge-C8000V" + # cisco_logging: + # enable: true + # size: "20" + # rotate: "5" + # tls_profile: + # - profile: "default_tls_profile" + # version: "TLSv1.2" + # auth_type: "Server" + # ciphersuite_list: + # - "ECDHE-ECDSA-AES256-GCM-SHA384" + # - "ECDHE-RSA-AES256-GCM-SHA384" + # - profile: "secure_tls_profile" + # version: "TLSv1.2" + # auth_type: "Mutual" + # ciphersuite_list: + # - "ECDHE-ECDSA-CHACHA20-POLY1305" + # - "ECDHE-RSA-CHACHA20-POLY1305" + # server: + # - name: "1.1.1.1" + # vpn: "10" + # source_interface: "GigabitEthernet0/0" + # priority: "debugging" + # enable_tls: true + # custom_profile: true + # profile: "default_tls_profile" + # - name: "log_server_2" + # vpn: "20" + # source_interface: "GigabitEthernet0/1" + # priority: "error" + # enable_tls: false + # ipv6_server: + # - name: "ipv6_log_server_1" + # vpn: "10" + # source_interface: "GigabitEthernet0/2" + # priority: "critical" + # enable_tls: true + # custom_profile: true + # profile: "secure_tls_profile" + # - name: "ipv6_log_server_2" + # vpn: "30" + # source_interface: "GigabitEthernet0/3" + # priority: "emergency" + # enable_tls: false + # manager_credentials: + # <<: *manager_authentication + + # - name: Configure Cisco NTP Feature Template + # cisco.catalystwan.feature_templates: + # state: present + # template_name: "CiscoNTPFeatureTemplate" + # template_description: "Comprehensive NTP Configuration" + # debug: true + # device_models: + # - "vedge-C8000V" + # cisco_ntp: + # server: + # - name: "0.pool.ntp.org" + # key: "1" + # vpn: "10" + # version: "4" + # source_interface: "GigabitEthernet0/0" + # prefer: true + # - name: "1.pool.ntp.org" + # key: "2" + # vpn: "20" + # version: "4" + # source_interface: "GigabitEthernet0/1" + # prefer: false + # authentication: + # - number: 1 + # md5: "md5key1" + # - number: 2 + # md5: "md5key2" + # trusted: + # - "1" + # - "2" + # enable: true + # stratum: "2" + # source: "Loopback0" + # manager_credentials: + # <<: *manager_authentication - name: Configure Cisco OMP Feature Template cisco.catalystwan.feature_templates: state: present template_name: "CiscoOMPFeatureTemplate" template_description: "Comprehensive OMP Configuration" + debug: true device_models: - - "vmanage" + - "vedge-C8000V" cisco_omp: - graceful_restart: "enabled" - overlay_as: "65530" - send_path_limit: "5" - ecmp_limit: "2" - shutdown: "enabled" # TODO - omp_admin_distance_ipv4: "130" - omp_admin_distance_ipv6: "130" + graceful_restart: true + overlay_as: "65000" + send_path_limit: "10" + ecmp_limit: "8" + shutdown: false + omp_admin_distance_ipv4: "110" + omp_admin_distance_ipv6: "115" advertisement_interval: "30" graceful_restart_timer: "120" eor_timer: "300" @@ -234,17 +292,190 @@ - protocol: "bgp" route: "external" - protocol: "ospf" + - protocol: "connected" - protocol: "static" + - protocol: "eigrp" + - protocol: "lisp" ipv6_advertise: - protocol: "bgp" - protocol: "ospf" - protocol: "connected" - ignore_region_path_length: "true" + - protocol: "static" + ignore_region_path_length: true transport_gateway: "prefer" site_types: - "type-1" - "type-2" + - "cloud" - "branch" - auto_translate: "enabled" + - "spoke" + auto_translate: true manager_credentials: <<: *manager_authentication + + + - name: Configure Cisco OSPF Feature Template + cisco.catalystwan.feature_templates: + state: present + template_name: "CiscoOSPFeatureTemplate" + template_description: "Comprehensive OSPF Configuration" + device_models: + - "vedge-C8000V" + cisco_ospf: + router_id: "1.1.1.1" + reference_bandwidth: "10000" + rfc1583: false + originate: true + always: true + metric: "10" + metric_type: "type1" + external: "20" + inter_area: "30" + intra_area: "40" + delay: "5" + initial_hold: "10" + max_hold: "40" + redistribute: + - protocol: "static" + route_policy: "static_policy" + dia: true + - protocol: "bgp" + route_policy: "bgp_to_ospf_policy" + dia: false + router_lsa: + - ad_type: "administrative" + time: 10 + route_policy: + - direction: "in" + pol_name: "ospf_in_policy" + area: + - a_num: 0 + stub: false + nssa: true + interface: + - name: "GigabitEthernet0/0" + hello_interval: "10" + dead_interval: "40" + retransmit_interval: "5" + cost: "1" + priority: "1" + network: "broadcast" + passive_interface: false + type: "simple" + message_digest_key: "1" + md5: "md5keystring" + range: + - address: "192.168.1.0/24" + cost: "100" + no_advertise: true + manager_credentials: + <<: *manager_authentication + + + + # INVALID + # - name: Create Comprehensive Cisco System Template + # cisco.catalystwan.feature_templates: + # state: present + # template_name: "ComprehensiveCiscoSystemTemplate" + # template_description: "Cisco System template" + # debug: true + # cisco_system: + # timezone: "UTC" + # hostname: + # name: "sdwan-hostname" # Replace with the actual hostname + # location: "Data Center A" + # latitude: "37.7749" + # longitude: "-122.4194" + # range: "10" + # enable_fencing: true + # mobile_number: + # - number: "+12345678901" + # - number: "+10987654321" + # enable_sms: true + # device_groups: + # - "group1" + # - "group2" + # controller_group_list: + # - "controller_group1" + # system_ip: + # name: "192.0.2.1" # Replace with the actual system IP + # overlay_id: "1" + # site_id: 1001 + # site_type: + # - "branch" + # - "spoke" + # port_offset: "1000" + # port_hop: true + # control_session_pps: "500" + # track_transport: true + # track_interface_tag: "eth0" + # console_baud_rate: "9600" + # max_omp_sessions: "50" + # multi_tenant: false + # track_default_gateway: false + # admin_tech_on_failure: true + # enable_tunnel: true + # idle_timeout: "300" + # on_demand_idle_timeout_min: "60" + # tracker: + # - name: "tracker1" + # endpoint_ip: "203.0.113.1" + # endpoint_ip_transport_port: "8080" + # protocol: "tcp" + # port: "443" + # endpoint_dns_name: "example.com" + # endpoint_api_url: "https://api.example.com" + # elements: + # - "element1" + # - "element2" + # boolean: "and" + # threshold: "10" + # interval: "30" + # multiplier: "3" + # type: "interface" + # object_track: + # - object_number: 10 + # interface: 'GigabitEthernet0/0/0' + # sig: '100' + # ip: '192.0.2.1' + # mask: '255.255.255.0' + # vpn: 1 + # object: + # - number: 101 + # boolean: 'and' + # - object_number: 20 + # interface: 'GigabitEthernet0/0/1' + # sig: '200' + # ip: '198.51.100.1' + # mask: '255.255.255.0' + # vpn: 2 + # object: + # - number: 201 + # boolean: 'or' + # preference: + # - 1 + # preference_auto: true + # epfr: "conservative" + # vrf: + # - vrf_id: 1 + # gateway_preference: + # - '192.0.2.1' + # - '192.0.2.2' + # - vrf_id: 2 + # gateway_preference: + # - '198.51.100.1' + # - '198.51.100.2' + # enable_management_region: true + # migration_bgp_community: '65535:12345' + # enable_mrf_migration: enabled + # transport_gateway: true + # affinity_group_number: 1 + # affinity_per_vrf: + # - affinity_group_number: 1 + # vrf_range: "22" + # role: 'vSmart' + # secondary_region: 'secondaryRegion' + # region_id: 'primaryRegion' + # manager_credentials: + # <<: *manager_authentication diff --git a/plugins/doc_fragments/feature_template_cisco_aaa.py b/plugins/doc_fragments/feature_template_cisco_aaa.py index 256c8f0..62d351c 100644 --- a/plugins/doc_fragments/feature_template_cisco_aaa.py +++ b/plugins/doc_fragments/feature_template_cisco_aaa.py @@ -17,9 +17,29 @@ class ModuleDocFragment(object): description: Cisco AAA Feature Template configuration type: dict suboptions: + authentication_group: + description: + - 'Whether to enable the authentication group, GUI equivalent: Authentication + Param' + required: false + default: false + type: bool + accounting_group: + description: + - 'Whether to enable the accounting group, GUI equivalent: Accounting + Param' + required: false + default: false + type: bool + server_auth_order: + description: + - ServerGroups authentication order to user access + required: false + default: local + type: str user: description: - - List of user configurations + - List of local user configurations required: false default: null type: list @@ -47,27 +67,132 @@ class ModuleDocFragment(object): description: - The privilege level for the user required: false - default: null + default: '15' type: str + choices: + - '1' + - '15' pubkey_chain: description: - List of public keys for the user required: false default: [] type: list - elements: str - authentication_group: + elements: dict + suboptions: + key_string: + description: + - Set the RSA key string + required: true + default: null + type: str + key_type: + description: + - Only RSA is supported + required: false + default: ssh-rsa + type: str + accounting_rules: description: - - Whether to enable the authentication group + - Configure the accounting rules + required: false + default: null + type: list + elements: dict + suboptions: + rule_id: + description: + - Accounting Rule ID + required: true + default: null + type: str + method: + description: + - Configure Accounting Method + required: true + default: null + type: str + choices: + - commands + - exec + - network + - system + level: + description: + - Privilege level when method is commands + required: false + default: null + type: str + choices: + - '1' + - '15' + start_stop: + description: + - Enable Start-Stop + required: false + default: true + type: bool + group: + description: + - List of groups. + required: true + default: null + type: str + authorization_console: + description: + - For enabling console authorization required: false default: null type: bool - accounting_group: + authorization_config_commands: description: - - Whether to enable the accounting group + - For configuration mode commands required: false default: null type: bool + authorization_rules: + description: + - Configure the accounting rules + required: false + default: null + type: list + elements: dict + suboptions: + rule_id: + description: + - Authorization Rule ID + required: true + default: null + type: str + method: + description: + - Configure Authorization Method + required: true + default: null + type: str + choices: + - commands + level: + description: + - Privilege level when method is commands + required: false + default: null + type: str + choices: + - '1' + - '15' + group: + description: + - List of groups. + required: true + default: null + type: str + authenticated: + description: + - Succeed if user has authenticated + required: false + default: false + type: bool radius: description: - List of Radius group configurations @@ -113,26 +238,26 @@ class ModuleDocFragment(object): - The authentication port for the RADIUS server required: false default: null - type: str + type: int acct_port: description: - The accounting port for the RADIUS server required: false default: null - type: str + type: int timeout: description: - The timeout period in seconds for the RADIUS server required: false default: null - type: str + type: int retransmit: description: - The number of retransmit attempts for the RADIUS server required: false default: null - type: str + type: int key: description: - The key for the RADIUS server @@ -157,6 +282,40 @@ class ModuleDocFragment(object): required: false default: null type: str + radius_client: + description: + - Specify a RADIUS client + required: false + default: null + type: list + elements: dict + suboptions: + ip: + description: + - The Client IP + required: true + default: null + type: str + vpn: + description: + - The VPN Configuration + required: true + default: null + type: list + elements: dict + suboptions: + name: + description: + - VPN ID + required: true + default: null + type: str + server_key: + description: + - Specify a RADIUS client server-key + required: false + default: null + type: str domain_stripping: description: - The domain stripping configuration @@ -167,9 +326,37 @@ class ModuleDocFragment(object): - 'yes' - 'no' - right-to-left + authentication_type: + description: + - Authentication Type + required: false + default: any + type: str + choices: + - any + - all + - session-key port: description: - - The port number for AAA + - Specify Radius Dynamic Author Port + required: false + default: null + type: str + server_key_password: + description: + - Specify a radius dynamic author server-key + required: false + default: null + type: str + cts_authorization_list: + description: + - Specify a radius dynamic author server-key + required: false + default: null + type: str + radius_trustsec_group: + description: + - RADIUS trustsec group required: false default: null type: str @@ -192,7 +379,7 @@ class ModuleDocFragment(object): - The VPN ID for the TACACS+ group required: false default: null - type: str + type: int source_interface: description: - The source interface for the TACACS+ group @@ -213,24 +400,24 @@ class ModuleDocFragment(object): required: true default: null type: str + key: + description: + - The key for the TACACS+ server + required: true + default: null + type: str port: description: - The port for the TACACS+ server required: false default: null - type: str + type: int timeout: description: - The timeout period in seconds for the TACACS+ server required: false default: null - type: str - key: - description: - - The key for the TACACS+ server - required: true - default: null - type: str + type: int secret_key: description: - The secret key for the TACACS+ server @@ -243,11 +430,4 @@ class ModuleDocFragment(object): required: false default: null type: str - server_auth_order: - description: - - Authentication order to user access - required: false - default: null - type: list - elements: str ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_cisco_bfd.py b/plugins/doc_fragments/feature_template_cisco_bfd.py index f06e3d0..3377f4a 100644 --- a/plugins/doc_fragments/feature_template_cisco_bfd.py +++ b/plugins/doc_fragments/feature_template_cisco_bfd.py @@ -89,8 +89,8 @@ class ModuleDocFragment(object): description: - Whether to enable Path MTU Discovery required: false - default: null - type: str + default: true + type: bool dscp: description: - The DSCP value used for BFD packets diff --git a/plugins/doc_fragments/feature_template_cisco_logging.py b/plugins/doc_fragments/feature_template_cisco_logging.py index 07c6338..f1b910a 100644 --- a/plugins/doc_fragments/feature_template_cisco_logging.py +++ b/plugins/doc_fragments/feature_template_cisco_logging.py @@ -22,7 +22,7 @@ class ModuleDocFragment(object): - Whether logging to disk is enabled required: false default: null - type: str + type: bool size: description: - The maximum file size for the log file @@ -119,14 +119,14 @@ class ModuleDocFragment(object): description: - Whether to enable TLS encryption required: false - default: null - type: str + default: false + type: bool custom_profile: description: - Whether to use a custom TLS profile required: false - default: null - type: str + default: false + type: bool profile: description: - The custom TLS profile to use @@ -178,14 +178,14 @@ class ModuleDocFragment(object): description: - Whether to enable TLS encryption for the IPv6 server required: false - default: null - type: str + default: false + type: bool custom_profile: description: - Whether to use a custom TLS profile for the IPv6 server required: false - default: null - type: str + default: false + type: bool profile: description: - The custom TLS profile to use for the IPv6 server diff --git a/plugins/doc_fragments/feature_template_cisco_ntp.py b/plugins/doc_fragments/feature_template_cisco_ntp.py index 5d6593b..f5327ad 100644 --- a/plugins/doc_fragments/feature_template_cisco_ntp.py +++ b/plugins/doc_fragments/feature_template_cisco_ntp.py @@ -60,7 +60,7 @@ class ModuleDocFragment(object): - Whether this server is preferred over others required: false default: null - type: str + type: bool authentication: description: - List of authentication keys @@ -74,7 +74,7 @@ class ModuleDocFragment(object): - The authentication key number required: true default: null - type: str + type: int md5: description: - The MD5 hash used for authentication @@ -93,7 +93,7 @@ class ModuleDocFragment(object): - Whether the device is an NTP master required: false default: null - type: str + type: bool stratum: description: - The stratum level if the device is an NTP master diff --git a/plugins/doc_fragments/feature_template_cisco_omp.py b/plugins/doc_fragments/feature_template_cisco_omp.py index 827ed95..6c35d42 100644 --- a/plugins/doc_fragments/feature_template_cisco_omp.py +++ b/plugins/doc_fragments/feature_template_cisco_omp.py @@ -22,8 +22,8 @@ class ModuleDocFragment(object): description: - Enable or disable graceful restart for OMP. required: false - default: null - type: str + default: true + type: bool overlay_as: description: - The autonomous system number used for the overlay. @@ -47,7 +47,7 @@ class ModuleDocFragment(object): - Enable or disable the shutdown of OMP. required: false default: null - type: str + type: bool omp_admin_distance_ipv4: description: - The administrative distance for IPv4 routes learned via OMP. @@ -144,8 +144,8 @@ class ModuleDocFragment(object): description: - Whether to ignore the region part of the path length for OMP routes. required: false - default: null - type: str + default: false + type: bool transport_gateway: description: - Specifies the preferred transport gateway selection strategy. @@ -175,6 +175,6 @@ class ModuleDocFragment(object): description: - Enable or disable automatic translation of network settings. required: false - default: null - type: str + default: false + type: bool ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_cisco_ospf.py b/plugins/doc_fragments/feature_template_cisco_ospf.py index dbfccba..9295957 100644 --- a/plugins/doc_fragments/feature_template_cisco_ospf.py +++ b/plugins/doc_fragments/feature_template_cisco_ospf.py @@ -33,21 +33,21 @@ class ModuleDocFragment(object): description: - Compatibility switch for RFC 1583. required: false - default: null - type: str + default: true + type: bool originate: description: - Controls the origination of default information into the OSPF domain. required: false default: null - type: str + type: bool always: description: - Ensures that the default route is always advertised, regardless of the existence of a default route in the routing table. required: false default: null - type: str + type: bool metric: description: - The metric value to be set for the default route advertised by OSPF. @@ -132,8 +132,8 @@ class ModuleDocFragment(object): - Default information originate, which controls the advertisement of default route. required: false - default: null - type: str + default: true + type: bool router_lsa: description: - Configuration options for the Router LSA in OSPF. @@ -156,7 +156,7 @@ class ModuleDocFragment(object): - Time in seconds for advertisement. required: true default: null - type: str + type: int route_policy: description: - A list of OSPF route policies. @@ -192,21 +192,21 @@ class ModuleDocFragment(object): - The OSPF area number. required: true default: null - type: str + type: int stub: description: - Configuration for the OSPF area to be a stub area. If set, no-summary can be applied. required: false default: null - type: str + type: bool nssa: description: - Configuration for the OSPF area to be a Not-So-Stubby Area (NSSA). If set, no-summary can be applied. required: false default: null - type: str + type: bool interface: description: - A list of OSPF interface configurations associated with @@ -270,8 +270,8 @@ class ModuleDocFragment(object): description: - Whether the interface is a passive OSPF interface. required: false - default: null - type: str + default: false + type: bool type: description: - The OSPF authentication type for the interface. @@ -320,6 +320,6 @@ class ModuleDocFragment(object): description: - Whether to suppress advertising this range. required: false - default: null - type: str + default: false + type: bool ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py b/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py index 5fa822a..2cabe78 100644 --- a/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py +++ b/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py @@ -22,7 +22,7 @@ class ModuleDocFragment(object): - VPN ID associated with the Cisco Secure Internet Gateway service. required: false default: null - type: str + type: int interface: description: - List of interface configurations associated with the service. @@ -130,7 +130,7 @@ class ModuleDocFragment(object): - MTU (Maximum Transmission Unit) size for the interface. required: false default: null - type: str + type: int dpd_interval: description: - Dead Peer Detection (DPD) interval in seconds. @@ -148,7 +148,7 @@ class ModuleDocFragment(object): - Internet Key Exchange (IKE) protocol version. required: false default: null - type: str + type: int pre_shared_secret: description: - Pre-shared secret key for IKE authentication. @@ -289,7 +289,7 @@ class ModuleDocFragment(object): in failover decisions. required: false default: null - type: str + type: int backup_interface: description: - Name of the backup interface. Can be 'None' if no @@ -303,7 +303,7 @@ class ModuleDocFragment(object): in failover decisions. required: false default: null - type: str + type: int auth_required: description: - Flag indicating if authentication is required for the service. @@ -340,14 +340,14 @@ class ModuleDocFragment(object): - Primary data center for the service. 'Auto' for automatic selection. required: false - default: null + default: Auto type: str secondary_data_center: description: - Secondary data center for the service. 'Auto' for automatic selection. required: false - default: null + default: Auto type: str ip: description: @@ -424,14 +424,14 @@ class ModuleDocFragment(object): description: - Alias for the primary data center setting. required: false - default: null + default: Auto type: str data_center_secondary: description: - Secondary data center for the service. 'Auto' for automatic selection or a specific identifier for a manual selection. required: false - default: null + default: Auto type: str tracker_src_ip: description: diff --git a/plugins/doc_fragments/feature_template_cisco_snmp.py b/plugins/doc_fragments/feature_template_cisco_snmp.py index 876c04d..fb5c544 100644 --- a/plugins/doc_fragments/feature_template_cisco_snmp.py +++ b/plugins/doc_fragments/feature_template_cisco_snmp.py @@ -21,18 +21,18 @@ class ModuleDocFragment(object): description: - Indicates whether SNMP is administratively shut down required: false - default: null - type: str + default: true + type: bool contact: description: - The contact information for the SNMP administrator - required: true + required: false default: null type: str location: description: - The physical location information for the SNMP agent - required: true + required: false default: null type: str view: @@ -52,7 +52,7 @@ class ModuleDocFragment(object): oid: description: - List of OIDs to include or exclude in the view - required: true + required: false default: null type: list elements: dict @@ -68,9 +68,9 @@ class ModuleDocFragment(object): description: - Indicates whether the OID should be excluded from the view - required: true + required: false default: null - type: str + type: bool community: description: - List of SNMP communities for different access rights @@ -146,7 +146,7 @@ class ModuleDocFragment(object): auth: description: - The authentication protocol used - required: true + required: false default: null type: str choices: @@ -155,7 +155,7 @@ class ModuleDocFragment(object): auth_password: description: - The password for authentication - required: true + required: false default: null type: str priv: @@ -169,7 +169,7 @@ class ModuleDocFragment(object): priv_password: description: - The password for privacy - required: true + required: false default: null type: str group: @@ -191,7 +191,7 @@ class ModuleDocFragment(object): - The VPN ID where the SNMP target resides required: true default: null - type: str + type: int ip: description: - The IP address of the SNMP target @@ -203,23 +203,23 @@ class ModuleDocFragment(object): - The port number for the SNMP target required: true default: null - type: str + type: int community_name: description: - The community name for the SNMP target - required: true + required: false default: null type: str user: description: - The user name for the SNMP target - required: true + required: false default: null type: str source_interface: description: - The source interface for sending SNMP traps - required: true + required: false default: null type: str ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_cisco_system.py b/plugins/doc_fragments/feature_template_cisco_system.py index acf3b61..3cb9cef 100644 --- a/plugins/doc_fragments/feature_template_cisco_system.py +++ b/plugins/doc_fragments/feature_template_cisco_system.py @@ -444,7 +444,7 @@ class ModuleDocFragment(object): description: - The hostname for the device. required: false - default: null + default: system_host_name type: dict suboptions: name: @@ -482,7 +482,7 @@ class ModuleDocFragment(object): - Enable or disable geo-fencing. required: false default: null - type: str + type: bool mobile_number: description: - List of mobile numbers for SMS notifications. @@ -502,8 +502,8 @@ class ModuleDocFragment(object): description: - Enable or disable SMS notifications. required: false - default: null - type: str + default: false + type: bool device_groups: description: - List of device groups the device belongs to. @@ -522,7 +522,7 @@ class ModuleDocFragment(object): description: - The system IP address of the device. required: false - default: null + default: system_system_ip type: dict suboptions: name: @@ -541,8 +541,8 @@ class ModuleDocFragment(object): description: - The site ID of the device. required: false - default: null - type: str + default: system_site_id + type: int site_type: description: - The site type classification for the device. @@ -569,7 +569,7 @@ class ModuleDocFragment(object): - Enable or disable port hopping. required: false default: null - type: str + type: bool control_session_pps: description: - Control session packets per second setting. @@ -581,7 +581,7 @@ class ModuleDocFragment(object): - Enable or disable transport tracking. required: false default: null - type: str + type: bool track_interface_tag: description: - The tag of the interface to be tracked. @@ -614,26 +614,26 @@ class ModuleDocFragment(object): - Enable or disable multi-tenant support. required: false default: null - type: str + type: bool track_default_gateway: description: - Enable or disable default gateway tracking. required: false default: null - type: str + type: bool admin_tech_on_failure: description: - Enable or disable automatic generation of admin technical details on failure. required: false default: null - type: str + type: bool enable_tunnel: description: - Enable or disable tunnel functionality. required: false default: null - type: str + type: bool idle_timeout: description: - The idle timeout setting for tunnels. @@ -755,7 +755,7 @@ class ModuleDocFragment(object): - The tracking object number. required: true default: null - type: str + type: int interface: description: - The name of the interface to track. @@ -778,14 +778,14 @@ class ModuleDocFragment(object): description: - The subnet mask associated with the IP address for tracking. required: false - default: null + default: 0.0.0.0 type: str vpn: description: - The VPN instance associated with the tracking object. required: true default: null - type: str + type: int object: description: - A list of objects related to the tracking. @@ -799,7 +799,7 @@ class ModuleDocFragment(object): - The unique identifier for the object. required: true default: null - type: str + type: int boolean: description: - The boolean condition to use when evaluating multiple objects. @@ -848,7 +848,7 @@ class ModuleDocFragment(object): - Enable or disable automatic preference setting for affinity groups. required: false default: null - type: str + type: bool affinity_per_vrf: description: - List of affinity configurations per VRF. @@ -874,7 +874,7 @@ class ModuleDocFragment(object): - Enable or disable the transport gateway feature. required: false default: null - type: str + type: bool enable_mrf_migration: description: - Enable Multicast Routing Framework (MRF) migration settings. @@ -895,7 +895,7 @@ class ModuleDocFragment(object): - Enable or disable management region configuration. required: false default: null - type: str + type: bool vrf: description: - List of VRF configurations. @@ -909,7 +909,7 @@ class ModuleDocFragment(object): - The VRF (VPN Routing and Forwarding) instance ID. required: true default: null - type: str + type: int gateway_preference: description: - A list of preferred gateway values for the VRF. @@ -922,7 +922,7 @@ class ModuleDocFragment(object): - Enable or disable the management gateway feature. required: false default: null - type: str + type: bool epfr: description: - Edge Policy-based Framework Routing (EPFR) setting. diff --git a/plugins/doc_fragments/feature_template_cisco_vpn.py b/plugins/doc_fragments/feature_template_cisco_vpn.py index 3c4f78e..72e0779 100644 --- a/plugins/doc_fragments/feature_template_cisco_vpn.py +++ b/plugins/doc_fragments/feature_template_cisco_vpn.py @@ -22,7 +22,7 @@ class ModuleDocFragment(object): - The unique identifier for the VPN instance (VRF). required: false default: null - type: str + type: int vpn_name: description: - The name of the VPN instance. @@ -193,7 +193,7 @@ class ModuleDocFragment(object): - The VPN identifier where the service route is to be applied. required: true default: null - type: str + type: int service: description: - The service associated with the route. @@ -372,7 +372,7 @@ class ModuleDocFragment(object): - The VPN identifier where the GRE route is to be applied. required: true default: null - type: str + type: int interface: description: - A list of interfaces associated with the GRE route. @@ -400,7 +400,7 @@ class ModuleDocFragment(object): - The VPN identifier where the IPSec route is to be applied. required: true default: null - type: str + type: int interface: description: - A list of interfaces associated with the IPSec route. @@ -620,7 +620,7 @@ class ModuleDocFragment(object): - The identifier for the NAT pool. required: true default: null - type: str + type: int prefix_length: description: - The length of the network prefix for the NAT pool. @@ -736,7 +736,7 @@ class ModuleDocFragment(object): NAT. required: true default: null - type: str + type: int static_nat_direction: description: - The direction (inside or outside) for the subnet static @@ -774,14 +774,14 @@ class ModuleDocFragment(object): - The source port number for the port forwarding rule. required: true default: null - type: str + type: int translate_port: description: - The destination port number to which the source port is translated. required: true default: null - type: str + type: int source_ip: description: - The source IP address for the port forwarding rule. @@ -876,7 +876,7 @@ class ModuleDocFragment(object): - The VPN instance (VRF) from which routes are to be imported. required: true default: null - type: str + type: int protocol: description: - The routing protocol from which routes are to be imported. diff --git a/plugins/doc_fragments/feature_template_cisco_vpn_interface.py b/plugins/doc_fragments/feature_template_cisco_vpn_interface.py index 431e4a1..5b6c2c4 100644 --- a/plugins/doc_fragments/feature_template_cisco_vpn_interface.py +++ b/plugins/doc_fragments/feature_template_cisco_vpn_interface.py @@ -35,7 +35,7 @@ class ModuleDocFragment(object): False otherwise. required: false default: null - type: str + type: bool ipv4_address: description: - The primary IPv4 address assigned to the interface. @@ -62,7 +62,7 @@ class ModuleDocFragment(object): True if enabled, False otherwise. required: false default: null - type: str + type: bool dhcp_distance: description: - Administrative distance for DHCP routes on the interface. @@ -81,7 +81,7 @@ class ModuleDocFragment(object): True if enabled, False otherwise. required: false default: null - type: str + type: bool secondary_ipv6_address: description: - A list of secondary IPv6 addresses assigned to the interface. @@ -160,7 +160,7 @@ class ModuleDocFragment(object): True if enabled, False otherwise. required: false default: null - type: str + type: bool iperf_server: description: - The IP address of the iPerf server used for performance testing @@ -174,7 +174,7 @@ class ModuleDocFragment(object): the interface. required: false default: null - type: str + type: bool nat_choice: description: - The type of NAT configured on the interface, if applicable. @@ -216,7 +216,7 @@ class ModuleDocFragment(object): - Indicates if NAT overload (PAT - Port Address Translation) is enabled. required: false default: null - type: str + type: bool loopback_interface: description: - The associated loopback interface, if any, for the VPN interface. @@ -235,21 +235,21 @@ class ModuleDocFragment(object): - Indicates whether the interface is enabled or disabled. required: false default: null - type: str + type: bool nat64: description: - Indicates whether NAT64 is enabled on the interface, allowing IPv6 addresses to communicate with IPv4 services. required: false default: null - type: str + type: bool nat66: description: - Indicates whether NAT66 is enabled on the interface, translating IPv6 addresses into IPv6 addresses. required: false default: null - type: str + type: bool static_nat66: description: - List of static NAT66 entries for translating IPv6 addresses into @@ -276,7 +276,7 @@ class ModuleDocFragment(object): - VPN ID associated with the source network prefix. required: false default: null - type: str + type: int static: description: - List of static NAT entries for configuring one-to-one address mappings. @@ -311,7 +311,7 @@ class ModuleDocFragment(object): - VPN ID associated with the source IP for static NAT. required: false default: null - type: str + type: int static_port_forward: description: - List of static port forwarding entries for the interface. @@ -346,13 +346,13 @@ class ModuleDocFragment(object): - Source port number for port forwarding. required: false default: null - type: str + type: int translate_port: description: - Translated port number for port forwarding. required: false default: null - type: str + type: int proto: description: - Protocol used for port forwarding (TCP/UDP). @@ -367,14 +367,14 @@ class ModuleDocFragment(object): - VPN ID associated with the source IP for port forwarding. required: false default: null - type: str + type: int enable_core_region: description: - Indicates if the interface is part of the core network region for centralized services. required: false default: null - type: str + type: bool core_region: description: - Configuration details for the core region. @@ -424,25 +424,25 @@ class ModuleDocFragment(object): decisions. required: false default: null - type: str + type: int border: description: - Defines if the interface is at the border of a network segment. required: false default: null - type: str + type: bool per_tunnel_qos: description: - Enable or disable per-tunnel Quality of Service (QoS). required: false default: null - type: str + type: bool per_tunnel_qos_aggregator: description: - Enable or disable per-tunnel QoS aggregator. required: false default: null - type: str + type: bool mode: description: - Defines the operating mode for the interface. @@ -507,14 +507,14 @@ class ModuleDocFragment(object): - Enables or disables control connections on the interface. required: false default: null - type: str + type: bool vbond_as_stun_server: description: - Configures the vBond orchestrator to act as a STUN server for the interface. required: false default: null - type: str + type: bool exclude_controller_group_list: description: - List of controller groups to exclude from connections. @@ -534,13 +534,13 @@ class ModuleDocFragment(object): blocking. required: false default: null - type: str + type: bool restrict: description: - Indicates whether the interface color is restricted for use. required: false default: null - type: str + type: bool dst_ip: description: - Destination IP address for GRE (Generic Routing Encapsulation) tunnel @@ -597,13 +597,13 @@ class ModuleDocFragment(object): back to. required: false default: null - type: str + type: bool low_bandwidth_link: description: - Indicates if the link is considered a low bandwidth link. required: false default: null - type: str + type: bool tunnel_tcp_mss_adjust: description: - Adjusts the Maximum Segment Size (MSS) value for TCP connections @@ -617,102 +617,102 @@ class ModuleDocFragment(object): in the IP header. required: false default: null - type: str + type: bool propagate_sgt: description: - Enables or disables the propagation of Security Group Tags (SGTs) across the tunnel interface. required: false default: null - type: str + type: bool network_broadcast: description: - Allows or disallows network broadcast traffic through the tunnel interface. required: false default: null - type: str + type: bool all: description: - Permits or denies all services through the tunnel interface. required: false default: null - type: str + type: bool bgp: description: - Allows or disallows Border Gateway Protocol (BGP) traffic through the tunnel interface. required: false default: null - type: str + type: bool dhcp: description: - Enables or disables Dynamic Host Configuration Protocol (DHCP) on the tunnel interface. required: false default: null - type: str + type: bool dns: description: - Allows or disallows Domain Name System (DNS) queries through the tunnel interface. required: false default: null - type: str + type: bool icmp: description: - Enables or disables Internet Control Message Protocol (ICMP) for ping and traceroute through the tunnel interface. required: false default: null - type: str + type: bool sshd: description: - Allows or disallows Secure Shell (SSH) daemon access through the tunnel interface. required: false default: null - type: str + type: bool netconf: description: - Enables or disables NETCONF protocol support on the tunnel interface. required: false default: null - type: str + type: bool ntp: description: - Allows or disallows Network Time Protocol (NTP) synchronization through the tunnel interface. required: false default: null - type: str + type: bool ospf: description: - Permits or denies Open Shortest Path First (OSPF) routing protocol traffic through the tunnel interface. required: false default: null - type: str + type: bool stun: description: - Enables or disables Session Traversal Utilities for NAT (STUN) on the tunnel interface. required: false default: null - type: str + type: bool snmp: description: - Allows or disallows Simple Network Management Protocol (SNMP) through the tunnel interface. required: false default: null - type: str + type: bool https: description: - Permits or denies HTTPS traffic through the tunnel interface. required: false default: null - type: str + type: bool media_type: description: - Specifies the media type used by the interface, such as copper or @@ -801,8 +801,8 @@ class ModuleDocFragment(object): description: - Enables or disables (shuts down) the interface. required: false - default: null - type: str + default: false + type: bool arp_timeout: description: - Time in seconds before an ARP cache entry is timed out. @@ -815,25 +815,25 @@ class ModuleDocFragment(object): on the interface. required: false default: null - type: str + type: bool ip_directed_broadcast: description: - Allows or disallows IP directed broadcasts on the interface. required: false default: null - type: str + type: bool icmp_redirect_disable: description: - Enables or disables ICMP redirect messages on the interface. required: false default: null - type: str + type: bool qos_adaptive: description: - Activates or deactivates adaptive QoS on the interface. required: false default: null - type: str + type: bool period: description: - Time period in seconds for measuring and adapting QoS settings. @@ -922,7 +922,7 @@ class ModuleDocFragment(object): IP addresses. required: false default: null - type: str + type: bool rule_name: description: - Specifies the name of the rewrite rule applied to the interface. @@ -988,19 +988,19 @@ class ModuleDocFragment(object): - VRRP group ID. required: true default: null - type: str + type: int priority: description: - Priority value for the VRRP group (higher values take precedence). required: false default: null - type: str + type: int timer: description: - VRRP advertisement interval timer in milliseconds. required: false default: null - type: str + type: int track_omp: description: - Flag to track Overlay Management Protocol (OMP) session @@ -1045,7 +1045,7 @@ class ModuleDocFragment(object): - VRRP value to determine the primary node for the VRRP group. required: true default: null - type: str + type: int tracking_object: description: - List of tracking objects associated with the VRRP configuration. @@ -1059,7 +1059,7 @@ class ModuleDocFragment(object): - Unique identifier for the tracking object. required: true default: null - type: str + type: int track_action: description: - Action to take when the tracked object state changes @@ -1076,7 +1076,7 @@ class ModuleDocFragment(object): the tracked object is down. required: true default: null - type: str + type: int ipv6_vrrp: description: - A list of Virtual Router Redundancy Protocol (VRRP) configurations @@ -1091,20 +1091,20 @@ class ModuleDocFragment(object): - IPv6 VRRP group ID. required: true default: null - type: str + type: int priority: description: - Priority value for the IPv6 VRRP group (higher values take precedence). required: false default: null - type: str + type: int timer: description: - IPv6 VRRP advertisement interval timer in milliseconds. required: false default: null - type: str + type: int track_omp: description: - Flag to track Overlay Management Protocol (OMP) session @@ -1145,7 +1145,7 @@ class ModuleDocFragment(object): - Enables or disables Security Group Tag (SGT) propagation. required: false default: null - type: str + type: bool security_group_tag: description: - Specifies a static Security Group Tag (SGT) for the interface. @@ -1157,19 +1157,19 @@ class ModuleDocFragment(object): - Marks the interface as trusted or untrusted for TrustSec. required: false default: null - type: str + type: bool enable_sgt_authorization_and_forwarding: description: - Enables or disables Security Group Tag (SGT) authorization and forwarding. required: false default: null - type: str + type: bool enable_sgt_enforcement: description: - Activates or deactivates Security Group Tag (SGT) enforcement. required: false default: null - type: str + type: bool enforcement_sgt: description: - Specifies the Security Group Tag (SGT) to be enforced on the interface. diff --git a/plugins/doc_fragments/feature_template_omp_vsmart.py b/plugins/doc_fragments/feature_template_omp_vsmart.py index ca94a83..8273468 100644 --- a/plugins/doc_fragments/feature_template_omp_vsmart.py +++ b/plugins/doc_fragments/feature_template_omp_vsmart.py @@ -22,7 +22,7 @@ class ModuleDocFragment(object): - Enable or disable graceful restart for the OMP session required: false default: null - type: str + type: bool send_path_limit: description: - The maximum number of paths that can be sent to a TLOC @@ -34,20 +34,20 @@ class ModuleDocFragment(object): - Enable or disable sending additional backup paths required: false default: null - type: str + type: bool discard_rejected: description: - Discard routes that are rejected by policy instead of marking them as rejected required: false default: null - type: str + type: bool shutdown: description: - Enable or disable the shutdown of the OMP session required: false default: null - type: str + type: bool graceful_restart_timer: description: - The time interval for graceful restart of OMP sessions @@ -71,7 +71,7 @@ class ModuleDocFragment(object): - Prefer routes from the same affinity group required: false default: null - type: str + type: bool advertisement_interval: description: - Interval between sending OMP route advertisements diff --git a/plugins/module_utils/feature_templates/cisco_aaa.py b/plugins/module_utils/feature_templates/cisco_aaa.py index bf07afe..2630f40 100644 --- a/plugins/module_utils/feature_templates/cisco_aaa.py +++ b/plugins/module_utils/feature_templates/cisco_aaa.py @@ -1,10 +1,60 @@ cisco_aaa_definition = { 'cisco_aaa': { 'default': None, - 'options': { 'accounting_group': { 'default': None, + 'options': { 'accounting_group': { 'default': False, 'required': False, 'type': 'bool'}, - 'authentication_group': { 'default': None, + 'accounting_rules': { 'default': None, + 'elements': 'dict', + 'options': { 'group': { 'default': None, + 'required': True, + 'type': 'str'}, + 'level': { 'default': None, + 'required': False, + 'type': 'str'}, + 'method': { 'default': None, + 'required': True, + 'type': 'str'}, + 'rule_id': { 'default': None, + 'required': True, + 'type': 'str'}, + 'start_stop': { 'default': True, + 'required': False, + 'type': 'bool'}}, + 'required': False, + 'type': 'list'}, + 'authentication_group': { 'default': False, 'required': False, 'type': 'bool'}, + 'authentication_type': { 'default': 'any', + 'required': False, + 'type': 'str'}, + 'authorization_config_commands': { 'default': None, + 'required': False, + 'type': 'bool'}, + 'authorization_console': { 'default': None, + 'required': False, + 'type': 'bool'}, + 'authorization_rules': { 'default': None, + 'elements': 'dict', + 'options': { 'authenticated': { 'default': False, + 'required': False, + 'type': 'bool'}, + 'group': { 'default': None, + 'required': True, + 'type': 'str'}, + 'level': { 'default': None, + 'required': False, + 'type': 'str'}, + 'method': { 'default': None, + 'required': True, + 'type': 'str'}, + 'rule_id': { 'default': None, + 'required': True, + 'type': 'str'}}, + 'required': False, + 'type': 'list'}, + 'cts_authorization_list': { 'default': None, + 'required': False, + 'type': 'str'}, 'domain_stripping': { 'default': None, 'required': False, 'type': 'str'}, @@ -20,13 +70,13 @@ 'elements': 'dict', 'options': { 'acct_port': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'address': { 'default': None, 'required': True, 'type': 'str'}, 'auth_port': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'key': { 'default': None, 'required': True, 'type': 'str'}, @@ -38,13 +88,13 @@ 'type': 'str'}, 'retransmit': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'secret_key': { 'default': None, 'required': False, 'type': 'str'}, 'timeout': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'source_interface': { 'default': None, @@ -55,10 +105,32 @@ 'type': 'str'}}, 'required': False, 'type': 'list'}, - 'server_auth_order': { 'default': None, - 'elements': 'str', + 'radius_client': { 'default': None, + 'elements': 'dict', + 'options': { 'ip': { 'default': None, + 'required': True, + 'type': 'str'}, + 'vpn': { 'default': None, + 'elements': 'dict', + 'options': { 'name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'server_key': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': True, + 'type': 'list'}}, + 'required': False, + 'type': 'list'}, + 'radius_trustsec_group': { 'default': None, + 'required': False, + 'type': 'str'}, + 'server_auth_order': { 'default': 'local', 'required': False, - 'type': 'list'}, + 'type': 'str'}, + 'server_key_password': { 'default': None, + 'required': False, + 'type': 'str'}, 'tacacs': { 'default': None, 'elements': 'dict', 'options': { 'group_name': { 'default': None, @@ -77,13 +149,13 @@ 'type': 'str'}, 'port': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'secret_key': { 'default': None, 'required': False, 'type': 'str'}, 'timeout': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'source_interface': { 'default': None, @@ -91,7 +163,7 @@ 'type': 'str'}, 'vpn': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'user': { 'default': None, @@ -102,11 +174,17 @@ 'password': { 'default': None, 'required': False, 'type': 'str'}, - 'privilege': { 'default': None, + 'privilege': { 'default': '15', 'required': False, 'type': 'str'}, 'pubkey_chain': { 'default': [ ], - 'elements': 'str', + 'elements': 'dict', + 'options': { 'key_string': { 'default': None, + 'required': True, + 'type': 'str'}, + 'key_type': { 'default': 'ssh-rsa', + 'required': False, + 'type': 'str'}}, 'required': False, 'type': 'list'}, 'secret': { 'default': None, diff --git a/plugins/module_utils/feature_templates/cisco_bfd.py b/plugins/module_utils/feature_templates/cisco_bfd.py index 93b4f37..c2767d2 100644 --- a/plugins/module_utils/feature_templates/cisco_bfd.py +++ b/plugins/module_utils/feature_templates/cisco_bfd.py @@ -13,9 +13,9 @@ 'multiplier': { 'default': None, 'required': False, 'type': 'str'}, - 'pmtu_discovery': { 'default': None, + 'pmtu_discovery': { 'default': True, 'required': False, - 'type': 'str'}}, + 'type': 'bool'}}, 'required': False, 'type': 'list'}, 'default_dscp': { 'default': None, diff --git a/plugins/module_utils/feature_templates/cisco_logging.py b/plugins/module_utils/feature_templates/cisco_logging.py index 423d827..2608fb3 100644 --- a/plugins/module_utils/feature_templates/cisco_logging.py +++ b/plugins/module_utils/feature_templates/cisco_logging.py @@ -1,15 +1,15 @@ cisco_logging_definition = { 'cisco_logging': { 'default': None, 'options': { 'enable': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'ipv6_server': { 'default': None, 'elements': 'dict', - 'options': { 'custom_profile': { 'default': None, + 'options': { 'custom_profile': { 'default': False, 'required': False, - 'type': 'str'}, - 'enable_tls': { 'default': None, + 'type': 'bool'}, + 'enable_tls': { 'default': False, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'name': { 'default': None, 'required': True, 'type': 'str'}, @@ -32,12 +32,12 @@ 'type': 'str'}, 'server': { 'default': None, 'elements': 'dict', - 'options': { 'custom_profile': { 'default': None, + 'options': { 'custom_profile': { 'default': False, 'required': False, - 'type': 'str'}, - 'enable_tls': { 'default': None, + 'type': 'bool'}, + 'enable_tls': { 'default': False, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'name': { 'default': None, 'required': True, 'type': 'str'}, diff --git a/plugins/module_utils/feature_templates/cisco_ntp.py b/plugins/module_utils/feature_templates/cisco_ntp.py index 321b93a..d29ba18 100644 --- a/plugins/module_utils/feature_templates/cisco_ntp.py +++ b/plugins/module_utils/feature_templates/cisco_ntp.py @@ -6,12 +6,12 @@ 'type': 'str'}, 'number': { 'default': None, 'required': True, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'enable': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'server': { 'default': [], 'elements': 'dict', 'options': { 'key': { 'default': None, @@ -22,7 +22,7 @@ 'type': 'str'}, 'prefer': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'source_interface': { 'default': None, 'required': False, 'type': 'str'}, diff --git a/plugins/module_utils/feature_templates/cisco_omp.py b/plugins/module_utils/feature_templates/cisco_omp.py index 358c5c0..e0c6bb0 100644 --- a/plugins/module_utils/feature_templates/cisco_omp.py +++ b/plugins/module_utils/feature_templates/cisco_omp.py @@ -12,27 +12,27 @@ 'advertisement_interval': { 'default': None, 'required': False, 'type': 'str'}, - 'auto_translate': { 'default': None, + 'auto_translate': { 'default': False, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'ecmp_limit': { 'default': None, 'required': False, 'type': 'str'}, 'eor_timer': { 'default': None, 'required': False, 'type': 'str'}, - 'graceful_restart': { 'default': None, + 'graceful_restart': { 'default': True, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'graceful_restart_timer': { 'default': None, 'required': False, 'type': 'str'}, 'holdtime': { 'default': None, 'required': False, 'type': 'str'}, - 'ignore_region_path_length': { 'default': None, + 'ignore_region_path_length': { 'default': False, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'ipv6_advertise': { 'default': None, 'elements': 'dict', 'options': { 'protocol': { 'default': None, @@ -54,7 +54,7 @@ 'type': 'str'}, 'shutdown': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'site_types': { 'default': None, 'elements': 'str', 'required': False, diff --git a/plugins/module_utils/feature_templates/cisco_ospf.py b/plugins/module_utils/feature_templates/cisco_ospf.py index fae5255..5012f3e 100644 --- a/plugins/module_utils/feature_templates/cisco_ospf.py +++ b/plugins/module_utils/feature_templates/cisco_ospf.py @@ -1,12 +1,12 @@ cisco_ospf_definition = { 'cisco_ospf': { 'default': None, 'options': { 'always': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'area': { 'default': None, 'elements': 'dict', 'options': { 'a_num': { 'default': None, 'required': True, - 'type': 'str'}, + 'type': 'int'}, 'interface': { 'default': None, 'elements': 'dict', 'options': { 'cost': { 'default': None, @@ -30,9 +30,9 @@ 'network': { 'default': 'broadcast', 'required': False, 'type': 'str'}, - 'passive_interface': { 'default': None, + 'passive_interface': { 'default': False, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'priority': { 'default': None, 'required': False, 'type': 'str'}, @@ -46,7 +46,7 @@ 'type': 'list'}, 'nssa': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'range': { 'default': None, 'elements': 'dict', 'options': { 'address': { 'default': None, @@ -55,14 +55,14 @@ 'cost': { 'default': None, 'required': False, 'type': 'str'}, - 'no_advertise': { 'default': None, + 'no_advertise': { 'default': False, 'required': False, - 'type': 'str'}}, + 'type': 'bool'}}, 'required': False, 'type': 'list'}, 'stub': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'bool'}}, 'required': False, 'type': 'list'}, 'delay': { 'default': None, @@ -91,12 +91,12 @@ 'type': 'str'}, 'originate': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'redistribute': { 'default': None, 'elements': 'dict', - 'options': { 'dia': { 'default': None, + 'options': { 'dia': { 'default': True, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'protocol': { 'default': None, 'required': True, 'type': 'str'}, @@ -108,9 +108,9 @@ 'reference_bandwidth': { 'default': None, 'required': False, 'type': 'str'}, - 'rfc1583': { 'default': None, + 'rfc1583': { 'default': True, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'route_policy': { 'default': None, 'elements': 'dict', 'options': { 'direction': { 'default': None, @@ -131,7 +131,7 @@ 'type': 'str'}, 'time': { 'default': None, 'required': True, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}}, 'required': False, diff --git a/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py b/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py index 860ab51..0d49278 100644 --- a/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py +++ b/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py @@ -39,7 +39,7 @@ 'type': 'str'}, 'ike_version': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'ipsec_ciphersuite': { 'default': 'aes256-gcm', 'required': False, 'type': 'str'}, @@ -51,7 +51,7 @@ 'type': 'str'}, 'mtu': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'perfect_forward_secrecy': { 'default': 'none', 'required': False, 'type': 'str'}, @@ -107,10 +107,10 @@ 'caution_enabled': { 'default': None, 'required': False, 'type': 'str'}, - 'data_center_primary': { 'default': None, + 'data_center_primary': { 'default': 'Auto', 'required': False, 'type': 'str'}, - 'data_center_secondary': { 'default': None, + 'data_center_secondary': { 'default': 'Auto', 'required': False, 'type': 'str'}, 'display_time_unit': { 'default': 'MINUTE', @@ -132,13 +132,13 @@ 'type': 'str'}, 'active_interface_weight': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'backup_interface': { 'default': None, 'required': False, 'type': 'str'}, 'backup_interface_weight': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'int'}}, 'required': True, 'type': 'list'}, 'ip': { 'default': None, @@ -153,7 +153,7 @@ 'ofw_enabled': { 'default': None, 'required': False, 'type': 'str'}, - 'primary_data_center': { 'default': None, + 'primary_data_center': { 'default': 'Auto', 'required': False, 'type': 'str'}, 'refresh_time': { 'default': None, @@ -162,7 +162,7 @@ 'refresh_time_unit': { 'default': 'MINUTE', 'required': False, 'type': 'str'}, - 'secondary_data_center': { 'default': None, + 'secondary_data_center': { 'default': 'Auto', 'required': False, 'type': 'str'}, 'svc_type': { 'default': 'sig', @@ -203,6 +203,6 @@ 'type': 'str'}, 'vpn_id': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'dict'}} diff --git a/plugins/module_utils/feature_templates/cisco_snmp.py b/plugins/module_utils/feature_templates/cisco_snmp.py index 37957a9..4c253a0 100644 --- a/plugins/module_utils/feature_templates/cisco_snmp.py +++ b/plugins/module_utils/feature_templates/cisco_snmp.py @@ -13,7 +13,7 @@ 'required': False, 'type': 'list'}, 'contact': { 'default': None, - 'required': True, + 'required': False, 'type': 'str'}, 'group': { 'default': None, 'elements': 'dict', @@ -29,40 +29,40 @@ 'required': False, 'type': 'list'}, 'location': { 'default': None, - 'required': True, - 'type': 'str'}, - 'shutdown': { 'default': None, 'required': False, 'type': 'str'}, + 'shutdown': { 'default': True, + 'required': False, + 'type': 'bool'}, 'target': { 'default': None, 'elements': 'dict', 'options': { 'community_name': { 'default': None, - 'required': True, + 'required': False, 'type': 'str'}, 'ip': { 'default': None, 'required': True, 'type': 'str'}, 'port': { 'default': None, 'required': True, - 'type': 'str'}, + 'type': 'int'}, 'source_interface': { 'default': None, - 'required': True, + 'required': False, 'type': 'str'}, 'user': { 'default': None, - 'required': True, + 'required': False, 'type': 'str'}, 'vpn_id': { 'default': None, 'required': True, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'user': { 'default': None, 'elements': 'dict', 'options': { 'auth': { 'default': None, - 'required': True, + 'required': False, 'type': 'str'}, 'auth_password': { 'default': None, - 'required': True, + 'required': False, 'type': 'str'}, 'group': { 'default': None, 'required': True, @@ -74,7 +74,7 @@ 'required': True, 'type': 'str'}, 'priv_password': { 'default': None, - 'required': True, + 'required': False, 'type': 'str'}}, 'required': False, 'type': 'list'}, @@ -86,12 +86,12 @@ 'oid': { 'default': None, 'elements': 'dict', 'options': { 'exclude': { 'default': None, - 'required': True, - 'type': 'str'}, + 'required': False, + 'type': 'bool'}, 'id': { 'default': None, 'required': True, 'type': 'str'}}, - 'required': True, + 'required': False, 'type': 'list'}}, 'required': False, 'type': 'list'}}, diff --git a/plugins/module_utils/feature_templates/cisco_system.py b/plugins/module_utils/feature_templates/cisco_system.py index 7e67ea7..376bce9 100644 --- a/plugins/module_utils/feature_templates/cisco_system.py +++ b/plugins/module_utils/feature_templates/cisco_system.py @@ -1,7 +1,7 @@ cisco_system_definition = { 'cisco_system': { 'default': None, 'options': { 'admin_tech_on_failure': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'affinity_group_number': { 'default': None, 'required': False, 'type': 'str'}, @@ -31,23 +31,23 @@ 'type': 'list'}, 'enable_fencing': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'enable_management_region': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'enable_mrf_migration': { 'default': None, 'required': False, 'type': 'str'}, - 'enable_sms': { 'default': None, + 'enable_sms': { 'default': False, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'enable_tunnel': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'epfr': { 'default': None, 'required': False, 'type': 'str'}, - 'hostname': { 'default': None, + 'hostname': { 'default': 'system_host_name', 'options': { 'name': { 'default': None, 'required': True, 'type': 'str'}}, @@ -67,7 +67,7 @@ 'type': 'str'}, 'management_gateway': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'max_omp_sessions': { 'default': None, 'required': False, 'type': 'str'}, @@ -83,7 +83,7 @@ 'type': 'list'}, 'multi_tenant': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'object_track': { 'default': None, 'elements': 'dict', 'options': { 'boolean': { 'default': None, @@ -95,25 +95,25 @@ 'ip': { 'default': None, 'required': True, 'type': 'str'}, - 'mask': { 'default': None, + 'mask': { 'default': '0.0.0.0', 'required': False, 'type': 'str'}, 'object': { 'default': None, 'elements': 'dict', 'options': { 'number': { 'default': None, 'required': True, - 'type': 'str'}}, + 'type': 'int'}}, 'required': True, 'type': 'list'}, 'object_number': { 'default': None, 'required': True, - 'type': 'str'}, + 'type': 'int'}, 'sig': { 'default': None, 'required': True, 'type': 'str'}, 'vpn': { 'default': None, 'required': True, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'on_demand_idle_timeout_min': { 'default': None, @@ -124,7 +124,7 @@ 'type': 'str'}, 'port_hop': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'port_offset': { 'default': None, 'required': False, 'type': 'str'}, @@ -134,7 +134,7 @@ 'type': 'list'}, 'preference_auto': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'range': { 'default': None, 'required': False, 'type': 'str'}, @@ -147,14 +147,14 @@ 'secondary_region': { 'default': None, 'required': False, 'type': 'str'}, - 'site_id': { 'default': None, + 'site_id': { 'default': 'system_site_id', 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'site_type': { 'default': None, 'elements': 'str', 'required': False, 'type': 'list'}, - 'system_ip': { 'default': None, + 'system_ip': { 'default': 'system_system_ip', 'options': { 'name': { 'default': None, 'required': True, 'type': 'str'}}, @@ -165,13 +165,13 @@ 'type': 'str'}, 'track_default_gateway': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'track_interface_tag': { 'default': None, 'required': False, 'type': 'str'}, 'track_transport': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'tracker': { 'default': None, 'elements': 'dict', 'options': { 'boolean': { 'default': 'or', @@ -218,7 +218,7 @@ 'type': 'list'}, 'transport_gateway': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'vrf': { 'default': None, 'elements': 'dict', 'options': { 'gateway_preference': { 'default': None, @@ -227,7 +227,7 @@ 'type': 'list'}, 'vrf_id': { 'default': None, 'required': True, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}}, 'required': False, diff --git a/plugins/module_utils/feature_templates/cisco_vpn.py b/plugins/module_utils/feature_templates/cisco_vpn.py index f6ae887..7536213 100644 --- a/plugins/module_utils/feature_templates/cisco_vpn.py +++ b/plugins/module_utils/feature_templates/cisco_vpn.py @@ -57,7 +57,7 @@ 'type': 'str'}, 'vpn': { 'default': None, 'required': True, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'host': { 'default': None, @@ -82,7 +82,7 @@ 'type': 'str'}, 'vpn': { 'default': None, 'required': True, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'ipv6_advertise': { 'default': None, @@ -122,7 +122,7 @@ 'type': 'str'}, 'name': { 'default': None, 'required': True, - 'type': 'str'}, + 'type': 'int'}, 'overload': { 'default': 'true', 'required': False, 'type': 'str'}, @@ -187,13 +187,13 @@ 'type': 'str'}, 'source_port': { 'default': None, 'required': True, - 'type': 'str'}, + 'type': 'int'}, 'translate_ip': { 'default': None, 'required': True, 'type': 'str'}, 'translate_port': { 'default': None, 'required': True, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'route_export': { 'default': None, @@ -268,7 +268,7 @@ 'type': 'str'}, 'source_vpn': { 'default': None, 'required': True, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'route_v4': { 'default': None, @@ -369,7 +369,7 @@ 'type': 'str'}, 'vpn': { 'default': None, 'required': True, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'static': { 'default': None, @@ -395,7 +395,7 @@ 'elements': 'dict', 'options': { 'prefix_length': { 'default': None, 'required': True, - 'type': 'str'}, + 'type': 'int'}, 'source_ip_subnet': { 'default': None, 'required': True, 'type': 'str'}, @@ -415,7 +415,7 @@ 'type': 'str'}, 'vpn_id': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'vpn_name': { 'default': None, 'required': False, 'type': 'str'}}, diff --git a/plugins/module_utils/feature_templates/cisco_vpn_interface.py b/plugins/module_utils/feature_templates/cisco_vpn_interface.py index 0568658..bcd7513 100644 --- a/plugins/module_utils/feature_templates/cisco_vpn_interface.py +++ b/plugins/module_utils/feature_templates/cisco_vpn_interface.py @@ -21,16 +21,16 @@ 'type': 'list'}, 'all': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'arp_timeout': { 'default': None, 'required': False, 'type': 'str'}, 'auto_bandwidth_detect': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'autonegotiate': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'bandwidth_down': { 'default': None, 'required': False, 'type': 'str'}, @@ -45,31 +45,31 @@ 'type': 'str'}, 'bgp': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'bind': { 'default': None, 'required': False, 'type': 'str'}, 'block_non_source_ip': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'border': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'carrier': { 'default': None, 'required': False, 'type': 'str'}, 'clear_dont_fragment': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'control_connections': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'core_region': { 'default': None, 'required': False, 'type': 'str'}, 'dhcp': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'dhcp_distance': { 'default': None, 'required': False, 'type': 'str'}, @@ -89,10 +89,10 @@ 'type': 'list'}, 'dhcp_ipv4_client': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'dhcp_ipv6_client': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'dmax': { 'default': None, 'required': False, 'type': 'str'}, @@ -101,7 +101,7 @@ 'type': 'str'}, 'dns': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'dst_ip': { 'default': None, 'required': False, 'type': 'str'}, @@ -110,19 +110,19 @@ 'type': 'str'}, 'enable': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'enable_core_region': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'enable_sgt_authorization_and_forwarding': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'enable_sgt_enforcement': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'enable_sgt_propagation': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'enforcement_sgt': { 'default': None, 'required': False, 'type': 'str'}, @@ -142,13 +142,13 @@ 'type': 'str'}, 'https': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'icmp': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'icmp_redirect_disable': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'if_name': { 'default': None, 'required': False, 'type': 'str'}, @@ -170,7 +170,7 @@ 'type': 'list'}, 'ip_directed_broadcast': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'iperf_server': { 'default': None, 'required': False, 'type': 'str'}, @@ -184,7 +184,7 @@ 'elements': 'dict', 'options': { 'grp_id': { 'default': None, 'required': True, - 'type': 'str'}, + 'type': 'int'}, 'ipv6': { 'default': None, 'elements': 'dict', 'options': { 'ipv6_link_local': { 'default': None, @@ -197,10 +197,10 @@ 'type': 'list'}, 'priority': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'timer': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'track_omp': { 'default': None, 'required': False, 'type': 'bool'}, @@ -211,7 +211,7 @@ 'type': 'list'}, 'last_resort_circuit': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'load_interval': { 'default': None, 'required': False, 'type': 'str'}, @@ -220,7 +220,7 @@ 'type': 'str'}, 'low_bandwidth_link': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'mac_address': { 'default': None, 'required': False, 'type': 'str'}, @@ -238,13 +238,13 @@ 'type': 'str'}, 'nat': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'nat64': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'nat66': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'nat_choice': { 'default': None, 'required': False, 'type': 'str'}, @@ -259,43 +259,43 @@ 'type': 'str'}, 'netconf': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'network_broadcast': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'ntp': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'ospf': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'overload': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'per_tunnel_qos': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'per_tunnel_qos_aggregator': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'period': { 'default': None, 'required': False, 'type': 'str'}, 'poe': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'port_hop': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'prefix_length': { 'default': None, 'required': False, 'type': 'str'}, 'propagate_sgt': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'qos_adaptive': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'qos_map': { 'default': None, 'required': False, 'type': 'str'}, @@ -304,7 +304,7 @@ 'type': 'str'}, 'restrict': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'rule_name': { 'default': None, 'required': False, 'type': 'str'}, @@ -334,12 +334,12 @@ 'shaping_rate': { 'default': None, 'required': False, 'type': 'str'}, - 'shutdown': { 'default': None, + 'shutdown': { 'default': False, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'snmp': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'speed': { 'default': None, 'required': False, 'type': 'str'}, @@ -348,7 +348,7 @@ 'type': 'str'}, 'sshd': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'static': { 'default': None, 'elements': 'dict', 'options': { 'source_ip': { 'default': None, @@ -356,7 +356,7 @@ 'type': 'str'}, 'source_vpn': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'static_nat_direction': { 'default': 'inside', 'required': False, 'type': 'str'}, @@ -372,7 +372,7 @@ 'type': 'str'}, 'source_vpn_id': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'translated_source_prefix': { 'default': None, 'required': True, 'type': 'str'}}, @@ -388,10 +388,10 @@ 'type': 'str'}, 'source_port': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'source_vpn': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'static_nat_direction': { 'default': 'inside', 'required': False, 'type': 'str'}, @@ -400,12 +400,12 @@ 'type': 'str'}, 'translate_port': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'stun': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'tcp_mss_adjust': { 'default': None, 'required': False, 'type': 'str'}, @@ -422,7 +422,7 @@ 'type': 'str'}, 'weight': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'tloc_extension': { 'default': None, @@ -434,7 +434,7 @@ 'type': 'list'}, 'trusted': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'tunnel_tcp_mss_adjust': { 'default': None, 'required': False, 'type': 'str'}, @@ -455,7 +455,7 @@ 'type': 'str'}, 'vbond_as_stun_server': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'vmanage_connection_preference': { 'default': None, 'required': False, 'type': 'str'}, @@ -466,7 +466,7 @@ 'type': 'str'}, 'grp_id': { 'default': None, 'required': True, - 'type': 'str'}, + 'type': 'int'}, 'ipv4_secondary': { 'default': None, 'elements': 'dict', 'options': { 'address': { 'default': None, @@ -476,10 +476,10 @@ 'type': 'list'}, 'priority': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'timer': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'tloc_change_pref': { 'default': None, 'required': False, 'type': 'bool'}, @@ -493,10 +493,10 @@ 'elements': 'dict', 'options': { 'decrement': { 'default': None, 'required': True, - 'type': 'str'}, + 'type': 'int'}, 'name': { 'default': None, 'required': True, - 'type': 'str'}, + 'type': 'int'}, 'track_action': { 'default': 'Decrement', 'required': False, 'type': 'str'}}, @@ -504,7 +504,7 @@ 'type': 'list'}, 'value': { 'default': None, 'required': True, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'xconnect': { 'default': None, diff --git a/plugins/module_utils/feature_templates/omp_vsmart.py b/plugins/module_utils/feature_templates/omp_vsmart.py index ee29739..f44f841 100644 --- a/plugins/module_utils/feature_templates/omp_vsmart.py +++ b/plugins/module_utils/feature_templates/omp_vsmart.py @@ -4,16 +4,16 @@ 'type': 'str'}, 'affinity_group_preference': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'discard_rejected': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'eor_timer': { 'default': None, 'required': False, 'type': 'str'}, 'graceful_restart': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'graceful_restart_timer': { 'default': None, 'required': False, 'type': 'str'}, @@ -22,12 +22,12 @@ 'type': 'str'}, 'send_backup_paths': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'send_path_limit': { 'default': None, 'required': False, 'type': 'str'}, 'shutdown': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'bool'}}, 'required': False, 'type': 'dict'}} diff --git a/plugins/modules/feature_templates.py b/plugins/modules/feature_templates.py index b7e6af1..f3052d1 100644 --- a/plugins/modules/feature_templates.py +++ b/plugins/modules/feature_templates.py @@ -75,6 +75,8 @@ from ..module_utils.feature_templates.cisco_ntp import cisco_ntp_definition from ..module_utils.feature_templates.cisco_omp import cisco_omp_definition from ..module_utils.feature_templates.cisco_ospf import cisco_ospf_definition +from ..module_utils.feature_templates.cisco_system import cisco_system_definition + class ExtendedModuleResult(ModuleResult): templates_info: Optional[Dict] = Field(default={}) diff --git a/utils/ft_generator.py b/utils/ft_generator.py index 97e9b35..9a5fc3e 100644 --- a/utils/ft_generator.py +++ b/utils/ft_generator.py @@ -1,11 +1,12 @@ # Copyright 2024 Cisco Systems, Inc. and its affiliates # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import annotations import yaml from enum import Enum -from typing import Type, Union, get_args, get_origin +from typing import Annotated, Type, Union, get_args, get_origin, Literal from pathlib import Path, PurePath from pprint import pformat from jinja2 import Environment, FileSystemLoader @@ -13,6 +14,7 @@ from pydantic.fields import FieldInfo from catalystwan.api.templates.models.supported import available_models +from catalystwan.api.templates.device_variable import DeviceVariable from catalystwan.utils.device_model import DeviceModel PROJECT_ROOT_DIR = PurePath(Path.cwd()) @@ -32,23 +34,27 @@ def is_pydantic_model(type_): return False -def field_to_ansible_option(field: FieldInfo): - # # if field.description == "List of public keys for the user": - # if field.description == "A list of site types that are allowed to participate in the overlay network.": +def field_to_ansible_option(field: FieldInfo, field_name: str, model_name: str): + # if field.description == "List of public keys for the user": + # if field.description == "Configure Accounting Method": # from IPython import embed; embed() option = { "description": [field.description], "required": field.is_required(), "default": None, - "type": "str", # default type is str, will be overwritten as needed + "type": None # "str", #None, # default type is None, will be overwritten as needed } if not field.is_required(): if safe_issubclass(field.default, str) or safe_issubclass(field.default, str): option["default"] = field.default - if safe_issubclass(type(field.default), Enum): + elif safe_issubclass(type(field.default), Enum): option["default"] = field.default.value - if safe_issubclass(type(field.default), list): + elif safe_issubclass(type(field.default), str): option["default"] = field.default + elif safe_issubclass(type(field.default), list): + option["default"] = field.default + elif type(field.default) == DeviceVariable: + option["default"] = field.default.name field_type = get_origin(field.annotation) or field.annotation args = get_args(field.annotation) @@ -56,10 +62,13 @@ def field_to_ansible_option(field: FieldInfo): if field_type == bool: option["type"] = "bool" + + elif field_type == int: + option["type"] = "int" elif is_pydantic_model(field_type): option["type"] = "dict" - option["suboptions"] = model_to_ansible_options(field_type) + option["suboptions"] = model_to_ansible_options(field_type, model_name) elif field_type == list or (field_type == Union and list in subargs_base_types): elements_type = next((arg for arg in args if arg is not None), None) @@ -67,7 +76,7 @@ def field_to_ansible_option(field: FieldInfo): # from IPython import embed; embed() option["type"] = "list" option["elements"] = "dict" - option["suboptions"] = model_to_ansible_options(elements_type) + option["suboptions"] = model_to_ansible_options(elements_type, model_name) else: origin_type = get_origin(elements_type) if origin_type == list: @@ -77,28 +86,55 @@ def field_to_ansible_option(field: FieldInfo): if is_pydantic_model(user_class): option["type"] = "list" option["elements"] = "dict" - option["suboptions"] = model_to_ansible_options(user_class) + option["suboptions"] = model_to_ansible_options(user_class, model_name) elif safe_issubclass(user_class, Enum): option["type"] = "list" option["elements"] = "str" - option["choices"] = [item.value for item in user_class] + option["choices"] = [item.value for item in user_class] else: option["type"] = "list" option["elements"] = "str" elif is_pydantic_model(field_type): option["type"] = "dict" - option["suboptions"] = model_to_ansible_options(field_type) + option["suboptions"] = model_to_ansible_options(field_type, model_name) elif safe_issubclass(field_type, Enum): option["type"] = "str" option["choices"] = [item.value for item in field_type] elif field_type == Union and safe_issubclass(next((arg for arg in args if arg is not None), None), Enum): option["type"] = "str" option["choices"] = [item.value for item in args[0]] + elif field_type == Union and Annotated in subargs_base_types: + elements_type = next((arg for arg in args if arg is not None), None) + origin_type = get_origin(elements_type) + if origin_type == Annotated: + user_class = get_args(elements_type)[0] + else: + user_class = None + if user_class == bool: + option["type"] = "bool" + option["default"] = field.default + # from IPython import embed; embed() + # THIS LINE IS NEWEST FOR LITERALS + elif field_type == Union and Literal in subargs_base_types: + elements_type = next((arg for arg in args if arg is not None), None) + option["type"] = "str" + option["choices"] = [item for item in get_args(elements_type)] + elif field_type == Literal: + option["type"] = "str" + option["choices"] = [item for item in args] + else: + print(f"With model: {model_name}, field_name: {field_name} field: {field}") + option["type"] = "str" + if hasattr(field.default, "value"): + option["default"] = field.default.value + # from IPython import embed; embed() + # raise TypeError(f"Cannot properly create field from model: {model_name}, field_name: {field_name} field: {field}") + return option -def model_to_ansible_options(model: Type[BaseModel]): +def model_to_ansible_options(model: Type[BaseModel], model_name: str): options = {} for field_name, field in model.model_fields.items(): if field_name in [ @@ -108,7 +144,7 @@ def model_to_ansible_options(model: Type[BaseModel]): "device_specific_variables", ]: continue - options[field_name] = field_to_ansible_option(field) + options[field_name] = field_to_ansible_option(field, field_name, model_name) return options @@ -120,7 +156,7 @@ def generate_ansible_docs(model: Type[BaseModel], model_name: str): model_name: { "description": model._docs_description.default, "type": "dict", - "suboptions": model_to_ansible_options(model), + "suboptions": model_to_ansible_options(model, model_name), } } } @@ -181,8 +217,12 @@ def to_nice_yaml(data): template_file = PurePath("docs_fragments_template.j2") template = env.get_template(str(template_file)) - - output = template.render(yaml_data=ansible_docs) + try: + output = template.render(yaml_data=ansible_docs) + except Exception as ex: + print(ex) + print(ansible_docs) + raise ex filename = f"{PROJECT_ROOT_DIR}/plugins/doc_fragments/feature_template_{model_name}.py" with open(filename, "w") as f: From 8b4e3062852912ca979be1bb0c0dffa1f87294b7 Mon Sep 17 00:00:00 2001 From: acichon Date: Tue, 7 May 2024 17:48:04 +0200 Subject: [PATCH 08/18] next batch of models for ft --- playbooks/tests/test_feature_templates.yml | 410 +++++++++++++----- .../feature_template_cisco_logging.py | 2 +- ..._template_cisco_secure_internet_gateway.py | 30 +- .../feature_template_cisco_system.py | 8 +- .../feature_template_cisco_vpn.py | 14 +- .../feature_template_system_vsmart.py | 10 +- .../cisco_secure_internet_gateway.py | 29 +- .../feature_templates/cisco_system.py | 3 + .../feature_templates/cisco_vpn.py | 14 +- .../feature_templates/system_vsmart.py | 10 +- plugins/modules/feature_templates.py | 88 +++- utils/ft_generator.py | 8 +- 12 files changed, 432 insertions(+), 194 deletions(-) diff --git a/playbooks/tests/test_feature_templates.yml b/playbooks/tests/test_feature_templates.yml index a35ae63..99a308a 100644 --- a/playbooks/tests/test_feature_templates.yml +++ b/playbooks/tests/test_feature_templates.yml @@ -268,122 +268,249 @@ # manager_credentials: # <<: *manager_authentication - - name: Configure Cisco OMP Feature Template - cisco.catalystwan.feature_templates: - state: present - template_name: "CiscoOMPFeatureTemplate" - template_description: "Comprehensive OMP Configuration" - debug: true - device_models: - - "vedge-C8000V" - cisco_omp: - graceful_restart: true - overlay_as: "65000" - send_path_limit: "10" - ecmp_limit: "8" - shutdown: false - omp_admin_distance_ipv4: "110" - omp_admin_distance_ipv6: "115" - advertisement_interval: "30" - graceful_restart_timer: "120" - eor_timer: "300" - holdtime: "180" - advertise: - - protocol: "bgp" - route: "external" - - protocol: "ospf" - - protocol: "connected" - - protocol: "static" - - protocol: "eigrp" - - protocol: "lisp" - ipv6_advertise: - - protocol: "bgp" - - protocol: "ospf" - - protocol: "connected" - - protocol: "static" - ignore_region_path_length: true - transport_gateway: "prefer" - site_types: - - "type-1" - - "type-2" - - "cloud" - - "branch" - - "spoke" - auto_translate: true - manager_credentials: - <<: *manager_authentication - + # - name: Configure Cisco OMP Feature Template + # cisco.catalystwan.feature_templates: + # state: present + # template_name: "CiscoOMPFeatureTemplate" + # template_description: "Comprehensive OMP Configuration" + # debug: true + # device_models: + # - "vedge-C8000V" + # cisco_omp: + # graceful_restart: true + # overlay_as: "65000" + # send_path_limit: "10" + # ecmp_limit: "8" + # shutdown: false + # omp_admin_distance_ipv4: "110" + # omp_admin_distance_ipv6: "115" + # advertisement_interval: "30" + # graceful_restart_timer: "120" + # eor_timer: "300" + # holdtime: "180" + # advertise: + # - protocol: "bgp" + # route: "external" + # - protocol: "ospf" + # - protocol: "connected" + # - protocol: "static" + # - protocol: "eigrp" + # - protocol: "lisp" + # ipv6_advertise: + # - protocol: "bgp" + # - protocol: "ospf" + # - protocol: "connected" + # - protocol: "static" + # ignore_region_path_length: true + # transport_gateway: "prefer" + # site_types: + # - "type-1" + # - "type-2" + # - "cloud" + # - "branch" + # - "spoke" + # auto_translate: true + # manager_credentials: + # <<: *manager_authentication - - name: Configure Cisco OSPF Feature Template - cisco.catalystwan.feature_templates: - state: present - template_name: "CiscoOSPFeatureTemplate" - template_description: "Comprehensive OSPF Configuration" - device_models: - - "vedge-C8000V" - cisco_ospf: - router_id: "1.1.1.1" - reference_bandwidth: "10000" - rfc1583: false - originate: true - always: true - metric: "10" - metric_type: "type1" - external: "20" - inter_area: "30" - intra_area: "40" - delay: "5" - initial_hold: "10" - max_hold: "40" - redistribute: - - protocol: "static" - route_policy: "static_policy" - dia: true - - protocol: "bgp" - route_policy: "bgp_to_ospf_policy" - dia: false - router_lsa: - - ad_type: "administrative" - time: 10 - route_policy: - - direction: "in" - pol_name: "ospf_in_policy" - area: - - a_num: 0 - stub: false - nssa: true - interface: - - name: "GigabitEthernet0/0" - hello_interval: "10" - dead_interval: "40" - retransmit_interval: "5" - cost: "1" - priority: "1" - network: "broadcast" - passive_interface: false - type: "simple" - message_digest_key: "1" - md5: "md5keystring" - range: - - address: "192.168.1.0/24" - cost: "100" - no_advertise: true - manager_credentials: - <<: *manager_authentication + # - name: Configure Cisco OSPF Feature Template + # cisco.catalystwan.feature_templates: + # state: present + # template_name: "CiscoOSPFeatureTemplate" + # template_description: "Comprehensive OSPF Configuration" + # device_models: + # - "vedge-C8000V" + # cisco_ospf: + # router_id: "1.1.1.1" + # reference_bandwidth: "10000" + # rfc1583: false + # originate: true + # always: true + # metric: "10" + # metric_type: "type1" + # external: "20" + # inter_area: "30" + # intra_area: "40" + # delay: "5" + # initial_hold: "10" + # max_hold: "40" + # redistribute: + # - protocol: "static" + # route_policy: "static_policy" + # dia: true + # - protocol: "bgp" + # route_policy: "bgp_to_ospf_policy" + # dia: false + # router_lsa: + # - ad_type: "administrative" + # time: 10 + # route_policy: + # - direction: "in" + # pol_name: "ospf_in_policy" + # area: + # - a_num: 0 + # stub: false + # nssa: true + # interface: + # - name: "GigabitEthernet0/0" + # hello_interval: "10" + # dead_interval: "40" + # retransmit_interval: "5" + # cost: "1" + # priority: "1" + # network: "broadcast" + # passive_interface: false + # type: "simple" + # message_digest_key: "1" + # md5: "md5keystring" + # range: + # - address: "192.168.1.0/24" + # cost: "100" + # no_advertise: true + # manager_credentials: + # <<: *manager_authentication + # - name: "Configure Secure Internet Gateway feature template" + # cisco.catalystwan.feature_templates: + # state: present + # template_name: "CiscoSecureInternetGatewayFeatureTemplate" + # template_description: "Comprehensive CiscoSecureInternetGateway Configuration" + # debug: true + # device_models: + # - "vedge-C8000V" + # cisco_secure_internet_gateway: + # vpn_id: 10 + # child_org_id: "example_org" + # interface: + # - if_name: "GigabitEthernet0/0" + # auto: true + # shutdown: false + # description: "Main interface for SIG" + # unnumbered: false + # address: "192.168.1.1/24" + # tunnel_source: "192.168.1.1" + # tunnel_source_interface: "Loopback0" + # tunnel_route_via: "192.168.2.1" + # tunnel_destination: "203.0.113.1" + # application: "sig" + # tunnel_set: "secure-internet-gateway-umbrella" + # tunnel_dc_preference: "primary-dc" + # tcp_mss_adjust: "1400" + # mtu: 1400 + # dpd_interval: "30" + # dpd_retries: "3" + # ike_version: 2 + # pre_shared_secret: "MyPreSharedSecret" + # ike_rekey_interval: "3600" + # ike_ciphersuite: "aes256-cbc-sha1" + # ike_group: "14" + # pre_shared_key_dynamic: false + # ike_local_id: "local-id" + # ike_remote_id: "remote-id" + # ipsec_rekey_interval: "3600" + # ipsec_replay_window: "32" + # ipsec_ciphersuite: "aes256-gcm" + # perfect_forward_secrecy: "group-14" + # tracker: true + # track_enable: true + # service: + # - svc_type: "sig" + # interface_pair: + # - active_interface: "GigabitEthernet0/0" + # active_interface_weight: 10 + # backup_interface: "GigabitEthernet0/1" + # backup_interface_weight: 5 + # auth_required: "yes" + # xff_forward_enabled: "yes" + # ofw_enabled: "no" + # ips_control: "yes" + # caution_enabled: "no" + # primary_data_center: "Auto" + # secondary_data_center: "Auto" + # ip: "yes" + # idle_time: "30" + # display_time_unit: "MINUTE" + # ip_enforced_for_known_browsers: "yes" + # refresh_time: "5" + # refresh_time_unit: "MINUTE" + # enabled: "yes" + # block_internet_until_accepted: "no" + # force_ssl_inspection: "yes" + # timeout: "60" + # data_center_primary: "Auto" + # data_center_secondary: "Auto" + # tracker_src_ip: "192.0.2.1" + # tracker: + # - name: "health-check-tracker" + # endpoint_api_url: "https://api.example.com/health" + # threshold: "5" + # interval: "60" + # multiplier: "2" + # tracker_type: "SIG" + # manager_credentials: + # <<: *manager_authentication + # - name: "Configure Cisco SNMP feature template" + # cisco.catalystwan.feature_templates: + # state: present + # template_name: "CiscoSNMPFeatureTemplate" + # template_description: "Comprehensive Cisco SNMP Configuration" + # cisco_snmp: + # shutdown: false + # contact: "SNMP Admin" + # location: "Data Center A" + # view: + # - name: "SystemView" + # oid: + # - id: "1.3.6.1.2.1.1" + # exclude: false + # - id: "1.3.6.1.2.1.2" + # exclude: true + # - name: "AllView" + # oid: + # - id: "1.3.6.1" + # exclude: false + # community: + # - name: "public" + # view: "SystemView" + # authorization: "read-only" + # - name: "private" + # view: "AllView" + # authorization: "read-only" + # group: + # - name: "v3group" + # security_level: "auth-priv" + # view: "AllView" + # user: + # - name: "snmpuser" + # auth: "md5" + # auth_password: "authpass" + # priv: "aes-cfb-128" + # priv_password: "privpass" + # group: "v3group" + # target: + # - vpn_id: 10 + # ip: "192.0.2.50" + # port: 162 + # community_name: "public" + # user: "snmpuser" + # source_interface: "GigabitEthernet0/0" + # manager_credentials: + # <<: *manager_authentication - # INVALID - # - name: Create Comprehensive Cisco System Template + # - name: "Create Comprehensive Cisco System Template" # cisco.catalystwan.feature_templates: # state: present # template_name: "ComprehensiveCiscoSystemTemplate" # template_description: "Cisco System template" # debug: true + # device_models: + # - "vedge-C8000V" # cisco_system: # timezone: "UTC" + # description: "Example desc" # hostname: - # name: "sdwan-hostname" # Replace with the actual hostname + # name: "sdwan-hostname" # location: "Data Center A" # latitude: "37.7749" # longitude: "-122.4194" @@ -397,9 +524,10 @@ # - "group1" # - "group2" # controller_group_list: - # - "controller_group1" + # - 1 + # - 3 # system_ip: - # name: "192.0.2.1" # Replace with the actual system IP + # name: "192.0.2.1" # overlay_id: "1" # site_id: 1001 # site_type: @@ -409,7 +537,7 @@ # port_hop: true # control_session_pps: "500" # track_transport: true - # track_interface_tag: "eth0" + # track_interface_tag: "1" # console_baud_rate: "9600" # max_omp_sessions: "50" # multi_tenant: false @@ -424,16 +552,13 @@ # endpoint_ip_transport_port: "8080" # protocol: "tcp" # port: "443" - # endpoint_dns_name: "example.com" - # endpoint_api_url: "https://api.example.com" # elements: - # - "element1" - # - "element2" + # - "element1, element2" # boolean: "and" # threshold: "10" # interval: "30" # multiplier: "3" - # type: "interface" + # type: "static-route" # object_track: # - object_number: 10 # interface: 'GigabitEthernet0/0/0' @@ -445,6 +570,15 @@ # - number: 101 # boolean: 'and' # - object_number: 20 + # interface: 'GigabitEthernet0/0/0' + # sig: '100' + # ip: '192.0.2.1' + # mask: '255.255.255.0' + # vpn: 1 + # object: + # - number: 101 + # boolean: 'and' + # - object_number: 30 # interface: 'GigabitEthernet0/0/1' # sig: '200' # ip: '198.51.100.1' @@ -460,22 +594,58 @@ # vrf: # - vrf_id: 1 # gateway_preference: - # - '192.0.2.1' - # - '192.0.2.2' + # - 4 + # - 5 # - vrf_id: 2 # gateway_preference: - # - '198.51.100.1' - # - '198.51.100.2' + # - 12 + # - 13 # enable_management_region: true - # migration_bgp_community: '65535:12345' + # migration_bgp_community: 65535 # enable_mrf_migration: enabled # transport_gateway: true # affinity_group_number: 1 # affinity_per_vrf: # - affinity_group_number: 1 # vrf_range: "22" - # role: 'vSmart' - # secondary_region: 'secondaryRegion' - # region_id: 'primaryRegion' + # role: "edge-router" + # # secondary_region: 55 + # # region_id: 44 + # manager_credentials: + # <<: *manager_authentication + + - name: "Create Comprehensive Cisco VPN Interface Template" + cisco.catalystwan.feature_templates: + state: present + template_name: "ComprehensiveCiscoVPNInterfaceTemplate" + template_description: "Cisco VPN Interface template" + device_specific_variables: + ipv4_address: ipv4_address_variable + debug: true + device_models: + - "vedge-C8000V" + cisco_vpn_interface: + if_name: "GigabitEthernet4" + interface_description: "Service or Lan Net interface" + poe: true + ipv4_address: device_specific_variable + manager_credentials: + <<: *manager_authentication + + # # Example of devices specific variables - this works in Feature Templates, need to check Device Templates + # - name: Create Cisco Banner Feature Template + # cisco.catalystwan.feature_templates: + # state: present + # template_name: "CiscoBannerConfigTemplate" + # template_description: "Banner configuration for login and MOTD" + # debug: true + # device_specific_variables: + # login_banner: "var_name_1" + # motd_banner: "var_name_2" + # device_models: + # - "vedge-C8000V" + # cisco_banner: + # login_banner: device_specific_variable + # motd_banner: device_specific_variable # manager_credentials: # <<: *manager_authentication diff --git a/plugins/doc_fragments/feature_template_cisco_logging.py b/plugins/doc_fragments/feature_template_cisco_logging.py index f1b910a..23cfb46 100644 --- a/plugins/doc_fragments/feature_template_cisco_logging.py +++ b/plugins/doc_fragments/feature_template_cisco_logging.py @@ -84,7 +84,7 @@ class ModuleDocFragment(object): suboptions: name: description: - - The name of the server + - The hostname/IPv4 address of the server required: true default: null type: str diff --git a/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py b/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py index 2cabe78..1ab7d25 100644 --- a/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py +++ b/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py @@ -23,6 +23,12 @@ class ModuleDocFragment(object): required: false default: null type: int + child_org_id: + description: + - Child Organization Id + required: false + default: '' + type: str interface: description: - List of interface configurations associated with the service. @@ -246,13 +252,13 @@ class ModuleDocFragment(object): - Flag indicating if interface tracking is enabled. required: false default: null - type: str + type: bool track_enable: description: - Flag indicating if tracking is enabled for the interface. required: false default: null - type: str + type: bool service: description: - List of service configurations for the Cisco Secure Internet Gateway. @@ -309,32 +315,32 @@ class ModuleDocFragment(object): - Flag indicating if authentication is required for the service. required: false default: null - type: str + type: bool xff_forward_enabled: description: - Flag indicating if X-Forwarded-For HTTP header is enabled. required: false default: null - type: str + type: bool ofw_enabled: description: - Flag indicating if on-premise firewall is enabled. required: false default: null - type: str + type: bool ips_control: description: - Flag indicating if Intrusion Prevention System (IPS) control is enabled. required: false default: null - type: str + type: bool caution_enabled: description: - Flag indicating if caution warnings are enabled. required: false default: null - type: str + type: bool primary_data_center: description: - Primary data center for the service. 'Auto' for automatic @@ -355,7 +361,7 @@ class ModuleDocFragment(object): for the service. required: false default: null - type: str + type: bool idle_time: description: - Idle time before a session is considered inactive. @@ -377,7 +383,7 @@ class ModuleDocFragment(object): - Flag indicating if IP is enforced for known browsers. required: false default: null - type: str + type: bool refresh_time: description: - Time after which the service information is refreshed. @@ -399,20 +405,20 @@ class ModuleDocFragment(object): - Flag indicating if the service is enabled. required: false default: null - type: str + type: bool block_internet_until_accepted: description: - Flag indicating if Internet access is blocked until the service is accepted. required: false default: null - type: str + type: bool force_ssl_inspection: description: - Flag indicating if SSL inspection is forced. required: false default: null - type: str + type: bool timeout: description: - Timeout value for the service, after which the session is diff --git a/plugins/doc_fragments/feature_template_cisco_system.py b/plugins/doc_fragments/feature_template_cisco_system.py index 3cb9cef..0f08b46 100644 --- a/plugins/doc_fragments/feature_template_cisco_system.py +++ b/plugins/doc_fragments/feature_template_cisco_system.py @@ -440,6 +440,12 @@ class ModuleDocFragment(object): - Africa/Lusaka - Africa/Harare - UTC + description: + description: + - Set a text description of the device + required: false + default: null + type: str hostname: description: - The hostname for the device. @@ -912,7 +918,7 @@ class ModuleDocFragment(object): type: int gateway_preference: description: - - A list of preferred gateway values for the VRF. + - List of affinity group preferences for VRF required: false default: null type: list diff --git a/plugins/doc_fragments/feature_template_cisco_vpn.py b/plugins/doc_fragments/feature_template_cisco_vpn.py index 72e0779..1cc0ff2 100644 --- a/plugins/doc_fragments/feature_template_cisco_vpn.py +++ b/plugins/doc_fragments/feature_template_cisco_vpn.py @@ -108,7 +108,7 @@ class ModuleDocFragment(object): ECMP hash key. required: false default: null - type: str + type: bool host: description: - A list of host configurations within the VPN instance. @@ -276,7 +276,7 @@ class ModuleDocFragment(object): this static route. required: false default: null - type: str + type: bool distance: description: - The administrative distance for the static route. @@ -294,7 +294,7 @@ class ModuleDocFragment(object): - A flag indicating whether DHCP is used for this static route. required: false default: null - type: str + type: bool route_v6: description: - A list of IPv6 route configurations within the VPN instance. @@ -335,7 +335,7 @@ class ModuleDocFragment(object): for this static route. required: false default: null - type: str + type: bool vpn: description: - The VPN instance identifier associated with the IPv6 static @@ -470,7 +470,7 @@ class ModuleDocFragment(object): be considered. required: false default: null - type: str + type: bool region: description: - The network region where the prefix list is applied. @@ -538,7 +538,7 @@ class ModuleDocFragment(object): be considered. required: false default: null - type: str + type: bool region: description: - The network region where the prefix list is applied. @@ -579,7 +579,7 @@ class ModuleDocFragment(object): - A flag indicating whether address overload is allowed. required: false default: null - type: str + type: bool leak_from_global: description: - A flag indicating whether leaking from the global table diff --git a/plugins/doc_fragments/feature_template_system_vsmart.py b/plugins/doc_fragments/feature_template_system_vsmart.py index e9e6339..58ebfb9 100644 --- a/plugins/doc_fragments/feature_template_system_vsmart.py +++ b/plugins/doc_fragments/feature_template_system_vsmart.py @@ -451,19 +451,19 @@ class ModuleDocFragment(object): - Enable automatic generation of tech-support file on failure required: false default: null - type: str + type: bool iptables_enable: description: - Enable or disable iptables for security required: false default: null - type: str + type: bool track_default_gateway: description: - Enable or disable tracking of the default gateway required: false default: null - type: str + type: bool dns_cache_timeout: description: - DNS cache timeout in minutes @@ -475,7 +475,7 @@ class ModuleDocFragment(object): - Enable or disable tracking of transport connections required: false default: null - type: str + type: bool controller_group_id: description: - Group ID for the vSmart controller @@ -493,7 +493,7 @@ class ModuleDocFragment(object): - Enable or disable port hopping required: false default: null - type: str + type: bool port_offset: description: - Port offset for port hopping diff --git a/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py b/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py index 0d49278..612e46d 100644 --- a/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py +++ b/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py @@ -1,5 +1,8 @@ cisco_secure_internet_gateway_definition = { 'cisco_secure_internet_gateway': { 'default': None, - 'options': { 'interface': { 'default': None, + 'options': { 'child_org_id': { 'default': '', + 'required': False, + 'type': 'str'}, + 'interface': { 'default': None, 'elements': 'dict', 'options': { 'address': { 'default': None, 'required': False, @@ -69,10 +72,10 @@ 'type': 'str'}, 'track_enable': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'tracker': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'tunnel_dc_preference': { 'default': 'primary-dc', 'required': False, 'type': 'str'}, @@ -100,13 +103,13 @@ 'elements': 'dict', 'options': { 'auth_required': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'block_internet_until_accepted': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'caution_enabled': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'data_center_primary': { 'default': 'Auto', 'required': False, 'type': 'str'}, @@ -118,10 +121,10 @@ 'type': 'str'}, 'enabled': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'force_ssl_inspection': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'idle_time': { 'default': None, 'required': False, 'type': 'str'}, @@ -143,16 +146,16 @@ 'type': 'list'}, 'ip': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'ip_enforced_for_known_browsers': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'ips_control': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'ofw_enabled': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'primary_data_center': { 'default': 'Auto', 'required': False, 'type': 'str'}, @@ -173,7 +176,7 @@ 'type': 'str'}, 'xff_forward_enabled': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'bool'}}, 'required': True, 'type': 'list'}, 'tracker': { 'default': None, diff --git a/plugins/module_utils/feature_templates/cisco_system.py b/plugins/module_utils/feature_templates/cisco_system.py index 376bce9..8806451 100644 --- a/plugins/module_utils/feature_templates/cisco_system.py +++ b/plugins/module_utils/feature_templates/cisco_system.py @@ -25,6 +25,9 @@ 'elements': 'str', 'required': False, 'type': 'list'}, + 'description': { 'default': None, + 'required': False, + 'type': 'str'}, 'device_groups': { 'default': None, 'elements': 'str', 'required': False, diff --git a/plugins/module_utils/feature_templates/cisco_vpn.py b/plugins/module_utils/feature_templates/cisco_vpn.py index 7536213..410c1f1 100644 --- a/plugins/module_utils/feature_templates/cisco_vpn.py +++ b/plugins/module_utils/feature_templates/cisco_vpn.py @@ -5,7 +5,7 @@ 'elements': 'dict', 'options': { 'aggregate_only': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'prefix_entry': { 'default': None, 'required': True, 'type': 'str'}, @@ -91,7 +91,7 @@ 'elements': 'dict', 'options': { 'aggregate_only': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'prefix_entry': { 'default': None, 'required': True, 'type': 'str'}, @@ -114,7 +114,7 @@ 'type': 'list'}, 'layer4': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'natpool': { 'default': None, 'elements': 'dict', 'options': { 'direction': { 'default': None, @@ -168,7 +168,7 @@ 'type': 'str'}, 'overload': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'start_address': { 'default': None, 'required': True, 'type': 'str'}}, @@ -275,7 +275,7 @@ 'elements': 'dict', 'options': { 'dhcp': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'distance': { 'default': None, 'required': False, 'type': 'str'}, @@ -304,7 +304,7 @@ 'type': 'list'}, 'null0': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'prefix': { 'default': None, 'required': False, 'type': 'str'}, @@ -333,7 +333,7 @@ 'type': 'list'}, 'null0': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'prefix': { 'default': None, 'required': True, 'type': 'str'}, diff --git a/plugins/module_utils/feature_templates/system_vsmart.py b/plugins/module_utils/feature_templates/system_vsmart.py index a761824..8597af6 100644 --- a/plugins/module_utils/feature_templates/system_vsmart.py +++ b/plugins/module_utils/feature_templates/system_vsmart.py @@ -1,7 +1,7 @@ system_vsmart_definition = { 'system_vsmart': { 'default': None, 'options': { 'admin_tech_on_failure': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'control_session_pps': { 'default': None, 'required': False, 'type': 'str'}, @@ -22,7 +22,7 @@ 'type': 'str'}, 'iptables_enable': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'latitude': { 'default': None, 'required': False, 'type': 'str'}, @@ -37,7 +37,7 @@ 'type': 'str'}, 'port_hop': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'port_offset': { 'default': None, 'required': False, 'type': 'str'}, @@ -55,9 +55,9 @@ 'type': 'str'}, 'track_default_gateway': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'bool'}, 'track_transport': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'bool'}}, 'required': False, 'type': 'dict'}} diff --git a/plugins/modules/feature_templates.py b/plugins/modules/feature_templates.py index f3052d1..63b5b9a 100644 --- a/plugins/modules/feature_templates.py +++ b/plugins/modules/feature_templates.py @@ -34,6 +34,11 @@ - Description for the Feature Template. type: str required: true + device_specific_variables: + description: + - Dictionary containing device specific variables names to be defined in template. + type: dict + required: false debug: description: - If to write payload of created template and response from vmanage as json to file. @@ -48,6 +53,10 @@ - cisco.catalystwan.feature_template_cisco_ntp - cisco.catalystwan.feature_template_cisco_omp - cisco.catalystwan.feature_template_cisco_ospf + - cisco.catalystwan.feature_template_cisco_secure_internet_gateway + - cisco.catalystwan.feature_template_cisco_snmp + - cisco.catalystwan.feature_template_cisco_system + - cisco.catalystwan.feature_template_cisco_vpn_interface - cisco.catalystwan.device_models_feature_template - cisco.catalystwan.manager_authentication author: @@ -56,8 +65,8 @@ from enum import Enum -from pydantic import Field -from typing import Optional, Dict +from pydantic import BaseModel, Field, ConfigDict +from typing import Optional, Dict, Final from catalystwan.api.template_api import FeatureTemplate from catalystwan.dataclasses import FeatureTemplateInfo @@ -68,6 +77,7 @@ from ..module_utils.result import ModuleResult from ..module_utils.vmanage_module import AnsibleCatalystwanModule +from catalystwan.api.templates.device_variable import DeviceVariable from ..module_utils.feature_templates.cisco_aaa import cisco_aaa_definition from ..module_utils.feature_templates.cisco_banner import cisco_banner_definition from ..module_utils.feature_templates.cisco_bfd import cisco_bfd_definition @@ -75,7 +85,12 @@ from ..module_utils.feature_templates.cisco_ntp import cisco_ntp_definition from ..module_utils.feature_templates.cisco_omp import cisco_omp_definition from ..module_utils.feature_templates.cisco_ospf import cisco_ospf_definition +from ..module_utils.feature_templates.cisco_secure_internet_gateway import cisco_secure_internet_gateway_definition +from ..module_utils.feature_templates.cisco_snmp import cisco_snmp_definition from ..module_utils.feature_templates.cisco_system import cisco_system_definition +from ..module_utils.feature_templates.cisco_vpn_interface import cisco_vpn_interface_definition + +ALLOW: Final[str] = "allow" class ExtendedModuleResult(ModuleResult): @@ -88,6 +103,10 @@ class State(str, Enum): ABSENT = "absent" +class Values(BaseModel): + model_config = ConfigDict(extra=ALLOW, populate_by_name=True) + + def run_module(): module_args = dict( state=dict( @@ -99,6 +118,7 @@ def run_module(): template_description=dict(type="str", default=None), device_models=dict(type="list", choices=[device_model.value for device_model in DeviceModel], default=[]), debug=dict(type="bool", default=False), + device_specific_variables=dict(type="raw", default={}), device=dict(type="str", default=None), # For this we need to think how to pass devices **cisco_aaa_definition, **cisco_banner_definition, @@ -107,6 +127,10 @@ def run_module(): **cisco_ntp_definition, **cisco_omp_definition, **cisco_ospf_definition, + **cisco_secure_internet_gateway_definition, + **cisco_snmp_definition, + **cisco_system_definition, + **cisco_vpn_interface_definition, ) result = ExtendedModuleResult() @@ -141,6 +165,7 @@ def run_module(): ) # Verify if we are dealing with one or more templates template_name = module.params.get("template_name") + device_specific_variables = module.params.get("device_specific_variables") module.logger.info(f"Module input: \n{module.params}\n") all_templates: DataSequence[FeatureTemplateInfo] = module.get_response_safely( @@ -158,27 +183,46 @@ def run_module(): ) else: for model_name, model_module in available_models.items(): - if model_name in module.params.keys() and module.params[model_name] is not None: - module.logger.debug(f"Template input:\n{module.params_without_none_values[model_name]}\n") - # Perform action with template - template = model_module( - template_name=template_name, - template_description=module.params.get("template_description"), - device_models=module.params.get("device_models"), - **module.params_without_none_values[model_name], - ) - - module.logger.debug( - f"Prepared template for sending to vManage, template configuration:\n{template}\n" - ) - try: - module.session.api.templates.create(template=template, debug=module.params.get("debug")) - except ManagerHTTPError as ex: - module.fail_json( - msg=f"Could not perform create Feature Template {template_name}.\nManager error: {ex.info}" + if model_name in module.params.keys(): + if module.params[model_name] is not None: + module.logger.debug(f"Template input:\n{module.params_without_none_values[model_name]}\n") + # Perform action with template + + module.logger.debug(f"device_specific_variables:\n{device_specific_variables}\n") + # only temporary part for debugging + configuration = module.params_without_none_values[model_name] + # Check if any device_specific_variables defined + if device_specific_variables: + _dsv = Values() + for key, value in device_specific_variables.items(): + dev_value = DeviceVariable(name=value) + setattr(_dsv, key, dev_value) + module.logger.debug(f"{_dsv}") + + for field, value in configuration.items(): + if value == "device_specific_variable": + module.logger.debug(f"{field}: {value}") + configuration[field] = _dsv.model_extra[field] + module.logger.debug(f"configuration[field]:\n{configuration[field]}\n") + + template = model_module( + template_name=template_name, + template_description=module.params.get("template_description"), + device_models=module.params.get("device_models"), + **configuration, + ) + + module.logger.debug( + f"Prepared template for sending to vManage, template configuration:\n{template}\n" ) - result.changed = True - result.msg += f"Created template {model_name}: {template}" + try: + module.session.api.templates.create(template=template, debug=module.params.get("debug")) + except ManagerHTTPError as ex: + module.fail_json( + msg=f"Could not perform create Feature Template {template_name}.\nManager error: {ex.info}" + ) + result.changed = True + result.msg += f"Created template {model_name}: {template}" if module.params.get("state") == "absent": module.session.api.templates.delete(template=FeatureTemplate, name=template_name) diff --git a/utils/ft_generator.py b/utils/ft_generator.py index 9a5fc3e..abce542 100644 --- a/utils/ft_generator.py +++ b/utils/ft_generator.py @@ -36,7 +36,7 @@ def is_pydantic_model(type_): def field_to_ansible_option(field: FieldInfo, field_name: str, model_name: str): # if field.description == "List of public keys for the user": - # if field.description == "Configure Accounting Method": + # if field.description == "Flag indicating if interface tracking is enabled.": # from IPython import embed; embed() option = { "description": [field.description], @@ -91,6 +91,10 @@ def field_to_ansible_option(field: FieldInfo, field_name: str, model_name: str): option["type"] = "list" option["elements"] = "str" option["choices"] = [item.value for item in user_class] + elif get_origin(user_class) == Literal: + option["type"] = "list" + option["elements"] = "str" + option["choices"] = [item for item in get_args(user_class)] else: option["type"] = "list" option["elements"] = "str" @@ -104,6 +108,8 @@ def field_to_ansible_option(field: FieldInfo, field_name: str, model_name: str): elif field_type == Union and safe_issubclass(next((arg for arg in args if arg is not None), None), Enum): option["type"] = "str" option["choices"] = [item.value for item in args[0]] + elif field_type == Union and bool in args: + option["type"] = "bool" elif field_type == Union and Annotated in subargs_base_types: elements_type = next((arg for arg in args if arg is not None), None) origin_type = get_origin(elements_type) From e0783470e2eb2eebfd809303b74d7d1cc1d852e2 Mon Sep 17 00:00:00 2001 From: acichon Date: Wed, 8 May 2024 13:30:08 +0200 Subject: [PATCH 09/18] next batch of models for ft --- playbooks/tests/test_feature_templates.yml | 435 +++++++++++++++++- .../feature_template_cisco_aaa.py | 4 +- .../feature_template_cisco_bfd.py | 12 +- .../feature_template_cisco_logging.py | 8 +- .../feature_template_cisco_ntp.py | 10 +- .../feature_template_cisco_omp.py | 18 +- .../feature_template_cisco_ospf.py | 30 +- ..._template_cisco_secure_internet_gateway.py | 24 +- .../feature_template_cisco_system.py | 40 +- .../feature_template_cisco_vpn.py | 68 ++- .../feature_template_cisco_vpn_interface.py | 64 +-- .../feature_template_omp_vsmart.py | 20 +- .../feature_template_security_vsmart.py | 2 +- .../feature_template_system_vsmart.py | 262 +++++++++-- .../feature_templates/cisco_aaa.py | 4 +- .../feature_templates/cisco_bfd.py | 12 +- .../feature_templates/cisco_logging.py | 8 +- .../feature_templates/cisco_ntp.py | 10 +- .../feature_templates/cisco_omp.py | 18 +- .../feature_templates/cisco_ospf.py | 30 +- .../cisco_secure_internet_gateway.py | 24 +- .../feature_templates/cisco_system.py | 40 +- .../feature_templates/cisco_vpn.py | 45 +- .../feature_templates/cisco_vpn_interface.py | 64 +-- .../feature_templates/omp_vsmart.py | 17 +- .../feature_templates/security_vsmart.py | 2 +- .../feature_templates/system_vsmart.py | 51 +- plugins/modules/feature_templates.py | 12 + utils/ft_generator.py | 31 +- 29 files changed, 1029 insertions(+), 336 deletions(-) diff --git a/playbooks/tests/test_feature_templates.yml b/playbooks/tests/test_feature_templates.yml index 99a308a..093b641 100644 --- a/playbooks/tests/test_feature_templates.yml +++ b/playbooks/tests/test_feature_templates.yml @@ -260,8 +260,8 @@ # - number: 2 # md5: "md5key2" # trusted: - # - "1" - # - "2" + # - 1 + # - 2 # enable: true # stratum: "2" # source: "Loopback0" @@ -614,21 +614,428 @@ # manager_credentials: # <<: *manager_authentication - - name: "Create Comprehensive Cisco VPN Interface Template" + # - name: "Create Comprehensive Cisco VPN Interface Template" + # cisco.catalystwan.feature_templates: + # state: present + # template_name: "ComprehensiveCiscoVPNInterfaceTemplate" + # template_description: "Cisco VPN Interface template" + # debug: true + # device_models: + # - "vedge-C8000V" + # cisco_vpn_interface: + # if_name: "GigabitEthernet0/0" + # interface_description: "WAN interface" + # poe: true + # ipv4_address: "192.0.2.1/24" + # secondary_ipv4_address: + # - address: "192.0.2.2/24" + # - address: "192.0.2.3/24" + # dhcp_ipv4_client: false + # dhcp_distance: "1" + # ipv6_address: "2001:db8::1/64" + # dhcp_ipv6_client: true + # secondary_ipv6_address: + # - address: "2001:db8::2/64" + # - address: "2001:db8::3/64" + # access_list_ipv4: + # - direction: "in" + # acl_name: "ACL-INBOUND" + # - direction: "out" + # acl_name: "ACL-OUTBOUND" + # dhcp_helper: + # - "192.0.2.254" + # dhcp_helper_v6: + # - address: "2001:db8::1" + # vpn: "0" + # tracker: + # - "Tracker1" + # - "Tracker2" + # auto_bandwidth_detect: true + # iperf_server: "192.0.2.100" + # nat: true + # nat_choice: "Interface" + # udp_timeout: "30" + # tcp_timeout: "60" + # nat_range_start: "192.0.2.100" + # nat_range_end: "192.0.2.200" + # overload: true + # loopback_interface: "Loopback0" + # prefix_length: "24" + # enable: true + # nat64: false + # nat66: false + # static_nat66: + # - source_prefix: "2001:db8:1234::/64" + # translated_source_prefix: "2001:db8:5678::/64" + # source_vpn_id: 10 + # static: + # - source_ip: "192.0.2.1" + # translate_ip: "203.0.113.1" + # static_nat_direction: "inside" + # source_vpn: 10 + # static_port_forward: + # - source_ip: "192.0.2.2" + # translate_ip: "203.0.113.2" + # static_nat_direction: "outside" + # source_port: 8080 + # translate_port: 9090 + # proto: "tcp" + # source_vpn: 10 + # enable_core_region: true + # core_region: "core" + # secondary_region: "secondary-only" + # tloc_encapsulation: + # - encap: "ipsec" + # preference: "100" + # weight: 1 + # border: true + # per_tunnel_qos: true + # per_tunnel_qos_aggregator: true + # mode: "hub" + # tunnels_bandwidth: "1000" + # group: + # - "1" + # - "2" + # value: "mpls" + # max_control_connections: "5" + # control_connections: true + # vbond_as_stun_server: true + # exclude_controller_group_list: + # - "3" + # - "4" + # vmanage_connection_preference: "100" + # port_hop: true + # restrict: false + # dst_ip: "198.51.100.14" + # carrier: "carrier1" + # nat_refresh_interval: "30" + # hello_interval: "10" + # hello_tolerance: "30" + # bind: "GigabitEthernet0/0" + # last_resort_circuit: false + # low_bandwidth_link: false + # tunnel_tcp_mss_adjust: "1360" + # clear_dont_fragment: true + # propagate_sgt: false + # network_broadcast: true + # all: false + # bgp: true + # dhcp: false + # dns: true + # icmp: true + # sshd: true + # netconf: false + # ntp: true + # ospf: false + # stun: false + # snmp: true + # https: true + # media_type: "rj45" + # intrf_mtu: "1500" + # mtu: "1400" + # tcp_mss_adjust: "1360" + # tloc_extension: "100" + # load_interval: "300" + # src_ip: "198.51.100.1" + # xconnect: "10" + # mac_address: "00:0C:29:4B:55:3A" + # speed: "1000" + # duplex: "full" + # shutdown: false + # arp_timeout: "1200" + # autonegotiate: true + # ip_directed_broadcast: false + # icmp_redirect_disable: true + # qos_adaptive: true + # period: "60" + # bandwidth_down: "10000" + # dmin: "5000" + # dmax: "15000" + # bandwidth_up: "5000" + # umin: "2500" + # umax: "7500" + # shaping_rate: "5000" + # qos_map: "default_qos_map" + # qos_map_vpn: "vpn_qos_map" + # service_provider: "ISP1" + # bandwidth_upstream: "5000" + # bandwidth_downstream: "10000" + # block_non_source_ip: true + # rule_name: "rewrite_rule_1" + # access_list_ipv6: + # - direction: "in" + # acl_name: "ipv6_acl_1" + # ip: + # - addr: "192.0.2.1" + # mac: "00:0C:29:4B:55:3A" + # vrrp: + # - grp_id: 1 + # priority: 110 + # timer: 100 + # track_omp: true + # track_prefix_list: "TRACKING_LIST" + # address: "192.0.2.254" + # ipv4_secondary: + # - address: "192.0.2.253" + # tloc_change_pref: true + # value: 20 + # tracking_object: + # - name: 10 + # track_action: "Decrement" + # decrement: 20 + # ipv6_vrrp: + # - grp_id: 1 + # priority: 110 + # timer: 100 + # track_omp: true + # track_prefix_list: "TRACKING_LIST_IPV6" + # ipv6: + # - ipv6_link_local: "FE80::1" + # prefix: "2001:db8::/64" + # enable_sgt_propagation: true + # security_group_tag: "0000" + # trusted: true + # enable_sgt_authorization_and_forwarding: true + # enable_sgt_enforcement: true + # enforcement_sgt: "010001" + # manager_credentials: + # <<: *manager_authentication + + # - name: "Create Comprehensive Cisco VPN Template" + # cisco.catalystwan.feature_templates: + # state: present + # template_name: "ComprehensiveCiscoVPNTemplate" + # template_description: "Cisco VPN template" + # debug: true + # device_models: + # - "vedge-C8000V" + # cisco_vpn: + # vpn_id: 10 + # vpn_name: "CorporateVPN" + # tenant_vpn_id: 200 + # org_name: "ACME_Corporation" + # omp_admin_distance_ipv4: 5 + # omp_admin_distance_ipv6: 5 + # dns: + # - dns_addr: "8.8.8.8" + # role: "primary" + # - dns_addr: "8.8.4.4" + # role: "secondary" + # dns_ipv6: + # - dns_addr: "2001:4860:4860::8888" + # role: "primary" + # - dns_addr: "2001:4860:4860::8844" + # role: "secondary" + # layer4: true + # host: + # - hostname: "server1.example.com" + # ip: + # - "192.168.1.10" + # service: + # - svc_type: "FW" + # address: + # - "192.168.2.10" + # interface: "GigabitEthernet0/0" + # track_enable: true + # service_route: + # - prefix: "192.168.3.0/24" + # vpn: 10 + # service: "sig" + # route_v4: + # - prefix: "192.168.1.0/24" + # next_hop: + # - address: "192.168.1.1" + # distance: 10 + # next_hop_with_track: + # - address: "192.168.1.2" + # distance: 20 + # tracker: "Track1" + # route_interface: + # interface_name: "GigabitEthernet0/0" + # interface_next_hop: + # - address: "2001:db8:abcd:0012::1" + # distance: 1 + # null0: false + # distance: 1 + # vpn: 10 + # dhcp: false + # route_v6: + # - prefix: "2001:db8:abcd:0012::/64" + # next_hop: + # - address: "2001:db8:abcd:0012::1" + # distance: 10 + # null0: false + # vpn: 10 + # nat: "NAT64" + # gre_route: + # - prefix: "10.0.0.0/8" + # vpn: 20 + # interface: + # - "Tunnel0" + # ipsec_route: + # - prefix: "172.16.0.0/12" + # vpn: 30 + # interface: + # - "Tunnel1" + # advertise: + # - protocol: bgp + # route_policy: "BGP-Export-Policy" + # protocol_sub_type: + # - external + # prefix_list: + # - prefix_entry: "192.168.50.0/24" + # aggregate_only: false + # region: core + # - prefix_entry: "192.168.60.0/24" + # aggregate_only: true + # region: access + # ipv6_advertise: + # - protocol: bgp + # route_policy: "BGP-IPv6-Export-Policy" + # protocol_sub_type: + # - external + # prefix_list: + # - prefix_entry: "2001:db8:abcd:0012::/64" + # aggregate_only: false + # region: core + # - prefix_entry: "2001:db8:abcd:0034::/64" + # aggregate_only: true + # region: access + # pool: + # - name: "NAT64Pool1" + # start_address: "203.0.113.1" + # end_address: "203.0.113.100" + # overload: true + # leak_from_global: true + # leak_from_global_protocol: static + # leak_to_global: false + # natpool: + # - name: 101 + # prefix_length: 24 + # range_start: "192.0.2.1" + # range_end: "192.0.2.100" + # overload: 'true' + # direction: inside + # tracker_id: 1 + # static: + # - pool_name: 101 + # source_ip: "198.51.100.5" + # translate_ip: "203.0.113.5" + # static_nat_direction: inside + # tracker_id: 2 + # subnet_static: + # - source_ip_subnet: "198.51.100.0/24" + # translate_ip_subnet: "203.0.113.0/24" + # prefix_length: 24 + # static_nat_direction: inside + # port_forward: + # - pool_name: 101 + # source_port: 8080 + # translate_port: 80 + # source_ip: "198.51.100.5" + # translate_ip: "203.0.113.5" + # proto: tcp + # route_import: + # - protocol: bgp + # protocol_sub_type: ['external'] + # route_policy: 'import-bgp-routes' + # redistribute: + # - protocol: ospf + # route_policy: 'ospf-to-bgp' + # route_import_from: + # - source_vpn: 10 + # protocol: static + # protocol_sub_type: + # - external + # route_policy: 'import-static-from-vpn10' + # redistribute: + # - protocol: eigrp + # route_policy: 'eigrp-to-vpn10' + # route_export: + # - protocol: bgp + # protocol_sub_type: + # - external + # route_policy: 'export-bgp-routes' + # redistribute: + # - protocol: bgp + # route_policy: 'static-to-bgp' + # manager_credentials: + # <<: *manager_authentication + + # - name: "Create Comprehensive OMP vSmart Template" + # cisco.catalystwan.feature_templates: + # state: present + # template_name: "OMPvSmartConfigTemplate" + # template_description: "Apply OMP settings for vSmart controller" + # debug: true + # device_models: vsmart + # omp_vsmart: + # graceful_restart: true + # graceful_restart_timer: 120 + # send_path_limit: 100 + # send_backup_paths: true + # shutdown: false + # discard_rejected: false + # eor_timer: 50 + # holdtime: 300 + # affinity_group_preference: true + # advertisement_interval: 30 + # tloc_color: true + # manager_credentials: + # <<: *manager_authentication + + # - name: "Create Comprehensive Security vSmart Template" + # cisco.catalystwan.feature_templates: + # state: present + # template_name: "SecurityvSmartConfigTemplate" + # template_description: "Apply Security settings for vSmart controller" + # debug: true + # device_models: vsmart + # security_vsmart: + # protocol: dtls + # tls_port: 120 + # manager_credentials: + # <<: *manager_authentication + + - name: "Create Comprehensive System vSmart Template" cisco.catalystwan.feature_templates: state: present - template_name: "ComprehensiveCiscoVPNInterfaceTemplate" - template_description: "Cisco VPN Interface template" - device_specific_variables: - ipv4_address: ipv4_address_variable + template_name: "SystemvSmartConfigTemplate" + template_description: "Apply System settings for vSmart controller" debug: true - device_models: - - "vedge-C8000V" - cisco_vpn_interface: - if_name: "GigabitEthernet4" - interface_description: "Service or Lan Net interface" - poe: true - ipv4_address: device_specific_variable + device_models: vsmart + system_vsmart: + timezone: UTC + idle_timeout: 100 + admin_tech_on_failure: true + iptables_enable: true + track_default_gateway: true + dns_cache_timeout: 10 + track_transport: true + controller_group_id: 44 + control_session_pps: 999 + port_hop: true + port_offset: 5 + overlay_id: 44 + site_id: 500 + system_ip: "192.168.1.1" + device_groups: "example1,example2" + latitude: "37" + longitude: "-122" + system_tunnel_mtu: "example_mtu_size" + location: "Location" + host_name: "myhostname" + dual_stack_ipv6: true + description: "Example description" + topology: "Hub and Spoke" + region_list_id: 12 + management_region: true + compatible: + color_1: mpls + color_2: metro-ethernet + incompatible: + color_1: biz-internet + color_2: public-internet manager_credentials: <<: *manager_authentication diff --git a/plugins/doc_fragments/feature_template_cisco_aaa.py b/plugins/doc_fragments/feature_template_cisco_aaa.py index 62d351c..3ca2fb3 100644 --- a/plugins/doc_fragments/feature_template_cisco_aaa.py +++ b/plugins/doc_fragments/feature_template_cisco_aaa.py @@ -212,7 +212,7 @@ class ModuleDocFragment(object): - The VPN ID for the RADIUS group required: true default: null - type: str + type: int source_interface: description: - The source interface for the RADIUS group @@ -341,7 +341,7 @@ class ModuleDocFragment(object): - Specify Radius Dynamic Author Port required: false default: null - type: str + type: int server_key_password: description: - Specify a radius dynamic author server-key diff --git a/plugins/doc_fragments/feature_template_cisco_bfd.py b/plugins/doc_fragments/feature_template_cisco_bfd.py index 3377f4a..09dcc63 100644 --- a/plugins/doc_fragments/feature_template_cisco_bfd.py +++ b/plugins/doc_fragments/feature_template_cisco_bfd.py @@ -22,19 +22,19 @@ class ModuleDocFragment(object): - The default BFD multiplier for all colors required: false default: null - type: str + type: int poll_interval: description: - The BFD poll interval in milliseconds required: false default: null - type: str + type: int default_dscp: description: - The default DSCP value for BFD packets required: false default: null - type: str + type: int color: description: - List of color-specific BFD configurations @@ -78,13 +78,13 @@ class ModuleDocFragment(object): - The BFD hello interval in milliseconds required: false default: null - type: str + type: int multiplier: description: - The BFD multiplier for the color required: false default: null - type: str + type: int pmtu_discovery: description: - Whether to enable Path MTU Discovery @@ -96,5 +96,5 @@ class ModuleDocFragment(object): - The DSCP value used for BFD packets required: false default: null - type: str + type: int ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_cisco_logging.py b/plugins/doc_fragments/feature_template_cisco_logging.py index 23cfb46..43ea554 100644 --- a/plugins/doc_fragments/feature_template_cisco_logging.py +++ b/plugins/doc_fragments/feature_template_cisco_logging.py @@ -28,13 +28,13 @@ class ModuleDocFragment(object): - The maximum file size for the log file required: false default: null - type: str + type: int rotate: description: - The number of log files to maintain before rotating required: false default: null - type: str + type: int tls_profile: description: - List of TLS profiles configurations @@ -93,7 +93,7 @@ class ModuleDocFragment(object): - The VPN ID for the server required: true default: null - type: str + type: int source_interface: description: - The source interface for the server @@ -152,7 +152,7 @@ class ModuleDocFragment(object): - The VPN ID for the IPv6 server required: true default: null - type: str + type: int source_interface: description: - The source interface for the IPv6 server diff --git a/plugins/doc_fragments/feature_template_cisco_ntp.py b/plugins/doc_fragments/feature_template_cisco_ntp.py index f5327ad..4f11a99 100644 --- a/plugins/doc_fragments/feature_template_cisco_ntp.py +++ b/plugins/doc_fragments/feature_template_cisco_ntp.py @@ -36,19 +36,19 @@ class ModuleDocFragment(object): - The identifier for the authentication key required: false default: null - type: str + type: int vpn: description: - The VPN ID associated with the NTP server required: false default: null - type: str + type: int version: description: - The NTP version used required: false default: null - type: str + type: int source_interface: description: - The source interface for NTP messages @@ -87,7 +87,7 @@ class ModuleDocFragment(object): required: false default: null type: list - elements: str + elements: int enable: description: - Whether the device is an NTP master @@ -99,7 +99,7 @@ class ModuleDocFragment(object): - The stratum level if the device is an NTP master required: false default: null - type: str + type: int source: description: - The source interface for NTP messages if the device is an NTP master diff --git a/plugins/doc_fragments/feature_template_cisco_omp.py b/plugins/doc_fragments/feature_template_cisco_omp.py index 6c35d42..42b8cb5 100644 --- a/plugins/doc_fragments/feature_template_cisco_omp.py +++ b/plugins/doc_fragments/feature_template_cisco_omp.py @@ -29,19 +29,19 @@ class ModuleDocFragment(object): - The autonomous system number used for the overlay. required: false default: null - type: str + type: int send_path_limit: description: - The maximum number of paths that can be sent for each prefix. required: false default: null - type: str + type: int ecmp_limit: description: - The maximum number of equal-cost multi-path routes. required: false default: null - type: str + type: int shutdown: description: - Enable or disable the shutdown of OMP. @@ -53,39 +53,39 @@ class ModuleDocFragment(object): - The administrative distance for IPv4 routes learned via OMP. required: false default: null - type: str + type: int omp_admin_distance_ipv6: description: - The administrative distance for IPv6 routes learned via OMP. required: false default: null - type: str + type: int advertisement_interval: description: - The interval between sending unsolicited OMP route advertisements. required: false default: null - type: str + type: int graceful_restart_timer: description: - The timer for graceful restart, specifying the period during which peerings are preserved. required: false default: null - type: str + type: int eor_timer: description: - End-of-RIB (EOR) timer which indicates stability of the route table. required: false default: null - type: str + type: int holdtime: description: - The amount of time that the routes are preserved while the peer is unreachable. required: false default: null - type: str + type: int advertise: description: - A list of IPv4 advertise rules. diff --git a/plugins/doc_fragments/feature_template_cisco_ospf.py b/plugins/doc_fragments/feature_template_cisco_ospf.py index 9295957..3112ac6 100644 --- a/plugins/doc_fragments/feature_template_cisco_ospf.py +++ b/plugins/doc_fragments/feature_template_cisco_ospf.py @@ -28,7 +28,7 @@ class ModuleDocFragment(object): - The reference bandwidth used by OSPF for cost calculation. required: false default: null - type: str + type: int rfc1583: description: - Compatibility switch for RFC 1583. @@ -53,7 +53,7 @@ class ModuleDocFragment(object): - The metric value to be set for the default route advertised by OSPF. required: false default: null - type: str + type: int metric_type: description: - The metric type (Type 1 or Type 2) for OSPF external routes. @@ -68,37 +68,37 @@ class ModuleDocFragment(object): - The OSPF external route metric. required: false default: null - type: str + type: int inter_area: description: - The OSPF inter-area route metric. required: false default: null - type: str + type: int intra_area: description: - The OSPF intra-area route metric. required: false default: null - type: str + type: int delay: description: - The OSPF Shortest Path First (SPF) delay time. required: false default: null - type: str + type: int initial_hold: description: - The initial hold time between consecutive SPF calculations. required: false default: null - type: str + type: int max_hold: description: - The maximum hold time between consecutive SPF calculations. required: false default: null - type: str + type: int redistribute: description: - A list of OSPF redistribution configurations. @@ -228,33 +228,33 @@ class ModuleDocFragment(object): the router sends on the interface. required: false default: null - type: str + type: int dead_interval: description: - The time interval an OSPF router waits for a Hello packet before declaring the sending router down. required: false default: null - type: str + type: int retransmit_interval: description: - The interval between LSA retransmissions for adjacencies belonging to the interface. required: false default: null - type: str + type: int cost: description: - The OSPF cost (metric) for this interface. required: false default: null - type: str + type: int priority: description: - The OSPF priority of the interface. required: false default: null - type: str + type: int network: description: - The OSPF network type for the interface. @@ -287,7 +287,7 @@ class ModuleDocFragment(object): - The message-digest key ID for OSPF authentication. required: false default: null - type: str + type: int md5: description: - The MD5 string for OSPF message-digest authentication. @@ -315,7 +315,7 @@ class ModuleDocFragment(object): - The OSPF cost (metric) for this range. required: false default: null - type: str + type: int no_advertise: description: - Whether to suppress advertising this range. diff --git a/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py b/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py index 1ab7d25..0e5a519 100644 --- a/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py +++ b/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py @@ -130,7 +130,7 @@ class ModuleDocFragment(object): - TCP Maximum Segment Size (MSS) adjust value. required: false default: null - type: str + type: int mtu: description: - MTU (Maximum Transmission Unit) size for the interface. @@ -142,13 +142,13 @@ class ModuleDocFragment(object): - Dead Peer Detection (DPD) interval in seconds. required: false default: null - type: str + type: int dpd_retries: description: - Number of retries for Dead Peer Detection (DPD). required: false default: null - type: str + type: int ike_version: description: - Internet Key Exchange (IKE) protocol version. @@ -166,7 +166,7 @@ class ModuleDocFragment(object): - Interval for rekeying the IKE security association. required: false default: null - type: str + type: int ike_ciphersuite: description: - Ciphersuite for IKE security association establishment. @@ -212,13 +212,13 @@ class ModuleDocFragment(object): - Interval for rekeying the IPsec security association. required: false default: null - type: str + type: int ipsec_replay_window: description: - Replay window size for IPsec security association. required: false default: null - type: str + type: int ipsec_ciphersuite: description: - Ciphersuite for IPsec security association establishment. @@ -367,7 +367,7 @@ class ModuleDocFragment(object): - Idle time before a session is considered inactive. required: false default: null - type: str + type: int display_time_unit: description: - Unit of time used for displaying time-related settings. @@ -389,7 +389,7 @@ class ModuleDocFragment(object): - Time after which the service information is refreshed. required: false default: null - type: str + type: int refresh_time_unit: description: - Unit of time used for the refresh time setting. @@ -425,7 +425,7 @@ class ModuleDocFragment(object): considered inactive. required: false default: null - type: str + type: int data_center_primary: description: - Alias for the primary data center setting. @@ -471,20 +471,20 @@ class ModuleDocFragment(object): - Threshold value for the tracker to trigger an alert or action. required: false default: null - type: str + type: int interval: description: - Interval at which the tracker performs health checks. required: false default: null - type: str + type: int multiplier: description: - Multiplier value used by the tracker to escalate repeated failures. required: false default: null - type: str + type: int tracker_type: description: - Type of tracker used for monitoring. diff --git a/plugins/doc_fragments/feature_template_cisco_system.py b/plugins/doc_fragments/feature_template_cisco_system.py index 0f08b46..1484700 100644 --- a/plugins/doc_fragments/feature_template_cisco_system.py +++ b/plugins/doc_fragments/feature_template_cisco_system.py @@ -482,7 +482,7 @@ class ModuleDocFragment(object): - The range for geo-fencing feature. required: false default: null - type: str + type: int enable_fencing: description: - Enable or disable geo-fencing. @@ -523,7 +523,7 @@ class ModuleDocFragment(object): required: false default: null type: list - elements: str + elements: int system_ip: description: - The system IP address of the device. @@ -542,7 +542,7 @@ class ModuleDocFragment(object): - The overlay ID of the device. required: false default: null - type: str + type: int site_id: description: - The site ID of the device. @@ -569,7 +569,7 @@ class ModuleDocFragment(object): - The port offset for the device. required: false default: null - type: str + type: int port_hop: description: - Enable or disable port hopping. @@ -581,7 +581,7 @@ class ModuleDocFragment(object): - Control session packets per second setting. required: false default: null - type: str + type: int track_transport: description: - Enable or disable transport tracking. @@ -593,7 +593,7 @@ class ModuleDocFragment(object): - The tag of the interface to be tracked. required: false default: null - type: str + type: int console_baud_rate: description: - The console baud rate setting for the device. @@ -614,7 +614,7 @@ class ModuleDocFragment(object): - The maximum number of OMP (Overlay Management Protocol) sessions. required: false default: null - type: str + type: int multi_tenant: description: - Enable or disable multi-tenant support. @@ -645,13 +645,13 @@ class ModuleDocFragment(object): - The idle timeout setting for tunnels. required: false default: null - type: str + type: int on_demand_idle_timeout_min: description: - The minimum idle timeout for on-demand tunnels. required: false default: null - type: str + type: int tracker: description: - List of tracker configurations. @@ -692,7 +692,7 @@ class ModuleDocFragment(object): - The port number used for the tracker. required: false default: null - type: str + type: int endpoint_dns_name: description: - The DNS name of the endpoint to track. @@ -726,19 +726,19 @@ class ModuleDocFragment(object): - The threshold for triggering the tracker. required: false default: null - type: str + type: int interval: description: - The interval at which the tracker checks the elements. required: false default: null - type: str + type: int multiplier: description: - The multiplier used for determining the loss threshold. required: false default: null - type: str + type: int type: description: - The type of tracker (interface or static route). @@ -820,13 +820,13 @@ class ModuleDocFragment(object): - The region ID of the device. required: false default: null - type: str + type: int secondary_region: description: - The secondary region ID of the device. required: false default: null - type: str + type: int role: description: - The role of the device in the network. @@ -841,14 +841,14 @@ class ModuleDocFragment(object): - The affinity group number for VRF binding. required: false default: null - type: str + type: int preference: description: - List of affinity group preferences. required: false default: null type: list - elements: str + elements: int preference_auto: description: - Enable or disable automatic preference setting for affinity groups. @@ -868,7 +868,7 @@ class ModuleDocFragment(object): - The affinity group number for VRF binding. required: false default: null - type: str + type: int vrf_range: description: - The range of VRFs associated with the affinity group. @@ -895,7 +895,7 @@ class ModuleDocFragment(object): - BGP community value for MRF migration. required: false default: null - type: str + type: int enable_management_region: description: - Enable or disable management region configuration. @@ -922,7 +922,7 @@ class ModuleDocFragment(object): required: false default: null type: list - elements: str + elements: int management_gateway: description: - Enable or disable the management gateway feature. diff --git a/plugins/doc_fragments/feature_template_cisco_vpn.py b/plugins/doc_fragments/feature_template_cisco_vpn.py index 1cc0ff2..51be8ed 100644 --- a/plugins/doc_fragments/feature_template_cisco_vpn.py +++ b/plugins/doc_fragments/feature_template_cisco_vpn.py @@ -35,7 +35,7 @@ class ModuleDocFragment(object): environments. required: false default: null - type: str + type: int org_name: description: - The name of the organization to which the VPN instance belongs. @@ -48,13 +48,13 @@ class ModuleDocFragment(object): Management Protocol (OMP). required: false default: null - type: str + type: int omp_admin_distance_ipv6: description: - The administrative distance for IPv6 routes received over OMP. required: false default: null - type: str + type: int dns: description: - A list of DNS configurations for the VPN instance. @@ -235,7 +235,7 @@ class ModuleDocFragment(object): - The administrative distance of the next hop. required: false default: null - type: str + type: int next_hop_with_track: description: - A list of IPv4 next hops with tracking for the route. @@ -257,7 +257,7 @@ class ModuleDocFragment(object): requires tracking. required: false default: null - type: str + type: int tracker: description: - The tracker associated with this next hop. @@ -269,7 +269,37 @@ class ModuleDocFragment(object): - The interface configuration for the IPv4 static route. required: false default: null - type: str + type: dict + elements: dict + suboptions: + interface_name: + description: + - The name of the interface used for routing. + required: true + default: null + type: str + interface_next_hop: + description: + - A list of next hops associated with the interface + for routing purposes. + required: false + default: null + type: list + elements: dict + suboptions: + address: + description: + - The IP address of the next hop for the route. + required: false + default: null + type: str + distance: + description: + - The administrative distance of the next + hop. + required: false + default: null + type: int null0: description: - A flag indicating whether to route traffic to null0 for @@ -282,13 +312,13 @@ class ModuleDocFragment(object): - The administrative distance for the static route. required: false default: null - type: str + type: int vpn: description: - The VPN instance identifier associated with the static route. required: false default: null - type: str + type: int dhcp: description: - A flag indicating whether DHCP is used for this static route. @@ -328,7 +358,7 @@ class ModuleDocFragment(object): - The administrative distance of the IPv6 next hop. required: false default: null - type: str + type: int null0: description: - A flag indicating whether to route IPv6 traffic to null0 @@ -342,7 +372,7 @@ class ModuleDocFragment(object): route. required: false default: null - type: str + type: int nat: description: - The type of NAT to apply for the IPv6 static route, if applicable. @@ -626,7 +656,7 @@ class ModuleDocFragment(object): - The length of the network prefix for the NAT pool. required: false default: null - type: str + type: int range_start: description: - The starting IP address for the NAT pool range. @@ -664,7 +694,7 @@ class ModuleDocFragment(object): - The tracker identifier associated with the NAT pool. required: false default: null - type: str + type: int static: description: - A list of static configurations within the VPN instance for NAT. @@ -679,7 +709,7 @@ class ModuleDocFragment(object): NAT rule. required: false default: null - type: str + type: int source_ip: description: - The original source IP address to be translated by static @@ -707,7 +737,7 @@ class ModuleDocFragment(object): - The tracker identifier associated with the static NAT rule. required: false default: null - type: str + type: int subnet_static: description: - A list of subnet-specific static configurations within the VPN instance @@ -753,7 +783,7 @@ class ModuleDocFragment(object): NAT rule. required: false default: null - type: str + type: int port_forward: description: - A list of port forwarding configurations within the VPN instance. @@ -768,7 +798,7 @@ class ModuleDocFragment(object): forwarding rule. required: false default: null - type: str + type: int source_port: description: - The source port number for the port forwarding rule. @@ -829,6 +859,8 @@ class ModuleDocFragment(object): default: null type: list elements: str + choices: + - external route_policy: description: - The route policy that specifies the conditions for route @@ -896,6 +928,8 @@ class ModuleDocFragment(object): default: null type: list elements: str + choices: + - external route_policy: description: - The route policy that specifies the criteria for route importation. @@ -956,6 +990,8 @@ class ModuleDocFragment(object): default: null type: list elements: str + choices: + - external route_policy: description: - The route policy that specifies the criteria for route exportation. diff --git a/plugins/doc_fragments/feature_template_cisco_vpn_interface.py b/plugins/doc_fragments/feature_template_cisco_vpn_interface.py index 5b6c2c4..9d15008 100644 --- a/plugins/doc_fragments/feature_template_cisco_vpn_interface.py +++ b/plugins/doc_fragments/feature_template_cisco_vpn_interface.py @@ -68,7 +68,7 @@ class ModuleDocFragment(object): - Administrative distance for DHCP routes on the interface. required: false default: null - type: str + type: int ipv6_address: description: - The primary IPv6 address assigned to the interface. @@ -146,7 +146,7 @@ class ModuleDocFragment(object): - Optional VPN ID where the DHCP helper is configured. required: false default: null - type: str + type: int tracker: description: - A list of tracker identifiers associated with the interface. @@ -191,14 +191,14 @@ class ModuleDocFragment(object): on this interface. required: false default: null - type: str + type: int tcp_timeout: description: - The timeout value in seconds for TCP connections through the NAT on this interface. required: false default: null - type: str + type: int nat_range_start: description: - The starting IP address in the range used for NAT on this interface. @@ -229,7 +229,7 @@ class ModuleDocFragment(object): size of the subnet. required: false default: null - type: str + type: int enable: description: - Indicates whether the interface is enabled or disabled. @@ -417,7 +417,7 @@ class ModuleDocFragment(object): have higher priority). required: false default: null - type: str + type: int weight: description: - Weight for the encapsulation type used in load balancing @@ -457,14 +457,14 @@ class ModuleDocFragment(object): - Specifies the total bandwidth available across all tunnels. required: false default: null - type: str + type: int group: description: - Identifies the group or groups the interface belongs to. required: false default: null type: list - elements: str + elements: int value: description: - The value field often corresponds to a specific attribute or setting, @@ -501,7 +501,7 @@ class ModuleDocFragment(object): the interface. required: false default: null - type: str + type: int control_connections: description: - Enables or disables control connections on the interface. @@ -521,13 +521,13 @@ class ModuleDocFragment(object): required: false default: null type: list - elements: str + elements: int vmanage_connection_preference: description: - Preference value for establishing vManage connections. required: false default: null - type: str + type: int port_hop: description: - Enables or disables port hopping for the interface to evade port @@ -570,21 +570,21 @@ class ModuleDocFragment(object): mappings. required: false default: null - type: str + type: int hello_interval: description: - Time interval in seconds between successive hello packets sent over the tunnel interface. required: false default: null - type: str + type: int hello_tolerance: description: - Time in seconds to wait before declaring a neighbor down due to missing hello packets. required: false default: null - type: str + type: int bind: description: - Interface or IP address to which the tunnel interface is bound. @@ -610,7 +610,7 @@ class ModuleDocFragment(object): over the tunnel. required: false default: null - type: str + type: int clear_dont_fragment: description: - Enables or disables the clearing of the 'Don't Fragment' (DF) bit @@ -729,20 +729,20 @@ class ModuleDocFragment(object): - Sets the Maximum Transmission Unit (MTU) size for the interface. required: false default: null - type: str + type: int mtu: description: - Specifies the MTU size for the tunnel or logical interface. required: false default: null - type: str + type: int tcp_mss_adjust: description: - Adjusts the TCP Maximum Segment Size (MSS) value for connections over the interface. required: false default: null - type: str + type: int tloc_extension: description: - Defines the Transport Location (TLOC) extension for the interface. @@ -755,7 +755,7 @@ class ModuleDocFragment(object): statistics. required: false default: null - type: str + type: int src_ip: description: - Source IP address for GRE tunnel extension. @@ -808,7 +808,7 @@ class ModuleDocFragment(object): - Time in seconds before an ARP cache entry is timed out. required: false default: null - type: str + type: int autonegotiate: description: - Enables or disables autonegotiation of speed and duplex settings @@ -839,51 +839,51 @@ class ModuleDocFragment(object): - Time period in seconds for measuring and adapting QoS settings. required: false default: null - type: str + type: int bandwidth_down: description: - Specifies the downstream bandwidth in Kbps for adaptive QoS calculations. required: false default: null - type: str + type: int dmin: description: - Specifies the minimum downstream bandwidth in Kbps for adaptive QoS. required: false default: null - type: str + type: int dmax: description: - Specifies the maximum downstream bandwidth in Kbps for adaptive QoS. required: false default: null - type: str + type: int bandwidth_up: description: - Specifies the upstream bandwidth in Kbps for adaptive QoS calculations. required: false default: null - type: str + type: int umin: description: - Specifies the minimum upstream bandwidth in Kbps for adaptive QoS. required: false default: null - type: str + type: int umax: description: - Specifies the maximum upstream bandwidth in Kbps for adaptive QoS. required: false default: null - type: str + type: int shaping_rate: description: - Defines the traffic shaping rate for the interface. required: false default: null - type: str + type: int qos_map: description: - Associates a QoS map with the interface for traffic classification @@ -909,13 +909,13 @@ class ModuleDocFragment(object): - Specifies the upstream bandwidth in Kbps available on the interface. required: false default: null - type: str + type: int bandwidth_downstream: description: - Specifies the downstream bandwidth in Kbps available on the interface. required: false default: null - type: str + type: int block_non_source_ip: description: - Enables or disables blocking of traffic with non-matching source @@ -1151,7 +1151,7 @@ class ModuleDocFragment(object): - Specifies a static Security Group Tag (SGT) for the interface. required: false default: null - type: str + type: int trusted: description: - Marks the interface as trusted or untrusted for TrustSec. @@ -1175,5 +1175,5 @@ class ModuleDocFragment(object): - Specifies the Security Group Tag (SGT) to be enforced on the interface. required: false default: null - type: str + type: int ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_omp_vsmart.py b/plugins/doc_fragments/feature_template_omp_vsmart.py index 8273468..c39d280 100644 --- a/plugins/doc_fragments/feature_template_omp_vsmart.py +++ b/plugins/doc_fragments/feature_template_omp_vsmart.py @@ -28,7 +28,7 @@ class ModuleDocFragment(object): - The maximum number of paths that can be sent to a TLOC required: false default: null - type: str + type: int send_backup_paths: description: - Enable or disable sending additional backup paths @@ -53,29 +53,35 @@ class ModuleDocFragment(object): - The time interval for graceful restart of OMP sessions required: false default: null - type: str + type: int eor_timer: description: - The End of Routes (EOR) timer value required: false default: null - type: str + type: int holdtime: description: - The hold time interval for OMP sessions required: false default: null - type: str + type: int affinity_group_preference: description: - - Prefer routes from the same affinity group + - Filter routes based on affinity preference list required: false - default: null + default: false type: bool advertisement_interval: description: - Interval between sending OMP route advertisements required: false default: null - type: str + type: int + tloc_color: + description: + - Filter routes based on TLOC color + required: false + default: false + type: bool ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_security_vsmart.py b/plugins/doc_fragments/feature_template_security_vsmart.py index 009c33a..6093535 100644 --- a/plugins/doc_fragments/feature_template_security_vsmart.py +++ b/plugins/doc_fragments/feature_template_security_vsmart.py @@ -31,5 +31,5 @@ class ModuleDocFragment(object): - The port used for TLS communications required: false default: null - type: str + type: int ''' \ No newline at end of file diff --git a/plugins/doc_fragments/feature_template_system_vsmart.py b/plugins/doc_fragments/feature_template_system_vsmart.py index 58ebfb9..83b3a2a 100644 --- a/plugins/doc_fragments/feature_template_system_vsmart.py +++ b/plugins/doc_fragments/feature_template_system_vsmart.py @@ -440,118 +440,282 @@ class ModuleDocFragment(object): - Africa/Lusaka - Africa/Harare - UTC - idle_timeout: + host_name: description: - - Idle timeout in minutes for user sessions + - The hostname for the vSmart controller required: false default: null type: str - admin_tech_on_failure: + dual_stack_ipv6: description: - - Enable automatic generation of tech-support file on failure + - Enable Dual Stack IPv6 Default required: false default: null type: bool - iptables_enable: + description: description: - - Enable or disable iptables for security + - Set a text description of the device required: false default: null - type: bool - track_default_gateway: + type: str + location: description: - - Enable or disable tracking of the default gateway + - A description of the physical location of the vSmart controller required: false default: null - type: bool - dns_cache_timeout: + type: str + system_tunnel_mtu: description: - - DNS cache timeout in minutes + - MTU size for system tunnels required: false default: null type: str - track_transport: + latitude: description: - - Enable or disable tracking of transport connections + - Geographical latitude of the vSmart controller required: false default: null - type: bool - controller_group_id: + type: int + longitude: description: - - Group ID for the vSmart controller + - Geographical longitude of the vSmart controller + required: false + default: null + type: int + device_groups: + description: + - Device group names for the vSmart controller required: false default: null type: str - control_session_pps: + system_ip: description: - - Control session packets per second limit + - System IP address for the vSmart controller required: false default: null type: str + site_id: + description: + - Site ID for the vSmart controller + required: false + default: null + type: int + overlay_id: + description: + - Overlay ID for the vSmart controller + required: false + default: null + type: int + topology: + description: + - Set the topology + required: false + default: null + type: str + choices: + - Hub and Spoke + port_offset: + description: + - Port offset for port hopping + required: false + default: null + type: int port_hop: description: - Enable or disable port hopping required: false default: null type: bool - port_offset: + control_session_pps: description: - - Port offset for port hopping + - Control session packets per second limit required: false default: null - type: str - overlay_id: + type: int + controller_group_id: description: - - Overlay ID for the vSmart controller + - Group ID for the vSmart controller required: false default: null - type: str - site_id: + type: int + track_transport: description: - - Site ID for the vSmart controller + - Enable or disable tracking of transport connections required: false default: null - type: str - system_ip: + type: bool + track_default_gateway: description: - - System IP address for the vSmart controller + - Enable or disable tracking of the default gateway required: false default: null - type: str - device_groups: + type: bool + iptables_enable: description: - - Device group names for the vSmart controller + - Enable or disable iptables for security required: false default: null - type: str - longitude: + type: bool + admin_tech_on_failure: description: - - Geographical longitude of the vSmart controller + - Enable automatic generation of tech-support file on failure required: false default: null - type: str - latitude: + type: bool + idle_timeout: description: - - Geographical latitude of the vSmart controller + - Idle timeout in minutes for user sessions required: false default: null - type: str - system_tunnel_mtu: + type: int + dns_cache_timeout: description: - - MTU size for system tunnels + - DNS cache timeout in minutes required: false default: null - type: str - location: + type: int + region_list_id: description: - - A description of the physical location of the vSmart controller + - Configure a list of region ID required: false default: null - type: str - host_name: + type: int + management_region: description: - - The hostname for the vSmart controller + - Management Region required: false default: null - type: str + type: bool + compatible: + description: + - Configure compatible TLOC color + required: false + default: null + type: dict + elements: dict + suboptions: + color_1: + description: + - First TLOC color in comparsion + required: false + default: null + type: str + choices: + - default + - mpls + - metro-ethernet + - biz-internet + - public-internet + - lte + - 3g + - red + - green + - blue + - gold + - silver + - bronze + - custom1 + - custom2 + - custom3 + - private1 + - private2 + - private3 + - private4 + - private5 + - private6 + color_2: + description: + - Second TLOC color in comparsion + required: false + default: null + type: str + choices: + - default + - mpls + - metro-ethernet + - biz-internet + - public-internet + - lte + - 3g + - red + - green + - blue + - gold + - silver + - bronze + - custom1 + - custom2 + - custom3 + - private1 + - private2 + - private3 + - private4 + - private5 + - private6 + incompatible: + description: + - Configure incompatible TLOC color + required: false + default: null + type: dict + elements: dict + suboptions: + color_1: + description: + - First TLOC color in comparsion + required: false + default: null + type: str + choices: + - default + - mpls + - metro-ethernet + - biz-internet + - public-internet + - lte + - 3g + - red + - green + - blue + - gold + - silver + - bronze + - custom1 + - custom2 + - custom3 + - private1 + - private2 + - private3 + - private4 + - private5 + - private6 + color_2: + description: + - Second TLOC color in comparsion + required: false + default: null + type: str + choices: + - default + - mpls + - metro-ethernet + - biz-internet + - public-internet + - lte + - 3g + - red + - green + - blue + - gold + - silver + - bronze + - custom1 + - custom2 + - custom3 + - private1 + - private2 + - private3 + - private4 + - private5 + - private6 ''' \ No newline at end of file diff --git a/plugins/module_utils/feature_templates/cisco_aaa.py b/plugins/module_utils/feature_templates/cisco_aaa.py index 2630f40..1ae2f48 100644 --- a/plugins/module_utils/feature_templates/cisco_aaa.py +++ b/plugins/module_utils/feature_templates/cisco_aaa.py @@ -60,7 +60,7 @@ 'type': 'str'}, 'port': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'radius': { 'default': None, 'elements': 'dict', 'options': { 'group_name': { 'default': None, @@ -102,7 +102,7 @@ 'type': 'str'}, 'vpn': { 'default': None, 'required': True, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'radius_client': { 'default': None, diff --git a/plugins/module_utils/feature_templates/cisco_bfd.py b/plugins/module_utils/feature_templates/cisco_bfd.py index c2767d2..8871f79 100644 --- a/plugins/module_utils/feature_templates/cisco_bfd.py +++ b/plugins/module_utils/feature_templates/cisco_bfd.py @@ -6,13 +6,13 @@ 'type': 'str'}, 'dscp': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'hello_interval': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'multiplier': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'pmtu_discovery': { 'default': True, 'required': False, 'type': 'bool'}}, @@ -20,12 +20,12 @@ 'type': 'list'}, 'default_dscp': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'multiplier': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'poll_interval': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'dict'}} diff --git a/plugins/module_utils/feature_templates/cisco_logging.py b/plugins/module_utils/feature_templates/cisco_logging.py index 2608fb3..c441488 100644 --- a/plugins/module_utils/feature_templates/cisco_logging.py +++ b/plugins/module_utils/feature_templates/cisco_logging.py @@ -24,12 +24,12 @@ 'type': 'str'}, 'vpn': { 'default': None, 'required': True, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'rotate': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'server': { 'default': None, 'elements': 'dict', 'options': { 'custom_profile': { 'default': False, @@ -52,12 +52,12 @@ 'type': 'str'}, 'vpn': { 'default': None, 'required': True, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'size': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'tls_profile': { 'default': None, 'elements': 'dict', 'options': { 'auth_type': { 'default': None, diff --git a/plugins/module_utils/feature_templates/cisco_ntp.py b/plugins/module_utils/feature_templates/cisco_ntp.py index d29ba18..057d187 100644 --- a/plugins/module_utils/feature_templates/cisco_ntp.py +++ b/plugins/module_utils/feature_templates/cisco_ntp.py @@ -16,7 +16,7 @@ 'elements': 'dict', 'options': { 'key': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'name': { 'default': None, 'required': True, 'type': 'str'}, @@ -28,10 +28,10 @@ 'type': 'str'}, 'version': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'vpn': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'source': { 'default': None, @@ -39,9 +39,9 @@ 'type': 'str'}, 'stratum': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'trusted': { 'default': None, - 'elements': 'str', + 'elements': 'int', 'required': False, 'type': 'list'}}, 'required': False, diff --git a/plugins/module_utils/feature_templates/cisco_omp.py b/plugins/module_utils/feature_templates/cisco_omp.py index e0c6bb0..05d965a 100644 --- a/plugins/module_utils/feature_templates/cisco_omp.py +++ b/plugins/module_utils/feature_templates/cisco_omp.py @@ -11,25 +11,25 @@ 'type': 'list'}, 'advertisement_interval': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'auto_translate': { 'default': False, 'required': False, 'type': 'bool'}, 'ecmp_limit': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'eor_timer': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'graceful_restart': { 'default': True, 'required': False, 'type': 'bool'}, 'graceful_restart_timer': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'holdtime': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'ignore_region_path_length': { 'default': False, 'required': False, 'type': 'bool'}, @@ -42,16 +42,16 @@ 'type': 'list'}, 'omp_admin_distance_ipv4': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'omp_admin_distance_ipv6': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'overlay_as': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'send_path_limit': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'shutdown': { 'default': None, 'required': False, 'type': 'bool'}, diff --git a/plugins/module_utils/feature_templates/cisco_ospf.py b/plugins/module_utils/feature_templates/cisco_ospf.py index 5012f3e..5f3d56e 100644 --- a/plugins/module_utils/feature_templates/cisco_ospf.py +++ b/plugins/module_utils/feature_templates/cisco_ospf.py @@ -11,19 +11,19 @@ 'elements': 'dict', 'options': { 'cost': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'dead_interval': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'hello_interval': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'md5': { 'default': None, 'required': False, 'type': 'str'}, 'message_digest_key': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'name': { 'default': None, 'required': True, 'type': 'str'}, @@ -35,10 +35,10 @@ 'type': 'bool'}, 'priority': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'retransmit_interval': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'type': { 'default': None, 'required': False, 'type': 'str'}}, @@ -54,7 +54,7 @@ 'type': 'str'}, 'cost': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'no_advertise': { 'default': False, 'required': False, 'type': 'bool'}}, @@ -67,25 +67,25 @@ 'type': 'list'}, 'delay': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'external': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'initial_hold': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'inter_area': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'intra_area': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'max_hold': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'metric': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'metric_type': { 'default': None, 'required': False, 'type': 'str'}, @@ -107,7 +107,7 @@ 'type': 'list'}, 'reference_bandwidth': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'rfc1583': { 'default': True, 'required': False, 'type': 'bool'}, diff --git a/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py b/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py index 612e46d..ba90a49 100644 --- a/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py +++ b/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py @@ -18,10 +18,10 @@ 'type': 'str'}, 'dpd_interval': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'dpd_retries': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'if_name': { 'default': None, 'required': True, 'type': 'str'}, @@ -36,7 +36,7 @@ 'type': 'str'}, 'ike_rekey_interval': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'ike_remote_id': { 'default': None, 'required': False, 'type': 'str'}, @@ -48,10 +48,10 @@ 'type': 'str'}, 'ipsec_rekey_interval': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'ipsec_replay_window': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'mtu': { 'default': None, 'required': False, 'type': 'int'}, @@ -69,7 +69,7 @@ 'type': 'bool'}, 'tcp_mss_adjust': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'track_enable': { 'default': None, 'required': False, 'type': 'bool'}, @@ -127,7 +127,7 @@ 'type': 'bool'}, 'idle_time': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'interface_pair': { 'default': None, 'elements': 'dict', 'options': { 'active_interface': { 'default': None, @@ -161,7 +161,7 @@ 'type': 'str'}, 'refresh_time': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'refresh_time_unit': { 'default': 'MINUTE', 'required': False, 'type': 'str'}, @@ -173,7 +173,7 @@ 'type': 'str'}, 'timeout': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'xff_forward_enabled': { 'default': None, 'required': False, 'type': 'bool'}}, @@ -186,16 +186,16 @@ 'type': 'str'}, 'interval': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'multiplier': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'name': { 'default': None, 'required': True, 'type': 'str'}, 'threshold': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'tracker_type': { 'default': None, 'required': True, 'type': 'str'}}, diff --git a/plugins/module_utils/feature_templates/cisco_system.py b/plugins/module_utils/feature_templates/cisco_system.py index 8806451..b6723ba 100644 --- a/plugins/module_utils/feature_templates/cisco_system.py +++ b/plugins/module_utils/feature_templates/cisco_system.py @@ -4,12 +4,12 @@ 'type': 'bool'}, 'affinity_group_number': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'affinity_per_vrf': { 'default': None, 'elements': 'dict', 'options': { 'affinity_group_number': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'vrf_range': { 'default': None, 'required': False, 'type': 'str'}}, @@ -20,9 +20,9 @@ 'type': 'str'}, 'control_session_pps': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'controller_group_list': { 'default': None, - 'elements': 'str', + 'elements': 'int', 'required': False, 'type': 'list'}, 'description': { 'default': None, @@ -58,7 +58,7 @@ 'type': 'dict'}, 'idle_timeout': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'latitude': { 'default': None, 'required': False, 'type': 'str'}, @@ -73,10 +73,10 @@ 'type': 'bool'}, 'max_omp_sessions': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'migration_bgp_community': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'mobile_number': { 'default': None, 'elements': 'dict', 'options': { 'number': { 'default': None, @@ -121,18 +121,18 @@ 'type': 'list'}, 'on_demand_idle_timeout_min': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'overlay_id': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'port_hop': { 'default': None, 'required': False, 'type': 'bool'}, 'port_offset': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'preference': { 'default': None, - 'elements': 'str', + 'elements': 'int', 'required': False, 'type': 'list'}, 'preference_auto': { 'default': None, @@ -140,16 +140,16 @@ 'type': 'bool'}, 'range': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'region_id': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'role': { 'default': None, 'required': False, 'type': 'str'}, 'secondary_region': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'site_id': { 'default': 'system_site_id', 'required': False, 'type': 'int'}, @@ -171,7 +171,7 @@ 'type': 'bool'}, 'track_interface_tag': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'track_transport': { 'default': None, 'required': False, 'type': 'bool'}, @@ -198,22 +198,22 @@ 'type': 'str'}, 'interval': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'multiplier': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'name': { 'default': None, 'required': True, 'type': 'str'}, 'port': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'protocol': { 'default': None, 'required': False, 'type': 'str'}, 'threshold': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'type': { 'default': 'interface', 'required': False, 'type': 'str'}}, @@ -225,7 +225,7 @@ 'vrf': { 'default': None, 'elements': 'dict', 'options': { 'gateway_preference': { 'default': None, - 'elements': 'str', + 'elements': 'int', 'required': False, 'type': 'list'}, 'vrf_id': { 'default': None, diff --git a/plugins/module_utils/feature_templates/cisco_vpn.py b/plugins/module_utils/feature_templates/cisco_vpn.py index 410c1f1..2d5bc6e 100644 --- a/plugins/module_utils/feature_templates/cisco_vpn.py +++ b/plugins/module_utils/feature_templates/cisco_vpn.py @@ -128,7 +128,7 @@ 'type': 'str'}, 'prefix_length': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'range_end': { 'default': None, 'required': False, 'type': 'str'}, @@ -137,15 +137,15 @@ 'type': 'str'}, 'tracker_id': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'omp_admin_distance_ipv4': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'omp_admin_distance_ipv6': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'org_name': { 'default': None, 'required': False, 'type': 'str'}, @@ -178,7 +178,7 @@ 'elements': 'dict', 'options': { 'pool_name': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'proto': { 'default': None, 'required': True, 'type': 'str'}, @@ -278,7 +278,7 @@ 'type': 'bool'}, 'distance': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'next_hop': { 'default': None, 'elements': 'dict', 'options': { 'address': { 'default': None, @@ -286,7 +286,7 @@ 'type': 'str'}, 'distance': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'next_hop_with_track': { 'default': None, @@ -296,7 +296,7 @@ 'type': 'str'}, 'distance': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'tracker': { 'default': None, 'required': True, 'type': 'str'}}, @@ -309,11 +309,24 @@ 'required': False, 'type': 'str'}, 'route_interface': { 'default': None, + 'options': { 'interface_name': { 'default': None, + 'required': True, + 'type': 'str'}, + 'interface_next_hop': { 'default': None, + 'elements': 'dict', + 'options': { 'address': { 'default': None, + 'required': False, + 'type': 'str'}, + 'distance': { 'default': None, + 'required': False, + 'type': 'int'}}, + 'required': False, + 'type': 'list'}}, 'required': False, - 'type': 'str'}, + 'type': 'dict'}, 'vpn': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'route_v6': { 'default': None, @@ -328,7 +341,7 @@ 'type': 'str'}, 'distance': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'null0': { 'default': None, @@ -339,7 +352,7 @@ 'type': 'str'}, 'vpn': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'service': { 'default': None, @@ -376,7 +389,7 @@ 'elements': 'dict', 'options': { 'pool_name': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'source_ip': { 'default': None, 'required': False, 'type': 'str'}, @@ -385,7 +398,7 @@ 'type': 'str'}, 'tracker_id': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'translate_ip': { 'default': None, 'required': False, 'type': 'str'}}, @@ -404,7 +417,7 @@ 'type': 'str'}, 'tracker_id': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'translate_ip_subnet': { 'default': None, 'required': True, 'type': 'str'}}, @@ -412,7 +425,7 @@ 'type': 'list'}, 'tenant_vpn_id': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'vpn_id': { 'default': None, 'required': False, 'type': 'int'}, diff --git a/plugins/module_utils/feature_templates/cisco_vpn_interface.py b/plugins/module_utils/feature_templates/cisco_vpn_interface.py index bcd7513..6ed933f 100644 --- a/plugins/module_utils/feature_templates/cisco_vpn_interface.py +++ b/plugins/module_utils/feature_templates/cisco_vpn_interface.py @@ -24,7 +24,7 @@ 'type': 'bool'}, 'arp_timeout': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'auto_bandwidth_detect': { 'default': None, 'required': False, 'type': 'bool'}, @@ -33,16 +33,16 @@ 'type': 'bool'}, 'bandwidth_down': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'bandwidth_downstream': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'bandwidth_up': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'bandwidth_upstream': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'bgp': { 'default': None, 'required': False, 'type': 'bool'}, @@ -72,7 +72,7 @@ 'type': 'bool'}, 'dhcp_distance': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'dhcp_helper': { 'default': None, 'elements': 'str', 'required': False, @@ -84,7 +84,7 @@ 'type': 'str'}, 'vpn': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'list'}, 'dhcp_ipv4_client': { 'default': None, @@ -95,10 +95,10 @@ 'type': 'bool'}, 'dmax': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'dmin': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'dns': { 'default': None, 'required': False, 'type': 'bool'}, @@ -125,21 +125,21 @@ 'type': 'bool'}, 'enforcement_sgt': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'exclude_controller_group_list': { 'default': None, - 'elements': 'str', + 'elements': 'int', 'required': False, 'type': 'list'}, 'group': { 'default': None, - 'elements': 'str', + 'elements': 'int', 'required': False, 'type': 'list'}, 'hello_interval': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'hello_tolerance': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'https': { 'default': None, 'required': False, 'type': 'bool'}, @@ -157,7 +157,7 @@ 'type': 'str'}, 'intrf_mtu': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'ip': { 'default': None, 'elements': 'dict', 'options': { 'addr': { 'default': None, @@ -214,7 +214,7 @@ 'type': 'bool'}, 'load_interval': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'loopback_interface': { 'default': None, 'required': False, 'type': 'str'}, @@ -226,7 +226,7 @@ 'type': 'str'}, 'max_control_connections': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'media_type': { 'default': None, 'required': False, 'type': 'str'}, @@ -235,7 +235,7 @@ 'type': 'str'}, 'mtu': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'nat': { 'default': None, 'required': False, 'type': 'bool'}, @@ -256,7 +256,7 @@ 'type': 'str'}, 'nat_refresh_interval': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'netconf': { 'default': None, 'required': False, 'type': 'bool'}, @@ -280,7 +280,7 @@ 'type': 'bool'}, 'period': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'poe': { 'default': None, 'required': False, 'type': 'bool'}, @@ -289,7 +289,7 @@ 'type': 'bool'}, 'prefix_length': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'propagate_sgt': { 'default': None, 'required': False, 'type': 'bool'}, @@ -327,13 +327,13 @@ 'type': 'str'}, 'security_group_tag': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'service_provider': { 'default': None, 'required': False, 'type': 'str'}, 'shaping_rate': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'shutdown': { 'default': False, 'required': False, 'type': 'bool'}, @@ -408,10 +408,10 @@ 'type': 'bool'}, 'tcp_mss_adjust': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'tcp_timeout': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'tloc_encapsulation': { 'default': None, 'elements': 'dict', 'options': { 'encap': { 'default': None, @@ -419,7 +419,7 @@ 'type': 'str'}, 'preference': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'weight': { 'default': None, 'required': False, 'type': 'int'}}, @@ -437,19 +437,19 @@ 'type': 'bool'}, 'tunnel_tcp_mss_adjust': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'tunnels_bandwidth': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'udp_timeout': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'umax': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'umin': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'value': { 'default': None, 'required': False, 'type': 'str'}, @@ -458,7 +458,7 @@ 'type': 'bool'}, 'vmanage_connection_preference': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'vrrp': { 'default': None, 'elements': 'dict', 'options': { 'address': { 'default': None, diff --git a/plugins/module_utils/feature_templates/omp_vsmart.py b/plugins/module_utils/feature_templates/omp_vsmart.py index f44f841..3805dde 100644 --- a/plugins/module_utils/feature_templates/omp_vsmart.py +++ b/plugins/module_utils/feature_templates/omp_vsmart.py @@ -1,8 +1,8 @@ omp_vsmart_definition = { 'omp_vsmart': { 'default': None, 'options': { 'advertisement_interval': { 'default': None, 'required': False, - 'type': 'str'}, - 'affinity_group_preference': { 'default': None, + 'type': 'int'}, + 'affinity_group_preference': { 'default': False, 'required': False, 'type': 'bool'}, 'discard_rejected': { 'default': None, @@ -10,24 +10,27 @@ 'type': 'bool'}, 'eor_timer': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'graceful_restart': { 'default': None, 'required': False, 'type': 'bool'}, 'graceful_restart_timer': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'holdtime': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'send_backup_paths': { 'default': None, 'required': False, 'type': 'bool'}, 'send_path_limit': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'shutdown': { 'default': None, 'required': False, - 'type': 'bool'}}, + 'type': 'bool'}, + 'tloc_color': { 'default': False, + 'required': False, + 'type': 'bool'}}, 'required': False, 'type': 'dict'}} diff --git a/plugins/module_utils/feature_templates/security_vsmart.py b/plugins/module_utils/feature_templates/security_vsmart.py index 2d9b9b1..f712090 100644 --- a/plugins/module_utils/feature_templates/security_vsmart.py +++ b/plugins/module_utils/feature_templates/security_vsmart.py @@ -4,6 +4,6 @@ 'type': 'str'}, 'tls_port': { 'default': None, 'required': False, - 'type': 'str'}}, + 'type': 'int'}}, 'required': False, 'type': 'dict'}} diff --git a/plugins/module_utils/feature_templates/system_vsmart.py b/plugins/module_utils/feature_templates/system_vsmart.py index 8597af6..4605546 100644 --- a/plugins/module_utils/feature_templates/system_vsmart.py +++ b/plugins/module_utils/feature_templates/system_vsmart.py @@ -2,48 +2,78 @@ 'options': { 'admin_tech_on_failure': { 'default': None, 'required': False, 'type': 'bool'}, + 'compatible': { 'default': None, + 'options': { 'color_1': { 'default': None, + 'required': False, + 'type': 'str'}, + 'color_2': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'dict'}, 'control_session_pps': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'controller_group_id': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, + 'description': { 'default': None, + 'required': False, + 'type': 'str'}, 'device_groups': { 'default': None, 'required': False, 'type': 'str'}, 'dns_cache_timeout': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, + 'dual_stack_ipv6': { 'default': None, + 'required': False, + 'type': 'bool'}, 'host_name': { 'default': None, 'required': False, 'type': 'str'}, 'idle_timeout': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, + 'incompatible': { 'default': None, + 'options': { 'color_1': { 'default': None, + 'required': False, + 'type': 'str'}, + 'color_2': { 'default': None, + 'required': False, + 'type': 'str'}}, + 'required': False, + 'type': 'dict'}, 'iptables_enable': { 'default': None, 'required': False, 'type': 'bool'}, 'latitude': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'location': { 'default': None, 'required': False, 'type': 'str'}, 'longitude': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, + 'management_region': { 'default': None, + 'required': False, + 'type': 'bool'}, 'overlay_id': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'port_hop': { 'default': None, 'required': False, 'type': 'bool'}, 'port_offset': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, + 'region_list_id': { 'default': None, + 'required': False, + 'type': 'int'}, 'site_id': { 'default': None, 'required': False, - 'type': 'str'}, + 'type': 'int'}, 'system_ip': { 'default': None, 'required': False, 'type': 'str'}, @@ -53,6 +83,9 @@ 'timezone': { 'default': None, 'required': False, 'type': 'str'}, + 'topology': { 'default': None, + 'required': False, + 'type': 'str'}, 'track_default_gateway': { 'default': None, 'required': False, 'type': 'bool'}, diff --git a/plugins/modules/feature_templates.py b/plugins/modules/feature_templates.py index 63b5b9a..529e54a 100644 --- a/plugins/modules/feature_templates.py +++ b/plugins/modules/feature_templates.py @@ -57,6 +57,10 @@ - cisco.catalystwan.feature_template_cisco_snmp - cisco.catalystwan.feature_template_cisco_system - cisco.catalystwan.feature_template_cisco_vpn_interface + - cisco.catalystwan.feature_template_cisco_vpn + - cisco.catalystwan.feature_template_omp_vsmart + - cisco.catalystwan.feature_template_security_vsmart + - cisco.catalystwan.feature_template_system_vsmart - cisco.catalystwan.device_models_feature_template - cisco.catalystwan.manager_authentication author: @@ -89,6 +93,10 @@ from ..module_utils.feature_templates.cisco_snmp import cisco_snmp_definition from ..module_utils.feature_templates.cisco_system import cisco_system_definition from ..module_utils.feature_templates.cisco_vpn_interface import cisco_vpn_interface_definition +from ..module_utils.feature_templates.cisco_vpn import cisco_vpn_definition +from ..module_utils.feature_templates.omp_vsmart import omp_vsmart_definition +from ..module_utils.feature_templates.security_vsmart import security_vsmart_definition +from ..module_utils.feature_templates.system_vsmart import system_vsmart_definition ALLOW: Final[str] = "allow" @@ -131,6 +139,10 @@ def run_module(): **cisco_snmp_definition, **cisco_system_definition, **cisco_vpn_interface_definition, + **cisco_vpn_definition, + **omp_vsmart_definition, + **security_vsmart_definition, + **system_vsmart_definition, ) result = ExtendedModuleResult() diff --git a/utils/ft_generator.py b/utils/ft_generator.py index abce542..cdb4805 100644 --- a/utils/ft_generator.py +++ b/utils/ft_generator.py @@ -36,7 +36,7 @@ def is_pydantic_model(type_): def field_to_ansible_option(field: FieldInfo, field_name: str, model_name: str): # if field.description == "List of public keys for the user": - # if field.description == "Flag indicating if interface tracking is enabled.": + # if field.description == "The list of subtypes for the import protocol.": # from IPython import embed; embed() option = { "description": [field.description], @@ -95,21 +95,38 @@ def field_to_ansible_option(field: FieldInfo, field_name: str, model_name: str): option["type"] = "list" option["elements"] = "str" option["choices"] = [item for item in get_args(user_class)] + elif origin_type == Literal: + option["type"] = "list" + option["elements"] = "str" + option["choices"] = [item for item in get_args(elements_type)] + elif user_class == int: + option["type"] = "list" + option["elements"] = "int" else: option["type"] = "list" option["elements"] = "str" - - elif is_pydantic_model(field_type): - option["type"] = "dict" - option["suboptions"] = model_to_ansible_options(field_type, model_name) + elif safe_issubclass(field_type, Enum): option["type"] = "str" option["choices"] = [item.value for item in field_type] + + # Special for field.description == "The interface configuration for the IPv4 static route." + elif field_type == Union and is_pydantic_model(next((arg for arg in args if arg is not None), None)): + elements_type = next((arg for arg in args if arg is not None), None) + option["type"] = "dict" + option["elements"] = "dict" + option["suboptions"] = model_to_ansible_options(elements_type, model_name) + elif field_type == Union and safe_issubclass(next((arg for arg in args if arg is not None), None), Enum): option["type"] = "str" option["choices"] = [item.value for item in args[0]] + elif field_type == Union and bool in args: option["type"] = "bool" + + elif field_type == Union and int in args: + option["type"] = "int" + elif field_type == Union and Annotated in subargs_base_types: elements_type = next((arg for arg in args if arg is not None), None) origin_type = get_origin(elements_type) @@ -120,15 +137,17 @@ def field_to_ansible_option(field: FieldInfo, field_name: str, model_name: str): if user_class == bool: option["type"] = "bool" option["default"] = field.default - # from IPython import embed; embed() + # THIS LINE IS NEWEST FOR LITERALS elif field_type == Union and Literal in subargs_base_types: elements_type = next((arg for arg in args if arg is not None), None) option["type"] = "str" option["choices"] = [item for item in get_args(elements_type)] + elif field_type == Literal: option["type"] = "str" option["choices"] = [item for item in args] + else: print(f"With model: {model_name}, field_name: {field_name} field: {field}") option["type"] = "str" From afdabc371ae54f7099bee2f3c5446fda33ba2cde Mon Sep 17 00:00:00 2001 From: acichon Date: Fri, 10 May 2024 15:34:39 +0200 Subject: [PATCH 10/18] next batch of templates --- playbooks/tests/test_feature_templates.yml | 1937 +++++++++-------- .../feature_template_cisco_aaa.py | 2 +- ..._template_cisco_secure_internet_gateway.py | 15 +- .../feature_templates/cisco_aaa.py | 2 +- .../cisco_secure_internet_gateway.py | 6 + 5 files changed, 1001 insertions(+), 961 deletions(-) diff --git a/playbooks/tests/test_feature_templates.yml b/playbooks/tests/test_feature_templates.yml index 093b641..d9d103c 100644 --- a/playbooks/tests/test_feature_templates.yml +++ b/playbooks/tests/test_feature_templates.yml @@ -42,960 +42,961 @@ # vedge-C8000V templates - # - name: "Create Comprehensive AAA Template with TACACS+ and RADIUS" - # cisco.catalystwan.feature_templates: - # state: present - # template_name: "ComprehensiveAAATemplate" - # template_description: "AAA Template with both TACACS+ and RADIUS servers" - # debug: true - # device_models: - # - vedge-C8000V - # cisco_aaa: - # user: - # - name: "local_admin" - # password: "admin_password" - # secret: "admin_secret" - # privilege: "15" - # pubkey_chain: - # - key_string: "AAAAB3NzaC1yc2EAAAADAQABAAABAQC3myRj5L6ZFLdRnOEZdUd+4Qq0XPLW9RfO6qD7DJ2t4ZzLh6Oz+IUJg8d8bJDfxO9zGKs5uUQ9f2H5yTGX5G8Z5kKp8QDp1MkDVqwGJ4UM7JqH8s8kD7xcl8SyPc5TjzK4s4W+8LPNOPXmIKtHh1Qlvkp5N7w3M/Rm5ZVX5/3+Hk8Ib5syigQQd/5u5xJj9k3i2x3m3LZ7v5e7YlCpRdCQGf6ZCwvbVQHdJp5nlU0HxJbqjOTL4IcDj09G3Dq2C5JnohKJb7E7HVCUl7F5vYpC/4iNjges65GgdzaFJsT9qA8CgxyF+7J3PpLk5qPAQDT5OjArJj4x9Bw3j3lZdH example@example.com" - # key_type: "ssh-rsa" - # authentication_group: true - # accounting_group: true - # radius: - # - group_name: "radius_group1" - # vpn: "1" - # source_interface: "GigabitEthernet0/0" - # server: - # - address: "192.0.2.1" - # auth_port: 1812 - # acct_port: 1813 - # timeout: 5 - # retransmit: 3 - # key: "secure_radius_server_key" - # secret_key: "radius_secret" - # key_enum: "key_enum_value" - # key_type: "key_type_value" - # domain_stripping: "right-to-left" - # port: 1234 - # authentication_type: any - # server_auth_order: "local radius_group1 tacacs_group1" - # server_key_password: "secure_server_key_password" - # cts_authorization_list: "example_element" - # radius_trustsec_group: "radius_group1" - # radius_client: - # - ip: 2.2.2.2 - # vpn: - # - name: example_radius_client - # server_key: secure_radius_client_key - # accounting_rules: - # - rule_id: 0 - # method: network - # level: "1" - # group: "radius_group1,tacacs_group1" - # start_stop: false - # authorization_console: true - # authorization_config_commands: true - # authorization_rules: - # - rule_id: 111 - # method: commands - # group: "radius_group1,tacacs_group1" - # authenticated: true - # tacacs: - # - group_name: "tacacs_group1" - # vpn: 2 - # source_interface: "GigabitEthernet0/1" - # server: - # - address: "192.0.2.2" - # port: 49 - # timeout: 10 - # key: "tacacs_key" - # secret_key: "tacacs_secret" - # key_enum: "key_enum_value" - # manager_credentials: - # <<: *manager_authentication + - name: "Create Comprehensive AAA Template with TACACS+ and RADIUS" + cisco.catalystwan.feature_templates: + state: present + template_name: "ComprehensiveAAATemplate" + template_description: "AAA Template with both TACACS+ and RADIUS servers" + debug: true + # device_models: + # - vedge-C8000V + cisco_aaa: + user: + - name: "local_admin" + password: "admin_password" + secret: "admin_secret" + privilege: "15" + pubkey_chain: + - key_string: "AAAAB3NzaC1yc2EAAAADAQABAAABAQC3myRj5L6ZFLdRnOEZdUd+4Qq0XPLW9RfO6qD7DJ2t4ZzLh6Oz+IUJg8d8bJDfxO9zGKs5uUQ9f2H5yTGX5G8Z5kKp8QDp1MkDVqwGJ4UM7JqH8s8kD7xcl8SyPc5TjzK4s4W+8LPNOPXmIKtHh1Qlvkp5N7w3M/Rm5ZVX5/3+Hk8Ib5syigQQd/5u5xJj9k3i2x3m3LZ7v5e7YlCpRdCQGf6ZCwvbVQHdJp5nlU0HxJbqjOTL4IcDj09G3Dq2C5JnohKJb7E7HVCUl7F5vYpC/4iNjges65GgdzaFJsT9qA8CgxyF+7J3PpLk5qPAQDT5OjArJj4x9Bw3j3lZdH example@example.com" + key_type: "ssh-rsa" + authentication_group: true + accounting_group: true + radius: + - group_name: "radius_group1" + vpn: "1" + source_interface: "GigabitEthernet0/0" + server: + - address: "192.0.2.1" + auth_port: 1812 + acct_port: 1813 + timeout: 5 + retransmit: 3 + key: "secure_radius_server_key" + secret_key: "radius_secret" + key_enum: "key_enum_value" + key_type: "key_type_value" + domain_stripping: "right-to-left" + port: 1234 + authentication_type: any + server_auth_order: "local radius_group1 tacacs_group1" + server_key_password: "secure_server_key_password" + cts_authorization_list: "example_element" + radius_trustsec_group: "radius_group1" + radius_client: + - ip: 2.2.2.2 + vpn: + - name: example_radius_client + server_key: secure_radius_client_key + accounting_rules: + - rule_id: 0 + method: network + level: "1" + group: "radius_group1,tacacs_group1" + start_stop: false + authorization_console: true + authorization_config_commands: true + authorization_rules: + - rule_id: 111 + method: commands + group: "radius_group1,tacacs_group1" + authenticated: true + tacacs: + - group_name: "tacacs_group1" + vpn: 2 + source_interface: "GigabitEthernet0/1" + server: + - address: "192.0.2.2" + port: 49 + timeout: 10 + key: "tacacs_key" + secret_key: "tacacs_secret" + key_enum: "key_enum_value" + manager_credentials: + <<: *manager_authentication - # - name: Create Cisco Banner Feature Template - # cisco.catalystwan.feature_templates: - # state: present - # template_name: "CiscoBannerConfigTemplate" - # template_description: "Banner configuration for login and MOTD" - # debug: true - # device_models: - # - "vedge-C8000V" - # cisco_banner: - # login_banner: | - # **************************************************************** - # * Unauthorized access to this device is prohibited. * - # * You must have explicit permission to access or configure this * - # * device. All activities performed on this device are logged and * - # * violations of this policy may result in disciplinary action, * - # * and may be reported to law enforcement. There is no right to * - # * privacy on this device. Use of this system constitutes consent * - # * to monitoring for these purposes. * - # **************************************************************** - # motd_banner: | - # **************************************************************** - # * Welcome to Company XYZ Network! * - # * All connections are monitored and recorded for audit purposes. * - # * Disconnect IMMEDIATELY if you are not an authorized user! * - # **************************************************************** - # manager_credentials: - # <<: *manager_authentication + - name: Create Cisco Banner Feature Template + cisco.catalystwan.feature_templates: + state: present + template_name: "CiscoBannerConfigTemplate" + template_description: "Banner configuration for login and MOTD" + debug: true + # device_models: + # - "vedge-C8000V" + cisco_banner: + login_banner: | + **************************************************************** + * Unauthorized access to this device is prohibited. * + * You must have explicit permission to access or configure this * + * device. All activities performed on this device are logged and * + * violations of this policy may result in disciplinary action, * + * and may be reported to law enforcement. There is no right to * + * privacy on this device. Use of this system constitutes consent * + * to monitoring for these purposes. * + **************************************************************** + motd_banner: | + **************************************************************** + * Welcome to Company XYZ Network! * + * All connections are monitored and recorded for audit purposes. * + * Disconnect IMMEDIATELY if you are not an authorized user! * + **************************************************************** + manager_credentials: + <<: *manager_authentication - # - name: Create Cisco BFD Feature Template - # cisco.catalystwan.feature_templates: - # state: present - # template_name: "CiscoBFDFeatureTemplate" - # template_description: "Comprehensive BFD configuration" - # debug: true - # device_models: - # - "vedge-C8000V" - # cisco_bfd: - # multiplier: "3" - # poll_interval: "500" - # default_dscp: "46" - # color: - # - color: "mpls" - # hello_interval: "200" - # multiplier: "4" - # pmtu_discovery: true - # dscp: "46" - # - color: "biz-internet" - # hello_interval: "300" - # multiplier: "5" - # pmtu_discovery: false - # dscp: "34" - # - color: "private1" - # hello_interval: "250" - # multiplier: "3" - # pmtu_discovery: true - # dscp: "26" - # - color: "custom3" - # hello_interval: "350" - # multiplier: "6" - # pmtu_discovery: true - # dscp: "18" - # manager_credentials: - # <<: *manager_authentication + - name: Create Cisco BFD Feature Template + cisco.catalystwan.feature_templates: + state: present + template_name: "CiscoBFDFeatureTemplate" + template_description: "Comprehensive BFD configuration" + debug: true + # device_models: + # - "vedge-C8000V" + cisco_bfd: + multiplier: "3" + poll_interval: "500" + default_dscp: "46" + color: + - color: "mpls" + hello_interval: "200" + multiplier: "4" + pmtu_discovery: true + dscp: "46" + - color: "biz-internet" + hello_interval: "300" + multiplier: "5" + pmtu_discovery: false + dscp: "34" + - color: "private1" + hello_interval: "250" + multiplier: "3" + pmtu_discovery: true + dscp: "26" + - color: "custom3" + hello_interval: "350" + multiplier: "6" + pmtu_discovery: true + dscp: "18" + manager_credentials: + <<: *manager_authentication - # - name: Configure Cisco Logging Feature Template - # cisco.catalystwan.feature_templates: - # state: present - # template_name: "CiscoLoggingFeatureTemplate" - # template_description: "Comprehensive Logging Configuration" - # debug: true - # device_models: - # - "vedge-C8000V" - # cisco_logging: - # enable: true - # size: "20" - # rotate: "5" - # tls_profile: - # - profile: "default_tls_profile" - # version: "TLSv1.2" - # auth_type: "Server" - # ciphersuite_list: - # - "ECDHE-ECDSA-AES256-GCM-SHA384" - # - "ECDHE-RSA-AES256-GCM-SHA384" - # - profile: "secure_tls_profile" - # version: "TLSv1.2" - # auth_type: "Mutual" - # ciphersuite_list: - # - "ECDHE-ECDSA-CHACHA20-POLY1305" - # - "ECDHE-RSA-CHACHA20-POLY1305" - # server: - # - name: "1.1.1.1" - # vpn: "10" - # source_interface: "GigabitEthernet0/0" - # priority: "debugging" - # enable_tls: true - # custom_profile: true - # profile: "default_tls_profile" - # - name: "log_server_2" - # vpn: "20" - # source_interface: "GigabitEthernet0/1" - # priority: "error" - # enable_tls: false - # ipv6_server: - # - name: "ipv6_log_server_1" - # vpn: "10" - # source_interface: "GigabitEthernet0/2" - # priority: "critical" - # enable_tls: true - # custom_profile: true - # profile: "secure_tls_profile" - # - name: "ipv6_log_server_2" - # vpn: "30" - # source_interface: "GigabitEthernet0/3" - # priority: "emergency" - # enable_tls: false - # manager_credentials: - # <<: *manager_authentication + - name: Configure Cisco Logging Feature Template + cisco.catalystwan.feature_templates: + state: present + template_name: "CiscoLoggingFeatureTemplate" + template_description: "Comprehensive Logging Configuration" + debug: true + # device_models: + # - "vedge-C8000V" + cisco_logging: + enable: true + size: "20" + rotate: "5" + tls_profile: + - profile: "default_tls_profile" + version: "TLSv1.2" + auth_type: "Server" + ciphersuite_list: + - "ECDHE-ECDSA-AES256-GCM-SHA384" + - "ECDHE-RSA-AES256-GCM-SHA384" + - profile: "secure_tls_profile" + version: "TLSv1.2" + auth_type: "Mutual" + ciphersuite_list: + - "ECDHE-ECDSA-CHACHA20-POLY1305" + - "ECDHE-RSA-CHACHA20-POLY1305" + server: + - name: "1.1.1.1" + vpn: "10" + source_interface: "GigabitEthernet0/0" + priority: "debugging" + enable_tls: true + custom_profile: true + profile: "default_tls_profile" + - name: "log_server_2" + vpn: "20" + source_interface: "GigabitEthernet0/1" + priority: "error" + enable_tls: false + ipv6_server: + - name: "ipv6_log_server_1" + vpn: "10" + source_interface: "GigabitEthernet0/2" + priority: "critical" + enable_tls: true + custom_profile: true + profile: "secure_tls_profile" + - name: "ipv6_log_server_2" + vpn: "30" + source_interface: "GigabitEthernet0/3" + priority: "emergency" + enable_tls: false + manager_credentials: + <<: *manager_authentication - # - name: Configure Cisco NTP Feature Template - # cisco.catalystwan.feature_templates: - # state: present - # template_name: "CiscoNTPFeatureTemplate" - # template_description: "Comprehensive NTP Configuration" - # debug: true - # device_models: - # - "vedge-C8000V" - # cisco_ntp: - # server: - # - name: "0.pool.ntp.org" - # key: "1" - # vpn: "10" - # version: "4" - # source_interface: "GigabitEthernet0/0" - # prefer: true - # - name: "1.pool.ntp.org" - # key: "2" - # vpn: "20" - # version: "4" - # source_interface: "GigabitEthernet0/1" - # prefer: false - # authentication: - # - number: 1 - # md5: "md5key1" - # - number: 2 - # md5: "md5key2" - # trusted: - # - 1 - # - 2 - # enable: true - # stratum: "2" - # source: "Loopback0" - # manager_credentials: - # <<: *manager_authentication + - name: Configure Cisco NTP Feature Template + cisco.catalystwan.feature_templates: + state: present + template_name: "CiscoNTPFeatureTemplate" + template_description: "Comprehensive NTP Configuration" + debug: true + # device_models: + # - "vedge-C8000V" + cisco_ntp: + server: + - name: "0.pool.ntp.org" + key: "1" + vpn: "10" + version: "4" + source_interface: "GigabitEthernet0/0" + prefer: true + - name: "1.pool.ntp.org" + key: "2" + vpn: "20" + version: "4" + source_interface: "GigabitEthernet0/1" + prefer: false + authentication: + - number: 1 + md5: "md5key1" + - number: 2 + md5: "md5key2" + trusted: + - 1 + - 2 + enable: true + stratum: "2" + source: "Loopback0" + manager_credentials: + <<: *manager_authentication - # - name: Configure Cisco OMP Feature Template - # cisco.catalystwan.feature_templates: - # state: present - # template_name: "CiscoOMPFeatureTemplate" - # template_description: "Comprehensive OMP Configuration" - # debug: true - # device_models: - # - "vedge-C8000V" - # cisco_omp: - # graceful_restart: true - # overlay_as: "65000" - # send_path_limit: "10" - # ecmp_limit: "8" - # shutdown: false - # omp_admin_distance_ipv4: "110" - # omp_admin_distance_ipv6: "115" - # advertisement_interval: "30" - # graceful_restart_timer: "120" - # eor_timer: "300" - # holdtime: "180" - # advertise: - # - protocol: "bgp" - # route: "external" - # - protocol: "ospf" - # - protocol: "connected" - # - protocol: "static" - # - protocol: "eigrp" - # - protocol: "lisp" - # ipv6_advertise: - # - protocol: "bgp" - # - protocol: "ospf" - # - protocol: "connected" - # - protocol: "static" - # ignore_region_path_length: true - # transport_gateway: "prefer" - # site_types: - # - "type-1" - # - "type-2" - # - "cloud" - # - "branch" - # - "spoke" - # auto_translate: true - # manager_credentials: - # <<: *manager_authentication + - name: Configure Cisco OMP Feature Template + cisco.catalystwan.feature_templates: + state: present + template_name: "CiscoOMPFeatureTemplate" + template_description: "Comprehensive OMP Configuration" + debug: true + # device_models: + # - "vsmart" + cisco_omp: + graceful_restart: true + overlay_as: "65000" + send_path_limit: "10" + ecmp_limit: "8" + shutdown: false + omp_admin_distance_ipv4: "110" + omp_admin_distance_ipv6: "115" + advertisement_interval: "30" + graceful_restart_timer: "120" + eor_timer: "300" + holdtime: "180" + advertise: + - protocol: "bgp" + route: "external" + - protocol: "ospf" + - protocol: "connected" + - protocol: "static" + - protocol: "eigrp" + - protocol: "lisp" + ipv6_advertise: + - protocol: "bgp" + - protocol: "ospf" + - protocol: "connected" + - protocol: "static" + ignore_region_path_length: true + transport_gateway: "prefer" + site_types: + - "type-1" + - "type-2" + - "cloud" + - "branch" + - "spoke" + auto_translate: true + manager_credentials: + <<: *manager_authentication - # - name: Configure Cisco OSPF Feature Template - # cisco.catalystwan.feature_templates: - # state: present - # template_name: "CiscoOSPFeatureTemplate" - # template_description: "Comprehensive OSPF Configuration" - # device_models: - # - "vedge-C8000V" - # cisco_ospf: - # router_id: "1.1.1.1" - # reference_bandwidth: "10000" - # rfc1583: false - # originate: true - # always: true - # metric: "10" - # metric_type: "type1" - # external: "20" - # inter_area: "30" - # intra_area: "40" - # delay: "5" - # initial_hold: "10" - # max_hold: "40" - # redistribute: - # - protocol: "static" - # route_policy: "static_policy" - # dia: true - # - protocol: "bgp" - # route_policy: "bgp_to_ospf_policy" - # dia: false - # router_lsa: - # - ad_type: "administrative" - # time: 10 - # route_policy: - # - direction: "in" - # pol_name: "ospf_in_policy" - # area: - # - a_num: 0 - # stub: false - # nssa: true - # interface: - # - name: "GigabitEthernet0/0" - # hello_interval: "10" - # dead_interval: "40" - # retransmit_interval: "5" - # cost: "1" - # priority: "1" - # network: "broadcast" - # passive_interface: false - # type: "simple" - # message_digest_key: "1" - # md5: "md5keystring" - # range: - # - address: "192.168.1.0/24" - # cost: "100" - # no_advertise: true - # manager_credentials: - # <<: *manager_authentication + - name: Configure Cisco OSPF Feature Template + cisco.catalystwan.feature_templates: + state: present + template_name: "CiscoOSPFeatureTemplate" + template_description: "Comprehensive OSPF Configuration" + debug: true + # device_models: + # - "vedge-C8000V" + cisco_ospf: + router_id: "1.1.1.1" + reference_bandwidth: "10000" + rfc1583: false + originate: true + always: true + metric: "10" + metric_type: "type1" + external: "20" + inter_area: "30" + intra_area: "40" + delay: "5" + initial_hold: "10" + max_hold: "40" + redistribute: + - protocol: "static" + route_policy: "static_policy" + dia: true + - protocol: "bgp" + route_policy: "bgp_to_ospf_policy" + dia: false + router_lsa: + - ad_type: "administrative" + time: 10 + route_policy: + - direction: "in" + pol_name: "ospf_in_policy" + area: + - a_num: 0 + stub: false + nssa: true + interface: + - name: "GigabitEthernet0/0" + hello_interval: "10" + dead_interval: "40" + retransmit_interval: "5" + cost: "1" + priority: "1" + network: "broadcast" + passive_interface: false + type: "simple" + message_digest_key: "1" + md5: "md5keystring" + range: + - address: "192.168.1.0/24" + cost: "100" + no_advertise: true + manager_credentials: + <<: *manager_authentication - # - name: "Configure Secure Internet Gateway feature template" - # cisco.catalystwan.feature_templates: - # state: present - # template_name: "CiscoSecureInternetGatewayFeatureTemplate" - # template_description: "Comprehensive CiscoSecureInternetGateway Configuration" - # debug: true - # device_models: - # - "vedge-C8000V" - # cisco_secure_internet_gateway: - # vpn_id: 10 - # child_org_id: "example_org" - # interface: - # - if_name: "GigabitEthernet0/0" - # auto: true - # shutdown: false - # description: "Main interface for SIG" - # unnumbered: false - # address: "192.168.1.1/24" - # tunnel_source: "192.168.1.1" - # tunnel_source_interface: "Loopback0" - # tunnel_route_via: "192.168.2.1" - # tunnel_destination: "203.0.113.1" - # application: "sig" - # tunnel_set: "secure-internet-gateway-umbrella" - # tunnel_dc_preference: "primary-dc" - # tcp_mss_adjust: "1400" - # mtu: 1400 - # dpd_interval: "30" - # dpd_retries: "3" - # ike_version: 2 - # pre_shared_secret: "MyPreSharedSecret" - # ike_rekey_interval: "3600" - # ike_ciphersuite: "aes256-cbc-sha1" - # ike_group: "14" - # pre_shared_key_dynamic: false - # ike_local_id: "local-id" - # ike_remote_id: "remote-id" - # ipsec_rekey_interval: "3600" - # ipsec_replay_window: "32" - # ipsec_ciphersuite: "aes256-gcm" - # perfect_forward_secrecy: "group-14" - # tracker: true - # track_enable: true - # service: - # - svc_type: "sig" - # interface_pair: - # - active_interface: "GigabitEthernet0/0" - # active_interface_weight: 10 - # backup_interface: "GigabitEthernet0/1" - # backup_interface_weight: 5 - # auth_required: "yes" - # xff_forward_enabled: "yes" - # ofw_enabled: "no" - # ips_control: "yes" - # caution_enabled: "no" - # primary_data_center: "Auto" - # secondary_data_center: "Auto" - # ip: "yes" - # idle_time: "30" - # display_time_unit: "MINUTE" - # ip_enforced_for_known_browsers: "yes" - # refresh_time: "5" - # refresh_time_unit: "MINUTE" - # enabled: "yes" - # block_internet_until_accepted: "no" - # force_ssl_inspection: "yes" - # timeout: "60" - # data_center_primary: "Auto" - # data_center_secondary: "Auto" - # tracker_src_ip: "192.0.2.1" - # tracker: - # - name: "health-check-tracker" - # endpoint_api_url: "https://api.example.com/health" - # threshold: "5" - # interval: "60" - # multiplier: "2" - # tracker_type: "SIG" - # manager_credentials: - # <<: *manager_authentication + - name: "Configure Secure Internet Gateway feature template" + cisco.catalystwan.feature_templates: + state: present + template_name: "CiscoSecureInternetGatewayFeatureTemplate" + template_description: "Comprehensive CiscoSecureInternetGateway Configuration" + debug: true + # device_models: + # - "vedge-C8000V" + cisco_secure_internet_gateway: + vpn_id: 10 + child_org_id: "example_org" + interface: + - if_name: "GigabitEthernet0/0" + auto: true + shutdown: false + description: "Main interface for SIG" + unnumbered: false + address: "192.168.1.1/24" + tunnel_source: "192.168.1.1" + tunnel_source_interface: "Loopback0" + tunnel_route_via: "192.168.2.1" + tunnel_destination: "203.0.113.1" + application: "sig" + tunnel_set: "secure-internet-gateway-umbrella" + tunnel_dc_preference: "primary-dc" + tcp_mss_adjust: "1400" + mtu: 1400 + dpd_interval: "30" + dpd_retries: "3" + ike_version: 2 + pre_shared_secret: "MyPreSharedSecret" + ike_rekey_interval: "3600" + ike_ciphersuite: "aes256-cbc-sha1" + ike_group: "14" + pre_shared_key_dynamic: false + ike_local_id: "local-id" + ike_remote_id: "remote-id" + ipsec_rekey_interval: "3600" + ipsec_replay_window: "32" + ipsec_ciphersuite: "aes256-gcm" + perfect_forward_secrecy: "group-14" + tracker: true + track_enable: true + service: + - svc_type: "sig" + interface_pair: + - active_interface: "GigabitEthernet0/0" + active_interface_weight: 10 + backup_interface: "GigabitEthernet0/1" + backup_interface_weight: 5 + auth_required: "yes" + xff_forward_enabled: "yes" + ofw_enabled: "no" + ips_control: "yes" + caution_enabled: "no" + primary_data_center: "Auto" + secondary_data_center: "Auto" + ip: "yes" + idle_time: "30" + display_time_unit: "MINUTE" + ip_enforced_for_known_browsers: "yes" + refresh_time: "5" + refresh_time_unit: "MINUTE" + enabled: "yes" + block_internet_until_accepted: "no" + force_ssl_inspection: "yes" + timeout: "60" + data_center_primary: "Auto" + data_center_secondary: "Auto" + tracker_src_ip: "192.0.2.1" + tracker: + - name: "health-check-tracker" + endpoint_api_url: "https://api.example.com/health" + threshold: "5" + interval: "60" + multiplier: "2" + tracker_type: "SIG" + manager_credentials: + <<: *manager_authentication - # - name: "Configure Cisco SNMP feature template" - # cisco.catalystwan.feature_templates: - # state: present - # template_name: "CiscoSNMPFeatureTemplate" - # template_description: "Comprehensive Cisco SNMP Configuration" - # cisco_snmp: - # shutdown: false - # contact: "SNMP Admin" - # location: "Data Center A" - # view: - # - name: "SystemView" - # oid: - # - id: "1.3.6.1.2.1.1" - # exclude: false - # - id: "1.3.6.1.2.1.2" - # exclude: true - # - name: "AllView" - # oid: - # - id: "1.3.6.1" - # exclude: false - # community: - # - name: "public" - # view: "SystemView" - # authorization: "read-only" - # - name: "private" - # view: "AllView" - # authorization: "read-only" - # group: - # - name: "v3group" - # security_level: "auth-priv" - # view: "AllView" - # user: - # - name: "snmpuser" - # auth: "md5" - # auth_password: "authpass" - # priv: "aes-cfb-128" - # priv_password: "privpass" - # group: "v3group" - # target: - # - vpn_id: 10 - # ip: "192.0.2.50" - # port: 162 - # community_name: "public" - # user: "snmpuser" - # source_interface: "GigabitEthernet0/0" - # manager_credentials: - # <<: *manager_authentication + - name: "Configure Cisco SNMP feature template" + cisco.catalystwan.feature_templates: + state: present + template_name: "CiscoSNMPFeatureTemplate" + template_description: "Comprehensive Cisco SNMP Configuration" + cisco_snmp: + shutdown: false + contact: "SNMP Admin" + location: "Data Center A" + view: + - name: "SystemView" + oid: + - id: "1.3.6.1.2.1.1" + exclude: false + - id: "1.3.6.1.2.1.2" + exclude: true + - name: "AllView" + oid: + - id: "1.3.6.1" + exclude: false + community: + - name: "public" + view: "SystemView" + authorization: "read-only" + - name: "private" + view: "AllView" + authorization: "read-only" + group: + - name: "v3group" + security_level: "auth-priv" + view: "AllView" + user: + - name: "snmpuser" + auth: "md5" + auth_password: "authpass" + priv: "aes-cfb-128" + priv_password: "privpass" + group: "v3group" + target: + - vpn_id: 10 + ip: "192.0.2.50" + port: 162 + community_name: "public" + user: "snmpuser" + source_interface: "GigabitEthernet0/0" + manager_credentials: + <<: *manager_authentication - # - name: "Create Comprehensive Cisco System Template" - # cisco.catalystwan.feature_templates: - # state: present - # template_name: "ComprehensiveCiscoSystemTemplate" - # template_description: "Cisco System template" - # debug: true - # device_models: - # - "vedge-C8000V" - # cisco_system: - # timezone: "UTC" - # description: "Example desc" - # hostname: - # name: "sdwan-hostname" - # location: "Data Center A" - # latitude: "37.7749" - # longitude: "-122.4194" - # range: "10" - # enable_fencing: true - # mobile_number: - # - number: "+12345678901" - # - number: "+10987654321" - # enable_sms: true - # device_groups: - # - "group1" - # - "group2" - # controller_group_list: - # - 1 - # - 3 - # system_ip: - # name: "192.0.2.1" - # overlay_id: "1" - # site_id: 1001 - # site_type: - # - "branch" - # - "spoke" - # port_offset: "1000" - # port_hop: true - # control_session_pps: "500" - # track_transport: true - # track_interface_tag: "1" - # console_baud_rate: "9600" - # max_omp_sessions: "50" - # multi_tenant: false - # track_default_gateway: false - # admin_tech_on_failure: true - # enable_tunnel: true - # idle_timeout: "300" - # on_demand_idle_timeout_min: "60" - # tracker: - # - name: "tracker1" - # endpoint_ip: "203.0.113.1" - # endpoint_ip_transport_port: "8080" - # protocol: "tcp" - # port: "443" - # elements: - # - "element1, element2" - # boolean: "and" - # threshold: "10" - # interval: "30" - # multiplier: "3" - # type: "static-route" - # object_track: - # - object_number: 10 - # interface: 'GigabitEthernet0/0/0' - # sig: '100' - # ip: '192.0.2.1' - # mask: '255.255.255.0' - # vpn: 1 - # object: - # - number: 101 - # boolean: 'and' - # - object_number: 20 - # interface: 'GigabitEthernet0/0/0' - # sig: '100' - # ip: '192.0.2.1' - # mask: '255.255.255.0' - # vpn: 1 - # object: - # - number: 101 - # boolean: 'and' - # - object_number: 30 - # interface: 'GigabitEthernet0/0/1' - # sig: '200' - # ip: '198.51.100.1' - # mask: '255.255.255.0' - # vpn: 2 - # object: - # - number: 201 - # boolean: 'or' - # preference: - # - 1 - # preference_auto: true - # epfr: "conservative" - # vrf: - # - vrf_id: 1 - # gateway_preference: - # - 4 - # - 5 - # - vrf_id: 2 - # gateway_preference: - # - 12 - # - 13 - # enable_management_region: true - # migration_bgp_community: 65535 - # enable_mrf_migration: enabled - # transport_gateway: true - # affinity_group_number: 1 - # affinity_per_vrf: - # - affinity_group_number: 1 - # vrf_range: "22" - # role: "edge-router" - # # secondary_region: 55 - # # region_id: 44 - # manager_credentials: - # <<: *manager_authentication + - name: "Create Comprehensive Cisco System Template" + cisco.catalystwan.feature_templates: + state: present + template_name: "ComprehensiveCiscoSystemTemplate" + template_description: "Cisco System template" + debug: true + # device_models: + # - "vedge-C8000V" + cisco_system: + timezone: "UTC" + description: "Example desc" + hostname: + name: "sdwan-hostname" + location: "Data Center A" + latitude: "37.7749" + longitude: "-122.4194" + range: "10" + enable_fencing: true + mobile_number: + - number: "+12345678901" + - number: "+10987654321" + enable_sms: true + device_groups: + - "group1" + - "group2" + controller_group_list: + - 1 + - 3 + system_ip: + name: "192.0.2.1" + overlay_id: "1" + site_id: 1001 + site_type: + - "branch" + - "spoke" + port_offset: "1000" + port_hop: true + control_session_pps: "500" + track_transport: true + track_interface_tag: "1" + console_baud_rate: "9600" + max_omp_sessions: "50" + multi_tenant: false + track_default_gateway: false + admin_tech_on_failure: true + enable_tunnel: true + idle_timeout: "300" + on_demand_idle_timeout_min: "60" + tracker: + - name: "tracker1" + endpoint_ip: "203.0.113.1" + endpoint_ip_transport_port: "8080" + protocol: "tcp" + port: "443" + elements: + - "element1, element2" + boolean: "and" + threshold: "10" + interval: "30" + multiplier: "3" + type: "static-route" + object_track: + - object_number: 10 + interface: 'GigabitEthernet0/0/0' + sig: '100' + ip: '192.0.2.1' + mask: '255.255.255.0' + vpn: 1 + object: + - number: 101 + boolean: 'and' + - object_number: 20 + interface: 'GigabitEthernet0/0/0' + sig: '100' + ip: '192.0.2.1' + mask: '255.255.255.0' + vpn: 1 + object: + - number: 101 + boolean: 'and' + - object_number: 30 + interface: 'GigabitEthernet0/0/1' + sig: '200' + ip: '198.51.100.1' + mask: '255.255.255.0' + vpn: 2 + object: + - number: 201 + boolean: 'or' + preference: + - 1 + preference_auto: true + epfr: "conservative" + vrf: + - vrf_id: 1 + gateway_preference: + - 4 + - 5 + - vrf_id: 2 + gateway_preference: + - 12 + - 13 + enable_management_region: true + migration_bgp_community: 65535 + enable_mrf_migration: enabled + transport_gateway: true + affinity_group_number: 1 + affinity_per_vrf: + - affinity_group_number: 1 + vrf_range: "22" + role: "edge-router" + # secondary_region: 55 + # region_id: 44 + manager_credentials: + <<: *manager_authentication - # - name: "Create Comprehensive Cisco VPN Interface Template" - # cisco.catalystwan.feature_templates: - # state: present - # template_name: "ComprehensiveCiscoVPNInterfaceTemplate" - # template_description: "Cisco VPN Interface template" - # debug: true - # device_models: - # - "vedge-C8000V" - # cisco_vpn_interface: - # if_name: "GigabitEthernet0/0" - # interface_description: "WAN interface" - # poe: true - # ipv4_address: "192.0.2.1/24" - # secondary_ipv4_address: - # - address: "192.0.2.2/24" - # - address: "192.0.2.3/24" - # dhcp_ipv4_client: false - # dhcp_distance: "1" - # ipv6_address: "2001:db8::1/64" - # dhcp_ipv6_client: true - # secondary_ipv6_address: - # - address: "2001:db8::2/64" - # - address: "2001:db8::3/64" - # access_list_ipv4: - # - direction: "in" - # acl_name: "ACL-INBOUND" - # - direction: "out" - # acl_name: "ACL-OUTBOUND" - # dhcp_helper: - # - "192.0.2.254" - # dhcp_helper_v6: - # - address: "2001:db8::1" - # vpn: "0" - # tracker: - # - "Tracker1" - # - "Tracker2" - # auto_bandwidth_detect: true - # iperf_server: "192.0.2.100" - # nat: true - # nat_choice: "Interface" - # udp_timeout: "30" - # tcp_timeout: "60" - # nat_range_start: "192.0.2.100" - # nat_range_end: "192.0.2.200" - # overload: true - # loopback_interface: "Loopback0" - # prefix_length: "24" - # enable: true - # nat64: false - # nat66: false - # static_nat66: - # - source_prefix: "2001:db8:1234::/64" - # translated_source_prefix: "2001:db8:5678::/64" - # source_vpn_id: 10 - # static: - # - source_ip: "192.0.2.1" - # translate_ip: "203.0.113.1" - # static_nat_direction: "inside" - # source_vpn: 10 - # static_port_forward: - # - source_ip: "192.0.2.2" - # translate_ip: "203.0.113.2" - # static_nat_direction: "outside" - # source_port: 8080 - # translate_port: 9090 - # proto: "tcp" - # source_vpn: 10 - # enable_core_region: true - # core_region: "core" - # secondary_region: "secondary-only" - # tloc_encapsulation: - # - encap: "ipsec" - # preference: "100" - # weight: 1 - # border: true - # per_tunnel_qos: true - # per_tunnel_qos_aggregator: true - # mode: "hub" - # tunnels_bandwidth: "1000" - # group: - # - "1" - # - "2" - # value: "mpls" - # max_control_connections: "5" - # control_connections: true - # vbond_as_stun_server: true - # exclude_controller_group_list: - # - "3" - # - "4" - # vmanage_connection_preference: "100" - # port_hop: true - # restrict: false - # dst_ip: "198.51.100.14" - # carrier: "carrier1" - # nat_refresh_interval: "30" - # hello_interval: "10" - # hello_tolerance: "30" - # bind: "GigabitEthernet0/0" - # last_resort_circuit: false - # low_bandwidth_link: false - # tunnel_tcp_mss_adjust: "1360" - # clear_dont_fragment: true - # propagate_sgt: false - # network_broadcast: true - # all: false - # bgp: true - # dhcp: false - # dns: true - # icmp: true - # sshd: true - # netconf: false - # ntp: true - # ospf: false - # stun: false - # snmp: true - # https: true - # media_type: "rj45" - # intrf_mtu: "1500" - # mtu: "1400" - # tcp_mss_adjust: "1360" - # tloc_extension: "100" - # load_interval: "300" - # src_ip: "198.51.100.1" - # xconnect: "10" - # mac_address: "00:0C:29:4B:55:3A" - # speed: "1000" - # duplex: "full" - # shutdown: false - # arp_timeout: "1200" - # autonegotiate: true - # ip_directed_broadcast: false - # icmp_redirect_disable: true - # qos_adaptive: true - # period: "60" - # bandwidth_down: "10000" - # dmin: "5000" - # dmax: "15000" - # bandwidth_up: "5000" - # umin: "2500" - # umax: "7500" - # shaping_rate: "5000" - # qos_map: "default_qos_map" - # qos_map_vpn: "vpn_qos_map" - # service_provider: "ISP1" - # bandwidth_upstream: "5000" - # bandwidth_downstream: "10000" - # block_non_source_ip: true - # rule_name: "rewrite_rule_1" - # access_list_ipv6: - # - direction: "in" - # acl_name: "ipv6_acl_1" - # ip: - # - addr: "192.0.2.1" - # mac: "00:0C:29:4B:55:3A" - # vrrp: - # - grp_id: 1 - # priority: 110 - # timer: 100 - # track_omp: true - # track_prefix_list: "TRACKING_LIST" - # address: "192.0.2.254" - # ipv4_secondary: - # - address: "192.0.2.253" - # tloc_change_pref: true - # value: 20 - # tracking_object: - # - name: 10 - # track_action: "Decrement" - # decrement: 20 - # ipv6_vrrp: - # - grp_id: 1 - # priority: 110 - # timer: 100 - # track_omp: true - # track_prefix_list: "TRACKING_LIST_IPV6" - # ipv6: - # - ipv6_link_local: "FE80::1" - # prefix: "2001:db8::/64" - # enable_sgt_propagation: true - # security_group_tag: "0000" - # trusted: true - # enable_sgt_authorization_and_forwarding: true - # enable_sgt_enforcement: true - # enforcement_sgt: "010001" - # manager_credentials: - # <<: *manager_authentication + - name: "Create Comprehensive Cisco VPN Interface Template" + cisco.catalystwan.feature_templates: + state: present + template_name: "ComprehensiveCiscoVPNInterfaceTemplate" + template_description: "Cisco VPN Interface template" + debug: true + # device_models: + # - "vedge-C8000V" + cisco_vpn_interface: + if_name: "GigabitEthernet0/0" + interface_description: "WAN interface" + poe: true + ipv4_address: "192.0.2.1/24" + secondary_ipv4_address: + - address: "192.0.2.2/24" + - address: "192.0.2.3/24" + dhcp_ipv4_client: false + dhcp_distance: "1" + ipv6_address: "2001:db8::1/64" + dhcp_ipv6_client: true + secondary_ipv6_address: + - address: "2001:db8::2/64" + - address: "2001:db8::3/64" + access_list_ipv4: + - direction: "in" + acl_name: "ACL-INBOUND" + - direction: "out" + acl_name: "ACL-OUTBOUND" + dhcp_helper: + - "192.0.2.254" + dhcp_helper_v6: + - address: "2001:db8::1" + vpn: "0" + tracker: + - "Tracker1" + - "Tracker2" + auto_bandwidth_detect: true + iperf_server: "192.0.2.100" + nat: true + nat_choice: "Interface" + udp_timeout: "30" + tcp_timeout: "60" + nat_range_start: "192.0.2.100" + nat_range_end: "192.0.2.200" + overload: true + loopback_interface: "Loopback0" + prefix_length: "24" + enable: true + nat64: false + nat66: false + static_nat66: + - source_prefix: "2001:db8:1234::/64" + translated_source_prefix: "2001:db8:5678::/64" + source_vpn_id: 10 + static: + - source_ip: "192.0.2.1" + translate_ip: "203.0.113.1" + static_nat_direction: "inside" + source_vpn: 10 + static_port_forward: + - source_ip: "192.0.2.2" + translate_ip: "203.0.113.2" + static_nat_direction: "outside" + source_port: 8080 + translate_port: 9090 + proto: "tcp" + source_vpn: 10 + enable_core_region: true + core_region: "core" + secondary_region: "secondary-only" + tloc_encapsulation: + - encap: "ipsec" + preference: "100" + weight: 1 + border: true + per_tunnel_qos: true + per_tunnel_qos_aggregator: true + mode: "hub" + tunnels_bandwidth: "1000" + group: + - "1" + - "2" + value: "mpls" + max_control_connections: "5" + control_connections: true + vbond_as_stun_server: true + exclude_controller_group_list: + - "3" + - "4" + vmanage_connection_preference: "100" + port_hop: true + restrict: false + dst_ip: "198.51.100.14" + carrier: "carrier1" + nat_refresh_interval: "30" + hello_interval: "10" + hello_tolerance: "30" + bind: "GigabitEthernet0/0" + last_resort_circuit: false + low_bandwidth_link: false + tunnel_tcp_mss_adjust: "1360" + clear_dont_fragment: true + propagate_sgt: false + network_broadcast: true + all: false + bgp: true + dhcp: false + dns: true + icmp: true + sshd: true + netconf: false + ntp: true + ospf: false + stun: false + snmp: true + https: true + media_type: "rj45" + intrf_mtu: "1500" + mtu: "1400" + tcp_mss_adjust: "1360" + tloc_extension: "100" + load_interval: "300" + src_ip: "198.51.100.1" + xconnect: "10" + mac_address: "00:0C:29:4B:55:3A" + speed: "1000" + duplex: "full" + shutdown: false + arp_timeout: "1200" + autonegotiate: true + ip_directed_broadcast: false + icmp_redirect_disable: true + qos_adaptive: true + period: "60" + bandwidth_down: "10000" + dmin: "5000" + dmax: "15000" + bandwidth_up: "5000" + umin: "2500" + umax: "7500" + shaping_rate: "5000" + qos_map: "default_qos_map" + qos_map_vpn: "vpn_qos_map" + service_provider: "ISP1" + bandwidth_upstream: "5000" + bandwidth_downstream: "10000" + block_non_source_ip: true + rule_name: "rewrite_rule_1" + access_list_ipv6: + - direction: "in" + acl_name: "ipv6_acl_1" + ip: + - addr: "192.0.2.1" + mac: "00:0C:29:4B:55:3A" + vrrp: + - grp_id: 1 + priority: 110 + timer: 100 + track_omp: true + track_prefix_list: "TRACKING_LIST" + address: "192.0.2.254" + ipv4_secondary: + - address: "192.0.2.253" + tloc_change_pref: true + value: 20 + tracking_object: + - name: 10 + track_action: "Decrement" + decrement: 20 + ipv6_vrrp: + - grp_id: 1 + priority: 110 + timer: 100 + track_omp: true + track_prefix_list: "TRACKING_LIST_IPV6" + ipv6: + - ipv6_link_local: "FE80::1" + prefix: "2001:db8::/64" + enable_sgt_propagation: true + security_group_tag: "0000" + trusted: true + enable_sgt_authorization_and_forwarding: true + enable_sgt_enforcement: true + enforcement_sgt: "010001" + manager_credentials: + <<: *manager_authentication - # - name: "Create Comprehensive Cisco VPN Template" - # cisco.catalystwan.feature_templates: - # state: present - # template_name: "ComprehensiveCiscoVPNTemplate" - # template_description: "Cisco VPN template" - # debug: true - # device_models: - # - "vedge-C8000V" - # cisco_vpn: - # vpn_id: 10 - # vpn_name: "CorporateVPN" - # tenant_vpn_id: 200 - # org_name: "ACME_Corporation" - # omp_admin_distance_ipv4: 5 - # omp_admin_distance_ipv6: 5 - # dns: - # - dns_addr: "8.8.8.8" - # role: "primary" - # - dns_addr: "8.8.4.4" - # role: "secondary" - # dns_ipv6: - # - dns_addr: "2001:4860:4860::8888" - # role: "primary" - # - dns_addr: "2001:4860:4860::8844" - # role: "secondary" - # layer4: true - # host: - # - hostname: "server1.example.com" - # ip: - # - "192.168.1.10" - # service: - # - svc_type: "FW" - # address: - # - "192.168.2.10" - # interface: "GigabitEthernet0/0" - # track_enable: true - # service_route: - # - prefix: "192.168.3.0/24" - # vpn: 10 - # service: "sig" - # route_v4: - # - prefix: "192.168.1.0/24" - # next_hop: - # - address: "192.168.1.1" - # distance: 10 - # next_hop_with_track: - # - address: "192.168.1.2" - # distance: 20 - # tracker: "Track1" - # route_interface: - # interface_name: "GigabitEthernet0/0" - # interface_next_hop: - # - address: "2001:db8:abcd:0012::1" - # distance: 1 - # null0: false - # distance: 1 - # vpn: 10 - # dhcp: false - # route_v6: - # - prefix: "2001:db8:abcd:0012::/64" - # next_hop: - # - address: "2001:db8:abcd:0012::1" - # distance: 10 - # null0: false - # vpn: 10 - # nat: "NAT64" - # gre_route: - # - prefix: "10.0.0.0/8" - # vpn: 20 - # interface: - # - "Tunnel0" - # ipsec_route: - # - prefix: "172.16.0.0/12" - # vpn: 30 - # interface: - # - "Tunnel1" - # advertise: - # - protocol: bgp - # route_policy: "BGP-Export-Policy" - # protocol_sub_type: - # - external - # prefix_list: - # - prefix_entry: "192.168.50.0/24" - # aggregate_only: false - # region: core - # - prefix_entry: "192.168.60.0/24" - # aggregate_only: true - # region: access - # ipv6_advertise: - # - protocol: bgp - # route_policy: "BGP-IPv6-Export-Policy" - # protocol_sub_type: - # - external - # prefix_list: - # - prefix_entry: "2001:db8:abcd:0012::/64" - # aggregate_only: false - # region: core - # - prefix_entry: "2001:db8:abcd:0034::/64" - # aggregate_only: true - # region: access - # pool: - # - name: "NAT64Pool1" - # start_address: "203.0.113.1" - # end_address: "203.0.113.100" - # overload: true - # leak_from_global: true - # leak_from_global_protocol: static - # leak_to_global: false - # natpool: - # - name: 101 - # prefix_length: 24 - # range_start: "192.0.2.1" - # range_end: "192.0.2.100" - # overload: 'true' - # direction: inside - # tracker_id: 1 - # static: - # - pool_name: 101 - # source_ip: "198.51.100.5" - # translate_ip: "203.0.113.5" - # static_nat_direction: inside - # tracker_id: 2 - # subnet_static: - # - source_ip_subnet: "198.51.100.0/24" - # translate_ip_subnet: "203.0.113.0/24" - # prefix_length: 24 - # static_nat_direction: inside - # port_forward: - # - pool_name: 101 - # source_port: 8080 - # translate_port: 80 - # source_ip: "198.51.100.5" - # translate_ip: "203.0.113.5" - # proto: tcp - # route_import: - # - protocol: bgp - # protocol_sub_type: ['external'] - # route_policy: 'import-bgp-routes' - # redistribute: - # - protocol: ospf - # route_policy: 'ospf-to-bgp' - # route_import_from: - # - source_vpn: 10 - # protocol: static - # protocol_sub_type: - # - external - # route_policy: 'import-static-from-vpn10' - # redistribute: - # - protocol: eigrp - # route_policy: 'eigrp-to-vpn10' - # route_export: - # - protocol: bgp - # protocol_sub_type: - # - external - # route_policy: 'export-bgp-routes' - # redistribute: - # - protocol: bgp - # route_policy: 'static-to-bgp' - # manager_credentials: - # <<: *manager_authentication + - name: "Create Comprehensive Cisco VPN Template" + cisco.catalystwan.feature_templates: + state: present + template_name: "ComprehensiveCiscoVPNTemplate" + template_description: "Cisco VPN template" + debug: true + # device_models: + # - "vedge-C8000V" + cisco_vpn: + vpn_id: 10 + vpn_name: "CorporateVPN" + tenant_vpn_id: 200 + org_name: "ACME_Corporation" + omp_admin_distance_ipv4: 5 + omp_admin_distance_ipv6: 5 + dns: + - dns_addr: "8.8.8.8" + role: "primary" + - dns_addr: "8.8.4.4" + role: "secondary" + dns_ipv6: + - dns_addr: "2001:4860:4860::8888" + role: "primary" + - dns_addr: "2001:4860:4860::8844" + role: "secondary" + layer4: true + host: + - hostname: "server1.example.com" + ip: + - "192.168.1.10" + service: + - svc_type: "FW" + address: + - "192.168.2.10" + interface: "GigabitEthernet0/0" + track_enable: true + service_route: + - prefix: "192.168.3.0/24" + vpn: 10 + service: "sig" + route_v4: + - prefix: "192.168.1.0/24" + next_hop: + - address: "192.168.1.1" + distance: 10 + next_hop_with_track: + - address: "192.168.1.2" + distance: 20 + tracker: "Track1" + route_interface: + interface_name: "GigabitEthernet0/0" + interface_next_hop: + - address: "2001:db8:abcd:0012::1" + distance: 1 + null0: false + distance: 1 + vpn: 10 + dhcp: false + route_v6: + - prefix: "2001:db8:abcd:0012::/64" + next_hop: + - address: "2001:db8:abcd:0012::1" + distance: 10 + null0: false + vpn: 10 + nat: "NAT64" + gre_route: + - prefix: "10.0.0.0/8" + vpn: 20 + interface: + - "Tunnel0" + ipsec_route: + - prefix: "172.16.0.0/12" + vpn: 30 + interface: + - "Tunnel1" + advertise: + - protocol: bgp + route_policy: "BGP-Export-Policy" + protocol_sub_type: + - external + prefix_list: + - prefix_entry: "192.168.50.0/24" + aggregate_only: false + region: core + - prefix_entry: "192.168.60.0/24" + aggregate_only: true + region: access + ipv6_advertise: + - protocol: bgp + route_policy: "BGP-IPv6-Export-Policy" + protocol_sub_type: + - external + prefix_list: + - prefix_entry: "2001:db8:abcd:0012::/64" + aggregate_only: false + region: core + - prefix_entry: "2001:db8:abcd:0034::/64" + aggregate_only: true + region: access + pool: + - name: "NAT64Pool1" + start_address: "203.0.113.1" + end_address: "203.0.113.100" + overload: true + leak_from_global: true + leak_from_global_protocol: static + leak_to_global: false + natpool: + - name: 101 + prefix_length: 24 + range_start: "192.0.2.1" + range_end: "192.0.2.100" + overload: 'true' + direction: inside + tracker_id: 1 + static: + - pool_name: 101 + source_ip: "198.51.100.5" + translate_ip: "203.0.113.5" + static_nat_direction: inside + tracker_id: 2 + subnet_static: + - source_ip_subnet: "198.51.100.0/24" + translate_ip_subnet: "203.0.113.0/24" + prefix_length: 24 + static_nat_direction: inside + port_forward: + - pool_name: 101 + source_port: 8080 + translate_port: 80 + source_ip: "198.51.100.5" + translate_ip: "203.0.113.5" + proto: tcp + route_import: + - protocol: bgp + protocol_sub_type: ['external'] + route_policy: 'import-bgp-routes' + redistribute: + - protocol: ospf + route_policy: 'ospf-to-bgp' + route_import_from: + - source_vpn: 10 + protocol: static + protocol_sub_type: + - external + route_policy: 'import-static-from-vpn10' + redistribute: + - protocol: eigrp + route_policy: 'eigrp-to-vpn10' + route_export: + - protocol: bgp + protocol_sub_type: + - external + route_policy: 'export-bgp-routes' + redistribute: + - protocol: bgp + route_policy: 'static-to-bgp' + manager_credentials: + <<: *manager_authentication - # - name: "Create Comprehensive OMP vSmart Template" - # cisco.catalystwan.feature_templates: - # state: present - # template_name: "OMPvSmartConfigTemplate" - # template_description: "Apply OMP settings for vSmart controller" - # debug: true - # device_models: vsmart - # omp_vsmart: - # graceful_restart: true - # graceful_restart_timer: 120 - # send_path_limit: 100 - # send_backup_paths: true - # shutdown: false - # discard_rejected: false - # eor_timer: 50 - # holdtime: 300 - # affinity_group_preference: true - # advertisement_interval: 30 - # tloc_color: true - # manager_credentials: - # <<: *manager_authentication + - name: "Create Comprehensive OMP vSmart Template" + cisco.catalystwan.feature_templates: + state: present + template_name: "OMPvSmartConfigTemplate" + template_description: "Apply OMP settings for vSmart controller" + debug: true + device_models: vsmart + omp_vsmart: + graceful_restart: true + graceful_restart_timer: 120 + send_path_limit: 100 + send_backup_paths: true + shutdown: false + discard_rejected: false + eor_timer: 50 + holdtime: 300 + affinity_group_preference: true + advertisement_interval: 30 + tloc_color: true + manager_credentials: + <<: *manager_authentication - # - name: "Create Comprehensive Security vSmart Template" - # cisco.catalystwan.feature_templates: - # state: present - # template_name: "SecurityvSmartConfigTemplate" - # template_description: "Apply Security settings for vSmart controller" - # debug: true - # device_models: vsmart - # security_vsmart: - # protocol: dtls - # tls_port: 120 - # manager_credentials: - # <<: *manager_authentication + - name: "Create Comprehensive Security vSmart Template" + cisco.catalystwan.feature_templates: + state: present + template_name: "SecurityvSmartConfigTemplate" + template_description: "Apply Security settings for vSmart controller" + debug: true + device_models: vsmart + security_vsmart: + protocol: dtls + tls_port: 120 + manager_credentials: + <<: *manager_authentication - name: "Create Comprehensive System vSmart Template" cisco.catalystwan.feature_templates: @@ -1039,20 +1040,40 @@ manager_credentials: <<: *manager_authentication - # # Example of devices specific variables - this works in Feature Templates, need to check Device Templates - # - name: Create Cisco Banner Feature Template - # cisco.catalystwan.feature_templates: - # state: present - # template_name: "CiscoBannerConfigTemplate" - # template_description: "Banner configuration for login and MOTD" - # debug: true - # device_specific_variables: - # login_banner: "var_name_1" - # motd_banner: "var_name_2" - # device_models: - # - "vedge-C8000V" - # cisco_banner: - # login_banner: device_specific_variable - # motd_banner: device_specific_variable - # manager_credentials: - # <<: *manager_authentication +# # # Example of devices specific variables - this works in Feature Templates, need to check Device Templates +# # - name: Create Cisco Banner Feature Template +# # cisco.catalystwan.feature_templates: +# # state: present +# # template_name: "CiscoBannerConfigTemplate" +# # template_description: "Banner configuration for login and MOTD" +# # debug: true +# # device_specific_variables: +# # login_banner: "var_name_1" +# # motd_banner: "var_name_2" +# # device_models: +# # - "vedge-C8000V" +# # cisco_banner: +# # login_banner: device_specific_variable +# # motd_banner: device_specific_variable +# # manager_credentials: +# # <<: *manager_authentication + + + +# """ +# By default it should use default Feature Template + +# But if user want to change it, they have choice and they should do it explicitly + + + +# Change create -> add for Feature Template + +# """ +# - name: "Create Comprehensive OMP vSmart Template" +# cisco.catalystwan.device_templates: +# state: attached +# template_name: "OMPvSmartConfigTemplate" +# template_description: "Apply OMP settings for vSmart controller" +# debug: true +# device_models: "" diff --git a/plugins/doc_fragments/feature_template_cisco_aaa.py b/plugins/doc_fragments/feature_template_cisco_aaa.py index 3ca2fb3..0deb19f 100644 --- a/plugins/doc_fragments/feature_template_cisco_aaa.py +++ b/plugins/doc_fragments/feature_template_cisco_aaa.py @@ -76,7 +76,7 @@ class ModuleDocFragment(object): description: - List of public keys for the user required: false - default: [] + default: null type: list elements: dict suboptions: diff --git a/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py b/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py index 0e5a519..797b085 100644 --- a/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py +++ b/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py @@ -259,6 +259,12 @@ class ModuleDocFragment(object): required: false default: null type: bool + tunnel_public_ip: + description: + - Public IP required to setup GRE tunnel to Zscaler + required: false + default: null + type: str service: description: - List of service configurations for the Cisco Secure Internet Gateway. @@ -426,9 +432,16 @@ class ModuleDocFragment(object): required: false default: null type: int + location_name: + description: + - Secondary data center for the service. 'Auto' for automatic + selection. + required: false + default: Auto + type: str data_center_primary: description: - - Alias for the primary data center setting. + - Zscaler location name (optional) required: false default: Auto type: str diff --git a/plugins/module_utils/feature_templates/cisco_aaa.py b/plugins/module_utils/feature_templates/cisco_aaa.py index 1ae2f48..9ce7dc3 100644 --- a/plugins/module_utils/feature_templates/cisco_aaa.py +++ b/plugins/module_utils/feature_templates/cisco_aaa.py @@ -177,7 +177,7 @@ 'privilege': { 'default': '15', 'required': False, 'type': 'str'}, - 'pubkey_chain': { 'default': [ ], + 'pubkey_chain': { 'default': None, 'elements': 'dict', 'options': { 'key_string': { 'default': None, 'required': True, diff --git a/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py b/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py index ba90a49..5c29620 100644 --- a/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py +++ b/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py @@ -82,6 +82,9 @@ 'tunnel_destination': { 'default': None, 'required': True, 'type': 'str'}, + 'tunnel_public_ip': { 'default': None, + 'required': False, + 'type': 'str'}, 'tunnel_route_via': { 'default': None, 'required': False, 'type': 'str'}, @@ -153,6 +156,9 @@ 'ips_control': { 'default': None, 'required': False, 'type': 'bool'}, + 'location_name': { 'default': 'Auto', + 'required': False, + 'type': 'str'}, 'ofw_enabled': { 'default': None, 'required': False, 'type': 'bool'}, From 7aa84d229e0967152ab3e5d45f628bdeaf976ba5 Mon Sep 17 00:00:00 2001 From: acichon Date: Mon, 13 May 2024 14:22:55 +0200 Subject: [PATCH 11/18] Final part of Feature Templates --- .ansible-lint | 2 + .gitignore | 2 + playbooks/tests/test_feature_templates.yml | 109 +++++------ .../feature_template_cisco_snmp.py | 7 +- .../feature_template_cisco_system.py | 10 +- .../feature_templates/cisco_snmp.py | 180 ++++++++---------- plugins/module_utils/vmanage_module.py | 2 +- plugins/modules/feature_templates.py | 74 +++---- plugins/modules/feature_templates_info.py | 118 ++++++++++-- plugins/modules/vmanage_mode.py | 5 +- utils/ft_device_model.j2 | 4 +- utils/ft_generator.py | 40 ++-- 12 files changed, 289 insertions(+), 264 deletions(-) diff --git a/.ansible-lint b/.ansible-lint index 218f356..08c6545 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -28,6 +28,8 @@ mock_modules: - cisco.catalystwan.devices_controllers - cisco.catalystwan.devices_info - cisco.catalystwan.devices_wan_edges + - cisco.catalystwan.feature_templates + - cisco.catalystwan.feature_templates_info - cisco.catalystwan.health_checks - cisco.catalystwan.server_info - cisco.catalystwan.software_repository diff --git a/.gitignore b/.gitignore index 6eb99a4..22f407b 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ playbooks/tests/configuration_file_dev_vars.yml playbooks/tests/ansible_catalystwan.log playbooks/tests/ansible_catalystwan_module.log playbooks/tests/catalystwan.log +playbooks/tests/payload* +playbooks/tests/response* diff --git a/playbooks/tests/test_feature_templates.yml b/playbooks/tests/test_feature_templates.yml index d9d103c..c31c9fd 100644 --- a/playbooks/tests/test_feature_templates.yml +++ b/playbooks/tests/test_feature_templates.yml @@ -48,8 +48,8 @@ template_name: "ComprehensiveAAATemplate" template_description: "AAA Template with both TACACS+ and RADIUS servers" debug: true - # device_models: - # - vedge-C8000V + device_models: + - vedge-C8000V cisco_aaa: user: - name: "local_admin" @@ -57,7 +57,7 @@ secret: "admin_secret" privilege: "15" pubkey_chain: - - key_string: "AAAAB3NzaC1yc2EAAAADAQABAAABAQC3myRj5L6ZFLdRnOEZdUd+4Qq0XPLW9RfO6qD7DJ2t4ZzLh6Oz+IUJg8d8bJDfxO9zGKs5uUQ9f2H5yTGX5G8Z5kKp8QDp1MkDVqwGJ4UM7JqH8s8kD7xcl8SyPc5TjzK4s4W+8LPNOPXmIKtHh1Qlvkp5N7w3M/Rm5ZVX5/3+Hk8Ib5syigQQd/5u5xJj9k3i2x3m3LZ7v5e7YlCpRdCQGf6ZCwvbVQHdJp5nlU0HxJbqjOTL4IcDj09G3Dq2C5JnohKJb7E7HVCUl7F5vYpC/4iNjges65GgdzaFJsT9qA8CgxyF+7J3PpLk5qPAQDT5OjArJj4x9Bw3j3lZdH example@example.com" + - key_string: "AAAAB3NzaC1yc2EAAAADAQABAAABAQC3myRj5L6ZFLdRnOEZdUd+4Qq0XPLW9RfO6qD7DJ2t4ZzLh6Oz+IUJg8d8bJDfxO9zGKs5uUQ9f2H5yTGX5G8Z5kKp8QDp1MkDVqwGJ4UM7JqH8s8kD7xcl8SyPc5TjzK4s4W+8LPNOPXmIKtHh1Qlvkp5N7w3M/Rm5ZVX5/3+Hk8Ib5syigQQd/5u5xJj9k3i2x3m3LZ7v5e7YlCpRdCQGf6ZCwvbVQHdJp5nlU0HxJbqjOTL4IcDj09G3Dq2C5JnohKJb7E7HVCUl7F5vYpC/4iNjges65GgdzaFJsT9qA8CgxyF+7J3PpLk5qPAQDT5OjArJj4x9Bw3j3lZdH example@example.com" # noqa yaml[line-length] key_type: "ssh-rsa" authentication_group: true accounting_group: true @@ -110,7 +110,7 @@ timeout: 10 key: "tacacs_key" secret_key: "tacacs_secret" - key_enum: "key_enum_value" + key_enum: "key_enum_value" manager_credentials: <<: *manager_authentication @@ -120,8 +120,8 @@ template_name: "CiscoBannerConfigTemplate" template_description: "Banner configuration for login and MOTD" debug: true - # device_models: - # - "vedge-C8000V" + device_models: + - "vedge-C8000V" cisco_banner: login_banner: | **************************************************************** @@ -148,8 +148,8 @@ template_name: "CiscoBFDFeatureTemplate" template_description: "Comprehensive BFD configuration" debug: true - # device_models: - # - "vedge-C8000V" + device_models: + - "vedge-C8000V" cisco_bfd: multiplier: "3" poll_interval: "500" @@ -184,8 +184,8 @@ template_name: "CiscoLoggingFeatureTemplate" template_description: "Comprehensive Logging Configuration" debug: true - # device_models: - # - "vedge-C8000V" + device_models: + - "vedge-C8000V" cisco_logging: enable: true size: "20" @@ -238,8 +238,8 @@ template_name: "CiscoNTPFeatureTemplate" template_description: "Comprehensive NTP Configuration" debug: true - # device_models: - # - "vedge-C8000V" + device_models: + - "vedge-C8000V" cisco_ntp: server: - name: "0.pool.ntp.org" @@ -274,8 +274,8 @@ template_name: "CiscoOMPFeatureTemplate" template_description: "Comprehensive OMP Configuration" debug: true - # device_models: - # - "vsmart" + device_models: + - "vsmart" cisco_omp: graceful_restart: true overlay_as: "65000" @@ -319,8 +319,8 @@ template_name: "CiscoOSPFeatureTemplate" template_description: "Comprehensive OSPF Configuration" debug: true - # device_models: - # - "vedge-C8000V" + device_models: + - "vedge-C8000V" cisco_ospf: router_id: "1.1.1.1" reference_bandwidth: "10000" @@ -369,7 +369,7 @@ cost: "100" no_advertise: true manager_credentials: - <<: *manager_authentication + <<: *manager_authentication - name: "Configure Secure Internet Gateway feature template" cisco.catalystwan.feature_templates: @@ -377,8 +377,8 @@ template_name: "CiscoSecureInternetGatewayFeatureTemplate" template_description: "Comprehensive CiscoSecureInternetGateway Configuration" debug: true - # device_models: - # - "vedge-C8000V" + device_models: + - "vedge-C8000V" cisco_secure_internet_gateway: vpn_id: 10 child_org_id: "example_org" @@ -455,6 +455,7 @@ cisco.catalystwan.feature_templates: state: present template_name: "CiscoSNMPFeatureTemplate" + debug: true template_description: "Comprehensive Cisco SNMP Configuration" cisco_snmp: shutdown: false @@ -505,8 +506,8 @@ template_name: "ComprehensiveCiscoSystemTemplate" template_description: "Cisco System template" debug: true - # device_models: - # - "vedge-C8000V" + device_models: + - "vedge-C8000V" cisco_system: timezone: "UTC" description: "Example desc" @@ -595,7 +596,7 @@ vrf: - vrf_id: 1 gateway_preference: - - 4 + - 4 - 5 - vrf_id: 2 gateway_preference: @@ -621,8 +622,8 @@ template_name: "ComprehensiveCiscoVPNInterfaceTemplate" template_description: "Cisco VPN Interface template" debug: true - # device_models: - # - "vedge-C8000V" + device_models: + - "vedge-C8000V" cisco_vpn_interface: if_name: "GigabitEthernet0/0" interface_description: "WAN interface" @@ -808,8 +809,8 @@ template_name: "ComprehensiveCiscoVPNTemplate" template_description: "Cisco VPN template" debug: true - # device_models: - # - "vedge-C8000V" + device_models: + - "vedge-C8000V" cisco_vpn: vpn_id: 10 vpn_name: "CorporateVPN" @@ -969,7 +970,7 @@ template_name: "OMPvSmartConfigTemplate" template_description: "Apply OMP settings for vSmart controller" debug: true - device_models: vsmart + device_models: "vsmart" omp_vsmart: graceful_restart: true graceful_restart_timer: 120 @@ -1040,40 +1041,20 @@ manager_credentials: <<: *manager_authentication -# # # Example of devices specific variables - this works in Feature Templates, need to check Device Templates -# # - name: Create Cisco Banner Feature Template -# # cisco.catalystwan.feature_templates: -# # state: present -# # template_name: "CiscoBannerConfigTemplate" -# # template_description: "Banner configuration for login and MOTD" -# # debug: true -# # device_specific_variables: -# # login_banner: "var_name_1" -# # motd_banner: "var_name_2" -# # device_models: -# # - "vedge-C8000V" -# # cisco_banner: -# # login_banner: device_specific_variable -# # motd_banner: device_specific_variable -# # manager_credentials: -# # <<: *manager_authentication - - - -# """ -# By default it should use default Feature Template - -# But if user want to change it, they have choice and they should do it explicitly - - - -# Change create -> add for Feature Template - -# """ -# - name: "Create Comprehensive OMP vSmart Template" -# cisco.catalystwan.device_templates: -# state: attached -# template_name: "OMPvSmartConfigTemplate" -# template_description: "Apply OMP settings for vSmart controller" -# debug: true -# device_models: "" + # Example of devices specific variables - this works in Feature Templates, need to check Device Templates + - name: Create Cisco Banner Feature Template + cisco.catalystwan.feature_templates: + state: present + template_name: "CiscoBannerConfigTemplateDSV" + template_description: "Banner configuration for login and MOTD with DSV" + debug: true + device_specific_variables: + login_banner: "var_name_1" + motd_banner: "var_name_2" + device_models: + - "vedge-C8000V" + cisco_banner: + login_banner: device_specific_variable + motd_banner: device_specific_variable + manager_credentials: + <<: *manager_authentication diff --git a/plugins/doc_fragments/feature_template_cisco_snmp.py b/plugins/doc_fragments/feature_template_cisco_snmp.py index fb5c544..c497c0e 100644 --- a/plugins/doc_fragments/feature_template_cisco_snmp.py +++ b/plugins/doc_fragments/feature_template_cisco_snmp.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r''' + DOCUMENTATION = r""" options: cisco_snmp: description: Cisco SNMP Feature Template configuration @@ -161,11 +161,12 @@ class ModuleDocFragment(object): priv: description: - The privacy (encryption) protocol used - required: true + required: false default: null type: str choices: - aes-cfb-128 + - aes-256-cfb-128 priv_password: description: - The password for privacy @@ -222,4 +223,4 @@ class ModuleDocFragment(object): required: false default: null type: str - ''' \ No newline at end of file + """ diff --git a/plugins/doc_fragments/feature_template_cisco_system.py b/plugins/doc_fragments/feature_template_cisco_system.py index 1484700..bb1d3ae 100644 --- a/plugins/doc_fragments/feature_template_cisco_system.py +++ b/plugins/doc_fragments/feature_template_cisco_system.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r''' + DOCUMENTATION = r""" options: cisco_system: description: Cisco System configuration settings for SD-WAN devices. @@ -455,7 +455,7 @@ class ModuleDocFragment(object): suboptions: name: description: - - null + - Device Specific Variables names required: true default: null type: str @@ -533,7 +533,7 @@ class ModuleDocFragment(object): suboptions: name: description: - - null + - Device Specific Variables names required: true default: null type: str @@ -662,7 +662,7 @@ class ModuleDocFragment(object): suboptions: name: description: - - null + - Name for the Tracker required: true default: null type: str @@ -940,4 +940,4 @@ class ModuleDocFragment(object): - aggressive - moderate - conservative - ''' \ No newline at end of file + """ diff --git a/plugins/module_utils/feature_templates/cisco_snmp.py b/plugins/module_utils/feature_templates/cisco_snmp.py index 4c253a0..1018a10 100644 --- a/plugins/module_utils/feature_templates/cisco_snmp.py +++ b/plugins/module_utils/feature_templates/cisco_snmp.py @@ -1,99 +1,81 @@ -cisco_snmp_definition = { 'cisco_snmp': { 'default': None, - 'options': { 'community': { 'default': None, - 'elements': 'dict', - 'options': { 'authorization': { 'default': None, - 'required': True, - 'type': 'str'}, - 'name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'view': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'contact': { 'default': None, - 'required': False, - 'type': 'str'}, - 'group': { 'default': None, - 'elements': 'dict', - 'options': { 'name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'security_level': { 'default': None, - 'required': True, - 'type': 'str'}, - 'view': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'location': { 'default': None, - 'required': False, - 'type': 'str'}, - 'shutdown': { 'default': True, - 'required': False, - 'type': 'bool'}, - 'target': { 'default': None, - 'elements': 'dict', - 'options': { 'community_name': { 'default': None, - 'required': False, - 'type': 'str'}, - 'ip': { 'default': None, - 'required': True, - 'type': 'str'}, - 'port': { 'default': None, - 'required': True, - 'type': 'int'}, - 'source_interface': { 'default': None, - 'required': False, - 'type': 'str'}, - 'user': { 'default': None, - 'required': False, - 'type': 'str'}, - 'vpn_id': { 'default': None, - 'required': True, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'user': { 'default': None, - 'elements': 'dict', - 'options': { 'auth': { 'default': None, - 'required': False, - 'type': 'str'}, - 'auth_password': { 'default': None, - 'required': False, - 'type': 'str'}, - 'group': { 'default': None, - 'required': True, - 'type': 'str'}, - 'name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'priv': { 'default': None, - 'required': True, - 'type': 'str'}, - 'priv_password': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'view': { 'default': None, - 'elements': 'dict', - 'options': { 'name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'oid': { 'default': None, - 'elements': 'dict', - 'options': { 'exclude': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'id': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}}, - 'required': False, - 'type': 'list'}}, - 'required': False, - 'type': 'dict'}} +cisco_snmp_definition = { + "cisco_snmp": { + "default": None, + "options": { + "community": { + "default": None, + "elements": "dict", + "options": { + "authorization": {"default": None, "required": True, "type": "str"}, + "name": {"default": None, "required": True, "type": "str"}, + "view": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "contact": {"default": None, "required": False, "type": "str"}, + "group": { + "default": None, + "elements": "dict", + "options": { + "name": {"default": None, "required": True, "type": "str"}, + "security_level": {"default": None, "required": True, "type": "str"}, + "view": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "location": {"default": None, "required": False, "type": "str"}, + "shutdown": {"default": True, "required": False, "type": "bool"}, + "target": { + "default": None, + "elements": "dict", + "options": { + "community_name": {"default": None, "required": False, "type": "str"}, + "ip": {"default": None, "required": True, "type": "str"}, + "port": {"default": None, "required": True, "type": "int"}, + "source_interface": {"default": None, "required": False, "type": "str"}, + "user": {"default": None, "required": False, "type": "str"}, + "vpn_id": {"default": None, "required": True, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "user": { + "default": None, + "elements": "dict", + "options": { + "auth": {"default": None, "required": False, "type": "str"}, + "auth_password": {"default": None, "required": False, "type": "str"}, + "group": {"default": None, "required": True, "type": "str"}, + "name": {"default": None, "required": True, "type": "str"}, + "priv": {"default": None, "required": False, "type": "str"}, + "priv_password": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "view": { + "default": None, + "elements": "dict", + "options": { + "name": {"default": None, "required": True, "type": "str"}, + "oid": { + "default": None, + "elements": "dict", + "options": { + "exclude": {"default": None, "required": False, "type": "bool"}, + "id": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + }, + "required": False, + "type": "list", + }, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/vmanage_module.py b/plugins/module_utils/vmanage_module.py index e0a6b35..85864c9 100644 --- a/plugins/module_utils/vmanage_module.py +++ b/plugins/module_utils/vmanage_module.py @@ -93,7 +93,7 @@ def params(self) -> Dict: return self.module.params @property - def params_without_none_values(self): + def params_without_none_values(self) -> Dict: """ When passing values to catalystwan endpoints, we don't want to modify state by providing any None values. """ diff --git a/plugins/modules/feature_templates.py b/plugins/modules/feature_templates.py index 529e54a..71098ab 100644 --- a/plugins/modules/feature_templates.py +++ b/plugins/modules/feature_templates.py @@ -7,15 +7,11 @@ DOCUMENTATION = r""" --- module: vmanage_feature_template - short_description: Manage feature templates for Cisco vManage SD-WAN - -version_added: "1.0.0" - +version_added: "0.1.0" description: - This module can be used to create, modify, and delete feature templates in Cisco vManage SD-WAN. - The feature template configuration is defined via Python Pydantic models. - options: state: description: @@ -56,8 +52,8 @@ - cisco.catalystwan.feature_template_cisco_secure_internet_gateway - cisco.catalystwan.feature_template_cisco_snmp - cisco.catalystwan.feature_template_cisco_system - - cisco.catalystwan.feature_template_cisco_vpn_interface - cisco.catalystwan.feature_template_cisco_vpn + - cisco.catalystwan.feature_template_cisco_vpn_interface - cisco.catalystwan.feature_template_omp_vsmart - cisco.catalystwan.feature_template_security_vsmart - cisco.catalystwan.feature_template_system_vsmart @@ -68,14 +64,13 @@ """ -from enum import Enum from pydantic import BaseModel, Field, ConfigDict -from typing import Optional, Dict, Final +from typing import Optional, Dict, Final, get_args, Literal from catalystwan.api.template_api import FeatureTemplate from catalystwan.dataclasses import FeatureTemplateInfo from catalystwan.typed_list import DataSequence -from catalystwan.utils.device_model import DeviceModel +from catalystwan.models.common import DeviceModel from catalystwan.session import ManagerHTTPError from catalystwan.api.templates.models.supported import available_models @@ -101,30 +96,27 @@ ALLOW: Final[str] = "allow" -class ExtendedModuleResult(ModuleResult): - templates_info: Optional[Dict] = Field(default={}) +class Values(BaseModel): + model_config = ConfigDict(extra=ALLOW, populate_by_name=True) -class State(str, Enum): - PRESENT = "present" - MODIFIED = "modified" - ABSENT = "absent" +class ExtendedModuleResult(ModuleResult): + templates_info: Optional[Dict] = Field(default={}) -class Values(BaseModel): - model_config = ConfigDict(extra=ALLOW, populate_by_name=True) +State = Literal["present", "modified", "absent"] def run_module(): module_args = dict( state=dict( type=str, - choices=[State.PRESENT, State.ABSENT, State.MODIFIED], - default=State.PRESENT.value, + choices=list(get_args(State)), + default="present", ), template_name=dict(type="str", required=True), template_description=dict(type="str", default=None), - device_models=dict(type="list", choices=[device_model.value for device_model in DeviceModel], default=[]), + device_models=dict(type="list", choices=list(get_args(DeviceModel)), default=[]), debug=dict(type="bool", default=False), device_specific_variables=dict(type="raw", default={}), device=dict(type="str", default=None), # For this we need to think how to pass devices @@ -154,7 +146,7 @@ def run_module(): required_if=[ ( "state", - State.PRESENT.value, + "present", ( "template_name", "template_description", @@ -164,7 +156,7 @@ def run_module(): ), ( "modified", - State.MODIFIED.value, + "modified", ( "template_name", "template_description", @@ -172,12 +164,12 @@ def run_module(): ), True, ), - ("state", State.ABSENT.value, ("template_name",), True), + ("state", "absent", ("template_name",), True), ], ) # Verify if we are dealing with one or more templates template_name = module.params.get("template_name") - device_specific_variables = module.params.get("device_specific_variables") + device_specific_variables: Dict = module.params.get("device_specific_variables") module.logger.info(f"Module input: \n{module.params}\n") all_templates: DataSequence[FeatureTemplateInfo] = module.get_response_safely( @@ -185,9 +177,9 @@ def run_module(): ) target_template: FeatureTemplateInfo = all_templates.filter(name=template_name) - # Code for checking if template name exists already - # if yes, do we need some force method or we just inform user and exit? if module.params.get("state") == "present": + # Code for checking if template name exists already + # if yes, do we need some force method or we just inform user and exit? if target_template: module.logger.debug(f"Detected existing template:\n{target_template}\n") result.msg = ( @@ -199,23 +191,19 @@ def run_module(): if module.params[model_name] is not None: module.logger.debug(f"Template input:\n{module.params_without_none_values[model_name]}\n") # Perform action with template - - module.logger.debug(f"device_specific_variables:\n{device_specific_variables}\n") - # only temporary part for debugging - configuration = module.params_without_none_values[model_name] - # Check if any device_specific_variables defined + + configuration: Dict = module.params_without_none_values[model_name] + + # Check if any device_specific_variables defined and use them in template if device_specific_variables: _dsv = Values() for key, value in device_specific_variables.items(): dev_value = DeviceVariable(name=value) setattr(_dsv, key, dev_value) - module.logger.debug(f"{_dsv}") - + for field, value in configuration.items(): if value == "device_specific_variable": - module.logger.debug(f"{field}: {value}") configuration[field] = _dsv.model_extra[field] - module.logger.debug(f"configuration[field]:\n{configuration[field]}\n") template = model_module( template_name=template_name, @@ -231,7 +219,7 @@ def run_module(): module.session.api.templates.create(template=template, debug=module.params.get("debug")) except ManagerHTTPError as ex: module.fail_json( - msg=f"Could not perform create Feature Template {template_name}.\nManager error: {ex.info}" + msg=f"Could not perform add Feature Template {template_name}.\nManager error: {ex.info}" ) result.changed = True result.msg += f"Created template {model_name}: {template}" @@ -241,18 +229,8 @@ def run_module(): result.changed = True result.msg = f"Deleted template {template_name}" - # if filters: - # filtered_templates = all_templates.filter(**filters) - # if filtered_templates: - # module.logger.info(f"All Feature Templates filtered with filters: {filters}:\n{filtered_templates}") - # result.msg = "Succesfully got all requested Feature Templates Info from vManage" - # result.templates_info = [asdict(template) for template in filtered_templates] - # else: - # module.logger.warning(msg=f"Feature templates filtered with `{filters}` not present.") - # result.msg = f"Feature templates filtered with `{filters}` not present on vManage." - # else: - # result.msg = "Succesfully got all Feature Templates Info from vManage" - # result.templates_info = [asdict(template) for template in all_templates] + if module.params.get("state") == "modified": + module.fail_json(msg="Module parameter 'modified' not implemented yet!") module.exit_json(**result.model_dump(mode="json")) diff --git a/plugins/modules/feature_templates_info.py b/plugins/modules/feature_templates_info.py index f957b38..f398b8c 100644 --- a/plugins/modules/feature_templates_info.py +++ b/plugins/modules/feature_templates_info.py @@ -4,6 +4,7 @@ # Copyright 2024 Cisco Systems, Inc. and its affiliates # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + DOCUMENTATION = r""" --- module: feature_templates_info @@ -14,15 +15,83 @@ options: filters: description: - - A dictionary of filters used to select devices for module action. + - A dictionary of filters used to select Feature Templates info. type: dict required: false - # suboptions: - # description: - # - The login banner text displayed before authentication - # required: false - # default: null - # type: str + suboptions: + template_type: + description: + - The type of template, eg. "system-vsmart + required: false + default: null + type: str + device_type: + description: + - The device type of the template + required: false + default: null + type: list + elements: str + name: + description: + - The name of the Feature Template. + required: false + default: null + type: str + description: + description: + - Description of the Feature Template. + required: false + default: null + type: str + version: + description: + - Version of the Feature Template. + required: false + default: null + type: str + factory_default: + description: + - If template is Factory Default template. + required: false + default: null + type: bool + template_definiton: + description: + - The definiton of Feature Template. + required: false + default: null + type: str + devices_attached: + description: + - Number of attached devices. + required: false + default: null + type: int + id: + description: + - Feature Template ID. + required: false + default: null + type: str + last_updated_on: + description: + - Last Updated on value. + required: false + default: null + type: int + last_updated_by: + description: + - Last Updated by value. + required: false + default: null + type: str + resource_group: + description: + - Resource Group value. + required: false + default: null + type: str author: - Arkadiusz Cichon (acichon@cisco.com) extends_documentation_fragment: @@ -32,22 +101,35 @@ """ EXAMPLES = r""" -- name: Attach default CLI template to the specified devices +- name: Get all Non-Default Feature Templates available cisco.catalystwan.feature_templates_info: filters: - name: "trial-template" + factory_default: false + manager_credentials: + ... + register: feature_templates """ RETURN = r""" template_info: - description: A dictionary of templates with the key as template name and value as device hostname. - type: dict + description: A list of dictionaries of templates info + type: list returned: on success sample: | - { - "Default_device1": "device1", - "Default_device2": "device2" - } + templates_info: + - deviceType: + - vedge-C8000V + devicesAttached: 0 + factoryDefault: false + lastUpdatedBy: example_user + lastUpdatedOn: 111111111 + resourceGroup: example_groupo + templateDefinition: null + templateDescription: AAA Template with both TACACS+ and RADIUS servers + templateId: xxxx-xxxx-xxxx-xxxx + templateMinVersion: X.X.X.X + templateName: example_name + templateType: cedge_aaa msg: description: Messages that indicate actions taken or any errors that have occurred. type: str @@ -85,9 +167,11 @@ def run_module(): module = AnsibleCatalystwanModule(argument_spec=module_args) - filters = module.params.get('filters') + filters = module.params.get("filters") - all_templates: DataSequence[FeatureTemplateInfo] = module.get_response_safely(module.session.api.templates.get, template=FeatureTemplate) + all_templates: DataSequence[FeatureTemplateInfo] = module.get_response_safely( + module.session.api.templates.get, template=FeatureTemplate + ) if filters: filtered_templates = all_templates.filter(**filters) diff --git a/plugins/modules/vmanage_mode.py b/plugins/modules/vmanage_mode.py index 249cc4c..feee60f 100644 --- a/plugins/modules/vmanage_mode.py +++ b/plugins/modules/vmanage_mode.py @@ -74,7 +74,6 @@ from catalystwan.api.template_api import CLITemplate from catalystwan.session import ManagerHTTPError -from catalystwan.utils.device_model import DeviceModel from catalystwan.utils.personality import Personality from ..module_utils.result import ModuleResult @@ -114,9 +113,9 @@ def run_module(): device = devices.filter(hostname=hostname).single_or_default() try: template_name = f"Default_{hostname}" - device_model = DeviceModel(device.model) + device_model = device.model if device.personality is Personality.VBOND: - device_model = DeviceModel.VBOND + device_model = "vedge-cloud" cli_template = CLITemplate( template_name=template_name, diff --git a/utils/ft_device_model.j2 b/utils/ft_device_model.j2 index 88c4b48..4a6567a 100644 --- a/utils/ft_device_model.j2 +++ b/utils/ft_device_model.j2 @@ -20,7 +20,7 @@ options: default: [] elements: str choices: -{% for model in DeviceModel %} - - "{{ model.value }}" +{% for model in device_models %} + - "{{ model }}" {% endfor %} ''' diff --git a/utils/ft_generator.py b/utils/ft_generator.py index cdb4805..740c73e 100644 --- a/utils/ft_generator.py +++ b/utils/ft_generator.py @@ -15,7 +15,7 @@ from catalystwan.api.templates.models.supported import available_models from catalystwan.api.templates.device_variable import DeviceVariable -from catalystwan.utils.device_model import DeviceModel +from catalystwan.models.common import DeviceModel PROJECT_ROOT_DIR = PurePath(Path.cwd()) @@ -35,14 +35,11 @@ def is_pydantic_model(type_): def field_to_ansible_option(field: FieldInfo, field_name: str, model_name: str): - # if field.description == "List of public keys for the user": - # if field.description == "The list of subtypes for the import protocol.": - # from IPython import embed; embed() option = { "description": [field.description], "required": field.is_required(), "default": None, - "type": None # "str", #None, # default type is None, will be overwritten as needed + "type": None, # "str", #None, # default type is None, will be overwritten as needed } if not field.is_required(): if safe_issubclass(field.default, str) or safe_issubclass(field.default, str): @@ -53,7 +50,7 @@ def field_to_ansible_option(field: FieldInfo, field_name: str, model_name: str): option["default"] = field.default elif safe_issubclass(type(field.default), list): option["default"] = field.default - elif type(field.default) == DeviceVariable: + elif type(field.default) is DeviceVariable: option["default"] = field.default.name field_type = get_origin(field.annotation) or field.annotation @@ -62,7 +59,7 @@ def field_to_ansible_option(field: FieldInfo, field_name: str, model_name: str): if field_type == bool: option["type"] = "bool" - + elif field_type == int: option["type"] = "int" @@ -149,12 +146,9 @@ def field_to_ansible_option(field: FieldInfo, field_name: str, model_name: str): option["choices"] = [item for item in args] else: - print(f"With model: {model_name}, field_name: {field_name} field: {field}") option["type"] = "str" if hasattr(field.default, "value"): option["default"] = field.default.value - # from IPython import embed; embed() - # raise TypeError(f"Cannot properly create field from model: {model_name}, field_name: {field_name} field: {field}") return option @@ -188,13 +182,6 @@ def generate_ansible_docs(model: Type[BaseModel], model_name: str): return ansible_docs -# from catalystwan.api.templates.models.cisco_ntp_model import CiscoNTPModel - -# available_models = { -# "cisco_ntp": CiscoNTPModel, -# } - - # Function to parse YAML data and return the argument spec def generate_arg_spec(yaml_data): # Load the YAML data @@ -205,9 +192,6 @@ def parse_options(options): arg_spec = {} for opt_name, opt_info in options.items(): if "type" in opt_info: - # Basic fields - # if opt_name == "key": - # from IPython import embed; embed() arg_spec[opt_name] = { "type": opt_info["type"], "required": opt_info.get("required", False), @@ -271,7 +255,7 @@ def to_nice_yaml(data): # Use pformat to get a string representation of the dictionary file.write(pformat(arg_spec, indent=2, width=80)) file.write("\n") - print(f"Argument spec saved to {output_file} under the variable {variable_name}") + print(f"File '{output_file}' has been written successfully.") # Part for Ansible DeviceModel docs fragment # Load the template file @@ -279,9 +263,21 @@ def to_nice_yaml(data): template = env.get_template(template_file) # Render the template with the DeviceModel enum - output = template.render(DeviceModel=DeviceModel) + output = template.render(device_models=get_args(DeviceModel)) # Write the output to a file file_name = f"{PROJECT_ROOT_DIR}/plugins/doc_fragments/device_models_feature_template.py" with open(file_name, "w") as f: f.write(output) + print(f"File '{file_name}' has been written successfully.") + + +print( + """ + When used, note that Device Specific Variables doesn't have description and it required manual effort to fix + these in documentation. Example: cisco.catalystwan.feature_template_cisco_system requires updating few fields. + Look for '- null' fields. + That will be solved once we will have Device Specific Variables in SDK properly defined. + + """ +) From c64433739fa55bdefb3e375271c99a389d1e827f Mon Sep 17 00:00:00 2001 From: acichon Date: Tue, 14 May 2024 21:00:37 +0200 Subject: [PATCH 12/18] Add option for devies info for backup --- .gitignore | 1 + README.md | 7 ++ playbooks/tests/test_module_devices_info.yml | 26 +++++-- plugins/README.md | 16 ++++ plugins/module_utils/filters.py | 15 +++- plugins/modules/devices_info.py | 78 +++++++++++++++++--- 6 files changed, 125 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 22f407b..cbf97c0 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ playbooks/tests/ansible_catalystwan_module.log playbooks/tests/catalystwan.log playbooks/tests/payload* playbooks/tests/response* +playbooks/tests/backup/* diff --git a/README.md b/README.md index 1049cc2..95b0da2 100644 --- a/README.md +++ b/README.md @@ -164,6 +164,13 @@ And then you can use the module: All of the modules will produce 2 log files: `ansible_catalystwan_module.log` and `ansible_catalystwan.log`. Currently base dir destination of these log files will be current working directory of playbooks. +### Feature Templates + +Feature Templates operations (`add` and `delete`) are supported via `cisco.catalystwan.feature_templates` module. + +Available models are dependent on Catalystwan SDK, and they can be seen [here](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/api/templates/models/supported.py). + +For more information about adding new models see [Feature Templates generation](./plugins/README.md#feature-templates). --- diff --git a/playbooks/tests/test_module_devices_info.yml b/playbooks/tests/test_module_devices_info.yml index e4cd100..cdf25bb 100644 --- a/playbooks/tests/test_module_devices_info.yml +++ b/playbooks/tests/test_module_devices_info.yml @@ -16,17 +16,33 @@ gather_facts: false vars_files: - configuration_file_dev_vars.yml + vars: + manager_authentication: &manager_authentication + url: "{{ (vmanage_instances | first).mgmt_public_ip }}" + username: "{{ (vmanage_instances | first).admin_username }}" + password: "{{ (vmanage_instances | first).admin_password }}" tasks: - name: 1. Get list of Edge devices cisco.catalystwan.devices_info: device_category: vedges - manager_authentication: - url: "{{ (vmanage_instances | first).mgmt_public_ip }}" - username: "{{ (vmanage_instances | first).admin_username }}" - password: "{{ (vmanage_instances | first).admin_password }}" + manager_credentials: + <<: *manager_authentication register: edge_devices - - name: 2. Check if all controller devices are discoverable via system ip + - name: 2. Backup running-config from vManage with default backup dir (in CWD) + cisco.catalystwan.devices_info: + backup: true + manager_credentials: + <<: *manager_authentication + + - name: 3. Backup running-config from vManage to specified directory + cisco.catalystwan.devices_info: + backup: true + backup_dir_path: "/tmp/backups" + manager_credentials: + <<: *manager_authentication + + - name: 4. Check if all controller devices are discoverable via system ip cisco.catalystwan.devices_info: device_category: controllers filters: diff --git a/plugins/README.md b/plugins/README.md index e5e4cf3..47505f7 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -66,6 +66,22 @@ Proposed common Return Values: --- +## Feature Templates contribution + +Module [feature_templaes](../plugins/modules/feature_templates.py) provide option to add Feature Templates. +This module is highly relaying on existing models of Feature Templates in Catalystwan SDK. If there is a missing +template that you want to use, you can contribute, and first add that model in Catalystwan SDK (important node: available_models dictionary is still used to determine which templates are supported) + +When required model is already there, you can reuse [script for generating documentation and module args](../utils/ft_generator.py) (simply by running it as python script). If your model was correctly added in Catalystwan SDK, script should create 2 files: + +* first one in `plugins/doc_fragments/` directory with .yml extension -> this one contains all documentation for that template in Ansible module + +* second one in `plugins/module_utils/feature_templates` directory with .py extension -> this one contains all module args that can be reuse later in Ansible module + +With these 2 files, you can extend `feature_templates` module by using `extends_documentation_fragment` fragment in DOCUMENTATION block, and also by using `module_args` dictionary extended by unpacked dictionary coming from `plugins/module_utils/feature_templates` file. + +--- + ## Providing credentials to catalystwan Ansible modules There are 3 ways to provide information to module about vManage you want to work with. diff --git a/plugins/module_utils/filters.py b/plugins/module_utils/filters.py index b70fe0b..bcb214a 100644 --- a/plugins/module_utils/filters.py +++ b/plugins/module_utils/filters.py @@ -13,7 +13,7 @@ def get_target_device( module: AnsibleCatalystwanModule, - device_category: DeviceCategory = "controllers", + device_category: DeviceCategory = "all", all_from_category: bool = False, ) -> DataSequence[DeviceDetailsResponse]: """ @@ -22,9 +22,18 @@ def get_target_device( """ target_device = None try: - devices = module.session.endpoints.configuration_device_inventory.get_device_details( - device_category=device_category + controllers = module.session.endpoints.configuration_device_inventory.get_device_details( + device_category="controllers" ) + vedges = module.session.endpoints.configuration_device_inventory.get_device_details(device_category="vedges") + all_devices = controllers + vedges + + if device_category == "all": + devices = all_devices + elif device_category == "controllers": + devices = controllers + elif device_category == "vedges": + devices = vedges except ManagerHTTPError as ex: module.fail_json( msg=f"Could not perform get_device_details action: {str(ex)}", exception=traceback.format_exc() diff --git a/plugins/modules/devices_info.py b/plugins/modules/devices_info.py index d53090b..09c139a 100644 --- a/plugins/modules/devices_info.py +++ b/plugins/modules/devices_info.py @@ -12,22 +12,42 @@ description: - This module retrieves details about devices in vManage. - It can filter the retrieved device information based on specified criteria. + - This module supports backup of running-config from devices. Available for all or filtered devices. options: device_category: description: - Category of devices to retrieve information for. type: str - choices: ["controllers", "vedges"] + choices: ["controllers", "vedges", "all"] + default: all + details: + description: + - This argument triggers the module to collect device details info. + type: bool + default: true filters: description: - Dictionary of filter key-value pairs to apply on the device details. type: dict default: None + backup: + description: + - This argument triggers the module to back up the filtered device's current running-config. + Without specified backup_options, it saves to the playbook's root "backup" folder + or the role's root if within an Ansible role. The folder is created if it doesn't exist. + type: bool + default: false + backup_dir_path: + description: + - Directory to store the backup. It's created if missing. Defaults to a 'backup' folder in the current directory. + type: path author: - Arkadiusz Cichon (acichon@cisco.com) notes: - - The 'filters' option allows for specifying filtering criteria such as device model, status, etc. + - The C(filters) option allows for specifying filtering criteria such as device model, status, etc. + - The C(backup) option doesn't allow to specify backup file path, it only allows to specify directory + Backup files are always stored in format of f"{base_filename}_{timestamp} extends_documentation_fragment: - cisco.catalystwan.manager_authentication @@ -73,8 +93,10 @@ status: "active" """ -from typing import List, Optional +from datetime import datetime +from pathlib import Path, PurePath from pydantic import Field +from typing import List, Optional from ..module_utils.filters import get_target_device from ..module_utils.result import ModuleResult @@ -92,25 +114,61 @@ def run_module(): module_args = dict( device_category=dict( type=str, - choices=["controllers", "vedges"], + choices=["controllers", "vedges", "all"], + default="all", ), + details=dict(type=bool, default=True), filters=dict(type=dict, default=None), + backup=dict(type=bool, default=False), + backup_dir_path=dict(type="path", default=PurePath(Path.cwd() / "backup")), ) module = AnsibleCatalystwanModule(argument_spec=module_args) result = ExtendedModuleResult() + details = module.params.get("details") + filters = module.params.get("filters") + backup = module.params.get("backup") + backup_dir_path: Path = Path(module.params.get("backup_dir_path")) + devices = get_target_device(module, device_category=module.params.get("device_category"), all_from_category=True) if not devices: module.exit_json(**result.model_dump(mode="json")) - if module.params.get("filters"): - filtered_devices: DataSequence[DeviceDetailsResponse] = devices.filter(**module.params.get("filters")) - module.logger.debug(f"All filtered_devices: {filtered_devices}") - result.devices = [dev.model_dump(mode="json") for dev in filtered_devices] - else: - result.devices = [dev.model_dump(mode="json") for dev in devices] + if details: + if filters: + filtered_devices: DataSequence[DeviceDetailsResponse] = devices.filter(**filters) + if filtered_devices: + module.logger.debug(f"All filtered_devices: {filtered_devices}") + result.devices = [dev.model_dump(mode="json") for dev in filtered_devices] + else: + result.msg = f"No devices found based on filters: {filters}" + else: + result.devices = [dev.model_dump(mode="json") for dev in devices] + + if backup: + module.logger.info(f"{backup_dir_path}") + try: + backup_dir_path.mkdir(parents=True, exist_ok=True) + except OSError as ex: + module.fail_json(msg=f"Cannot create or find directory: {backup_dir_path}, exception: {ex.strerror}") + + if filters: + devices = module.get_response_safely(module.session.api.devices.get).filter(**filters) + else: + devices = module.get_response_safely(module.session.api.devices.get) + + if devices: + for device in devices: + rcfg = module.get_response_safely(module.session.api.templates.load_running, device=device) + timestamp = datetime.now().strftime("%d-%m-%Y-%H-%M") + rcfg.save_as(f"{backup_dir_path}/{device.hostname}_{timestamp}") + result.msg = ( + f"Succesfully saved running configuration to file: {backup_dir_path}/{device.hostname}_{timestamp}" + ) + else: + result.msg = f"No devices found based on filters: {filters}" module.exit_json(**result.model_dump(mode="json")) From b06784ba68888eccd3e02041452210db6e483309 Mon Sep 17 00:00:00 2001 From: acichon Date: Mon, 10 Jun 2024 14:28:08 +0200 Subject: [PATCH 13/18] introduce device templates modules --- .ansible-lint | 1 + .gitignore | 1 + playbooks/tests/test_device_templates.yml | 56 +++++ .../device_models_device_template.py | 87 +++++++ plugins/module_utils/vmanage_module.py | 2 +- plugins/modules/device_templates.py | 228 ++++++++++++++++++ plugins/modules/feature_templates.py | 52 ++-- 7 files changed, 408 insertions(+), 19 deletions(-) create mode 100644 playbooks/tests/test_device_templates.yml create mode 100644 plugins/doc_fragments/device_models_device_template.py create mode 100644 plugins/modules/device_templates.py diff --git a/.ansible-lint b/.ansible-lint index d918c34..a190b22 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -24,6 +24,7 @@ mock_modules: - cisco.catalystwan.active_sessions_info - cisco.catalystwan.administration_settings - cisco.catalystwan.alarms + - cisco.catalystwan.device_templates - cisco.catalystwan.devices_certificates - cisco.catalystwan.devices_controllers - cisco.catalystwan.devices_info diff --git a/.gitignore b/.gitignore index cbf97c0..61cc87e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ poetry.lock .vscode* .venv* +run* .dev_dir/playground.yml .dev_dir/dev_vars.yml .dev_dir/ansible_catalystwan_module.log diff --git a/playbooks/tests/test_device_templates.yml b/playbooks/tests/test_device_templates.yml new file mode 100644 index 0000000..43cb5ba --- /dev/null +++ b/playbooks/tests/test_device_templates.yml @@ -0,0 +1,56 @@ +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +--- + +# Helper playbooks to test modules and flows while developing them + +# Tested operations: + +# --- Device Templates --- # + + +- name: Testing playbook to verify cisco.catalystwan.device_templates module operations + hosts: localhost + gather_facts: false + vars_files: + - configuration_file_dev_vars.yml + vars: + manager_authentication: &manager_authentication + url: "{{ (vmanage_instances | first).mgmt_public_ip }}" + username: "{{ (vmanage_instances | first).admin_username }}" + password: "{{ (vmanage_instances | first).admin_password }}" + tasks: + - name: Get all Non-Default Device Templates available + cisco.catalystwan.device_templates_info: + filters: + factory_default: false + manager_credentials: + <<: *manager_authentication + register: device_templates + + - name: Debug Templates Info + ansible.builtin.debug: + msg: "{{ device_templates }}" + + - name: Delete selected Device Template from vManage + cisco.catalystwan.device_templates: + state: absent + template_name: "vc8000-device-template" + manager_credentials: + <<: *manager_authentication + + - name: Create example Device Template with default templates + cisco.catalystwan.device_templates: + state: present + template_name: "vc8000-device-template" + template_description: "vc8000-device-template" + device_type: vedge-C8000V + device_role: sdwan-edge + general_templates: + - "cisco_aaa" + - "Factory_Default_Cisco_BFD_Template" + - "Factory_Default_Cisco_OMP_ipv46_Template" + - "Factory_Default_Cisco_Security_Template" + manager_credentials: + <<: *manager_authentication diff --git a/plugins/doc_fragments/device_models_device_template.py b/plugins/doc_fragments/device_models_device_template.py new file mode 100644 index 0000000..5124e86 --- /dev/null +++ b/plugins/doc_fragments/device_models_device_template.py @@ -0,0 +1,87 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" +options: + device_type: + description: + - Defines the SD-WAN device type for template application. + type: str + required: false + aliases: [device_models] + choices: + - "vsmart" + - "vedge-cloud" + - "vmanage" + - "vedge-ISR1100-6G" + - "vedge-ISR1100X-6G" + - "vedge-ISR1100-4G" + - "vedge-ISR1100X-4G" + - "vedge-ISR1100-4GLTE" + - "vedge-1000" + - "vedge-2000" + - "vedge-100" + - "vedge-100-B" + - "vedge-100-WM" + - "vedge-100-M" + - "vedge-5000" + - "vedge-IR-1101" + - "vedge-ESR-6300" + - "vedge-IR-1821" + - "vedge-IR-1831" + - "vedge-IR-1833" + - "vedge-IR-1835" + - "vedge-ASR-1001-X" + - "vedge-ASR-1002-X" + - "vedge-ASR-1002-HX" + - "vedge-ASR-1001-HX" + - "vedge-C8500L-8G4X" + - "vedge-C8500-12X4QC" + - "vedge-C8500-12X" + - "vedge-C8500L-8S4X" + - "vedge-ASR-1006-X" + - "vedge-C8500-20X6C" + - "vedge-CSR-1000v" + - "vedge-C8000V" + - "vedge-ISR-4331" + - "vedge-ISR-4431" + - "vedge-ISR-4461" + - "vedge-ISR-4451-X" + - "vedge-ISR-4321" + - "vedge-ISR-4351" + - "vedge-ISR-4221" + - "vedge-ISR-4221X" + - "vedge-C1111-8PW" + - "vedge-C1111-8PLTELAW" + - "vedge-C1111-8PLTEEAW" + - "vedge-C1113-8PMLTEEA" + - "vedge-C1116-4P" + - "vedge-C1116-4PLTEEA" + - "vedge-C1117-4P" + - "vedge-C1117-4PM" + - "vedge-C1117-4PLTEEA" + - "vedge-C1111-8PLTELA" + - "vedge-C1111-8PLTEEA" + - "vedge-C1121-8PLTEPW" + - "vedge-C1121-8PLTEP" + - "vedge-C1121X-8PLTEP" + - "vedge-C1111-4PLTEEA" + - "vedge-C1161X-8PLTEP" + - "vedge-C8300-2N2S-6T" + - "vedge-C8300-1N1S-6T" + - "vedge-C8300-1N1S-4T2X" + - "vedge-C8300-2N2S-4T2X" + - "vedge-C8200-1N-4T" + - "vedge-C8200L-1N-4T" + - "vedge-ISRv" + """ diff --git a/plugins/module_utils/vmanage_module.py b/plugins/module_utils/vmanage_module.py index e2c0e94..f7a95a2 100644 --- a/plugins/module_utils/vmanage_module.py +++ b/plugins/module_utils/vmanage_module.py @@ -177,7 +177,7 @@ def send_request_safely( except ManagerHTTPError as ex: self.fail_json( - msg=f"Could not perform '{action_name}' action.\nManager error: {str(ex)} {ex.info}", + msg=f"Could not perform '{action_name}' action.\nManager error: {ex.info}", exception=traceback.format_exc(), ) diff --git a/plugins/modules/device_templates.py b/plugins/modules/device_templates.py new file mode 100644 index 0000000..d883607 --- /dev/null +++ b/plugins/modules/device_templates.py @@ -0,0 +1,228 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + + +DOCUMENTATION = r""" +--- +module: Device_templates +short_description: Manage Device Templates on vManage. +version_added: "0.1.1" +description: + - This module allows you to create, delete, attach and detach Device Templates + - Device Templates can be filtered by Device Templates Info key:values. +options: + state: + description: + - Desired state for the template. + - 0(state=present) is equivalent of create template in GUI + type: str + choices: ["absent", "present", "attached", "detached"] + default: "present" + template_name: + description: + - The name for the Feature Template. + type: str + required: true + template_description: + description: + - Description for the Feature Template. + type: str + required: true + device_role: + description: + - The device role. Applicable to all devices except 'vManage' and 'vSmart' + required: false + default: null + type: str + choices: ["service-node", "sdwan-edge"] + general_templates: + description: + - List of names of Feature Templates to be included in Device Template + type: list + elements: str + required: false +author: + - Arkadiusz Cichon (acichon@cisco.com) +extends_documentation_fragment: + - cisco.catalystwan.device_models_device_template + - cisco.catalystwan.manager_authentication +notes: + - Ensure that the provided credentials have sufficient permissions to manage templates and devices in vManage. +""" + +EXAMPLES = r""" +- name: Get all Non-Default Device Templates available + cisco.catalystwan.device_templates_info: + filters: + factory_default: false + manager_credentials: + ... + register: device_templates +""" + +RETURN = r""" +template_info: + description: A list of dictionaries of templates info + type: list + returned: on success + sample: | + templates_info: + - configType: template + deviceRole: sdwan-edge + deviceType: vedge-C8000V + devicesAttached: 0 + draftMode: Disabled + factoryDefault: false + lastUpdatedBy: example_admin + lastUpdatedOn: 1715270833776 + resourceGroup: global + templateAttached: 11 + templateClass: cedge + templateDescription: xd + templateId: xxx-xxx-xxx + templateName: xd +msg: + description: Messages that indicate actions taken or any errors that have occurred. + type: str + returned: always + sample: "Successfully fetched information about template: trial-template" +changed: + description: Indicates whether any change was made. + type: bool + returned: always + sample: false +""" + +from typing import Dict, Literal, Optional, get_args + +from catalystwan.api.template_api import DeviceTemplate +from catalystwan.dataclasses import DeviceTemplateInfo +from catalystwan.models.common import DeviceModel +from catalystwan.session import ManagerHTTPError +from catalystwan.typed_list import DataSequence +from pydantic import Field + +from ..module_utils.result import ModuleResult +from ..module_utils.vmanage_module import AnsibleCatalystwanModule + +State = Literal["present", "absent"] + + +class ExtendedModuleResult(ModuleResult): + templates_info: Optional[Dict] = Field(default={}) + + +def run_module(): + module_args = dict( + state=dict( + type=str, + choices=list(get_args(State)), + default="present", + ), + template_name=dict(type="str", required=True), + template_description=dict(type="str", default=None), + device_type=dict(type="str", choices=list(get_args(DeviceModel)), default=None), + device_role=dict(type="str", choices=["sdwan-edge", "service-node"], default=None), + general_templates=dict(type="list", elements="str", default=[]), + ) + result = ExtendedModuleResult() + result.state = None + result.response = None + + module = AnsibleCatalystwanModule( + argument_spec=module_args, + required_if=[ + ( + "state", + "present", + ( + "template_name", + "template_description", + "device_type", + ), + ), + ( + "state", + "absent", + ("template_name",), + ), + ], + ) + + template_name = module.params.get("template_name") + + all_templates: DataSequence[DeviceTemplateInfo] = module.get_response_safely( + module.session.api.templates.get, template=DeviceTemplate + ) + target_template: DeviceTemplateInfo = all_templates.filter(name=template_name) + + if module.params.get("state") == "present": + # Code for checking if template name exists already + if target_template: + module.logger.debug(f"Detected existing template:\n{target_template}\n") + result.msg = ( + f"Template with name {template_name} already present on vManage, skipping create template operation." + ) + else: + device_template = DeviceTemplate( + template_name=template_name, + template_description=module.params.get("template_description"), + device_type=module.params.get("device_type"), + device_role=module.params.get("device_role"), + general_templates=module.params.get("general_templates"), + ) + + module.logger.debug( + f"Prepared template for sending to vManage, template configuration:\n{device_template}\n" + ) + try: + module.session.api.templates.create(template=device_template, debug=module.params.get("debug")) + except ManagerHTTPError as ex: + module.fail_json( + msg=f"Could not perform add Feature Template {template_name}.\nManager error: {ex.info}" + ) + result.changed = True + result.msg += f"Created template {template_name}: {device_template}" + + # Way to attach the template, to be implemented + # response = provider_session.api.templates.attach( + # name=name, + # template=device_template, + # device=device, + # device_specific_vars={ + # "//system/site-id": mt_edge.get_site_id(), + # "//system/host-name": mt_edge.name, + # "//system/system-ip": mt_edge.get_system_ip_no_mask(), + # }, + # ) + + if module.params.get("state") == "absent": + if target_template: + module.send_request_safely( + result, + action_name="Delete Template", + send_func=module.session.api.templates.delete, + template=DeviceTemplate, + name=template_name, + ) + result.changed = True + result.msg = f"Deleted template {template_name}" + else: + module.logger.debug(f"Template '{target_template}' not presend in list of Device Templates on vManage.") + result.msg = ( + f"Template {template_name} not presend in list of Device Templates on vManage. " + "skipping delete template operation." + ) + + module.exit_json(**result.model_dump(mode="json")) + + +def main(): + run_module() + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/feature_templates.py b/plugins/modules/feature_templates.py index 71098ab..43ad8ae 100644 --- a/plugins/modules/feature_templates.py +++ b/plugins/modules/feature_templates.py @@ -8,14 +8,14 @@ --- module: vmanage_feature_template short_description: Manage feature templates for Cisco vManage SD-WAN -version_added: "0.1.0" +version_added: "0.1.1" description: - This module can be used to create, modify, and delete feature templates in Cisco vManage SD-WAN. - The feature template configuration is defined via Python Pydantic models. options: state: description: - - Desired state of for the template. + - Desired state for the template. - 0(state=present) is equivalent of create template in GUI type: str choices: ["absent", "present", "modified"] @@ -29,7 +29,7 @@ description: - Description for the Feature Template. type: str - required: true + required: false device_specific_variables: description: - Dictionary containing device specific variables names to be defined in template. @@ -64,19 +64,17 @@ """ -from pydantic import BaseModel, Field, ConfigDict -from typing import Optional, Dict, Final, get_args, Literal +from typing import Dict, Final, Literal, Optional, get_args from catalystwan.api.template_api import FeatureTemplate +from catalystwan.api.templates.device_variable import DeviceVariable +from catalystwan.api.templates.models.supported import available_models from catalystwan.dataclasses import FeatureTemplateInfo -from catalystwan.typed_list import DataSequence from catalystwan.models.common import DeviceModel from catalystwan.session import ManagerHTTPError -from catalystwan.api.templates.models.supported import available_models +from catalystwan.typed_list import DataSequence +from pydantic import BaseModel, ConfigDict, Field -from ..module_utils.result import ModuleResult -from ..module_utils.vmanage_module import AnsibleCatalystwanModule -from catalystwan.api.templates.device_variable import DeviceVariable from ..module_utils.feature_templates.cisco_aaa import cisco_aaa_definition from ..module_utils.feature_templates.cisco_banner import cisco_banner_definition from ..module_utils.feature_templates.cisco_bfd import cisco_bfd_definition @@ -87,11 +85,13 @@ from ..module_utils.feature_templates.cisco_secure_internet_gateway import cisco_secure_internet_gateway_definition from ..module_utils.feature_templates.cisco_snmp import cisco_snmp_definition from ..module_utils.feature_templates.cisco_system import cisco_system_definition -from ..module_utils.feature_templates.cisco_vpn_interface import cisco_vpn_interface_definition from ..module_utils.feature_templates.cisco_vpn import cisco_vpn_definition +from ..module_utils.feature_templates.cisco_vpn_interface import cisco_vpn_interface_definition from ..module_utils.feature_templates.omp_vsmart import omp_vsmart_definition from ..module_utils.feature_templates.security_vsmart import security_vsmart_definition from ..module_utils.feature_templates.system_vsmart import system_vsmart_definition +from ..module_utils.result import ModuleResult +from ..module_utils.vmanage_module import AnsibleCatalystwanModule ALLOW: Final[str] = "allow" @@ -119,7 +119,7 @@ def run_module(): device_models=dict(type="list", choices=list(get_args(DeviceModel)), default=[]), debug=dict(type="bool", default=False), device_specific_variables=dict(type="raw", default={}), - device=dict(type="str", default=None), # For this we need to think how to pass devices + # device=dict(type="str", default=None), # For this we need to think how to pass devices **cisco_aaa_definition, **cisco_banner_definition, **cisco_bfd_definition, @@ -152,7 +152,6 @@ def run_module(): "template_description", "device_models", ), - True, ), ( "modified", @@ -162,9 +161,12 @@ def run_module(): "template_description", "device_models", ), - True, ), - ("state", "absent", ("template_name",), True), + ( + "state", + "absent", + ("template_name",), + ), ], ) # Verify if we are dealing with one or more templates @@ -225,9 +227,23 @@ def run_module(): result.msg += f"Created template {model_name}: {template}" if module.params.get("state") == "absent": - module.session.api.templates.delete(template=FeatureTemplate, name=template_name) - result.changed = True - result.msg = f"Deleted template {template_name}" + if target_template: + module.send_request_safely( + result, + action_name="Delete Template", + send_func=module.session.api.templates.delete, + template=FeatureTemplate, + name=template_name, + ) + # module.session.api.templates.delete(template=FeatureTemplate, name=template_name) + result.changed = True + result.msg = f"Deleted template {template_name}" + else: + module.logger.debug(f"Template '{target_template}' not presend in list of Feature Templates on vManage.") + result.msg = ( + f"Template {template_name} not presend in list of Feature Templates on vManage, " + "skipping delete template operation." + ) if module.params.get("state") == "modified": module.fail_json(msg="Module parameter 'modified' not implemented yet!") From 84276485f54ca282fb36487a9d1b65b72e743b1d Mon Sep 17 00:00:00 2001 From: acichon Date: Tue, 18 Jun 2024 11:21:41 +0200 Subject: [PATCH 14/18] include device and cli templates --- .ansible-lint | 1 + galaxy.yml | 2 +- playbooks/tests/test_backup_and_restore.yml | 71 +++++++ playbooks/tests/test_device_templates.yml | 1 - playbooks/tests/test_templates_attachment.yml | 66 ++++++ .../device_models_device_template.py | 2 +- plugins/module_utils/vmanage_module.py | 2 +- plugins/modules/cli_templates.py | 192 ++++++++++++++++++ plugins/modules/device_templates.py | 133 +++++++----- plugins/modules/device_templates_info.py | 2 - plugins/modules/devices_info.py | 44 ++-- plugins/modules/feature_templates.py | 2 - plugins/modules/feature_templates_info.py | 7 +- plugins/modules/vmanage_mode.py | 7 +- 14 files changed, 454 insertions(+), 78 deletions(-) create mode 100644 playbooks/tests/test_backup_and_restore.yml create mode 100644 playbooks/tests/test_templates_attachment.yml create mode 100644 plugins/modules/cli_templates.py diff --git a/.ansible-lint b/.ansible-lint index a190b22..210da23 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -24,6 +24,7 @@ mock_modules: - cisco.catalystwan.active_sessions_info - cisco.catalystwan.administration_settings - cisco.catalystwan.alarms + - cisco.catalystwan.cli_templates - cisco.catalystwan.device_templates - cisco.catalystwan.devices_certificates - cisco.catalystwan.devices_controllers diff --git a/galaxy.yml b/galaxy.yml index 34efd9d..c0e6646 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,6 +1,6 @@ namespace: cisco name: catalystwan -version: 0.1.1 +version: 0.2.0 readme: README.md authors: - Arkadiusz Cichon diff --git a/playbooks/tests/test_backup_and_restore.yml b/playbooks/tests/test_backup_and_restore.yml new file mode 100644 index 0000000..5abeae1 --- /dev/null +++ b/playbooks/tests/test_backup_and_restore.yml @@ -0,0 +1,71 @@ +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +--- + +# Helper playbooks to test modules and flows while developing them + +# Tested operations: + +# --- Backup & Restore --- # + + +- name: Testing playbook to verify backup & restore operations + hosts: localhost + gather_facts: false + vars_files: + - configuration_file_dev_vars.yml + vars: + manager_authentication: &manager_authentication + url: "{{ (vmanage_instances | first).mgmt_public_ip }}" + username: "{{ (vmanage_instances | first).admin_username }}" + password: "{{ (vmanage_instances | first).admin_password }}" + tasks: + - name: 1. Backup running-config for all c8000V devices with default backup dir (in CWD) + cisco.catalystwan.devices_info: + backup: true + filters: + personality: "vedge" + manager_credentials: + <<: *manager_authentication + register: backup_info + + - name: 2. Using backup files, create CLI templates for each Edge device + cisco.catalystwan.cli_templates: + state: present + template_name: "backup-template-{{ device_item.filename }}" + template_description: "Template for {{ device_item.hostname }} created from backup file." + config_file: "{{ device_item.backup_path }}" + device_model: vedge-C8000V + manager_credentials: + <<: *manager_authentication + loop: "{{ backup_info.backup_paths }}" + loop_control: + loop_var: device_item + when: backup_info.backup_paths | length > 0 + + - name: 3. Attach backup templates to the Edge devices + cisco.catalystwan.device_templates: + state: attached + template_name: "backup-template-{{ device_item.filename }}" + hostname: "{{ device_item.hostname }}" + manager_credentials: + <<: *manager_authentication + loop: "{{ backup_info.backup_paths }}" + loop_control: + loop_var: device_item + when: backup_info.backup_paths | length > 0 + + - name: 4. Post-test - Set vManage mode for cEdge devices - not required + cisco.catalystwan.vmanage_mode: + state: present + hostnames: + - "{{ device_item.hostname }}" + manager_credentials: + <<: *manager_authentication + loop: "{{ backup_info.backup_paths }}" + loop_control: + loop_var: device_item + when: backup_info.backup_paths | length > 0 + + # Add task to remove all unused templates (not attached) diff --git a/playbooks/tests/test_device_templates.yml b/playbooks/tests/test_device_templates.yml index 43cb5ba..a148f0c 100644 --- a/playbooks/tests/test_device_templates.yml +++ b/playbooks/tests/test_device_templates.yml @@ -48,7 +48,6 @@ device_type: vedge-C8000V device_role: sdwan-edge general_templates: - - "cisco_aaa" - "Factory_Default_Cisco_BFD_Template" - "Factory_Default_Cisco_OMP_ipv46_Template" - "Factory_Default_Cisco_Security_Template" diff --git a/playbooks/tests/test_templates_attachment.yml b/playbooks/tests/test_templates_attachment.yml new file mode 100644 index 0000000..7fb9181 --- /dev/null +++ b/playbooks/tests/test_templates_attachment.yml @@ -0,0 +1,66 @@ +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +--- + +# Helper playbooks to test modules and flows while developing them + +# Tested operations: + +# --- Device Templates attachment - from --- # + + +- name: Testing playbook to verify cisco.catalystwan.device_templates module operations + hosts: localhost + gather_facts: false + vars_files: + - configuration_file_dev_vars.yml + vars: + manager_authentication: &manager_authentication + url: "{{ (vmanage_instances | first).mgmt_public_ip }}" + username: "{{ (vmanage_instances | first).admin_username }}" + password: "{{ (vmanage_instances | first).admin_password }}" + tasks: + - name: Backup running-config from devices, store in default backup dir (in CWD) + cisco.catalystwan.devices_info: + backup: true + manager_credentials: + <<: *manager_authentication + register: backup_info + + - name: Using backup files, create CLI templates for each device available + cisco.catalystwan.cli_templates: + state: present + template_name: "backup-template-{{ device_item.filename }}" + template_description: "Template for {{ device_item.hostname }} created from backup file." + config_file: "{{ device_item.backup_path }}" + device_model: "{% if 'cedge' in device_item.hostname %}vedge-C8000V\ + {% elif 'vSmart' in device_item.hostname %}vsmart{% elif 'vManage' in device_item.hostname %}vmanage\ + {% elif 'vBond' in device_item.hostname %}vedge-cloud{% endif %}" + manager_credentials: + <<: *manager_authentication + loop: "{{ backup_info.backup_paths }}" + loop_control: + loop_var: device_item + when: backup_info.backup_paths | length > 0 + + - name: Get all Non-Default Feature Templates available + cisco.catalystwan.feature_templates_info: + filters: + factory_default: false + manager_credentials: + <<: *manager_authentication + register: feature_templates + + - name: Delete all Non-Default Feature templates + cisco.catalystwan.feature_templates: + state: absent + template_name: "{{ template.templateName }}" + manager_credentials: + <<: *manager_authentication + loop: "{{ feature_templates.templates_info | default([], true) }}" + loop_control: + loop_var: template + label: "template: {{ template.templateName }}" + + # Create now all Feature Templates that are necessary to form minimal Device Template, and attach this template diff --git a/plugins/doc_fragments/device_models_device_template.py b/plugins/doc_fragments/device_models_device_template.py index 5124e86..cde723c 100644 --- a/plugins/doc_fragments/device_models_device_template.py +++ b/plugins/doc_fragments/device_models_device_template.py @@ -18,7 +18,7 @@ class ModuleDocFragment(object): - Defines the SD-WAN device type for template application. type: str required: false - aliases: [device_models] + aliases: [device_model] choices: - "vsmart" - "vedge-cloud" diff --git a/plugins/module_utils/vmanage_module.py b/plugins/module_utils/vmanage_module.py index f7a95a2..b3e855e 100644 --- a/plugins/module_utils/vmanage_module.py +++ b/plugins/module_utils/vmanage_module.py @@ -8,7 +8,6 @@ import urllib3 from ansible.module_utils.basic import AnsibleModule, env_fallback, missing_required_lib -from catalystwan.typed_list import DataSequence from urllib3.exceptions import NewConnectionError, TimeoutError from ..module_utils.logger_config import configure_logger @@ -23,6 +22,7 @@ try: from catalystwan.api.task_status_api import Task from catalystwan.session import ManagerHTTPError, ManagerRequestException, ManagerSession, create_manager_session + from catalystwan.typed_list import DataSequence from catalystwan.vmanage_auth import UnauthorizedAccessError HAS_LIB = True diff --git a/plugins/modules/cli_templates.py b/plugins/modules/cli_templates.py new file mode 100644 index 0000000..d0bb11b --- /dev/null +++ b/plugins/modules/cli_templates.py @@ -0,0 +1,192 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + + +DOCUMENTATION = r""" +--- +module: cli_templates +short_description: Manage CLI templates in Cisco SDWAN +version_added: "0.2.0" +description: + - This module allows you to create or delete CLI templates in Cisco SDWAN. +options: + state: + description: + - Whether the CLI template should be present or absent on the Cisco SDWAN. + required: false + type: str + choices: ["present", "absent"] + default: "present" + template_name: + description: + - The name of the CLI template. + required: true + type: str + template_description: + description: + - The description of the CLI template. + required: false + type: str + default: None + config_file: + description: + - The path to the configuration file that contains the CLI template content. + required: false + type: str + aliases: ["running_config_file_path"] +author: + - Arkadiusz Cichon (acichon@cisco.com) +extends_documentation_fragment: + - cisco.catalystwan.device_models_device_template + - cisco.catalystwan.manager_authentication +notes: + - Ensure that the provided credentials have sufficient permissions to manage templates and devices in vManage. +""" + +EXAMPLES = r""" +- name: Using configuration from file, ensure a CLI template is present on vManage + cisco.catalystwan.cli_templates: + state: present + template_name: "MyTemplate" + template_description: "This is a CLI template for device configuration" + device_model: "ISR4451" + config_file: "/path/to/config_file.txt" + manager_credentials: ... + +- name: Remove a CLI template from vManage + cisco.catalystwan.cli_templates: + state: absent + template_name: "MyTemplate" + manager_credentials: ... +""" + +RETURN = r""" +msg: + description: A message describing the result of the operation. + returned: always + type: str + sample: "Created template MyTemplate: MyTemplate. Template id: abc123" +changed: + description: A boolean flag indicating if any changes were made. + returned: always + type: bool + sample: true +template_id: + description: The ID of the template that was created or modified. + returned: when a template is created + type: str + sample: "abc123" +""" + +from typing import Literal, get_args + +from catalystwan.api.template_api import CLITemplate +from catalystwan.dataclasses import DeviceTemplateInfo +from catalystwan.models.common import DeviceModel +from catalystwan.session import ManagerHTTPError +from catalystwan.typed_list import DataSequence + +from ..module_utils.result import ModuleResult +from ..module_utils.vmanage_module import AnsibleCatalystwanModule + +State = Literal["present", "absent"] + + +def run_module(): + module_args = dict( + state=dict( + type=str, + choices=list(get_args(State)), + default="present", + ), + template_name=dict(type="str", required=True), + template_description=dict(type="str", default=None), + device_model=dict(type="str", aliases=["device_type"], choices=list(get_args(DeviceModel)), default=None), + config_file=dict(type="str", aliases=["running_config_file_path"]), + ) + result = ModuleResult() + + module = AnsibleCatalystwanModule( + argument_spec=module_args, + required_if=[ + ( + "state", + "present", + ( + "template_name", + "template_description", + "device_model", + ), + ), + ( + "state", + "absent", + ("template_name",), + ), + ], + ) + + template_name = module.params.get("template_name") + + all_templates: DataSequence[DeviceTemplateInfo] = module.get_response_safely( + module.session.api.templates.get, template=CLITemplate + ) + target_template: DeviceTemplateInfo = all_templates.filter(name=template_name) + + if module.params.get("state") == "present": + # Code for checking if template name exists already + if target_template: + module.logger.debug(f"Detected existing template:\n{target_template}\n") + result.msg = ( + f"Template with name {template_name} already present on vManage, skipping create template operation." + ) + else: + cli_template = CLITemplate( + template_name=template_name, + template_description=module.params.get("template_description"), + device_model=module.params.get("device_model"), + ) + cli_template.load_from_file(file=module.params.get("config_file")) + + module.logger.debug(f"Prepared template for sending to vManage, template configuration:\n{cli_template}\n") + try: + template_id: str = module.session.api.templates.create( + template=cli_template, debug=module.params.get("debug") + ) + except ManagerHTTPError as ex: + module.fail_json( + msg=f"Could not perform create CLI Template {template_name}.\nManager error: {ex.info}" + ) + result.changed = True + result.msg += f"Created template {template_name}: {cli_template.template_name}. Template id: {template_id}" + + if module.params.get("state") == "absent": + if target_template: + module.send_request_safely( + result, + action_name="Delete Template", + send_func=module.session.api.templates.delete, + template=CLITemplate, + name=template_name, + ) + result.changed = True + result.msg = f"Deleted template {template_name}" + else: + module.logger.debug(f"Template '{target_template}' not presend in list of Templates on vManage.") + result.msg = ( + f"Template {template_name} not presend in list of CLI Templates on vManage. " + "skipping delete template operation." + ) + + module.exit_json(**result.model_dump(mode="json")) + + +def main(): + run_module() + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/device_templates.py b/plugins/modules/device_templates.py index d883607..1974279 100644 --- a/plugins/modules/device_templates.py +++ b/plugins/modules/device_templates.py @@ -9,7 +9,7 @@ --- module: Device_templates short_description: Manage Device Templates on vManage. -version_added: "0.1.1" +version_added: "0.2.0" description: - This module allows you to create, delete, attach and detach Device Templates - Device Templates can be filtered by Device Templates Info key:values. @@ -19,7 +19,7 @@ - Desired state for the template. - 0(state=present) is equivalent of create template in GUI type: str - choices: ["absent", "present", "attached", "detached"] + choices: ["absent", "present", "attached"] default: "present" template_name: description: @@ -44,6 +44,10 @@ type: list elements: str required: false + hostname: + description: + - Hostname of the device to attach template. Available only for 0(state=attached). + type: str author: - Arkadiusz Cichon (acichon@cisco.com) extends_documentation_fragment: @@ -54,52 +58,66 @@ """ EXAMPLES = r""" -- name: Get all Non-Default Device Templates available - cisco.catalystwan.device_templates_info: - filters: - factory_default: false - manager_credentials: - ... - register: device_templates +- name: Ensure a device template is present on vManage + cisco.catalystwan.device_templates: + state: present + template_name: "MyDeviceTemplate" + template_description: "This is a device template for device configuration" + device_type: "ISR4451" + device_role: "sdwan-edge" + general_templates: + - "Template1" + - "Template2" + manager_credentials: ... + +- name: Attach a device template to a device with a specific hostname + cisco.catalystwan.device_templates: + state: attached + template_name: "MyDeviceTemplate" + hostname: "device-hostname" + timeout_seconds: 600 + manager_credentials: ... + +- name: Remove a device template from vManage + cisco.catalystwan.device_templates: + state: absent + template_name: "MyDeviceTemplate" + manager_credentials: ... """ RETURN = r""" -template_info: - description: A list of dictionaries of templates info - type: list - returned: on success - sample: | - templates_info: - - configType: template - deviceRole: sdwan-edge - deviceType: vedge-C8000V - devicesAttached: 0 - draftMode: Disabled - factoryDefault: false - lastUpdatedBy: example_admin - lastUpdatedOn: 1715270833776 - resourceGroup: global - templateAttached: 11 - templateClass: cedge - templateDescription: xd - templateId: xxx-xxx-xxx - templateName: xd msg: - description: Messages that indicate actions taken or any errors that have occurred. - type: str + description: A message describing the result of the operation. returned: always - sample: "Successfully fetched information about template: trial-template" + type: str + sample: "Created template MyDeviceTemplate: MyDeviceTemplate" + changed: - description: Indicates whether any change was made. - type: bool + description: A boolean flag indicating if any changes were made. returned: always - sample: false + type: bool + sample: true + +templates_info: + description: Detailed information about the templates. + returned: when templates are queried + type: dict + sample: { + "MyDeviceTemplate": { + "template_id": "abc123", + "template_name": "MyDeviceTemplate", + "template_description": "This is a device template for device configuration", + "device_type": "ISR4451", + "device_role": "sdwan-edge", + "general_templates": ["Template1", "Template2"] + } + } """ from typing import Dict, Literal, Optional, get_args from catalystwan.api.template_api import DeviceTemplate -from catalystwan.dataclasses import DeviceTemplateInfo +from catalystwan.dataclasses import Device, DeviceTemplateInfo from catalystwan.models.common import DeviceModel from catalystwan.session import ManagerHTTPError from catalystwan.typed_list import DataSequence @@ -108,7 +126,7 @@ from ..module_utils.result import ModuleResult from ..module_utils.vmanage_module import AnsibleCatalystwanModule -State = Literal["present", "absent"] +State = Literal["present", "absent", "attached"] class ExtendedModuleResult(ModuleResult): @@ -124,13 +142,13 @@ def run_module(): ), template_name=dict(type="str", required=True), template_description=dict(type="str", default=None), - device_type=dict(type="str", choices=list(get_args(DeviceModel)), default=None), + device_type=dict(type="str", aliases=["device_model"], choices=list(get_args(DeviceModel)), default=None), device_role=dict(type="str", choices=["sdwan-edge", "service-node"], default=None), general_templates=dict(type="list", elements="str", default=[]), + timeout_seconds=dict(type="int", default=300), + hostname=dict(type="str"), ) result = ExtendedModuleResult() - result.state = None - result.response = None module = AnsibleCatalystwanModule( argument_spec=module_args, @@ -149,6 +167,14 @@ def run_module(): "absent", ("template_name",), ), + ( + "state", + "attached", + ( + "template_name", + "hostname", + ), + ), ], ) @@ -187,17 +213,22 @@ def run_module(): result.changed = True result.msg += f"Created template {template_name}: {device_template}" - # Way to attach the template, to be implemented - # response = provider_session.api.templates.attach( - # name=name, - # template=device_template, - # device=device, - # device_specific_vars={ - # "//system/site-id": mt_edge.get_site_id(), - # "//system/host-name": mt_edge.name, - # "//system/system-ip": mt_edge.get_system_ip_no_mask(), - # }, - # ) + if module.params.get("state") == "attached": + hostname = module.params.get("hostname") + device: DataSequence[Device] = ( + module.get_response_safely(module.session.api.devices.get).filter(hostname=hostname).single_or_default() + ) + + if not device: + module.fail_json(f"No devices with hostname found, hostname provided: {hostname}") + try: + module.session.api.templates.attach( + name=template_name, device=device, timeout_seconds=module.params.get("timeout_seconds") + ) + result.changed = True + result.msg = f"Attached template {template_name} to device: {hostname}" + except ManagerHTTPError as ex: + module.fail_json(msg=f"Could not perform attach Template {template_name}.\nManager error: {ex.info}") if module.params.get("state") == "absent": if target_template: diff --git a/plugins/modules/device_templates_info.py b/plugins/modules/device_templates_info.py index 3c1d2cf..1b16ab4 100644 --- a/plugins/modules/device_templates_info.py +++ b/plugins/modules/device_templates_info.py @@ -177,8 +177,6 @@ def run_module(): filters=dict(type="dict", default=None, required=False), ) result = ExtendedModuleResult() - result.state = None - result.response = None module = AnsibleCatalystwanModule(argument_spec=module_args) diff --git a/plugins/modules/devices_info.py b/plugins/modules/devices_info.py index 8d84ce0..5e56406 100644 --- a/plugins/modules/devices_info.py +++ b/plugins/modules/devices_info.py @@ -33,7 +33,7 @@ backup: description: - This argument triggers the module to back up the filtered device's current running-config. - Without specified backup_options, it saves to the playbook's root "backup" folder + Without specified backup_dir_path, it saves to the playbook's root "backup" folder or the role's root if within an Ansible role. The folder is created if it doesn't exist. type: bool default: false @@ -96,17 +96,25 @@ from pathlib import Path, PurePath from typing import List, Optional +from catalystwan.dataclasses import Device from catalystwan.endpoints.configuration_device_inventory import DeviceDetailsResponse from catalystwan.typed_list import DataSequence -from pydantic import Field +from pydantic import BaseModel, Field from ..module_utils.filters import get_target_device from ..module_utils.result import ModuleResult from ..module_utils.vmanage_module import AnsibleCatalystwanModule +class BackupPathModel(BaseModel): + hostname: str + filename: str + backup_path: str + + class ExtendedModuleResult(ModuleResult): devices: Optional[List] = Field(default=[]) + backup_paths: Optional[List[BackupPathModel]] = Field(default=[]) def run_module(): @@ -122,7 +130,13 @@ def run_module(): backup_dir_path=dict(type="path", default=PurePath(Path.cwd() / "backup")), ) - module = AnsibleCatalystwanModule(argument_spec=module_args) + module = AnsibleCatalystwanModule( + argument_spec=module_args, + mutually_exclusive=[ + ("details", "backup"), + ("details", "backup_dir_path"), + ], + ) result = ExtendedModuleResult() details = module.params.get("details") @@ -130,19 +144,22 @@ def run_module(): backup = module.params.get("backup") backup_dir_path: Path = Path(module.params.get("backup_dir_path")) - devices = get_target_device(module, device_category=module.params.get("device_category"), all_from_category=True) + devices: DataSequence[DeviceDetailsResponse] = get_target_device( + module, device_category=module.params.get("device_category"), all_from_category=True + ) if not devices: + module.module.warn("No devices found") module.exit_json(**result.model_dump(mode="json")) - if details: + if details and not backup: if filters: filtered_devices: DataSequence[DeviceDetailsResponse] = devices.filter(**filters) if filtered_devices: module.logger.debug(f"All filtered_devices: {filtered_devices}") result.devices = [dev.model_dump(mode="json") for dev in filtered_devices] else: - result.msg = f"No devices found based on filters: {filters}" + module.module.warn(f"No devices found based on filters: {filters}") else: result.devices = [dev.model_dump(mode="json") for dev in devices] @@ -154,20 +171,23 @@ def run_module(): module.fail_json(msg=f"Cannot create or find directory: {backup_dir_path}, exception: {ex.strerror}") if filters: - devices = module.get_response_safely(module.session.api.devices.get).filter(**filters) + devices: DataSequence[Device] = module.get_response_safely(module.session.api.devices.get).filter(**filters) else: - devices = module.get_response_safely(module.session.api.devices.get) + devices: DataSequence[Device] = module.get_response_safely(module.session.api.devices.get) if devices: for device in devices: rcfg = module.get_response_safely(module.session.api.templates.load_running, device=device) timestamp = datetime.now().strftime("%d-%m-%Y-%H-%M") - rcfg.save_as(f"{backup_dir_path}/{device.hostname}_{timestamp}") - result.msg = ( - f"Succesfully saved running configuration to file: {backup_dir_path}/{device.hostname}_{timestamp}" + filename = f"{device.hostname}_{timestamp}.txt" + backup_path = f"{backup_dir_path}/{filename}" + rcfg.save_as(backup_path) + result.backup_paths.append( + BackupPathModel(hostname=device.hostname, backup_path=backup_path, filename=filename) ) + result.msg = f"Succesfully saved running configuration to file: {backup_path}" else: - result.msg = f"No devices found based on filters: {filters}" + module.module.warn(f"No devices found based on filters: {filters}") module.exit_json(**result.model_dump(mode="json")) diff --git a/plugins/modules/feature_templates.py b/plugins/modules/feature_templates.py index 43ad8ae..55c76b4 100644 --- a/plugins/modules/feature_templates.py +++ b/plugins/modules/feature_templates.py @@ -138,8 +138,6 @@ def run_module(): ) result = ExtendedModuleResult() - result.state = None - result.response = None module = AnsibleCatalystwanModule( argument_spec=module_args, diff --git a/plugins/modules/feature_templates_info.py b/plugins/modules/feature_templates_info.py index f398b8c..4866d44 100644 --- a/plugins/modules/feature_templates_info.py +++ b/plugins/modules/feature_templates_info.py @@ -141,13 +141,14 @@ returned: always sample: false """ -from typing import Optional, Dict -from pydantic import Field + +from typing import Dict, Optional from catalystwan.api.template_api import FeatureTemplate from catalystwan.dataclasses import FeatureTemplateInfo from catalystwan.typed_list import DataSequence from catalystwan.utils.creation_tools import asdict +from pydantic import Field from ..module_utils.result import ModuleResult from ..module_utils.vmanage_module import AnsibleCatalystwanModule @@ -162,8 +163,6 @@ def run_module(): filters=dict(type="dict", default=None, required=False), ) result = ExtendedModuleResult() - result.state = None - result.response = None module = AnsibleCatalystwanModule(argument_spec=module_args) diff --git a/plugins/modules/vmanage_mode.py b/plugins/modules/vmanage_mode.py index 831bb23..2bda9dd 100644 --- a/plugins/modules/vmanage_mode.py +++ b/plugins/modules/vmanage_mode.py @@ -19,8 +19,8 @@ description: - The state of vManage mode to enforce on the specified devices. type: str - choices: ['present'] - default: 'present' + choices: ["present"] + default: "present" hostnames: description: - A list of hostnames of devices to which the vManage mode will be applied. @@ -67,6 +67,7 @@ returned: always sample: true """ + import traceback from typing import Dict, Literal, Optional, get_args @@ -110,7 +111,7 @@ def run_module(): for hostname in module.params["hostnames"]: device = devices.filter(hostname=hostname).single_or_default() try: - template_name = f"Default_{hostname}" + template_name = f"Default-{hostname}" device_model = device.model if device.personality is Personality.VBOND: device_model = "vedge-cloud" From 5410801f25d60f90f896209c9360f0cfe5637410 Mon Sep 17 00:00:00 2001 From: acichon Date: Wed, 10 Jul 2024 16:51:36 +0200 Subject: [PATCH 15/18] attaching device templates --- playbooks/tests/test_device_templates.yml | 41 +- .../tests/test_device_templates_info.yml | 9 + playbooks/tests/test_templates_attachment.yml | 183 +++++++- playbooks/tests/test_templates_removal.yml | 60 +++ plugins/doc_fragments/feature_template_aaa.py | 443 ++++++++++++++++++ .../feature_template_cisco_system.py | 16 +- .../feature_template_system_vsmart.py | 64 ++- .../feature_template_vpn_vsmart.py | 222 +++++++++ .../feature_template_vpn_vsmart_interface.py | 299 ++++++++++++ plugins/module_utils/feature_templates/aaa.py | 144 ++++++ .../feature_templates/cisco_system.py | 366 +++++---------- .../feature_templates/system_vsmart.py | 170 +++---- .../feature_templates/vpn_vsmart.py | 93 ++++ .../feature_templates/vpn_vsmart_interface.py | 52 ++ plugins/modules/device_templates.py | 60 ++- plugins/modules/device_templates_info.py | 63 ++- plugins/modules/feature_templates.py | 10 +- utils/ft_generator.py | 38 +- 18 files changed, 1927 insertions(+), 406 deletions(-) create mode 100644 playbooks/tests/test_templates_removal.yml create mode 100644 plugins/doc_fragments/feature_template_aaa.py create mode 100644 plugins/doc_fragments/feature_template_vpn_vsmart.py create mode 100644 plugins/doc_fragments/feature_template_vpn_vsmart_interface.py create mode 100644 plugins/module_utils/feature_templates/aaa.py create mode 100644 plugins/module_utils/feature_templates/vpn_vsmart.py create mode 100644 plugins/module_utils/feature_templates/vpn_vsmart_interface.py diff --git a/playbooks/tests/test_device_templates.yml b/playbooks/tests/test_device_templates.yml index a148f0c..3211888 100644 --- a/playbooks/tests/test_device_templates.yml +++ b/playbooks/tests/test_device_templates.yml @@ -33,23 +33,24 @@ ansible.builtin.debug: msg: "{{ device_templates }}" - - name: Delete selected Device Template from vManage - cisco.catalystwan.device_templates: - state: absent - template_name: "vc8000-device-template" - manager_credentials: - <<: *manager_authentication - - - name: Create example Device Template with default templates - cisco.catalystwan.device_templates: - state: present - template_name: "vc8000-device-template" - template_description: "vc8000-device-template" - device_type: vedge-C8000V - device_role: sdwan-edge - general_templates: - - "Factory_Default_Cisco_BFD_Template" - - "Factory_Default_Cisco_OMP_ipv46_Template" - - "Factory_Default_Cisco_Security_Template" - manager_credentials: - <<: *manager_authentication + # - name: Delete selected Device Template from vManage + # cisco.catalystwan.device_templates: + # state: absent + # template_name: "vc8000-device-template" + # manager_credentials: + # <<: *manager_authentication + + # - name: Create example Device Template with default templates + # cisco.catalystwan.device_templates: + # state: present + # template_name: "vc8000-device-template" + # template_description: "vc8000-device-template" + # device_type: vedge-C8000V + # device_role: sdwan-edge + # general_templates: + # - name: "Factory_Default_Cisco_BFD_Template" + # subtemplates: "Factory_Default_Cisco_Logging_Template" + # - name: "Factory_Default_Cisco_OMP_ipv46_Template" + # - name: "Factory_Default_Cisco_Security_Template" + # manager_credentials: + # <<: *manager_authentication diff --git a/playbooks/tests/test_device_templates_info.yml b/playbooks/tests/test_device_templates_info.yml index 37489d2..b77c268 100644 --- a/playbooks/tests/test_device_templates_info.yml +++ b/playbooks/tests/test_device_templates_info.yml @@ -32,3 +32,12 @@ - name: Debug Templates Info ansible.builtin.debug: msg: "{{ device_templates }}" + + - name: Backup all Non-Default Device Templates available + cisco.catalystwan.device_templates_info: + filters: + factory_default: false + backup: true + manager_credentials: + <<: *manager_authentication + register: device_templates diff --git a/playbooks/tests/test_templates_attachment.yml b/playbooks/tests/test_templates_attachment.yml index 7fb9181..88e8495 100644 --- a/playbooks/tests/test_templates_attachment.yml +++ b/playbooks/tests/test_templates_attachment.yml @@ -7,7 +7,7 @@ # Tested operations: -# --- Device Templates attachment - from --- # +# --- Device Templates attachment - created from Feature Templates--- # - name: Testing playbook to verify cisco.catalystwan.device_templates module operations @@ -21,6 +21,30 @@ username: "{{ (vmanage_instances | first).admin_username }}" password: "{{ (vmanage_instances | first).admin_password }}" tasks: + - name: Get all Device Templates that are not attached to any device + cisco.catalystwan.device_templates_info: + filters: + devices_attached: 0 + factory_default: false + manager_credentials: + <<: *manager_authentication + register: device_templates + + - name: Debug Templates Info + ansible.builtin.debug: + msg: "{{ device_templates.templates_info }}" + + - name: Delete selected Device Templates from vManage + cisco.catalystwan.device_templates: + state: absent + template_name: "{{ device_template.templateName }}" + manager_credentials: + <<: *manager_authentication + loop: "{{ device_templates.templates_info | default([], True) }}" + loop_control: + loop_var: device_template + when: device_templates.templates_info | length > 0 + - name: Backup running-config from devices, store in default backup dir (in CWD) cisco.catalystwan.devices_info: backup: true @@ -48,6 +72,7 @@ cisco.catalystwan.feature_templates_info: filters: factory_default: false + devices_attached: 0 manager_credentials: <<: *manager_authentication register: feature_templates @@ -64,3 +89,159 @@ label: "template: {{ template.templateName }}" # Create now all Feature Templates that are necessary to form minimal Device Template, and attach this template + # These will be applicable for vSmart devices + + - name: Create AAA Template for vSmart devices + cisco.catalystwan.feature_templates: + state: present + template_name: "AAA_for_vSmart" + template_description: "AAA Template for testing" + device_models: vsmart + debug: true + aaa: + auth_fallback: false + admin_auth_order: false + accounting: false + usergroup: + - name: basic + task: + - mode: system + permission: + - read + - mode: interface + permission: + - read + - name: netadmin + task: [] + - name: operator + task: + - mode: system + permission: + - read + - mode: interface + permission: + - read + - mode: policy + permission: + - read + - mode: routing + permission: + - read + - mode: security + permission: + - read + user: + - name: admin + password: Cisco#123@ViptelaXDD + manager_credentials: + <<: *manager_authentication + + - name: Create System Template for vSmart devices + cisco.catalystwan.feature_templates: + state: present + template_name: "System_for_vSmart" + template_description: "System Template for testing" + device_specific_variables: + site_id: "side_id_variable" + device_models: vsmart + debug: true + system_vsmart: + site_id: device_specific_variable + manager_credentials: + <<: *manager_authentication + + # Now for vpn and vpn interfaces, and then attach device template with device specific variables + - name: Create VPN template for vSmart devices - VPN 0 + cisco.catalystwan.feature_templates: + state: present + template_name: "VPN_0_for_vSmart" + template_description: "VPN_0 Template for testing" + device_models: vsmart + debug: true + vpn_vsmart: + vpn_id: 0 + manager_credentials: + <<: *manager_authentication + + - name: Create VPN template for vSmart devices - VPN 512 + cisco.catalystwan.feature_templates: + state: present + template_name: "VPN_512_for_vSmart" + template_description: "VPN_512 Template for testing" + device_models: vsmart + debug: true + vpn_vsmart: + vpn_id: 512 + manager_credentials: + <<: *manager_authentication + + - name: Create VPN Interface template for vSmart devices - VPN 0 + cisco.catalystwan.feature_templates: + state: present + template_name: "VPN_0_Interface_for_vSmart" + template_description: "VPN_0 Interface Template for testing" + device_models: vsmart + debug: true + vpn_vsmart_interface: + if_name: eth1 + shutdown: false + dhcp_ipv4_client: true + dhcp: true + dns: true + icmp: true + sshd: true + netconf: true + ntp: false + stun: false + manager_credentials: + <<: *manager_authentication + + - name: Create VPN Interface template for vSmart devices - VPN 512 + cisco.catalystwan.feature_templates: + state: present + template_name: "VPN_512_Interface_for_vSmart" + template_description: "VPN_512 Interface Template for testing" + device_models: vsmart + debug: true + vpn_vsmart_interface: + if_name: eth0 + shutdown: false + dhcp_ipv4_client: true + manager_credentials: + <<: *manager_authentication + + - name: Create example Device Template for vSmart + cisco.catalystwan.device_templates: + state: present + template_name: "vSmart-test-device-template" + template_description: "vSmart-test-device-template" + device_type: vsmart + general_templates: + - name: "System_for_vSmart" + subtemplates: + - "Factory_Default_Logging_Template_V01" + - name: "AAA_for_vSmart" + - name: "Factory_Default_vSmart_OMP_Template" + - name: "Factory_Default_vSmart_vManage_Security_Template" + - name: "VPN_0_for_vSmart" + subtemplates: + - "VPN_0_Interface_for_vSmart" + - name: "VPN_512_for_vSmart" + subtemplates: + - "VPN_512_Interface_for_vSmart" + manager_credentials: + <<: *manager_authentication + + - name: Attach example Device Template for vSmart + cisco.catalystwan.device_templates: + state: attached + template_name: "second_vSmart-test-device-template" + device_type: vsmart + hostname: "acich-rg-vSmart" + device_specific_vars: + - "//system/site-id": "333" + - "//system/host-name": "acich-rg-vSmart" + - "//system/system-ip": "192.168.2.1" + - "//system/ipv6-strict-control": false + manager_credentials: + <<: *manager_authentication diff --git a/playbooks/tests/test_templates_removal.yml b/playbooks/tests/test_templates_removal.yml new file mode 100644 index 0000000..c4d3c6e --- /dev/null +++ b/playbooks/tests/test_templates_removal.yml @@ -0,0 +1,60 @@ +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +--- + +# Helper playbooks to test modules and flows while developing them + +# Tested operations: + + +- name: Testing playbook to verify cisco.catalystwan.device_templates module operations + hosts: localhost + gather_facts: false + vars_files: + - configuration_file_dev_vars.yml + vars: + manager_authentication: &manager_authentication + url: "{{ (vmanage_instances | first).mgmt_public_ip }}" + username: "{{ (vmanage_instances | first).admin_username }}" + password: "{{ (vmanage_instances | first).admin_password }}" + tasks: + - name: Get all Device Templates that are not attached to any device + cisco.catalystwan.device_templates_info: + filters: + devices_attached: 0 + factory_default: false + manager_credentials: + <<: *manager_authentication + register: device_templates + + - name: Delete selected Device Templates from vManage + cisco.catalystwan.device_templates: + state: absent + template_name: "{{ device_template.templateName }}" + manager_credentials: + <<: *manager_authentication + loop: "{{ device_templates.templates_info | default([], True) }}" + loop_control: + loop_var: device_template + when: device_templates.templates_info | length > 0 + + - name: Get all Non-Default Feature Templates available + cisco.catalystwan.feature_templates_info: + filters: + factory_default: false + devices_attached: 0 + manager_credentials: + <<: *manager_authentication + register: feature_templates + + - name: Delete all Non-Default Feature templates + cisco.catalystwan.feature_templates: + state: absent + template_name: "{{ template.templateName }}" + manager_credentials: + <<: *manager_authentication + loop: "{{ feature_templates.templates_info | default([], true) }}" + loop_control: + loop_var: template + label: "template: {{ template.templateName }}" diff --git a/plugins/doc_fragments/feature_template_aaa.py b/plugins/doc_fragments/feature_template_aaa.py new file mode 100644 index 0000000..6047db1 --- /dev/null +++ b/plugins/doc_fragments/feature_template_aaa.py @@ -0,0 +1,443 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" +options: + aaa: + description: AAA Feature Template configuration + type: dict + suboptions: + auth_order: + description: + - ServerGroups authentication order to user access + required: false + default: + - local + - radius + - tacacs + type: list + elements: str + choices: + - local + - radius + - tacacs + auth_fallback: + description: + - Authenticate admin user as per auth-order + required: false + default: false + type: bool + admin_auth_order: + description: + - Fall back if higher-priority authentication fails + required: false + default: false + type: bool + netconf_disable: + description: + - Disable Netconf logs + required: false + default: false + type: bool + audit_disable: + description: + - Disable audit logs + required: false + default: false + type: bool + radius_server_list: + description: + - Designate radius servers for authentication and accounting + required: false + default: null + type: list + elements: str + task: + description: + - Set the user group's tasks and task privileges. + required: false + default: null + type: list + elements: dict + suboptions: + name: + description: + - The name of the user + required: true + default: null + type: str + config_default_action: + description: + - Define config default action + required: true + default: null + type: str + choices: + - accept + - deny + oper_exec_default_action: + description: + - Define oper-exec default action + required: true + default: null + type: str + choices: + - accept + - deny + oper_exec_accept_action: + description: + - List of oper-exec commands to allow + required: false + default: null + type: list + elements: dict + suboptions: + command: + description: + - Define command + required: true + default: null + type: str + oper_exec_deny_action: + description: + - List of oper-exec commands to deny + required: false + default: null + type: list + elements: dict + suboptions: + command: + description: + - Define command + required: true + default: null + type: str + config_accept_action: + description: + - List of config commands to allow + required: false + default: null + type: list + elements: dict + suboptions: + command: + description: + - Define command + required: true + default: null + type: str + config_deny_action: + description: + - List of config commands to deny + required: false + default: null + type: list + elements: dict + suboptions: + command: + description: + - Define command + required: true + default: null + type: str + password: + description: + - The password for the user + required: false + default: null + type: str + secret: + description: + - The secret for the user + required: false + default: null + type: str + privilege: + description: + - The privilege level for the user + required: false + default: '15' + type: str + choices: + - '1' + - '15' + accounting: + description: + - Enable/disable user accounting + required: false + default: false + type: bool + usergroup: + description: + - Create groupings of users with the same authorization privileges. + When used, overrides existing groups(netadmin, basic, operator) + required: false + default: null + type: list + elements: dict + suboptions: + name: + description: + - Set name of user group + required: true + default: null + type: str + task: + description: + - Set the user group's tasks and task privileges. Skipping + tasks sets all as read and write + required: false + default: null + type: list + elements: dict + suboptions: + mode: + description: + - Select the task to set privileges for + required: true + default: null + type: str + choices: + - system + - interface + - policy + - routing + - security + permission: + description: + - Set read or write permission for the task + required: false + default: pap + type: list + elements: str + choices: + - read + - write + user: + description: + - List of local user configurations. When used, overrides existing + users + required: false + default: null + type: list + elements: dict + suboptions: + name: + description: + - The name of the user + required: true + default: null + type: str + password: + description: + - The password for the user + required: false + default: null + type: str + secret: + description: + - The secret for the user + required: false + default: null + type: str + description: + description: + - Add a description of the user + required: false + default: null + type: str + group: + description: + - Configure the groups that the user is part of + required: false + default: null + type: list + elements: str + pubkey_chain: + description: + - List of public keys for the user + required: false + default: null + type: list + elements: dict + suboptions: + usertag: + description: + - User Tag + required: true + default: null + type: str + key_string: + description: + - Set the RSA key string + required: true + default: null + type: str + key_type: + description: + - Only RSA is supported + required: false + default: ssh-rsa + type: str + cisco_tac_ro_user: + description: + - Cisco Tac Enable Read only + required: false + default: true + type: bool + cisco_tac_rw_user: + description: + - Cisco Tac Enable Read and Write + required: false + default: true + type: bool + tacacs_timeout: + description: + - The timeout period in seconds for the TACACS+ server + required: false + default: null + type: int + tacacs_authentication: + description: + - TACACS authentication type + required: false + default: pap + type: str + choices: + - pap + - ascii + tacacs_server: + description: + - The list of TACACS+ servers + required: false + default: null + type: list + elements: dict + suboptions: + address: + description: + - The IP address or hostname of the TACACS+ server + required: true + default: null + type: str + auth_port: + description: + - The authentication port for the TACACS+ server + required: false + default: null + type: int + vpn: + description: + - Set VPN in which TACACS+ server is located + required: false + default: null + type: str + source_interface: + description: + - Set interface to use to reach TACACS+ server + required: false + default: null + type: str + key: + description: + - Set the password to access the TACACS+ server + required: false + default: null + type: str + secret_key: + description: + - Set the AES encrypted key to access the TACACS+ server + required: false + default: null + type: str + priority: + description: + - TACACS+ server priority <0..7> + required: false + default: null + type: int + radius_timeout: + description: + - The timeout period in seconds for the RADIUS server + required: false + default: null + type: int + radius_retransmit: + description: + - The number of retransmit attempts for the RADIUS server + required: false + default: null + type: int + radius_server: + description: + - The list of RADIUS servers + required: false + default: null + type: list + elements: dict + suboptions: + address: + description: + - The IP address or hostname of the RADIUS server + required: true + default: null + type: str + auth_port: + description: + - The authentication port for the RADIUS server + required: false + default: null + type: int + tag: + description: + - Reference tag/name for the server + required: false + default: null + type: str + acct_port: + description: + - The accounting port for the RADIUS server + required: false + default: null + type: int + vpn: + description: + - Set VPN in which RADIUS server is located + required: false + default: null + type: str + source_interface: + description: + - Set interface to use to reach RADIUS server + required: false + default: null + type: str + key: + description: + - Set the password to access the RADIUS server + required: false + default: null + type: str + secret_key: + description: + - Set the AES encrypted key to access the RADIUS server + required: false + default: null + type: str + priority: + description: + - RADIUS server priority <0..7> + required: false + default: null + type: int + """ diff --git a/plugins/doc_fragments/feature_template_cisco_system.py b/plugins/doc_fragments/feature_template_cisco_system.py index bb1d3ae..4edee17 100644 --- a/plugins/doc_fragments/feature_template_cisco_system.py +++ b/plugins/doc_fragments/feature_template_cisco_system.py @@ -450,15 +450,13 @@ class ModuleDocFragment(object): description: - The hostname for the device. required: false - default: system_host_name - type: dict + type: raw suboptions: name: - description: - - Device Specific Variables names + default: system_host_name required: true - default: null type: str + description: Device Specific Variables name location: description: - The physical location of the device. @@ -528,15 +526,13 @@ class ModuleDocFragment(object): description: - The system IP address of the device. required: false - default: system_system_ip - type: dict + type: raw suboptions: name: - description: - - Device Specific Variables names + default: system_system_ip required: true - default: null type: str + description: Device Specific Variables name overlay_id: description: - The overlay ID of the device. diff --git a/plugins/doc_fragments/feature_template_system_vsmart.py b/plugins/doc_fragments/feature_template_system_vsmart.py index 83b3a2a..dc70f37 100644 --- a/plugins/doc_fragments/feature_template_system_vsmart.py +++ b/plugins/doc_fragments/feature_template_system_vsmart.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r''' + DOCUMENTATION = r""" options: system_vsmart: description: Security settings for vSmart controller @@ -21,7 +21,7 @@ class ModuleDocFragment(object): description: - The timezone setting for the vSmart controller required: false - default: null + default: UTC type: str choices: - Europe/Andorra @@ -444,14 +444,24 @@ class ModuleDocFragment(object): description: - The hostname for the vSmart controller required: false - default: null - type: str + type: raw + suboptions: + name: + default: system_host_name + required: true + type: str + description: Device Specific Variables name dual_stack_ipv6: description: - Enable Dual Stack IPv6 Default required: false - default: null - type: bool + type: raw + suboptions: + name: + default: system_ipv6-strict-control + required: true + type: str + description: Device Specific Variables name description: description: - Set a text description of the device @@ -469,7 +479,7 @@ class ModuleDocFragment(object): - MTU size for system tunnels required: false default: null - type: str + type: int latitude: description: - Geographical latitude of the vSmart controller @@ -487,19 +497,30 @@ class ModuleDocFragment(object): - Device group names for the vSmart controller required: false default: null - type: str + type: list + elements: str system_ip: description: - System IP address for the vSmart controller required: false - default: null - type: str + type: raw + suboptions: + name: + default: system_system_ip + required: true + type: str + description: Device Specific Variables name site_id: description: - Site ID for the vSmart controller required: false - default: null - type: int + type: raw + suboptions: + name: + default: system_site_id + required: true + type: str + description: Device Specific Variables name overlay_id: description: - Overlay ID for the vSmart controller @@ -511,9 +532,10 @@ class ModuleDocFragment(object): - Set the topology required: false default: null - type: str + type: list + elements: str choices: - - Hub and Spoke + - hub-and-spoke port_offset: description: - Port offset for port hopping @@ -542,25 +564,25 @@ class ModuleDocFragment(object): description: - Enable or disable tracking of transport connections required: false - default: null + default: true type: bool track_default_gateway: description: - Enable or disable tracking of the default gateway required: false - default: null + default: true type: bool iptables_enable: description: - Enable or disable iptables for security required: false - default: null + default: true type: bool admin_tech_on_failure: description: - Enable automatic generation of tech-support file on failure required: false - default: null + default: true type: bool idle_timeout: description: @@ -591,7 +613,7 @@ class ModuleDocFragment(object): - Configure compatible TLOC color required: false default: null - type: dict + type: list elements: dict suboptions: color_1: @@ -657,7 +679,7 @@ class ModuleDocFragment(object): - Configure incompatible TLOC color required: false default: null - type: dict + type: list elements: dict suboptions: color_1: @@ -718,4 +740,4 @@ class ModuleDocFragment(object): - private4 - private5 - private6 - ''' \ No newline at end of file + """ diff --git a/plugins/doc_fragments/feature_template_vpn_vsmart.py b/plugins/doc_fragments/feature_template_vpn_vsmart.py new file mode 100644 index 0000000..6b35787 --- /dev/null +++ b/plugins/doc_fragments/feature_template_vpn_vsmart.py @@ -0,0 +1,222 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" +options: + vpn_vsmart: + description: vSmart VPN Feature Template configuration. + type: dict + suboptions: + vpn_id: + description: + - The unique identifier for the VPN, only 0 and 512 are allowed on + vsmart + required: true + default: null + type: str + choices: + - '0' + - '512' + name: + description: + - The name of the VPN. + required: false + default: null + type: str + dns: + description: + - A list of DNS configurations for the VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + dns_addr: + description: + - The IP address of the DNS server. + required: false + default: null + type: str + role: + description: + - The role of the DNS server, either 'PRIMARY' or 'SECONDARY'. + required: true + default: null + type: str + choices: + - primary + - secondary + host: + description: + - Static DNS mapping + required: false + default: null + type: list + elements: dict + suboptions: + hostname: + description: + - The hostname of the device. + required: true + default: null + type: str + ip: + description: + - A list of IP addresses associated with the hostname. + required: true + default: null + type: list + elements: str + route_v4: + description: + - A list of IPv4 route configurations within the VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + prefix: + description: + - The IPv4 network prefix for the static route. + required: false + default: null + type: str + next_hop: + description: + - A list of IPv4 next hops for the route. + required: false + default: null + type: list + elements: dict + suboptions: + address: + description: + - The IP address of the next hop for the route. + required: false + default: null + type: str + distance: + description: + - The administrative distance of the next hop. + required: false + default: null + type: int + route_interface: + description: + - The interface configuration for the IPv4 static route. + required: false + default: null + type: dict + elements: dict + suboptions: + interface_name: + description: + - The name of the interface used for routing. + required: true + default: null + type: str + interface_next_hop: + description: + - A list of next hops associated with the interface + for routing purposes. + required: false + default: null + type: list + elements: dict + suboptions: + address: + description: + - The IP address of the next hop for the route. + required: false + default: null + type: str + distance: + description: + - The administrative distance of the next + hop. + required: false + default: null + type: int + null0: + description: + - A flag indicating whether to route traffic to null0 for + this static route. + required: false + default: null + type: bool + distance: + description: + - The administrative distance for the static route. + required: false + default: null + type: int + vpn: + description: + - The VPN instance identifier associated with the static route. + required: false + default: null + type: int + route_v6: + description: + - A list of IPv6 route configurations within the VPN instance. + required: false + default: null + type: list + elements: dict + suboptions: + prefix: + description: + - The IPv6 network prefix for the static route. + required: true + default: null + type: str + next_hop: + description: + - A list of IPv6 next hops for the route. + required: false + default: null + type: list + elements: dict + suboptions: + address: + description: + - The IPv6 address of the next hop for the route. + required: true + default: null + type: str + distance: + description: + - The administrative distance of the IPv6 next hop. + required: false + default: null + type: int + null0: + description: + - A flag indicating whether to route IPv6 traffic to null0 + for this static route. + required: false + default: null + type: bool + distance: + description: + - The administrative distance for the static route. + required: false + default: null + type: int + vpn: + description: + - The VPN instance identifier associated with the static route. + required: false + default: null + type: int + """ diff --git a/plugins/doc_fragments/feature_template_vpn_vsmart_interface.py b/plugins/doc_fragments/feature_template_vpn_vsmart_interface.py new file mode 100644 index 0000000..f8f65c0 --- /dev/null +++ b/plugins/doc_fragments/feature_template_vpn_vsmart_interface.py @@ -0,0 +1,299 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This file is autogenerated by `utils/feature_template_docs_generator.py` + + +from __future__ import annotations + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" +options: + vpn_vsmart_interface: + description: vSmart VPN Interface Feature Template configuration + type: dict + suboptions: + if_name: + description: + - The name of the interface. + required: false + default: null + type: str + interface_description: + description: + - A description for the interface. + required: false + default: null + type: str + ipv4_address: + description: + - The primary IPv4 address assigned to the interface. + required: false + default: null + type: str + dhcp_ipv4_client: + description: + - Whether DHCP client is enabled on the interface for IPv4 addressing. + True if enabled, False otherwise. + required: false + default: null + type: bool + dhcp_distance: + description: + - Administrative distance for DHCP routes on the interface. + required: false + default: null + type: int + ipv6_address: + description: + - The primary IPv6 address assigned to the interface. + required: false + default: null + type: str + dhcp_ipv6_client: + description: + - Whether DHCP client is enabled on the interface for IPv6 addressing. + True if enabled, False otherwise. + required: false + default: null + type: bool + dhcp_ipv6_distance: + description: + - Administrative distance for DHCP routes on the interface. + required: false + default: null + type: int + dhcp_rapid_commit: + description: + - Enable DHCPv6 rapid commit + required: false + default: null + type: bool + group: + description: + - Identifies the group or groups the interface belongs to. + required: false + default: null + type: list + elements: int + value: + description: + - The value field often corresponds to a specific attribute or setting, + such as color in this context. + required: false + default: null + type: str + choices: + - default + - mpls + - metro-ethernet + - biz-internet + - public-internet + - lte + - 3g + - red + - green + - blue + - gold + - silver + - bronze + - custom1 + - custom2 + - custom3 + - private1 + - private2 + - private3 + - private4 + - private5 + - private6 + carrier: + description: + - Specifies the carrier information for the tunnel interface. + required: false + default: null + type: str + choices: + - default + - carrier1 + - carrier2 + - carrier3 + - carrier4 + - carrier5 + - carrier6 + - carrier7 + - carrier8 + nat_refresh_interval: + description: + - Interval in seconds to refresh NAT (Network Address Translation) + mappings. + required: false + default: null + type: int + hello_interval: + description: + - Time interval in seconds between successive hello packets sent over + the tunnel interface. + required: false + default: null + type: int + hello_tolerance: + description: + - Time in seconds to wait before declaring a neighbor down due to + missing hello packets. + required: false + default: null + type: int + all: + description: + - Permits or denies all services through the tunnel interface. + required: false + default: null + type: bool + dhcp: + description: + - Enables or disables Dynamic Host Configuration Protocol (DHCP) on + the tunnel interface. + required: false + default: null + type: bool + dns: + description: + - Allows or disallows Domain Name System (DNS) queries through the + tunnel interface. + required: false + default: null + type: bool + icmp: + description: + - Enables or disables Internet Control Message Protocol (ICMP) for + ping and traceroute through the tunnel interface. + required: false + default: null + type: bool + sshd: + description: + - Allows or disallows Secure Shell (SSH) daemon access through the + tunnel interface. + required: false + default: null + type: bool + netconf: + description: + - Enables or disables NETCONF protocol support on the tunnel interface. + required: false + default: null + type: bool + ntp: + description: + - Allows or disallows Network Time Protocol (NTP) synchronization + through the tunnel interface. + required: false + default: null + type: bool + stun: + description: + - Enables or disables Session Traversal Utilities for NAT (STUN) on + the tunnel interface. + required: false + default: null + type: bool + flow_control: + description: + - Enable flow control. + required: false + default: null + type: str + choices: + - ingress + - egress + - autoneg + - both + - none + clear_dont_fragment: + description: + - Enables Clear don't fragment bit + required: false + default: false + type: bool + autonegotiate: + description: + - Link autonegotiation + required: false + default: true + type: bool + pmtu: + description: + - Enables Path MTU Discovery + required: false + default: false + type: bool + mtu: + description: + - Interface MTU <576..2000> + required: false + default: null + type: int + tcp_mss_adjust: + description: + - TCP MSS on SYN packets, in bytes + required: false + default: null + type: int + mac_address: + description: + - Specifies the MAC address for the interface. + required: false + default: null + type: str + speed: + description: + - Defines the speed of the interface, such as 10Mbps, 100Mbps, or + 1Gbps. + required: false + default: null + type: str + choices: + - '10' + - '100' + - '1000' + duplex: + description: + - Sets the duplex mode for the interface, such as full or half duplex. + required: false + default: null + type: str + choices: + - full + - half + shutdown: + description: + - Enables or disables (shuts down) the interface. + required: false + default: false + type: bool + ip: + description: + - A list of IP configurations for Address Resolution Protocol (ARP) + settings. + required: false + default: null + type: list + elements: dict + suboptions: + addr: + description: + - IPv4 address for the interface. + required: true + default: null + type: str + mac: + description: + - MAC address associated with the IPv4 address. + required: true + default: null + type: str + """ diff --git a/plugins/module_utils/feature_templates/aaa.py b/plugins/module_utils/feature_templates/aaa.py new file mode 100644 index 0000000..36b7b39 --- /dev/null +++ b/plugins/module_utils/feature_templates/aaa.py @@ -0,0 +1,144 @@ +aaa_definition = { + "aaa": { + "default": None, + "options": { + "accounting": {"default": False, "required": False, "type": "bool"}, + "admin_auth_order": {"default": False, "required": False, "type": "bool"}, + "audit_disable": {"default": False, "required": False, "type": "bool"}, + "auth_fallback": {"default": False, "required": False, "type": "bool"}, + "auth_order": { + "default": ["local", "radius", "tacacs"], + "elements": "str", + "required": False, + "type": "list", + }, + "cisco_tac_ro_user": {"default": True, "required": False, "type": "bool"}, + "cisco_tac_rw_user": {"default": True, "required": False, "type": "bool"}, + "netconf_disable": {"default": False, "required": False, "type": "bool"}, + "radius_retransmit": {"default": None, "required": False, "type": "int"}, + "radius_server": { + "default": None, + "elements": "dict", + "options": { + "acct_port": {"default": None, "required": False, "type": "int"}, + "address": {"default": None, "required": True, "type": "str"}, + "auth_port": {"default": None, "required": False, "type": "int"}, + "key": {"default": None, "required": False, "type": "str"}, + "priority": {"default": None, "required": False, "type": "int"}, + "secret_key": {"default": None, "required": False, "type": "str"}, + "source_interface": {"default": None, "required": False, "type": "str"}, + "tag": {"default": None, "required": False, "type": "str"}, + "vpn": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "radius_server_list": {"default": None, "elements": "str", "required": False, "type": "list"}, + "radius_timeout": {"default": None, "required": False, "type": "int"}, + "tacacs_authentication": {"default": "pap", "required": False, "type": "str"}, + "tacacs_server": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": True, "type": "str"}, + "auth_port": {"default": None, "required": False, "type": "int"}, + "key": {"default": None, "required": False, "type": "str"}, + "priority": {"default": None, "required": False, "type": "int"}, + "secret_key": {"default": None, "required": False, "type": "str"}, + "source_interface": {"default": None, "required": False, "type": "str"}, + "vpn": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "tacacs_timeout": {"default": None, "required": False, "type": "int"}, + "task": { + "default": None, + "elements": "dict", + "options": { + "config_accept_action": { + "default": None, + "elements": "dict", + "options": {"command": {"default": None, "required": True, "type": "str"}}, + "required": False, + "type": "list", + }, + "config_default_action": {"default": None, "required": True, "type": "str"}, + "config_deny_action": { + "default": None, + "elements": "dict", + "options": {"command": {"default": None, "required": True, "type": "str"}}, + "required": False, + "type": "list", + }, + "name": {"default": None, "required": True, "type": "str"}, + "oper_exec_accept_action": { + "default": None, + "elements": "dict", + "options": {"command": {"default": None, "required": True, "type": "str"}}, + "required": False, + "type": "list", + }, + "oper_exec_default_action": {"default": None, "required": True, "type": "str"}, + "oper_exec_deny_action": { + "default": None, + "elements": "dict", + "options": {"command": {"default": None, "required": True, "type": "str"}}, + "required": False, + "type": "list", + }, + "password": {"default": None, "required": False, "type": "str"}, + "privilege": {"default": "15", "required": False, "type": "str"}, + "secret": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "user": { + "default": None, + "elements": "dict", + "options": { + "description": {"default": None, "required": False, "type": "str"}, + "group": {"default": None, "elements": "str", "required": False, "type": "list"}, + "name": {"default": None, "required": True, "type": "str"}, + "password": {"default": None, "required": False, "type": "str"}, + "pubkey_chain": { + "default": None, + "elements": "dict", + "options": { + "key_string": {"default": None, "required": True, "type": "str"}, + "key_type": {"default": "ssh-rsa", "required": False, "type": "str"}, + "usertag": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "secret": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "usergroup": { + "default": None, + "elements": "dict", + "options": { + "name": {"default": None, "required": True, "type": "str"}, + "task": { + "default": None, + "elements": "dict", + "options": { + "mode": {"default": None, "required": True, "type": "str"}, + "permission": {"default": "pap", "elements": "str", "required": False, "type": "list"}, + }, + "required": False, + "type": "list", + }, + }, + "required": False, + "type": "list", + }, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_system.py b/plugins/module_utils/feature_templates/cisco_system.py index b6723ba..078caa7 100644 --- a/plugins/module_utils/feature_templates/cisco_system.py +++ b/plugins/module_utils/feature_templates/cisco_system.py @@ -1,237 +1,129 @@ -cisco_system_definition = { 'cisco_system': { 'default': None, - 'options': { 'admin_tech_on_failure': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'affinity_group_number': { 'default': None, - 'required': False, - 'type': 'int'}, - 'affinity_per_vrf': { 'default': None, - 'elements': 'dict', - 'options': { 'affinity_group_number': { 'default': None, - 'required': False, - 'type': 'int'}, - 'vrf_range': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'console_baud_rate': { 'default': None, - 'required': False, - 'type': 'str'}, - 'control_session_pps': { 'default': None, - 'required': False, - 'type': 'int'}, - 'controller_group_list': { 'default': None, - 'elements': 'int', - 'required': False, - 'type': 'list'}, - 'description': { 'default': None, - 'required': False, - 'type': 'str'}, - 'device_groups': { 'default': None, - 'elements': 'str', - 'required': False, - 'type': 'list'}, - 'enable_fencing': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'enable_management_region': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'enable_mrf_migration': { 'default': None, - 'required': False, - 'type': 'str'}, - 'enable_sms': { 'default': False, - 'required': False, - 'type': 'bool'}, - 'enable_tunnel': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'epfr': { 'default': None, - 'required': False, - 'type': 'str'}, - 'hostname': { 'default': 'system_host_name', - 'options': { 'name': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'dict'}, - 'idle_timeout': { 'default': None, - 'required': False, - 'type': 'int'}, - 'latitude': { 'default': None, - 'required': False, - 'type': 'str'}, - 'location': { 'default': None, - 'required': False, - 'type': 'str'}, - 'longitude': { 'default': None, - 'required': False, - 'type': 'str'}, - 'management_gateway': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'max_omp_sessions': { 'default': None, - 'required': False, - 'type': 'int'}, - 'migration_bgp_community': { 'default': None, - 'required': False, - 'type': 'int'}, - 'mobile_number': { 'default': None, - 'elements': 'dict', - 'options': { 'number': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'multi_tenant': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'object_track': { 'default': None, - 'elements': 'dict', - 'options': { 'boolean': { 'default': None, - 'required': True, - 'type': 'str'}, - 'interface': { 'default': None, - 'required': True, - 'type': 'str'}, - 'ip': { 'default': None, - 'required': True, - 'type': 'str'}, - 'mask': { 'default': '0.0.0.0', - 'required': False, - 'type': 'str'}, - 'object': { 'default': None, - 'elements': 'dict', - 'options': { 'number': { 'default': None, - 'required': True, - 'type': 'int'}}, - 'required': True, - 'type': 'list'}, - 'object_number': { 'default': None, - 'required': True, - 'type': 'int'}, - 'sig': { 'default': None, - 'required': True, - 'type': 'str'}, - 'vpn': { 'default': None, - 'required': True, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'on_demand_idle_timeout_min': { 'default': None, - 'required': False, - 'type': 'int'}, - 'overlay_id': { 'default': None, - 'required': False, - 'type': 'int'}, - 'port_hop': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'port_offset': { 'default': None, - 'required': False, - 'type': 'int'}, - 'preference': { 'default': None, - 'elements': 'int', - 'required': False, - 'type': 'list'}, - 'preference_auto': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'range': { 'default': None, - 'required': False, - 'type': 'int'}, - 'region_id': { 'default': None, - 'required': False, - 'type': 'int'}, - 'role': { 'default': None, - 'required': False, - 'type': 'str'}, - 'secondary_region': { 'default': None, - 'required': False, - 'type': 'int'}, - 'site_id': { 'default': 'system_site_id', - 'required': False, - 'type': 'int'}, - 'site_type': { 'default': None, - 'elements': 'str', - 'required': False, - 'type': 'list'}, - 'system_ip': { 'default': 'system_system_ip', - 'options': { 'name': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'dict'}, - 'timezone': { 'default': None, - 'required': False, - 'type': 'str'}, - 'track_default_gateway': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'track_interface_tag': { 'default': None, - 'required': False, - 'type': 'int'}, - 'track_transport': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'tracker': { 'default': None, - 'elements': 'dict', - 'options': { 'boolean': { 'default': 'or', - 'required': False, - 'type': 'str'}, - 'elements': { 'default': None, - 'elements': 'str', - 'required': False, - 'type': 'list'}, - 'endpoint_api_url': { 'default': None, - 'required': False, - 'type': 'str'}, - 'endpoint_dns_name': { 'default': None, - 'required': False, - 'type': 'str'}, - 'endpoint_ip': { 'default': None, - 'required': False, - 'type': 'str'}, - 'endpoint_ip_transport_port': { 'default': None, - 'required': False, - 'type': 'str'}, - 'interval': { 'default': None, - 'required': False, - 'type': 'int'}, - 'multiplier': { 'default': None, - 'required': False, - 'type': 'int'}, - 'name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'port': { 'default': None, - 'required': False, - 'type': 'int'}, - 'protocol': { 'default': None, - 'required': False, - 'type': 'str'}, - 'threshold': { 'default': None, - 'required': False, - 'type': 'int'}, - 'type': { 'default': 'interface', - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'transport_gateway': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'vrf': { 'default': None, - 'elements': 'dict', - 'options': { 'gateway_preference': { 'default': None, - 'elements': 'int', - 'required': False, - 'type': 'list'}, - 'vrf_id': { 'default': None, - 'required': True, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}}, - 'required': False, - 'type': 'dict'}} +cisco_system_definition = { + "cisco_system": { + "default": None, + "options": { + "admin_tech_on_failure": {"default": None, "required": False, "type": "bool"}, + "affinity_group_number": {"default": None, "required": False, "type": "int"}, + "affinity_per_vrf": { + "default": None, + "elements": "dict", + "options": { + "affinity_group_number": {"default": None, "required": False, "type": "int"}, + "vrf_range": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "console_baud_rate": {"default": None, "required": False, "type": "str"}, + "control_session_pps": {"default": None, "required": False, "type": "int"}, + "controller_group_list": {"default": None, "elements": "int", "required": False, "type": "list"}, + "description": {"default": None, "required": False, "type": "str"}, + "device_groups": {"default": None, "elements": "str", "required": False, "type": "list"}, + "enable_fencing": {"default": None, "required": False, "type": "bool"}, + "enable_management_region": {"default": None, "required": False, "type": "bool"}, + "enable_mrf_migration": {"default": None, "required": False, "type": "str"}, + "enable_sms": {"default": False, "required": False, "type": "bool"}, + "enable_tunnel": {"default": None, "required": False, "type": "bool"}, + "epfr": {"default": None, "required": False, "type": "str"}, + "hostname": { + "default": None, + "options": {"name": {"default": "system_host_name", "required": True, "type": "str"}}, + "required": False, + "type": "raw", + }, + "idle_timeout": {"default": None, "required": False, "type": "int"}, + "latitude": {"default": None, "required": False, "type": "str"}, + "location": {"default": None, "required": False, "type": "str"}, + "longitude": {"default": None, "required": False, "type": "str"}, + "management_gateway": {"default": None, "required": False, "type": "bool"}, + "max_omp_sessions": {"default": None, "required": False, "type": "int"}, + "migration_bgp_community": {"default": None, "required": False, "type": "int"}, + "mobile_number": { + "default": None, + "elements": "dict", + "options": {"number": {"default": None, "required": True, "type": "str"}}, + "required": False, + "type": "list", + }, + "multi_tenant": {"default": None, "required": False, "type": "bool"}, + "object_track": { + "default": None, + "elements": "dict", + "options": { + "boolean": {"default": None, "required": True, "type": "str"}, + "interface": {"default": None, "required": True, "type": "str"}, + "ip": {"default": None, "required": True, "type": "str"}, + "mask": {"default": "0.0.0.0", "required": False, "type": "str"}, + "object": { + "default": None, + "elements": "dict", + "options": {"number": {"default": None, "required": True, "type": "int"}}, + "required": True, + "type": "list", + }, + "object_number": {"default": None, "required": True, "type": "int"}, + "sig": {"default": None, "required": True, "type": "str"}, + "vpn": {"default": None, "required": True, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "on_demand_idle_timeout_min": {"default": None, "required": False, "type": "int"}, + "overlay_id": {"default": None, "required": False, "type": "int"}, + "port_hop": {"default": None, "required": False, "type": "bool"}, + "port_offset": {"default": None, "required": False, "type": "int"}, + "preference": {"default": None, "elements": "int", "required": False, "type": "list"}, + "preference_auto": {"default": None, "required": False, "type": "bool"}, + "range": {"default": None, "required": False, "type": "int"}, + "region_id": {"default": None, "required": False, "type": "int"}, + "role": {"default": None, "required": False, "type": "str"}, + "secondary_region": {"default": None, "required": False, "type": "int"}, + "site_id": {"default": "system_site_id", "required": False, "type": "int"}, + "site_type": {"default": None, "elements": "str", "required": False, "type": "list"}, + "system_ip": { + "default": None, + "options": {"name": {"default": "system_system_ip", "required": True, "type": "str"}}, + "required": False, + "type": "raw", + }, + "timezone": {"default": None, "required": False, "type": "str"}, + "track_default_gateway": {"default": None, "required": False, "type": "bool"}, + "track_interface_tag": {"default": None, "required": False, "type": "int"}, + "track_transport": {"default": None, "required": False, "type": "bool"}, + "tracker": { + "default": None, + "elements": "dict", + "options": { + "boolean": {"default": "or", "required": False, "type": "str"}, + "elements": {"default": None, "elements": "str", "required": False, "type": "list"}, + "endpoint_api_url": {"default": None, "required": False, "type": "str"}, + "endpoint_dns_name": {"default": None, "required": False, "type": "str"}, + "endpoint_ip": {"default": None, "required": False, "type": "str"}, + "endpoint_ip_transport_port": {"default": None, "required": False, "type": "str"}, + "interval": {"default": None, "required": False, "type": "int"}, + "multiplier": {"default": None, "required": False, "type": "int"}, + "name": {"default": None, "required": True, "type": "str"}, + "port": {"default": None, "required": False, "type": "int"}, + "protocol": {"default": None, "required": False, "type": "str"}, + "threshold": {"default": None, "required": False, "type": "int"}, + "type": {"default": "interface", "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "transport_gateway": {"default": None, "required": False, "type": "bool"}, + "vrf": { + "default": None, + "elements": "dict", + "options": { + "gateway_preference": {"default": None, "elements": "int", "required": False, "type": "list"}, + "vrf_id": {"default": None, "required": True, "type": "int"}, + }, + "required": False, + "type": "list", + }, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/system_vsmart.py b/plugins/module_utils/feature_templates/system_vsmart.py index 4605546..fa59be1 100644 --- a/plugins/module_utils/feature_templates/system_vsmart.py +++ b/plugins/module_utils/feature_templates/system_vsmart.py @@ -1,96 +1,74 @@ -system_vsmart_definition = { 'system_vsmart': { 'default': None, - 'options': { 'admin_tech_on_failure': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'compatible': { 'default': None, - 'options': { 'color_1': { 'default': None, - 'required': False, - 'type': 'str'}, - 'color_2': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'dict'}, - 'control_session_pps': { 'default': None, - 'required': False, - 'type': 'int'}, - 'controller_group_id': { 'default': None, - 'required': False, - 'type': 'int'}, - 'description': { 'default': None, - 'required': False, - 'type': 'str'}, - 'device_groups': { 'default': None, - 'required': False, - 'type': 'str'}, - 'dns_cache_timeout': { 'default': None, - 'required': False, - 'type': 'int'}, - 'dual_stack_ipv6': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'host_name': { 'default': None, - 'required': False, - 'type': 'str'}, - 'idle_timeout': { 'default': None, - 'required': False, - 'type': 'int'}, - 'incompatible': { 'default': None, - 'options': { 'color_1': { 'default': None, - 'required': False, - 'type': 'str'}, - 'color_2': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'dict'}, - 'iptables_enable': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'latitude': { 'default': None, - 'required': False, - 'type': 'int'}, - 'location': { 'default': None, - 'required': False, - 'type': 'str'}, - 'longitude': { 'default': None, - 'required': False, - 'type': 'int'}, - 'management_region': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'overlay_id': { 'default': None, - 'required': False, - 'type': 'int'}, - 'port_hop': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'port_offset': { 'default': None, - 'required': False, - 'type': 'int'}, - 'region_list_id': { 'default': None, - 'required': False, - 'type': 'int'}, - 'site_id': { 'default': None, - 'required': False, - 'type': 'int'}, - 'system_ip': { 'default': None, - 'required': False, - 'type': 'str'}, - 'system_tunnel_mtu': { 'default': None, - 'required': False, - 'type': 'str'}, - 'timezone': { 'default': None, - 'required': False, - 'type': 'str'}, - 'topology': { 'default': None, - 'required': False, - 'type': 'str'}, - 'track_default_gateway': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'track_transport': { 'default': None, - 'required': False, - 'type': 'bool'}}, - 'required': False, - 'type': 'dict'}} +system_vsmart_definition = { + "system_vsmart": { + "default": None, + "options": { + "admin_tech_on_failure": {"default": True, "required": False, "type": "bool"}, + "compatible": { + "default": None, + "elements": "dict", + "options": { + "color_1": {"default": None, "required": False, "type": "str"}, + "color_2": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "control_session_pps": {"default": None, "required": False, "type": "int"}, + "controller_group_id": {"default": None, "required": False, "type": "int"}, + "description": {"default": None, "required": False, "type": "str"}, + "device_groups": {"default": None, "elements": "str", "required": False, "type": "list"}, + "dns_cache_timeout": {"default": None, "required": False, "type": "int"}, + "dual_stack_ipv6": { + "default": None, + "options": {"name": {"default": "system_ipv6-strict-control", "required": True, "type": "str"}}, + "required": False, + "type": "raw", + }, + "host_name": { + "default": None, + "options": {"name": {"default": "system_host_name", "required": True, "type": "str"}}, + "required": False, + "type": "raw", + }, + "idle_timeout": {"default": None, "required": False, "type": "int"}, + "incompatible": { + "default": None, + "elements": "dict", + "options": { + "color_1": {"default": None, "required": False, "type": "str"}, + "color_2": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "iptables_enable": {"default": True, "required": False, "type": "bool"}, + "latitude": {"default": None, "required": False, "type": "int"}, + "location": {"default": None, "required": False, "type": "str"}, + "longitude": {"default": None, "required": False, "type": "int"}, + "management_region": {"default": None, "required": False, "type": "bool"}, + "overlay_id": {"default": None, "required": False, "type": "int"}, + "port_hop": {"default": None, "required": False, "type": "bool"}, + "port_offset": {"default": None, "required": False, "type": "int"}, + "region_list_id": {"default": None, "required": False, "type": "int"}, + "site_id": { + "default": None, + "options": {"name": {"default": "system_site_id", "required": True, "type": "str"}}, + "required": False, + "type": "raw", + }, + "system_ip": { + "default": None, + "options": {"name": {"default": "system_system_ip", "required": True, "type": "str"}}, + "required": False, + "type": "raw", + }, + "system_tunnel_mtu": {"default": None, "required": False, "type": "int"}, + "timezone": {"default": "UTC", "required": False, "type": "str"}, + "topology": {"default": None, "elements": "str", "required": False, "type": "list"}, + "track_default_gateway": {"default": True, "required": False, "type": "bool"}, + "track_transport": {"default": True, "required": False, "type": "bool"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/vpn_vsmart.py b/plugins/module_utils/feature_templates/vpn_vsmart.py new file mode 100644 index 0000000..a44cd60 --- /dev/null +++ b/plugins/module_utils/feature_templates/vpn_vsmart.py @@ -0,0 +1,93 @@ +vpn_vsmart_definition = { + "vpn_vsmart": { + "default": None, + "options": { + "dns": { + "default": None, + "elements": "dict", + "options": { + "dns_addr": {"default": None, "required": False, "type": "str"}, + "role": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "host": { + "default": None, + "elements": "dict", + "options": { + "hostname": {"default": None, "required": True, "type": "str"}, + "ip": {"default": None, "elements": "str", "required": True, "type": "list"}, + }, + "required": False, + "type": "list", + }, + "name": {"default": None, "required": False, "type": "str"}, + "route_v4": { + "default": None, + "elements": "dict", + "options": { + "distance": {"default": None, "required": False, "type": "int"}, + "next_hop": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": False, "type": "str"}, + "distance": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "null0": {"default": None, "required": False, "type": "bool"}, + "prefix": {"default": None, "required": False, "type": "str"}, + "route_interface": { + "default": None, + "options": { + "interface_name": {"default": None, "required": True, "type": "str"}, + "interface_next_hop": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": False, "type": "str"}, + "distance": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "list", + }, + }, + "required": False, + "type": "dict", + }, + "vpn": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "route_v6": { + "default": None, + "elements": "dict", + "options": { + "distance": {"default": None, "required": False, "type": "int"}, + "next_hop": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": True, "type": "str"}, + "distance": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "null0": {"default": None, "required": False, "type": "bool"}, + "prefix": {"default": None, "required": True, "type": "str"}, + "vpn": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "vpn_id": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/vpn_vsmart_interface.py b/plugins/module_utils/feature_templates/vpn_vsmart_interface.py new file mode 100644 index 0000000..9c600de --- /dev/null +++ b/plugins/module_utils/feature_templates/vpn_vsmart_interface.py @@ -0,0 +1,52 @@ +vpn_vsmart_interface_definition = { + "vpn_vsmart_interface": { + "default": None, + "options": { + "all": {"default": None, "required": False, "type": "bool"}, + "autonegotiate": {"default": True, "required": False, "type": "bool"}, + "carrier": {"default": None, "required": False, "type": "str"}, + "clear_dont_fragment": {"default": False, "required": False, "type": "bool"}, + "dhcp": {"default": None, "required": False, "type": "bool"}, + "dhcp_distance": {"default": None, "required": False, "type": "int"}, + "dhcp_ipv4_client": {"default": None, "required": False, "type": "bool"}, + "dhcp_ipv6_client": {"default": None, "required": False, "type": "bool"}, + "dhcp_ipv6_distance": {"default": None, "required": False, "type": "int"}, + "dhcp_rapid_commit": {"default": None, "required": False, "type": "bool"}, + "dns": {"default": None, "required": False, "type": "bool"}, + "duplex": {"default": None, "required": False, "type": "str"}, + "flow_control": {"default": None, "required": False, "type": "str"}, + "group": {"default": None, "elements": "int", "required": False, "type": "list"}, + "hello_interval": {"default": None, "required": False, "type": "int"}, + "hello_tolerance": {"default": None, "required": False, "type": "int"}, + "icmp": {"default": None, "required": False, "type": "bool"}, + "if_name": {"default": None, "required": False, "type": "str"}, + "interface_description": {"default": None, "required": False, "type": "str"}, + "ip": { + "default": None, + "elements": "dict", + "options": { + "addr": {"default": None, "required": True, "type": "str"}, + "mac": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "ipv4_address": {"default": None, "required": False, "type": "str"}, + "ipv6_address": {"default": None, "required": False, "type": "str"}, + "mac_address": {"default": None, "required": False, "type": "str"}, + "mtu": {"default": None, "required": False, "type": "int"}, + "nat_refresh_interval": {"default": None, "required": False, "type": "int"}, + "netconf": {"default": None, "required": False, "type": "bool"}, + "ntp": {"default": None, "required": False, "type": "bool"}, + "pmtu": {"default": False, "required": False, "type": "bool"}, + "shutdown": {"default": False, "required": False, "type": "bool"}, + "speed": {"default": None, "required": False, "type": "str"}, + "sshd": {"default": None, "required": False, "type": "bool"}, + "stun": {"default": None, "required": False, "type": "bool"}, + "tcp_mss_adjust": {"default": None, "required": False, "type": "int"}, + "value": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/modules/device_templates.py b/plugins/modules/device_templates.py index 1974279..a7f3c2b 100644 --- a/plugins/modules/device_templates.py +++ b/plugins/modules/device_templates.py @@ -41,13 +41,33 @@ general_templates: description: - List of names of Feature Templates to be included in Device Template - type: list - elements: str - required: false + required: false + default: null + type: list + elements: dict + suboptions: + name: + description: + - The name of the template + required: true + type: str + subtemplates: + description: + - List of names of the subtemplates to be attached to General template + required: false + default: null + type: list + elements: str hostname: description: - Hostname of the device to attach template. Available only for 0(state=attached). type: str + device_specific_vars: + description: + - For parameters in a feature template that you configure as device-specific, + when you attach a device template to a device, Cisco vManage prompts you for the values to use + for these parameters. + type: raw author: - Arkadiusz Cichon (acichon@cisco.com) extends_documentation_fragment: @@ -116,7 +136,7 @@ from typing import Dict, Literal, Optional, get_args -from catalystwan.api.template_api import DeviceTemplate +from catalystwan.api.template_api import DeviceTemplate, GeneralTemplate from catalystwan.dataclasses import Device, DeviceTemplateInfo from catalystwan.models.common import DeviceModel from catalystwan.session import ManagerHTTPError @@ -143,10 +163,19 @@ def run_module(): template_name=dict(type="str", required=True), template_description=dict(type="str", default=None), device_type=dict(type="str", aliases=["device_model"], choices=list(get_args(DeviceModel)), default=None), - device_role=dict(type="str", choices=["sdwan-edge", "service-node"], default=None), - general_templates=dict(type="list", elements="str", default=[]), + device_role=dict(type="str", choices=["sdwan-edge", "service-node"], default="sdwan-edge"), + general_templates=dict( + type="list", + elements="dict", + options=dict( + name=dict(type="str", required=True), + subtemplates=dict(type="list", elements="str", default=[]), + ), + default=[], + ), timeout_seconds=dict(type="int", default=300), hostname=dict(type="str"), + device_specific_vars=dict(type="list", elements="dict"), ) result = ExtendedModuleResult() @@ -193,12 +222,17 @@ def run_module(): f"Template with name {template_name} already present on vManage, skipping create template operation." ) else: + general_templates = [] + for template in module.params.get("general_templates"): + sub_templates = [GeneralTemplate(name=sub) for sub in template.get("subtemplates", [])] + general_templates.append(GeneralTemplate(name=template["name"], subTemplates=sub_templates)) + device_template = DeviceTemplate( template_name=template_name, template_description=module.params.get("template_description"), device_type=module.params.get("device_type"), device_role=module.params.get("device_role"), - general_templates=module.params.get("general_templates"), + general_templates=general_templates, ) module.logger.debug( @@ -222,13 +256,21 @@ def run_module(): if not device: module.fail_json(f"No devices with hostname found, hostname provided: {hostname}") try: - module.session.api.templates.attach( - name=template_name, device=device, timeout_seconds=module.params.get("timeout_seconds") + device_specific_vars = {k: v for d in module.params.get("device_specific_vars") for k, v in d.items()} + response = module.session.api.templates.attach( + name=template_name, + device=device, + device_specific_vars=device_specific_vars, + timeout_seconds=module.params.get("timeout_seconds"), ) + if not response: + module.fail_json(f"Failed to attach device template: {template_name}") result.changed = True result.msg = f"Attached template {template_name} to device: {hostname}" except ManagerHTTPError as ex: module.fail_json(msg=f"Could not perform attach Template {template_name}.\nManager error: {ex.info}") + except TypeError as ex: + module.fail_json(msg=f"{ex}") if module.params.get("state") == "absent": if target_template: diff --git a/plugins/modules/device_templates_info.py b/plugins/modules/device_templates_info.py index 1b16ab4..2aae397 100644 --- a/plugins/modules/device_templates_info.py +++ b/plugins/modules/device_templates_info.py @@ -105,6 +105,18 @@ required: false default: null type: str + backup: + description: + - This argument triggers the module to back up the filtered Device Templates. + Device Template backup is dumped json payload with template definition. + Without specified backup_dir_path, it saves to the playbook's root "backup" folder + or the role's root if within an Ansible role. The folder is created if it doesn't exist. + type: bool + default: false + backup_dir_path: + description: + - Directory to store the backup. It's created if missing. Defaults to a 'backup' folder in the current directory. + type: path author: - Arkadiusz Cichon (acichon@cisco.com) extends_documentation_fragment: @@ -155,32 +167,45 @@ returned: always sample: false """ - -from typing import Dict, Optional +import json +import traceback +from pathlib import Path, PurePath +from typing import Dict, List, Optional from catalystwan.api.template_api import DeviceTemplate from catalystwan.dataclasses import DeviceTemplateInfo +from catalystwan.session import ManagerHTTPError from catalystwan.typed_list import DataSequence from catalystwan.utils.creation_tools import asdict -from pydantic import Field +from pydantic import BaseModel, Field from ..module_utils.result import ModuleResult from ..module_utils.vmanage_module import AnsibleCatalystwanModule +class BackupPathModel(BaseModel): + hostname: str + filename: str + backup_path: str + + class ExtendedModuleResult(ModuleResult): templates_info: Optional[Dict] = Field(default={}) + backup_paths: Optional[List[BackupPathModel]] = Field(default=[]) def run_module(): module_args = dict( filters=dict(type="dict", default=None, required=False), + backup=dict(type=bool, default=False), + backup_dir_path=dict(type="path", default=PurePath(Path.cwd() / "backup")), ) result = ExtendedModuleResult() module = AnsibleCatalystwanModule(argument_spec=module_args) filters = module.params.get("filters") + filtered_templates = DataSequence(DeviceTemplate) all_templates: DataSequence[DeviceTemplateInfo] = module.get_response_safely( module.session.api.templates.get, template=DeviceTemplate @@ -199,6 +224,38 @@ def run_module(): result.msg = "Succesfully got all Device Templates Info from vManage" result.templates_info = [asdict(template) for template in all_templates] + if module.params.get("backup"): + backup_dir_path: Path = Path(module.params.get("backup_dir_path")) + module.logger.info(f"{backup_dir_path}") + try: + backup_dir_path.mkdir(parents=True, exist_ok=True) + except OSError as ex: + module.fail_json(msg=f"Cannot create or find directory: {backup_dir_path}, exception: {ex.strerror}") + + templates_to_backup = filtered_templates if filtered_templates else all_templates + if templates_to_backup: + for template in templates_to_backup: + try: + template_payload = module.session.get(f"dataservice/template/device/object/{template.id}").json() + except ManagerHTTPError as ex: + module.fail_json( + msg=( + f"Could not call get DeviceTemplate payload for template with name: {template.name}. " + f"\nManager error: {ex.info}" + ), + exception=traceback.format_exc(), + ) + filename = f"{template.name}.json" + backup_path = f"{backup_dir_path}/{filename}" + with open(backup_path, "w", encoding="utf-8") as file: + json.dump(template_payload, file, ensure_ascii=False, indent=4) + result.backup_paths.append( + BackupPathModel(hostname=template.name, backup_path=backup_path, filename=filename) + ) + result.msg = f"Succesfully saved Device Template payload to file: {backup_path}" + else: + module.module.warn(f"No Device Templates found based on filters: {filters}") + module.exit_json(**result.model_dump(mode="json")) diff --git a/plugins/modules/feature_templates.py b/plugins/modules/feature_templates.py index 55c76b4..0830b8f 100644 --- a/plugins/modules/feature_templates.py +++ b/plugins/modules/feature_templates.py @@ -42,6 +42,7 @@ type: bool default: false extends_documentation_fragment: + - cisco.catalystwan.feature_template_aaa - cisco.catalystwan.feature_template_cisco_aaa - cisco.catalystwan.feature_template_cisco_banner - cisco.catalystwan.feature_template_cisco_bfd @@ -57,6 +58,8 @@ - cisco.catalystwan.feature_template_omp_vsmart - cisco.catalystwan.feature_template_security_vsmart - cisco.catalystwan.feature_template_system_vsmart + - cisco.catalystwan.feature_template_vpn_vsmart_interface + - cisco.catalystwan.feature_template_vpn_vsmart - cisco.catalystwan.device_models_feature_template - cisco.catalystwan.manager_authentication author: @@ -75,6 +78,7 @@ from catalystwan.typed_list import DataSequence from pydantic import BaseModel, ConfigDict, Field +from ..module_utils.feature_templates.aaa import aaa_definition from ..module_utils.feature_templates.cisco_aaa import cisco_aaa_definition from ..module_utils.feature_templates.cisco_banner import cisco_banner_definition from ..module_utils.feature_templates.cisco_bfd import cisco_bfd_definition @@ -90,6 +94,8 @@ from ..module_utils.feature_templates.omp_vsmart import omp_vsmart_definition from ..module_utils.feature_templates.security_vsmart import security_vsmart_definition from ..module_utils.feature_templates.system_vsmart import system_vsmart_definition +from ..module_utils.feature_templates.vpn_vsmart import vpn_vsmart_definition +from ..module_utils.feature_templates.vpn_vsmart_interface import vpn_vsmart_interface_definition from ..module_utils.result import ModuleResult from ..module_utils.vmanage_module import AnsibleCatalystwanModule @@ -120,6 +126,7 @@ def run_module(): debug=dict(type="bool", default=False), device_specific_variables=dict(type="raw", default={}), # device=dict(type="str", default=None), # For this we need to think how to pass devices + **aaa_definition, **cisco_aaa_definition, **cisco_banner_definition, **cisco_bfd_definition, @@ -135,6 +142,8 @@ def run_module(): **omp_vsmart_definition, **security_vsmart_definition, **system_vsmart_definition, + **vpn_vsmart_definition, + **vpn_vsmart_interface_definition, ) result = ExtendedModuleResult() @@ -179,7 +188,6 @@ def run_module(): if module.params.get("state") == "present": # Code for checking if template name exists already - # if yes, do we need some force method or we just inform user and exit? if target_template: module.logger.debug(f"Detected existing template:\n{target_template}\n") result.msg = ( diff --git a/utils/ft_generator.py b/utils/ft_generator.py index 740c73e..502c12d 100644 --- a/utils/ft_generator.py +++ b/utils/ft_generator.py @@ -3,19 +3,18 @@ from __future__ import annotations -import yaml - from enum import Enum -from typing import Annotated, Type, Union, get_args, get_origin, Literal from pathlib import Path, PurePath from pprint import pformat -from jinja2 import Environment, FileSystemLoader -from pydantic import BaseModel -from pydantic.fields import FieldInfo +from typing import Annotated, Literal, Type, Union, get_args, get_origin -from catalystwan.api.templates.models.supported import available_models +import yaml from catalystwan.api.templates.device_variable import DeviceVariable +from catalystwan.api.templates.models.supported import available_models from catalystwan.models.common import DeviceModel +from jinja2 import Environment, FileSystemLoader +from pydantic import BaseModel +from pydantic.fields import FieldInfo PROJECT_ROOT_DIR = PurePath(Path.cwd()) @@ -63,6 +62,30 @@ def field_to_ansible_option(field: FieldInfo, field_name: str, model_name: str): elif field_type == int: option["type"] = "int" + elif field_type == DeviceVariable: + option["type"] = "raw" + option["suboptions"] = { + "name": { + "default": option["default"], + "required": True, + "type": "str", + "description": "Device Specific Variables name", + } + } + del option["default"] + + elif field_type == Union and DeviceVariable in args: + option["type"] = "raw" + option["suboptions"] = { + "name": { + "default": option["default"], + "required": True, + "type": "str", + "description": "Device Specific Variables name", + } + } + del option["default"] + elif is_pydantic_model(field_type): option["type"] = "dict" option["suboptions"] = model_to_ansible_options(field_type, model_name) @@ -70,7 +93,6 @@ def field_to_ansible_option(field: FieldInfo, field_name: str, model_name: str): elif field_type == list or (field_type == Union and list in subargs_base_types): elements_type = next((arg for arg in args if arg is not None), None) if is_pydantic_model(elements_type): - # from IPython import embed; embed() option["type"] = "list" option["elements"] = "dict" option["suboptions"] = model_to_ansible_options(elements_type, model_name) From 3d9d268cc91dc22e82bba418657e908c098011bf Mon Sep 17 00:00:00 2001 From: acichon Date: Tue, 23 Jul 2024 14:35:59 +0200 Subject: [PATCH 16/18] use newest SDK version --- .gitignore | 2 +- README.md | 22 ++---- ...est_backup_and_restore_running_config.yml} | 7 +- playbooks/tests/test_device_templates.yml | 48 +++++------- .../tests/test_device_templates_info.yml | 8 +- playbooks/tests/test_feature_templates.yml | 77 ++++++++----------- playbooks/tests/test_templates_attachment.yml | 57 ++++++++------ playbooks/tests/test_templates_removal.yml | 14 ++-- .../device_models_feature_template.py | 5 +- .../feature_template_cisco_aaa.py | 4 +- .../feature_template_cisco_banner.py | 4 +- .../feature_template_cisco_bfd.py | 4 +- .../feature_template_cisco_logging.py | 4 +- .../feature_template_cisco_ntp.py | 4 +- .../feature_template_cisco_omp.py | 4 +- .../feature_template_cisco_ospf.py | 4 +- ..._template_cisco_secure_internet_gateway.py | 4 +- .../feature_template_cisco_vpn.py | 4 +- .../feature_template_cisco_vpn_interface.py | 4 +- .../feature_template_omp_vsmart.py | 4 +- .../feature_template_security_vsmart.py | 4 +- plugins/module_utils/filters.py | 4 +- .../backup_restore_device_templates.py | 0 plugins/modules/cli_templates.py | 6 +- plugins/modules/device_templates.py | 32 +++++--- plugins/modules/device_templates_info.py | 11 ++- plugins/modules/feature_templates.py | 7 +- plugins/modules/feature_templates_info.py | 9 +-- pyproject.toml | 2 +- utils/ft_generator.py | 4 +- 30 files changed, 182 insertions(+), 181 deletions(-) rename playbooks/tests/{test_backup_and_restore.yml => test_backup_and_restore_running_config.yml} (88%) create mode 100644 plugins/modules/backup_restore_device_templates.py diff --git a/.gitignore b/.gitignore index 61cc87e..6160071 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,4 @@ playbooks/tests/ansible_catalystwan_module.log playbooks/tests/catalystwan.log playbooks/tests/payload* playbooks/tests/response* -playbooks/tests/backup/* +playbooks/tests/backup diff --git a/README.md b/README.md index 2f7377b..401d9fd 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,16 @@ # Ansible Collection - cisco.catalystwan -Initial repository for Ansible Collection using catalystwan library. +## Overview + +Reusable Ansible modules and roles that will help to automate Cisco +SD-WAN management (post bringup operations, day0, day1). -***NOTE: this repository is still in pre-release dev version** +All modules are based on [catalystwan](https://github.com/CiscoDevNet/catalystwan). + +Collection available on Ansible Galaxy: [cisco.catalystwan](https://galaxy.ansible.com/ui/repo/published/cisco/catalystwan/) ## Table of Contents -- [Overview](#overview) - [Roadmap](#roadmap) - [Requirements](#requirements) - [Installing this collection](#installing-this-collection) @@ -17,18 +21,6 @@ Initial repository for Ansible Collection using catalystwan library. --- -## Overview - -Reusable Ansible modules and roles that will help to automate Cisco -SD-WAN management (post bringup operations, day0, day1). - -All modules are based on [catalystwan](https://github.com/CiscoDevNet/catalystwan). Current installation available -via local Ansible Galaxy collection. - -Once finished, repository will be migrated to Cisco Open, and modules will be available via Ansible Galaxy. - ---- - ## Roadmap Support for the following workflows in vManage client and as Ansible modules: diff --git a/playbooks/tests/test_backup_and_restore.yml b/playbooks/tests/test_backup_and_restore_running_config.yml similarity index 88% rename from playbooks/tests/test_backup_and_restore.yml rename to playbooks/tests/test_backup_and_restore_running_config.yml index 5abeae1..267ab54 100644 --- a/playbooks/tests/test_backup_and_restore.yml +++ b/playbooks/tests/test_backup_and_restore_running_config.yml @@ -9,6 +9,11 @@ # --- Backup & Restore --- # +# 1. Backup running-config for all c8000V devices with default backup dir +# 2. Using backup files, create CLI templates for each Edge device +# 3. Attach backup templates to the Edge devices +# 4. Post-test - Set vManage mode for cEdge devices - in order to use previous templates + - name: Testing playbook to verify backup & restore operations hosts: localhost @@ -56,7 +61,7 @@ loop_var: device_item when: backup_info.backup_paths | length > 0 - - name: 4. Post-test - Set vManage mode for cEdge devices - not required + - name: 4. Post-test - Set vManage mode for cEdge devices - in order to use previous templates cisco.catalystwan.vmanage_mode: state: present hostnames: diff --git a/playbooks/tests/test_device_templates.yml b/playbooks/tests/test_device_templates.yml index 3211888..04ece5e 100644 --- a/playbooks/tests/test_device_templates.yml +++ b/playbooks/tests/test_device_templates.yml @@ -5,8 +5,6 @@ # Helper playbooks to test modules and flows while developing them -# Tested operations: - # --- Device Templates --- # @@ -21,7 +19,7 @@ username: "{{ (vmanage_instances | first).admin_username }}" password: "{{ (vmanage_instances | first).admin_password }}" tasks: - - name: Get all Non-Default Device Templates available + - name: 1. Get all Non-Default Device Templates available cisco.catalystwan.device_templates_info: filters: factory_default: false @@ -29,28 +27,24 @@ <<: *manager_authentication register: device_templates - - name: Debug Templates Info - ansible.builtin.debug: - msg: "{{ device_templates }}" - - # - name: Delete selected Device Template from vManage - # cisco.catalystwan.device_templates: - # state: absent - # template_name: "vc8000-device-template" - # manager_credentials: - # <<: *manager_authentication + - name: 2. Delete selected Device Template from vManage + cisco.catalystwan.device_templates: + state: absent + template_name: "vc8000-device-template" + manager_credentials: + <<: *manager_authentication - # - name: Create example Device Template with default templates - # cisco.catalystwan.device_templates: - # state: present - # template_name: "vc8000-device-template" - # template_description: "vc8000-device-template" - # device_type: vedge-C8000V - # device_role: sdwan-edge - # general_templates: - # - name: "Factory_Default_Cisco_BFD_Template" - # subtemplates: "Factory_Default_Cisco_Logging_Template" - # - name: "Factory_Default_Cisco_OMP_ipv46_Template" - # - name: "Factory_Default_Cisco_Security_Template" - # manager_credentials: - # <<: *manager_authentication + - name: 3. Create example Device Template with default templates + cisco.catalystwan.device_templates: + state: present + template_name: "vc8000-device-template" + template_description: "vc8000-device-template" + device_type: vedge-C8000V + device_role: sdwan-edge + general_templates: + - name: "Factory_Default_Cisco_BFD_Template" + subtemplates: "Factory_Default_Cisco_Logging_Template" + - name: "Factory_Default_Cisco_OMP_ipv46_Template" + - name: "Factory_Default_Cisco_Security_Template" + manager_credentials: + <<: *manager_authentication diff --git a/playbooks/tests/test_device_templates_info.yml b/playbooks/tests/test_device_templates_info.yml index b77c268..dff01bd 100644 --- a/playbooks/tests/test_device_templates_info.yml +++ b/playbooks/tests/test_device_templates_info.yml @@ -5,8 +5,6 @@ # Helper playbooks to test modules and flows while developing them -# Tested operations: - # --- Device Templates Info --- # @@ -21,7 +19,7 @@ username: "{{ (vmanage_instances | first).admin_username }}" password: "{{ (vmanage_instances | first).admin_password }}" tasks: - - name: Get all Non-Default Device Templates available + - name: 1. Get all Non-Default Device Templates available cisco.catalystwan.device_templates_info: filters: factory_default: false @@ -29,11 +27,11 @@ <<: *manager_authentication register: device_templates - - name: Debug Templates Info + - name: 2. Debug Templates Info ansible.builtin.debug: msg: "{{ device_templates }}" - - name: Backup all Non-Default Device Templates available + - name: 3. Backup all Non-Default Device Templates available cisco.catalystwan.device_templates_info: filters: factory_default: false diff --git a/playbooks/tests/test_feature_templates.yml b/playbooks/tests/test_feature_templates.yml index c31c9fd..77aa28e 100644 --- a/playbooks/tests/test_feature_templates.yml +++ b/playbooks/tests/test_feature_templates.yml @@ -21,7 +21,7 @@ username: "{{ (vmanage_instances | first).admin_username }}" password: "{{ (vmanage_instances | first).admin_password }}" tasks: - - name: Get all Non-Default Feature Templates available + - name: 1. Get all Non-Default Feature Templates available cisco.catalystwan.feature_templates_info: filters: factory_default: false @@ -29,25 +29,24 @@ <<: *manager_authentication register: feature_templates - - name: Delete all Non-Default Feature templates + - name: 2. Delete all Non-Default Feature templates cisco.catalystwan.feature_templates: state: absent - template_name: "{{ template.templateName }}" + template_name: "{{ template.name }}" manager_credentials: <<: *manager_authentication loop: "{{ feature_templates.templates_info | default([], true) }}" loop_control: loop_var: template - label: "template: {{ template.templateName }}" + label: "template: {{ template.name }}" # vedge-C8000V templates - - name: "Create Comprehensive AAA Template with TACACS+ and RADIUS" + - name: 2. Create Comprehensive AAA Template with TACACS+ and RADIUS cisco.catalystwan.feature_templates: state: present template_name: "ComprehensiveAAATemplate" template_description: "AAA Template with both TACACS+ and RADIUS servers" - debug: true device_models: - vedge-C8000V cisco_aaa: @@ -114,12 +113,11 @@ manager_credentials: <<: *manager_authentication - - name: Create Cisco Banner Feature Template + - name: 3. Create Cisco Banner Feature Template cisco.catalystwan.feature_templates: state: present template_name: "CiscoBannerConfigTemplate" template_description: "Banner configuration for login and MOTD" - debug: true device_models: - "vedge-C8000V" cisco_banner: @@ -142,12 +140,11 @@ manager_credentials: <<: *manager_authentication - - name: Create Cisco BFD Feature Template + - name: 4. Create Cisco BFD Feature Template cisco.catalystwan.feature_templates: state: present template_name: "CiscoBFDFeatureTemplate" template_description: "Comprehensive BFD configuration" - debug: true device_models: - "vedge-C8000V" cisco_bfd: @@ -178,12 +175,11 @@ manager_credentials: <<: *manager_authentication - - name: Configure Cisco Logging Feature Template + - name: 5. Configure Cisco Logging Feature Template cisco.catalystwan.feature_templates: state: present template_name: "CiscoLoggingFeatureTemplate" template_description: "Comprehensive Logging Configuration" - debug: true device_models: - "vedge-C8000V" cisco_logging: @@ -232,12 +228,11 @@ manager_credentials: <<: *manager_authentication - - name: Configure Cisco NTP Feature Template + - name: 6. Configure Cisco NTP Feature Template cisco.catalystwan.feature_templates: state: present template_name: "CiscoNTPFeatureTemplate" template_description: "Comprehensive NTP Configuration" - debug: true device_models: - "vedge-C8000V" cisco_ntp: @@ -268,12 +263,11 @@ manager_credentials: <<: *manager_authentication - - name: Configure Cisco OMP Feature Template + - name: 7. Configure Cisco OMP Feature Template cisco.catalystwan.feature_templates: state: present template_name: "CiscoOMPFeatureTemplate" template_description: "Comprehensive OMP Configuration" - debug: true device_models: - "vsmart" cisco_omp: @@ -313,12 +307,11 @@ manager_credentials: <<: *manager_authentication - - name: Configure Cisco OSPF Feature Template + - name: 8. Configure Cisco OSPF Feature Template cisco.catalystwan.feature_templates: state: present template_name: "CiscoOSPFeatureTemplate" template_description: "Comprehensive OSPF Configuration" - debug: true device_models: - "vedge-C8000V" cisco_ospf: @@ -371,12 +364,11 @@ manager_credentials: <<: *manager_authentication - - name: "Configure Secure Internet Gateway feature template" + - name: 9. Configure Secure Internet Gateway feature template cisco.catalystwan.feature_templates: state: present template_name: "CiscoSecureInternetGatewayFeatureTemplate" template_description: "Comprehensive CiscoSecureInternetGateway Configuration" - debug: true device_models: - "vedge-C8000V" cisco_secure_internet_gateway: @@ -451,11 +443,10 @@ manager_credentials: <<: *manager_authentication - - name: "Configure Cisco SNMP feature template" + - name: 10. Configure Cisco SNMP feature template cisco.catalystwan.feature_templates: state: present template_name: "CiscoSNMPFeatureTemplate" - debug: true template_description: "Comprehensive Cisco SNMP Configuration" cisco_snmp: shutdown: false @@ -500,12 +491,11 @@ manager_credentials: <<: *manager_authentication - - name: "Create Comprehensive Cisco System Template" + - name: 11. Create Comprehensive Cisco System Template cisco.catalystwan.feature_templates: state: present template_name: "ComprehensiveCiscoSystemTemplate" template_description: "Cisco System template" - debug: true device_models: - "vedge-C8000V" cisco_system: @@ -616,12 +606,11 @@ manager_credentials: <<: *manager_authentication - - name: "Create Comprehensive Cisco VPN Interface Template" + - name: 12. Create Comprehensive Cisco VPN Interface Template cisco.catalystwan.feature_templates: state: present template_name: "ComprehensiveCiscoVPNInterfaceTemplate" template_description: "Cisco VPN Interface template" - debug: true device_models: - "vedge-C8000V" cisco_vpn_interface: @@ -803,12 +792,11 @@ manager_credentials: <<: *manager_authentication - - name: "Create Comprehensive Cisco VPN Template" + - name: 13. Create Comprehensive Cisco VPN Template cisco.catalystwan.feature_templates: state: present template_name: "ComprehensiveCiscoVPNTemplate" template_description: "Cisco VPN template" - debug: true device_models: - "vedge-C8000V" cisco_vpn: @@ -964,12 +952,11 @@ manager_credentials: <<: *manager_authentication - - name: "Create Comprehensive OMP vSmart Template" + - name: 14. Create Comprehensive OMP vSmart Template cisco.catalystwan.feature_templates: state: present template_name: "OMPvSmartConfigTemplate" template_description: "Apply OMP settings for vSmart controller" - debug: true device_models: "vsmart" omp_vsmart: graceful_restart: true @@ -986,12 +973,11 @@ manager_credentials: <<: *manager_authentication - - name: "Create Comprehensive Security vSmart Template" + - name: 15. Create Comprehensive Security vSmart Template cisco.catalystwan.feature_templates: state: present template_name: "SecurityvSmartConfigTemplate" template_description: "Apply Security settings for vSmart controller" - debug: true device_models: vsmart security_vsmart: protocol: dtls @@ -999,14 +985,20 @@ manager_credentials: <<: *manager_authentication - - name: "Create Comprehensive System vSmart Template" + - name: 16. Create Comprehensive System vSmart Template cisco.catalystwan.feature_templates: state: present template_name: "SystemvSmartConfigTemplate" template_description: "Apply System settings for vSmart controller" - debug: true device_models: vsmart + device_specific_variables: + site_id: "side_id_variable" + host_name: "host_name_variable" + system_ip: "system_ip_variable" system_vsmart: + host_name: device_specific_variable + site_id: device_specific_variable + system_ip: device_specific_variable timezone: UTC idle_timeout: 100 admin_tech_on_failure: true @@ -1019,25 +1011,23 @@ port_hop: true port_offset: 5 overlay_id: 44 - site_id: 500 - system_ip: "192.168.1.1" device_groups: "example1,example2" latitude: "37" longitude: "-122" - system_tunnel_mtu: "example_mtu_size" + system_tunnel_mtu: 1024 location: "Location" - host_name: "myhostname" dual_stack_ipv6: true description: "Example description" - topology: "Hub and Spoke" + topology: + - "hub-and-spoke" region_list_id: 12 management_region: true compatible: - color_1: mpls - color_2: metro-ethernet + - color_1: mpls + color_2: metro-ethernet incompatible: - color_1: biz-internet - color_2: public-internet + - color_1: biz-internet + color_2: public-internet manager_credentials: <<: *manager_authentication @@ -1047,7 +1037,6 @@ state: present template_name: "CiscoBannerConfigTemplateDSV" template_description: "Banner configuration for login and MOTD with DSV" - debug: true device_specific_variables: login_banner: "var_name_1" motd_banner: "var_name_2" diff --git a/playbooks/tests/test_templates_attachment.yml b/playbooks/tests/test_templates_attachment.yml index 88e8495..1083a56 100644 --- a/playbooks/tests/test_templates_attachment.yml +++ b/playbooks/tests/test_templates_attachment.yml @@ -3,11 +3,26 @@ --- +# --- Device Templates attachment - created from Feature Templates--- # + # Helper playbooks to test modules and flows while developing them # Tested operations: -# --- Device Templates attachment - created from Feature Templates--- # +# 1. Get all Device Templates that are not attached to any device +# 2. Delete selected Device Templates from vManage +# 3. Backup running-config from devices, store in default backup dir (in CWD) +# 4. Using backup files, create CLI templates for each device available +# 5. Get all Non-Default Feature Templates available +# 6. Delete all Non-Default Feature templates +# 7. Create AAA Template for vSmart devices +# 8. Create System Template for vSmart devices +# 9. Create VPN template for vSmart devices - VPN 0 +# 10. Create VPN template for vSmart devices - VPN 512 +# 11. Create VPN Interface template for vSmart devices - VPN 0 +# 12. Create VPN Interface template for vSmart devices - VPN 512 +# 13. Create example Device Template for vSmart +# 14. Attach example Device Template for vSmart - name: Testing playbook to verify cisco.catalystwan.device_templates module operations @@ -21,7 +36,7 @@ username: "{{ (vmanage_instances | first).admin_username }}" password: "{{ (vmanage_instances | first).admin_password }}" tasks: - - name: Get all Device Templates that are not attached to any device + - name: 1. Get all Device Templates that are not attached to any device cisco.catalystwan.device_templates_info: filters: devices_attached: 0 @@ -30,14 +45,10 @@ <<: *manager_authentication register: device_templates - - name: Debug Templates Info - ansible.builtin.debug: - msg: "{{ device_templates.templates_info }}" - - - name: Delete selected Device Templates from vManage + - name: 2. Delete selected Device Templates from vManage cisco.catalystwan.device_templates: state: absent - template_name: "{{ device_template.templateName }}" + template_name: "{{ device_template.name }}" manager_credentials: <<: *manager_authentication loop: "{{ device_templates.templates_info | default([], True) }}" @@ -45,14 +56,14 @@ loop_var: device_template when: device_templates.templates_info | length > 0 - - name: Backup running-config from devices, store in default backup dir (in CWD) + - name: 3. Backup running-config from devices, store in default backup dir (in CWD) cisco.catalystwan.devices_info: backup: true manager_credentials: <<: *manager_authentication register: backup_info - - name: Using backup files, create CLI templates for each device available + - name: 4. Using backup files, create CLI templates for each device available cisco.catalystwan.cli_templates: state: present template_name: "backup-template-{{ device_item.filename }}" @@ -68,7 +79,7 @@ loop_var: device_item when: backup_info.backup_paths | length > 0 - - name: Get all Non-Default Feature Templates available + - name: 5. Get all Non-Default Feature Templates available cisco.catalystwan.feature_templates_info: filters: factory_default: false @@ -77,21 +88,21 @@ <<: *manager_authentication register: feature_templates - - name: Delete all Non-Default Feature templates + - name: 6. Delete all Non-Default Feature templates cisco.catalystwan.feature_templates: state: absent - template_name: "{{ template.templateName }}" + template_name: "{{ template.name }}" manager_credentials: <<: *manager_authentication loop: "{{ feature_templates.templates_info | default([], true) }}" loop_control: loop_var: template - label: "template: {{ template.templateName }}" + label: "template: {{ template.name }}" # Create now all Feature Templates that are necessary to form minimal Device Template, and attach this template # These will be applicable for vSmart devices - - name: Create AAA Template for vSmart devices + - name: 7. Create AAA Template for vSmart devices cisco.catalystwan.feature_templates: state: present template_name: "AAA_for_vSmart" @@ -136,7 +147,7 @@ manager_credentials: <<: *manager_authentication - - name: Create System Template for vSmart devices + - name: 8. Create System Template for vSmart devices cisco.catalystwan.feature_templates: state: present template_name: "System_for_vSmart" @@ -151,7 +162,7 @@ <<: *manager_authentication # Now for vpn and vpn interfaces, and then attach device template with device specific variables - - name: Create VPN template for vSmart devices - VPN 0 + - name: 9. Create VPN template for vSmart devices - VPN 0 cisco.catalystwan.feature_templates: state: present template_name: "VPN_0_for_vSmart" @@ -163,7 +174,7 @@ manager_credentials: <<: *manager_authentication - - name: Create VPN template for vSmart devices - VPN 512 + - name: 10. Create VPN template for vSmart devices - VPN 512 cisco.catalystwan.feature_templates: state: present template_name: "VPN_512_for_vSmart" @@ -175,7 +186,7 @@ manager_credentials: <<: *manager_authentication - - name: Create VPN Interface template for vSmart devices - VPN 0 + - name: 11. Create VPN Interface template for vSmart devices - VPN 0 cisco.catalystwan.feature_templates: state: present template_name: "VPN_0_Interface_for_vSmart" @@ -196,7 +207,7 @@ manager_credentials: <<: *manager_authentication - - name: Create VPN Interface template for vSmart devices - VPN 512 + - name: 12. Create VPN Interface template for vSmart devices - VPN 512 cisco.catalystwan.feature_templates: state: present template_name: "VPN_512_Interface_for_vSmart" @@ -210,7 +221,7 @@ manager_credentials: <<: *manager_authentication - - name: Create example Device Template for vSmart + - name: 13. Create example Device Template for vSmart cisco.catalystwan.device_templates: state: present template_name: "vSmart-test-device-template" @@ -232,10 +243,10 @@ manager_credentials: <<: *manager_authentication - - name: Attach example Device Template for vSmart + - name: 14. Attach example Device Template for vSmart cisco.catalystwan.device_templates: state: attached - template_name: "second_vSmart-test-device-template" + template_name: "vSmart-test-device-template" device_type: vsmart hostname: "acich-rg-vSmart" device_specific_vars: diff --git a/playbooks/tests/test_templates_removal.yml b/playbooks/tests/test_templates_removal.yml index c4d3c6e..ed1af14 100644 --- a/playbooks/tests/test_templates_removal.yml +++ b/playbooks/tests/test_templates_removal.yml @@ -19,7 +19,7 @@ username: "{{ (vmanage_instances | first).admin_username }}" password: "{{ (vmanage_instances | first).admin_password }}" tasks: - - name: Get all Device Templates that are not attached to any device + - name: 1. Get all Device Templates that are not attached to any device cisco.catalystwan.device_templates_info: filters: devices_attached: 0 @@ -28,10 +28,10 @@ <<: *manager_authentication register: device_templates - - name: Delete selected Device Templates from vManage + - name: 2. Delete selected Device Templates from vManage cisco.catalystwan.device_templates: state: absent - template_name: "{{ device_template.templateName }}" + template_name: "{{ device_template.name }}" manager_credentials: <<: *manager_authentication loop: "{{ device_templates.templates_info | default([], True) }}" @@ -39,7 +39,7 @@ loop_var: device_template when: device_templates.templates_info | length > 0 - - name: Get all Non-Default Feature Templates available + - name: 3. Get all Non-Default Feature Templates available cisco.catalystwan.feature_templates_info: filters: factory_default: false @@ -48,13 +48,13 @@ <<: *manager_authentication register: feature_templates - - name: Delete all Non-Default Feature templates + - name: 4. Delete all Non-Default Feature templates cisco.catalystwan.feature_templates: state: absent - template_name: "{{ template.templateName }}" + template_name: "{{ template.name }}" manager_credentials: <<: *manager_authentication loop: "{{ feature_templates.templates_info | default([], true) }}" loop_control: loop_var: template - label: "template: {{ template.templateName }}" + label: "template: {{ template.name }}" diff --git a/plugins/doc_fragments/device_models_feature_template.py b/plugins/doc_fragments/device_models_feature_template.py index 1102418..f9ff45d 100644 --- a/plugins/doc_fragments/device_models_feature_template.py +++ b/plugins/doc_fragments/device_models_feature_template.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r''' + DOCUMENTATION = r""" options: device_models: description: @@ -20,6 +20,7 @@ class ModuleDocFragment(object): default: [] elements: str choices: + - "None" - "vsmart" - "vedge-cloud" - "vmanage" @@ -84,4 +85,4 @@ class ModuleDocFragment(object): - "vedge-C8200-1N-4T" - "vedge-C8200L-1N-4T" - "vedge-ISRv" - ''' \ No newline at end of file + """ diff --git a/plugins/doc_fragments/feature_template_cisco_aaa.py b/plugins/doc_fragments/feature_template_cisco_aaa.py index 0deb19f..0d1ed35 100644 --- a/plugins/doc_fragments/feature_template_cisco_aaa.py +++ b/plugins/doc_fragments/feature_template_cisco_aaa.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r''' + DOCUMENTATION = r""" options: cisco_aaa: description: Cisco AAA Feature Template configuration @@ -430,4 +430,4 @@ class ModuleDocFragment(object): required: false default: null type: str - ''' \ No newline at end of file + """ diff --git a/plugins/doc_fragments/feature_template_cisco_banner.py b/plugins/doc_fragments/feature_template_cisco_banner.py index c8586f2..458aea4 100644 --- a/plugins/doc_fragments/feature_template_cisco_banner.py +++ b/plugins/doc_fragments/feature_template_cisco_banner.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r''' + DOCUMENTATION = r""" options: cisco_banner: description: Cisco Banner configuration for login and message of the day (MOTD) @@ -30,4 +30,4 @@ class ModuleDocFragment(object): required: false default: null type: str - ''' \ No newline at end of file + """ diff --git a/plugins/doc_fragments/feature_template_cisco_bfd.py b/plugins/doc_fragments/feature_template_cisco_bfd.py index 09dcc63..4c7867c 100644 --- a/plugins/doc_fragments/feature_template_cisco_bfd.py +++ b/plugins/doc_fragments/feature_template_cisco_bfd.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r''' + DOCUMENTATION = r""" options: cisco_bfd: description: Cisco Bidirectional Forwarding Detection (BFD) configuration @@ -97,4 +97,4 @@ class ModuleDocFragment(object): required: false default: null type: int - ''' \ No newline at end of file + """ diff --git a/plugins/doc_fragments/feature_template_cisco_logging.py b/plugins/doc_fragments/feature_template_cisco_logging.py index 43ea554..47434cb 100644 --- a/plugins/doc_fragments/feature_template_cisco_logging.py +++ b/plugins/doc_fragments/feature_template_cisco_logging.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r''' + DOCUMENTATION = r""" options: cisco_logging: description: Cisco Logging Feature Template configuration @@ -192,4 +192,4 @@ class ModuleDocFragment(object): required: false default: null type: str - ''' \ No newline at end of file + """ diff --git a/plugins/doc_fragments/feature_template_cisco_ntp.py b/plugins/doc_fragments/feature_template_cisco_ntp.py index 4f11a99..dc662a9 100644 --- a/plugins/doc_fragments/feature_template_cisco_ntp.py +++ b/plugins/doc_fragments/feature_template_cisco_ntp.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r''' + DOCUMENTATION = r""" options: cisco_ntp: description: Cisco NTP Feature Template configuration @@ -106,4 +106,4 @@ class ModuleDocFragment(object): required: false default: null type: str - ''' \ No newline at end of file + """ diff --git a/plugins/doc_fragments/feature_template_cisco_omp.py b/plugins/doc_fragments/feature_template_cisco_omp.py index 42b8cb5..3024d07 100644 --- a/plugins/doc_fragments/feature_template_cisco_omp.py +++ b/plugins/doc_fragments/feature_template_cisco_omp.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r''' + DOCUMENTATION = r""" options: cisco_omp: description: Configuration settings for the Cisco Overlay Management Protocol @@ -177,4 +177,4 @@ class ModuleDocFragment(object): required: false default: false type: bool - ''' \ No newline at end of file + """ diff --git a/plugins/doc_fragments/feature_template_cisco_ospf.py b/plugins/doc_fragments/feature_template_cisco_ospf.py index 3112ac6..e56b9b8 100644 --- a/plugins/doc_fragments/feature_template_cisco_ospf.py +++ b/plugins/doc_fragments/feature_template_cisco_ospf.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r''' + DOCUMENTATION = r""" options: cisco_ospf: description: Cisco OSPF (Open Shortest Path First) configuration @@ -322,4 +322,4 @@ class ModuleDocFragment(object): required: false default: false type: bool - ''' \ No newline at end of file + """ diff --git a/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py b/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py index 797b085..f93c7cc 100644 --- a/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py +++ b/plugins/doc_fragments/feature_template_cisco_secure_internet_gateway.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r''' + DOCUMENTATION = r""" options: cisco_secure_internet_gateway: description: Cisco Secure Internet Gateway feature template configuration @@ -506,4 +506,4 @@ class ModuleDocFragment(object): type: str choices: - SIG - ''' \ No newline at end of file + """ diff --git a/plugins/doc_fragments/feature_template_cisco_vpn.py b/plugins/doc_fragments/feature_template_cisco_vpn.py index 51be8ed..29dc1a0 100644 --- a/plugins/doc_fragments/feature_template_cisco_vpn.py +++ b/plugins/doc_fragments/feature_template_cisco_vpn.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r''' + DOCUMENTATION = r""" options: cisco_vpn: description: Cisco VPN Feature Template configuration. @@ -1024,4 +1024,4 @@ class ModuleDocFragment(object): required: false default: null type: str - ''' \ No newline at end of file + """ diff --git a/plugins/doc_fragments/feature_template_cisco_vpn_interface.py b/plugins/doc_fragments/feature_template_cisco_vpn_interface.py index 9d15008..792a08e 100644 --- a/plugins/doc_fragments/feature_template_cisco_vpn_interface.py +++ b/plugins/doc_fragments/feature_template_cisco_vpn_interface.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r''' + DOCUMENTATION = r""" options: cisco_vpn_interface: description: Cisco VPN Interface Feature Template configuration @@ -1176,4 +1176,4 @@ class ModuleDocFragment(object): required: false default: null type: int - ''' \ No newline at end of file + """ diff --git a/plugins/doc_fragments/feature_template_omp_vsmart.py b/plugins/doc_fragments/feature_template_omp_vsmart.py index c39d280..73a48e3 100644 --- a/plugins/doc_fragments/feature_template_omp_vsmart.py +++ b/plugins/doc_fragments/feature_template_omp_vsmart.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r''' + DOCUMENTATION = r""" options: omp_vsmart: description: Overlay Management Protocol (OMP) settings for vSmart controller @@ -84,4 +84,4 @@ class ModuleDocFragment(object): required: false default: false type: bool - ''' \ No newline at end of file + """ diff --git a/plugins/doc_fragments/feature_template_security_vsmart.py b/plugins/doc_fragments/feature_template_security_vsmart.py index 6093535..20a6182 100644 --- a/plugins/doc_fragments/feature_template_security_vsmart.py +++ b/plugins/doc_fragments/feature_template_security_vsmart.py @@ -11,7 +11,7 @@ class ModuleDocFragment(object): - DOCUMENTATION = r''' + DOCUMENTATION = r""" options: security_vsmart: description: Security settings for vSmart controller @@ -32,4 +32,4 @@ class ModuleDocFragment(object): required: false default: null type: int - ''' \ No newline at end of file + """ diff --git a/plugins/module_utils/filters.py b/plugins/module_utils/filters.py index 0e8b934..2809c9d 100644 --- a/plugins/module_utils/filters.py +++ b/plugins/module_utils/filters.py @@ -3,7 +3,7 @@ import traceback -from catalystwan.endpoints.configuration_device_inventory import DeviceCategory, DeviceDetailsResponse +from catalystwan.endpoints.configuration_device_inventory import DeviceDetailsResponse from catalystwan.session import ManagerHTTPError from catalystwan.typed_list import DataSequence @@ -12,7 +12,7 @@ def get_target_device( module: AnsibleCatalystwanModule, - device_category: DeviceCategory = "all", + device_category="all", all_from_category: bool = False, ) -> DataSequence[DeviceDetailsResponse]: """ diff --git a/plugins/modules/backup_restore_device_templates.py b/plugins/modules/backup_restore_device_templates.py new file mode 100644 index 0000000..e69de29 diff --git a/plugins/modules/cli_templates.py b/plugins/modules/cli_templates.py index d0bb11b..99b7314 100644 --- a/plugins/modules/cli_templates.py +++ b/plugins/modules/cli_templates.py @@ -84,8 +84,8 @@ from typing import Literal, get_args from catalystwan.api.template_api import CLITemplate -from catalystwan.dataclasses import DeviceTemplateInfo from catalystwan.models.common import DeviceModel +from catalystwan.models.templates import DeviceTemplateInformation from catalystwan.session import ManagerHTTPError from catalystwan.typed_list import DataSequence @@ -131,10 +131,10 @@ def run_module(): template_name = module.params.get("template_name") - all_templates: DataSequence[DeviceTemplateInfo] = module.get_response_safely( + all_templates: DataSequence[DeviceTemplateInformation] = module.get_response_safely( module.session.api.templates.get, template=CLITemplate ) - target_template: DeviceTemplateInfo = all_templates.filter(name=template_name) + target_template: DeviceTemplateInformation = all_templates.filter(name=template_name) if module.params.get("state") == "present": # Code for checking if template name exists already diff --git a/plugins/modules/device_templates.py b/plugins/modules/device_templates.py index a7f3c2b..c23000c 100644 --- a/plugins/modules/device_templates.py +++ b/plugins/modules/device_templates.py @@ -137,8 +137,10 @@ from typing import Dict, Literal, Optional, get_args from catalystwan.api.template_api import DeviceTemplate, GeneralTemplate -from catalystwan.dataclasses import Device, DeviceTemplateInfo +from catalystwan.dataclasses import Device +from catalystwan.exceptions import TemplateNotFoundError from catalystwan.models.common import DeviceModel +from catalystwan.models.templates import DeviceTemplateInformation from catalystwan.session import ManagerHTTPError from catalystwan.typed_list import DataSequence from pydantic import Field @@ -209,10 +211,10 @@ def run_module(): template_name = module.params.get("template_name") - all_templates: DataSequence[DeviceTemplateInfo] = module.get_response_safely( + all_templates: DataSequence[DeviceTemplateInformation] = module.get_response_safely( module.session.api.templates.get, template=DeviceTemplate ) - target_template: DeviceTemplateInfo = all_templates.filter(name=template_name) + target_template: Optional[DeviceTemplateInformation] = all_templates.filter(name=template_name) if module.params.get("state") == "present": # Code for checking if template name exists already @@ -256,19 +258,29 @@ def run_module(): if not device: module.fail_json(f"No devices with hostname found, hostname provided: {hostname}") try: - device_specific_vars = {k: v for d in module.params.get("device_specific_vars") for k, v in d.items()} - response = module.session.api.templates.attach( - name=template_name, - device=device, - device_specific_vars=device_specific_vars, - timeout_seconds=module.params.get("timeout_seconds"), - ) + response = None + if module.params.get("device_specific_vars"): + device_specific_vars = {k: v for d in module.params.get("device_specific_vars") for k, v in d.items()} + response = module.session.api.templates.attach( + name=template_name, + device=device, + device_specific_vars=device_specific_vars, + timeout_seconds=module.params.get("timeout_seconds"), + ) + else: + response = module.session.api.templates.attach( + name=template_name, + device=device, + timeout_seconds=module.params.get("timeout_seconds"), + ) if not response: module.fail_json(f"Failed to attach device template: {template_name}") result.changed = True result.msg = f"Attached template {template_name} to device: {hostname}" except ManagerHTTPError as ex: module.fail_json(msg=f"Could not perform attach Template {template_name}.\nManager error: {ex.info}") + except TemplateNotFoundError as ex: + module.fail_json(msg=f"Template with name: {template_name} doesn't exist. \nOriginal error: {ex}") except TypeError as ex: module.fail_json(msg=f"{ex}") diff --git a/plugins/modules/device_templates_info.py b/plugins/modules/device_templates_info.py index 2aae397..a2498b0 100644 --- a/plugins/modules/device_templates_info.py +++ b/plugins/modules/device_templates_info.py @@ -173,10 +173,9 @@ from typing import Dict, List, Optional from catalystwan.api.template_api import DeviceTemplate -from catalystwan.dataclasses import DeviceTemplateInfo +from catalystwan.models.templates import DeviceTemplateInformation from catalystwan.session import ManagerHTTPError from catalystwan.typed_list import DataSequence -from catalystwan.utils.creation_tools import asdict from pydantic import BaseModel, Field from ..module_utils.result import ModuleResult @@ -205,9 +204,9 @@ def run_module(): module = AnsibleCatalystwanModule(argument_spec=module_args) filters = module.params.get("filters") - filtered_templates = DataSequence(DeviceTemplate) + filtered_templates = DataSequence(DeviceTemplateInformation) - all_templates: DataSequence[DeviceTemplateInfo] = module.get_response_safely( + all_templates: DataSequence[DeviceTemplateInformation] = module.get_response_safely( module.session.api.templates.get, template=DeviceTemplate ) @@ -216,13 +215,13 @@ def run_module(): if filtered_templates: module.logger.info(f"All Device Templates filtered with filters: {filters}:\n{filtered_templates}") result.msg = "Succesfully got all requested Device Templates Info from vManage" - result.templates_info = [asdict(template) for template in filtered_templates] + result.templates_info = [template for template in filtered_templates] else: module.logger.warning(msg=f"Device templates filtered with `{filters}` not present.") result.msg = f"Device templates filtered with `{filters}` not present on vManage." else: result.msg = "Succesfully got all Device Templates Info from vManage" - result.templates_info = [asdict(template) for template in all_templates] + result.templates_info = [template for template in all_templates] if module.params.get("backup"): backup_dir_path: Path = Path(module.params.get("backup_dir_path")) diff --git a/plugins/modules/feature_templates.py b/plugins/modules/feature_templates.py index 0830b8f..51104d3 100644 --- a/plugins/modules/feature_templates.py +++ b/plugins/modules/feature_templates.py @@ -72,8 +72,8 @@ from catalystwan.api.template_api import FeatureTemplate from catalystwan.api.templates.device_variable import DeviceVariable from catalystwan.api.templates.models.supported import available_models -from catalystwan.dataclasses import FeatureTemplateInfo from catalystwan.models.common import DeviceModel +from catalystwan.models.templates import FeatureTemplateInformation from catalystwan.session import ManagerHTTPError from catalystwan.typed_list import DataSequence from pydantic import BaseModel, ConfigDict, Field @@ -181,10 +181,10 @@ def run_module(): device_specific_variables: Dict = module.params.get("device_specific_variables") module.logger.info(f"Module input: \n{module.params}\n") - all_templates: DataSequence[FeatureTemplateInfo] = module.get_response_safely( + all_templates: DataSequence[FeatureTemplateInformation] = module.get_response_safely( module.session.api.templates.get, template=FeatureTemplate ) - target_template: FeatureTemplateInfo = all_templates.filter(name=template_name) + target_template: Optional[FeatureTemplateInformation] = all_templates.filter(name=template_name) if module.params.get("state") == "present": # Code for checking if template name exists already @@ -241,7 +241,6 @@ def run_module(): template=FeatureTemplate, name=template_name, ) - # module.session.api.templates.delete(template=FeatureTemplate, name=template_name) result.changed = True result.msg = f"Deleted template {template_name}" else: diff --git a/plugins/modules/feature_templates_info.py b/plugins/modules/feature_templates_info.py index 4866d44..4de2533 100644 --- a/plugins/modules/feature_templates_info.py +++ b/plugins/modules/feature_templates_info.py @@ -145,9 +145,8 @@ from typing import Dict, Optional from catalystwan.api.template_api import FeatureTemplate -from catalystwan.dataclasses import FeatureTemplateInfo +from catalystwan.models.templates import FeatureTemplateInformation from catalystwan.typed_list import DataSequence -from catalystwan.utils.creation_tools import asdict from pydantic import Field from ..module_utils.result import ModuleResult @@ -168,7 +167,7 @@ def run_module(): filters = module.params.get("filters") - all_templates: DataSequence[FeatureTemplateInfo] = module.get_response_safely( + all_templates: DataSequence[FeatureTemplateInformation] = module.get_response_safely( module.session.api.templates.get, template=FeatureTemplate ) @@ -177,13 +176,13 @@ def run_module(): if filtered_templates: module.logger.info(f"All Feature Templates filtered with filters: {filters}:\n{filtered_templates}") result.msg = "Succesfully got all requested Feature Templates Info from vManage" - result.templates_info = [asdict(template) for template in filtered_templates] + result.templates_info = [template for template in filtered_templates] else: module.logger.warning(msg=f"Feature templates filtered with `{filters}` not present.") result.msg = f"Feature templates filtered with `{filters}` not present on vManage." else: result.msg = "Succesfully got all Feature Templates Info from vManage" - result.templates_info = [asdict(template) for template in all_templates] + result.templates_info = [template for template in all_templates] module.exit_json(**result.model_dump(mode="json")) diff --git a/pyproject.toml b/pyproject.toml index 0e4644b..d452061 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ readme = "README.md" python = "^3.10" ansible-core = "^2.16.6" ansible = "^9.4.0" -catalystwan = "v0.33.6post0" +catalystwan = "v0.33.8dev7" flake8 = "^5.0.4" black = "^23.12.1" pre-commit = "3.7" diff --git a/utils/ft_generator.py b/utils/ft_generator.py index 502c12d..c537dbd 100644 --- a/utils/ft_generator.py +++ b/utils/ft_generator.py @@ -243,7 +243,9 @@ def to_nice_yaml(data): return yaml.dump(data, allow_unicode=True, default_flow_style=False, indent=4, sort_keys=False) template_dir = PROJECT_ROOT_DIR / "utils" - env = Environment(loader=FileSystemLoader(template_dir), trim_blocks=True, lstrip_blocks=True) + env = Environment( + loader=FileSystemLoader(template_dir), trim_blocks=True, lstrip_blocks=True, keep_trailing_newline=True + ) env.filters["to_nice_yaml"] = to_nice_yaml template_file = PurePath("docs_fragments_template.j2") From ca04dd465598b6533a1ff1be88de5a51ac229cad Mon Sep 17 00:00:00 2001 From: acichon Date: Tue, 23 Jul 2024 15:00:05 +0200 Subject: [PATCH 17/18] format feature_templates module args --- .../feature_templates/cisco_aaa.py | 336 ++++---- .../feature_templates/cisco_banner.py | 20 +- .../feature_templates/cisco_bfd.py | 56 +- .../feature_templates/cisco_logging.py | 133 ++- .../feature_templates/cisco_ntp.py | 85 +- .../feature_templates/cisco_omp.py | 107 +-- .../feature_templates/cisco_ospf.py | 232 +++--- .../cisco_secure_internet_gateway.py | 324 +++----- .../feature_templates/cisco_vpn.py | 779 ++++++++--------- .../feature_templates/cisco_vpn_interface.py | 786 ++++++------------ .../feature_templates/omp_vsmart.py | 56 +- .../feature_templates/security_vsmart.py | 20 +- plugins/modules/cli_templates.py | 4 +- plugins/modules/device_templates.py | 29 +- plugins/modules/device_templates_info.py | 3 +- plugins/modules/feature_templates.py | 2 +- plugins/modules/feature_templates_info.py | 2 +- 17 files changed, 1167 insertions(+), 1807 deletions(-) diff --git a/plugins/module_utils/feature_templates/cisco_aaa.py b/plugins/module_utils/feature_templates/cisco_aaa.py index 9ce7dc3..1d622d8 100644 --- a/plugins/module_utils/feature_templates/cisco_aaa.py +++ b/plugins/module_utils/feature_templates/cisco_aaa.py @@ -1,196 +1,140 @@ -cisco_aaa_definition = { 'cisco_aaa': { 'default': None, - 'options': { 'accounting_group': { 'default': False, - 'required': False, - 'type': 'bool'}, - 'accounting_rules': { 'default': None, - 'elements': 'dict', - 'options': { 'group': { 'default': None, - 'required': True, - 'type': 'str'}, - 'level': { 'default': None, - 'required': False, - 'type': 'str'}, - 'method': { 'default': None, - 'required': True, - 'type': 'str'}, - 'rule_id': { 'default': None, - 'required': True, - 'type': 'str'}, - 'start_stop': { 'default': True, - 'required': False, - 'type': 'bool'}}, - 'required': False, - 'type': 'list'}, - 'authentication_group': { 'default': False, - 'required': False, - 'type': 'bool'}, - 'authentication_type': { 'default': 'any', - 'required': False, - 'type': 'str'}, - 'authorization_config_commands': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'authorization_console': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'authorization_rules': { 'default': None, - 'elements': 'dict', - 'options': { 'authenticated': { 'default': False, - 'required': False, - 'type': 'bool'}, - 'group': { 'default': None, - 'required': True, - 'type': 'str'}, - 'level': { 'default': None, - 'required': False, - 'type': 'str'}, - 'method': { 'default': None, - 'required': True, - 'type': 'str'}, - 'rule_id': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'cts_authorization_list': { 'default': None, - 'required': False, - 'type': 'str'}, - 'domain_stripping': { 'default': None, - 'required': False, - 'type': 'str'}, - 'port': { 'default': None, - 'required': False, - 'type': 'int'}, - 'radius': { 'default': None, - 'elements': 'dict', - 'options': { 'group_name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'server': { 'default': [ ], - 'elements': 'dict', - 'options': { 'acct_port': { 'default': None, - 'required': False, - 'type': 'int'}, - 'address': { 'default': None, - 'required': True, - 'type': 'str'}, - 'auth_port': { 'default': None, - 'required': False, - 'type': 'int'}, - 'key': { 'default': None, - 'required': True, - 'type': 'str'}, - 'key_enum': { 'default': None, - 'required': False, - 'type': 'str'}, - 'key_type': { 'default': None, - 'required': False, - 'type': 'str'}, - 'retransmit': { 'default': None, - 'required': False, - 'type': 'int'}, - 'secret_key': { 'default': None, - 'required': False, - 'type': 'str'}, - 'timeout': { 'default': None, - 'required': False, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'source_interface': { 'default': None, - 'required': True, - 'type': 'str'}, - 'vpn': { 'default': None, - 'required': True, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'radius_client': { 'default': None, - 'elements': 'dict', - 'options': { 'ip': { 'default': None, - 'required': True, - 'type': 'str'}, - 'vpn': { 'default': None, - 'elements': 'dict', - 'options': { 'name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'server_key': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': True, - 'type': 'list'}}, - 'required': False, - 'type': 'list'}, - 'radius_trustsec_group': { 'default': None, - 'required': False, - 'type': 'str'}, - 'server_auth_order': { 'default': 'local', - 'required': False, - 'type': 'str'}, - 'server_key_password': { 'default': None, - 'required': False, - 'type': 'str'}, - 'tacacs': { 'default': None, - 'elements': 'dict', - 'options': { 'group_name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'server': { 'default': [ ], - 'elements': 'dict', - 'options': { 'address': { 'default': None, - 'required': True, - 'type': 'str'}, - 'key': { 'default': None, - 'required': True, - 'type': 'str'}, - 'key_enum': { 'default': None, - 'required': False, - 'type': 'str'}, - 'port': { 'default': None, - 'required': False, - 'type': 'int'}, - 'secret_key': { 'default': None, - 'required': False, - 'type': 'str'}, - 'timeout': { 'default': None, - 'required': False, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'source_interface': { 'default': None, - 'required': False, - 'type': 'str'}, - 'vpn': { 'default': None, - 'required': False, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'user': { 'default': None, - 'elements': 'dict', - 'options': { 'name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'password': { 'default': None, - 'required': False, - 'type': 'str'}, - 'privilege': { 'default': '15', - 'required': False, - 'type': 'str'}, - 'pubkey_chain': { 'default': None, - 'elements': 'dict', - 'options': { 'key_string': { 'default': None, - 'required': True, - 'type': 'str'}, - 'key_type': { 'default': 'ssh-rsa', - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'secret': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}}, - 'required': False, - 'type': 'dict'}} +cisco_aaa_definition = { + "cisco_aaa": { + "default": None, + "options": { + "accounting_group": {"default": False, "required": False, "type": "bool"}, + "accounting_rules": { + "default": None, + "elements": "dict", + "options": { + "group": {"default": None, "required": True, "type": "str"}, + "level": {"default": None, "required": False, "type": "str"}, + "method": {"default": None, "required": True, "type": "str"}, + "rule_id": {"default": None, "required": True, "type": "str"}, + "start_stop": {"default": True, "required": False, "type": "bool"}, + }, + "required": False, + "type": "list", + }, + "authentication_group": {"default": False, "required": False, "type": "bool"}, + "authentication_type": {"default": "any", "required": False, "type": "str"}, + "authorization_config_commands": {"default": None, "required": False, "type": "bool"}, + "authorization_console": {"default": None, "required": False, "type": "bool"}, + "authorization_rules": { + "default": None, + "elements": "dict", + "options": { + "authenticated": {"default": False, "required": False, "type": "bool"}, + "group": {"default": None, "required": True, "type": "str"}, + "level": {"default": None, "required": False, "type": "str"}, + "method": {"default": None, "required": True, "type": "str"}, + "rule_id": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "cts_authorization_list": {"default": None, "required": False, "type": "str"}, + "domain_stripping": {"default": None, "required": False, "type": "str"}, + "port": {"default": None, "required": False, "type": "int"}, + "radius": { + "default": None, + "elements": "dict", + "options": { + "group_name": {"default": None, "required": True, "type": "str"}, + "server": { + "default": [], + "elements": "dict", + "options": { + "acct_port": {"default": None, "required": False, "type": "int"}, + "address": {"default": None, "required": True, "type": "str"}, + "auth_port": {"default": None, "required": False, "type": "int"}, + "key": {"default": None, "required": True, "type": "str"}, + "key_enum": {"default": None, "required": False, "type": "str"}, + "key_type": {"default": None, "required": False, "type": "str"}, + "retransmit": {"default": None, "required": False, "type": "int"}, + "secret_key": {"default": None, "required": False, "type": "str"}, + "timeout": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "source_interface": {"default": None, "required": True, "type": "str"}, + "vpn": {"default": None, "required": True, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "radius_client": { + "default": None, + "elements": "dict", + "options": { + "ip": {"default": None, "required": True, "type": "str"}, + "vpn": { + "default": None, + "elements": "dict", + "options": { + "name": {"default": None, "required": True, "type": "str"}, + "server_key": {"default": None, "required": False, "type": "str"}, + }, + "required": True, + "type": "list", + }, + }, + "required": False, + "type": "list", + }, + "radius_trustsec_group": {"default": None, "required": False, "type": "str"}, + "server_auth_order": {"default": "local", "required": False, "type": "str"}, + "server_key_password": {"default": None, "required": False, "type": "str"}, + "tacacs": { + "default": None, + "elements": "dict", + "options": { + "group_name": {"default": None, "required": True, "type": "str"}, + "server": { + "default": [], + "elements": "dict", + "options": { + "address": {"default": None, "required": True, "type": "str"}, + "key": {"default": None, "required": True, "type": "str"}, + "key_enum": {"default": None, "required": False, "type": "str"}, + "port": {"default": None, "required": False, "type": "int"}, + "secret_key": {"default": None, "required": False, "type": "str"}, + "timeout": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "source_interface": {"default": None, "required": False, "type": "str"}, + "vpn": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "user": { + "default": None, + "elements": "dict", + "options": { + "name": {"default": None, "required": True, "type": "str"}, + "password": {"default": None, "required": False, "type": "str"}, + "privilege": {"default": "15", "required": False, "type": "str"}, + "pubkey_chain": { + "default": None, + "elements": "dict", + "options": { + "key_string": {"default": None, "required": True, "type": "str"}, + "key_type": {"default": "ssh-rsa", "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "secret": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_banner.py b/plugins/module_utils/feature_templates/cisco_banner.py index f0d96d8..94dc562 100644 --- a/plugins/module_utils/feature_templates/cisco_banner.py +++ b/plugins/module_utils/feature_templates/cisco_banner.py @@ -1,9 +1,11 @@ -cisco_banner_definition = { 'cisco_banner': { 'default': None, - 'options': { 'login_banner': { 'default': None, - 'required': False, - 'type': 'str'}, - 'motd_banner': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'dict'}} +cisco_banner_definition = { + "cisco_banner": { + "default": None, + "options": { + "login_banner": {"default": None, "required": False, "type": "str"}, + "motd_banner": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_bfd.py b/plugins/module_utils/feature_templates/cisco_bfd.py index 8871f79..e327be7 100644 --- a/plugins/module_utils/feature_templates/cisco_bfd.py +++ b/plugins/module_utils/feature_templates/cisco_bfd.py @@ -1,31 +1,25 @@ -cisco_bfd_definition = { 'cisco_bfd': { 'default': None, - 'options': { 'color': { 'default': None, - 'elements': 'dict', - 'options': { 'color': { 'default': None, - 'required': True, - 'type': 'str'}, - 'dscp': { 'default': None, - 'required': False, - 'type': 'int'}, - 'hello_interval': { 'default': None, - 'required': False, - 'type': 'int'}, - 'multiplier': { 'default': None, - 'required': False, - 'type': 'int'}, - 'pmtu_discovery': { 'default': True, - 'required': False, - 'type': 'bool'}}, - 'required': False, - 'type': 'list'}, - 'default_dscp': { 'default': None, - 'required': False, - 'type': 'int'}, - 'multiplier': { 'default': None, - 'required': False, - 'type': 'int'}, - 'poll_interval': { 'default': None, - 'required': False, - 'type': 'int'}}, - 'required': False, - 'type': 'dict'}} +cisco_bfd_definition = { + "cisco_bfd": { + "default": None, + "options": { + "color": { + "default": None, + "elements": "dict", + "options": { + "color": {"default": None, "required": True, "type": "str"}, + "dscp": {"default": None, "required": False, "type": "int"}, + "hello_interval": {"default": None, "required": False, "type": "int"}, + "multiplier": {"default": None, "required": False, "type": "int"}, + "pmtu_discovery": {"default": True, "required": False, "type": "bool"}, + }, + "required": False, + "type": "list", + }, + "default_dscp": {"default": None, "required": False, "type": "int"}, + "multiplier": {"default": None, "required": False, "type": "int"}, + "poll_interval": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_logging.py b/plugins/module_utils/feature_templates/cisco_logging.py index c441488..4c1bb30 100644 --- a/plugins/module_utils/feature_templates/cisco_logging.py +++ b/plugins/module_utils/feature_templates/cisco_logging.py @@ -1,79 +1,54 @@ -cisco_logging_definition = { 'cisco_logging': { 'default': None, - 'options': { 'enable': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'ipv6_server': { 'default': None, - 'elements': 'dict', - 'options': { 'custom_profile': { 'default': False, - 'required': False, - 'type': 'bool'}, - 'enable_tls': { 'default': False, - 'required': False, - 'type': 'bool'}, - 'name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'priority': { 'default': 'information', - 'required': False, - 'type': 'str'}, - 'profile': { 'default': None, - 'required': False, - 'type': 'str'}, - 'source_interface': { 'default': None, - 'required': False, - 'type': 'str'}, - 'vpn': { 'default': None, - 'required': True, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'rotate': { 'default': None, - 'required': False, - 'type': 'int'}, - 'server': { 'default': None, - 'elements': 'dict', - 'options': { 'custom_profile': { 'default': False, - 'required': False, - 'type': 'bool'}, - 'enable_tls': { 'default': False, - 'required': False, - 'type': 'bool'}, - 'name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'priority': { 'default': 'information', - 'required': False, - 'type': 'str'}, - 'profile': { 'default': None, - 'required': False, - 'type': 'str'}, - 'source_interface': { 'default': None, - 'required': False, - 'type': 'str'}, - 'vpn': { 'default': None, - 'required': True, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'size': { 'default': None, - 'required': False, - 'type': 'int'}, - 'tls_profile': { 'default': None, - 'elements': 'dict', - 'options': { 'auth_type': { 'default': None, - 'required': True, - 'type': 'str'}, - 'ciphersuite_list': { 'default': None, - 'elements': 'str', - 'required': False, - 'type': 'list'}, - 'profile': { 'default': None, - 'required': True, - 'type': 'str'}, - 'version': { 'default': 'TLSv1.1', - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}}, - 'required': False, - 'type': 'dict'}} +cisco_logging_definition = { + "cisco_logging": { + "default": None, + "options": { + "enable": {"default": None, "required": False, "type": "bool"}, + "ipv6_server": { + "default": None, + "elements": "dict", + "options": { + "custom_profile": {"default": False, "required": False, "type": "bool"}, + "enable_tls": {"default": False, "required": False, "type": "bool"}, + "name": {"default": None, "required": True, "type": "str"}, + "priority": {"default": "information", "required": False, "type": "str"}, + "profile": {"default": None, "required": False, "type": "str"}, + "source_interface": {"default": None, "required": False, "type": "str"}, + "vpn": {"default": None, "required": True, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "rotate": {"default": None, "required": False, "type": "int"}, + "server": { + "default": None, + "elements": "dict", + "options": { + "custom_profile": {"default": False, "required": False, "type": "bool"}, + "enable_tls": {"default": False, "required": False, "type": "bool"}, + "name": {"default": None, "required": True, "type": "str"}, + "priority": {"default": "information", "required": False, "type": "str"}, + "profile": {"default": None, "required": False, "type": "str"}, + "source_interface": {"default": None, "required": False, "type": "str"}, + "vpn": {"default": None, "required": True, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "size": {"default": None, "required": False, "type": "int"}, + "tls_profile": { + "default": None, + "elements": "dict", + "options": { + "auth_type": {"default": None, "required": True, "type": "str"}, + "ciphersuite_list": {"default": None, "elements": "str", "required": False, "type": "list"}, + "profile": {"default": None, "required": True, "type": "str"}, + "version": {"default": "TLSv1.1", "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_ntp.py b/plugins/module_utils/feature_templates/cisco_ntp.py index 057d187..6ac3117 100644 --- a/plugins/module_utils/feature_templates/cisco_ntp.py +++ b/plugins/module_utils/feature_templates/cisco_ntp.py @@ -1,48 +1,37 @@ -cisco_ntp_definition = { 'cisco_ntp': { 'default': None, - 'options': { 'authentication': { 'default': None, - 'elements': 'dict', - 'options': { 'md5': { 'default': None, - 'required': True, - 'type': 'str'}, - 'number': { 'default': None, - 'required': True, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'enable': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'server': { 'default': [], - 'elements': 'dict', - 'options': { 'key': { 'default': None, - 'required': False, - 'type': 'int'}, - 'name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'prefer': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'source_interface': { 'default': None, - 'required': False, - 'type': 'str'}, - 'version': { 'default': None, - 'required': False, - 'type': 'int'}, - 'vpn': { 'default': None, - 'required': False, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'source': { 'default': None, - 'required': False, - 'type': 'str'}, - 'stratum': { 'default': None, - 'required': False, - 'type': 'int'}, - 'trusted': { 'default': None, - 'elements': 'int', - 'required': False, - 'type': 'list'}}, - 'required': False, - 'type': 'dict'}} +cisco_ntp_definition = { + "cisco_ntp": { + "default": None, + "options": { + "authentication": { + "default": None, + "elements": "dict", + "options": { + "md5": {"default": None, "required": True, "type": "str"}, + "number": {"default": None, "required": True, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "enable": {"default": None, "required": False, "type": "bool"}, + "server": { + "default": [], + "elements": "dict", + "options": { + "key": {"default": None, "required": False, "type": "int"}, + "name": {"default": None, "required": True, "type": "str"}, + "prefer": {"default": None, "required": False, "type": "bool"}, + "source_interface": {"default": None, "required": False, "type": "str"}, + "version": {"default": None, "required": False, "type": "int"}, + "vpn": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "source": {"default": None, "required": False, "type": "str"}, + "stratum": {"default": None, "required": False, "type": "int"}, + "trusted": {"default": None, "elements": "int", "required": False, "type": "list"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_omp.py b/plugins/module_utils/feature_templates/cisco_omp.py index 05d965a..6eb5021 100644 --- a/plugins/module_utils/feature_templates/cisco_omp.py +++ b/plugins/module_utils/feature_templates/cisco_omp.py @@ -1,66 +1,41 @@ -cisco_omp_definition = { 'cisco_omp': { 'default': None, - 'options': { 'advertise': { 'default': None, - 'elements': 'dict', - 'options': { 'protocol': { 'default': None, - 'required': True, - 'type': 'str'}, - 'route': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'advertisement_interval': { 'default': None, - 'required': False, - 'type': 'int'}, - 'auto_translate': { 'default': False, - 'required': False, - 'type': 'bool'}, - 'ecmp_limit': { 'default': None, - 'required': False, - 'type': 'int'}, - 'eor_timer': { 'default': None, - 'required': False, - 'type': 'int'}, - 'graceful_restart': { 'default': True, - 'required': False, - 'type': 'bool'}, - 'graceful_restart_timer': { 'default': None, - 'required': False, - 'type': 'int'}, - 'holdtime': { 'default': None, - 'required': False, - 'type': 'int'}, - 'ignore_region_path_length': { 'default': False, - 'required': False, - 'type': 'bool'}, - 'ipv6_advertise': { 'default': None, - 'elements': 'dict', - 'options': { 'protocol': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'omp_admin_distance_ipv4': { 'default': None, - 'required': False, - 'type': 'int'}, - 'omp_admin_distance_ipv6': { 'default': None, - 'required': False, - 'type': 'int'}, - 'overlay_as': { 'default': None, - 'required': False, - 'type': 'int'}, - 'send_path_limit': { 'default': None, - 'required': False, - 'type': 'int'}, - 'shutdown': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'site_types': { 'default': None, - 'elements': 'str', - 'required': False, - 'type': 'list'}, - 'transport_gateway': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'dict'}} +cisco_omp_definition = { + "cisco_omp": { + "default": None, + "options": { + "advertise": { + "default": None, + "elements": "dict", + "options": { + "protocol": {"default": None, "required": True, "type": "str"}, + "route": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "advertisement_interval": {"default": None, "required": False, "type": "int"}, + "auto_translate": {"default": False, "required": False, "type": "bool"}, + "ecmp_limit": {"default": None, "required": False, "type": "int"}, + "eor_timer": {"default": None, "required": False, "type": "int"}, + "graceful_restart": {"default": True, "required": False, "type": "bool"}, + "graceful_restart_timer": {"default": None, "required": False, "type": "int"}, + "holdtime": {"default": None, "required": False, "type": "int"}, + "ignore_region_path_length": {"default": False, "required": False, "type": "bool"}, + "ipv6_advertise": { + "default": None, + "elements": "dict", + "options": {"protocol": {"default": None, "required": True, "type": "str"}}, + "required": False, + "type": "list", + }, + "omp_admin_distance_ipv4": {"default": None, "required": False, "type": "int"}, + "omp_admin_distance_ipv6": {"default": None, "required": False, "type": "int"}, + "overlay_as": {"default": None, "required": False, "type": "int"}, + "send_path_limit": {"default": None, "required": False, "type": "int"}, + "shutdown": {"default": None, "required": False, "type": "bool"}, + "site_types": {"default": None, "elements": "str", "required": False, "type": "list"}, + "transport_gateway": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_ospf.py b/plugins/module_utils/feature_templates/cisco_ospf.py index 5f3d56e..925f44e 100644 --- a/plugins/module_utils/feature_templates/cisco_ospf.py +++ b/plugins/module_utils/feature_templates/cisco_ospf.py @@ -1,138 +1,94 @@ -cisco_ospf_definition = { 'cisco_ospf': { 'default': None, - 'options': { 'always': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'area': { 'default': None, - 'elements': 'dict', - 'options': { 'a_num': { 'default': None, - 'required': True, - 'type': 'int'}, - 'interface': { 'default': None, - 'elements': 'dict', - 'options': { 'cost': { 'default': None, - 'required': False, - 'type': 'int'}, - 'dead_interval': { 'default': None, - 'required': False, - 'type': 'int'}, - 'hello_interval': { 'default': None, - 'required': False, - 'type': 'int'}, - 'md5': { 'default': None, - 'required': False, - 'type': 'str'}, - 'message_digest_key': { 'default': None, - 'required': False, - 'type': 'int'}, - 'name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'network': { 'default': 'broadcast', - 'required': False, - 'type': 'str'}, - 'passive_interface': { 'default': False, - 'required': False, - 'type': 'bool'}, - 'priority': { 'default': None, - 'required': False, - 'type': 'int'}, - 'retransmit_interval': { 'default': None, - 'required': False, - 'type': 'int'}, - 'type': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'nssa': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'range': { 'default': None, - 'elements': 'dict', - 'options': { 'address': { 'default': None, - 'required': True, - 'type': 'str'}, - 'cost': { 'default': None, - 'required': False, - 'type': 'int'}, - 'no_advertise': { 'default': False, - 'required': False, - 'type': 'bool'}}, - 'required': False, - 'type': 'list'}, - 'stub': { 'default': None, - 'required': False, - 'type': 'bool'}}, - 'required': False, - 'type': 'list'}, - 'delay': { 'default': None, - 'required': False, - 'type': 'int'}, - 'external': { 'default': None, - 'required': False, - 'type': 'int'}, - 'initial_hold': { 'default': None, - 'required': False, - 'type': 'int'}, - 'inter_area': { 'default': None, - 'required': False, - 'type': 'int'}, - 'intra_area': { 'default': None, - 'required': False, - 'type': 'int'}, - 'max_hold': { 'default': None, - 'required': False, - 'type': 'int'}, - 'metric': { 'default': None, - 'required': False, - 'type': 'int'}, - 'metric_type': { 'default': None, - 'required': False, - 'type': 'str'}, - 'originate': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'redistribute': { 'default': None, - 'elements': 'dict', - 'options': { 'dia': { 'default': True, - 'required': False, - 'type': 'bool'}, - 'protocol': { 'default': None, - 'required': True, - 'type': 'str'}, - 'route_policy': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'reference_bandwidth': { 'default': None, - 'required': False, - 'type': 'int'}, - 'rfc1583': { 'default': True, - 'required': False, - 'type': 'bool'}, - 'route_policy': { 'default': None, - 'elements': 'dict', - 'options': { 'direction': { 'default': None, - 'required': True, - 'type': 'str'}, - 'pol_name': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'router_id': { 'default': None, - 'required': False, - 'type': 'str'}, - 'router_lsa': { 'default': None, - 'elements': 'dict', - 'options': { 'ad_type': { 'default': None, - 'required': True, - 'type': 'str'}, - 'time': { 'default': None, - 'required': True, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}}, - 'required': False, - 'type': 'dict'}} +cisco_ospf_definition = { + "cisco_ospf": { + "default": None, + "options": { + "always": {"default": None, "required": False, "type": "bool"}, + "area": { + "default": None, + "elements": "dict", + "options": { + "a_num": {"default": None, "required": True, "type": "int"}, + "interface": { + "default": None, + "elements": "dict", + "options": { + "cost": {"default": None, "required": False, "type": "int"}, + "dead_interval": {"default": None, "required": False, "type": "int"}, + "hello_interval": {"default": None, "required": False, "type": "int"}, + "md5": {"default": None, "required": False, "type": "str"}, + "message_digest_key": {"default": None, "required": False, "type": "int"}, + "name": {"default": None, "required": True, "type": "str"}, + "network": {"default": "broadcast", "required": False, "type": "str"}, + "passive_interface": {"default": False, "required": False, "type": "bool"}, + "priority": {"default": None, "required": False, "type": "int"}, + "retransmit_interval": {"default": None, "required": False, "type": "int"}, + "type": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "nssa": {"default": None, "required": False, "type": "bool"}, + "range": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": True, "type": "str"}, + "cost": {"default": None, "required": False, "type": "int"}, + "no_advertise": {"default": False, "required": False, "type": "bool"}, + }, + "required": False, + "type": "list", + }, + "stub": {"default": None, "required": False, "type": "bool"}, + }, + "required": False, + "type": "list", + }, + "delay": {"default": None, "required": False, "type": "int"}, + "external": {"default": None, "required": False, "type": "int"}, + "initial_hold": {"default": None, "required": False, "type": "int"}, + "inter_area": {"default": None, "required": False, "type": "int"}, + "intra_area": {"default": None, "required": False, "type": "int"}, + "max_hold": {"default": None, "required": False, "type": "int"}, + "metric": {"default": None, "required": False, "type": "int"}, + "metric_type": {"default": None, "required": False, "type": "str"}, + "originate": {"default": None, "required": False, "type": "bool"}, + "redistribute": { + "default": None, + "elements": "dict", + "options": { + "dia": {"default": True, "required": False, "type": "bool"}, + "protocol": {"default": None, "required": True, "type": "str"}, + "route_policy": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "reference_bandwidth": {"default": None, "required": False, "type": "int"}, + "rfc1583": {"default": True, "required": False, "type": "bool"}, + "route_policy": { + "default": None, + "elements": "dict", + "options": { + "direction": {"default": None, "required": True, "type": "str"}, + "pol_name": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "router_id": {"default": None, "required": False, "type": "str"}, + "router_lsa": { + "default": None, + "elements": "dict", + "options": { + "ad_type": {"default": None, "required": True, "type": "str"}, + "time": {"default": None, "required": True, "type": "int"}, + }, + "required": False, + "type": "list", + }, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py b/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py index 5c29620..da2a98d 100644 --- a/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py +++ b/plugins/module_utils/feature_templates/cisco_secure_internet_gateway.py @@ -1,217 +1,107 @@ -cisco_secure_internet_gateway_definition = { 'cisco_secure_internet_gateway': { 'default': None, - 'options': { 'child_org_id': { 'default': '', - 'required': False, - 'type': 'str'}, - 'interface': { 'default': None, - 'elements': 'dict', - 'options': { 'address': { 'default': None, - 'required': False, - 'type': 'str'}, - 'application': { 'default': 'sig', - 'required': False, - 'type': 'str'}, - 'auto': { 'default': None, - 'required': True, - 'type': 'bool'}, - 'description': { 'default': None, - 'required': False, - 'type': 'str'}, - 'dpd_interval': { 'default': None, - 'required': False, - 'type': 'int'}, - 'dpd_retries': { 'default': None, - 'required': False, - 'type': 'int'}, - 'if_name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'ike_ciphersuite': { 'default': 'aes256-cbc-sha1', - 'required': False, - 'type': 'str'}, - 'ike_group': { 'default': '14', - 'required': False, - 'type': 'str'}, - 'ike_local_id': { 'default': None, - 'required': False, - 'type': 'str'}, - 'ike_rekey_interval': { 'default': None, - 'required': False, - 'type': 'int'}, - 'ike_remote_id': { 'default': None, - 'required': False, - 'type': 'str'}, - 'ike_version': { 'default': None, - 'required': False, - 'type': 'int'}, - 'ipsec_ciphersuite': { 'default': 'aes256-gcm', - 'required': False, - 'type': 'str'}, - 'ipsec_rekey_interval': { 'default': None, - 'required': False, - 'type': 'int'}, - 'ipsec_replay_window': { 'default': None, - 'required': False, - 'type': 'int'}, - 'mtu': { 'default': None, - 'required': False, - 'type': 'int'}, - 'perfect_forward_secrecy': { 'default': 'none', - 'required': False, - 'type': 'str'}, - 'pre_shared_key_dynamic': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'pre_shared_secret': { 'default': None, - 'required': False, - 'type': 'str'}, - 'shutdown': { 'default': None, - 'required': True, - 'type': 'bool'}, - 'tcp_mss_adjust': { 'default': None, - 'required': False, - 'type': 'int'}, - 'track_enable': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'tracker': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'tunnel_dc_preference': { 'default': 'primary-dc', - 'required': False, - 'type': 'str'}, - 'tunnel_destination': { 'default': None, - 'required': True, - 'type': 'str'}, - 'tunnel_public_ip': { 'default': None, - 'required': False, - 'type': 'str'}, - 'tunnel_route_via': { 'default': None, - 'required': False, - 'type': 'str'}, - 'tunnel_set': { 'default': 'secure-internet-gateway-umbrella', - 'required': False, - 'type': 'str'}, - 'tunnel_source': { 'default': None, - 'required': False, - 'type': 'str'}, - 'tunnel_source_interface': { 'default': None, - 'required': False, - 'type': 'str'}, - 'unnumbered': { 'default': None, - 'required': False, - 'type': 'bool'}}, - 'required': True, - 'type': 'list'}, - 'service': { 'default': None, - 'elements': 'dict', - 'options': { 'auth_required': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'block_internet_until_accepted': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'caution_enabled': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'data_center_primary': { 'default': 'Auto', - 'required': False, - 'type': 'str'}, - 'data_center_secondary': { 'default': 'Auto', - 'required': False, - 'type': 'str'}, - 'display_time_unit': { 'default': 'MINUTE', - 'required': False, - 'type': 'str'}, - 'enabled': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'force_ssl_inspection': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'idle_time': { 'default': None, - 'required': False, - 'type': 'int'}, - 'interface_pair': { 'default': None, - 'elements': 'dict', - 'options': { 'active_interface': { 'default': None, - 'required': True, - 'type': 'str'}, - 'active_interface_weight': { 'default': None, - 'required': False, - 'type': 'int'}, - 'backup_interface': { 'default': None, - 'required': False, - 'type': 'str'}, - 'backup_interface_weight': { 'default': None, - 'required': False, - 'type': 'int'}}, - 'required': True, - 'type': 'list'}, - 'ip': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'ip_enforced_for_known_browsers': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'ips_control': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'location_name': { 'default': 'Auto', - 'required': False, - 'type': 'str'}, - 'ofw_enabled': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'primary_data_center': { 'default': 'Auto', - 'required': False, - 'type': 'str'}, - 'refresh_time': { 'default': None, - 'required': False, - 'type': 'int'}, - 'refresh_time_unit': { 'default': 'MINUTE', - 'required': False, - 'type': 'str'}, - 'secondary_data_center': { 'default': 'Auto', - 'required': False, - 'type': 'str'}, - 'svc_type': { 'default': 'sig', - 'required': False, - 'type': 'str'}, - 'timeout': { 'default': None, - 'required': False, - 'type': 'int'}, - 'xff_forward_enabled': { 'default': None, - 'required': False, - 'type': 'bool'}}, - 'required': True, - 'type': 'list'}, - 'tracker': { 'default': None, - 'elements': 'dict', - 'options': { 'endpoint_api_url': { 'default': None, - 'required': True, - 'type': 'str'}, - 'interval': { 'default': None, - 'required': False, - 'type': 'int'}, - 'multiplier': { 'default': None, - 'required': False, - 'type': 'int'}, - 'name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'threshold': { 'default': None, - 'required': False, - 'type': 'int'}, - 'tracker_type': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'tracker_src_ip': { 'default': None, - 'required': False, - 'type': 'str'}, - 'vpn_id': { 'default': None, - 'required': False, - 'type': 'int'}}, - 'required': False, - 'type': 'dict'}} +cisco_secure_internet_gateway_definition = { + "cisco_secure_internet_gateway": { + "default": None, + "options": { + "child_org_id": {"default": "", "required": False, "type": "str"}, + "interface": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": False, "type": "str"}, + "application": {"default": "sig", "required": False, "type": "str"}, + "auto": {"default": None, "required": True, "type": "bool"}, + "description": {"default": None, "required": False, "type": "str"}, + "dpd_interval": {"default": None, "required": False, "type": "int"}, + "dpd_retries": {"default": None, "required": False, "type": "int"}, + "if_name": {"default": None, "required": True, "type": "str"}, + "ike_ciphersuite": {"default": "aes256-cbc-sha1", "required": False, "type": "str"}, + "ike_group": {"default": "14", "required": False, "type": "str"}, + "ike_local_id": {"default": None, "required": False, "type": "str"}, + "ike_rekey_interval": {"default": None, "required": False, "type": "int"}, + "ike_remote_id": {"default": None, "required": False, "type": "str"}, + "ike_version": {"default": None, "required": False, "type": "int"}, + "ipsec_ciphersuite": {"default": "aes256-gcm", "required": False, "type": "str"}, + "ipsec_rekey_interval": {"default": None, "required": False, "type": "int"}, + "ipsec_replay_window": {"default": None, "required": False, "type": "int"}, + "mtu": {"default": None, "required": False, "type": "int"}, + "perfect_forward_secrecy": {"default": "none", "required": False, "type": "str"}, + "pre_shared_key_dynamic": {"default": None, "required": False, "type": "bool"}, + "pre_shared_secret": {"default": None, "required": False, "type": "str"}, + "shutdown": {"default": None, "required": True, "type": "bool"}, + "tcp_mss_adjust": {"default": None, "required": False, "type": "int"}, + "track_enable": {"default": None, "required": False, "type": "bool"}, + "tracker": {"default": None, "required": False, "type": "bool"}, + "tunnel_dc_preference": {"default": "primary-dc", "required": False, "type": "str"}, + "tunnel_destination": {"default": None, "required": True, "type": "str"}, + "tunnel_public_ip": {"default": None, "required": False, "type": "str"}, + "tunnel_route_via": {"default": None, "required": False, "type": "str"}, + "tunnel_set": {"default": "secure-internet-gateway-umbrella", "required": False, "type": "str"}, + "tunnel_source": {"default": None, "required": False, "type": "str"}, + "tunnel_source_interface": {"default": None, "required": False, "type": "str"}, + "unnumbered": {"default": None, "required": False, "type": "bool"}, + }, + "required": True, + "type": "list", + }, + "service": { + "default": None, + "elements": "dict", + "options": { + "auth_required": {"default": None, "required": False, "type": "bool"}, + "block_internet_until_accepted": {"default": None, "required": False, "type": "bool"}, + "caution_enabled": {"default": None, "required": False, "type": "bool"}, + "data_center_primary": {"default": "Auto", "required": False, "type": "str"}, + "data_center_secondary": {"default": "Auto", "required": False, "type": "str"}, + "display_time_unit": {"default": "MINUTE", "required": False, "type": "str"}, + "enabled": {"default": None, "required": False, "type": "bool"}, + "force_ssl_inspection": {"default": None, "required": False, "type": "bool"}, + "idle_time": {"default": None, "required": False, "type": "int"}, + "interface_pair": { + "default": None, + "elements": "dict", + "options": { + "active_interface": {"default": None, "required": True, "type": "str"}, + "active_interface_weight": {"default": None, "required": False, "type": "int"}, + "backup_interface": {"default": None, "required": False, "type": "str"}, + "backup_interface_weight": {"default": None, "required": False, "type": "int"}, + }, + "required": True, + "type": "list", + }, + "ip": {"default": None, "required": False, "type": "bool"}, + "ip_enforced_for_known_browsers": {"default": None, "required": False, "type": "bool"}, + "ips_control": {"default": None, "required": False, "type": "bool"}, + "location_name": {"default": "Auto", "required": False, "type": "str"}, + "ofw_enabled": {"default": None, "required": False, "type": "bool"}, + "primary_data_center": {"default": "Auto", "required": False, "type": "str"}, + "refresh_time": {"default": None, "required": False, "type": "int"}, + "refresh_time_unit": {"default": "MINUTE", "required": False, "type": "str"}, + "secondary_data_center": {"default": "Auto", "required": False, "type": "str"}, + "svc_type": {"default": "sig", "required": False, "type": "str"}, + "timeout": {"default": None, "required": False, "type": "int"}, + "xff_forward_enabled": {"default": None, "required": False, "type": "bool"}, + }, + "required": True, + "type": "list", + }, + "tracker": { + "default": None, + "elements": "dict", + "options": { + "endpoint_api_url": {"default": None, "required": True, "type": "str"}, + "interval": {"default": None, "required": False, "type": "int"}, + "multiplier": {"default": None, "required": False, "type": "int"}, + "name": {"default": None, "required": True, "type": "str"}, + "threshold": {"default": None, "required": False, "type": "int"}, + "tracker_type": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "tracker_src_ip": {"default": None, "required": False, "type": "str"}, + "vpn_id": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_vpn.py b/plugins/module_utils/feature_templates/cisco_vpn.py index 2d5bc6e..74a7940 100644 --- a/plugins/module_utils/feature_templates/cisco_vpn.py +++ b/plugins/module_utils/feature_templates/cisco_vpn.py @@ -1,436 +1,343 @@ -cisco_vpn_definition = { 'cisco_vpn': { 'default': None, - 'options': { 'advertise': { 'default': None, - 'elements': 'dict', - 'options': { 'prefix_list': { 'default': None, - 'elements': 'dict', - 'options': { 'aggregate_only': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'prefix_entry': { 'default': None, - 'required': True, - 'type': 'str'}, - 'region': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'protocol': { 'default': None, - 'required': True, - 'type': 'str'}, - 'protocol_sub_type': { 'default': None, - 'elements': 'str', - 'required': False, - 'type': 'list'}, - 'route_policy': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'dns': { 'default': None, - 'elements': 'dict', - 'options': { 'dns_addr': { 'default': None, - 'required': False, - 'type': 'str'}, - 'role': { 'default': 'primary', - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'dns_ipv6': { 'default': None, - 'elements': 'dict', - 'options': { 'dns_addr': { 'default': None, - 'required': False, - 'type': 'str'}, - 'role': { 'default': 'primary', - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'gre_route': { 'default': None, - 'elements': 'dict', - 'options': { 'interface': { 'default': None, - 'elements': 'str', - 'required': False, - 'type': 'list'}, - 'prefix': { 'default': None, - 'required': True, - 'type': 'str'}, - 'vpn': { 'default': None, - 'required': True, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'host': { 'default': None, - 'elements': 'dict', - 'options': { 'hostname': { 'default': None, - 'required': True, - 'type': 'str'}, - 'ip': { 'default': None, - 'elements': 'str', - 'required': True, - 'type': 'list'}}, - 'required': False, - 'type': 'list'}, - 'ipsec_route': { 'default': None, - 'elements': 'dict', - 'options': { 'interface': { 'default': None, - 'elements': 'str', - 'required': False, - 'type': 'list'}, - 'prefix': { 'default': None, - 'required': True, - 'type': 'str'}, - 'vpn': { 'default': None, - 'required': True, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'ipv6_advertise': { 'default': None, - 'elements': 'dict', - 'options': { 'prefix_list': { 'default': None, - 'elements': 'dict', - 'options': { 'aggregate_only': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'prefix_entry': { 'default': None, - 'required': True, - 'type': 'str'}, - 'region': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'protocol': { 'default': None, - 'required': True, - 'type': 'str'}, - 'protocol_sub_type': { 'default': None, - 'elements': 'str', - 'required': False, - 'type': 'list'}, - 'route_policy': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'layer4': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'natpool': { 'default': None, - 'elements': 'dict', - 'options': { 'direction': { 'default': None, - 'required': True, - 'type': 'str'}, - 'name': { 'default': None, - 'required': True, - 'type': 'int'}, - 'overload': { 'default': 'true', - 'required': False, - 'type': 'str'}, - 'prefix_length': { 'default': None, - 'required': False, - 'type': 'int'}, - 'range_end': { 'default': None, - 'required': False, - 'type': 'str'}, - 'range_start': { 'default': None, - 'required': False, - 'type': 'str'}, - 'tracker_id': { 'default': None, - 'required': False, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'omp_admin_distance_ipv4': { 'default': None, - 'required': False, - 'type': 'int'}, - 'omp_admin_distance_ipv6': { 'default': None, - 'required': False, - 'type': 'int'}, - 'org_name': { 'default': None, - 'required': False, - 'type': 'str'}, - 'pool': { 'default': None, - 'elements': 'dict', - 'options': { 'end_address': { 'default': None, - 'required': True, - 'type': 'str'}, - 'leak_from_global': { 'default': None, - 'required': True, - 'type': 'bool'}, - 'leak_from_global_protocol': { 'default': None, - 'required': True, - 'type': 'str'}, - 'leak_to_global': { 'default': None, - 'required': True, - 'type': 'bool'}, - 'name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'overload': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'start_address': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'port_forward': { 'default': None, - 'elements': 'dict', - 'options': { 'pool_name': { 'default': None, - 'required': False, - 'type': 'int'}, - 'proto': { 'default': None, - 'required': True, - 'type': 'str'}, - 'source_ip': { 'default': None, - 'required': True, - 'type': 'str'}, - 'source_port': { 'default': None, - 'required': True, - 'type': 'int'}, - 'translate_ip': { 'default': None, - 'required': True, - 'type': 'str'}, - 'translate_port': { 'default': None, - 'required': True, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'route_export': { 'default': None, - 'elements': 'dict', - 'options': { 'protocol': { 'default': None, - 'required': True, - 'type': 'str'}, - 'protocol_sub_type': { 'default': None, - 'elements': 'str', - 'required': True, - 'type': 'list'}, - 'redistribute': { 'default': None, - 'elements': 'dict', - 'options': { 'protocol': { 'default': None, - 'required': True, - 'type': 'str'}, - 'route_policy': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'route_policy': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'route_import': { 'default': None, - 'elements': 'dict', - 'options': { 'protocol': { 'default': None, - 'required': True, - 'type': 'str'}, - 'protocol_sub_type': { 'default': None, - 'elements': 'str', - 'required': True, - 'type': 'list'}, - 'redistribute': { 'default': None, - 'elements': 'dict', - 'options': { 'protocol': { 'default': None, - 'required': True, - 'type': 'str'}, - 'route_policy': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'route_policy': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'route_import_from': { 'default': None, - 'elements': 'dict', - 'options': { 'protocol': { 'default': None, - 'required': True, - 'type': 'str'}, - 'protocol_sub_type': { 'default': None, - 'elements': 'str', - 'required': True, - 'type': 'list'}, - 'redistribute': { 'default': None, - 'elements': 'dict', - 'options': { 'protocol': { 'default': None, - 'required': True, - 'type': 'str'}, - 'route_policy': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'route_policy': { 'default': None, - 'required': False, - 'type': 'str'}, - 'source_vpn': { 'default': None, - 'required': True, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'route_v4': { 'default': None, - 'elements': 'dict', - 'options': { 'dhcp': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'distance': { 'default': None, - 'required': False, - 'type': 'int'}, - 'next_hop': { 'default': None, - 'elements': 'dict', - 'options': { 'address': { 'default': None, - 'required': False, - 'type': 'str'}, - 'distance': { 'default': None, - 'required': False, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'next_hop_with_track': { 'default': None, - 'elements': 'dict', - 'options': { 'address': { 'default': None, - 'required': False, - 'type': 'str'}, - 'distance': { 'default': None, - 'required': False, - 'type': 'int'}, - 'tracker': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'null0': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'prefix': { 'default': None, - 'required': False, - 'type': 'str'}, - 'route_interface': { 'default': None, - 'options': { 'interface_name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'interface_next_hop': { 'default': None, - 'elements': 'dict', - 'options': { 'address': { 'default': None, - 'required': False, - 'type': 'str'}, - 'distance': { 'default': None, - 'required': False, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}}, - 'required': False, - 'type': 'dict'}, - 'vpn': { 'default': None, - 'required': False, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'route_v6': { 'default': None, - 'elements': 'dict', - 'options': { 'nat': { 'default': None, - 'required': False, - 'type': 'str'}, - 'next_hop': { 'default': None, - 'elements': 'dict', - 'options': { 'address': { 'default': None, - 'required': True, - 'type': 'str'}, - 'distance': { 'default': None, - 'required': False, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'null0': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'prefix': { 'default': None, - 'required': True, - 'type': 'str'}, - 'vpn': { 'default': None, - 'required': False, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'service': { 'default': None, - 'elements': 'dict', - 'options': { 'address': { 'default': None, - 'elements': 'str', - 'required': False, - 'type': 'list'}, - 'interface': { 'default': None, - 'required': False, - 'type': 'str'}, - 'svc_type': { 'default': None, - 'required': True, - 'type': 'str'}, - 'track_enable': { 'default': None, - 'required': False, - 'type': 'bool'}}, - 'required': False, - 'type': 'list'}, - 'service_route': { 'default': None, - 'elements': 'dict', - 'options': { 'prefix': { 'default': None, - 'required': True, - 'type': 'str'}, - 'service': { 'default': 'sig', - 'required': False, - 'type': 'str'}, - 'vpn': { 'default': None, - 'required': True, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'static': { 'default': None, - 'elements': 'dict', - 'options': { 'pool_name': { 'default': None, - 'required': False, - 'type': 'int'}, - 'source_ip': { 'default': None, - 'required': False, - 'type': 'str'}, - 'static_nat_direction': { 'default': None, - 'required': True, - 'type': 'str'}, - 'tracker_id': { 'default': None, - 'required': False, - 'type': 'int'}, - 'translate_ip': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'subnet_static': { 'default': None, - 'elements': 'dict', - 'options': { 'prefix_length': { 'default': None, - 'required': True, - 'type': 'int'}, - 'source_ip_subnet': { 'default': None, - 'required': True, - 'type': 'str'}, - 'static_nat_direction': { 'default': None, - 'required': True, - 'type': 'str'}, - 'tracker_id': { 'default': None, - 'required': False, - 'type': 'int'}, - 'translate_ip_subnet': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'tenant_vpn_id': { 'default': None, - 'required': False, - 'type': 'int'}, - 'vpn_id': { 'default': None, - 'required': False, - 'type': 'int'}, - 'vpn_name': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'dict'}} +cisco_vpn_definition = { + "cisco_vpn": { + "default": None, + "options": { + "advertise": { + "default": None, + "elements": "dict", + "options": { + "prefix_list": { + "default": None, + "elements": "dict", + "options": { + "aggregate_only": {"default": None, "required": False, "type": "bool"}, + "prefix_entry": {"default": None, "required": True, "type": "str"}, + "region": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "protocol": {"default": None, "required": True, "type": "str"}, + "protocol_sub_type": {"default": None, "elements": "str", "required": False, "type": "list"}, + "route_policy": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "dns": { + "default": None, + "elements": "dict", + "options": { + "dns_addr": {"default": None, "required": False, "type": "str"}, + "role": {"default": "primary", "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "dns_ipv6": { + "default": None, + "elements": "dict", + "options": { + "dns_addr": {"default": None, "required": False, "type": "str"}, + "role": {"default": "primary", "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "gre_route": { + "default": None, + "elements": "dict", + "options": { + "interface": {"default": None, "elements": "str", "required": False, "type": "list"}, + "prefix": {"default": None, "required": True, "type": "str"}, + "vpn": {"default": None, "required": True, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "host": { + "default": None, + "elements": "dict", + "options": { + "hostname": {"default": None, "required": True, "type": "str"}, + "ip": {"default": None, "elements": "str", "required": True, "type": "list"}, + }, + "required": False, + "type": "list", + }, + "ipsec_route": { + "default": None, + "elements": "dict", + "options": { + "interface": {"default": None, "elements": "str", "required": False, "type": "list"}, + "prefix": {"default": None, "required": True, "type": "str"}, + "vpn": {"default": None, "required": True, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "ipv6_advertise": { + "default": None, + "elements": "dict", + "options": { + "prefix_list": { + "default": None, + "elements": "dict", + "options": { + "aggregate_only": {"default": None, "required": False, "type": "bool"}, + "prefix_entry": {"default": None, "required": True, "type": "str"}, + "region": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "protocol": {"default": None, "required": True, "type": "str"}, + "protocol_sub_type": {"default": None, "elements": "str", "required": False, "type": "list"}, + "route_policy": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "layer4": {"default": None, "required": False, "type": "bool"}, + "natpool": { + "default": None, + "elements": "dict", + "options": { + "direction": {"default": None, "required": True, "type": "str"}, + "name": {"default": None, "required": True, "type": "int"}, + "overload": {"default": "true", "required": False, "type": "str"}, + "prefix_length": {"default": None, "required": False, "type": "int"}, + "range_end": {"default": None, "required": False, "type": "str"}, + "range_start": {"default": None, "required": False, "type": "str"}, + "tracker_id": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "omp_admin_distance_ipv4": {"default": None, "required": False, "type": "int"}, + "omp_admin_distance_ipv6": {"default": None, "required": False, "type": "int"}, + "org_name": {"default": None, "required": False, "type": "str"}, + "pool": { + "default": None, + "elements": "dict", + "options": { + "end_address": {"default": None, "required": True, "type": "str"}, + "leak_from_global": {"default": None, "required": True, "type": "bool"}, + "leak_from_global_protocol": {"default": None, "required": True, "type": "str"}, + "leak_to_global": {"default": None, "required": True, "type": "bool"}, + "name": {"default": None, "required": True, "type": "str"}, + "overload": {"default": None, "required": False, "type": "bool"}, + "start_address": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "port_forward": { + "default": None, + "elements": "dict", + "options": { + "pool_name": {"default": None, "required": False, "type": "int"}, + "proto": {"default": None, "required": True, "type": "str"}, + "source_ip": {"default": None, "required": True, "type": "str"}, + "source_port": {"default": None, "required": True, "type": "int"}, + "translate_ip": {"default": None, "required": True, "type": "str"}, + "translate_port": {"default": None, "required": True, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "route_export": { + "default": None, + "elements": "dict", + "options": { + "protocol": {"default": None, "required": True, "type": "str"}, + "protocol_sub_type": {"default": None, "elements": "str", "required": True, "type": "list"}, + "redistribute": { + "default": None, + "elements": "dict", + "options": { + "protocol": {"default": None, "required": True, "type": "str"}, + "route_policy": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "route_policy": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "route_import": { + "default": None, + "elements": "dict", + "options": { + "protocol": {"default": None, "required": True, "type": "str"}, + "protocol_sub_type": {"default": None, "elements": "str", "required": True, "type": "list"}, + "redistribute": { + "default": None, + "elements": "dict", + "options": { + "protocol": {"default": None, "required": True, "type": "str"}, + "route_policy": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "route_policy": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "route_import_from": { + "default": None, + "elements": "dict", + "options": { + "protocol": {"default": None, "required": True, "type": "str"}, + "protocol_sub_type": {"default": None, "elements": "str", "required": True, "type": "list"}, + "redistribute": { + "default": None, + "elements": "dict", + "options": { + "protocol": {"default": None, "required": True, "type": "str"}, + "route_policy": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "route_policy": {"default": None, "required": False, "type": "str"}, + "source_vpn": {"default": None, "required": True, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "route_v4": { + "default": None, + "elements": "dict", + "options": { + "dhcp": {"default": None, "required": False, "type": "bool"}, + "distance": {"default": None, "required": False, "type": "int"}, + "next_hop": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": False, "type": "str"}, + "distance": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "next_hop_with_track": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": False, "type": "str"}, + "distance": {"default": None, "required": False, "type": "int"}, + "tracker": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "null0": {"default": None, "required": False, "type": "bool"}, + "prefix": {"default": None, "required": False, "type": "str"}, + "route_interface": { + "default": None, + "options": { + "interface_name": {"default": None, "required": True, "type": "str"}, + "interface_next_hop": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": False, "type": "str"}, + "distance": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "list", + }, + }, + "required": False, + "type": "dict", + }, + "vpn": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "route_v6": { + "default": None, + "elements": "dict", + "options": { + "nat": {"default": None, "required": False, "type": "str"}, + "next_hop": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": True, "type": "str"}, + "distance": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "null0": {"default": None, "required": False, "type": "bool"}, + "prefix": {"default": None, "required": True, "type": "str"}, + "vpn": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "service": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "elements": "str", "required": False, "type": "list"}, + "interface": {"default": None, "required": False, "type": "str"}, + "svc_type": {"default": None, "required": True, "type": "str"}, + "track_enable": {"default": None, "required": False, "type": "bool"}, + }, + "required": False, + "type": "list", + }, + "service_route": { + "default": None, + "elements": "dict", + "options": { + "prefix": {"default": None, "required": True, "type": "str"}, + "service": {"default": "sig", "required": False, "type": "str"}, + "vpn": {"default": None, "required": True, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "static": { + "default": None, + "elements": "dict", + "options": { + "pool_name": {"default": None, "required": False, "type": "int"}, + "source_ip": {"default": None, "required": False, "type": "str"}, + "static_nat_direction": {"default": None, "required": True, "type": "str"}, + "tracker_id": {"default": None, "required": False, "type": "int"}, + "translate_ip": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "subnet_static": { + "default": None, + "elements": "dict", + "options": { + "prefix_length": {"default": None, "required": True, "type": "int"}, + "source_ip_subnet": {"default": None, "required": True, "type": "str"}, + "static_nat_direction": {"default": None, "required": True, "type": "str"}, + "tracker_id": {"default": None, "required": False, "type": "int"}, + "translate_ip_subnet": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "tenant_vpn_id": {"default": None, "required": False, "type": "int"}, + "vpn_id": {"default": None, "required": False, "type": "int"}, + "vpn_name": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/cisco_vpn_interface.py b/plugins/module_utils/feature_templates/cisco_vpn_interface.py index 6ed933f..d056248 100644 --- a/plugins/module_utils/feature_templates/cisco_vpn_interface.py +++ b/plugins/module_utils/feature_templates/cisco_vpn_interface.py @@ -1,514 +1,272 @@ -cisco_vpn_interface_definition = { 'cisco_vpn_interface': { 'default': None, - 'options': { 'access_list_ipv4': { 'default': None, - 'elements': 'dict', - 'options': { 'acl_name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'direction': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'access_list_ipv6': { 'default': None, - 'elements': 'dict', - 'options': { 'acl_name': { 'default': None, - 'required': True, - 'type': 'str'}, - 'direction': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'all': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'arp_timeout': { 'default': None, - 'required': False, - 'type': 'int'}, - 'auto_bandwidth_detect': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'autonegotiate': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'bandwidth_down': { 'default': None, - 'required': False, - 'type': 'int'}, - 'bandwidth_downstream': { 'default': None, - 'required': False, - 'type': 'int'}, - 'bandwidth_up': { 'default': None, - 'required': False, - 'type': 'int'}, - 'bandwidth_upstream': { 'default': None, - 'required': False, - 'type': 'int'}, - 'bgp': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'bind': { 'default': None, - 'required': False, - 'type': 'str'}, - 'block_non_source_ip': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'border': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'carrier': { 'default': None, - 'required': False, - 'type': 'str'}, - 'clear_dont_fragment': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'control_connections': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'core_region': { 'default': None, - 'required': False, - 'type': 'str'}, - 'dhcp': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'dhcp_distance': { 'default': None, - 'required': False, - 'type': 'int'}, - 'dhcp_helper': { 'default': None, - 'elements': 'str', - 'required': False, - 'type': 'list'}, - 'dhcp_helper_v6': { 'default': None, - 'elements': 'dict', - 'options': { 'address': { 'default': None, - 'required': True, - 'type': 'str'}, - 'vpn': { 'default': None, - 'required': False, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'dhcp_ipv4_client': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'dhcp_ipv6_client': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'dmax': { 'default': None, - 'required': False, - 'type': 'int'}, - 'dmin': { 'default': None, - 'required': False, - 'type': 'int'}, - 'dns': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'dst_ip': { 'default': None, - 'required': False, - 'type': 'str'}, - 'duplex': { 'default': None, - 'required': False, - 'type': 'str'}, - 'enable': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'enable_core_region': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'enable_sgt_authorization_and_forwarding': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'enable_sgt_enforcement': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'enable_sgt_propagation': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'enforcement_sgt': { 'default': None, - 'required': False, - 'type': 'int'}, - 'exclude_controller_group_list': { 'default': None, - 'elements': 'int', - 'required': False, - 'type': 'list'}, - 'group': { 'default': None, - 'elements': 'int', - 'required': False, - 'type': 'list'}, - 'hello_interval': { 'default': None, - 'required': False, - 'type': 'int'}, - 'hello_tolerance': { 'default': None, - 'required': False, - 'type': 'int'}, - 'https': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'icmp': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'icmp_redirect_disable': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'if_name': { 'default': None, - 'required': False, - 'type': 'str'}, - 'interface_description': { 'default': None, - 'required': False, - 'type': 'str'}, - 'intrf_mtu': { 'default': None, - 'required': False, - 'type': 'int'}, - 'ip': { 'default': None, - 'elements': 'dict', - 'options': { 'addr': { 'default': None, - 'required': True, - 'type': 'str'}, - 'mac': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'ip_directed_broadcast': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'iperf_server': { 'default': None, - 'required': False, - 'type': 'str'}, - 'ipv4_address': { 'default': None, - 'required': False, - 'type': 'str'}, - 'ipv6_address': { 'default': None, - 'required': False, - 'type': 'str'}, - 'ipv6_vrrp': { 'default': None, - 'elements': 'dict', - 'options': { 'grp_id': { 'default': None, - 'required': True, - 'type': 'int'}, - 'ipv6': { 'default': None, - 'elements': 'dict', - 'options': { 'ipv6_link_local': { 'default': None, - 'required': True, - 'type': 'str'}, - 'prefix': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'priority': { 'default': None, - 'required': False, - 'type': 'int'}, - 'timer': { 'default': None, - 'required': False, - 'type': 'int'}, - 'track_omp': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'track_prefix_list': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'last_resort_circuit': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'load_interval': { 'default': None, - 'required': False, - 'type': 'int'}, - 'loopback_interface': { 'default': None, - 'required': False, - 'type': 'str'}, - 'low_bandwidth_link': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'mac_address': { 'default': None, - 'required': False, - 'type': 'str'}, - 'max_control_connections': { 'default': None, - 'required': False, - 'type': 'int'}, - 'media_type': { 'default': None, - 'required': False, - 'type': 'str'}, - 'mode': { 'default': None, - 'required': False, - 'type': 'str'}, - 'mtu': { 'default': None, - 'required': False, - 'type': 'int'}, - 'nat': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'nat64': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'nat66': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'nat_choice': { 'default': None, - 'required': False, - 'type': 'str'}, - 'nat_range_end': { 'default': None, - 'required': False, - 'type': 'str'}, - 'nat_range_start': { 'default': None, - 'required': False, - 'type': 'str'}, - 'nat_refresh_interval': { 'default': None, - 'required': False, - 'type': 'int'}, - 'netconf': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'network_broadcast': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'ntp': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'ospf': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'overload': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'per_tunnel_qos': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'per_tunnel_qos_aggregator': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'period': { 'default': None, - 'required': False, - 'type': 'int'}, - 'poe': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'port_hop': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'prefix_length': { 'default': None, - 'required': False, - 'type': 'int'}, - 'propagate_sgt': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'qos_adaptive': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'qos_map': { 'default': None, - 'required': False, - 'type': 'str'}, - 'qos_map_vpn': { 'default': None, - 'required': False, - 'type': 'str'}, - 'restrict': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'rule_name': { 'default': None, - 'required': False, - 'type': 'str'}, - 'secondary_ipv4_address': { 'default': None, - 'elements': 'dict', - 'options': { 'address': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'secondary_ipv6_address': { 'default': None, - 'elements': 'dict', - 'options': { 'address': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'secondary_region': { 'default': None, - 'required': False, - 'type': 'str'}, - 'security_group_tag': { 'default': None, - 'required': False, - 'type': 'int'}, - 'service_provider': { 'default': None, - 'required': False, - 'type': 'str'}, - 'shaping_rate': { 'default': None, - 'required': False, - 'type': 'int'}, - 'shutdown': { 'default': False, - 'required': False, - 'type': 'bool'}, - 'snmp': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'speed': { 'default': None, - 'required': False, - 'type': 'str'}, - 'src_ip': { 'default': None, - 'required': False, - 'type': 'str'}, - 'sshd': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'static': { 'default': None, - 'elements': 'dict', - 'options': { 'source_ip': { 'default': None, - 'required': True, - 'type': 'str'}, - 'source_vpn': { 'default': None, - 'required': False, - 'type': 'int'}, - 'static_nat_direction': { 'default': 'inside', - 'required': False, - 'type': 'str'}, - 'translate_ip': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'static_nat66': { 'default': None, - 'elements': 'dict', - 'options': { 'source_prefix': { 'default': None, - 'required': True, - 'type': 'str'}, - 'source_vpn_id': { 'default': None, - 'required': False, - 'type': 'int'}, - 'translated_source_prefix': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'static_port_forward': { 'default': None, - 'elements': 'dict', - 'options': { 'proto': { 'default': None, - 'required': True, - 'type': 'str'}, - 'source_ip': { 'default': None, - 'required': True, - 'type': 'str'}, - 'source_port': { 'default': None, - 'required': False, - 'type': 'int'}, - 'source_vpn': { 'default': None, - 'required': False, - 'type': 'int'}, - 'static_nat_direction': { 'default': 'inside', - 'required': False, - 'type': 'str'}, - 'translate_ip': { 'default': None, - 'required': True, - 'type': 'str'}, - 'translate_port': { 'default': None, - 'required': False, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'stun': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'tcp_mss_adjust': { 'default': None, - 'required': False, - 'type': 'int'}, - 'tcp_timeout': { 'default': None, - 'required': False, - 'type': 'int'}, - 'tloc_encapsulation': { 'default': None, - 'elements': 'dict', - 'options': { 'encap': { 'default': None, - 'required': True, - 'type': 'str'}, - 'preference': { 'default': None, - 'required': False, - 'type': 'int'}, - 'weight': { 'default': None, - 'required': False, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'tloc_extension': { 'default': None, - 'required': False, - 'type': 'str'}, - 'tracker': { 'default': None, - 'elements': 'str', - 'required': False, - 'type': 'list'}, - 'trusted': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'tunnel_tcp_mss_adjust': { 'default': None, - 'required': False, - 'type': 'int'}, - 'tunnels_bandwidth': { 'default': None, - 'required': False, - 'type': 'int'}, - 'udp_timeout': { 'default': None, - 'required': False, - 'type': 'int'}, - 'umax': { 'default': None, - 'required': False, - 'type': 'int'}, - 'umin': { 'default': None, - 'required': False, - 'type': 'int'}, - 'value': { 'default': None, - 'required': False, - 'type': 'str'}, - 'vbond_as_stun_server': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'vmanage_connection_preference': { 'default': None, - 'required': False, - 'type': 'int'}, - 'vrrp': { 'default': None, - 'elements': 'dict', - 'options': { 'address': { 'default': None, - 'required': False, - 'type': 'str'}, - 'grp_id': { 'default': None, - 'required': True, - 'type': 'int'}, - 'ipv4_secondary': { 'default': None, - 'elements': 'dict', - 'options': { 'address': { 'default': None, - 'required': True, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'priority': { 'default': None, - 'required': False, - 'type': 'int'}, - 'timer': { 'default': None, - 'required': False, - 'type': 'int'}, - 'tloc_change_pref': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'track_omp': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'track_prefix_list': { 'default': None, - 'required': False, - 'type': 'str'}, - 'tracking_object': { 'default': None, - 'elements': 'dict', - 'options': { 'decrement': { 'default': None, - 'required': True, - 'type': 'int'}, - 'name': { 'default': None, - 'required': True, - 'type': 'int'}, - 'track_action': { 'default': 'Decrement', - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'list'}, - 'value': { 'default': None, - 'required': True, - 'type': 'int'}}, - 'required': False, - 'type': 'list'}, - 'xconnect': { 'default': None, - 'required': False, - 'type': 'str'}}, - 'required': False, - 'type': 'dict'}} +cisco_vpn_interface_definition = { + "cisco_vpn_interface": { + "default": None, + "options": { + "access_list_ipv4": { + "default": None, + "elements": "dict", + "options": { + "acl_name": {"default": None, "required": True, "type": "str"}, + "direction": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "access_list_ipv6": { + "default": None, + "elements": "dict", + "options": { + "acl_name": {"default": None, "required": True, "type": "str"}, + "direction": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "all": {"default": None, "required": False, "type": "bool"}, + "arp_timeout": {"default": None, "required": False, "type": "int"}, + "auto_bandwidth_detect": {"default": None, "required": False, "type": "bool"}, + "autonegotiate": {"default": None, "required": False, "type": "bool"}, + "bandwidth_down": {"default": None, "required": False, "type": "int"}, + "bandwidth_downstream": {"default": None, "required": False, "type": "int"}, + "bandwidth_up": {"default": None, "required": False, "type": "int"}, + "bandwidth_upstream": {"default": None, "required": False, "type": "int"}, + "bgp": {"default": None, "required": False, "type": "bool"}, + "bind": {"default": None, "required": False, "type": "str"}, + "block_non_source_ip": {"default": None, "required": False, "type": "bool"}, + "border": {"default": None, "required": False, "type": "bool"}, + "carrier": {"default": None, "required": False, "type": "str"}, + "clear_dont_fragment": {"default": None, "required": False, "type": "bool"}, + "control_connections": {"default": None, "required": False, "type": "bool"}, + "core_region": {"default": None, "required": False, "type": "str"}, + "dhcp": {"default": None, "required": False, "type": "bool"}, + "dhcp_distance": {"default": None, "required": False, "type": "int"}, + "dhcp_helper": {"default": None, "elements": "str", "required": False, "type": "list"}, + "dhcp_helper_v6": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": True, "type": "str"}, + "vpn": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "dhcp_ipv4_client": {"default": None, "required": False, "type": "bool"}, + "dhcp_ipv6_client": {"default": None, "required": False, "type": "bool"}, + "dmax": {"default": None, "required": False, "type": "int"}, + "dmin": {"default": None, "required": False, "type": "int"}, + "dns": {"default": None, "required": False, "type": "bool"}, + "dst_ip": {"default": None, "required": False, "type": "str"}, + "duplex": {"default": None, "required": False, "type": "str"}, + "enable": {"default": None, "required": False, "type": "bool"}, + "enable_core_region": {"default": None, "required": False, "type": "bool"}, + "enable_sgt_authorization_and_forwarding": {"default": None, "required": False, "type": "bool"}, + "enable_sgt_enforcement": {"default": None, "required": False, "type": "bool"}, + "enable_sgt_propagation": {"default": None, "required": False, "type": "bool"}, + "enforcement_sgt": {"default": None, "required": False, "type": "int"}, + "exclude_controller_group_list": {"default": None, "elements": "int", "required": False, "type": "list"}, + "group": {"default": None, "elements": "int", "required": False, "type": "list"}, + "hello_interval": {"default": None, "required": False, "type": "int"}, + "hello_tolerance": {"default": None, "required": False, "type": "int"}, + "https": {"default": None, "required": False, "type": "bool"}, + "icmp": {"default": None, "required": False, "type": "bool"}, + "icmp_redirect_disable": {"default": None, "required": False, "type": "bool"}, + "if_name": {"default": None, "required": False, "type": "str"}, + "interface_description": {"default": None, "required": False, "type": "str"}, + "intrf_mtu": {"default": None, "required": False, "type": "int"}, + "ip": { + "default": None, + "elements": "dict", + "options": { + "addr": {"default": None, "required": True, "type": "str"}, + "mac": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "ip_directed_broadcast": {"default": None, "required": False, "type": "bool"}, + "iperf_server": {"default": None, "required": False, "type": "str"}, + "ipv4_address": {"default": None, "required": False, "type": "str"}, + "ipv6_address": {"default": None, "required": False, "type": "str"}, + "ipv6_vrrp": { + "default": None, + "elements": "dict", + "options": { + "grp_id": {"default": None, "required": True, "type": "int"}, + "ipv6": { + "default": None, + "elements": "dict", + "options": { + "ipv6_link_local": {"default": None, "required": True, "type": "str"}, + "prefix": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "priority": {"default": None, "required": False, "type": "int"}, + "timer": {"default": None, "required": False, "type": "int"}, + "track_omp": {"default": None, "required": False, "type": "bool"}, + "track_prefix_list": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "last_resort_circuit": {"default": None, "required": False, "type": "bool"}, + "load_interval": {"default": None, "required": False, "type": "int"}, + "loopback_interface": {"default": None, "required": False, "type": "str"}, + "low_bandwidth_link": {"default": None, "required": False, "type": "bool"}, + "mac_address": {"default": None, "required": False, "type": "str"}, + "max_control_connections": {"default": None, "required": False, "type": "int"}, + "media_type": {"default": None, "required": False, "type": "str"}, + "mode": {"default": None, "required": False, "type": "str"}, + "mtu": {"default": None, "required": False, "type": "int"}, + "nat": {"default": None, "required": False, "type": "bool"}, + "nat64": {"default": None, "required": False, "type": "bool"}, + "nat66": {"default": None, "required": False, "type": "bool"}, + "nat_choice": {"default": None, "required": False, "type": "str"}, + "nat_range_end": {"default": None, "required": False, "type": "str"}, + "nat_range_start": {"default": None, "required": False, "type": "str"}, + "nat_refresh_interval": {"default": None, "required": False, "type": "int"}, + "netconf": {"default": None, "required": False, "type": "bool"}, + "network_broadcast": {"default": None, "required": False, "type": "bool"}, + "ntp": {"default": None, "required": False, "type": "bool"}, + "ospf": {"default": None, "required": False, "type": "bool"}, + "overload": {"default": None, "required": False, "type": "bool"}, + "per_tunnel_qos": {"default": None, "required": False, "type": "bool"}, + "per_tunnel_qos_aggregator": {"default": None, "required": False, "type": "bool"}, + "period": {"default": None, "required": False, "type": "int"}, + "poe": {"default": None, "required": False, "type": "bool"}, + "port_hop": {"default": None, "required": False, "type": "bool"}, + "prefix_length": {"default": None, "required": False, "type": "int"}, + "propagate_sgt": {"default": None, "required": False, "type": "bool"}, + "qos_adaptive": {"default": None, "required": False, "type": "bool"}, + "qos_map": {"default": None, "required": False, "type": "str"}, + "qos_map_vpn": {"default": None, "required": False, "type": "str"}, + "restrict": {"default": None, "required": False, "type": "bool"}, + "rule_name": {"default": None, "required": False, "type": "str"}, + "secondary_ipv4_address": { + "default": None, + "elements": "dict", + "options": {"address": {"default": None, "required": False, "type": "str"}}, + "required": False, + "type": "list", + }, + "secondary_ipv6_address": { + "default": None, + "elements": "dict", + "options": {"address": {"default": None, "required": False, "type": "str"}}, + "required": False, + "type": "list", + }, + "secondary_region": {"default": None, "required": False, "type": "str"}, + "security_group_tag": {"default": None, "required": False, "type": "int"}, + "service_provider": {"default": None, "required": False, "type": "str"}, + "shaping_rate": {"default": None, "required": False, "type": "int"}, + "shutdown": {"default": False, "required": False, "type": "bool"}, + "snmp": {"default": None, "required": False, "type": "bool"}, + "speed": {"default": None, "required": False, "type": "str"}, + "src_ip": {"default": None, "required": False, "type": "str"}, + "sshd": {"default": None, "required": False, "type": "bool"}, + "static": { + "default": None, + "elements": "dict", + "options": { + "source_ip": {"default": None, "required": True, "type": "str"}, + "source_vpn": {"default": None, "required": False, "type": "int"}, + "static_nat_direction": {"default": "inside", "required": False, "type": "str"}, + "translate_ip": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "static_nat66": { + "default": None, + "elements": "dict", + "options": { + "source_prefix": {"default": None, "required": True, "type": "str"}, + "source_vpn_id": {"default": None, "required": False, "type": "int"}, + "translated_source_prefix": {"default": None, "required": True, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "static_port_forward": { + "default": None, + "elements": "dict", + "options": { + "proto": {"default": None, "required": True, "type": "str"}, + "source_ip": {"default": None, "required": True, "type": "str"}, + "source_port": {"default": None, "required": False, "type": "int"}, + "source_vpn": {"default": None, "required": False, "type": "int"}, + "static_nat_direction": {"default": "inside", "required": False, "type": "str"}, + "translate_ip": {"default": None, "required": True, "type": "str"}, + "translate_port": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "stun": {"default": None, "required": False, "type": "bool"}, + "tcp_mss_adjust": {"default": None, "required": False, "type": "int"}, + "tcp_timeout": {"default": None, "required": False, "type": "int"}, + "tloc_encapsulation": { + "default": None, + "elements": "dict", + "options": { + "encap": {"default": None, "required": True, "type": "str"}, + "preference": {"default": None, "required": False, "type": "int"}, + "weight": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "tloc_extension": {"default": None, "required": False, "type": "str"}, + "tracker": {"default": None, "elements": "str", "required": False, "type": "list"}, + "trusted": {"default": None, "required": False, "type": "bool"}, + "tunnel_tcp_mss_adjust": {"default": None, "required": False, "type": "int"}, + "tunnels_bandwidth": {"default": None, "required": False, "type": "int"}, + "udp_timeout": {"default": None, "required": False, "type": "int"}, + "umax": {"default": None, "required": False, "type": "int"}, + "umin": {"default": None, "required": False, "type": "int"}, + "value": {"default": None, "required": False, "type": "str"}, + "vbond_as_stun_server": {"default": None, "required": False, "type": "bool"}, + "vmanage_connection_preference": {"default": None, "required": False, "type": "int"}, + "vrrp": { + "default": None, + "elements": "dict", + "options": { + "address": {"default": None, "required": False, "type": "str"}, + "grp_id": {"default": None, "required": True, "type": "int"}, + "ipv4_secondary": { + "default": None, + "elements": "dict", + "options": {"address": {"default": None, "required": True, "type": "str"}}, + "required": False, + "type": "list", + }, + "priority": {"default": None, "required": False, "type": "int"}, + "timer": {"default": None, "required": False, "type": "int"}, + "tloc_change_pref": {"default": None, "required": False, "type": "bool"}, + "track_omp": {"default": None, "required": False, "type": "bool"}, + "track_prefix_list": {"default": None, "required": False, "type": "str"}, + "tracking_object": { + "default": None, + "elements": "dict", + "options": { + "decrement": {"default": None, "required": True, "type": "int"}, + "name": {"default": None, "required": True, "type": "int"}, + "track_action": {"default": "Decrement", "required": False, "type": "str"}, + }, + "required": False, + "type": "list", + }, + "value": {"default": None, "required": True, "type": "int"}, + }, + "required": False, + "type": "list", + }, + "xconnect": {"default": None, "required": False, "type": "str"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/omp_vsmart.py b/plugins/module_utils/feature_templates/omp_vsmart.py index 3805dde..3c52c22 100644 --- a/plugins/module_utils/feature_templates/omp_vsmart.py +++ b/plugins/module_utils/feature_templates/omp_vsmart.py @@ -1,36 +1,20 @@ -omp_vsmart_definition = { 'omp_vsmart': { 'default': None, - 'options': { 'advertisement_interval': { 'default': None, - 'required': False, - 'type': 'int'}, - 'affinity_group_preference': { 'default': False, - 'required': False, - 'type': 'bool'}, - 'discard_rejected': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'eor_timer': { 'default': None, - 'required': False, - 'type': 'int'}, - 'graceful_restart': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'graceful_restart_timer': { 'default': None, - 'required': False, - 'type': 'int'}, - 'holdtime': { 'default': None, - 'required': False, - 'type': 'int'}, - 'send_backup_paths': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'send_path_limit': { 'default': None, - 'required': False, - 'type': 'int'}, - 'shutdown': { 'default': None, - 'required': False, - 'type': 'bool'}, - 'tloc_color': { 'default': False, - 'required': False, - 'type': 'bool'}}, - 'required': False, - 'type': 'dict'}} +omp_vsmart_definition = { + "omp_vsmart": { + "default": None, + "options": { + "advertisement_interval": {"default": None, "required": False, "type": "int"}, + "affinity_group_preference": {"default": False, "required": False, "type": "bool"}, + "discard_rejected": {"default": None, "required": False, "type": "bool"}, + "eor_timer": {"default": None, "required": False, "type": "int"}, + "graceful_restart": {"default": None, "required": False, "type": "bool"}, + "graceful_restart_timer": {"default": None, "required": False, "type": "int"}, + "holdtime": {"default": None, "required": False, "type": "int"}, + "send_backup_paths": {"default": None, "required": False, "type": "bool"}, + "send_path_limit": {"default": None, "required": False, "type": "int"}, + "shutdown": {"default": None, "required": False, "type": "bool"}, + "tloc_color": {"default": False, "required": False, "type": "bool"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/module_utils/feature_templates/security_vsmart.py b/plugins/module_utils/feature_templates/security_vsmart.py index f712090..d5cafb3 100644 --- a/plugins/module_utils/feature_templates/security_vsmart.py +++ b/plugins/module_utils/feature_templates/security_vsmart.py @@ -1,9 +1,11 @@ -security_vsmart_definition = { 'security_vsmart': { 'default': None, - 'options': { 'protocol': { 'default': None, - 'required': False, - 'type': 'str'}, - 'tls_port': { 'default': None, - 'required': False, - 'type': 'int'}}, - 'required': False, - 'type': 'dict'}} +security_vsmart_definition = { + "security_vsmart": { + "default": None, + "options": { + "protocol": {"default": None, "required": False, "type": "str"}, + "tls_port": {"default": None, "required": False, "type": "int"}, + }, + "required": False, + "type": "dict", + } +} diff --git a/plugins/modules/cli_templates.py b/plugins/modules/cli_templates.py index 99b7314..e1b0f85 100644 --- a/plugins/modules/cli_templates.py +++ b/plugins/modules/cli_templates.py @@ -81,7 +81,7 @@ sample: "abc123" """ -from typing import Literal, get_args +from typing import Literal, Optional, get_args from catalystwan.api.template_api import CLITemplate from catalystwan.models.common import DeviceModel @@ -134,7 +134,7 @@ def run_module(): all_templates: DataSequence[DeviceTemplateInformation] = module.get_response_safely( module.session.api.templates.get, template=CLITemplate ) - target_template: DeviceTemplateInformation = all_templates.filter(name=template_name) + target_template: Optional[DeviceTemplateInformation] = all_templates.filter(name=template_name) if module.params.get("state") == "present": # Code for checking if template name exists already diff --git a/plugins/modules/device_templates.py b/plugins/modules/device_templates.py index c23000c..c221873 100644 --- a/plugins/modules/device_templates.py +++ b/plugins/modules/device_templates.py @@ -12,7 +12,6 @@ version_added: "0.2.0" description: - This module allows you to create, delete, attach and detach Device Templates - - Device Templates can be filtered by Device Templates Info key:values. options: state: description: @@ -58,6 +57,10 @@ default: null type: list elements: str + timeout_seconds: + description: + - The timeout in seconds for attaching the template. Default is 300. + type: int hostname: description: - Hostname of the device to attach template. Available only for 0(state=attached). @@ -117,24 +120,9 @@ returned: always type: bool sample: true - -templates_info: - description: Detailed information about the templates. - returned: when templates are queried - type: dict - sample: { - "MyDeviceTemplate": { - "template_id": "abc123", - "template_name": "MyDeviceTemplate", - "template_description": "This is a device template for device configuration", - "device_type": "ISR4451", - "device_role": "sdwan-edge", - "general_templates": ["Template1", "Template2"] - } - } """ -from typing import Dict, Literal, Optional, get_args +from typing import Literal, Optional, get_args from catalystwan.api.template_api import DeviceTemplate, GeneralTemplate from catalystwan.dataclasses import Device @@ -143,7 +131,6 @@ from catalystwan.models.templates import DeviceTemplateInformation from catalystwan.session import ManagerHTTPError from catalystwan.typed_list import DataSequence -from pydantic import Field from ..module_utils.result import ModuleResult from ..module_utils.vmanage_module import AnsibleCatalystwanModule @@ -151,10 +138,6 @@ State = Literal["present", "absent", "attached"] -class ExtendedModuleResult(ModuleResult): - templates_info: Optional[Dict] = Field(default={}) - - def run_module(): module_args = dict( state=dict( @@ -179,7 +162,7 @@ def run_module(): hostname=dict(type="str"), device_specific_vars=dict(type="list", elements="dict"), ) - result = ExtendedModuleResult() + result = ModuleResult() module = AnsibleCatalystwanModule( argument_spec=module_args, diff --git a/plugins/modules/device_templates_info.py b/plugins/modules/device_templates_info.py index a2498b0..0811d2c 100644 --- a/plugins/modules/device_templates_info.py +++ b/plugins/modules/device_templates_info.py @@ -9,7 +9,7 @@ --- module: Device_templates_info short_description: Get information about Device Templates on vManage. -version_added: "0.1.0" +version_added: "0.2.0" description: - This module allows you to get Device Templates Info from vManage. - Device Templates can be filtered by Device Templates Info key:values. @@ -167,6 +167,7 @@ returned: always sample: false """ + import json import traceback from pathlib import Path, PurePath diff --git a/plugins/modules/feature_templates.py b/plugins/modules/feature_templates.py index 51104d3..56f26b8 100644 --- a/plugins/modules/feature_templates.py +++ b/plugins/modules/feature_templates.py @@ -8,7 +8,7 @@ --- module: vmanage_feature_template short_description: Manage feature templates for Cisco vManage SD-WAN -version_added: "0.1.1" +version_added: "0.2.0" description: - This module can be used to create, modify, and delete feature templates in Cisco vManage SD-WAN. - The feature template configuration is defined via Python Pydantic models. diff --git a/plugins/modules/feature_templates_info.py b/plugins/modules/feature_templates_info.py index 4de2533..23aa483 100644 --- a/plugins/modules/feature_templates_info.py +++ b/plugins/modules/feature_templates_info.py @@ -9,7 +9,7 @@ --- module: feature_templates_info short_description: Get information about Feature Templates on vManage. -version_added: "0.1.0" +version_added: "0.2.0" description: - This module allows you to get and filter Feature Templates from vManage. options: From 01acbf44ccd2495cbc0f718753c19f7f98e7ac5f Mon Sep 17 00:00:00 2001 From: acichon Date: Tue, 23 Jul 2024 16:51:42 +0200 Subject: [PATCH 18/18] module for device templates recovery --- .ansible-lint | 1 + .gitignore | 1 + playbooks/tests/test_feature_templates.yml | 1 + .../test_module_device_templates_recovery.yml | 73 +++++++ .../backup_restore_device_templates.py | 0 plugins/modules/device_templates_recovery.py | 197 ++++++++++++++++++ 6 files changed, 273 insertions(+) create mode 100644 playbooks/tests/test_module_device_templates_recovery.yml delete mode 100644 plugins/modules/backup_restore_device_templates.py create mode 100644 plugins/modules/device_templates_recovery.py diff --git a/.ansible-lint b/.ansible-lint index 210da23..a7cb38d 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -30,6 +30,7 @@ mock_modules: - cisco.catalystwan.devices_controllers - cisco.catalystwan.devices_info - cisco.catalystwan.devices_wan_edges + - cisco.catalystwan.device_templates_recovery - cisco.catalystwan.feature_templates - cisco.catalystwan.feature_templates_info - cisco.catalystwan.health_checks diff --git a/.gitignore b/.gitignore index 6160071..7abcbf0 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ playbooks/tests/catalystwan.log playbooks/tests/payload* playbooks/tests/response* playbooks/tests/backup +playbooks/tests/templates diff --git a/playbooks/tests/test_feature_templates.yml b/playbooks/tests/test_feature_templates.yml index 77aa28e..40a340b 100644 --- a/playbooks/tests/test_feature_templates.yml +++ b/playbooks/tests/test_feature_templates.yml @@ -25,6 +25,7 @@ cisco.catalystwan.feature_templates_info: filters: factory_default: false + devices_attached: 0 manager_credentials: <<: *manager_authentication register: feature_templates diff --git a/playbooks/tests/test_module_device_templates_recovery.yml b/playbooks/tests/test_module_device_templates_recovery.yml new file mode 100644 index 0000000..573a3a9 --- /dev/null +++ b/playbooks/tests/test_module_device_templates_recovery.yml @@ -0,0 +1,73 @@ +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +--- + +# Helper playbooks to test modules and flows while developing them + +# Tested operations: + +- name: Testing playbook to verify cisco.catalystwan.device_templates_recovery module operations + hosts: localhost + gather_facts: false + vars_files: + - configuration_file_dev_vars.yml + vars: + manager_authentication: &manager_authentication + url: "{{ (vmanage_instances | first).mgmt_public_ip }}" + username: "{{ (vmanage_instances | first).admin_username }}" + password: "{{ (vmanage_instances | first).admin_password }}" + tasks: + - name: 1. Perform backup of all non factory default Device Templates + cisco.catalystwan.device_templates_recovery: + mode: backup + backup_dir_path: "/Users/acichon/Work/cisco-open/ansible-collection-catalystwan/templates_export" + manager_credentials: + <<: *manager_authentication + + - name: 2. Get all Device Templates that are not attached to any device + cisco.catalystwan.device_templates_info: + filters: + devices_attached: 0 + factory_default: false + manager_credentials: + <<: *manager_authentication + register: device_templates + + - name: 3. Delete selected Device Templates from vManage + cisco.catalystwan.device_templates: + state: absent + template_name: "{{ device_template.name }}" + manager_credentials: + <<: *manager_authentication + loop: "{{ device_templates.templates_info | default([], True) }}" + loop_control: + loop_var: device_template + when: device_templates.templates_info | length > 0 + + - name: 4. Get all Non-Default Feature Templates available + cisco.catalystwan.feature_templates_info: + filters: + factory_default: false + devices_attached: 0 + manager_credentials: + <<: *manager_authentication + register: feature_templates + + - name: 5. Delete all Non-Default Feature templates + cisco.catalystwan.feature_templates: + state: absent + template_name: "{{ template.name }}" + manager_credentials: + <<: *manager_authentication + loop: "{{ feature_templates.templates_info | default([], true) }}" + loop_control: + loop_var: template + label: "template: {{ template.name }}" + + - name: 6. Restore Templates from backup directory + cisco.catalystwan.device_templates_recovery: + mode: restore + backup_dir_path: "/Users/acichon/Work/cisco-open/ansible-collection-catalystwan/templates_export" + manager_credentials: + <<: *manager_authentication diff --git a/plugins/modules/backup_restore_device_templates.py b/plugins/modules/backup_restore_device_templates.py deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/modules/device_templates_recovery.py b/plugins/modules/device_templates_recovery.py new file mode 100644 index 0000000..dbc2aed --- /dev/null +++ b/plugins/modules/device_templates_recovery.py @@ -0,0 +1,197 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2024 Cisco Systems, Inc. and its affiliates +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_templates_recovery +short_description: Backup and restore Device Templates +version_added: "0.2.0" +description: + - This module allows you to backup and restore Device Templates. + - With 0(mode=backup), it exports Device Templates (with Feature Templates and Policies) + and store them to tar archive. + - With 0(mode=restore), it extracts the templates from a tar archive, loads the JSON data for device, + feature, and policy templates, and then processes them to create or update the templates. + Templates will be extracted to Path(Path.cwd() / "templates") location. + - If 0(backup_dir_path) already exists, it will be removed and new empty director will be created. +options: + mode: + description: + - Desired recovery operation. + type: str + choices: ["backup", "restore"] + default: "backup" + backup_dir_path: + description: + - With 0(mode=backup), directory to store the backup. It's created if missing. + Defaults to a 'default_templates' folder in the current directory. + - With 0(mode=restore), directory containing the tar archive of templates. + type: path + filters: + description: + - A dictionary of filters used to select Device Templates to backup. + type: dict + required: false + suboptions: + template_type: + description: + - The type of template, eg. "system-vsmart + required: false + default: null + type: str + device_type: + description: + - The device type of the template + required: false + default: null + type: list + elements: str + name: + description: + - The name of the Device Template. + required: false + default: null + type: str + description: + description: + - Description of the Device Template. + required: false + default: null + type: str + version: + description: + - Version of the Device Template. + required: false + default: null + type: str + factory_default: + description: + - If template is Factory Default template. + required: false + default: false + type: bool + template_definiton: + description: + - The definiton of Device Template. + required: false + default: null + type: str + devices_attached: + description: + - Number of attached devices. + required: false + default: null + type: int + draft_mode: + description: + - The draft mode of template. + required: false + default: null + type: str + device_role: + description: + - The device role. + required: false + default: null + type: str + id: + description: + - Device Template ID. + required: false + default: null + type: str + last_updated_on: + description: + - Last Updated on value. + required: false + default: null + type: int + last_updated_by: + description: + - Last Updated by value. + required: false + default: null + type: str + resource_group: + description: + - Resource Group value. + required: false + default: null + type: str +author: + - Arkadiusz Cichon (acichon@cisco.com) +extends_documentation_fragment: + - cisco.catalystwan.manager_authentication +notes: + - Ensure that the provided credentials have sufficient permissions to manage templates and devices in vManage. +""" + +EXAMPLES = r""" +""" + +RETURN = r""" +""" + +from pathlib import Path, PurePath + +from catalystwan.session import ManagerHTTPError +from catalystwan.workflows import backup_restore_device_templates + +from ..module_utils.result import ModuleResult +from ..module_utils.vmanage_module import AnsibleCatalystwanModule + + +def run_module(): + module_args = dict( + mode=dict( + type=str, + choices=list(["backup", "restore"]), + default="backup", + ), + filters=dict(type="dict", default={"factory_default": False}, required=False), + backup_dir_path=dict(type="path", default=PurePath(Path.cwd() / "backup")), + ) + result = ModuleResult() + + module = AnsibleCatalystwanModule(argument_spec=module_args) + + filters = module.params.get("filters") + backup_dir_path: Path = Path(module.params.get("backup_dir_path")) + + if module.params.get("mode") == "backup": + try: + backup_restore_device_templates.export_templates( + session=module.session, + templates_directory=backup_dir_path, + filters=filters, + force_existing_dir_removal=True, + ) + except ManagerHTTPError as ex: + module.fail_json(msg=f"Could not perform Backup of Device Templates.\nManager error: {ex.info}") + result.changed = True + result.msg += f"Successfully exported and archived Device Templates to directory: {backup_dir_path}" + result.msg += "See catalystwan log file for more details." + + if module.params.get("mode") == "restore": + try: + backup_restore_device_templates.import_templates( + session=module.session, templates_directory=backup_dir_path + ) + except ManagerHTTPError as ex: + module.fail_json(msg=f"Could not perform Import of Device Templates.\nManager error: {ex.info}") + result.changed = True + result.msg += f"Successfully imported Device Templates to Manager from directory: {backup_dir_path}" + result.msg += "See catalystwan log file for more details." + + module.exit_json(**result.model_dump(mode="json")) + + +def main(): + run_module() + + +if __name__ == "__main__": + main()