Access group feature added - user_role_workflow_manager#446
Conversation
| "ERROR", | ||
| ) | ||
| self.set_operation_result("failed", False, self.msg, "ERROR") | ||
| return self |
There was a problem hiding this comment.
Callers (get_diff_merged line 2358, access_group_requires_update line 5610) check if not role_id: — returning self is truthy, so the error is silently ignored and self is used as a role ID string in the API payload, causing a downstream API failure.
There was a problem hiding this comment.
updated the code
| return self | ||
|
|
||
| self.log( | ||
| "xAccess group " |
There was a problem hiding this comment.
Typo "xAccess group"
There was a problem hiding this comment.
self.log(
"Access group "
There was a problem hiding this comment.
Updated the code
| "spaces.".format(name) | ||
| ) | ||
|
|
||
| new_name = ag_config.get("new_name") |
There was a problem hiding this comment.
the update comparison and payload construction are not using the new_name.. can you check and update?
There was a problem hiding this comment.
Removed new_name parameter from the code as we will not be able to update access group name. Checked in both UI and API
| "Description update required.", | ||
| "DEBUG", | ||
| ) | ||
|
|
There was a problem hiding this comment.
Do we need to add check for new_name here?
# Check name change (rename)
desired_new_name = desired_config.get("new_name")
if desired_new_name:
current_name = current_config.get("name", "")
self.log(
"Comparing name - current: '{0}', "
"desired new_name: '{1}'".format(
current_name, desired_new_name
),
"DEBUG",
)
if desired_new_name != current_name:
update_payload["name"] = desired_new_name
update_required = True
self.log(
"access_group_requires_update: "
"Name update (rename) required.",
"DEBUG",
)
There was a problem hiding this comment.
Removed new_name parameter from the code as we will not be able to update access group name. Checked in both UI and API
| "response": { | ||
| "msg": "Role not found." | ||
| } | ||
| } |
There was a problem hiding this comment.
# Case 12: Successful creation of access group
response_12:
description: A message confirming access group creation.
returned: always
type: dict
sample:
{
"response": "Access group(s) 'Test_access_group' created successfully in Cisco Catalyst Center."
}
# Case 13: Access group already exists, no update needed
response_13:
description: A message indicating the access group needs no update.
returned: always
type: dict
sample:
{
"response": "Access group(s) 'Test_access_group' need no update in Cisco Catalyst Center."
}
Also can you please add a new line for every case?
There was a problem hiding this comment.
Updated the code
| result_msg_list.append(delete_ag_msg) | ||
|
|
||
| if self.no_deleted_access_group: | ||
| no_delete_ag_msg = ( |
There was a problem hiding this comment.
no_delete_ag_msg = (
"Access group(s) '{0}' is already absent in "
"Cisco Catalyst Center. Nothing to "
"delete.".format(
"', '".join(
self.no_deleted_access_group
)
)
)
There was a problem hiding this comment.
Updated the code
There was a problem hiding this comment.
short_description: Resource module for managing users,
roles, and access groups in Cisco Catalyst Center.
There was a problem hiding this comment.
Updated the code
| self.assertEqual( | ||
| result.get("response"), | ||
| "Invalid parameters in playbook config: role_name: Required when creating a new access group." | ||
| ) |
There was a problem hiding this comment.
def test_user_role_workflow_manager_resolve_role_api_failure(self):
"""
Verify that when get_roles raises an exception during
access group creation, the module fails gracefully with
a clear error instead of passing 'self' as a role ID.
"""
set_module_args(
dict(
dnac_host="1.1.1.1",
dnac_username="dummy",
dnac_password="dummy",
dnac_log=True,
state="merged",
config_verify=False,
dnac_version="3.1.6.0",
config=self.playbook_create_access_group,
)
)
# Mock get_access_groups to return no match,
# get_sites to succeed, get_roles to raise
self.run_dnac_exec.side_effect = [
self.test_data.get("get_access_groups"),
self.test_data.get("get_sites"),
Exception("Connection timeout"),
]
result = self.execute_module(changed=False, failed=True)
self.assertIn("role", result.get("msg", "").lower())
There was a problem hiding this comment.
Updated the code
Type of Change
Description
Summary:
Added enhancement for user_role_workflow_manager - creation, update and deletion of access group support is added from v3.1.6.0
Sample playbook:
config:
access_group_details:
- name: "Test_access_group"
description: "Updated description"
site_hierarchy: "Global/Australia"
role_name: "role_2"
Testing Done:
Test cases covered: [Mention test case IDs or brief points]
Checklist
Ansible Best Practices
ansible-vaultor environment variables)Documentation
Screenshots (if applicable)
Notes to Reviewers