Skip to content

Commit

Permalink
Merge branch 'develop' into ndfc_custom_network
Browse files Browse the repository at this point in the history
  • Loading branch information
mikewiebe authored Jul 29, 2024
2 parents 7f7563e + 8574383 commit 6408850
Show file tree
Hide file tree
Showing 200 changed files with 37,494 additions and 2,405 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
1,156 changes: 1,154 additions & 2 deletions docs/cisco.dcnm.dcnm_fabric_module.rst

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions docs/cisco.dcnm.dcnm_policy_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,26 @@ Parameters
<div>The required state of the configuration after module completion.</div>
</td>
</tr>
<tr>
<td colspan="4">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>use_desc_as_key</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
<li>yes</li>
</ul>
</td>
<td>
<div>Flag to enforce using the description parameter as the unique key for policy management.</div>
<div>When set to True, the description parameter must be unique and non-empty for each policy in the playbook. The module will also use the description to find the policy to modify or delete. If exsiting policies have the same description, the module will raise an error. If the existing policy with the matching description is using differnet template name, the module will delete the existing policy and create a new one.</div>
</td>
</tr>
</table>
<br/>

Expand Down Expand Up @@ -535,6 +555,46 @@ Examples
- switch:
- ip: "{{ ansible_switch1 }}"
# Use the description as key
# NOTE: As the description of the policy in NDFC/DCNM is not unique,
# the user must make sure no policies with the same description are created on NDFC out of the playbook.
# If the description is not unique, the module will raise an error.
## Below task will create policies with description "policy_radius" on swtich1, switch2 and switch3,
## and only create policy "feature bfd" and "feature bash-shell" on the switch1 only
- name: Create policies
cisco.dcnm.dcnm_policy:
fabric: fabric_prod
use_desc_as_key: true
config:
- name: switch_freeform
create_additional_policy: false
description: policy_radius
policy_vars:
CONF: |
radius-server host 10.1.1.2 key 7 "ljw3976!" authentication accounting
- switch:
- ip: "{{ switch1 }}"
policies:
- name: switch_freeform
create_additional_policy: false
priority: 101
description: feature bfd
policy_vars:
CONF: |
feature bfd
- name: switch_freeform
create_additional_policy: false
priority: 102
description: feature bash-shell
policy_vars:
CONF: |
feature bash-shell
- ip: "{{ switch2 }}"
- ip: "{{ switch3 }}"
Expand Down
65 changes: 33 additions & 32 deletions playbooks/roles/dcnm_fabric/dcnm_tests.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
---
# This playbook can be used to execute the dcnm_fabric test role.
#
# Replace the vars: section with details for your 2 spine, 4 leaf fabric.
# This playbook can be used to execute integration tests for
# the role located in:
#
# Modify the vars section with details for testing setup.
#
# NOTES:
# 1. For the IPFM test cases (dcnm_*_ipfm), ensure that the controller
# is running in IPFM mode. i.e. Ensure that
# Fabric Controller -> Admin -> System Settings -> Feature Management
# "IP Fabric for Media" is checked.
# 2. For all other test cases, ensure that
# Fabric Controller -> Admin -> System Settings -> Feature Management
# "Fabric Builder" is checked.
- hosts: dcnm
gather_facts: no
connection: ansible.netcommon.httpapi

vars:
# This testcase field can run any test in the tests directory for the role
testcase: spine_leaf_basic
fabric_name: fabric-name
spine1: n9k-spine1.example.com
spine2: n9k-spine2.example.com
leaf1: n9k-leaf1.example.com
leaf2: n9k-leaf2.example.com
leaf3: n9k-leaf3.example.com
leaf4: n9k-leaf4.example.com
username: admin
password: "secret-password"
# testcase: dcnm_fabric_deleted_basic
# testcase: dcnm_fabric_deleted_basic_ipfm
# testcase: dcnm_fabric_merged_basic
# testcase: dcnm_fabric_merged_basic_ipfm
# testcase: dcnm_fabric_merged_save_deploy
# testcase: dcnm_fabric_merged_save_deploy_ipfm
# testcase: dcnm_fabric_replaced_basic
# testcase: dcnm_fabric_replaced_basic_ipfm
# testcase: dcnm_fabric_replaced_save_deploy
# testcase: dcnm_fabric_replaced_save_deploy_ipfm
fabric_name_1: VXLAN_EVPN_Fabric
fabric_type_1: VXLAN_EVPN
fabric_name_2: VXLAN_EVPN_MSD_Fabric
fabric_type_2: VXLAN_EVPN_MSD
fabric_name_3: LAN_CLASSIC_Fabric
fabric_type_3: LAN_CLASSIC
fabric_name_4: IPFM_Fabric
fabric_type_4: IPFM
leaf_1: 172.22.150.103
leaf_2: 172.22.150.104
nxos_username: admin
nxos_password: myNxosPassword

roles:
- dcnm_fabric

# Uncomment the following play if you want to verify connectivity between
# host a and host c and d across the vxlan fabric setup by test spine_leaf_basic
#

# - hosts: nxos
# gather_facts: no
# connection: ansible.netcommon.network_cli
#
# tasks:
# - name: Verify IP reachability for vni 4000
# nxos_ping:
# dest: 192.168.1.20
# state: present
#
# - name: Verify IP reachability for vni 7000
# nxos_ping:
# dest: 192.168.2.20
# state: present
20 changes: 20 additions & 0 deletions playbooks/roles/dcnm_maintenance_mode/dcnm_hosts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
all:
vars:
ansible_user: "admin"
ansible_password: "password-secret"
ansible_python_interpreter: python
ansible_httpapi_validate_certs: False
ansible_httpapi_use_ssl: True
children:
dcnm:
vars:
ansible_connection: ansible.netcommon.httpapi
ansible_network_os: cisco.dcnm.dcnm
hosts:
dcnm-instance.example.com:
nxos:
hosts:
n9k-hosta.example.com:
ansible_connection: ansible.netcommon.network_cli
ansible_network_os: cisco.nxos.nxos
ansible_ssh_port: 22
42 changes: 42 additions & 0 deletions playbooks/roles/dcnm_maintenance_mode/dcnm_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# This playbook can be used to execute integration tests for
# the role located in:
#
# tests/integration/targets/dcnm_maintenance_mode
#
# Modify the vars section with details for your testing setup.
#
# NOTES:
# 1. For the IPFM test cases (dcnm_*_ipfm), ensure that the controller
# is running in IPFM mode. i.e. Ensure that
# Fabric Controller -> Admin -> System Settings -> Feature Management
# "IP Fabric for Media" is checked.
# 2. For all other test cases, ensure that
# Fabric Controller -> Admin -> System Settings -> Feature Management
# "Fabric Builder" is checked.
- hosts: dcnm
gather_facts: no
connection: ansible.netcommon.httpapi

vars:
# See the following location for available test cases:
# tests/integration/targets/dcnm_maintenance_mode/tests
# testcase: 00_setup_fabrics_1x_rw
# testcase: 00_setup_fabrics_2x_rw
# testcase: 01_merged_maintenance_mode_deploy
# testcase: 01_merged_maintenance_mode_no_deploy
fabric_name_1: VXLAN_EVPN_Fabric
fabric_type_1: VXLAN_EVPN
fabric_name_2: VXLAN_EVPN_MSD_Fabric
fabric_type_2: VXLAN_EVPN_MSD
fabric_name_3: LAN_CLASSIC_Fabric
fabric_type_3: LAN_CLASSIC
fabric_name_4: IPFM_Fabric
fabric_type_4: IPFM
leaf_1: 172.22.150.103
leaf_2: 172.22.150.104
nxos_username: admin
nxos_password: myNxosPassword

roles:
- dcnm_maintenance_mode
Empty file.
65 changes: 65 additions & 0 deletions plugins/module_utils/common/api/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright (c) 2024 Cisco and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import, division, print_function

__metaclass__ = type
__author__ = "Allen Robel"

import logging

from ansible_collections.cisco.dcnm.plugins.module_utils.common.conversion import \
ConversionUtils


class Api:
"""
## API endpoints - Api()
### Description
Common methods and properties for Api() subclasses.
### Path
``/appcenter/cisco/ndfc/api``
"""

def __init__(self):
self.class_name = self.__class__.__name__
self.log = logging.getLogger(f"dcnm.{self.class_name}")
self.conversion = ConversionUtils()
# Popuate in subclasses to indicate which properties
# are mandatory for the subclass.
self.required_properties = set()
self.log.debug("ENTERED api.Api()")
self.api = "/appcenter/cisco/ndfc/api"
self._init_properties()

def _init_properties(self):
self.properties = {}
self.properties["path"] = None
self.properties["verb"] = None

@property
def path(self):
"""
Return the endpoint path.
"""
return self.properties["path"]

@property
def verb(self):
"""
Return the endpoint verb.
"""
return self.properties["verb"]
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright (c) 2024 Cisco and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import, division, print_function

__metaclass__ = type
__author__ = "Allen Robel"

import logging

from ansible_collections.cisco.dcnm.plugins.module_utils.common.api.v1.v1 import \
V1


class ConfigTemplate(V1):
"""
## V1 API - ConfigTemplate()
### Description
Common methods and properties for api.v1.ConfigTemplate() subclasses
### Path
``/appcenter/cisco/ndfc/api/v1/configtemplate``
"""

def __init__(self):
super().__init__()
self.class_name = self.__class__.__name__
self.log = logging.getLogger(f"dcnm.{self.class_name}")
self.configtemplate = f"{self.v1}/configtemplate"
self.log.debug("ENTERED api.v1.configtemplate.ConfigTemplate()")
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (c) 2024 Cisco and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# pylint: disable=line-too-long
from __future__ import absolute_import, division, print_function

__metaclass__ = type
__author__ = "Allen Robel"

import logging

from ansible_collections.cisco.dcnm.plugins.module_utils.common.api.v1.configtemplate.rest.rest import \
Rest


class Config(Rest):
"""
## V1 API Config() - api.v1.configtemplate.rest.config.Config()
### Description
Common methods and properties for api.v1.configtemplate.rest.config.Config() subclasses.
### Path
- ``/api/v1/configtemplate/rest/config``
"""

def __init__(self):
super().__init__()
self.class_name = self.__class__.__name__
self.log = logging.getLogger(f"dcnm.{self.class_name}")
self.config = f"{self.rest}/config"
msg = f"ENTERED api.v1.rest.config.{self.class_name}"
self.log.debug(msg)
self._build_properties()

def _build_properties(self):
"""
- Populate class-specific properties.
"""
Empty file.
Loading

0 comments on commit 6408850

Please sign in to comment.