Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…talyst-center-ansible-intg into site_module_workflow
  • Loading branch information
skesali committed Nov 19, 2024
2 parents c55bc25 + 63e3d41 commit 55e45d3
Show file tree
Hide file tree
Showing 20 changed files with 1,578 additions and 523 deletions.
110 changes: 5 additions & 105 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -335,24 +335,10 @@ jobs:
export ANSIBLE_ROLES_PATH=$PWD/tests/integration
cat ccc_roles.yml
echo $(circleci tests glob "tests/integration/*")
echo -n 0 > rc
cat ccc_roles.yml | circleci tests run --command "xargs ./run_tests.sh" --split-by=timings --timings-type=name || echo -n $? > rc
echo ${LOGS_SSH_KEY} | base64 -d > ~/id_ssh
chmod 600 ~/id_ssh
export NO_PROXY=""
export no_proxy=""
ssh $LOGS_MACHINE \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-i ~/id_ssh \
mkdir -p /var/www/html/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/$CIRCLE_BUILD_NUM
scp \
-i ~/id_ssh \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
sanity_tests_logs_$CIRCLE_NODE_INDEX.log $LOGS_MACHINE:/var/www/html/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/$CIRCLE_BUILD_NUM
echo "LOGS URL: http://10.195.243.37/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/$CIRCLE_BUILD_NUM/sanity_tests_logs_$CIRCLE_NODE_INDEX.log"
if [[ $(cat rc) != "0" ]]; then exit 1; fi
env
cat run_tests.sh
find / -name run_tests.sh
cat ccc_roles.yml | circleci tests run --command "xargs ./run_tests.sh" --split-by=timings --timings-type=name
no_output_timeout: 120m

Expand All @@ -368,51 +354,6 @@ jobs:
command: |
python ${HOME}/static/pnp_script.py #TODO
main-pr:
docker:
- image: maniator/gh:v2.49.2
resource_class: cisco-en-programmability/catalyst-center-ansible-runner-main
steps:
- run:
name: Clone repo to workspace
command: git clone --depth=1 -b $CIRCLE_BRANCH https://github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME.git .
- run:
name: Create release pr to main
command: |
gh repo set-default $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
gh pr create \
--base main \
--head $CIRCLE_BRANCH \
--title "Release v<< pipeline.parameters.ansible_cisco_dnac_version >>" \
--body "Release v<< pipeline.parameters.ansible_cisco_dnac_version >>"
release-job:
docker:
- image: python:3.8.10
resource_class: cisco-en-programmability/catalyst-center-ansible-runner-main
steps:
- run:
name: Clone repo to workspace
command: |
git clone --depth=1 https://github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME.git .
git fetch origin $CIRCLE_BRANCH:work
git checkout work
- restore_cache:
keys:
- collection-<< pipeline.git.revision >>
# - add_ssh_keys:
# fingerprints:
# - "KEY_FINGERPRINT"
- run:
echo create release
# git tag \
# -a v<< pipeline.parameters.ansible_cisco_dnac_version >> \
# -m "Ansible DNACCollection Version v<< pipeline.parameters.ansible_cisco_dnac_version >>"
# gh release create "v<< pipeline.parameters.ansible_cisco_dnac_version >>" \
# --title "DNAC Collection Version v<< pipeline.parameters.ansible_cisco_dnac_version >>" \
# --latest
# ansible-galaxy collection publish workspace/*.tar.gz --api-key=$GALAXYKEY

workflows:

building:
Expand Down Expand Up @@ -483,49 +424,8 @@ workflows:
- addrole
context:
- dnac-servers
- logs-vm
# - logs-vm

# - post_pnp_testing:
# requires:
# - sanity-tests

release-candidate:
when:
or:
- equal: [run-release-prep, << pipeline.parameters.GHA_Meta >>]
jobs:
- build
- addrole:
matrix:
parameters:
run-all:
- true
- sanity-tests:
requires:
- addrole
- build
context:
- dnac-servers
- hold:
type: approval
requires:
- sanity-tests

- main-pr:
context:
- gh-token
requires:
- hold

release:
when:
or:
- equal: [run-release, << pipeline.parameters.GHA_Meta >>]
jobs:
- build
- release-job:
requires:
- build
context:
- gh-token
- galaxy-token
10 changes: 7 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
---
name: main

on:
pull_request_review:
types: [submitted]
pull_request:
# pull_request_review:
# types: [submitted]

jobs:
trigger-circleci:
if: github.event.review.state == 'approved'
# if: github.event.review.state == 'approved'
runs-on: ubuntu-20.04
steps:
- run: echo -n "${GITHUB_REF}" | sed -r 's/^refs\///' | sed -r 's/merge/head/' > github_ref
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/sanity_tests.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
---
name: CI

on:
push:
branches: [main]
schedule:
- cron: '0 6 * * *'
workflow_dispatch:

env:
NAMESPACE: cisco
COLLECTION_NAME: dnac

jobs:
# https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#ansible-core-support-matrix
# 2.14 supports Python 3.9-3.11
Expand All @@ -24,27 +28,36 @@ jobs:
- stable-2.15
- stable-2.16
- stable-2.17
- devel
runs-on: ubuntu-22.04

steps:
- name: Check out code
uses: actions/checkout@v4
with:
path: cisco-en-programmability/dnacenter-ansible

- name: Create directory
run: mkdir -p ./ansible_collections/${{env.NAMESPACE}}

- name: Move repository
run: mv ./cisco-en-programmability/dnacenter-ansible ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check

- name: Run sanity tests
run: ansible-test sanity --docker -v --color
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}

- name: Install yamllint
run: pip install --user yamllint

- name: Run yamllint
run: yamllint -c .yamllint.yml .
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
51 changes: 49 additions & 2 deletions .github/workflows/sanity_tests_devel.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
---
name: CI Devel

on:
workflow_dispatch:
pull_request:

env:
NAMESPACE: cisco
COLLECTION_NAME: dnac

jobs:
sanity:
name: Sanity (Ⓐ${{ matrix.ansible }})
Expand All @@ -13,26 +17,69 @@ jobs:
ansible:
- devel
runs-on: ubuntu-22.04

steps:
- name: Check out code
uses: actions/checkout@v4
with:
path: cisco-en-programmability/dnacenter-ansible

- name: Create directory
run: mkdir -p ./ansible_collections/${{env.NAMESPACE}}

- name: Move repository
run: mv ./cisco-en-programmability/dnacenter-ansible ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check

- name: Get changed files
id: changed_files
run: |
cd ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
git fetch origin main
git diff --name-only origin/main HEAD > changed_files.txt
echo "Changed files:"
cat changed_files.txt
- name: Run sanity tests
run: ansible-test sanity --docker -v --color
run: |
if [ -s changed_files.txt ]; then
changed_files=$(cat changed_files.txt)
for file in $changed_files; do
ansible-test sanity --docker -v --color yes $file
done
else
echo "No changed files to test."
fi
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}

- name: Install yamllint
run: pip install --user yamllint

- name: Run yamllint
run: yamllint -c .yamllint.yml .
run: |
if [ -s changed_files.txt ]; then
changed_files=$(cat changed_files.txt)
lintable_files=""
for file in $changed_files; do
# Check if the file belongs to the plugins/modules or playbooks directory
if [[ $file == plugins/modules/* || $file == playbooks/* ]]; then
lintable_files="$lintable_files $file"
fi
done
if [ -n "$lintable_files" ]; then
yamllint -c .yamllint.yml $lintable_files
else
echo "No relevant files to lint."
fi
else
echo "No changed files to lint."
fi
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
11 changes: 10 additions & 1 deletion .yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@ extends: default
ignore:
- tests
- changelogs/changelog.yaml
# - playbooks
# - playbooks
# - plugins

level: warning

rules:
syntax-error:
level: warning

line-length:
max: 160
level: warning

indentation:
level: warning

trailing-spaces:
level: warning

new-line-at-end-of-file:
level: warning

key-duplicates:
level: warning
31 changes: 31 additions & 0 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1064,3 +1064,34 @@ releases:
- Changes in dnac.py
- inventory_workflow_manager.py - added attribute hostnames, serial_numbers and mac_addresses
- inventory_workflow_manager.py - Removed attribute hostname_list, serial_number_list and mac_address_list
6.23.0:
release_date: "2024-11-06"
changes:
release_summary: Code changes in workflow manager modules.
minor_changes:
- Changes in circleci to run test cases in integration branch
- Added support for bulk operations on multiple access points in accesspoint_workflow_manager
- Bug fixes in inventory_workflow_manager
- Enhancements in sda_fabric_devices_workflow_manager.py to support route distribution protocol
- Enhancements in sda_fabric_sites_zones_workflow_manager.py
- Bug fixes in sda_fabric_virtual_networks_workflow_manager.py
- Changes in site_workflow_manager
- accesspoint_workflow_manager - added attribute bulk_update_aps
- sda_fabric_devices_workflow_manager.py - added attribute route_distribution_protocol
- sda_fabric_sites_zones_workflow_manager.py - added attribute site_name_hierarchy and removed attribute site_name
6.24.0:
release_date: "2024-11-12"
changes:
release_summary: modifications to fix issues '#200'.
minor_changes:
- Removing duplicates in the discovery.py module. snmpRwCommunity property.
- Changes in circleci to run test cases in integration branch
- Added support for bulk operations on multiple access points in accesspoint_workflow_manager
- Bug fixes in inventory_workflow_manager
- Enhancements in sda_fabric_devices_workflow_manager.py to support route distribution protocol
- Enhancements in sda_fabric_sites_zones_workflow_manager.py
- Bug fixes in sda_fabric_virtual_networks_workflow_manager.py
- Changes in site_workflow_manager
- accesspoint_workflow_manager - added attribute bulk_update_aps
- sda_fabric_devices_workflow_manager.py - added attribute route_distribution_protocol
- sda_fabric_sites_zones_workflow_manager.py - added attribute site_name_hierarchy and removed attribute site_name
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: cisco
name: dnac
version: 6.22.0
version: 6.24.0
readme: README.md
authors:
- Rafael Campos <rcampos@altus.cr>
Expand Down
1 change: 1 addition & 0 deletions plugins/action/event_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def get_object_by_id(self, id):
family="event_management",
function="get_event_subscriptions",
)
tmp_result = None
if isinstance(items, dict):
if 'response' in items:
items = items.get('response')
Expand Down
7 changes: 3 additions & 4 deletions plugins/module_utils/dnac.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def get_execution_details(self, exec_id):

def check_execution_response_status(self, response, api_name):
"""
Checks the reponse status provided by API in the Cisco Catalyst Center
Checks the response status provided by API in the Cisco Catalyst Center
Args:
response (dict) - API response
api_name (str) - API name
Expand Down Expand Up @@ -1769,10 +1769,9 @@ def set_operation_result(self, operation_status, is_changed, status_message, log
self.result.update({
"status": operation_status,
"msg": status_message,
"response": status_message,
"response": additional_info or status_message,
"changed": is_changed,
"failed": operation_status == "failed",
"data": additional_info or {} # Include additional_info if provided, else an empty dictionary
"failed": operation_status == "failed"
})

# Log the message at the specified log level
Expand Down
Loading

0 comments on commit 55e45d3

Please sign in to comment.