Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to remove ignores and replace with module placeholder #198

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion plugins/action/common/check_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
class ActionModule(ActionBase):

def run(self, tmp=None, task_vars=None):
# self._supports_async = True
results = super(ActionModule, self).run(tmp, task_vars)
results['save_previous'] = False

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# SPDX-License-Identifier: MIT


from ...helper_functions import data_model_key_check
from ....plugin_utils.helper_functions import data_model_key_check


def update_nested_dict(nested_dict, keys, new_value):
Expand Down
1 change: 1 addition & 0 deletions plugins/action/common/prepare_plugins/prep_101_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#
# SPDX-License-Identifier: MIT


class PreparePlugin:
def __init__(self, **kwargs):
self.kwargs = kwargs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
# Group vPC interfaces by vpc_peers, vpc_id and switch_name
# This helps in identifying vPC interfaces for a given vpc_peer, vpc_id and switch_name
# Reduces the need to loop through all interfaces to find vPC interfaces in Jinja2 templates


class PreparePlugin:
def __init__(self, **kwargs):
self.kwargs = kwargs
Expand Down
2 changes: 1 addition & 1 deletion plugins/action/dtc/update_switch_hostname_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
__metaclass__ = type

from ansible.plugins.action import ActionBase
from ..helper_functions import ndfc_get_switch_policy
from ...plugin_utils.helper_functions import ndfc_get_switch_policy


class ActionModule(ActionBase):
Expand Down
Empty file added plugins/modules/.gitkeep
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,35 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# SPDX-License-Identifier: MIT

from __future__ import absolute_import, division, print_function
__metaclass__ = type


DOCUMENTATION = """
---
module: check_roles
short_description: Action plugin to check roles for create or remove.
version_added: "0.2.0"
author: Mike Wiebe (@mikewiebe)
description:
- Action plugin to check roles for create or remove.
options:
role_list:
description:
- List of roles.
required: true
type: list
elements: str
"""

EXAMPLES = """

# Perform Role Check

- name: Check Roles
cisco.nac_dc_vxlan.common.check_roles:
role_list: "{{ role_names }}"
register: check_roles

"""
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,34 @@
# SPDX-License-Identifier: MIT

from __future__ import absolute_import, division, print_function


__metaclass__ = type

from ansible.utils.display import Display
from ansible.plugins.action import ActionBase

display = Display()


class ActionModule(ActionBase):

def run(self, tmp=None, task_vars=None):
results = super(ActionModule, self).run(tmp, task_vars)
results['failed'] = False

test_data = self._task.args['test_data']['response']
model_data = self._task.args['model_data']

num_fabric_devices = len(test_data)
num_model_devices = len(model_data['vxlan']['topology']['switches'])
if num_fabric_devices != num_model_devices:
results['msg'] = 'There should be {0} switches in the fabric but only found {1}'.format(num_model_devices, num_fabric_devices)
results['failed'] = True

return results
DOCUMENTATION = """
---
module: get_credentials
short_description: Action plugin to get NDFC switch credentials and update inventory list.
version_added: "0.1.0"
author: Mike Wiebe (@mikewiebe)
description:
- Action plugin to get NDFC switch credentials and update inventory list.
options:
inv_list:
description:
- Inventory list.
required: true
type: list
elements: str
"""

EXAMPLES = """

# Get Collection NDFC Switch Credentials and Update Inventory List

- name: Retrieve NDFC Device Username and Password from Group Vars and update inv_config
cisco.nac_dc_vxlan.common.get_credentials:
inv_list: "{{ inv_config }}"
register: updated_inv_config
no_log: true

"""
65 changes: 65 additions & 0 deletions plugins/modules/common/nac_dc_validate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# SPDX-License-Identifier: MIT

from __future__ import absolute_import, division, print_function
__metaclass__ = type


DOCUMENTATION = """
---
module: nac_dc_validate
short_description: Prepare action plugin to validate the data model against the schema and return the rendered data model.
version_added: "0.1.0"
author:
- Mike Wiebe (@mikewiebe)
- Matt Tarkington (@mtarking)
description:
- Prepare action plugin to validate the data model against the schema and return the rendered data model.
options:
schema:
description:
- The path to the schema file.
required: false
type: str
mdata:
description:
- The path to the model data dir.
required: true
type: dict
rules:
description:
- The path to the rules dir.
required: false
type: str
"""

EXAMPLES = """

# Perform Required Syntax and Semantic Model Validation and Return the Model Data

- name: Perform Required Syntax and Semantic Model Validation
cisco.nac_dc_vxlan.common.nac_dc_validate:
schema: "{{ schema_path }}"
mdata: "{{ data_path }}"
rules: "{{ rules_path }}"
register: model_data

"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# SPDX-License-Identifier: MIT

from __future__ import absolute_import, division, print_function
__metaclass__ = type


DOCUMENTATION = """
---
module: prep_001_list_defaults
short_description: Prepare action plugin for list and nested list elementes of the extended data model.
version_added: "0.1.0"
author: Mike Wiebe (@mikewiebe)
description:
- Invoked from the main prepare action plugin prepare_service_model.
- Prepare action plugin for list and nested list elementes of the extended data model.
options:
inventory_hostname:
description:
- Ansible inventory_hostname.
required: true
type: str
hostvars:
description:
- Ansible runtime hostvars data.
required: true
type: dict
model_data:
description:
- The path to the data dir.
required: true
type: str
"""

EXAMPLES = """

# Prepare Data Model and Return Extended Data Model

- name: Perform Required Syntax and Semantic Model Validation
cisco.nac_dc_vxlan.common.prepare_service_model:
inventory_hostname: "{{ inventory_hostname }}"
hostvars: "{{ hostvars }}"
model_data: "{{ model_data['data'] }}"
register: smd

"""
64 changes: 64 additions & 0 deletions plugins/modules/common/prepare_plugins/prep_101_global.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# SPDX-License-Identifier: MIT

from __future__ import absolute_import, division, print_function
__metaclass__ = type


DOCUMENTATION = """
---
module: prep_101_global
short_description: Prepare action plugin for global elementes of the extended data model.
version_added: "0.1.0"
author: Mike Wiebe (@mikewiebe)
description:
- Invoked from the main prepare action plugin prepare_service_model.
- Prepare action plugin for global elementes of the extended data model.
options:
inventory_hostname:
description:
- Ansible inventory_hostname.
required: true
type: str
hostvars:
description:
- Ansible runtime hostvars data.
required: true
type: dict
model_data:
description:
- The path to the data dir.
required: true
type: str
"""

EXAMPLES = """

# Prepare Data Model and Return Extended Data Model

- name: Perform Required Syntax and Semantic Model Validation
cisco.nac_dc_vxlan.common.prepare_service_model:
inventory_hostname: "{{ inventory_hostname }}"
hostvars: "{{ hostvars }}"
model_data: "{{ model_data['data'] }}"
register: smd

"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# SPDX-License-Identifier: MIT

from __future__ import absolute_import, division, print_function
__metaclass__ = type


DOCUMENTATION = """
---
module: prep_103_topology_switches
short_description: Prepare action plugin for topology elementes of the extended data model.
version_added: "0.1.0"
author: Rameez Rahim M (@rrahimm)
description:
- Invoked from the main prepare action plugin prepare_service_model.
- Prepare action plugin for topology elementes of the extended data model.
options:
inventory_hostname:
description:
- Ansible inventory_hostname.
required: true
type: str
hostvars:
description:
- Ansible runtime hostvars data.
required: true
type: dict
model_data:
description:
- The path to the data dir.
required: true
type: str
"""

EXAMPLES = """

# Prepare Data Model and Return Extended Data Model

- name: Perform Required Syntax and Semantic Model Validation
cisco.nac_dc_vxlan.common.prepare_service_model:
inventory_hostname: "{{ inventory_hostname }}"
hostvars: "{{ hostvars }}"
model_data: "{{ model_data['data'] }}"
register: smd

"""
Loading