diff --git a/docs/conf.py b/docs/conf.py index 8122fe4d69..34275d071b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -153,4 +153,5 @@ # -- Options for intersphinx extension --------------------------------------- # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'python': ('https://docs.python.org/2', None), 'ansible': ('https://docs.ansible.com/ansible/latest/', None)} +intersphinx_mapping = {'python': ('https://docs.python.org/2', None), + 'ansible': ('https://docs.ansible.com/ansible/latest/', None)} diff --git a/plugins/action/accesspoint_configuration_details_by_task_id_info.py b/plugins/action/accesspoint_configuration_details_by_task_id_info.py index 7babbcc044..3914d10533 100644 --- a/plugins/action/accesspoint_configuration_details_by_task_id_info.py +++ b/plugins/action/accesspoint_configuration_details_by_task_id_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/app_policy_default_info.py b/plugins/action/app_policy_default_info.py index aedeafd638..d943c3c76f 100644 --- a/plugins/action/app_policy_default_info.py +++ b/plugins/action/app_policy_default_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/app_policy_info.py b/plugins/action/app_policy_info.py index d26d6ed617..75390735d0 100644 --- a/plugins/action/app_policy_info.py +++ b/plugins/action/app_policy_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/app_policy_intent_create.py b/plugins/action/app_policy_intent_create.py index f01febb2e5..d2b2f53ee2 100644 --- a/plugins/action/app_policy_intent_create.py +++ b/plugins/action/app_policy_intent_create.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/app_policy_queuing_profile.py b/plugins/action/app_policy_queuing_profile.py index f9e3a483d6..fd3aa28fc8 100644 --- a/plugins/action/app_policy_queuing_profile.py +++ b/plugins/action/app_policy_queuing_profile.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/app_policy_queuing_profile_count_info.py b/plugins/action/app_policy_queuing_profile_count_info.py index 49f2fbd955..e1053ca98d 100644 --- a/plugins/action/app_policy_queuing_profile_count_info.py +++ b/plugins/action/app_policy_queuing_profile_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/app_policy_queuing_profile_info.py b/plugins/action/app_policy_queuing_profile_info.py index 7686c3ca3d..23c05ab4e9 100644 --- a/plugins/action/app_policy_queuing_profile_info.py +++ b/plugins/action/app_policy_queuing_profile_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/app_policy_queuing_profile_v1.py b/plugins/action/app_policy_queuing_profile_v1.py index d0823d2c75..0530275ec3 100644 --- a/plugins/action/app_policy_queuing_profile_v1.py +++ b/plugins/action/app_policy_queuing_profile_v1.py @@ -126,7 +126,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -199,7 +200,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/app_policy_queuing_profile_v1_info.py b/plugins/action/app_policy_queuing_profile_v1_info.py index 5fe07973cb..b6a5abfbb0 100644 --- a/plugins/action/app_policy_queuing_profile_v1_info.py +++ b/plugins/action/app_policy_queuing_profile_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/app_policy_v1_info.py b/plugins/action/app_policy_v1_info.py index 608a01272c..b9ce628039 100644 --- a/plugins/action/app_policy_v1_info.py +++ b/plugins/action/app_policy_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/application_policy_application_set.py b/plugins/action/application_policy_application_set.py index 72bb489725..4fce53de15 100644 --- a/plugins/action/application_policy_application_set.py +++ b/plugins/action/application_policy_application_set.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/application_policy_application_set_count_info.py b/plugins/action/application_policy_application_set_count_info.py index ab6506d7e9..8bd3440abc 100644 --- a/plugins/action/application_policy_application_set_count_info.py +++ b/plugins/action/application_policy_application_set_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/application_policy_application_set_count_v2_info.py b/plugins/action/application_policy_application_set_count_v2_info.py index cf47b46051..8bcd902239 100644 --- a/plugins/action/application_policy_application_set_count_v2_info.py +++ b/plugins/action/application_policy_application_set_count_v2_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/application_policy_application_set_info.py b/plugins/action/application_policy_application_set_info.py index 9d6aaa5a8c..9bf7a85ad0 100644 --- a/plugins/action/application_policy_application_set_info.py +++ b/plugins/action/application_policy_application_set_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/application_policy_application_set_v2.py b/plugins/action/application_policy_application_set_v2.py index 07316e897a..9faeb2206f 100644 --- a/plugins/action/application_policy_application_set_v2.py +++ b/plugins/action/application_policy_application_set_v2.py @@ -3,7 +3,7 @@ # Copyright (c) 2021, Cisco Systems # 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 ansible.plugins.action import ActionBase @@ -112,7 +112,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -173,7 +174,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/application_policy_application_set_v2_info.py b/plugins/action/application_policy_application_set_v2_info.py index 705f259ec2..e3342b22cc 100644 --- a/plugins/action/application_policy_application_set_v2_info.py +++ b/plugins/action/application_policy_application_set_v2_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/application_sets.py b/plugins/action/application_sets.py index 6e9a61132a..e1aac474c5 100644 --- a/plugins/action/application_sets.py +++ b/plugins/action/application_sets.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/application_sets_count_info.py b/plugins/action/application_sets_count_info.py index bcc5a91431..6ea0f8f7ce 100644 --- a/plugins/action/application_sets_count_info.py +++ b/plugins/action/application_sets_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/application_sets_count_v1_info.py b/plugins/action/application_sets_count_v1_info.py index 7bdcb2d7fc..92e36d070c 100644 --- a/plugins/action/application_sets_count_v1_info.py +++ b/plugins/action/application_sets_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/application_sets_info.py b/plugins/action/application_sets_info.py index b7b3dc3f1f..3123593a1c 100644 --- a/plugins/action/application_sets_info.py +++ b/plugins/action/application_sets_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/application_sets_v1.py b/plugins/action/application_sets_v1.py index 58a7ff3f0a..2c91e4ce2b 100644 --- a/plugins/action/application_sets_v1.py +++ b/plugins/action/application_sets_v1.py @@ -109,7 +109,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -157,7 +158,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/application_sets_v1_info.py b/plugins/action/application_sets_v1_info.py index a854efcb9c..82cad0dcdd 100644 --- a/plugins/action/application_sets_v1_info.py +++ b/plugins/action/application_sets_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/applications.py b/plugins/action/applications.py index 8734678e5c..6e9e5e9584 100644 --- a/plugins/action/applications.py +++ b/plugins/action/applications.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/applications_count_info.py b/plugins/action/applications_count_info.py index 0c94de6461..c9a63f3b9d 100644 --- a/plugins/action/applications_count_info.py +++ b/plugins/action/applications_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/applications_count_v1_info.py b/plugins/action/applications_count_v1_info.py index 6339fe77ba..ba8ba26bd3 100644 --- a/plugins/action/applications_count_v1_info.py +++ b/plugins/action/applications_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/applications_count_v2_info.py b/plugins/action/applications_count_v2_info.py index 090ea20974..283022b099 100644 --- a/plugins/action/applications_count_v2_info.py +++ b/plugins/action/applications_count_v2_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/applications_health_info.py b/plugins/action/applications_health_info.py index baf6cc3168..3eb367ab2f 100644 --- a/plugins/action/applications_health_info.py +++ b/plugins/action/applications_health_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/applications_health_v1_info.py b/plugins/action/applications_health_v1_info.py index 6e1e743409..8c0581fc43 100644 --- a/plugins/action/applications_health_v1_info.py +++ b/plugins/action/applications_health_v1_info.py @@ -46,7 +46,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/applications_info.py b/plugins/action/applications_info.py index 193fd9beb7..e34e2f433d 100644 --- a/plugins/action/applications_info.py +++ b/plugins/action/applications_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/applications_v1.py b/plugins/action/applications_v1.py index 1731529aee..b35dcfeca9 100644 --- a/plugins/action/applications_v1.py +++ b/plugins/action/applications_v1.py @@ -126,7 +126,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -193,7 +194,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/applications_v1_info.py b/plugins/action/applications_v1_info.py index 51113d2ef3..611d7573b2 100644 --- a/plugins/action/applications_v1_info.py +++ b/plugins/action/applications_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/applications_v2.py b/plugins/action/applications_v2.py index 27d423a27c..f760c9a73d 100644 --- a/plugins/action/applications_v2.py +++ b/plugins/action/applications_v2.py @@ -129,7 +129,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -212,7 +213,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/applications_v2_info.py b/plugins/action/applications_v2_info.py index fe062ba6c5..97b6fcc90b 100644 --- a/plugins/action/applications_v2_info.py +++ b/plugins/action/applications_v2_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/areas.py b/plugins/action/areas.py index bb70c9fbbb..61834b4511 100644 --- a/plugins/action/areas.py +++ b/plugins/action/areas.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/areas_info.py b/plugins/action/areas_info.py index e6fa6f570b..414aea5496 100644 --- a/plugins/action/areas_info.py +++ b/plugins/action/areas_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/areas_v1.py b/plugins/action/areas_v1.py index 60288b9702..a2305bad6a 100644 --- a/plugins/action/areas_v1.py +++ b/plugins/action/areas_v1.py @@ -109,7 +109,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) if _id: @@ -181,7 +182,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/areas_v1_info.py b/plugins/action/areas_v1_info.py index 3cf7905ad9..02dff64687 100644 --- a/plugins/action/areas_v1_info.py +++ b/plugins/action/areas_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/assign_device_to_site.py b/plugins/action/assign_device_to_site.py index cbd0f73d54..dd7b13cabb 100644 --- a/plugins/action/assign_device_to_site.py +++ b/plugins/action/assign_device_to_site.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/assign_device_to_site_v1.py b/plugins/action/assign_device_to_site_v1.py index dc672cb636..7bdce3ce4c 100644 --- a/plugins/action/assign_device_to_site_v1.py +++ b/plugins/action/assign_device_to_site_v1.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/assign_to_site_apply.py b/plugins/action/assign_to_site_apply.py index 25f7ab83c9..5059a93545 100644 --- a/plugins/action/assign_to_site_apply.py +++ b/plugins/action/assign_to_site_apply.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/assign_to_site_apply_v1.py b/plugins/action/assign_to_site_apply_v1.py index 6d13dc4c3b..c9d512fb95 100644 --- a/plugins/action/assign_to_site_apply_v1.py +++ b/plugins/action/assign_to_site_apply_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/associate_site_to_network_profile.py b/plugins/action/associate_site_to_network_profile.py index e928964e26..0a3ac2797c 100644 --- a/plugins/action/associate_site_to_network_profile.py +++ b/plugins/action/associate_site_to_network_profile.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/associate_site_to_network_profile_v1.py b/plugins/action/associate_site_to_network_profile_v1.py index a2a4e3ad6b..aca21c3c42 100644 --- a/plugins/action/associate_site_to_network_profile_v1.py +++ b/plugins/action/associate_site_to_network_profile_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/assurance_events_child_events_info.py b/plugins/action/assurance_events_child_events_info.py index df8d1800ff..34bf206125 100644 --- a/plugins/action/assurance_events_child_events_info.py +++ b/plugins/action/assurance_events_child_events_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/assurance_events_child_events_v1_info.py b/plugins/action/assurance_events_child_events_v1_info.py index 503cb42c16..13f7113bc4 100644 --- a/plugins/action/assurance_events_child_events_v1_info.py +++ b/plugins/action/assurance_events_child_events_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/assurance_events_count_info.py b/plugins/action/assurance_events_count_info.py index a1ef235e62..b8bd5c6224 100644 --- a/plugins/action/assurance_events_count_info.py +++ b/plugins/action/assurance_events_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/assurance_events_count_v1_info.py b/plugins/action/assurance_events_count_v1_info.py index ebe15f1f67..2d8b4cfc4a 100644 --- a/plugins/action/assurance_events_count_v1_info.py +++ b/plugins/action/assurance_events_count_v1_info.py @@ -48,7 +48,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/assurance_events_info.py b/plugins/action/assurance_events_info.py index 980969421d..bcca1d79fb 100644 --- a/plugins/action/assurance_events_info.py +++ b/plugins/action/assurance_events_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/assurance_events_query.py b/plugins/action/assurance_events_query.py index 4067c3e178..d070719220 100644 --- a/plugins/action/assurance_events_query.py +++ b/plugins/action/assurance_events_query.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/assurance_events_query_count.py b/plugins/action/assurance_events_query_count.py index 5466962ef2..fbcb5de701 100644 --- a/plugins/action/assurance_events_query_count.py +++ b/plugins/action/assurance_events_query_count.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/assurance_events_query_count_v1.py b/plugins/action/assurance_events_query_count_v1.py index 1c914bdced..185e017b65 100644 --- a/plugins/action/assurance_events_query_count_v1.py +++ b/plugins/action/assurance_events_query_count_v1.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/assurance_events_query_v1.py b/plugins/action/assurance_events_query_v1.py index d4291593b6..307d7b6f33 100644 --- a/plugins/action/assurance_events_query_v1.py +++ b/plugins/action/assurance_events_query_v1.py @@ -44,7 +44,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/assurance_events_v1_info.py b/plugins/action/assurance_events_v1_info.py index e7806d66d5..3207a853b1 100644 --- a/plugins/action/assurance_events_v1_info.py +++ b/plugins/action/assurance_events_v1_info.py @@ -55,7 +55,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/assurance_get_sensor_test_results_info.py b/plugins/action/assurance_get_sensor_test_results_info.py index 4e234e241d..0b78dafbab 100644 --- a/plugins/action/assurance_get_sensor_test_results_info.py +++ b/plugins/action/assurance_get_sensor_test_results_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/assurance_get_sensor_test_results_v1_info.py b/plugins/action/assurance_get_sensor_test_results_v1_info.py index f90b2b1f9a..a30e62ee81 100644 --- a/plugins/action/assurance_get_sensor_test_results_v1_info.py +++ b/plugins/action/assurance_get_sensor_test_results_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/assurance_issues_count_info.py b/plugins/action/assurance_issues_count_info.py index acd7b09d52..dd02e4477d 100644 --- a/plugins/action/assurance_issues_count_info.py +++ b/plugins/action/assurance_issues_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/assurance_issues_count_v1_info.py b/plugins/action/assurance_issues_count_v1_info.py index 1cac4f3e55..24ba90234d 100644 --- a/plugins/action/assurance_issues_count_v1_info.py +++ b/plugins/action/assurance_issues_count_v1_info.py @@ -65,7 +65,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/assurance_issues_ignore.py b/plugins/action/assurance_issues_ignore.py index 8f6a3418eb..2073905727 100644 --- a/plugins/action/assurance_issues_ignore.py +++ b/plugins/action/assurance_issues_ignore.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/assurance_issues_ignore_v1.py b/plugins/action/assurance_issues_ignore_v1.py index 2ec7cf3c58..c49823e240 100644 --- a/plugins/action/assurance_issues_ignore_v1.py +++ b/plugins/action/assurance_issues_ignore_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/assurance_issues_info.py b/plugins/action/assurance_issues_info.py index b9ae8c9d43..11380ae975 100644 --- a/plugins/action/assurance_issues_info.py +++ b/plugins/action/assurance_issues_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/assurance_issues_query.py b/plugins/action/assurance_issues_query.py index a0050a3ac0..178ec0ecaa 100644 --- a/plugins/action/assurance_issues_query.py +++ b/plugins/action/assurance_issues_query.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/assurance_issues_query_count.py b/plugins/action/assurance_issues_query_count.py index 02b6a323c9..50d209d1ff 100644 --- a/plugins/action/assurance_issues_query_count.py +++ b/plugins/action/assurance_issues_query_count.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/assurance_issues_query_count_v1.py b/plugins/action/assurance_issues_query_count_v1.py index aa574445ca..69b83061ac 100644 --- a/plugins/action/assurance_issues_query_count_v1.py +++ b/plugins/action/assurance_issues_query_count_v1.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/assurance_issues_query_v1.py b/plugins/action/assurance_issues_query_v1.py index 2047022e19..d4534b8022 100644 --- a/plugins/action/assurance_issues_query_v1.py +++ b/plugins/action/assurance_issues_query_v1.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/assurance_issues_resolve.py b/plugins/action/assurance_issues_resolve.py index f83929266e..1735574457 100644 --- a/plugins/action/assurance_issues_resolve.py +++ b/plugins/action/assurance_issues_resolve.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/assurance_issues_resolve_v1.py b/plugins/action/assurance_issues_resolve_v1.py index 35520ff195..9781e1da33 100644 --- a/plugins/action/assurance_issues_resolve_v1.py +++ b/plugins/action/assurance_issues_resolve_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/assurance_issues_summary_analytics.py b/plugins/action/assurance_issues_summary_analytics.py index 6f03426015..24d68cea88 100644 --- a/plugins/action/assurance_issues_summary_analytics.py +++ b/plugins/action/assurance_issues_summary_analytics.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/assurance_issues_summary_analytics_v1.py b/plugins/action/assurance_issues_summary_analytics_v1.py index 27bc9e6805..c5ed364b48 100644 --- a/plugins/action/assurance_issues_summary_analytics_v1.py +++ b/plugins/action/assurance_issues_summary_analytics_v1.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/assurance_issues_top_n_analytics.py b/plugins/action/assurance_issues_top_n_analytics.py index b33079963a..54d5ce4538 100644 --- a/plugins/action/assurance_issues_top_n_analytics.py +++ b/plugins/action/assurance_issues_top_n_analytics.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/assurance_issues_top_n_analytics_v1.py b/plugins/action/assurance_issues_top_n_analytics_v1.py index d381b87b3a..207996fb6b 100644 --- a/plugins/action/assurance_issues_top_n_analytics_v1.py +++ b/plugins/action/assurance_issues_top_n_analytics_v1.py @@ -44,7 +44,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/assurance_issues_trend_analytics.py b/plugins/action/assurance_issues_trend_analytics.py index e95bbc9c09..5b048be3da 100644 --- a/plugins/action/assurance_issues_trend_analytics.py +++ b/plugins/action/assurance_issues_trend_analytics.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/assurance_issues_trend_analytics_v1.py b/plugins/action/assurance_issues_trend_analytics_v1.py index 638850fa1f..de92871d7e 100644 --- a/plugins/action/assurance_issues_trend_analytics_v1.py +++ b/plugins/action/assurance_issues_trend_analytics_v1.py @@ -44,7 +44,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/assurance_issues_update.py b/plugins/action/assurance_issues_update.py index 458a6c30c4..ecabee28fa 100644 --- a/plugins/action/assurance_issues_update.py +++ b/plugins/action/assurance_issues_update.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/assurance_issues_update_v1.py b/plugins/action/assurance_issues_update_v1.py index b807f4ccac..d29f7ca4e2 100644 --- a/plugins/action/assurance_issues_update_v1.py +++ b/plugins/action/assurance_issues_update_v1.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/assurance_issues_v1_info.py b/plugins/action/assurance_issues_v1_info.py index 0f10198d27..907f371353 100644 --- a/plugins/action/assurance_issues_v1_info.py +++ b/plugins/action/assurance_issues_v1_info.py @@ -72,7 +72,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/auth_token_create.py b/plugins/action/auth_token_create.py index 7e918aa701..52ff484e24 100644 --- a/plugins/action/auth_token_create.py +++ b/plugins/action/auth_token_create.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/auth_token_create_v1.py b/plugins/action/auth_token_create_v1.py index 1b223fdbd6..255f98c465 100644 --- a/plugins/action/auth_token_create_v1.py +++ b/plugins/action/auth_token_create_v1.py @@ -36,7 +36,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/authentication_import_certificate.py b/plugins/action/authentication_import_certificate.py index 9e2919cc51..0fdf64865e 100644 --- a/plugins/action/authentication_import_certificate.py +++ b/plugins/action/authentication_import_certificate.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/authentication_import_certificate_p12.py b/plugins/action/authentication_import_certificate_p12.py index 8f956cb29f..2bd7be8026 100644 --- a/plugins/action/authentication_import_certificate_p12.py +++ b/plugins/action/authentication_import_certificate_p12.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/authentication_import_certificate_p12_v1.py b/plugins/action/authentication_import_certificate_p12_v1.py index 31e940385e..78c87bea64 100644 --- a/plugins/action/authentication_import_certificate_p12_v1.py +++ b/plugins/action/authentication_import_certificate_p12_v1.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/authentication_import_certificate_v1.py b/plugins/action/authentication_import_certificate_v1.py index b091f1ae58..2c9d9c7e9c 100644 --- a/plugins/action/authentication_import_certificate_v1.py +++ b/plugins/action/authentication_import_certificate_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/authentication_policy_servers.py b/plugins/action/authentication_policy_servers.py index 5d72e28f9a..5e18070cfe 100644 --- a/plugins/action/authentication_policy_servers.py +++ b/plugins/action/authentication_policy_servers.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/authentication_policy_servers_info.py b/plugins/action/authentication_policy_servers_info.py index c5e7ffb9e6..592edf5aee 100644 --- a/plugins/action/authentication_policy_servers_info.py +++ b/plugins/action/authentication_policy_servers_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/authentication_policy_servers_v1.py b/plugins/action/authentication_policy_servers_v1.py index 2631e87c90..3820a51383 100644 --- a/plugins/action/authentication_policy_servers_v1.py +++ b/plugins/action/authentication_policy_servers_v1.py @@ -80,7 +80,8 @@ def __init__(self, params, dnac): encryptionScheme=params.get("encryptionScheme"), messageKey=params.get("messageKey"), encryptionKey=params.get("encryptionKey"), - externalCiscoIseIpAddrDtos=params.get("externalCiscoIseIpAddrDtos"), + externalCiscoIseIpAddrDtos=params.get( + "externalCiscoIseIpAddrDtos"), id=params.get("id"), ) @@ -95,23 +96,31 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['authenticationPort'] = self.new_object.get('authenticationPort') - new_object_params['accountingPort'] = self.new_object.get('accountingPort') + new_object_params['authenticationPort'] = self.new_object.get( + 'authenticationPort') + new_object_params['accountingPort'] = self.new_object.get( + 'accountingPort') new_object_params['ciscoIseDtos'] = self.new_object.get('ciscoIseDtos') new_object_params['ipAddress'] = self.new_object.get('ipAddress') - new_object_params['pxgridEnabled'] = self.new_object.get('pxgridEnabled') - new_object_params['useDnacCertForPxgrid'] = self.new_object.get('useDnacCertForPxgrid') + new_object_params['pxgridEnabled'] = self.new_object.get( + 'pxgridEnabled') + new_object_params['useDnacCertForPxgrid'] = self.new_object.get( + 'useDnacCertForPxgrid') new_object_params['isIseEnabled'] = self.new_object.get('isIseEnabled') new_object_params['port'] = self.new_object.get('port') new_object_params['protocol'] = self.new_object.get('protocol') new_object_params['retries'] = self.new_object.get('retries') new_object_params['role'] = self.new_object.get('role') new_object_params['sharedSecret'] = self.new_object.get('sharedSecret') - new_object_params['timeoutSeconds'] = self.new_object.get('timeoutSeconds') - new_object_params['encryptionScheme'] = self.new_object.get('encryptionScheme') + new_object_params['timeoutSeconds'] = self.new_object.get( + 'timeoutSeconds') + new_object_params['encryptionScheme'] = self.new_object.get( + 'encryptionScheme') new_object_params['messageKey'] = self.new_object.get('messageKey') - new_object_params['encryptionKey'] = self.new_object.get('encryptionKey') - new_object_params['externalCiscoIseIpAddrDtos'] = self.new_object.get('externalCiscoIseIpAddrDtos') + new_object_params['encryptionKey'] = self.new_object.get( + 'encryptionKey') + new_object_params['externalCiscoIseIpAddrDtos'] = self.new_object.get( + 'externalCiscoIseIpAddrDtos') return new_object_params def delete_by_id_params(self): @@ -121,23 +130,31 @@ def delete_by_id_params(self): def update_by_id_params(self): new_object_params = {} - new_object_params['authenticationPort'] = self.new_object.get('authenticationPort') - new_object_params['accountingPort'] = self.new_object.get('accountingPort') + new_object_params['authenticationPort'] = self.new_object.get( + 'authenticationPort') + new_object_params['accountingPort'] = self.new_object.get( + 'accountingPort') new_object_params['ciscoIseDtos'] = self.new_object.get('ciscoIseDtos') new_object_params['ipAddress'] = self.new_object.get('ipAddress') - new_object_params['pxgridEnabled'] = self.new_object.get('pxgridEnabled') - new_object_params['useDnacCertForPxgrid'] = self.new_object.get('useDnacCertForPxgrid') + new_object_params['pxgridEnabled'] = self.new_object.get( + 'pxgridEnabled') + new_object_params['useDnacCertForPxgrid'] = self.new_object.get( + 'useDnacCertForPxgrid') new_object_params['isIseEnabled'] = self.new_object.get('isIseEnabled') new_object_params['port'] = self.new_object.get('port') new_object_params['protocol'] = self.new_object.get('protocol') new_object_params['retries'] = self.new_object.get('retries') new_object_params['role'] = self.new_object.get('role') new_object_params['sharedSecret'] = self.new_object.get('sharedSecret') - new_object_params['timeoutSeconds'] = self.new_object.get('timeoutSeconds') - new_object_params['encryptionScheme'] = self.new_object.get('encryptionScheme') + new_object_params['timeoutSeconds'] = self.new_object.get( + 'timeoutSeconds') + new_object_params['encryptionScheme'] = self.new_object.get( + 'encryptionScheme') new_object_params['messageKey'] = self.new_object.get('messageKey') - new_object_params['encryptionKey'] = self.new_object.get('encryptionKey') - new_object_params['externalCiscoIseIpAddrDtos'] = self.new_object.get('externalCiscoIseIpAddrDtos') + new_object_params['encryptionKey'] = self.new_object.get( + 'encryptionKey') + new_object_params['externalCiscoIseIpAddrDtos'] = self.new_object.get( + 'externalCiscoIseIpAddrDtos') new_object_params['id'] = self.new_object.get('id') return new_object_params @@ -190,7 +207,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -275,7 +293,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/authentication_policy_servers_v1_info.py b/plugins/action/authentication_policy_servers_v1_info.py index cca3929487..b1b61442d9 100644 --- a/plugins/action/authentication_policy_servers_v1_info.py +++ b/plugins/action/authentication_policy_servers_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/buildings.py b/plugins/action/buildings.py index 47d3a8ecac..ba9c8f6a42 100644 --- a/plugins/action/buildings.py +++ b/plugins/action/buildings.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/buildings_info.py b/plugins/action/buildings_info.py index a2e2136d6a..94d42f9c0c 100644 --- a/plugins/action/buildings_info.py +++ b/plugins/action/buildings_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/buildings_planned_access_points_info.py b/plugins/action/buildings_planned_access_points_info.py index 1f7ade3c87..ca4608c526 100644 --- a/plugins/action/buildings_planned_access_points_info.py +++ b/plugins/action/buildings_planned_access_points_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/buildings_planned_access_points_v1_info.py b/plugins/action/buildings_planned_access_points_v1_info.py index a808617a56..fd69ba5746 100644 --- a/plugins/action/buildings_planned_access_points_v1_info.py +++ b/plugins/action/buildings_planned_access_points_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/buildings_v2.py b/plugins/action/buildings_v2.py index 7a8513d95c..c1b6add93e 100644 --- a/plugins/action/buildings_v2.py +++ b/plugins/action/buildings_v2.py @@ -125,7 +125,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) if _id: @@ -201,7 +202,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/buildings_v2_info.py b/plugins/action/buildings_v2_info.py index 5242ef9835..9fdf1512bc 100644 --- a/plugins/action/buildings_v2_info.py +++ b/plugins/action/buildings_v2_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/business_sda_hostonboarding_ssid_ippool.py b/plugins/action/business_sda_hostonboarding_ssid_ippool.py index 27ab9a4d8a..6944d8f026 100644 --- a/plugins/action/business_sda_hostonboarding_ssid_ippool.py +++ b/plugins/action/business_sda_hostonboarding_ssid_ippool.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/business_sda_hostonboarding_ssid_ippool_info.py b/plugins/action/business_sda_hostonboarding_ssid_ippool_info.py index 3c3676d55d..24c0fe85b6 100644 --- a/plugins/action/business_sda_hostonboarding_ssid_ippool_info.py +++ b/plugins/action/business_sda_hostonboarding_ssid_ippool_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/business_sda_hostonboarding_ssid_ippool_v1.py b/plugins/action/business_sda_hostonboarding_ssid_ippool_v1.py index b9c3ea5f86..1477a147e1 100644 --- a/plugins/action/business_sda_hostonboarding_ssid_ippool_v1.py +++ b/plugins/action/business_sda_hostonboarding_ssid_ippool_v1.py @@ -67,17 +67,21 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} new_object_params['vlanName'] = self.new_object.get('vlanName') - new_object_params['scalableGroupName'] = self.new_object.get('scalableGroupName') + new_object_params['scalableGroupName'] = self.new_object.get( + 'scalableGroupName') new_object_params['ssidNames'] = self.new_object.get('ssidNames') - new_object_params['siteNameHierarchy'] = self.new_object.get('siteNameHierarchy') + new_object_params['siteNameHierarchy'] = self.new_object.get( + 'siteNameHierarchy') return new_object_params def update_all_params(self): new_object_params = {} new_object_params['vlanName'] = self.new_object.get('vlanName') - new_object_params['scalableGroupName'] = self.new_object.get('scalableGroupName') + new_object_params['scalableGroupName'] = self.new_object.get( + 'scalableGroupName') new_object_params['ssidNames'] = self.new_object.get('ssidNames') - new_object_params['siteNameHierarchy'] = self.new_object.get('siteNameHierarchy') + new_object_params['siteNameHierarchy'] = self.new_object.get( + 'siteNameHierarchy') return new_object_params def get_object_by_name(self, name): @@ -105,7 +109,8 @@ def get_object_by_id(self, id): def exists(self): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and 'vlanName' in prev_obj + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and 'vlanName' in prev_obj return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -148,7 +153,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/business_sda_hostonboarding_ssid_ippool_v1_info.py b/plugins/action/business_sda_hostonboarding_ssid_ippool_v1_info.py index 41fdb54cc8..70abcf59a6 100644 --- a/plugins/action/business_sda_hostonboarding_ssid_ippool_v1_info.py +++ b/plugins/action/business_sda_hostonboarding_ssid_ippool_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/business_sda_virtual_network_summary_info.py b/plugins/action/business_sda_virtual_network_summary_info.py index 876df4e655..234a5fb549 100644 --- a/plugins/action/business_sda_virtual_network_summary_info.py +++ b/plugins/action/business_sda_virtual_network_summary_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/business_sda_virtual_network_summary_v1_info.py b/plugins/action/business_sda_virtual_network_summary_v1_info.py index 91b71899fc..e0eb93e01f 100644 --- a/plugins/action/business_sda_virtual_network_summary_v1_info.py +++ b/plugins/action/business_sda_virtual_network_summary_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/business_sda_wireless_controller_create.py b/plugins/action/business_sda_wireless_controller_create.py index bd0ca6834c..40ee3b5c56 100644 --- a/plugins/action/business_sda_wireless_controller_create.py +++ b/plugins/action/business_sda_wireless_controller_create.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/business_sda_wireless_controller_create_v1.py b/plugins/action/business_sda_wireless_controller_create_v1.py index e15a283424..c88b5222ad 100644 --- a/plugins/action/business_sda_wireless_controller_create_v1.py +++ b/plugins/action/business_sda_wireless_controller_create_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/business_sda_wireless_controller_delete.py b/plugins/action/business_sda_wireless_controller_delete.py index 287b454a46..2585767c79 100644 --- a/plugins/action/business_sda_wireless_controller_delete.py +++ b/plugins/action/business_sda_wireless_controller_delete.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/business_sda_wireless_controller_delete_v1.py b/plugins/action/business_sda_wireless_controller_delete_v1.py index 1318fa1f3d..b666c6d43f 100644 --- a/plugins/action/business_sda_wireless_controller_delete_v1.py +++ b/plugins/action/business_sda_wireless_controller_delete_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/client_detail_info.py b/plugins/action/client_detail_info.py index be06024a21..d82669c373 100644 --- a/plugins/action/client_detail_info.py +++ b/plugins/action/client_detail_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/client_detail_v1_info.py b/plugins/action/client_detail_v1_info.py index d09c8616e4..27f43dfc71 100644 --- a/plugins/action/client_detail_v1_info.py +++ b/plugins/action/client_detail_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/client_enrichment_details_info.py b/plugins/action/client_enrichment_details_info.py index bab9e406ff..adb4257a15 100644 --- a/plugins/action/client_enrichment_details_info.py +++ b/plugins/action/client_enrichment_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/client_enrichment_details_v1_info.py b/plugins/action/client_enrichment_details_v1_info.py index d64208fdde..0616726cc9 100644 --- a/plugins/action/client_enrichment_details_v1_info.py +++ b/plugins/action/client_enrichment_details_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/client_health_info.py b/plugins/action/client_health_info.py index 1bdd5a3720..7e6d0c3210 100644 --- a/plugins/action/client_health_info.py +++ b/plugins/action/client_health_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/client_health_v1_info.py b/plugins/action/client_health_v1_info.py index dcf9fb7049..7adb9d9123 100644 --- a/plugins/action/client_health_v1_info.py +++ b/plugins/action/client_health_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/client_proximity_info.py b/plugins/action/client_proximity_info.py index c46e56c722..e577c0e37f 100644 --- a/plugins/action/client_proximity_info.py +++ b/plugins/action/client_proximity_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/client_proximity_v1_info.py b/plugins/action/client_proximity_v1_info.py index 2f585708c2..c2af5f2a32 100644 --- a/plugins/action/client_proximity_v1_info.py +++ b/plugins/action/client_proximity_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/clients_count_info.py b/plugins/action/clients_count_info.py index d22a7cd656..84b5648eff 100644 --- a/plugins/action/clients_count_info.py +++ b/plugins/action/clients_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/clients_count_v1_info.py b/plugins/action/clients_count_v1_info.py index 628e6c1d14..fd2bc0c3fc 100644 --- a/plugins/action/clients_count_v1_info.py +++ b/plugins/action/clients_count_v1_info.py @@ -52,7 +52,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -90,7 +91,8 @@ def get_object(self, params): ipv6_address=params.get("ipv6Address"), mac_address=params.get("macAddress"), wlc_name=params.get("wlcName"), - connected_network_device_name=params.get("connectedNetworkDeviceName"), + connected_network_device_name=params.get( + "connectedNetworkDeviceName"), ssid=params.get("ssid"), band=params.get("band"), headers=params.get("headers"), diff --git a/plugins/action/clients_info.py b/plugins/action/clients_info.py index a985dae7d6..a9db849a5e 100644 --- a/plugins/action/clients_info.py +++ b/plugins/action/clients_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/clients_query.py b/plugins/action/clients_query.py index e7a6166697..1f79eea412 100644 --- a/plugins/action/clients_query.py +++ b/plugins/action/clients_query.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/clients_query_count.py b/plugins/action/clients_query_count.py index 5abe131f5f..0028f68f5c 100644 --- a/plugins/action/clients_query_count.py +++ b/plugins/action/clients_query_count.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/clients_query_count_v1.py b/plugins/action/clients_query_count_v1.py index 2fa4ff459a..3aec6cd610 100644 --- a/plugins/action/clients_query_count_v1.py +++ b/plugins/action/clients_query_count_v1.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/clients_query_v1.py b/plugins/action/clients_query_v1.py index 777d309519..4b5886a33c 100644 --- a/plugins/action/clients_query_v1.py +++ b/plugins/action/clients_query_v1.py @@ -44,7 +44,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/clients_summary_analytics.py b/plugins/action/clients_summary_analytics.py index 61e3bd233a..af0a374e46 100644 --- a/plugins/action/clients_summary_analytics.py +++ b/plugins/action/clients_summary_analytics.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/clients_summary_analytics_v1.py b/plugins/action/clients_summary_analytics_v1.py index 2217bf3397..eb1f522e65 100644 --- a/plugins/action/clients_summary_analytics_v1.py +++ b/plugins/action/clients_summary_analytics_v1.py @@ -44,7 +44,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/clients_top_n_analytics.py b/plugins/action/clients_top_n_analytics.py index 6621f06a88..d57960c2de 100644 --- a/plugins/action/clients_top_n_analytics.py +++ b/plugins/action/clients_top_n_analytics.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/clients_top_n_analytics_v1.py b/plugins/action/clients_top_n_analytics_v1.py index 121af598c4..6a8a5c1c17 100644 --- a/plugins/action/clients_top_n_analytics_v1.py +++ b/plugins/action/clients_top_n_analytics_v1.py @@ -45,7 +45,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/clients_trend_analytics.py b/plugins/action/clients_trend_analytics.py index ca6a91e550..ddda707cf1 100644 --- a/plugins/action/clients_trend_analytics.py +++ b/plugins/action/clients_trend_analytics.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/clients_trend_analytics_id.py b/plugins/action/clients_trend_analytics_id.py index 454f189871..39ac77acd7 100644 --- a/plugins/action/clients_trend_analytics_id.py +++ b/plugins/action/clients_trend_analytics_id.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/clients_trend_analytics_id_v1.py b/plugins/action/clients_trend_analytics_id_v1.py index 71e82e665e..79a7b9c01b 100644 --- a/plugins/action/clients_trend_analytics_id_v1.py +++ b/plugins/action/clients_trend_analytics_id_v1.py @@ -46,7 +46,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/clients_trend_analytics_v1.py b/plugins/action/clients_trend_analytics_v1.py index c583cdbfc2..8d2caf5e35 100644 --- a/plugins/action/clients_trend_analytics_v1.py +++ b/plugins/action/clients_trend_analytics_v1.py @@ -45,7 +45,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/clients_v1_info.py b/plugins/action/clients_v1_info.py index a34c7d2177..4a58680924 100644 --- a/plugins/action/clients_v1_info.py +++ b/plugins/action/clients_v1_info.py @@ -59,7 +59,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -101,7 +102,8 @@ def get_object(self, params): ipv6_address=params.get("ipv6Address"), mac_address=params.get("macAddress"), wlc_name=params.get("wlcName"), - connected_network_device_name=params.get("connectedNetworkDeviceName"), + connected_network_device_name=params.get( + "connectedNetworkDeviceName"), ssid=params.get("ssid"), band=params.get("band"), view=params.get("view"), diff --git a/plugins/action/command_runner_run_command.py b/plugins/action/command_runner_run_command.py index 5e1c2bbbef..0c6d094a48 100644 --- a/plugins/action/command_runner_run_command.py +++ b/plugins/action/command_runner_run_command.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/command_runner_run_command_v1.py b/plugins/action/command_runner_run_command_v1.py index bbae4f2335..06b44c1fa2 100644 --- a/plugins/action/command_runner_run_command_v1.py +++ b/plugins/action/command_runner_run_command_v1.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/compliance_check_run.py b/plugins/action/compliance_check_run.py index b32f25bfb4..d37478096b 100644 --- a/plugins/action/compliance_check_run.py +++ b/plugins/action/compliance_check_run.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/compliance_check_run_v1.py b/plugins/action/compliance_check_run_v1.py index 2cddcdf0f1..444583a887 100644 --- a/plugins/action/compliance_check_run_v1.py +++ b/plugins/action/compliance_check_run_v1.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/compliance_device.py b/plugins/action/compliance_device.py index 96a30b4ffd..687e32bec9 100644 --- a/plugins/action/compliance_device.py +++ b/plugins/action/compliance_device.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/compliance_device_by_id_info.py b/plugins/action/compliance_device_by_id_info.py index 725bb08d2b..0bd53813a7 100644 --- a/plugins/action/compliance_device_by_id_info.py +++ b/plugins/action/compliance_device_by_id_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/compliance_device_by_id_v1_info.py b/plugins/action/compliance_device_by_id_v1_info.py index 04ba649474..cb82bf3f33 100644 --- a/plugins/action/compliance_device_by_id_v1_info.py +++ b/plugins/action/compliance_device_by_id_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/compliance_device_details_count_info.py b/plugins/action/compliance_device_details_count_info.py index 2c69ac1e10..f7d125dd65 100644 --- a/plugins/action/compliance_device_details_count_info.py +++ b/plugins/action/compliance_device_details_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/compliance_device_details_count_v1_info.py b/plugins/action/compliance_device_details_count_v1_info.py index 97b83850fd..5b0ee61ad6 100644 --- a/plugins/action/compliance_device_details_count_v1_info.py +++ b/plugins/action/compliance_device_details_count_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/compliance_device_details_info.py b/plugins/action/compliance_device_details_info.py index ab35c58a27..e90ab493a9 100644 --- a/plugins/action/compliance_device_details_info.py +++ b/plugins/action/compliance_device_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/compliance_device_details_v1_info.py b/plugins/action/compliance_device_details_v1_info.py index f1645df110..0c0818fa63 100644 --- a/plugins/action/compliance_device_details_v1_info.py +++ b/plugins/action/compliance_device_details_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/compliance_device_info.py b/plugins/action/compliance_device_info.py index ed6ac8c875..efcba98c05 100644 --- a/plugins/action/compliance_device_info.py +++ b/plugins/action/compliance_device_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/compliance_device_status_count_info.py b/plugins/action/compliance_device_status_count_info.py index 564ffd8182..b3b1fe4782 100644 --- a/plugins/action/compliance_device_status_count_info.py +++ b/plugins/action/compliance_device_status_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/compliance_device_status_count_v1_info.py b/plugins/action/compliance_device_status_count_v1_info.py index fc1b0edc32..6583019ff5 100644 --- a/plugins/action/compliance_device_status_count_v1_info.py +++ b/plugins/action/compliance_device_status_count_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/compliance_device_v1.py b/plugins/action/compliance_device_v1.py index 6a9a4c996c..281d9dfa57 100644 --- a/plugins/action/compliance_device_v1.py +++ b/plugins/action/compliance_device_v1.py @@ -105,7 +105,8 @@ def exists(self): _id = prev_obj.get("id") _id = _id or prev_obj.get("deviceUuid") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) self.new_object.update(dict(device_uuid=_id)) @@ -129,7 +130,8 @@ def requires_update(self, current_obj): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/compliance_device_v1_info.py b/plugins/action/compliance_device_v1_info.py index 27814dc628..86beeb1e13 100644 --- a/plugins/action/compliance_device_v1_info.py +++ b/plugins/action/compliance_device_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/configuration_template.py b/plugins/action/configuration_template.py index feb2eca635..a2a24f054d 100644 --- a/plugins/action/configuration_template.py +++ b/plugins/action/configuration_template.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/configuration_template_clone.py b/plugins/action/configuration_template_clone.py index b551d06e22..4010b1a169 100644 --- a/plugins/action/configuration_template_clone.py +++ b/plugins/action/configuration_template_clone.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/configuration_template_clone_v1.py b/plugins/action/configuration_template_clone_v1.py index e0a8b0d3e3..3f5c6815e0 100644 --- a/plugins/action/configuration_template_clone_v1.py +++ b/plugins/action/configuration_template_clone_v1.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/configuration_template_create.py b/plugins/action/configuration_template_create.py index 7b65f63a5e..f99f4a30a8 100644 --- a/plugins/action/configuration_template_create.py +++ b/plugins/action/configuration_template_create.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/configuration_template_create_v1.py b/plugins/action/configuration_template_create_v1.py index c1709f539b..9d8d4588ef 100644 --- a/plugins/action/configuration_template_create_v1.py +++ b/plugins/action/configuration_template_create_v1.py @@ -62,7 +62,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/configuration_template_deploy.py b/plugins/action/configuration_template_deploy.py index 434bbcb8a5..57060ece79 100644 --- a/plugins/action/configuration_template_deploy.py +++ b/plugins/action/configuration_template_deploy.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/configuration_template_deploy_status_info.py b/plugins/action/configuration_template_deploy_status_info.py index 4cfeb1fce5..a380496ca9 100644 --- a/plugins/action/configuration_template_deploy_status_info.py +++ b/plugins/action/configuration_template_deploy_status_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/configuration_template_deploy_status_v1_info.py b/plugins/action/configuration_template_deploy_status_v1_info.py index 735b5f93f7..25b4796189 100644 --- a/plugins/action/configuration_template_deploy_status_v1_info.py +++ b/plugins/action/configuration_template_deploy_status_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/configuration_template_deploy_v1.py b/plugins/action/configuration_template_deploy_v1.py index a8c752fdbf..1d8b27ea3d 100644 --- a/plugins/action/configuration_template_deploy_v1.py +++ b/plugins/action/configuration_template_deploy_v1.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -71,7 +72,8 @@ def get_object(self, params): forcePushTemplate=params.get("forcePushTemplate"), isComposite=params.get("isComposite"), mainTemplateId=params.get("mainTemplateId"), - memberTemplateDeploymentInfo=params.get("memberTemplateDeploymentInfo"), + memberTemplateDeploymentInfo=params.get( + "memberTemplateDeploymentInfo"), targetInfo=params.get("targetInfo"), templateId=params.get("templateId"), ) diff --git a/plugins/action/configuration_template_deploy_v2.py b/plugins/action/configuration_template_deploy_v2.py index fe1ec9b760..0ad39ecba2 100644 --- a/plugins/action/configuration_template_deploy_v2.py +++ b/plugins/action/configuration_template_deploy_v2.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -71,7 +72,8 @@ def get_object(self, params): forcePushTemplate=params.get("forcePushTemplate"), isComposite=params.get("isComposite"), mainTemplateId=params.get("mainTemplateId"), - memberTemplateDeploymentInfo=params.get("memberTemplateDeploymentInfo"), + memberTemplateDeploymentInfo=params.get( + "memberTemplateDeploymentInfo"), targetInfo=params.get("targetInfo"), templateId=params.get("templateId"), ) diff --git a/plugins/action/configuration_template_export_project.py b/plugins/action/configuration_template_export_project.py index fd3820e15f..480287bf57 100644 --- a/plugins/action/configuration_template_export_project.py +++ b/plugins/action/configuration_template_export_project.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/configuration_template_export_project_v1.py b/plugins/action/configuration_template_export_project_v1.py index 8b9d592553..73f3089439 100644 --- a/plugins/action/configuration_template_export_project_v1.py +++ b/plugins/action/configuration_template_export_project_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/configuration_template_export_template.py b/plugins/action/configuration_template_export_template.py index 89efd64aa7..8643c331b6 100644 --- a/plugins/action/configuration_template_export_template.py +++ b/plugins/action/configuration_template_export_template.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/configuration_template_export_template_v1.py b/plugins/action/configuration_template_export_template_v1.py index cf5f70c508..22d34203d5 100644 --- a/plugins/action/configuration_template_export_template_v1.py +++ b/plugins/action/configuration_template_export_template_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/configuration_template_import_project.py b/plugins/action/configuration_template_import_project.py index 0c4fd47624..e0851a2652 100644 --- a/plugins/action/configuration_template_import_project.py +++ b/plugins/action/configuration_template_import_project.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/configuration_template_import_project_v1.py b/plugins/action/configuration_template_import_project_v1.py index e418378bde..267a3a6862 100644 --- a/plugins/action/configuration_template_import_project_v1.py +++ b/plugins/action/configuration_template_import_project_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/configuration_template_import_template.py b/plugins/action/configuration_template_import_template.py index 555ea4eff8..8817c5370a 100644 --- a/plugins/action/configuration_template_import_template.py +++ b/plugins/action/configuration_template_import_template.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/configuration_template_import_template_v1.py b/plugins/action/configuration_template_import_template_v1.py index c1fae6a03a..96dfccb05c 100644 --- a/plugins/action/configuration_template_import_template_v1.py +++ b/plugins/action/configuration_template_import_template_v1.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/configuration_template_info.py b/plugins/action/configuration_template_info.py index 0c4b436449..3383f1c7a8 100644 --- a/plugins/action/configuration_template_info.py +++ b/plugins/action/configuration_template_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/configuration_template_project.py b/plugins/action/configuration_template_project.py index 1382186e6d..29731b0dab 100644 --- a/plugins/action/configuration_template_project.py +++ b/plugins/action/configuration_template_project.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/configuration_template_project_info.py b/plugins/action/configuration_template_project_info.py index efd8f9a466..70142483fc 100644 --- a/plugins/action/configuration_template_project_info.py +++ b/plugins/action/configuration_template_project_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/configuration_template_project_v1.py b/plugins/action/configuration_template_project_v1.py index 9459934b6e..baa2ebb974 100644 --- a/plugins/action/configuration_template_project_v1.py +++ b/plugins/action/configuration_template_project_v1.py @@ -77,7 +77,8 @@ def create_params(self): new_object_params['createTime'] = self.new_object.get('createTime') new_object_params['description'] = self.new_object.get('description') new_object_params['id'] = self.new_object.get('id') - new_object_params['lastUpdateTime'] = self.new_object.get('lastUpdateTime') + new_object_params['lastUpdateTime'] = self.new_object.get( + 'lastUpdateTime') new_object_params['name'] = self.new_object.get('name') new_object_params['templates'] = self.new_object.get('templates') return new_object_params @@ -93,7 +94,8 @@ def update_all_params(self): new_object_params['createTime'] = self.new_object.get('createTime') new_object_params['description'] = self.new_object.get('description') new_object_params['id'] = self.new_object.get('id') - new_object_params['lastUpdateTime'] = self.new_object.get('lastUpdateTime') + new_object_params['lastUpdateTime'] = self.new_object.get( + 'lastUpdateTime') new_object_params['name'] = self.new_object.get('name') new_object_params['templates'] = self.new_object.get('templates') return new_object_params @@ -148,7 +150,8 @@ def exists(self): _id = prev_obj.get("id") _id = _id or prev_obj.get("projectId") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) self.new_object.update(dict(project_id=_id)) @@ -221,7 +224,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/configuration_template_project_v1_info.py b/plugins/action/configuration_template_project_v1_info.py index 02aa0343da..7579bd4561 100644 --- a/plugins/action/configuration_template_project_v1_info.py +++ b/plugins/action/configuration_template_project_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/configuration_template_v1.py b/plugins/action/configuration_template_v1.py index 6206fd2452..7cac8d5755 100644 --- a/plugins/action/configuration_template_v1.py +++ b/plugins/action/configuration_template_v1.py @@ -137,28 +137,41 @@ def update_all_params(self): new_object_params['tags'] = self.new_object.get('tags') new_object_params['author'] = self.new_object.get('author') new_object_params['composite'] = self.new_object.get('composite') - new_object_params['containingTemplates'] = self.new_object.get('containingTemplates') + new_object_params['containingTemplates'] = self.new_object.get( + 'containingTemplates') new_object_params['createTime'] = self.new_object.get('createTime') - new_object_params['customParamsOrder'] = self.new_object.get('customParamsOrder') + new_object_params['customParamsOrder'] = self.new_object.get( + 'customParamsOrder') new_object_params['description'] = self.new_object.get('description') new_object_params['deviceTypes'] = self.new_object.get('deviceTypes') - new_object_params['failurePolicy'] = self.new_object.get('failurePolicy') + new_object_params['failurePolicy'] = self.new_object.get( + 'failurePolicy') new_object_params['id'] = self.new_object.get('id') new_object_params['language'] = self.new_object.get('language') - new_object_params['lastUpdateTime'] = self.new_object.get('lastUpdateTime') - new_object_params['latestVersionTime'] = self.new_object.get('latestVersionTime') + new_object_params['lastUpdateTime'] = self.new_object.get( + 'lastUpdateTime') + new_object_params['latestVersionTime'] = self.new_object.get( + 'latestVersionTime') new_object_params['name'] = self.new_object.get('name') - new_object_params['parentTemplateId'] = self.new_object.get('parentTemplateId') + new_object_params['parentTemplateId'] = self.new_object.get( + 'parentTemplateId') new_object_params['projectId'] = self.new_object.get('projectId') new_object_params['projectName'] = self.new_object.get('projectName') - new_object_params['rollbackTemplateContent'] = self.new_object.get('rollbackTemplateContent') - new_object_params['rollbackTemplateParams'] = self.new_object.get('rollbackTemplateParams') + new_object_params['rollbackTemplateContent'] = self.new_object.get( + 'rollbackTemplateContent') + new_object_params['rollbackTemplateParams'] = self.new_object.get( + 'rollbackTemplateParams') new_object_params['softwareType'] = self.new_object.get('softwareType') - new_object_params['softwareVariant'] = self.new_object.get('softwareVariant') - new_object_params['softwareVersion'] = self.new_object.get('softwareVersion') - new_object_params['templateContent'] = self.new_object.get('templateContent') - new_object_params['templateParams'] = self.new_object.get('templateParams') - new_object_params['validationErrors'] = self.new_object.get('validationErrors') + new_object_params['softwareVariant'] = self.new_object.get( + 'softwareVariant') + new_object_params['softwareVersion'] = self.new_object.get( + 'softwareVersion') + new_object_params['templateContent'] = self.new_object.get( + 'templateContent') + new_object_params['templateParams'] = self.new_object.get( + 'templateParams') + new_object_params['validationErrors'] = self.new_object.get( + 'validationErrors') new_object_params['version'] = self.new_object.get('version') return new_object_params @@ -212,7 +225,8 @@ def exists(self): _id = prev_obj.get("id") _id = _id or prev_obj.get("templateId") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) self.new_object.update(dict(template_id=_id)) @@ -295,7 +309,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -341,7 +356,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") elif state == "absent": (obj_exists, prev_obj) = obj.exists() if obj_exists: diff --git a/plugins/action/configuration_template_v1_info.py b/plugins/action/configuration_template_v1_info.py index 2980f7a433..afb05c28ec 100644 --- a/plugins/action/configuration_template_v1_info.py +++ b/plugins/action/configuration_template_v1_info.py @@ -50,7 +50,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -82,7 +83,8 @@ def get_object(self, params): product_family=params.get("productFamily"), product_series=params.get("productSeries"), product_type=params.get("productType"), - filter_conflicting_templates=params.get("filterConflictingTemplates"), + filter_conflicting_templates=params.get( + "filterConflictingTemplates"), tags=params.get("tags"), project_names=params.get("projectNames"), un_committed=params.get("unCommitted"), diff --git a/plugins/action/configuration_template_version_create.py b/plugins/action/configuration_template_version_create.py index fcf9b1d678..fe056980e3 100644 --- a/plugins/action/configuration_template_version_create.py +++ b/plugins/action/configuration_template_version_create.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/configuration_template_version_create_v1.py b/plugins/action/configuration_template_version_create_v1.py index d4b31197e2..68e88f709e 100644 --- a/plugins/action/configuration_template_version_create_v1.py +++ b/plugins/action/configuration_template_version_create_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/configuration_template_version_info.py b/plugins/action/configuration_template_version_info.py index ef5234917d..d54596dd40 100644 --- a/plugins/action/configuration_template_version_info.py +++ b/plugins/action/configuration_template_version_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/configuration_template_version_v1_info.py b/plugins/action/configuration_template_version_v1_info.py index 6b8de881f1..716d603b66 100644 --- a/plugins/action/configuration_template_version_v1_info.py +++ b/plugins/action/configuration_template_version_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/credential_to_site_by_siteid_create.py b/plugins/action/credential_to_site_by_siteid_create.py index 010eef536a..b4eecb8017 100644 --- a/plugins/action/credential_to_site_by_siteid_create.py +++ b/plugins/action/credential_to_site_by_siteid_create.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/credential_to_site_by_siteid_create_v2.py b/plugins/action/credential_to_site_by_siteid_create_v2.py index 9c20820a32..ebca0c5607 100644 --- a/plugins/action/credential_to_site_by_siteid_create_v2.py +++ b/plugins/action/credential_to_site_by_siteid_create_v2.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/custom_issue_definitions.py b/plugins/action/custom_issue_definitions.py index b391ce2ed2..4c868017c0 100644 --- a/plugins/action/custom_issue_definitions.py +++ b/plugins/action/custom_issue_definitions.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/custom_issue_definitions_count_info.py b/plugins/action/custom_issue_definitions_count_info.py index e1798266f9..c304a6564f 100644 --- a/plugins/action/custom_issue_definitions_count_info.py +++ b/plugins/action/custom_issue_definitions_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/custom_issue_definitions_count_v1_info.py b/plugins/action/custom_issue_definitions_count_v1_info.py index 6343810463..7b3d53e9dc 100644 --- a/plugins/action/custom_issue_definitions_count_v1_info.py +++ b/plugins/action/custom_issue_definitions_count_v1_info.py @@ -45,7 +45,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/custom_issue_definitions_info.py b/plugins/action/custom_issue_definitions_info.py index c639a03347..08af7cc406 100644 --- a/plugins/action/custom_issue_definitions_info.py +++ b/plugins/action/custom_issue_definitions_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/custom_issue_definitions_v1.py b/plugins/action/custom_issue_definitions_v1.py index f2ac82f6a0..24b78df498 100644 --- a/plugins/action/custom_issue_definitions_v1.py +++ b/plugins/action/custom_issue_definitions_v1.py @@ -90,7 +90,8 @@ def create_params(self): new_object_params['rules'] = self.new_object.get('rules') new_object_params['isEnabled'] = self.new_object.get('isEnabled') new_object_params['priority'] = self.new_object.get('priority') - new_object_params['isNotificationEnabled'] = self.new_object.get('isNotificationEnabled') + new_object_params['isNotificationEnabled'] = self.new_object.get( + 'isNotificationEnabled') return new_object_params def delete_by_id_params(self): @@ -105,7 +106,8 @@ def update_by_id_params(self): new_object_params['rules'] = self.new_object.get('rules') new_object_params['isEnabled'] = self.new_object.get('isEnabled') new_object_params['priority'] = self.new_object.get('priority') - new_object_params['isNotificationEnabled'] = self.new_object.get('isNotificationEnabled') + new_object_params['isNotificationEnabled'] = self.new_object.get( + 'isNotificationEnabled') new_object_params['id'] = self.new_object.get('id') return new_object_params @@ -158,7 +160,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -233,7 +236,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/custom_issue_definitions_v1_info.py b/plugins/action/custom_issue_definitions_v1_info.py index dfb42a762d..822f63d655 100644 --- a/plugins/action/custom_issue_definitions_v1_info.py +++ b/plugins/action/custom_issue_definitions_v1_info.py @@ -49,7 +49,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/device_configurations_export.py b/plugins/action/device_configurations_export.py index a8f9d12876..2e3550c800 100644 --- a/plugins/action/device_configurations_export.py +++ b/plugins/action/device_configurations_export.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/device_configurations_export_v1.py b/plugins/action/device_configurations_export_v1.py index 93f74228a5..bfc68a6257 100644 --- a/plugins/action/device_configurations_export_v1.py +++ b/plugins/action/device_configurations_export_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/device_credential.py b/plugins/action/device_credential.py index ee6c8ed1e2..d8866c7cf2 100644 --- a/plugins/action/device_credential.py +++ b/plugins/action/device_credential.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/device_credential_info.py b/plugins/action/device_credential_info.py index 21bdafcf16..889b565598 100644 --- a/plugins/action/device_credential_info.py +++ b/plugins/action/device_credential_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/device_credential_v1.py b/plugins/action/device_credential_v1.py index 53d2b76a9c..6e30b27183 100644 --- a/plugins/action/device_credential_v1.py +++ b/plugins/action/device_credential_v1.py @@ -122,7 +122,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -184,7 +185,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/device_credential_v1_info.py b/plugins/action/device_credential_v1_info.py index 7b6b8aeaaf..125392352f 100644 --- a/plugins/action/device_credential_v1_info.py +++ b/plugins/action/device_credential_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/device_details_info.py b/plugins/action/device_details_info.py index cf913b511f..4e64f32898 100644 --- a/plugins/action/device_details_info.py +++ b/plugins/action/device_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/device_details_v1_info.py b/plugins/action/device_details_v1_info.py index 271d507a16..e2512fc131 100644 --- a/plugins/action/device_details_v1_info.py +++ b/plugins/action/device_details_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/device_enrichment_details_info.py b/plugins/action/device_enrichment_details_info.py index e3339148f2..806efc7606 100644 --- a/plugins/action/device_enrichment_details_info.py +++ b/plugins/action/device_enrichment_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/device_enrichment_details_v1_info.py b/plugins/action/device_enrichment_details_v1_info.py index 736d8199b4..364a8a1ef1 100644 --- a/plugins/action/device_enrichment_details_v1_info.py +++ b/plugins/action/device_enrichment_details_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/device_family_identifiers_details_info.py b/plugins/action/device_family_identifiers_details_info.py index 445057c3c1..66046640f5 100644 --- a/plugins/action/device_family_identifiers_details_info.py +++ b/plugins/action/device_family_identifiers_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/device_family_identifiers_details_v1_info.py b/plugins/action/device_family_identifiers_details_v1_info.py index 3b82f4e679..4e6e755c31 100644 --- a/plugins/action/device_family_identifiers_details_v1_info.py +++ b/plugins/action/device_family_identifiers_details_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/device_health_info.py b/plugins/action/device_health_info.py index 38f4762cd2..eefa46a801 100644 --- a/plugins/action/device_health_info.py +++ b/plugins/action/device_health_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/device_health_v1_info.py b/plugins/action/device_health_v1_info.py index 3601120b5b..8a26e3ec6b 100644 --- a/plugins/action/device_health_v1_info.py +++ b/plugins/action/device_health_v1_info.py @@ -44,7 +44,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/device_interface_by_ip_info.py b/plugins/action/device_interface_by_ip_info.py index f4235de3d6..675c310d19 100644 --- a/plugins/action/device_interface_by_ip_info.py +++ b/plugins/action/device_interface_by_ip_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/device_interface_by_ip_v1_info.py b/plugins/action/device_interface_by_ip_v1_info.py index cf72dba646..5d0e260bea 100644 --- a/plugins/action/device_interface_by_ip_v1_info.py +++ b/plugins/action/device_interface_by_ip_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/device_interface_count_info.py b/plugins/action/device_interface_count_info.py index d6c54d750c..beab214b68 100644 --- a/plugins/action/device_interface_count_info.py +++ b/plugins/action/device_interface_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/device_interface_count_v1_info.py b/plugins/action/device_interface_count_v1_info.py index c10bffe7cf..e1eeb9558e 100644 --- a/plugins/action/device_interface_count_v1_info.py +++ b/plugins/action/device_interface_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/device_interface_info.py b/plugins/action/device_interface_info.py index 8aa4274960..515f69daad 100644 --- a/plugins/action/device_interface_info.py +++ b/plugins/action/device_interface_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/device_interface_isis_info.py b/plugins/action/device_interface_isis_info.py index 8f939f4e1f..ac2bcc0f2f 100644 --- a/plugins/action/device_interface_isis_info.py +++ b/plugins/action/device_interface_isis_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/device_interface_isis_v1_info.py b/plugins/action/device_interface_isis_v1_info.py index a4cf6da5c4..1989186496 100644 --- a/plugins/action/device_interface_isis_v1_info.py +++ b/plugins/action/device_interface_isis_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/device_interface_ospf_info.py b/plugins/action/device_interface_ospf_info.py index ff994ab5ba..a9de353206 100644 --- a/plugins/action/device_interface_ospf_info.py +++ b/plugins/action/device_interface_ospf_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/device_interface_ospf_v1_info.py b/plugins/action/device_interface_ospf_v1_info.py index 773fc148ef..7467763496 100644 --- a/plugins/action/device_interface_ospf_v1_info.py +++ b/plugins/action/device_interface_ospf_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/device_interface_v1_info.py b/plugins/action/device_interface_v1_info.py index bb52213efc..1b3c637885 100644 --- a/plugins/action/device_interface_v1_info.py +++ b/plugins/action/device_interface_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/device_reboot_apreboot.py b/plugins/action/device_reboot_apreboot.py index a0e69ad94b..5d751e25c0 100644 --- a/plugins/action/device_reboot_apreboot.py +++ b/plugins/action/device_reboot_apreboot.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/device_reboot_apreboot_info.py b/plugins/action/device_reboot_apreboot_info.py index 6048261e75..0eafc08e3c 100644 --- a/plugins/action/device_reboot_apreboot_info.py +++ b/plugins/action/device_reboot_apreboot_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/device_reboot_apreboot_v1.py b/plugins/action/device_reboot_apreboot_v1.py index 99066a21b1..0c7898a695 100644 --- a/plugins/action/device_reboot_apreboot_v1.py +++ b/plugins/action/device_reboot_apreboot_v1.py @@ -56,7 +56,8 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['apMacAddresses'] = self.new_object.get('apMacAddresses') + new_object_params['apMacAddresses'] = self.new_object.get( + 'apMacAddresses') return new_object_params def get_object_by_name(self, name): @@ -96,7 +97,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -127,7 +129,8 @@ def create(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/device_reboot_apreboot_v1_info.py b/plugins/action/device_reboot_apreboot_v1_info.py index c8002a73b2..7ca6c522f4 100644 --- a/plugins/action/device_reboot_apreboot_v1_info.py +++ b/plugins/action/device_reboot_apreboot_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/device_replacement.py b/plugins/action/device_replacement.py index bffb77bf4b..5a86c9da84 100644 --- a/plugins/action/device_replacement.py +++ b/plugins/action/device_replacement.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/device_replacement_count_info.py b/plugins/action/device_replacement_count_info.py index 5ce6ac4368..8c83adbf0f 100644 --- a/plugins/action/device_replacement_count_info.py +++ b/plugins/action/device_replacement_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/device_replacement_count_v1_info.py b/plugins/action/device_replacement_count_v1_info.py index e168266b0f..f43bc16e01 100644 --- a/plugins/action/device_replacement_count_v1_info.py +++ b/plugins/action/device_replacement_count_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/device_replacement_deploy.py b/plugins/action/device_replacement_deploy.py index 34e0ce90fc..852a3ec5ca 100644 --- a/plugins/action/device_replacement_deploy.py +++ b/plugins/action/device_replacement_deploy.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/device_replacement_deploy_v1.py b/plugins/action/device_replacement_deploy_v1.py index 063fbe3ef0..b529b1ee2b 100644 --- a/plugins/action/device_replacement_deploy_v1.py +++ b/plugins/action/device_replacement_deploy_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -65,7 +66,8 @@ def _check_argspec(self): def get_object(self, params): new_object = dict( faultyDeviceSerialNumber=params.get("faultyDeviceSerialNumber"), - replacementDeviceSerialNumber=params.get("replacementDeviceSerialNumber"), + replacementDeviceSerialNumber=params.get( + "replacementDeviceSerialNumber"), ) return new_object diff --git a/plugins/action/device_replacement_info.py b/plugins/action/device_replacement_info.py index 10d4417a3f..f1a7c315b0 100644 --- a/plugins/action/device_replacement_info.py +++ b/plugins/action/device_replacement_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/device_replacement_v1.py b/plugins/action/device_replacement_v1.py index 631a9d9168..bc991938a2 100644 --- a/plugins/action/device_replacement_v1.py +++ b/plugins/action/device_replacement_v1.py @@ -122,7 +122,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -183,7 +184,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/device_replacement_v1_info.py b/plugins/action/device_replacement_v1_info.py index 2a3ecf124f..323a5a5e90 100644 --- a/plugins/action/device_replacement_v1_info.py +++ b/plugins/action/device_replacement_v1_info.py @@ -48,7 +48,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -76,9 +77,11 @@ def get_object(self, params): new_object = dict( faulty_device_name=params.get("faultyDeviceName"), faulty_device_platform=params.get("faultyDevicePlatform"), - replacement_device_platform=params.get("replacementDevicePlatform"), + replacement_device_platform=params.get( + "replacementDevicePlatform"), faulty_device_serial_number=params.get("faultyDeviceSerialNumber"), - replacement_device_serial_number=params.get("replacementDeviceSerialNumber"), + replacement_device_serial_number=params.get( + "replacementDeviceSerialNumber"), replacement_status=params.get("replacementStatus"), family=params.get("family"), sort_by=params.get("sortBy"), diff --git a/plugins/action/diagnostic_validation_sets_info.py b/plugins/action/diagnostic_validation_sets_info.py index 93d6dacb90..f21d58080d 100644 --- a/plugins/action/diagnostic_validation_sets_info.py +++ b/plugins/action/diagnostic_validation_sets_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/diagnostic_validation_sets_v1_info.py b/plugins/action/diagnostic_validation_sets_v1_info.py index 4d7b6adf61..61b08283ab 100644 --- a/plugins/action/diagnostic_validation_sets_v1_info.py +++ b/plugins/action/diagnostic_validation_sets_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/diagnostic_validation_workflows.py b/plugins/action/diagnostic_validation_workflows.py index a556b4af13..6527ea2ae2 100644 --- a/plugins/action/diagnostic_validation_workflows.py +++ b/plugins/action/diagnostic_validation_workflows.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/diagnostic_validation_workflows_count_info.py b/plugins/action/diagnostic_validation_workflows_count_info.py index 10f7ab82bf..3f1a6617a8 100644 --- a/plugins/action/diagnostic_validation_workflows_count_info.py +++ b/plugins/action/diagnostic_validation_workflows_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/diagnostic_validation_workflows_count_v1_info.py b/plugins/action/diagnostic_validation_workflows_count_v1_info.py index 54816f5225..e491447eb3 100644 --- a/plugins/action/diagnostic_validation_workflows_count_v1_info.py +++ b/plugins/action/diagnostic_validation_workflows_count_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/diagnostic_validation_workflows_info.py b/plugins/action/diagnostic_validation_workflows_info.py index c827eaadd9..eec6b00a64 100644 --- a/plugins/action/diagnostic_validation_workflows_info.py +++ b/plugins/action/diagnostic_validation_workflows_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/diagnostic_validation_workflows_v1.py b/plugins/action/diagnostic_validation_workflows_v1.py index 80962c0267..3718ce1b90 100644 --- a/plugins/action/diagnostic_validation_workflows_v1.py +++ b/plugins/action/diagnostic_validation_workflows_v1.py @@ -72,7 +72,8 @@ def create_params(self): new_object_params = {} new_object_params['name'] = self.new_object.get('name') new_object_params['description'] = self.new_object.get('description') - new_object_params['validationSetIds'] = self.new_object.get('validationSetIds') + new_object_params['validationSetIds'] = self.new_object.get( + 'validationSetIds') return new_object_params def delete_by_id_params(self): @@ -128,7 +129,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) if _id: @@ -182,7 +184,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/diagnostic_validation_workflows_v1_info.py b/plugins/action/diagnostic_validation_workflows_v1_info.py index 9c60a10794..c57436c037 100644 --- a/plugins/action/diagnostic_validation_workflows_v1_info.py +++ b/plugins/action/diagnostic_validation_workflows_v1_info.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/disassociate_site_to_network_profile.py b/plugins/action/disassociate_site_to_network_profile.py index 3309c549bb..f68cf272a4 100644 --- a/plugins/action/disassociate_site_to_network_profile.py +++ b/plugins/action/disassociate_site_to_network_profile.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/disassociate_site_to_network_profile_v1.py b/plugins/action/disassociate_site_to_network_profile_v1.py index 4a7782e648..f3db76074f 100644 --- a/plugins/action/disassociate_site_to_network_profile_v1.py +++ b/plugins/action/disassociate_site_to_network_profile_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/disasterrecovery_system_operationstatus_info.py b/plugins/action/disasterrecovery_system_operationstatus_info.py index 425157438e..706c6106f5 100644 --- a/plugins/action/disasterrecovery_system_operationstatus_info.py +++ b/plugins/action/disasterrecovery_system_operationstatus_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/disasterrecovery_system_operationstatus_v1_info.py b/plugins/action/disasterrecovery_system_operationstatus_v1_info.py index e0d2e72ee3..e7717a8762 100644 --- a/plugins/action/disasterrecovery_system_operationstatus_v1_info.py +++ b/plugins/action/disasterrecovery_system_operationstatus_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/disasterrecovery_system_status_info.py b/plugins/action/disasterrecovery_system_status_info.py index 74ad9bc5fc..9c1183437c 100644 --- a/plugins/action/disasterrecovery_system_status_info.py +++ b/plugins/action/disasterrecovery_system_status_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/disasterrecovery_system_status_v1_info.py b/plugins/action/disasterrecovery_system_status_v1_info.py index cc3ff7acdf..99c3fe6ca5 100644 --- a/plugins/action/disasterrecovery_system_status_v1_info.py +++ b/plugins/action/disasterrecovery_system_status_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/discovery.py b/plugins/action/discovery.py index 8182d0bf0e..11726e0043 100644 --- a/plugins/action/discovery.py +++ b/plugins/action/discovery.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/discovery_count_info.py b/plugins/action/discovery_count_info.py index d9b1bf872b..7afc41a7a5 100644 --- a/plugins/action/discovery_count_info.py +++ b/plugins/action/discovery_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/discovery_count_v1_info.py b/plugins/action/discovery_count_v1_info.py index 97ee2c8982..c0c7787ab2 100644 --- a/plugins/action/discovery_count_v1_info.py +++ b/plugins/action/discovery_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/discovery_device_count_info.py b/plugins/action/discovery_device_count_info.py index 0b7cf3a748..07b52282ae 100644 --- a/plugins/action/discovery_device_count_info.py +++ b/plugins/action/discovery_device_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/discovery_device_count_v1_info.py b/plugins/action/discovery_device_count_v1_info.py index 692e63d7d2..91b4b262af 100644 --- a/plugins/action/discovery_device_count_v1_info.py +++ b/plugins/action/discovery_device_count_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/discovery_device_info.py b/plugins/action/discovery_device_info.py index 8dda0e7fb4..182f635267 100644 --- a/plugins/action/discovery_device_info.py +++ b/plugins/action/discovery_device_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/discovery_device_range_info.py b/plugins/action/discovery_device_range_info.py index 1ae99bc94f..952395df18 100644 --- a/plugins/action/discovery_device_range_info.py +++ b/plugins/action/discovery_device_range_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/discovery_device_range_v1_info.py b/plugins/action/discovery_device_range_v1_info.py index a42bd50751..51dd9ab196 100644 --- a/plugins/action/discovery_device_range_v1_info.py +++ b/plugins/action/discovery_device_range_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/discovery_device_v1_info.py b/plugins/action/discovery_device_v1_info.py index cca2a04dcf..f50fd00567 100644 --- a/plugins/action/discovery_device_v1_info.py +++ b/plugins/action/discovery_device_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/discovery_info.py b/plugins/action/discovery_info.py index 24d7e3197b..446e442295 100644 --- a/plugins/action/discovery_info.py +++ b/plugins/action/discovery_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/discovery_job_info.py b/plugins/action/discovery_job_info.py index 1d4c14a012..f33228a350 100644 --- a/plugins/action/discovery_job_info.py +++ b/plugins/action/discovery_job_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/discovery_job_v1_info.py b/plugins/action/discovery_job_v1_info.py index 1407e8a938..dd7f592f4d 100644 --- a/plugins/action/discovery_job_v1_info.py +++ b/plugins/action/discovery_job_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/discovery_range_delete.py b/plugins/action/discovery_range_delete.py index 6e077c0ba1..c4f5544e2a 100644 --- a/plugins/action/discovery_range_delete.py +++ b/plugins/action/discovery_range_delete.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/discovery_range_delete_v1.py b/plugins/action/discovery_range_delete_v1.py index 31a4aa431e..5cb78d734b 100644 --- a/plugins/action/discovery_range_delete_v1.py +++ b/plugins/action/discovery_range_delete_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/discovery_range_info.py b/plugins/action/discovery_range_info.py index 036c68657b..7d95f8e50e 100644 --- a/plugins/action/discovery_range_info.py +++ b/plugins/action/discovery_range_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/discovery_range_v1_info.py b/plugins/action/discovery_range_v1_info.py index c4ea3abb2f..094c3b59a7 100644 --- a/plugins/action/discovery_range_v1_info.py +++ b/plugins/action/discovery_range_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/discovery_summary_info.py b/plugins/action/discovery_summary_info.py index d0abcdc322..714336c0b0 100644 --- a/plugins/action/discovery_summary_info.py +++ b/plugins/action/discovery_summary_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/discovery_summary_v1_info.py b/plugins/action/discovery_summary_v1_info.py index 76f399f328..013c5c9cb8 100644 --- a/plugins/action/discovery_summary_v1_info.py +++ b/plugins/action/discovery_summary_v1_info.py @@ -47,7 +47,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/discovery_v1.py b/plugins/action/discovery_v1.py index 771857dc48..8c7fd52ea4 100644 --- a/plugins/action/discovery_v1.py +++ b/plugins/action/discovery_v1.py @@ -127,29 +127,45 @@ def __init__(self, params, dnac): def create_params(self): new_object_params = {} new_object_params['cdpLevel'] = self.new_object.get('cdpLevel') - new_object_params['discoveryType'] = self.new_object.get('discoveryType') - new_object_params['enablePasswordList'] = self.new_object.get('enablePasswordList') - new_object_params['globalCredentialIdList'] = self.new_object.get('globalCredentialIdList') - new_object_params['httpReadCredential'] = self.new_object.get('httpReadCredential') - new_object_params['httpWriteCredential'] = self.new_object.get('httpWriteCredential') - new_object_params['ipAddressList'] = self.new_object.get('ipAddressList') + new_object_params['discoveryType'] = self.new_object.get( + 'discoveryType') + new_object_params['enablePasswordList'] = self.new_object.get( + 'enablePasswordList') + new_object_params['globalCredentialIdList'] = self.new_object.get( + 'globalCredentialIdList') + new_object_params['httpReadCredential'] = self.new_object.get( + 'httpReadCredential') + new_object_params['httpWriteCredential'] = self.new_object.get( + 'httpWriteCredential') + new_object_params['ipAddressList'] = self.new_object.get( + 'ipAddressList') new_object_params['ipFilterList'] = self.new_object.get('ipFilterList') new_object_params['lldpLevel'] = self.new_object.get('lldpLevel') new_object_params['name'] = self.new_object.get('name') new_object_params['netconfPort'] = self.new_object.get('netconfPort') new_object_params['passwordList'] = self.new_object.get('passwordList') - new_object_params['preferredMgmtIPMethod'] = self.new_object.get('preferredMgmtIPMethod') - new_object_params['protocolOrder'] = self.new_object.get('protocolOrder') + new_object_params['preferredMgmtIPMethod'] = self.new_object.get( + 'preferredMgmtIPMethod') + new_object_params['protocolOrder'] = self.new_object.get( + 'protocolOrder') new_object_params['retry'] = self.new_object.get('retry') - new_object_params['snmpAuthPassphrase'] = self.new_object.get('snmpAuthPassphrase') - new_object_params['snmpAuthProtocol'] = self.new_object.get('snmpAuthProtocol') + new_object_params['snmpAuthPassphrase'] = self.new_object.get( + 'snmpAuthPassphrase') + new_object_params['snmpAuthProtocol'] = self.new_object.get( + 'snmpAuthProtocol') new_object_params['snmpMode'] = self.new_object.get('snmpMode') - new_object_params['snmpPrivPassphrase'] = self.new_object.get('snmpPrivPassphrase') - new_object_params['snmpPrivProtocol'] = self.new_object.get('snmpPrivProtocol') - new_object_params['snmpROCommunity'] = self.new_object.get('snmpROCommunity') - new_object_params['snmpROCommunityDesc'] = self.new_object.get('snmpROCommunityDesc') - new_object_params['snmpRwCommunity'] = self.new_object.get('snmpRwCommunity') - new_object_params['snmpRwCommunityDesc'] = self.new_object.get('snmpRwCommunityDesc') + new_object_params['snmpPrivPassphrase'] = self.new_object.get( + 'snmpPrivPassphrase') + new_object_params['snmpPrivProtocol'] = self.new_object.get( + 'snmpPrivProtocol') + new_object_params['snmpROCommunity'] = self.new_object.get( + 'snmpROCommunity') + new_object_params['snmpROCommunityDesc'] = self.new_object.get( + 'snmpROCommunityDesc') + new_object_params['snmpRwCommunity'] = self.new_object.get( + 'snmpRwCommunity') + new_object_params['snmpRwCommunityDesc'] = self.new_object.get( + 'snmpRwCommunityDesc') new_object_params['snmpUserName'] = self.new_object.get('snmpUserName') new_object_params['snmpVersion'] = self.new_object.get('snmpVersion') new_object_params['timeout'] = self.new_object.get('timeout') @@ -163,38 +179,58 @@ def delete_by_id_params(self): def update_all_params(self): new_object_params = {} - new_object_params['attributeInfo'] = self.new_object.get('attributeInfo') + new_object_params['attributeInfo'] = self.new_object.get( + 'attributeInfo') new_object_params['cdpLevel'] = self.new_object.get('cdpLevel') new_object_params['deviceIds'] = self.new_object.get('deviceIds') - new_object_params['discoveryCondition'] = self.new_object.get('discoveryCondition') - new_object_params['discoveryStatus'] = self.new_object.get('discoveryStatus') - new_object_params['discoveryType'] = self.new_object.get('discoveryType') - new_object_params['enablePasswordList'] = self.new_object.get('enablePasswordList') - new_object_params['globalCredentialIdList'] = self.new_object.get('globalCredentialIdList') - new_object_params['httpReadCredential'] = self.new_object.get('httpReadCredential') - new_object_params['httpWriteCredential'] = self.new_object.get('httpWriteCredential') + new_object_params['discoveryCondition'] = self.new_object.get( + 'discoveryCondition') + new_object_params['discoveryStatus'] = self.new_object.get( + 'discoveryStatus') + new_object_params['discoveryType'] = self.new_object.get( + 'discoveryType') + new_object_params['enablePasswordList'] = self.new_object.get( + 'enablePasswordList') + new_object_params['globalCredentialIdList'] = self.new_object.get( + 'globalCredentialIdList') + new_object_params['httpReadCredential'] = self.new_object.get( + 'httpReadCredential') + new_object_params['httpWriteCredential'] = self.new_object.get( + 'httpWriteCredential') new_object_params['id'] = self.new_object.get('id') - new_object_params['ipAddressList'] = self.new_object.get('ipAddressList') + new_object_params['ipAddressList'] = self.new_object.get( + 'ipAddressList') new_object_params['ipFilterList'] = self.new_object.get('ipFilterList') new_object_params['isAutoCdp'] = self.new_object.get('isAutoCdp') new_object_params['lldpLevel'] = self.new_object.get('lldpLevel') new_object_params['name'] = self.new_object.get('name') new_object_params['netconfPort'] = self.new_object.get('netconfPort') new_object_params['numDevices'] = self.new_object.get('numDevices') - new_object_params['parentDiscoveryId'] = self.new_object.get('parentDiscoveryId') + new_object_params['parentDiscoveryId'] = self.new_object.get( + 'parentDiscoveryId') new_object_params['passwordList'] = self.new_object.get('passwordList') - new_object_params['preferredMgmtIPMethod'] = self.new_object.get('preferredMgmtIPMethod') - new_object_params['protocolOrder'] = self.new_object.get('protocolOrder') + new_object_params['preferredMgmtIPMethod'] = self.new_object.get( + 'preferredMgmtIPMethod') + new_object_params['protocolOrder'] = self.new_object.get( + 'protocolOrder') new_object_params['retryCount'] = self.new_object.get('retryCount') - new_object_params['snmpAuthPassphrase'] = self.new_object.get('snmpAuthPassphrase') - new_object_params['snmpAuthProtocol'] = self.new_object.get('snmpAuthProtocol') + new_object_params['snmpAuthPassphrase'] = self.new_object.get( + 'snmpAuthPassphrase') + new_object_params['snmpAuthProtocol'] = self.new_object.get( + 'snmpAuthProtocol') new_object_params['snmpMode'] = self.new_object.get('snmpMode') - new_object_params['snmpPrivPassphrase'] = self.new_object.get('snmpPrivPassphrase') - new_object_params['snmpPrivProtocol'] = self.new_object.get('snmpPrivProtocol') - new_object_params['snmpRoCommunity'] = self.new_object.get('snmpRoCommunity') - new_object_params['snmpRoCommunityDesc'] = self.new_object.get('snmpRoCommunityDesc') - new_object_params['snmpRwCommunity'] = self.new_object.get('snmpRwCommunity') - new_object_params['snmpRwCommunityDesc'] = self.new_object.get('snmpRwCommunityDesc') + new_object_params['snmpPrivPassphrase'] = self.new_object.get( + 'snmpPrivPassphrase') + new_object_params['snmpPrivProtocol'] = self.new_object.get( + 'snmpPrivProtocol') + new_object_params['snmpRoCommunity'] = self.new_object.get( + 'snmpRoCommunity') + new_object_params['snmpRoCommunityDesc'] = self.new_object.get( + 'snmpRoCommunityDesc') + new_object_params['snmpRwCommunity'] = self.new_object.get( + 'snmpRwCommunity') + new_object_params['snmpRwCommunityDesc'] = self.new_object.get( + 'snmpRwCommunityDesc') new_object_params['snmpUserName'] = self.new_object.get('snmpUserName') new_object_params['timeOut'] = self.new_object.get('timeOut') new_object_params['updateMgmtIp'] = self.new_object.get('updateMgmtIp') @@ -238,7 +274,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) if _id: @@ -337,7 +374,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/discovery_v1_info.py b/plugins/action/discovery_v1_info.py index 4bc808ee14..80a9811615 100644 --- a/plugins/action/discovery_v1_info.py +++ b/plugins/action/discovery_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/dna_command_runner_keywords_info.py b/plugins/action/dna_command_runner_keywords_info.py index 0b8dd49bc2..3722cc4516 100644 --- a/plugins/action/dna_command_runner_keywords_info.py +++ b/plugins/action/dna_command_runner_keywords_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/dna_command_runner_keywords_v1_info.py b/plugins/action/dna_command_runner_keywords_v1_info.py index aa942f1bb0..b5510cf670 100644 --- a/plugins/action/dna_command_runner_keywords_v1_info.py +++ b/plugins/action/dna_command_runner_keywords_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/dna_event_snmp_config_info.py b/plugins/action/dna_event_snmp_config_info.py index 220ab8fc97..76863d6f0d 100644 --- a/plugins/action/dna_event_snmp_config_info.py +++ b/plugins/action/dna_event_snmp_config_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/dna_event_snmp_config_v1_info.py b/plugins/action/dna_event_snmp_config_v1_info.py index 1509991978..95ca10f7a4 100644 --- a/plugins/action/dna_event_snmp_config_v1_info.py +++ b/plugins/action/dna_event_snmp_config_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/dnac_packages_info.py b/plugins/action/dnac_packages_info.py index 6bc9ad796d..9d2d040c7f 100644 --- a/plugins/action/dnac_packages_info.py +++ b/plugins/action/dnac_packages_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/dnac_packages_v1_info.py b/plugins/action/dnac_packages_v1_info.py index 27eeed8762..39a3c77fb1 100644 --- a/plugins/action/dnac_packages_v1_info.py +++ b/plugins/action/dnac_packages_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/dnacaap_management_execution_status_info.py b/plugins/action/dnacaap_management_execution_status_info.py index f62477f638..54d24d08a1 100644 --- a/plugins/action/dnacaap_management_execution_status_info.py +++ b/plugins/action/dnacaap_management_execution_status_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/dnacaap_management_execution_status_v1_info.py b/plugins/action/dnacaap_management_execution_status_v1_info.py index 61f3cee753..cb7a34afe7 100644 --- a/plugins/action/dnacaap_management_execution_status_v1_info.py +++ b/plugins/action/dnacaap_management_execution_status_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/endpoint_analytics_anc_policies_info.py b/plugins/action/endpoint_analytics_anc_policies_info.py index 30eb329027..34f667e14e 100644 --- a/plugins/action/endpoint_analytics_anc_policies_info.py +++ b/plugins/action/endpoint_analytics_anc_policies_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/endpoint_analytics_anc_policies_v1_info.py b/plugins/action/endpoint_analytics_anc_policies_v1_info.py index 249a5608da..7d1e90423a 100644 --- a/plugins/action/endpoint_analytics_anc_policies_v1_info.py +++ b/plugins/action/endpoint_analytics_anc_policies_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/endpoint_analytics_cmdb_endpoints.py b/plugins/action/endpoint_analytics_cmdb_endpoints.py index 049efe4b51..ceb9929ce1 100644 --- a/plugins/action/endpoint_analytics_cmdb_endpoints.py +++ b/plugins/action/endpoint_analytics_cmdb_endpoints.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/endpoint_analytics_cmdb_endpoints_v1.py b/plugins/action/endpoint_analytics_cmdb_endpoints_v1.py index 89bd14b01b..b24effc425 100644 --- a/plugins/action/endpoint_analytics_cmdb_endpoints_v1.py +++ b/plugins/action/endpoint_analytics_cmdb_endpoints_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/endpoint_analytics_dictionaries_info.py b/plugins/action/endpoint_analytics_dictionaries_info.py index 76c5de12aa..21fdb514b8 100644 --- a/plugins/action/endpoint_analytics_dictionaries_info.py +++ b/plugins/action/endpoint_analytics_dictionaries_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/endpoint_analytics_dictionaries_v1_info.py b/plugins/action/endpoint_analytics_dictionaries_v1_info.py index 0fa315c07a..4e933fe130 100644 --- a/plugins/action/endpoint_analytics_dictionaries_v1_info.py +++ b/plugins/action/endpoint_analytics_dictionaries_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/endpoint_analytics_endpoints.py b/plugins/action/endpoint_analytics_endpoints.py index 6cc8bccf5b..78db684872 100644 --- a/plugins/action/endpoint_analytics_endpoints.py +++ b/plugins/action/endpoint_analytics_endpoints.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/endpoint_analytics_endpoints_anc_policy_delete.py b/plugins/action/endpoint_analytics_endpoints_anc_policy_delete.py index 94c0c41a61..fffebe5836 100644 --- a/plugins/action/endpoint_analytics_endpoints_anc_policy_delete.py +++ b/plugins/action/endpoint_analytics_endpoints_anc_policy_delete.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/endpoint_analytics_endpoints_anc_policy_delete_v1.py b/plugins/action/endpoint_analytics_endpoints_anc_policy_delete_v1.py index 5e0c01898d..135bf165cf 100644 --- a/plugins/action/endpoint_analytics_endpoints_anc_policy_delete_v1.py +++ b/plugins/action/endpoint_analytics_endpoints_anc_policy_delete_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/endpoint_analytics_endpoints_anc_policy_update.py b/plugins/action/endpoint_analytics_endpoints_anc_policy_update.py index 1fd850053a..bdc32b530d 100644 --- a/plugins/action/endpoint_analytics_endpoints_anc_policy_update.py +++ b/plugins/action/endpoint_analytics_endpoints_anc_policy_update.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/endpoint_analytics_endpoints_anc_policy_update_v1.py b/plugins/action/endpoint_analytics_endpoints_anc_policy_update_v1.py index f91c0003d1..a406080b23 100644 --- a/plugins/action/endpoint_analytics_endpoints_anc_policy_update_v1.py +++ b/plugins/action/endpoint_analytics_endpoints_anc_policy_update_v1.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/endpoint_analytics_endpoints_count_info.py b/plugins/action/endpoint_analytics_endpoints_count_info.py index 3ab3cc425e..e4ccecc789 100644 --- a/plugins/action/endpoint_analytics_endpoints_count_info.py +++ b/plugins/action/endpoint_analytics_endpoints_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/endpoint_analytics_endpoints_count_v1_info.py b/plugins/action/endpoint_analytics_endpoints_count_v1_info.py index a737b902bd..f150f24dcb 100644 --- a/plugins/action/endpoint_analytics_endpoints_count_v1_info.py +++ b/plugins/action/endpoint_analytics_endpoints_count_v1_info.py @@ -58,7 +58,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/endpoint_analytics_endpoints_info.py b/plugins/action/endpoint_analytics_endpoints_info.py index 625d8fa4bf..dd9df906fe 100644 --- a/plugins/action/endpoint_analytics_endpoints_info.py +++ b/plugins/action/endpoint_analytics_endpoints_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/endpoint_analytics_endpoints_v1.py b/plugins/action/endpoint_analytics_endpoints_v1.py index cfe4e7323d..2bf7fa6923 100644 --- a/plugins/action/endpoint_analytics_endpoints_v1.py +++ b/plugins/action/endpoint_analytics_endpoints_v1.py @@ -112,8 +112,10 @@ def create_params(self): new_object_params = {} new_object_params['macAddress'] = self.new_object.get('macAddress') new_object_params['deviceType'] = self.new_object.get('deviceType') - new_object_params['hardwareManufacturer'] = self.new_object.get('hardwareManufacturer') - new_object_params['hardwareModel'] = self.new_object.get('hardwareModel') + new_object_params['hardwareManufacturer'] = self.new_object.get( + 'hardwareManufacturer') + new_object_params['hardwareModel'] = self.new_object.get( + 'hardwareModel') return new_object_params def delete_by_id_params(self): @@ -124,8 +126,10 @@ def delete_by_id_params(self): def update_by_id_params(self): new_object_params = {} new_object_params['deviceType'] = self.new_object.get('deviceType') - new_object_params['hardwareManufacturer'] = self.new_object.get('hardwareManufacturer') - new_object_params['hardwareModel'] = self.new_object.get('hardwareModel') + new_object_params['hardwareManufacturer'] = self.new_object.get( + 'hardwareManufacturer') + new_object_params['hardwareModel'] = self.new_object.get( + 'hardwareModel') new_object_params['epId'] = self.new_object.get('epId') return new_object_params @@ -179,7 +183,8 @@ def exists(self): _id = prev_obj.get("id") _id = _id or prev_obj.get("epId") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) self.new_object.update(dict(ep_id=_id)) @@ -258,7 +263,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/endpoint_analytics_endpoints_v1_info.py b/plugins/action/endpoint_analytics_endpoints_v1_info.py index a789a08c3a..2ba63c0384 100644 --- a/plugins/action/endpoint_analytics_endpoints_v1_info.py +++ b/plugins/action/endpoint_analytics_endpoints_v1_info.py @@ -64,7 +64,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/endpoint_analytics_profiling_rules.py b/plugins/action/endpoint_analytics_profiling_rules.py index 00268c4c38..2927719276 100644 --- a/plugins/action/endpoint_analytics_profiling_rules.py +++ b/plugins/action/endpoint_analytics_profiling_rules.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/endpoint_analytics_profiling_rules_bulk.py b/plugins/action/endpoint_analytics_profiling_rules_bulk.py index 806e75fe10..9e206db26b 100644 --- a/plugins/action/endpoint_analytics_profiling_rules_bulk.py +++ b/plugins/action/endpoint_analytics_profiling_rules_bulk.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/endpoint_analytics_profiling_rules_bulk_v1.py b/plugins/action/endpoint_analytics_profiling_rules_bulk_v1.py index 6a1c5a0449..fcf98b4e5a 100644 --- a/plugins/action/endpoint_analytics_profiling_rules_bulk_v1.py +++ b/plugins/action/endpoint_analytics_profiling_rules_bulk_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/endpoint_analytics_profiling_rules_count_info.py b/plugins/action/endpoint_analytics_profiling_rules_count_info.py index fdd8c5a36c..7231e51715 100644 --- a/plugins/action/endpoint_analytics_profiling_rules_count_info.py +++ b/plugins/action/endpoint_analytics_profiling_rules_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/endpoint_analytics_profiling_rules_count_v1_info.py b/plugins/action/endpoint_analytics_profiling_rules_count_v1_info.py index a2e467f666..37d0f91f85 100644 --- a/plugins/action/endpoint_analytics_profiling_rules_count_v1_info.py +++ b/plugins/action/endpoint_analytics_profiling_rules_count_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/endpoint_analytics_profiling_rules_info.py b/plugins/action/endpoint_analytics_profiling_rules_info.py index 5d4c16aeb0..cbffc24113 100644 --- a/plugins/action/endpoint_analytics_profiling_rules_info.py +++ b/plugins/action/endpoint_analytics_profiling_rules_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/endpoint_analytics_profiling_rules_v1.py b/plugins/action/endpoint_analytics_profiling_rules_v1.py index 513e7f1dee..fba93f44bb 100644 --- a/plugins/action/endpoint_analytics_profiling_rules_v1.py +++ b/plugins/action/endpoint_analytics_profiling_rules_v1.py @@ -99,16 +99,21 @@ def create_params(self): new_object_params['ruleType'] = self.new_object.get('ruleType') new_object_params['ruleVersion'] = self.new_object.get('ruleVersion') new_object_params['rulePriority'] = self.new_object.get('rulePriority') - new_object_params['sourcePriority'] = self.new_object.get('sourcePriority') + new_object_params['sourcePriority'] = self.new_object.get( + 'sourcePriority') new_object_params['isDeleted'] = self.new_object.get('isDeleted') - new_object_params['lastModifiedBy'] = self.new_object.get('lastModifiedBy') - new_object_params['lastModifiedOn'] = self.new_object.get('lastModifiedOn') + new_object_params['lastModifiedBy'] = self.new_object.get( + 'lastModifiedBy') + new_object_params['lastModifiedOn'] = self.new_object.get( + 'lastModifiedOn') new_object_params['pluginId'] = self.new_object.get('pluginId') new_object_params['clusterId'] = self.new_object.get('clusterId') new_object_params['rejected'] = self.new_object.get('rejected') new_object_params['result'] = self.new_object.get('result') - new_object_params['conditionGroups'] = self.new_object.get('conditionGroups') - new_object_params['usedAttributes'] = self.new_object.get('usedAttributes') + new_object_params['conditionGroups'] = self.new_object.get( + 'conditionGroups') + new_object_params['usedAttributes'] = self.new_object.get( + 'usedAttributes') return new_object_params def delete_by_id_params(self): @@ -123,16 +128,21 @@ def update_by_id_params(self): new_object_params['ruleType'] = self.new_object.get('ruleType') new_object_params['ruleVersion'] = self.new_object.get('ruleVersion') new_object_params['rulePriority'] = self.new_object.get('rulePriority') - new_object_params['sourcePriority'] = self.new_object.get('sourcePriority') + new_object_params['sourcePriority'] = self.new_object.get( + 'sourcePriority') new_object_params['isDeleted'] = self.new_object.get('isDeleted') - new_object_params['lastModifiedBy'] = self.new_object.get('lastModifiedBy') - new_object_params['lastModifiedOn'] = self.new_object.get('lastModifiedOn') + new_object_params['lastModifiedBy'] = self.new_object.get( + 'lastModifiedBy') + new_object_params['lastModifiedOn'] = self.new_object.get( + 'lastModifiedOn') new_object_params['pluginId'] = self.new_object.get('pluginId') new_object_params['clusterId'] = self.new_object.get('clusterId') new_object_params['rejected'] = self.new_object.get('rejected') new_object_params['result'] = self.new_object.get('result') - new_object_params['conditionGroups'] = self.new_object.get('conditionGroups') - new_object_params['usedAttributes'] = self.new_object.get('usedAttributes') + new_object_params['conditionGroups'] = self.new_object.get( + 'conditionGroups') + new_object_params['usedAttributes'] = self.new_object.get( + 'usedAttributes') return new_object_params def get_object_by_name(self, name): @@ -185,7 +195,8 @@ def exists(self): _id = prev_obj.get("id") _id = _id or prev_obj.get("ruleId") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) self.new_object.update(dict(rule_id=_id)) @@ -275,7 +286,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/endpoint_analytics_profiling_rules_v1_info.py b/plugins/action/endpoint_analytics_profiling_rules_v1_info.py index 1c1cd50dea..f5b7761b54 100644 --- a/plugins/action/endpoint_analytics_profiling_rules_v1_info.py +++ b/plugins/action/endpoint_analytics_profiling_rules_v1_info.py @@ -44,7 +44,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/endpoint_analytics_tasks_info.py b/plugins/action/endpoint_analytics_tasks_info.py index b76b420fb4..4561f2c7f7 100644 --- a/plugins/action/endpoint_analytics_tasks_info.py +++ b/plugins/action/endpoint_analytics_tasks_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/endpoint_analytics_tasks_v1_info.py b/plugins/action/endpoint_analytics_tasks_v1_info.py index 54a19513fd..af7ec5b4da 100644 --- a/plugins/action/endpoint_analytics_tasks_v1_info.py +++ b/plugins/action/endpoint_analytics_tasks_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/eox_status_device_info.py b/plugins/action/eox_status_device_info.py index 11e18f3155..31a4486a83 100644 --- a/plugins/action/eox_status_device_info.py +++ b/plugins/action/eox_status_device_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/eox_status_device_v1_info.py b/plugins/action/eox_status_device_v1_info.py index ac79c3c0bd..af569c30d5 100644 --- a/plugins/action/eox_status_device_v1_info.py +++ b/plugins/action/eox_status_device_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/eox_status_summary_info.py b/plugins/action/eox_status_summary_info.py index 4af435bea8..ef18b38224 100644 --- a/plugins/action/eox_status_summary_info.py +++ b/plugins/action/eox_status_summary_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/eox_status_summary_v1_info.py b/plugins/action/eox_status_summary_v1_info.py index fc645a850b..6a09160c46 100644 --- a/plugins/action/eox_status_summary_v1_info.py +++ b/plugins/action/eox_status_summary_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_api_status_info.py b/plugins/action/event_api_status_info.py index a59ac5e438..acf51b0d76 100644 --- a/plugins/action/event_api_status_info.py +++ b/plugins/action/event_api_status_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_api_status_v1_info.py b/plugins/action/event_api_status_v1_info.py index e1ee5852e3..d5ff0fe27a 100644 --- a/plugins/action/event_api_status_v1_info.py +++ b/plugins/action/event_api_status_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/event_artifact_count_info.py b/plugins/action/event_artifact_count_info.py index 12842118a6..814850cfcc 100644 --- a/plugins/action/event_artifact_count_info.py +++ b/plugins/action/event_artifact_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_artifact_count_v1_info.py b/plugins/action/event_artifact_count_v1_info.py index 61943ead78..2bfe905dc9 100644 --- a/plugins/action/event_artifact_count_v1_info.py +++ b/plugins/action/event_artifact_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_artifact_info.py b/plugins/action/event_artifact_info.py index 68afe92688..75e2bf8d09 100644 --- a/plugins/action/event_artifact_info.py +++ b/plugins/action/event_artifact_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_artifact_v1_info.py b/plugins/action/event_artifact_v1_info.py index beef1e6a9b..2a0cf32eaa 100644 --- a/plugins/action/event_artifact_v1_info.py +++ b/plugins/action/event_artifact_v1_info.py @@ -44,7 +44,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_config_connector_types_info.py b/plugins/action/event_config_connector_types_info.py index a2700dd330..f007e1a7c5 100644 --- a/plugins/action/event_config_connector_types_info.py +++ b/plugins/action/event_config_connector_types_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_config_connector_types_v1_info.py b/plugins/action/event_config_connector_types_v1_info.py index 417deaeece..0bd5ad80cb 100644 --- a/plugins/action/event_config_connector_types_v1_info.py +++ b/plugins/action/event_config_connector_types_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_count_info.py b/plugins/action/event_count_info.py index 7a5cad5d37..b3dc51bb88 100644 --- a/plugins/action/event_count_info.py +++ b/plugins/action/event_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_count_v1_info.py b/plugins/action/event_count_v1_info.py index 768b6617da..259a97d00c 100644 --- a/plugins/action/event_count_v1_info.py +++ b/plugins/action/event_count_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_email_config.py b/plugins/action/event_email_config.py index d9297e51ad..706bf914a2 100644 --- a/plugins/action/event_email_config.py +++ b/plugins/action/event_email_config.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_email_config_info.py b/plugins/action/event_email_config_info.py index 2ff6620964..7993587658 100644 --- a/plugins/action/event_email_config_info.py +++ b/plugins/action/event_email_config_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_email_config_v1.py b/plugins/action/event_email_config_v1.py index b533655d8b..3318dd9258 100644 --- a/plugins/action/event_email_config_v1.py +++ b/plugins/action/event_email_config_v1.py @@ -64,9 +64,12 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['emailConfigId'] = self.new_object.get('emailConfigId') - new_object_params['primarySMTPConfig'] = self.new_object.get('primarySMTPConfig') - new_object_params['secondarySMTPConfig'] = self.new_object.get('secondarySMTPConfig') + new_object_params['emailConfigId'] = self.new_object.get( + 'emailConfigId') + new_object_params['primarySMTPConfig'] = self.new_object.get( + 'primarySMTPConfig') + new_object_params['secondarySMTPConfig'] = self.new_object.get( + 'secondarySMTPConfig') new_object_params['fromEmail'] = self.new_object.get('fromEmail') new_object_params['toEmail'] = self.new_object.get('toEmail') new_object_params['subject'] = self.new_object.get('subject') @@ -74,9 +77,12 @@ def create_params(self): def update_all_params(self): new_object_params = {} - new_object_params['emailConfigId'] = self.new_object.get('emailConfigId') - new_object_params['primarySMTPConfig'] = self.new_object.get('primarySMTPConfig') - new_object_params['secondarySMTPConfig'] = self.new_object.get('secondarySMTPConfig') + new_object_params['emailConfigId'] = self.new_object.get( + 'emailConfigId') + new_object_params['primarySMTPConfig'] = self.new_object.get( + 'primarySMTPConfig') + new_object_params['secondarySMTPConfig'] = self.new_object.get( + 'secondarySMTPConfig') new_object_params['fromEmail'] = self.new_object.get('fromEmail') new_object_params['toEmail'] = self.new_object.get('toEmail') new_object_params['subject'] = self.new_object.get('subject') @@ -119,7 +125,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -167,7 +174,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/event_email_config_v1_info.py b/plugins/action/event_email_config_v1_info.py index 1e0449ffc6..bcbeaea648 100644 --- a/plugins/action/event_email_config_v1_info.py +++ b/plugins/action/event_email_config_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_info.py b/plugins/action/event_info.py index bdc11d9bcd..1ae0a6ed5a 100644 --- a/plugins/action/event_info.py +++ b/plugins/action/event_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_series_audit_logs_info.py b/plugins/action/event_series_audit_logs_info.py index 89813d0228..11fae70af3 100644 --- a/plugins/action/event_series_audit_logs_info.py +++ b/plugins/action/event_series_audit_logs_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_series_audit_logs_parent_records_info.py b/plugins/action/event_series_audit_logs_parent_records_info.py index 92c4dc7d56..9c51ef449d 100644 --- a/plugins/action/event_series_audit_logs_parent_records_info.py +++ b/plugins/action/event_series_audit_logs_parent_records_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_series_audit_logs_parent_records_v1_info.py b/plugins/action/event_series_audit_logs_parent_records_v1_info.py index ffd36b1fea..0cd663585a 100644 --- a/plugins/action/event_series_audit_logs_parent_records_v1_info.py +++ b/plugins/action/event_series_audit_logs_parent_records_v1_info.py @@ -58,7 +58,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_series_audit_logs_summary_info.py b/plugins/action/event_series_audit_logs_summary_info.py index e55814c09a..b44efa8298 100644 --- a/plugins/action/event_series_audit_logs_summary_info.py +++ b/plugins/action/event_series_audit_logs_summary_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_series_audit_logs_summary_v1_info.py b/plugins/action/event_series_audit_logs_summary_v1_info.py index 47e4576a18..fa1013d54b 100644 --- a/plugins/action/event_series_audit_logs_summary_v1_info.py +++ b/plugins/action/event_series_audit_logs_summary_v1_info.py @@ -56,7 +56,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_series_audit_logs_v1_info.py b/plugins/action/event_series_audit_logs_v1_info.py index 6bd1bd2f39..24460677f1 100644 --- a/plugins/action/event_series_audit_logs_v1_info.py +++ b/plugins/action/event_series_audit_logs_v1_info.py @@ -59,7 +59,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_series_count_info.py b/plugins/action/event_series_count_info.py index 8b932764c8..de21d10686 100644 --- a/plugins/action/event_series_count_info.py +++ b/plugins/action/event_series_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_series_count_v1_info.py b/plugins/action/event_series_count_v1_info.py index 88e04e429c..e785cc44fd 100644 --- a/plugins/action/event_series_count_v1_info.py +++ b/plugins/action/event_series_count_v1_info.py @@ -46,7 +46,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_series_info.py b/plugins/action/event_series_info.py index 074adda35d..41c1f9094c 100644 --- a/plugins/action/event_series_info.py +++ b/plugins/action/event_series_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_series_v1_info.py b/plugins/action/event_series_v1_info.py index 537049c5dc..e1fd12f97b 100644 --- a/plugins/action/event_series_v1_info.py +++ b/plugins/action/event_series_v1_info.py @@ -53,7 +53,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_snmp_config.py b/plugins/action/event_snmp_config.py index 90cdec1a7c..187a15f45d 100644 --- a/plugins/action/event_snmp_config.py +++ b/plugins/action/event_snmp_config.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_snmp_config_info.py b/plugins/action/event_snmp_config_info.py index afd9d9233a..ec51a913bd 100644 --- a/plugins/action/event_snmp_config_info.py +++ b/plugins/action/event_snmp_config_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_snmp_config_v1.py b/plugins/action/event_snmp_config_v1.py index 2e2544688e..2c2c9900b7 100644 --- a/plugins/action/event_snmp_config_v1.py +++ b/plugins/action/event_snmp_config_v1.py @@ -85,8 +85,10 @@ def create_params(self): new_object_params['snmpMode'] = self.new_object.get('snmpMode') new_object_params['snmpAuthType'] = self.new_object.get('snmpAuthType') new_object_params['authPassword'] = self.new_object.get('authPassword') - new_object_params['snmpPrivacyType'] = self.new_object.get('snmpPrivacyType') - new_object_params['privacyPassword'] = self.new_object.get('privacyPassword') + new_object_params['snmpPrivacyType'] = self.new_object.get( + 'snmpPrivacyType') + new_object_params['privacyPassword'] = self.new_object.get( + 'privacyPassword') return new_object_params def update_all_params(self): @@ -102,8 +104,10 @@ def update_all_params(self): new_object_params['snmpMode'] = self.new_object.get('snmpMode') new_object_params['snmpAuthType'] = self.new_object.get('snmpAuthType') new_object_params['authPassword'] = self.new_object.get('authPassword') - new_object_params['snmpPrivacyType'] = self.new_object.get('snmpPrivacyType') - new_object_params['privacyPassword'] = self.new_object.get('privacyPassword') + new_object_params['snmpPrivacyType'] = self.new_object.get( + 'snmpPrivacyType') + new_object_params['privacyPassword'] = self.new_object.get( + 'privacyPassword') return new_object_params def get_object_by_name(self, name): @@ -131,7 +135,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -186,7 +191,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/event_snmp_config_v1_info.py b/plugins/action/event_snmp_config_v1_info.py index cbd01f851f..0273e4192f 100644 --- a/plugins/action/event_snmp_config_v1_info.py +++ b/plugins/action/event_snmp_config_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -79,7 +80,8 @@ def run(self, tmp=None, task_vars=None): # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/event_subscription.py b/plugins/action/event_subscription.py index 780c63bffd..79ec94e1a8 100644 --- a/plugins/action/event_subscription.py +++ b/plugins/action/event_subscription.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_subscription_count_info.py b/plugins/action/event_subscription_count_info.py index 14a60a2b1e..9867b7cd7f 100644 --- a/plugins/action/event_subscription_count_info.py +++ b/plugins/action/event_subscription_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_subscription_count_v1_info.py b/plugins/action/event_subscription_count_v1_info.py index d71b6f7cbb..6b8b45b3eb 100644 --- a/plugins/action/event_subscription_count_v1_info.py +++ b/plugins/action/event_subscription_count_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_subscription_details_email_info.py b/plugins/action/event_subscription_details_email_info.py index 15b51feb8b..60b48170a3 100644 --- a/plugins/action/event_subscription_details_email_info.py +++ b/plugins/action/event_subscription_details_email_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_subscription_details_email_v1_info.py b/plugins/action/event_subscription_details_email_v1_info.py index f551aa438f..11e2c58ed4 100644 --- a/plugins/action/event_subscription_details_email_v1_info.py +++ b/plugins/action/event_subscription_details_email_v1_info.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_subscription_details_rest_info.py b/plugins/action/event_subscription_details_rest_info.py index ddcc198fd0..d25cd2a1a0 100644 --- a/plugins/action/event_subscription_details_rest_info.py +++ b/plugins/action/event_subscription_details_rest_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_subscription_details_rest_v1_info.py b/plugins/action/event_subscription_details_rest_v1_info.py index 96d1629b1e..9646c50553 100644 --- a/plugins/action/event_subscription_details_rest_v1_info.py +++ b/plugins/action/event_subscription_details_rest_v1_info.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_subscription_details_syslog_info.py b/plugins/action/event_subscription_details_syslog_info.py index 005925953f..302a36a573 100644 --- a/plugins/action/event_subscription_details_syslog_info.py +++ b/plugins/action/event_subscription_details_syslog_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_subscription_details_syslog_v1_info.py b/plugins/action/event_subscription_details_syslog_v1_info.py index 713d9e2f90..f831d02aa1 100644 --- a/plugins/action/event_subscription_details_syslog_v1_info.py +++ b/plugins/action/event_subscription_details_syslog_v1_info.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_subscription_email.py b/plugins/action/event_subscription_email.py index c128b42c9a..c9f19c7f74 100644 --- a/plugins/action/event_subscription_email.py +++ b/plugins/action/event_subscription_email.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_subscription_email_info.py b/plugins/action/event_subscription_email_info.py index 21ce6e6251..99ce594002 100644 --- a/plugins/action/event_subscription_email_info.py +++ b/plugins/action/event_subscription_email_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_subscription_email_v1.py b/plugins/action/event_subscription_email_v1.py index a3e29c4f28..270cb0f482 100644 --- a/plugins/action/event_subscription_email_v1.py +++ b/plugins/action/event_subscription_email_v1.py @@ -116,7 +116,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -169,7 +170,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/event_subscription_email_v1_info.py b/plugins/action/event_subscription_email_v1_info.py index d5d92b7530..083a36a53f 100644 --- a/plugins/action/event_subscription_email_v1_info.py +++ b/plugins/action/event_subscription_email_v1_info.py @@ -47,7 +47,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_subscription_info.py b/plugins/action/event_subscription_info.py index 1c11b04f6c..a036d969db 100644 --- a/plugins/action/event_subscription_info.py +++ b/plugins/action/event_subscription_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_subscription_rest.py b/plugins/action/event_subscription_rest.py index c5a1f352d6..e811e03129 100644 --- a/plugins/action/event_subscription_rest.py +++ b/plugins/action/event_subscription_rest.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_subscription_rest_info.py b/plugins/action/event_subscription_rest_info.py index c0a1d652f2..9d1b4db187 100644 --- a/plugins/action/event_subscription_rest_info.py +++ b/plugins/action/event_subscription_rest_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_subscription_rest_v1.py b/plugins/action/event_subscription_rest_v1.py index fc2304124f..073052b60c 100644 --- a/plugins/action/event_subscription_rest_v1.py +++ b/plugins/action/event_subscription_rest_v1.py @@ -116,7 +116,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -169,7 +170,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/event_subscription_rest_v1_info.py b/plugins/action/event_subscription_rest_v1_info.py index 1956395075..35a4157c47 100644 --- a/plugins/action/event_subscription_rest_v1_info.py +++ b/plugins/action/event_subscription_rest_v1_info.py @@ -47,7 +47,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_subscription_syslog.py b/plugins/action/event_subscription_syslog.py index 915087f2c3..352f9eb07a 100644 --- a/plugins/action/event_subscription_syslog.py +++ b/plugins/action/event_subscription_syslog.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_subscription_syslog_info.py b/plugins/action/event_subscription_syslog_info.py index 4ae8da97b8..341f90a293 100644 --- a/plugins/action/event_subscription_syslog_info.py +++ b/plugins/action/event_subscription_syslog_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_subscription_syslog_v1.py b/plugins/action/event_subscription_syslog_v1.py index a466ef5df7..ef7c1dd311 100644 --- a/plugins/action/event_subscription_syslog_v1.py +++ b/plugins/action/event_subscription_syslog_v1.py @@ -116,7 +116,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -169,7 +170,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/event_subscription_syslog_v1_info.py b/plugins/action/event_subscription_syslog_v1_info.py index 3b0778e8cc..be53dc5655 100644 --- a/plugins/action/event_subscription_syslog_v1_info.py +++ b/plugins/action/event_subscription_syslog_v1_info.py @@ -47,7 +47,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_subscription_v1.py b/plugins/action/event_subscription_v1.py index afcaba43bd..6cc9231f2d 100644 --- a/plugins/action/event_subscription_v1.py +++ b/plugins/action/event_subscription_v1.py @@ -70,7 +70,8 @@ def create_params(self): def delete_all_params(self): new_object_params = {} - new_object_params['subscriptions'] = self.new_object.get('subscriptions') + new_object_params['subscriptions'] = self.new_object.get( + 'subscriptions') return new_object_params def update_all_params(self): @@ -130,7 +131,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -198,7 +200,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/event_subscription_v1_info.py b/plugins/action/event_subscription_v1_info.py index 5e6ab69731..a02e2a45c3 100644 --- a/plugins/action/event_subscription_v1_info.py +++ b/plugins/action/event_subscription_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_syslog_config.py b/plugins/action/event_syslog_config.py index 33b6577217..c0d8f08284 100644 --- a/plugins/action/event_syslog_config.py +++ b/plugins/action/event_syslog_config.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_syslog_config_info.py b/plugins/action/event_syslog_config_info.py index 20080fe2fe..7a3d70c6ee 100644 --- a/plugins/action/event_syslog_config_info.py +++ b/plugins/action/event_syslog_config_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_syslog_config_v1.py b/plugins/action/event_syslog_config_v1.py index a5265cd17b..2d5e3469c0 100644 --- a/plugins/action/event_syslog_config_v1.py +++ b/plugins/action/event_syslog_config_v1.py @@ -129,7 +129,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -177,7 +178,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/event_syslog_config_v1_info.py b/plugins/action/event_syslog_config_v1_info.py index 2693ece170..438a832433 100644 --- a/plugins/action/event_syslog_config_v1_info.py +++ b/plugins/action/event_syslog_config_v1_info.py @@ -44,7 +44,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_v1_info.py b/plugins/action/event_v1_info.py index 4a5433d1fa..396dcd8641 100644 --- a/plugins/action/event_v1_info.py +++ b/plugins/action/event_v1_info.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/event_webhook.py b/plugins/action/event_webhook.py index 8dbded3a98..3314f1e1ac 100644 --- a/plugins/action/event_webhook.py +++ b/plugins/action/event_webhook.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_webhook_info.py b/plugins/action/event_webhook_info.py index b8225e5ad9..7b1ed8238c 100644 --- a/plugins/action/event_webhook_info.py +++ b/plugins/action/event_webhook_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/event_webhook_v1.py b/plugins/action/event_webhook_v1.py index 95f2ab55a5..fb603aa7e8 100644 --- a/plugins/action/event_webhook_v1.py +++ b/plugins/action/event_webhook_v1.py @@ -135,7 +135,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -184,7 +185,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/event_webhook_v1_info.py b/plugins/action/event_webhook_v1_info.py index 0dfe7fb32b..1c6567c287 100644 --- a/plugins/action/event_webhook_v1_info.py +++ b/plugins/action/event_webhook_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/execute_suggested_actions_commands.py b/plugins/action/execute_suggested_actions_commands.py index faef8472d6..193502be7a 100644 --- a/plugins/action/execute_suggested_actions_commands.py +++ b/plugins/action/execute_suggested_actions_commands.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/execute_suggested_actions_commands_v1.py b/plugins/action/execute_suggested_actions_commands_v1.py index 0541b89ba4..00715f729f 100644 --- a/plugins/action/execute_suggested_actions_commands_v1.py +++ b/plugins/action/execute_suggested_actions_commands_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/file_import.py b/plugins/action/file_import.py index 07eed81034..8192c49ba2 100644 --- a/plugins/action/file_import.py +++ b/plugins/action/file_import.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/file_import_v1.py b/plugins/action/file_import_v1.py index c565f1ac21..f4d0b938c4 100644 --- a/plugins/action/file_import_v1.py +++ b/plugins/action/file_import_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/file_info.py b/plugins/action/file_info.py index b6ad20c9f8..9f785e82c3 100644 --- a/plugins/action/file_info.py +++ b/plugins/action/file_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/file_namespace_files_info.py b/plugins/action/file_namespace_files_info.py index bb135f1d34..b67308b8a6 100644 --- a/plugins/action/file_namespace_files_info.py +++ b/plugins/action/file_namespace_files_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/file_namespace_files_v1_info.py b/plugins/action/file_namespace_files_v1_info.py index ae0f0b461b..6e01b2ccf0 100644 --- a/plugins/action/file_namespace_files_v1_info.py +++ b/plugins/action/file_namespace_files_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not name: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/file_namespaces_info.py b/plugins/action/file_namespaces_info.py index b3a07457b4..e5ddb66238 100644 --- a/plugins/action/file_namespaces_info.py +++ b/plugins/action/file_namespaces_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/file_namespaces_v1_info.py b/plugins/action/file_namespaces_v1_info.py index beef7d7d60..1290457add 100644 --- a/plugins/action/file_namespaces_v1_info.py +++ b/plugins/action/file_namespaces_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/file_v1_info.py b/plugins/action/file_v1_info.py index abc190f061..71f6eaa8e9 100644 --- a/plugins/action/file_v1_info.py +++ b/plugins/action/file_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -98,7 +99,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/flexible_report_content_info.py b/plugins/action/flexible_report_content_info.py index 253807766d..ae604b0f24 100644 --- a/plugins/action/flexible_report_content_info.py +++ b/plugins/action/flexible_report_content_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/flexible_report_content_v1_info.py b/plugins/action/flexible_report_content_v1_info.py index fcd1589982..2fc989d0fa 100644 --- a/plugins/action/flexible_report_content_v1_info.py +++ b/plugins/action/flexible_report_content_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -94,7 +95,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/flexible_report_execute.py b/plugins/action/flexible_report_execute.py index 529d45a7ce..65d0aea561 100644 --- a/plugins/action/flexible_report_execute.py +++ b/plugins/action/flexible_report_execute.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/flexible_report_execute_v1.py b/plugins/action/flexible_report_execute_v1.py index 0245ea8d2e..bae0d81946 100644 --- a/plugins/action/flexible_report_execute_v1.py +++ b/plugins/action/flexible_report_execute_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/flexible_report_executions_info.py b/plugins/action/flexible_report_executions_info.py index 3ea1180db9..a211512880 100644 --- a/plugins/action/flexible_report_executions_info.py +++ b/plugins/action/flexible_report_executions_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/flexible_report_executions_v1_info.py b/plugins/action/flexible_report_executions_v1_info.py index 7a7c9c274e..a23cf4e11b 100644 --- a/plugins/action/flexible_report_executions_v1_info.py +++ b/plugins/action/flexible_report_executions_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/flexible_report_schedule.py b/plugins/action/flexible_report_schedule.py index cc90b6c9a3..c61fe72c7e 100644 --- a/plugins/action/flexible_report_schedule.py +++ b/plugins/action/flexible_report_schedule.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/flexible_report_schedule_info.py b/plugins/action/flexible_report_schedule_info.py index 2fe56a0a86..304287b763 100644 --- a/plugins/action/flexible_report_schedule_info.py +++ b/plugins/action/flexible_report_schedule_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/flexible_report_schedule_v1.py b/plugins/action/flexible_report_schedule_v1.py index 53dd567949..f0e227060a 100644 --- a/plugins/action/flexible_report_schedule_v1.py +++ b/plugins/action/flexible_report_schedule_v1.py @@ -95,7 +95,8 @@ def exists(self): _id = prev_obj.get("id") _id = _id or prev_obj.get("reportId") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) self.new_object.update(dict(report_id=_id)) @@ -142,7 +143,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -188,7 +190,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/flexible_report_schedule_v1_info.py b/plugins/action/flexible_report_schedule_v1_info.py index bc83e24447..0301a14c15 100644 --- a/plugins/action/flexible_report_schedule_v1_info.py +++ b/plugins/action/flexible_report_schedule_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/flexible_report_schedules_info.py b/plugins/action/flexible_report_schedules_info.py index 8841b4290f..c49436be8b 100644 --- a/plugins/action/flexible_report_schedules_info.py +++ b/plugins/action/flexible_report_schedules_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/flexible_report_schedules_v1_info.py b/plugins/action/flexible_report_schedules_v1_info.py index de804dca16..23888be05d 100644 --- a/plugins/action/flexible_report_schedules_v1_info.py +++ b/plugins/action/flexible_report_schedules_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/floors.py b/plugins/action/floors.py index 70ca064bad..d0780eea61 100644 --- a/plugins/action/floors.py +++ b/plugins/action/floors.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/floors_info.py b/plugins/action/floors_info.py index 838ed0595a..78680ca85d 100644 --- a/plugins/action/floors_info.py +++ b/plugins/action/floors_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/floors_settings.py b/plugins/action/floors_settings.py index 4db4333544..bd66888fb8 100644 --- a/plugins/action/floors_settings.py +++ b/plugins/action/floors_settings.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/floors_settings_info.py b/plugins/action/floors_settings_info.py index ff59d16a9a..0e4ec51575 100644 --- a/plugins/action/floors_settings_info.py +++ b/plugins/action/floors_settings_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/floors_settings_v2.py b/plugins/action/floors_settings_v2.py index 5ede25d017..2f139faf74 100644 --- a/plugins/action/floors_settings_v2.py +++ b/plugins/action/floors_settings_v2.py @@ -54,7 +54,8 @@ def get_all_params(self, name=None, id=None): def update_all_params(self): new_object_params = {} - new_object_params['unitsOfMeasure'] = self.new_object.get('unitsOfMeasure') + new_object_params['unitsOfMeasure'] = self.new_object.get( + 'unitsOfMeasure') return new_object_params def get_object_by_name(self, name): @@ -106,7 +107,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -156,7 +158,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/floors_settings_v2_info.py b/plugins/action/floors_settings_v2_info.py index a410d21ce8..4c0565e856 100644 --- a/plugins/action/floors_settings_v2_info.py +++ b/plugins/action/floors_settings_v2_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/floors_upload_image.py b/plugins/action/floors_upload_image.py index 8ea7079eda..15579e721b 100644 --- a/plugins/action/floors_upload_image.py +++ b/plugins/action/floors_upload_image.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/floors_upload_image_v2.py b/plugins/action/floors_upload_image_v2.py index 60f8535c14..4676919fa7 100644 --- a/plugins/action/floors_upload_image_v2.py +++ b/plugins/action/floors_upload_image_v2.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/floors_v2.py b/plugins/action/floors_v2.py index c4a12e117b..c8cbc7111d 100644 --- a/plugins/action/floors_v2.py +++ b/plugins/action/floors_v2.py @@ -75,7 +75,8 @@ def create_params(self): new_object_params['width'] = self.new_object.get('width') new_object_params['length'] = self.new_object.get('length') new_object_params['height'] = self.new_object.get('height') - new_object_params['unitsOfMeasure'] = self.new_object.get('unitsOfMeasure') + new_object_params['unitsOfMeasure'] = self.new_object.get( + 'unitsOfMeasure') return new_object_params def delete_by_id_params(self): @@ -92,7 +93,8 @@ def update_by_id_params(self): new_object_params['width'] = self.new_object.get('width') new_object_params['length'] = self.new_object.get('length') new_object_params['height'] = self.new_object.get('height') - new_object_params['unitsOfMeasure'] = self.new_object.get('unitsOfMeasure') + new_object_params['unitsOfMeasure'] = self.new_object.get( + 'unitsOfMeasure') new_object_params['id'] = self.new_object.get('id') return new_object_params @@ -133,7 +135,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) if _id: @@ -211,7 +214,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/floors_v2_info.py b/plugins/action/floors_v2_info.py index 9609917320..12db5bff5d 100644 --- a/plugins/action/floors_v2_info.py +++ b/plugins/action/floors_v2_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -94,7 +95,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/global_credential_delete.py b/plugins/action/global_credential_delete.py index 91fde4b2c5..ad77d37e17 100644 --- a/plugins/action/global_credential_delete.py +++ b/plugins/action/global_credential_delete.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/global_credential_delete_v1.py b/plugins/action/global_credential_delete_v1.py index b900b3af2a..2c158d910d 100644 --- a/plugins/action/global_credential_delete_v1.py +++ b/plugins/action/global_credential_delete_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/global_credential_info.py b/plugins/action/global_credential_info.py index 31161ab4cb..6d5fcbcfd1 100644 --- a/plugins/action/global_credential_info.py +++ b/plugins/action/global_credential_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/global_credential_update.py b/plugins/action/global_credential_update.py index 987e4bec9e..f2f6e5f7c6 100644 --- a/plugins/action/global_credential_update.py +++ b/plugins/action/global_credential_update.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/global_credential_update_v1.py b/plugins/action/global_credential_update_v1.py index 76819ddb1e..7eb587cd34 100644 --- a/plugins/action/global_credential_update_v1.py +++ b/plugins/action/global_credential_update_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/global_credential_v1_info.py b/plugins/action/global_credential_v1_info.py index 7fad0c99d0..9afce02050 100644 --- a/plugins/action/global_credential_v1_info.py +++ b/plugins/action/global_credential_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/global_credential_v2.py b/plugins/action/global_credential_v2.py index 1831c0457e..c0c4df507c 100644 --- a/plugins/action/global_credential_v2.py +++ b/plugins/action/global_credential_v2.py @@ -68,7 +68,8 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['cliCredential'] = self.new_object.get('cliCredential') + new_object_params['cliCredential'] = self.new_object.get( + 'cliCredential') new_object_params['snmpV2cRead'] = self.new_object.get('snmpV2cRead') new_object_params['snmpV2cWrite'] = self.new_object.get('snmpV2cWrite') new_object_params['snmpV3'] = self.new_object.get('snmpV3') @@ -83,7 +84,8 @@ def delete_by_id_params(self): def update_all_params(self): new_object_params = {} - new_object_params['cliCredential'] = self.new_object.get('cliCredential') + new_object_params['cliCredential'] = self.new_object.get( + 'cliCredential') new_object_params['snmpV2cRead'] = self.new_object.get('snmpV2cRead') new_object_params['snmpV2cWrite'] = self.new_object.get('snmpV2cWrite') new_object_params['snmpV3'] = self.new_object.get('snmpV3') @@ -140,7 +142,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -207,7 +210,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/global_credential_v2_info.py b/plugins/action/global_credential_v2_info.py index 128a49ecc5..04025fc98c 100644 --- a/plugins/action/global_credential_v2_info.py +++ b/plugins/action/global_credential_v2_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/global_pool.py b/plugins/action/global_pool.py index a4579e7d1f..5c44f446e9 100644 --- a/plugins/action/global_pool.py +++ b/plugins/action/global_pool.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/global_pool_info.py b/plugins/action/global_pool_info.py index b472b3d46d..8a9e5a3300 100644 --- a/plugins/action/global_pool_info.py +++ b/plugins/action/global_pool_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/global_pool_v1.py b/plugins/action/global_pool_v1.py index 016850e429..5ebdd70c35 100644 --- a/plugins/action/global_pool_v1.py +++ b/plugins/action/global_pool_v1.py @@ -122,7 +122,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -184,7 +185,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/global_pool_v1_info.py b/plugins/action/global_pool_v1_info.py index bd09edffbf..c744163fea 100644 --- a/plugins/action/global_pool_v1_info.py +++ b/plugins/action/global_pool_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/golden_image_create.py b/plugins/action/golden_image_create.py index da8c1a598b..8528b518d3 100644 --- a/plugins/action/golden_image_create.py +++ b/plugins/action/golden_image_create.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/golden_image_create_v1.py b/plugins/action/golden_image_create_v1.py index ddef82b685..8e53c83a8f 100644 --- a/plugins/action/golden_image_create_v1.py +++ b/plugins/action/golden_image_create_v1.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/golden_tag_image_delete.py b/plugins/action/golden_tag_image_delete.py index 8cae759d05..91128c5968 100644 --- a/plugins/action/golden_tag_image_delete.py +++ b/plugins/action/golden_tag_image_delete.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/golden_tag_image_delete_v1.py b/plugins/action/golden_tag_image_delete_v1.py index bf72a1f9dd..d6c57a247d 100644 --- a/plugins/action/golden_tag_image_delete_v1.py +++ b/plugins/action/golden_tag_image_delete_v1.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/golden_tag_image_details_info.py b/plugins/action/golden_tag_image_details_info.py index be86a124cc..5011663ef8 100644 --- a/plugins/action/golden_tag_image_details_info.py +++ b/plugins/action/golden_tag_image_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/golden_tag_image_details_v1_info.py b/plugins/action/golden_tag_image_details_v1_info.py index bee4ef2323..a70ed2fc7a 100644 --- a/plugins/action/golden_tag_image_details_v1_info.py +++ b/plugins/action/golden_tag_image_details_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -98,7 +99,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/health_score_definitions.py b/plugins/action/health_score_definitions.py index 1f9958ed7b..1c7f12ce61 100644 --- a/plugins/action/health_score_definitions.py +++ b/plugins/action/health_score_definitions.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/health_score_definitions_bulk_update.py b/plugins/action/health_score_definitions_bulk_update.py index 5184273c01..0b5b38e3c1 100644 --- a/plugins/action/health_score_definitions_bulk_update.py +++ b/plugins/action/health_score_definitions_bulk_update.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/health_score_definitions_bulk_update_v1.py b/plugins/action/health_score_definitions_bulk_update_v1.py index a9d7a9b7e4..4b0e9ae91b 100644 --- a/plugins/action/health_score_definitions_bulk_update_v1.py +++ b/plugins/action/health_score_definitions_bulk_update_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/health_score_definitions_count_info.py b/plugins/action/health_score_definitions_count_info.py index 9d9e9c64eb..06ec3ae806 100644 --- a/plugins/action/health_score_definitions_count_info.py +++ b/plugins/action/health_score_definitions_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/health_score_definitions_count_v1_info.py b/plugins/action/health_score_definitions_count_v1_info.py index 30ab7e5b5e..5f41ecf475 100644 --- a/plugins/action/health_score_definitions_count_v1_info.py +++ b/plugins/action/health_score_definitions_count_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/health_score_definitions_info.py b/plugins/action/health_score_definitions_info.py index e9040f5a1b..b8d2f77333 100644 --- a/plugins/action/health_score_definitions_info.py +++ b/plugins/action/health_score_definitions_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/health_score_definitions_v1.py b/plugins/action/health_score_definitions_v1.py index 4deee8ca69..1a9b912dd0 100644 --- a/plugins/action/health_score_definitions_v1.py +++ b/plugins/action/health_score_definitions_v1.py @@ -51,7 +51,8 @@ def __init__(self, params, dnac): self.new_object = dict( includeForOverallHealth=params.get("includeForOverallHealth"), thresholdValue=params.get("thresholdValue"), - synchronizeToIssueThreshold=params.get("synchronizeToIssueThreshold"), + synchronizeToIssueThreshold=params.get( + "synchronizeToIssueThreshold"), id=params.get("id"), ) @@ -69,9 +70,12 @@ def get_all_params(self, name=None, id=None): def update_by_id_params(self): new_object_params = {} - new_object_params['includeForOverallHealth'] = self.new_object.get('includeForOverallHealth') - new_object_params['thresholdValue'] = self.new_object.get('thresholdValue') - new_object_params['synchronizeToIssueThreshold'] = self.new_object.get('synchronizeToIssueThreshold') + new_object_params['includeForOverallHealth'] = self.new_object.get( + 'includeForOverallHealth') + new_object_params['thresholdValue'] = self.new_object.get( + 'thresholdValue') + new_object_params['synchronizeToIssueThreshold'] = self.new_object.get( + 'synchronizeToIssueThreshold') new_object_params['id'] = self.new_object.get('id') return new_object_params @@ -123,7 +127,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) if _id: @@ -169,7 +174,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -215,7 +221,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/health_score_definitions_v1_info.py b/plugins/action/health_score_definitions_v1_info.py index 14941b7e60..c1cdfb7f75 100644 --- a/plugins/action/health_score_definitions_v1_info.py +++ b/plugins/action/health_score_definitions_v1_info.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/images_addon_images_count_info.py b/plugins/action/images_addon_images_count_info.py index defcab0ea0..3504cd6167 100644 --- a/plugins/action/images_addon_images_count_info.py +++ b/plugins/action/images_addon_images_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/images_addon_images_count_v1_info.py b/plugins/action/images_addon_images_count_v1_info.py index 0156b671c3..dd9449434d 100644 --- a/plugins/action/images_addon_images_count_v1_info.py +++ b/plugins/action/images_addon_images_count_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/images_addon_images_info.py b/plugins/action/images_addon_images_info.py index cd2177a122..5ff69df4c0 100644 --- a/plugins/action/images_addon_images_info.py +++ b/plugins/action/images_addon_images_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/images_addon_images_v1_info.py b/plugins/action/images_addon_images_v1_info.py index e62f4ed935..a8e4daae2d 100644 --- a/plugins/action/images_addon_images_v1_info.py +++ b/plugins/action/images_addon_images_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/images_count_info.py b/plugins/action/images_count_info.py index 63cfdb0b12..8a70591c1f 100644 --- a/plugins/action/images_count_info.py +++ b/plugins/action/images_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/images_count_v1_info.py b/plugins/action/images_count_v1_info.py index 69b175d3b7..e734cee353 100644 --- a/plugins/action/images_count_v1_info.py +++ b/plugins/action/images_count_v1_info.py @@ -47,7 +47,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -75,7 +76,8 @@ def get_object(self, params): new_object = dict( site_id=params.get("siteId"), product_name_ordinal=params.get("productNameOrdinal"), - supervisor_product_name_ordinal=params.get("supervisorProductNameOrdinal"), + supervisor_product_name_ordinal=params.get( + "supervisorProductNameOrdinal"), imported=params.get("imported"), name=params.get("name"), version=params.get("version"), diff --git a/plugins/action/images_distribution_server_settings.py b/plugins/action/images_distribution_server_settings.py index b653eea1ac..511d8e75dd 100644 --- a/plugins/action/images_distribution_server_settings.py +++ b/plugins/action/images_distribution_server_settings.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/images_distribution_server_settings_info.py b/plugins/action/images_distribution_server_settings_info.py index 8a62999017..a0a63a10ae 100644 --- a/plugins/action/images_distribution_server_settings_info.py +++ b/plugins/action/images_distribution_server_settings_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/images_distribution_server_settings_v1.py b/plugins/action/images_distribution_server_settings_v1.py index 2cce605885..6c48cd285a 100644 --- a/plugins/action/images_distribution_server_settings_v1.py +++ b/plugins/action/images_distribution_server_settings_v1.py @@ -62,7 +62,8 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['serverAddress'] = self.new_object.get('serverAddress') + new_object_params['serverAddress'] = self.new_object.get( + 'serverAddress') new_object_params['username'] = self.new_object.get('username') new_object_params['portNumber'] = self.new_object.get('portNumber') new_object_params['rootLocation'] = self.new_object.get('rootLocation') @@ -118,7 +119,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -166,7 +168,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/images_distribution_server_settings_v1_info.py b/plugins/action/images_distribution_server_settings_v1_info.py index 121fb24eaf..96612e5a8a 100644 --- a/plugins/action/images_distribution_server_settings_v1_info.py +++ b/plugins/action/images_distribution_server_settings_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/images_download.py b/plugins/action/images_download.py index 25134dc243..b50af169d7 100644 --- a/plugins/action/images_download.py +++ b/plugins/action/images_download.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/images_download_v1.py b/plugins/action/images_download_v1.py index 97d1c21207..d856463871 100644 --- a/plugins/action/images_download_v1.py +++ b/plugins/action/images_download_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/images_info.py b/plugins/action/images_info.py index 6da3433f32..b93b850141 100644 --- a/plugins/action/images_info.py +++ b/plugins/action/images_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/images_site_wise_product_names.py b/plugins/action/images_site_wise_product_names.py index 6e39b2004e..c0f30819b5 100644 --- a/plugins/action/images_site_wise_product_names.py +++ b/plugins/action/images_site_wise_product_names.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/images_site_wise_product_names_count_info.py b/plugins/action/images_site_wise_product_names_count_info.py index ce0d6af8a1..086b85fed3 100644 --- a/plugins/action/images_site_wise_product_names_count_info.py +++ b/plugins/action/images_site_wise_product_names_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/images_site_wise_product_names_count_v1_info.py b/plugins/action/images_site_wise_product_names_count_v1_info.py index 97e1cc004b..75c978ed49 100644 --- a/plugins/action/images_site_wise_product_names_count_v1_info.py +++ b/plugins/action/images_site_wise_product_names_count_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/images_site_wise_product_names_info.py b/plugins/action/images_site_wise_product_names_info.py index cbda88b376..150dd7eceb 100644 --- a/plugins/action/images_site_wise_product_names_info.py +++ b/plugins/action/images_site_wise_product_names_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/images_site_wise_product_names_v1.py b/plugins/action/images_site_wise_product_names_v1.py index 03f19420a4..753ab8df54 100644 --- a/plugins/action/images_site_wise_product_names_v1.py +++ b/plugins/action/images_site_wise_product_names_v1.py @@ -71,7 +71,8 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['productNameOrdinal'] = self.new_object.get('productNameOrdinal') + new_object_params['productNameOrdinal'] = self.new_object.get( + 'productNameOrdinal') new_object_params['siteIds'] = self.new_object.get('siteIds') new_object_params['imageId'] = self.new_object.get('imageId') return new_object_params @@ -79,14 +80,16 @@ def create_params(self): def delete_by_name_params(self): new_object_params = {} new_object_params['image_id'] = self.new_object.get('image_id') - new_object_params['product_name_ordinal'] = self.new_object.get('product_name_ordinal') + new_object_params['product_name_ordinal'] = self.new_object.get( + 'product_name_ordinal') return new_object_params def update_by_name_params(self): new_object_params = {} new_object_params['siteIds'] = self.new_object.get('siteIds') new_object_params['imageId'] = self.new_object.get('imageId') - new_object_params['productNameOrdinal'] = self.new_object.get('productNameOrdinal') + new_object_params['productNameOrdinal'] = self.new_object.get( + 'productNameOrdinal') return new_object_params def get_object_by_name(self, name): diff --git a/plugins/action/images_site_wise_product_names_v1_info.py b/plugins/action/images_site_wise_product_names_v1_info.py index 755aa1484d..533dbd8e5c 100644 --- a/plugins/action/images_site_wise_product_names_v1_info.py +++ b/plugins/action/images_site_wise_product_names_v1_info.py @@ -44,7 +44,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/images_v1_info.py b/plugins/action/images_v1_info.py index b1ee84bf73..422f132d1a 100644 --- a/plugins/action/images_v1_info.py +++ b/plugins/action/images_v1_info.py @@ -49,7 +49,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -77,7 +78,8 @@ def get_object(self, params): new_object = dict( site_id=params.get("siteId"), product_name_ordinal=params.get("productNameOrdinal"), - supervisor_product_name_ordinal=params.get("supervisorProductNameOrdinal"), + supervisor_product_name_ordinal=params.get( + "supervisorProductNameOrdinal"), imported=params.get("imported"), name=params.get("name"), version=params.get("version"), diff --git a/plugins/action/integrate_ise.py b/plugins/action/integrate_ise.py index 048d7631a3..0a146d4a5e 100644 --- a/plugins/action/integrate_ise.py +++ b/plugins/action/integrate_ise.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/integrate_ise_v1.py b/plugins/action/integrate_ise_v1.py index 6110266062..3d1d2ff74e 100644 --- a/plugins/action/integrate_ise_v1.py +++ b/plugins/action/integrate_ise_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/integration_settings_instances_itsm.py b/plugins/action/integration_settings_instances_itsm.py index bb0861a57a..cc4fb97436 100644 --- a/plugins/action/integration_settings_instances_itsm.py +++ b/plugins/action/integration_settings_instances_itsm.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/integration_settings_instances_itsm_info.py b/plugins/action/integration_settings_instances_itsm_info.py index 79273adaf7..6693b03d31 100644 --- a/plugins/action/integration_settings_instances_itsm_info.py +++ b/plugins/action/integration_settings_instances_itsm_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/integration_settings_instances_itsm_v1.py b/plugins/action/integration_settings_instances_itsm_v1.py index 3c787a4634..36a9f8cfd2 100644 --- a/plugins/action/integration_settings_instances_itsm_v1.py +++ b/plugins/action/integration_settings_instances_itsm_v1.py @@ -119,7 +119,8 @@ def exists(self): _id = prev_obj.get("id") _id = _id or prev_obj.get("instanceId") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) self.new_object.update(dict(instance_id=_id)) @@ -198,7 +199,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/integration_settings_instances_itsm_v1_info.py b/plugins/action/integration_settings_instances_itsm_v1_info.py index 67c389a37e..20a96751c4 100644 --- a/plugins/action/integration_settings_instances_itsm_v1_info.py +++ b/plugins/action/integration_settings_instances_itsm_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/integration_settings_itsm_instances_info.py b/plugins/action/integration_settings_itsm_instances_info.py index 1a38da6c66..c6989ce22c 100644 --- a/plugins/action/integration_settings_itsm_instances_info.py +++ b/plugins/action/integration_settings_itsm_instances_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/integration_settings_itsm_instances_v1_info.py b/plugins/action/integration_settings_itsm_instances_v1_info.py index d13c65c454..82c381746a 100644 --- a/plugins/action/integration_settings_itsm_instances_v1_info.py +++ b/plugins/action/integration_settings_itsm_instances_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/integration_settings_status_info.py b/plugins/action/integration_settings_status_info.py index 21a9de3733..d1d94c6aee 100644 --- a/plugins/action/integration_settings_status_info.py +++ b/plugins/action/integration_settings_status_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/integration_settings_status_v1_info.py b/plugins/action/integration_settings_status_v1_info.py index f3431091dc..27530f417f 100644 --- a/plugins/action/integration_settings_status_v1_info.py +++ b/plugins/action/integration_settings_status_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/intent_custom_issue_definitions_info.py b/plugins/action/intent_custom_issue_definitions_info.py index d6e2558e21..74844a6c08 100644 --- a/plugins/action/intent_custom_issue_definitions_info.py +++ b/plugins/action/intent_custom_issue_definitions_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/intent_custom_issue_definitions_v1_info.py b/plugins/action/intent_custom_issue_definitions_v1_info.py index 7685d867c6..46ae93e84c 100644 --- a/plugins/action/intent_custom_issue_definitions_v1_info.py +++ b/plugins/action/intent_custom_issue_definitions_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/interface_info.py b/plugins/action/interface_info.py index 1f64cf5c6a..da446bfa66 100644 --- a/plugins/action/interface_info.py +++ b/plugins/action/interface_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/interface_network_device_detail_info.py b/plugins/action/interface_network_device_detail_info.py index 8b1e6f3535..fb82e5fe71 100644 --- a/plugins/action/interface_network_device_detail_info.py +++ b/plugins/action/interface_network_device_detail_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/interface_network_device_detail_v1_info.py b/plugins/action/interface_network_device_detail_v1_info.py index 3907e2ae49..f7edb07f8e 100644 --- a/plugins/action/interface_network_device_detail_v1_info.py +++ b/plugins/action/interface_network_device_detail_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/interface_network_device_info.py b/plugins/action/interface_network_device_info.py index e394df164c..22a66748c4 100644 --- a/plugins/action/interface_network_device_info.py +++ b/plugins/action/interface_network_device_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/interface_network_device_range_info.py b/plugins/action/interface_network_device_range_info.py index 1c7d808fc1..0af5e04d55 100644 --- a/plugins/action/interface_network_device_range_info.py +++ b/plugins/action/interface_network_device_range_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/interface_network_device_range_v1_info.py b/plugins/action/interface_network_device_range_v1_info.py index abcda18540..e93cc42b3f 100644 --- a/plugins/action/interface_network_device_range_v1_info.py +++ b/plugins/action/interface_network_device_range_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/interface_network_device_v1_info.py b/plugins/action/interface_network_device_v1_info.py index db1f144502..c4d44d445e 100644 --- a/plugins/action/interface_network_device_v1_info.py +++ b/plugins/action/interface_network_device_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/interface_operation_create.py b/plugins/action/interface_operation_create.py index f415be8b84..fbeacc82ba 100644 --- a/plugins/action/interface_operation_create.py +++ b/plugins/action/interface_operation_create.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/interface_operation_create_v1.py b/plugins/action/interface_operation_create_v1.py index c98582277a..5fb363a6dd 100644 --- a/plugins/action/interface_operation_create_v1.py +++ b/plugins/action/interface_operation_create_v1.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/interface_update.py b/plugins/action/interface_update.py index a451458e09..ca990c019a 100644 --- a/plugins/action/interface_update.py +++ b/plugins/action/interface_update.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/interface_update_v1.py b/plugins/action/interface_update_v1.py index 6c715fcbb3..bf6d39b5b2 100644 --- a/plugins/action/interface_update_v1.py +++ b/plugins/action/interface_update_v1.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/interface_v1_info.py b/plugins/action/interface_v1_info.py index 8484e75284..5794c2d777 100644 --- a/plugins/action/interface_v1_info.py +++ b/plugins/action/interface_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/interfaces_count_info.py b/plugins/action/interfaces_count_info.py index fdf5678030..c46837cb79 100644 --- a/plugins/action/interfaces_count_info.py +++ b/plugins/action/interfaces_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/interfaces_count_v1_info.py b/plugins/action/interfaces_count_v1_info.py index 1e7231a8a0..93b35d867d 100644 --- a/plugins/action/interfaces_count_v1_info.py +++ b/plugins/action/interfaces_count_v1_info.py @@ -47,7 +47,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/interfaces_info.py b/plugins/action/interfaces_info.py index 22666c414c..3196f95920 100644 --- a/plugins/action/interfaces_info.py +++ b/plugins/action/interfaces_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/interfaces_query.py b/plugins/action/interfaces_query.py index d3d200849f..fa5cb2b1ce 100644 --- a/plugins/action/interfaces_query.py +++ b/plugins/action/interfaces_query.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/interfaces_query_count.py b/plugins/action/interfaces_query_count.py index 778f28e9f8..1cfca4d88e 100644 --- a/plugins/action/interfaces_query_count.py +++ b/plugins/action/interfaces_query_count.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/interfaces_query_count_v1.py b/plugins/action/interfaces_query_count_v1.py index 014256d531..4b62a8ab55 100644 --- a/plugins/action/interfaces_query_count_v1.py +++ b/plugins/action/interfaces_query_count_v1.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/interfaces_query_v1.py b/plugins/action/interfaces_query_v1.py index a00c9effa6..cb462556ba 100644 --- a/plugins/action/interfaces_query_v1.py +++ b/plugins/action/interfaces_query_v1.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/interfaces_v1_info.py b/plugins/action/interfaces_v1_info.py index a131596a6d..0e51c02127 100644 --- a/plugins/action/interfaces_v1_info.py +++ b/plugins/action/interfaces_v1_info.py @@ -54,7 +54,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/ipam_server_setting.py b/plugins/action/ipam_server_setting.py index 0f10f89f76..4eba424824 100644 --- a/plugins/action/ipam_server_setting.py +++ b/plugins/action/ipam_server_setting.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/ipam_server_setting_info.py b/plugins/action/ipam_server_setting_info.py index ccf54ad1e6..f44c23a15c 100644 --- a/plugins/action/ipam_server_setting_info.py +++ b/plugins/action/ipam_server_setting_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/ipam_server_setting_v1.py b/plugins/action/ipam_server_setting_v1.py index 0defc0e6fa..47c8baf546 100644 --- a/plugins/action/ipam_server_setting_v1.py +++ b/plugins/action/ipam_server_setting_v1.py @@ -138,7 +138,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -197,7 +198,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/ipam_server_setting_v1_info.py b/plugins/action/ipam_server_setting_v1_info.py index 09dca53b2e..f4fd561914 100644 --- a/plugins/action/ipam_server_setting_v1_info.py +++ b/plugins/action/ipam_server_setting_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/ise_integration_status_info.py b/plugins/action/ise_integration_status_info.py index 1f3adf77f0..899b37e33a 100644 --- a/plugins/action/ise_integration_status_info.py +++ b/plugins/action/ise_integration_status_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/ise_integration_status_v1_info.py b/plugins/action/ise_integration_status_v1_info.py index 41cb8d22a4..df0db03b76 100644 --- a/plugins/action/ise_integration_status_v1_info.py +++ b/plugins/action/ise_integration_status_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/issues_enrichment_details_info.py b/plugins/action/issues_enrichment_details_info.py index 96a8e26555..24679b5bcc 100644 --- a/plugins/action/issues_enrichment_details_info.py +++ b/plugins/action/issues_enrichment_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/issues_enrichment_details_v1_info.py b/plugins/action/issues_enrichment_details_v1_info.py index 9f27efc4ac..ff17eb6bfd 100644 --- a/plugins/action/issues_enrichment_details_v1_info.py +++ b/plugins/action/issues_enrichment_details_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/issues_info.py b/plugins/action/issues_info.py index 2e76b3dfa3..6051400ae9 100644 --- a/plugins/action/issues_info.py +++ b/plugins/action/issues_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/issues_v1_info.py b/plugins/action/issues_v1_info.py index 374f835526..d8fb73bcc0 100644 --- a/plugins/action/issues_v1_info.py +++ b/plugins/action/issues_v1_info.py @@ -45,7 +45,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/itsm_cmdb_sync_status_info.py b/plugins/action/itsm_cmdb_sync_status_info.py index 11d5e69415..c01b8983ec 100644 --- a/plugins/action/itsm_cmdb_sync_status_info.py +++ b/plugins/action/itsm_cmdb_sync_status_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/itsm_cmdb_sync_status_v1_info.py b/plugins/action/itsm_cmdb_sync_status_v1_info.py index 798e0130a5..bcb840188f 100644 --- a/plugins/action/itsm_cmdb_sync_status_v1_info.py +++ b/plugins/action/itsm_cmdb_sync_status_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/itsm_integration_events_failed.py b/plugins/action/itsm_integration_events_failed.py index c72c83b838..7ee9ebb600 100644 --- a/plugins/action/itsm_integration_events_failed.py +++ b/plugins/action/itsm_integration_events_failed.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/itsm_integration_events_failed_info.py b/plugins/action/itsm_integration_events_failed_info.py index 90d88a66c2..dacb79b2a8 100644 --- a/plugins/action/itsm_integration_events_failed_info.py +++ b/plugins/action/itsm_integration_events_failed_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/itsm_integration_events_failed_v1.py b/plugins/action/itsm_integration_events_failed_v1.py index c50c287634..cb80f81642 100644 --- a/plugins/action/itsm_integration_events_failed_v1.py +++ b/plugins/action/itsm_integration_events_failed_v1.py @@ -100,7 +100,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -132,7 +133,8 @@ def create(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/itsm_integration_events_failed_v1_info.py b/plugins/action/itsm_integration_events_failed_v1_info.py index d06a815262..48f31c5295 100644 --- a/plugins/action/itsm_integration_events_failed_v1_info.py +++ b/plugins/action/itsm_integration_events_failed_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/lan_automation.py b/plugins/action/lan_automation.py index 8c4ac01fb7..e52e394e08 100644 --- a/plugins/action/lan_automation.py +++ b/plugins/action/lan_automation.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/lan_automation_count_info.py b/plugins/action/lan_automation_count_info.py index 1fde5325e7..25e24251d9 100644 --- a/plugins/action/lan_automation_count_info.py +++ b/plugins/action/lan_automation_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/lan_automation_count_v1_info.py b/plugins/action/lan_automation_count_v1_info.py index 1149294aad..a80d82d89c 100644 --- a/plugins/action/lan_automation_count_v1_info.py +++ b/plugins/action/lan_automation_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/lan_automation_create.py b/plugins/action/lan_automation_create.py index 73fbf3cfac..aa9b295c36 100644 --- a/plugins/action/lan_automation_create.py +++ b/plugins/action/lan_automation_create.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/lan_automation_create_v1.py b/plugins/action/lan_automation_create_v1.py index 95a969628c..12a1136503 100644 --- a/plugins/action/lan_automation_create_v1.py +++ b/plugins/action/lan_automation_create_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/lan_automation_delete.py b/plugins/action/lan_automation_delete.py index 7a3589e356..e0aae5f5b2 100644 --- a/plugins/action/lan_automation_delete.py +++ b/plugins/action/lan_automation_delete.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/lan_automation_delete_v1.py b/plugins/action/lan_automation_delete_v1.py index c519c61dce..00f3f51914 100644 --- a/plugins/action/lan_automation_delete_v1.py +++ b/plugins/action/lan_automation_delete_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/lan_automation_log_by_serial_number_info.py b/plugins/action/lan_automation_log_by_serial_number_info.py index db0edc59a0..1f02652a73 100644 --- a/plugins/action/lan_automation_log_by_serial_number_info.py +++ b/plugins/action/lan_automation_log_by_serial_number_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/lan_automation_log_by_serial_number_v1_info.py b/plugins/action/lan_automation_log_by_serial_number_v1_info.py index c3cde2be1a..9f6d76fd4c 100644 --- a/plugins/action/lan_automation_log_by_serial_number_v1_info.py +++ b/plugins/action/lan_automation_log_by_serial_number_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -96,7 +97,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/lan_automation_log_info.py b/plugins/action/lan_automation_log_info.py index cc80812875..9ccea440e8 100644 --- a/plugins/action/lan_automation_log_info.py +++ b/plugins/action/lan_automation_log_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/lan_automation_log_v1_info.py b/plugins/action/lan_automation_log_v1_info.py index 2ee4f8ebd2..51bea25dda 100644 --- a/plugins/action/lan_automation_log_v1_info.py +++ b/plugins/action/lan_automation_log_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/lan_automation_sessions_info.py b/plugins/action/lan_automation_sessions_info.py index 4771d44dc7..137c5ab92f 100644 --- a/plugins/action/lan_automation_sessions_info.py +++ b/plugins/action/lan_automation_sessions_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/lan_automation_sessions_v1_info.py b/plugins/action/lan_automation_sessions_v1_info.py index 8b80834d78..a8df5e9c2f 100644 --- a/plugins/action/lan_automation_sessions_v1_info.py +++ b/plugins/action/lan_automation_sessions_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/lan_automation_status_info.py b/plugins/action/lan_automation_status_info.py index ded52e1cd9..a53ed6370b 100644 --- a/plugins/action/lan_automation_status_info.py +++ b/plugins/action/lan_automation_status_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/lan_automation_status_v1_info.py b/plugins/action/lan_automation_status_v1_info.py index 517e897fe8..0e02d6e321 100644 --- a/plugins/action/lan_automation_status_v1_info.py +++ b/plugins/action/lan_automation_status_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/lan_automation_update.py b/plugins/action/lan_automation_update.py index da37cd11fc..21656e36c0 100644 --- a/plugins/action/lan_automation_update.py +++ b/plugins/action/lan_automation_update.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/lan_automation_update_device.py b/plugins/action/lan_automation_update_device.py index 33ea6dec68..bd94f65643 100644 --- a/plugins/action/lan_automation_update_device.py +++ b/plugins/action/lan_automation_update_device.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/lan_automation_update_device_v1.py b/plugins/action/lan_automation_update_device_v1.py index a6515b0659..1f2d21cd03 100644 --- a/plugins/action/lan_automation_update_device_v1.py +++ b/plugins/action/lan_automation_update_device_v1.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/lan_automation_update_v1.py b/plugins/action/lan_automation_update_v1.py index 539a6546c9..e0bca86a33 100644 --- a/plugins/action/lan_automation_update_v1.py +++ b/plugins/action/lan_automation_update_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/lan_automation_update_v2.py b/plugins/action/lan_automation_update_v2.py index acd4c98120..264833642a 100644 --- a/plugins/action/lan_automation_update_v2.py +++ b/plugins/action/lan_automation_update_v2.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/lan_automation_v2.py b/plugins/action/lan_automation_v2.py index 2c538a873b..bbea910cba 100644 --- a/plugins/action/lan_automation_v2.py +++ b/plugins/action/lan_automation_v2.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/license_device_count_info.py b/plugins/action/license_device_count_info.py index 4bf949ac7d..bdceabb1c1 100644 --- a/plugins/action/license_device_count_info.py +++ b/plugins/action/license_device_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/license_device_count_v1_info.py b/plugins/action/license_device_count_v1_info.py index b6e7015826..71c76241ce 100644 --- a/plugins/action/license_device_count_v1_info.py +++ b/plugins/action/license_device_count_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/license_device_deregistration.py b/plugins/action/license_device_deregistration.py index d6e0c48786..807139d26e 100644 --- a/plugins/action/license_device_deregistration.py +++ b/plugins/action/license_device_deregistration.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/license_device_deregistration_v1.py b/plugins/action/license_device_deregistration_v1.py index 7b03a0074b..7db70e74ed 100644 --- a/plugins/action/license_device_deregistration_v1.py +++ b/plugins/action/license_device_deregistration_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/license_device_license_details_info.py b/plugins/action/license_device_license_details_info.py index 257de79c2f..6e6d4db89a 100644 --- a/plugins/action/license_device_license_details_info.py +++ b/plugins/action/license_device_license_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/license_device_license_details_v1_info.py b/plugins/action/license_device_license_details_v1_info.py index 9e6e1baa2b..c0125c71f3 100644 --- a/plugins/action/license_device_license_details_v1_info.py +++ b/plugins/action/license_device_license_details_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/license_device_license_summary_info.py b/plugins/action/license_device_license_summary_info.py index 8f0cb09e17..228cce3746 100644 --- a/plugins/action/license_device_license_summary_info.py +++ b/plugins/action/license_device_license_summary_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/license_device_license_summary_v1_info.py b/plugins/action/license_device_license_summary_v1_info.py index 4511ef1296..bb41348edb 100644 --- a/plugins/action/license_device_license_summary_v1_info.py +++ b/plugins/action/license_device_license_summary_v1_info.py @@ -47,7 +47,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/license_device_registration.py b/plugins/action/license_device_registration.py index ef1a9ab7c2..c286f86893 100644 --- a/plugins/action/license_device_registration.py +++ b/plugins/action/license_device_registration.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/license_device_registration_v1.py b/plugins/action/license_device_registration_v1.py index 9fce6728a0..c2aff73d2a 100644 --- a/plugins/action/license_device_registration_v1.py +++ b/plugins/action/license_device_registration_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/license_setting.py b/plugins/action/license_setting.py index 51da58d73d..01d2681bac 100644 --- a/plugins/action/license_setting.py +++ b/plugins/action/license_setting.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/license_setting_info.py b/plugins/action/license_setting_info.py index 49ccfb845f..126059ecf4 100644 --- a/plugins/action/license_setting_info.py +++ b/plugins/action/license_setting_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/license_setting_v1.py b/plugins/action/license_setting_v1.py index a3b7d31c87..c06830ff84 100644 --- a/plugins/action/license_setting_v1.py +++ b/plugins/action/license_setting_v1.py @@ -47,7 +47,8 @@ def __init__(self, params, dnac): self.dnac = dnac self.new_object = dict( defaultSmartAccountId=params.get("defaultSmartAccountId"), - autoRegistrationVirtualAccountId=params.get("autoRegistrationVirtualAccountId"), + autoRegistrationVirtualAccountId=params.get( + "autoRegistrationVirtualAccountId"), ) def get_all_params(self, name=None, id=None): @@ -56,8 +57,10 @@ def get_all_params(self, name=None, id=None): def update_all_params(self): new_object_params = {} - new_object_params['defaultSmartAccountId'] = self.new_object.get('defaultSmartAccountId') - new_object_params['autoRegistrationVirtualAccountId'] = self.new_object.get('autoRegistrationVirtualAccountId') + new_object_params['defaultSmartAccountId'] = self.new_object.get( + 'defaultSmartAccountId') + new_object_params['autoRegistrationVirtualAccountId'] = self.new_object.get( + 'autoRegistrationVirtualAccountId') return new_object_params def get_object_by_name(self, name): @@ -97,7 +100,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -108,7 +112,8 @@ def requires_update(self, current_obj): obj_params = [ ("defaultSmartAccountId", "defaultSmartAccountId"), - ("autoRegistrationVirtualAccountId", "autoRegistrationVirtualAccountId"), + ("autoRegistrationVirtualAccountId", + "autoRegistrationVirtualAccountId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params # If any does not have eq params, it requires update @@ -132,7 +137,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -178,7 +184,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/license_setting_v1_info.py b/plugins/action/license_setting_v1_info.py index 5e068b87c5..2826cb8f23 100644 --- a/plugins/action/license_setting_v1_info.py +++ b/plugins/action/license_setting_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/license_smart_account_details_info.py b/plugins/action/license_smart_account_details_info.py index 98401891cf..65603b8b47 100644 --- a/plugins/action/license_smart_account_details_info.py +++ b/plugins/action/license_smart_account_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/license_smart_account_details_v1_info.py b/plugins/action/license_smart_account_details_v1_info.py index 00cf0cb32b..70be088fd6 100644 --- a/plugins/action/license_smart_account_details_v1_info.py +++ b/plugins/action/license_smart_account_details_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/license_term_details_info.py b/plugins/action/license_term_details_info.py index 2f8c8775c0..675282d087 100644 --- a/plugins/action/license_term_details_info.py +++ b/plugins/action/license_term_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/license_term_details_v1_info.py b/plugins/action/license_term_details_v1_info.py index c916f6e845..d5918cdf3c 100644 --- a/plugins/action/license_term_details_v1_info.py +++ b/plugins/action/license_term_details_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -96,7 +97,8 @@ def run(self, tmp=None, task_vars=None): if not name: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/license_usage_details_info.py b/plugins/action/license_usage_details_info.py index fb2e0c3d37..63019d0148 100644 --- a/plugins/action/license_usage_details_info.py +++ b/plugins/action/license_usage_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/license_usage_details_v1_info.py b/plugins/action/license_usage_details_v1_info.py index 3e7380aed1..fd34f71a08 100644 --- a/plugins/action/license_usage_details_v1_info.py +++ b/plugins/action/license_usage_details_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -96,7 +97,8 @@ def run(self, tmp=None, task_vars=None): if not name: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/license_virtual_account_change.py b/plugins/action/license_virtual_account_change.py index 506cb5c597..a07451ad6f 100644 --- a/plugins/action/license_virtual_account_change.py +++ b/plugins/action/license_virtual_account_change.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/license_virtual_account_change_v1.py b/plugins/action/license_virtual_account_change_v1.py index c8e318163b..75a357ef46 100644 --- a/plugins/action/license_virtual_account_change_v1.py +++ b/plugins/action/license_virtual_account_change_v1.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/license_virtual_account_details_info.py b/plugins/action/license_virtual_account_details_info.py index 8e06837701..c28554c7be 100644 --- a/plugins/action/license_virtual_account_details_info.py +++ b/plugins/action/license_virtual_account_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/license_virtual_account_details_v1_info.py b/plugins/action/license_virtual_account_details_v1_info.py index 4220a392fc..7752c9b98c 100644 --- a/plugins/action/license_virtual_account_details_v1_info.py +++ b/plugins/action/license_virtual_account_details_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/maps_export.py b/plugins/action/maps_export.py index 06869e84d7..a382b6bd10 100644 --- a/plugins/action/maps_export.py +++ b/plugins/action/maps_export.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/maps_export_v1.py b/plugins/action/maps_export_v1.py index 16dfd37ff9..87a5d6ee65 100644 --- a/plugins/action/maps_export_v1.py +++ b/plugins/action/maps_export_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/maps_import.py b/plugins/action/maps_import.py index acac583819..70241e339e 100644 --- a/plugins/action/maps_import.py +++ b/plugins/action/maps_import.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/maps_import_perform.py b/plugins/action/maps_import_perform.py index 7df10cf497..2feb2cd9d6 100644 --- a/plugins/action/maps_import_perform.py +++ b/plugins/action/maps_import_perform.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/maps_import_perform_v1.py b/plugins/action/maps_import_perform_v1.py index b1d44a9a63..0d27b64403 100644 --- a/plugins/action/maps_import_perform_v1.py +++ b/plugins/action/maps_import_perform_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/maps_import_start.py b/plugins/action/maps_import_start.py index cd3f904273..fb795fae32 100644 --- a/plugins/action/maps_import_start.py +++ b/plugins/action/maps_import_start.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/maps_import_start_v1.py b/plugins/action/maps_import_start_v1.py index 4c6ad80f40..13ef034e71 100644 --- a/plugins/action/maps_import_start_v1.py +++ b/plugins/action/maps_import_start_v1.py @@ -36,7 +36,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/maps_import_status_info.py b/plugins/action/maps_import_status_info.py index 6e7afc2597..206a0274a9 100644 --- a/plugins/action/maps_import_status_info.py +++ b/plugins/action/maps_import_status_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/maps_import_status_v1_info.py b/plugins/action/maps_import_status_v1_info.py index 2c599e09c9..93a673d94a 100644 --- a/plugins/action/maps_import_status_v1_info.py +++ b/plugins/action/maps_import_status_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/maps_import_v1.py b/plugins/action/maps_import_v1.py index 31c3b417c8..b53b5e0d0e 100644 --- a/plugins/action/maps_import_v1.py +++ b/plugins/action/maps_import_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/maps_supported_access_points_info.py b/plugins/action/maps_supported_access_points_info.py index ee7a924daf..02817cd6df 100644 --- a/plugins/action/maps_supported_access_points_info.py +++ b/plugins/action/maps_supported_access_points_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/maps_supported_access_points_v1_info.py b/plugins/action/maps_supported_access_points_v1_info.py index 12cc544dfd..3294f258c5 100644 --- a/plugins/action/maps_supported_access_points_v1_info.py +++ b/plugins/action/maps_supported_access_points_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_create.py b/plugins/action/network_create.py index 31208b1551..81b9bfd94c 100644 --- a/plugins/action/network_create.py +++ b/plugins/action/network_create.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_create_v1.py b/plugins/action/network_create_v1.py index c13f1c3491..141c652453 100644 --- a/plugins/action/network_create_v1.py +++ b/plugins/action/network_create_v1.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_device.py b/plugins/action/network_device.py index 0c5c3c6fbf..fa1ff5c848 100644 --- a/plugins/action/network_device.py +++ b/plugins/action/network_device.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_by_ip_info.py b/plugins/action/network_device_by_ip_info.py index a5a4183c7a..4d7ab75ca1 100644 --- a/plugins/action/network_device_by_ip_info.py +++ b/plugins/action/network_device_by_ip_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_by_ip_v1_info.py b/plugins/action/network_device_by_ip_v1_info.py index 58ab3d4cde..418cfabfbf 100644 --- a/plugins/action/network_device_by_ip_v1_info.py +++ b/plugins/action/network_device_by_ip_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/network_device_by_serial_number_info.py b/plugins/action/network_device_by_serial_number_info.py index 4f59cd2e52..27081f32ac 100644 --- a/plugins/action/network_device_by_serial_number_info.py +++ b/plugins/action/network_device_by_serial_number_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_by_serial_number_v1_info.py b/plugins/action/network_device_by_serial_number_v1_info.py index 23391af764..3198d0a52c 100644 --- a/plugins/action/network_device_by_serial_number_v1_info.py +++ b/plugins/action/network_device_by_serial_number_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/network_device_chassis_details_info.py b/plugins/action/network_device_chassis_details_info.py index b540e12f09..f7d5ca9c36 100644 --- a/plugins/action/network_device_chassis_details_info.py +++ b/plugins/action/network_device_chassis_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_chassis_details_v1_info.py b/plugins/action/network_device_chassis_details_v1_info.py index ef3cd35c04..654046dfda 100644 --- a/plugins/action/network_device_chassis_details_v1_info.py +++ b/plugins/action/network_device_chassis_details_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_config_count_info.py b/plugins/action/network_device_config_count_info.py index 3d306dec13..a497c669e8 100644 --- a/plugins/action/network_device_config_count_info.py +++ b/plugins/action/network_device_config_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_config_count_v1_info.py b/plugins/action/network_device_config_count_v1_info.py index 9064ccc6fe..03667bc204 100644 --- a/plugins/action/network_device_config_count_v1_info.py +++ b/plugins/action/network_device_config_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_config_info.py b/plugins/action/network_device_config_info.py index 2bde03cd22..746c73f27e 100644 --- a/plugins/action/network_device_config_info.py +++ b/plugins/action/network_device_config_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_config_task_info.py b/plugins/action/network_device_config_task_info.py index 809b881c9c..a6ca408682 100644 --- a/plugins/action/network_device_config_task_info.py +++ b/plugins/action/network_device_config_task_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_config_task_v1_info.py b/plugins/action/network_device_config_task_v1_info.py index eaf15a4c79..5c12fb26ef 100644 --- a/plugins/action/network_device_config_task_v1_info.py +++ b/plugins/action/network_device_config_task_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_config_v1_info.py b/plugins/action/network_device_config_v1_info.py index 0edad5e027..fdbcdf74fb 100644 --- a/plugins/action/network_device_config_v1_info.py +++ b/plugins/action/network_device_config_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_config_write_memory.py b/plugins/action/network_device_config_write_memory.py index 7952bd01f1..c24acfd737 100644 --- a/plugins/action/network_device_config_write_memory.py +++ b/plugins/action/network_device_config_write_memory.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_config_write_memory_v1.py b/plugins/action/network_device_config_write_memory_v1.py index 3771c97b05..f182fbff8a 100644 --- a/plugins/action/network_device_config_write_memory_v1.py +++ b/plugins/action/network_device_config_write_memory_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_device_count_info.py b/plugins/action/network_device_count_info.py index 2e29d7bdd4..6580fab082 100644 --- a/plugins/action/network_device_count_info.py +++ b/plugins/action/network_device_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_count_v1_info.py b/plugins/action/network_device_count_v1_info.py index 79424c86a8..63eca66a6c 100644 --- a/plugins/action/network_device_count_v1_info.py +++ b/plugins/action/network_device_count_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_custom_prompt.py b/plugins/action/network_device_custom_prompt.py index 7c5ba80a43..4005113bc9 100644 --- a/plugins/action/network_device_custom_prompt.py +++ b/plugins/action/network_device_custom_prompt.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_custom_prompt_info_info.py b/plugins/action/network_device_custom_prompt_info_info.py index fca6a4412d..578e5a972a 100644 --- a/plugins/action/network_device_custom_prompt_info_info.py +++ b/plugins/action/network_device_custom_prompt_info_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_custom_prompt_info_v1_info.py b/plugins/action/network_device_custom_prompt_info_v1_info.py index 2673cec649..262e615e78 100644 --- a/plugins/action/network_device_custom_prompt_info_v1_info.py +++ b/plugins/action/network_device_custom_prompt_info_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_custom_prompt_v1.py b/plugins/action/network_device_custom_prompt_v1.py index ef10ec6df8..b4c4eda3bf 100644 --- a/plugins/action/network_device_custom_prompt_v1.py +++ b/plugins/action/network_device_custom_prompt_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_device_equipment_info.py b/plugins/action/network_device_equipment_info.py index 5cf8946296..b8fa2e0603 100644 --- a/plugins/action/network_device_equipment_info.py +++ b/plugins/action/network_device_equipment_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_equipment_v1_info.py b/plugins/action/network_device_equipment_v1_info.py index fadbd373d5..0ec8c329f4 100644 --- a/plugins/action/network_device_equipment_v1_info.py +++ b/plugins/action/network_device_equipment_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_export.py b/plugins/action/network_device_export.py index 8eebb3d786..bf7ecd8130 100644 --- a/plugins/action/network_device_export.py +++ b/plugins/action/network_device_export.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_export_v1.py b/plugins/action/network_device_export_v1.py index c733d689d2..302e412470 100644 --- a/plugins/action/network_device_export_v1.py +++ b/plugins/action/network_device_export_v1.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_device_functional_capability_info.py b/plugins/action/network_device_functional_capability_info.py index 2942eb255e..806854204d 100644 --- a/plugins/action/network_device_functional_capability_info.py +++ b/plugins/action/network_device_functional_capability_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_functional_capability_v1_info.py b/plugins/action/network_device_functional_capability_v1_info.py index c3bd5d190d..f83f380e4f 100644 --- a/plugins/action/network_device_functional_capability_v1_info.py +++ b/plugins/action/network_device_functional_capability_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_global_polling_interval_info.py b/plugins/action/network_device_global_polling_interval_info.py index c8dd93d619..06c67f0329 100644 --- a/plugins/action/network_device_global_polling_interval_info.py +++ b/plugins/action/network_device_global_polling_interval_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_global_polling_interval_v1_info.py b/plugins/action/network_device_global_polling_interval_v1_info.py index dfca8c9f6e..f05635805c 100644 --- a/plugins/action/network_device_global_polling_interval_v1_info.py +++ b/plugins/action/network_device_global_polling_interval_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_image_updates_count_info.py b/plugins/action/network_device_image_updates_count_info.py index 23b56a0409..04bb636e8b 100644 --- a/plugins/action/network_device_image_updates_count_info.py +++ b/plugins/action/network_device_image_updates_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_image_updates_count_v1_info.py b/plugins/action/network_device_image_updates_count_v1_info.py index 24c142f18a..0ad2805abe 100644 --- a/plugins/action/network_device_image_updates_count_v1_info.py +++ b/plugins/action/network_device_image_updates_count_v1_info.py @@ -46,7 +46,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_image_updates_info.py b/plugins/action/network_device_image_updates_info.py index b360a102d9..49da9d5cd1 100644 --- a/plugins/action/network_device_image_updates_info.py +++ b/plugins/action/network_device_image_updates_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_image_updates_v1_info.py b/plugins/action/network_device_image_updates_v1_info.py index dded31d837..85ab8daa7a 100644 --- a/plugins/action/network_device_image_updates_v1_info.py +++ b/plugins/action/network_device_image_updates_v1_info.py @@ -50,7 +50,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_info.py b/plugins/action/network_device_info.py index a5efab8203..809d15d800 100644 --- a/plugins/action/network_device_info.py +++ b/plugins/action/network_device_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_interface_neighbor_info.py b/plugins/action/network_device_interface_neighbor_info.py index 41fb9fbabb..fb2ab8e66c 100644 --- a/plugins/action/network_device_interface_neighbor_info.py +++ b/plugins/action/network_device_interface_neighbor_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_interface_neighbor_v1_info.py b/plugins/action/network_device_interface_neighbor_v1_info.py index 4b3b54a285..fab8ee8393 100644 --- a/plugins/action/network_device_interface_neighbor_v1_info.py +++ b/plugins/action/network_device_interface_neighbor_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_interface_poe_info.py b/plugins/action/network_device_interface_poe_info.py index b463eed683..ab315e7c54 100644 --- a/plugins/action/network_device_interface_poe_info.py +++ b/plugins/action/network_device_interface_poe_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_interface_poe_v1_info.py b/plugins/action/network_device_interface_poe_v1_info.py index d9a64e913b..83c76e2e4b 100644 --- a/plugins/action/network_device_interface_poe_v1_info.py +++ b/plugins/action/network_device_interface_poe_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_inventory_insight_link_mismatch_info.py b/plugins/action/network_device_inventory_insight_link_mismatch_info.py index 009760ae06..790cee1023 100644 --- a/plugins/action/network_device_inventory_insight_link_mismatch_info.py +++ b/plugins/action/network_device_inventory_insight_link_mismatch_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_inventory_insight_link_mismatch_v1_info.py b/plugins/action/network_device_inventory_insight_link_mismatch_v1_info.py index 63cdcd94bd..6d42008e73 100644 --- a/plugins/action/network_device_inventory_insight_link_mismatch_v1_info.py +++ b/plugins/action/network_device_inventory_insight_link_mismatch_v1_info.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_ip_address_info.py b/plugins/action/network_device_ip_address_info.py index 968a734724..0f807e4359 100644 --- a/plugins/action/network_device_ip_address_info.py +++ b/plugins/action/network_device_ip_address_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_ip_address_v1_info.py b/plugins/action/network_device_ip_address_v1_info.py index 58ab3d4cde..418cfabfbf 100644 --- a/plugins/action/network_device_ip_address_v1_info.py +++ b/plugins/action/network_device_ip_address_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/network_device_lexicographically_sorted_info.py b/plugins/action/network_device_lexicographically_sorted_info.py index c1b534d4d4..21ca15f65a 100644 --- a/plugins/action/network_device_lexicographically_sorted_info.py +++ b/plugins/action/network_device_lexicographically_sorted_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_lexicographically_sorted_v1_info.py b/plugins/action/network_device_lexicographically_sorted_v1_info.py index 1e58c631fd..255f008266 100644 --- a/plugins/action/network_device_lexicographically_sorted_v1_info.py +++ b/plugins/action/network_device_lexicographically_sorted_v1_info.py @@ -59,7 +59,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -95,7 +96,8 @@ def get_object(self, params): software_version=params.get("softwareVersion"), software_type=params.get("softwareType"), reachability_status=params.get("reachabilityStatus"), - reachability_failure_reason=params.get("reachabilityFailureReason"), + reachability_failure_reason=params.get( + "reachabilityFailureReason"), error_code=params.get("errorCode"), platform_id=params.get("platformId"), series=params.get("series"), diff --git a/plugins/action/network_device_linecard_details_info.py b/plugins/action/network_device_linecard_details_info.py index eeda1ecacf..f2498d3331 100644 --- a/plugins/action/network_device_linecard_details_info.py +++ b/plugins/action/network_device_linecard_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_linecard_details_v1_info.py b/plugins/action/network_device_linecard_details_v1_info.py index 04beab6a93..752f9d052b 100644 --- a/plugins/action/network_device_linecard_details_v1_info.py +++ b/plugins/action/network_device_linecard_details_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_management_address_update.py b/plugins/action/network_device_management_address_update.py index 7adb557c21..8f67770a3a 100644 --- a/plugins/action/network_device_management_address_update.py +++ b/plugins/action/network_device_management_address_update.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_management_address_update_v1.py b/plugins/action/network_device_management_address_update_v1.py index 14a5e10a5c..ed0d6eaece 100644 --- a/plugins/action/network_device_management_address_update_v1.py +++ b/plugins/action/network_device_management_address_update_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_device_meraki_organization_info.py b/plugins/action/network_device_meraki_organization_info.py index db0ce9db99..81481e335f 100644 --- a/plugins/action/network_device_meraki_organization_info.py +++ b/plugins/action/network_device_meraki_organization_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_meraki_organization_v1_info.py b/plugins/action/network_device_meraki_organization_v1_info.py index 3122cea48f..1d4ed059ea 100644 --- a/plugins/action/network_device_meraki_organization_v1_info.py +++ b/plugins/action/network_device_meraki_organization_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_module_count_info.py b/plugins/action/network_device_module_count_info.py index 20b6facfea..ec79fe6c28 100644 --- a/plugins/action/network_device_module_count_info.py +++ b/plugins/action/network_device_module_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_module_count_v1_info.py b/plugins/action/network_device_module_count_v1_info.py index 1b79e2effc..634e6ebfd7 100644 --- a/plugins/action/network_device_module_count_v1_info.py +++ b/plugins/action/network_device_module_count_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_module_info.py b/plugins/action/network_device_module_info.py index 1154ab7d03..154c847fab 100644 --- a/plugins/action/network_device_module_info.py +++ b/plugins/action/network_device_module_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_module_v1_info.py b/plugins/action/network_device_module_v1_info.py index b8c61cf9cf..a58fead3d8 100644 --- a/plugins/action/network_device_module_v1_info.py +++ b/plugins/action/network_device_module_v1_info.py @@ -45,7 +45,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_poe_info.py b/plugins/action/network_device_poe_info.py index 87a278a916..23a0009397 100644 --- a/plugins/action/network_device_poe_info.py +++ b/plugins/action/network_device_poe_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_poe_v1_info.py b/plugins/action/network_device_poe_v1_info.py index 9c9516a778..ea1b52ced9 100644 --- a/plugins/action/network_device_poe_v1_info.py +++ b/plugins/action/network_device_poe_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_polling_interval_info.py b/plugins/action/network_device_polling_interval_info.py index 08d22bf5be..388965ce50 100644 --- a/plugins/action/network_device_polling_interval_info.py +++ b/plugins/action/network_device_polling_interval_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_polling_interval_v1_info.py b/plugins/action/network_device_polling_interval_v1_info.py index 76ea2f1d8a..6b70c7efb2 100644 --- a/plugins/action/network_device_polling_interval_v1_info.py +++ b/plugins/action/network_device_polling_interval_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_range_info.py b/plugins/action/network_device_range_info.py index 0f397074a5..20d8aa6936 100644 --- a/plugins/action/network_device_range_info.py +++ b/plugins/action/network_device_range_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_range_v1_info.py b/plugins/action/network_device_range_v1_info.py index 88940b2019..c59b4e473e 100644 --- a/plugins/action/network_device_range_v1_info.py +++ b/plugins/action/network_device_range_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_register_for_wsa_info.py b/plugins/action/network_device_register_for_wsa_info.py index b3bd38ac95..7150fb81bb 100644 --- a/plugins/action/network_device_register_for_wsa_info.py +++ b/plugins/action/network_device_register_for_wsa_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_register_for_wsa_v1_info.py b/plugins/action/network_device_register_for_wsa_v1_info.py index 7ea36fa097..b82f43ff7a 100644 --- a/plugins/action/network_device_register_for_wsa_v1_info.py +++ b/plugins/action/network_device_register_for_wsa_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_stack_details_info.py b/plugins/action/network_device_stack_details_info.py index e339c2ab38..edea1eb9d1 100644 --- a/plugins/action/network_device_stack_details_info.py +++ b/plugins/action/network_device_stack_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_stack_details_v1_info.py b/plugins/action/network_device_stack_details_v1_info.py index 569ea0d980..d735750b87 100644 --- a/plugins/action/network_device_stack_details_v1_info.py +++ b/plugins/action/network_device_stack_details_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_summary_info.py b/plugins/action/network_device_summary_info.py index febedf7099..a834bdf89c 100644 --- a/plugins/action/network_device_summary_info.py +++ b/plugins/action/network_device_summary_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_summary_v1_info.py b/plugins/action/network_device_summary_v1_info.py index f56d2368e6..47067b2fc0 100644 --- a/plugins/action/network_device_summary_v1_info.py +++ b/plugins/action/network_device_summary_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_supervisor_card_details_info.py b/plugins/action/network_device_supervisor_card_details_info.py index 29f95a6946..f30a554aa3 100644 --- a/plugins/action/network_device_supervisor_card_details_info.py +++ b/plugins/action/network_device_supervisor_card_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_supervisor_card_details_v1_info.py b/plugins/action/network_device_supervisor_card_details_v1_info.py index 2563b7fac8..fc8ec09f26 100644 --- a/plugins/action/network_device_supervisor_card_details_v1_info.py +++ b/plugins/action/network_device_supervisor_card_details_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_sync.py b/plugins/action/network_device_sync.py index 8eebc0e045..d959259f1d 100644 --- a/plugins/action/network_device_sync.py +++ b/plugins/action/network_device_sync.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_sync_v1.py b/plugins/action/network_device_sync_v1.py index dcfcfb17f2..48f2296b04 100644 --- a/plugins/action/network_device_sync_v1.py +++ b/plugins/action/network_device_sync_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_device_update_role.py b/plugins/action/network_device_update_role.py index 77b4d48727..29769bc9cb 100644 --- a/plugins/action/network_device_update_role.py +++ b/plugins/action/network_device_update_role.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_update_role_v1.py b/plugins/action/network_device_update_role_v1.py index 4c05c4b1a1..fe87e4d93d 100644 --- a/plugins/action/network_device_update_role_v1.py +++ b/plugins/action/network_device_update_role_v1.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_device_user_defined_field.py b/plugins/action/network_device_user_defined_field.py index 2077d17b7b..522303d164 100644 --- a/plugins/action/network_device_user_defined_field.py +++ b/plugins/action/network_device_user_defined_field.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_user_defined_field_delete.py b/plugins/action/network_device_user_defined_field_delete.py index 3010d30798..8224a2020e 100644 --- a/plugins/action/network_device_user_defined_field_delete.py +++ b/plugins/action/network_device_user_defined_field_delete.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_user_defined_field_delete_v1.py b/plugins/action/network_device_user_defined_field_delete_v1.py index ac854cf70e..4552648c00 100644 --- a/plugins/action/network_device_user_defined_field_delete_v1.py +++ b/plugins/action/network_device_user_defined_field_delete_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_device_user_defined_field_info.py b/plugins/action/network_device_user_defined_field_info.py index 4c593ab2fb..b4b1816cb0 100644 --- a/plugins/action/network_device_user_defined_field_info.py +++ b/plugins/action/network_device_user_defined_field_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_user_defined_field_update.py b/plugins/action/network_device_user_defined_field_update.py index 420179fd58..52d0df0df7 100644 --- a/plugins/action/network_device_user_defined_field_update.py +++ b/plugins/action/network_device_user_defined_field_update.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_user_defined_field_update_v1.py b/plugins/action/network_device_user_defined_field_update_v1.py index 1ef8a5e9b8..ddd27c5e39 100644 --- a/plugins/action/network_device_user_defined_field_update_v1.py +++ b/plugins/action/network_device_user_defined_field_update_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_device_user_defined_field_v1.py b/plugins/action/network_device_user_defined_field_v1.py index 7b228e0be2..f9cf071a28 100644 --- a/plugins/action/network_device_user_defined_field_v1.py +++ b/plugins/action/network_device_user_defined_field_v1.py @@ -127,7 +127,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -197,7 +198,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_device_user_defined_field_v1_info.py b/plugins/action/network_device_user_defined_field_v1_info.py index 40785ea8ee..039789c6a7 100644 --- a/plugins/action/network_device_user_defined_field_v1_info.py +++ b/plugins/action/network_device_user_defined_field_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_v1.py b/plugins/action/network_device_v1.py index 5f60c2b176..33d98be748 100644 --- a/plugins/action/network_device_v1.py +++ b/plugins/action/network_device_v1.py @@ -146,13 +146,19 @@ def get_all_params(self, name=None, id=None): self.new_object.get('associated_wlc_ip') new_object_params['license_name'] = self.new_object.get('license_name') new_object_params['license_type'] = self.new_object.get('license_type') - new_object_params['license_status'] = self.new_object.get('license_status') + new_object_params['license_status'] = self.new_object.get( + 'license_status') new_object_params['module_name'] = self.new_object.get('module_name') - new_object_params['module_equpimenttype'] = self.new_object.get('module_equpimenttype') - new_object_params['module_servicestate'] = self.new_object.get('module_servicestate') - new_object_params['module_vendorequipmenttype'] = self.new_object.get('module_vendorequipmenttype') - new_object_params['module_partnumber'] = self.new_object.get('module_partnumber') - new_object_params['module_operationstatecode'] = self.new_object.get('module_operationstatecode') + new_object_params['module_equpimenttype'] = self.new_object.get( + 'module_equpimenttype') + new_object_params['module_servicestate'] = self.new_object.get( + 'module_servicestate') + new_object_params['module_vendorequipmenttype'] = self.new_object.get( + 'module_vendorequipmenttype') + new_object_params['module_partnumber'] = self.new_object.get( + 'module_partnumber') + new_object_params['module_operationstatecode'] = self.new_object.get( + 'module_operationstatecode') new_object_params['id'] = id or self.new_object.get('id') new_object_params['device_support_level'] = self.new_object.get('deviceSupportLevel') or \ self.new_object.get('device_support_level') @@ -163,9 +169,12 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} new_object_params['cliTransport'] = self.new_object.get('cliTransport') - new_object_params['computeDevice'] = self.new_object.get('computeDevice') - new_object_params['enablePassword'] = self.new_object.get('enablePassword') - new_object_params['extendedDiscoveryInfo'] = self.new_object.get('extendedDiscoveryInfo') + new_object_params['computeDevice'] = self.new_object.get( + 'computeDevice') + new_object_params['enablePassword'] = self.new_object.get( + 'enablePassword') + new_object_params['extendedDiscoveryInfo'] = self.new_object.get( + 'extendedDiscoveryInfo') new_object_params['httpPassword'] = self.new_object.get('httpPassword') new_object_params['httpPort'] = self.new_object.get('httpPort') new_object_params['httpSecure'] = self.new_object.get('httpSecure') @@ -175,13 +184,19 @@ def create_params(self): new_object_params['netconfPort'] = self.new_object.get('netconfPort') new_object_params['password'] = self.new_object.get('password') new_object_params['serialNumber'] = self.new_object.get('serialNumber') - new_object_params['snmpAuthPassphrase'] = self.new_object.get('snmpAuthPassphrase') - new_object_params['snmpAuthProtocol'] = self.new_object.get('snmpAuthProtocol') + new_object_params['snmpAuthPassphrase'] = self.new_object.get( + 'snmpAuthPassphrase') + new_object_params['snmpAuthProtocol'] = self.new_object.get( + 'snmpAuthProtocol') new_object_params['snmpMode'] = self.new_object.get('snmpMode') - new_object_params['snmpPrivPassphrase'] = self.new_object.get('snmpPrivPassphrase') - new_object_params['snmpPrivProtocol'] = self.new_object.get('snmpPrivProtocol') - new_object_params['snmpROCommunity'] = self.new_object.get('snmpROCommunity') - new_object_params['snmpRWCommunity'] = self.new_object.get('snmpRWCommunity') + new_object_params['snmpPrivPassphrase'] = self.new_object.get( + 'snmpPrivPassphrase') + new_object_params['snmpPrivProtocol'] = self.new_object.get( + 'snmpPrivProtocol') + new_object_params['snmpROCommunity'] = self.new_object.get( + 'snmpROCommunity') + new_object_params['snmpRWCommunity'] = self.new_object.get( + 'snmpRWCommunity') new_object_params['snmpRetry'] = self.new_object.get('snmpRetry') new_object_params['snmpTimeout'] = self.new_object.get('snmpTimeout') new_object_params['snmpUserName'] = self.new_object.get('snmpUserName') @@ -199,9 +214,12 @@ def delete_by_id_params(self): def update_all_params(self): new_object_params = {} new_object_params['cliTransport'] = self.new_object.get('cliTransport') - new_object_params['computeDevice'] = self.new_object.get('computeDevice') - new_object_params['enablePassword'] = self.new_object.get('enablePassword') - new_object_params['extendedDiscoveryInfo'] = self.new_object.get('extendedDiscoveryInfo') + new_object_params['computeDevice'] = self.new_object.get( + 'computeDevice') + new_object_params['enablePassword'] = self.new_object.get( + 'enablePassword') + new_object_params['extendedDiscoveryInfo'] = self.new_object.get( + 'extendedDiscoveryInfo') new_object_params['httpPassword'] = self.new_object.get('httpPassword') new_object_params['httpPort'] = self.new_object.get('httpPort') new_object_params['httpSecure'] = self.new_object.get('httpSecure') @@ -211,19 +229,26 @@ def update_all_params(self): new_object_params['netconfPort'] = self.new_object.get('netconfPort') new_object_params['password'] = self.new_object.get('password') new_object_params['serialNumber'] = self.new_object.get('serialNumber') - new_object_params['snmpAuthPassphrase'] = self.new_object.get('snmpAuthPassphrase') - new_object_params['snmpAuthProtocol'] = self.new_object.get('snmpAuthProtocol') + new_object_params['snmpAuthPassphrase'] = self.new_object.get( + 'snmpAuthPassphrase') + new_object_params['snmpAuthProtocol'] = self.new_object.get( + 'snmpAuthProtocol') new_object_params['snmpMode'] = self.new_object.get('snmpMode') - new_object_params['snmpPrivPassphrase'] = self.new_object.get('snmpPrivPassphrase') - new_object_params['snmpPrivProtocol'] = self.new_object.get('snmpPrivProtocol') - new_object_params['snmpROCommunity'] = self.new_object.get('snmpROCommunity') - new_object_params['snmpRWCommunity'] = self.new_object.get('snmpRWCommunity') + new_object_params['snmpPrivPassphrase'] = self.new_object.get( + 'snmpPrivPassphrase') + new_object_params['snmpPrivProtocol'] = self.new_object.get( + 'snmpPrivProtocol') + new_object_params['snmpROCommunity'] = self.new_object.get( + 'snmpROCommunity') + new_object_params['snmpRWCommunity'] = self.new_object.get( + 'snmpRWCommunity') new_object_params['snmpRetry'] = self.new_object.get('snmpRetry') new_object_params['snmpTimeout'] = self.new_object.get('snmpTimeout') new_object_params['snmpUserName'] = self.new_object.get('snmpUserName') new_object_params['snmpVersion'] = self.new_object.get('snmpVersion') new_object_params['type'] = self.new_object.get('type') - new_object_params['updateMgmtIPaddressList'] = self.new_object.get('updateMgmtIPaddressList') + new_object_params['updateMgmtIPaddressList'] = self.new_object.get( + 'updateMgmtIPaddressList') new_object_params['userName'] = self.new_object.get('userName') return new_object_params @@ -275,7 +300,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) if _id: @@ -365,7 +391,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_device_v1_info.py b/plugins/action/network_device_v1_info.py index c0f8d73e78..b5f1882e03 100644 --- a/plugins/action/network_device_v1_info.py +++ b/plugins/action/network_device_v1_info.py @@ -71,7 +71,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -124,7 +125,8 @@ def get_object(self, params): module_name=params.get("module_name"), module_equpimenttype=params.get("module_equpimenttype"), module_servicestate=params.get("module_servicestate"), - module_vendorequipmenttype=params.get("module_vendorequipmenttype"), + module_vendorequipmenttype=params.get( + "module_vendorequipmenttype"), module_partnumber=params.get("module_partnumber"), module_operationstatecode=params.get("module_operationstatecode"), id=params.get("id"), diff --git a/plugins/action/network_device_vlan_info.py b/plugins/action/network_device_vlan_info.py index bcd65f0152..f8e909e3bc 100644 --- a/plugins/action/network_device_vlan_info.py +++ b/plugins/action/network_device_vlan_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_vlan_v1_info.py b/plugins/action/network_device_vlan_v1_info.py index 4ec3a7a633..1f85c315d8 100644 --- a/plugins/action/network_device_vlan_v1_info.py +++ b/plugins/action/network_device_vlan_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_device_wireless_lan_info.py b/plugins/action/network_device_wireless_lan_info.py index f6585085f9..970f5b5786 100644 --- a/plugins/action/network_device_wireless_lan_info.py +++ b/plugins/action/network_device_wireless_lan_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_device_wireless_lan_v1_info.py b/plugins/action/network_device_wireless_lan_v1_info.py index 143d83e5e7..27ed2a8366 100644 --- a/plugins/action/network_device_wireless_lan_v1_info.py +++ b/plugins/action/network_device_wireless_lan_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_devices_assigned_to_site_count_info.py b/plugins/action/network_devices_assigned_to_site_count_info.py index 25cee00f3f..c8430def4f 100644 --- a/plugins/action/network_devices_assigned_to_site_count_info.py +++ b/plugins/action/network_devices_assigned_to_site_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_assigned_to_site_count_v1_info.py b/plugins/action/network_devices_assigned_to_site_count_v1_info.py index a8c944eb5a..87b2089e17 100644 --- a/plugins/action/network_devices_assigned_to_site_count_v1_info.py +++ b/plugins/action/network_devices_assigned_to_site_count_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_devices_assigned_to_site_id_info.py b/plugins/action/network_devices_assigned_to_site_id_info.py index b9a30230db..a145af3b55 100644 --- a/plugins/action/network_devices_assigned_to_site_id_info.py +++ b/plugins/action/network_devices_assigned_to_site_id_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_assigned_to_site_id_v1_info.py b/plugins/action/network_devices_assigned_to_site_id_v1_info.py index 416a17282b..9fe3b37e8c 100644 --- a/plugins/action/network_devices_assigned_to_site_id_v1_info.py +++ b/plugins/action/network_devices_assigned_to_site_id_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_devices_assigned_to_site_info.py b/plugins/action/network_devices_assigned_to_site_info.py index aba1f7b008..0e59e10e68 100644 --- a/plugins/action/network_devices_assigned_to_site_info.py +++ b/plugins/action/network_devices_assigned_to_site_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_assigned_to_site_v1_info.py b/plugins/action/network_devices_assigned_to_site_v1_info.py index 9f034fbb7e..defc596519 100644 --- a/plugins/action/network_devices_assigned_to_site_v1_info.py +++ b/plugins/action/network_devices_assigned_to_site_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_devices_count_info.py b/plugins/action/network_devices_count_info.py index afafe9e9c0..c7851a120c 100644 --- a/plugins/action/network_devices_count_info.py +++ b/plugins/action/network_devices_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_count_v1_info.py b/plugins/action/network_devices_count_v1_info.py index 842d8a05e0..42ffb9a2fb 100644 --- a/plugins/action/network_devices_count_v1_info.py +++ b/plugins/action/network_devices_count_v1_info.py @@ -54,7 +54,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_devices_device_controllability_settings.py b/plugins/action/network_devices_device_controllability_settings.py index 0db9d19921..488e471736 100644 --- a/plugins/action/network_devices_device_controllability_settings.py +++ b/plugins/action/network_devices_device_controllability_settings.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_device_controllability_settings_info.py b/plugins/action/network_devices_device_controllability_settings_info.py index 5804074042..5fbefcb7e1 100644 --- a/plugins/action/network_devices_device_controllability_settings_info.py +++ b/plugins/action/network_devices_device_controllability_settings_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_device_controllability_settings_v1.py b/plugins/action/network_devices_device_controllability_settings_v1.py index 2ed45d99a2..01a7baf065 100644 --- a/plugins/action/network_devices_device_controllability_settings_v1.py +++ b/plugins/action/network_devices_device_controllability_settings_v1.py @@ -46,7 +46,8 @@ class NetworkDevicesDeviceControllabilitySettingsV1(object): def __init__(self, params, dnac): self.dnac = dnac self.new_object = dict( - autocorrectTelemetryConfig=params.get("autocorrectTelemetryConfig"), + autocorrectTelemetryConfig=params.get( + "autocorrectTelemetryConfig"), deviceControllability=params.get("deviceControllability"), ) @@ -56,8 +57,10 @@ def get_all_params(self, name=None, id=None): def update_all_params(self): new_object_params = {} - new_object_params['autocorrectTelemetryConfig'] = self.new_object.get('autocorrectTelemetryConfig') - new_object_params['deviceControllability'] = self.new_object.get('deviceControllability') + new_object_params['autocorrectTelemetryConfig'] = self.new_object.get( + 'autocorrectTelemetryConfig') + new_object_params['deviceControllability'] = self.new_object.get( + 'deviceControllability') return new_object_params def get_object_by_name(self, name): @@ -97,7 +100,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -132,7 +136,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -163,7 +168,8 @@ def run(self, tmp=None, task_vars=None): self._check_argspec() dnac = DNACSDK(self._task.args) - obj = NetworkDevicesDeviceControllabilitySettingsV1(self._task.args, dnac) + obj = NetworkDevicesDeviceControllabilitySettingsV1( + self._task.args, dnac) state = self._task.args.get("state") @@ -178,7 +184,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/network_devices_device_controllability_settings_v1_info.py b/plugins/action/network_devices_device_controllability_settings_v1_info.py index 6f8c99720f..1bc0ab466b 100644 --- a/plugins/action/network_devices_device_controllability_settings_v1_info.py +++ b/plugins/action/network_devices_device_controllability_settings_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_devices_info.py b/plugins/action/network_devices_info.py index 4e6f317287..4086d80e1c 100644 --- a/plugins/action/network_devices_info.py +++ b/plugins/action/network_devices_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_interfaces_query.py b/plugins/action/network_devices_interfaces_query.py index fcf517079c..617c81deaa 100644 --- a/plugins/action/network_devices_interfaces_query.py +++ b/plugins/action/network_devices_interfaces_query.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_interfaces_query_v2.py b/plugins/action/network_devices_interfaces_query_v2.py index d2060b7eca..c6f4571c13 100644 --- a/plugins/action/network_devices_interfaces_query_v2.py +++ b/plugins/action/network_devices_interfaces_query_v2.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_devices_issues_remediation_provision.py b/plugins/action/network_devices_issues_remediation_provision.py index 4b964b075e..cb678f8b6b 100644 --- a/plugins/action/network_devices_issues_remediation_provision.py +++ b/plugins/action/network_devices_issues_remediation_provision.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_issues_remediation_provision_v1.py b/plugins/action/network_devices_issues_remediation_provision_v1.py index 94f057f84c..2e2d76a1d6 100644 --- a/plugins/action/network_devices_issues_remediation_provision_v1.py +++ b/plugins/action/network_devices_issues_remediation_provision_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_devices_network_profiles_for_sites.py b/plugins/action/network_devices_network_profiles_for_sites.py index fcfee9d474..a317d927a9 100644 --- a/plugins/action/network_devices_network_profiles_for_sites.py +++ b/plugins/action/network_devices_network_profiles_for_sites.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_network_profiles_for_sites_count_info.py b/plugins/action/network_devices_network_profiles_for_sites_count_info.py index 675606b454..560fbd8038 100644 --- a/plugins/action/network_devices_network_profiles_for_sites_count_info.py +++ b/plugins/action/network_devices_network_profiles_for_sites_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_network_profiles_for_sites_count_v1_info.py b/plugins/action/network_devices_network_profiles_for_sites_count_v1_info.py index e809662c06..b47ba6254e 100644 --- a/plugins/action/network_devices_network_profiles_for_sites_count_v1_info.py +++ b/plugins/action/network_devices_network_profiles_for_sites_count_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_devices_network_profiles_for_sites_info.py b/plugins/action/network_devices_network_profiles_for_sites_info.py index 04606ba190..edafa88d7e 100644 --- a/plugins/action/network_devices_network_profiles_for_sites_info.py +++ b/plugins/action/network_devices_network_profiles_for_sites_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_network_profiles_for_sites_v1.py b/plugins/action/network_devices_network_profiles_for_sites_v1.py index 081fe6cc2c..4174944092 100644 --- a/plugins/action/network_devices_network_profiles_for_sites_v1.py +++ b/plugins/action/network_devices_network_profiles_for_sites_v1.py @@ -113,7 +113,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) if _id: @@ -155,7 +156,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_devices_network_profiles_for_sites_v1_info.py b/plugins/action/network_devices_network_profiles_for_sites_v1_info.py index e1247ab9bf..8b15446418 100644 --- a/plugins/action/network_devices_network_profiles_for_sites_v1_info.py +++ b/plugins/action/network_devices_network_profiles_for_sites_v1_info.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_devices_not_assigned_to_site_count_info.py b/plugins/action/network_devices_not_assigned_to_site_count_info.py index 491c07f753..6a9b2a32c6 100644 --- a/plugins/action/network_devices_not_assigned_to_site_count_info.py +++ b/plugins/action/network_devices_not_assigned_to_site_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_not_assigned_to_site_count_v1_info.py b/plugins/action/network_devices_not_assigned_to_site_count_v1_info.py index 2575dfdc87..88175c98f5 100644 --- a/plugins/action/network_devices_not_assigned_to_site_count_v1_info.py +++ b/plugins/action/network_devices_not_assigned_to_site_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_devices_not_assigned_to_site_info.py b/plugins/action/network_devices_not_assigned_to_site_info.py index 3a5dd37ee3..6fdac072a8 100644 --- a/plugins/action/network_devices_not_assigned_to_site_info.py +++ b/plugins/action/network_devices_not_assigned_to_site_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_not_assigned_to_site_v1_info.py b/plugins/action/network_devices_not_assigned_to_site_v1_info.py index b24df31b38..a68724f355 100644 --- a/plugins/action/network_devices_not_assigned_to_site_v1_info.py +++ b/plugins/action/network_devices_not_assigned_to_site_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_devices_query.py b/plugins/action/network_devices_query.py index 88e45b4311..d54969cb47 100644 --- a/plugins/action/network_devices_query.py +++ b/plugins/action/network_devices_query.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_query_count.py b/plugins/action/network_devices_query_count.py index 0bd0889927..aa7d899927 100644 --- a/plugins/action/network_devices_query_count.py +++ b/plugins/action/network_devices_query_count.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_query_count_v1.py b/plugins/action/network_devices_query_count_v1.py index a684d3fc9f..3d946e4d5b 100644 --- a/plugins/action/network_devices_query_count_v1.py +++ b/plugins/action/network_devices_query_count_v1.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_devices_query_v1.py b/plugins/action/network_devices_query_v1.py index a36f023a38..5180ebc16a 100644 --- a/plugins/action/network_devices_query_v1.py +++ b/plugins/action/network_devices_query_v1.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_devices_resync_interval_settings.py b/plugins/action/network_devices_resync_interval_settings.py index b783736d23..d1a3395497 100644 --- a/plugins/action/network_devices_resync_interval_settings.py +++ b/plugins/action/network_devices_resync_interval_settings.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_resync_interval_settings_id.py b/plugins/action/network_devices_resync_interval_settings_id.py index dcd5029b01..71203cf752 100644 --- a/plugins/action/network_devices_resync_interval_settings_id.py +++ b/plugins/action/network_devices_resync_interval_settings_id.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_resync_interval_settings_id_info.py b/plugins/action/network_devices_resync_interval_settings_id_info.py index b02992996d..1640d95d6a 100644 --- a/plugins/action/network_devices_resync_interval_settings_id_info.py +++ b/plugins/action/network_devices_resync_interval_settings_id_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_resync_interval_settings_id_v1.py b/plugins/action/network_devices_resync_interval_settings_id_v1.py index 0a4920b8f7..521896d2b1 100644 --- a/plugins/action/network_devices_resync_interval_settings_id_v1.py +++ b/plugins/action/network_devices_resync_interval_settings_id_v1.py @@ -99,7 +99,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -134,7 +135,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -180,7 +182,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/network_devices_resync_interval_settings_id_v1_info.py b/plugins/action/network_devices_resync_interval_settings_id_v1_info.py index b5c9cc9562..83c429d3aa 100644 --- a/plugins/action/network_devices_resync_interval_settings_id_v1_info.py +++ b/plugins/action/network_devices_resync_interval_settings_id_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_devices_resync_interval_settings_override.py b/plugins/action/network_devices_resync_interval_settings_override.py index b9b73ec9be..a3d2e7b853 100644 --- a/plugins/action/network_devices_resync_interval_settings_override.py +++ b/plugins/action/network_devices_resync_interval_settings_override.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_resync_interval_settings_override_v1.py b/plugins/action/network_devices_resync_interval_settings_override_v1.py index 2b3a60856c..15ed953a49 100644 --- a/plugins/action/network_devices_resync_interval_settings_override_v1.py +++ b/plugins/action/network_devices_resync_interval_settings_override_v1.py @@ -36,7 +36,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_devices_resync_interval_settings_v1.py b/plugins/action/network_devices_resync_interval_settings_v1.py index ab4d6d6c7f..834b3483b7 100644 --- a/plugins/action/network_devices_resync_interval_settings_v1.py +++ b/plugins/action/network_devices_resync_interval_settings_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_devices_summary_analytics.py b/plugins/action/network_devices_summary_analytics.py index aa8b6a959b..d544647100 100644 --- a/plugins/action/network_devices_summary_analytics.py +++ b/plugins/action/network_devices_summary_analytics.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_summary_analytics_v1.py b/plugins/action/network_devices_summary_analytics_v1.py index 5480fe9a35..3ce3777f36 100644 --- a/plugins/action/network_devices_summary_analytics_v1.py +++ b/plugins/action/network_devices_summary_analytics_v1.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_devices_trend_analytics.py b/plugins/action/network_devices_trend_analytics.py index f256e38786..6c8c89c51e 100644 --- a/plugins/action/network_devices_trend_analytics.py +++ b/plugins/action/network_devices_trend_analytics.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_trend_analytics_id.py b/plugins/action/network_devices_trend_analytics_id.py index 7369a7277b..0dedbd0086 100644 --- a/plugins/action/network_devices_trend_analytics_id.py +++ b/plugins/action/network_devices_trend_analytics_id.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_trend_analytics_id_v1.py b/plugins/action/network_devices_trend_analytics_id_v1.py index 1b2f7f245a..ac6deb8304 100644 --- a/plugins/action/network_devices_trend_analytics_id_v1.py +++ b/plugins/action/network_devices_trend_analytics_id_v1.py @@ -45,7 +45,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_devices_trend_analytics_v1.py b/plugins/action/network_devices_trend_analytics_v1.py index 6f9ee6c6d3..a363ecb0ee 100644 --- a/plugins/action/network_devices_trend_analytics_v1.py +++ b/plugins/action/network_devices_trend_analytics_v1.py @@ -44,7 +44,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_devices_unassign_from_site_apply.py b/plugins/action/network_devices_unassign_from_site_apply.py index 180cfa8ea3..411b6b5c49 100644 --- a/plugins/action/network_devices_unassign_from_site_apply.py +++ b/plugins/action/network_devices_unassign_from_site_apply.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_devices_unassign_from_site_apply_v1.py b/plugins/action/network_devices_unassign_from_site_apply_v1.py index c48fea9306..66dafb4d85 100644 --- a/plugins/action/network_devices_unassign_from_site_apply_v1.py +++ b/plugins/action/network_devices_unassign_from_site_apply_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_devices_v1_info.py b/plugins/action/network_devices_v1_info.py index e37a72d87a..cfaaabe957 100644 --- a/plugins/action/network_devices_v1_info.py +++ b/plugins/action/network_devices_v1_info.py @@ -58,7 +58,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_info.py b/plugins/action/network_info.py index a0425da6d9..050b89e995 100644 --- a/plugins/action/network_info.py +++ b/plugins/action/network_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_profiles_for_sites_site_assignments.py b/plugins/action/network_profiles_for_sites_site_assignments.py index b7db4d53fa..3c5d568628 100644 --- a/plugins/action/network_profiles_for_sites_site_assignments.py +++ b/plugins/action/network_profiles_for_sites_site_assignments.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_profiles_for_sites_site_assignments_bulk_create.py b/plugins/action/network_profiles_for_sites_site_assignments_bulk_create.py index 0009d85500..0b0d15bfe7 100644 --- a/plugins/action/network_profiles_for_sites_site_assignments_bulk_create.py +++ b/plugins/action/network_profiles_for_sites_site_assignments_bulk_create.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_profiles_for_sites_site_assignments_bulk_create_v1.py b/plugins/action/network_profiles_for_sites_site_assignments_bulk_create_v1.py index 4dfb738de7..5df1a576a3 100644 --- a/plugins/action/network_profiles_for_sites_site_assignments_bulk_create_v1.py +++ b/plugins/action/network_profiles_for_sites_site_assignments_bulk_create_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_profiles_for_sites_site_assignments_bulk_delete.py b/plugins/action/network_profiles_for_sites_site_assignments_bulk_delete.py index de261be6ed..bfd484485a 100644 --- a/plugins/action/network_profiles_for_sites_site_assignments_bulk_delete.py +++ b/plugins/action/network_profiles_for_sites_site_assignments_bulk_delete.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_profiles_for_sites_site_assignments_bulk_delete_v1.py b/plugins/action/network_profiles_for_sites_site_assignments_bulk_delete_v1.py index cda9a3aca8..5b7317078d 100644 --- a/plugins/action/network_profiles_for_sites_site_assignments_bulk_delete_v1.py +++ b/plugins/action/network_profiles_for_sites_site_assignments_bulk_delete_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_profiles_for_sites_site_assignments_count_info.py b/plugins/action/network_profiles_for_sites_site_assignments_count_info.py index deec3dbdbb..58b6f72643 100644 --- a/plugins/action/network_profiles_for_sites_site_assignments_count_info.py +++ b/plugins/action/network_profiles_for_sites_site_assignments_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_profiles_for_sites_site_assignments_count_v1_info.py b/plugins/action/network_profiles_for_sites_site_assignments_count_v1_info.py index a325f5d571..622988a036 100644 --- a/plugins/action/network_profiles_for_sites_site_assignments_count_v1_info.py +++ b/plugins/action/network_profiles_for_sites_site_assignments_count_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_profiles_for_sites_site_assignments_info.py b/plugins/action/network_profiles_for_sites_site_assignments_info.py index 73f014c256..fa9b681119 100644 --- a/plugins/action/network_profiles_for_sites_site_assignments_info.py +++ b/plugins/action/network_profiles_for_sites_site_assignments_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_profiles_for_sites_site_assignments_v1.py b/plugins/action/network_profiles_for_sites_site_assignments_v1.py index cffb23aa64..48552a76cc 100644 --- a/plugins/action/network_profiles_for_sites_site_assignments_v1.py +++ b/plugins/action/network_profiles_for_sites_site_assignments_v1.py @@ -109,7 +109,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -159,7 +160,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_profiles_for_sites_site_assignments_v1_info.py b/plugins/action/network_profiles_for_sites_site_assignments_v1_info.py index 56b2923a76..88b35b100f 100644 --- a/plugins/action/network_profiles_for_sites_site_assignments_v1_info.py +++ b/plugins/action/network_profiles_for_sites_site_assignments_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_update.py b/plugins/action/network_update.py index 212430f6ff..8ffb1e9c39 100644 --- a/plugins/action/network_update.py +++ b/plugins/action/network_update.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/network_update_v1.py b/plugins/action/network_update_v1.py index 9eeea53952..2d603d3b83 100644 --- a/plugins/action/network_update_v1.py +++ b/plugins/action/network_update_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_v1_info.py b/plugins/action/network_v1_info.py index 46fc885add..90716adeab 100644 --- a/plugins/action/network_v1_info.py +++ b/plugins/action/network_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/network_v2.py b/plugins/action/network_v2.py index f9087cbf00..2832a7aa7b 100644 --- a/plugins/action/network_v2.py +++ b/plugins/action/network_v2.py @@ -108,7 +108,8 @@ def exists(self): _id = prev_obj.get("id") _id = _id or prev_obj.get("siteId") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) self.new_object.update(dict(site_id=_id)) @@ -162,7 +163,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/network_v2_info.py b/plugins/action/network_v2_info.py index 39f1e6b208..1e7b7484e0 100644 --- a/plugins/action/network_v2_info.py +++ b/plugins/action/network_v2_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/path_trace.py b/plugins/action/path_trace.py index 56917b8148..44ac5aa54d 100644 --- a/plugins/action/path_trace.py +++ b/plugins/action/path_trace.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/path_trace_info.py b/plugins/action/path_trace_info.py index bf601763ef..e5c7e31c0d 100644 --- a/plugins/action/path_trace_info.py +++ b/plugins/action/path_trace_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/path_trace_v1.py b/plugins/action/path_trace_v1.py index 7cc61c99c8..49c18cc217 100644 --- a/plugins/action/path_trace_v1.py +++ b/plugins/action/path_trace_v1.py @@ -101,7 +101,8 @@ def create_params(self): new_object_params['destIP'] = self.new_object.get('destIP') new_object_params['destPort'] = self.new_object.get('destPort') new_object_params['inclusions'] = self.new_object.get('inclusions') - new_object_params['periodicRefresh'] = self.new_object.get('periodicRefresh') + new_object_params['periodicRefresh'] = self.new_object.get( + 'periodicRefresh') new_object_params['protocol'] = self.new_object.get('protocol') new_object_params['sourceIP'] = self.new_object.get('sourceIP') new_object_params['sourcePort'] = self.new_object.get('sourcePort') @@ -109,7 +110,8 @@ def create_params(self): def delete_by_id_params(self): new_object_params = {} - new_object_params['flow_analysis_id'] = self.new_object.get('flow_analysis_id') + new_object_params['flow_analysis_id'] = self.new_object.get( + 'flow_analysis_id') return new_object_params def get_object_by_name(self, name): @@ -162,7 +164,8 @@ def exists(self): _id = prev_obj.get("id") _id = _id or prev_obj.get("flowAnalysisId") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) self.new_object.update(dict(flow_analysis_id=_id)) @@ -224,7 +227,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/path_trace_v1_info.py b/plugins/action/path_trace_v1_info.py index 23d26aa61c..024917a702 100644 --- a/plugins/action/path_trace_v1_info.py +++ b/plugins/action/path_trace_v1_info.py @@ -53,7 +53,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/planned_access_points.py b/plugins/action/planned_access_points.py index c16dca2ec3..016140b610 100644 --- a/plugins/action/planned_access_points.py +++ b/plugins/action/planned_access_points.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/planned_access_points_info.py b/plugins/action/planned_access_points_info.py index b01115be60..8636c42f6f 100644 --- a/plugins/action/planned_access_points_info.py +++ b/plugins/action/planned_access_points_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/planned_access_points_v1.py b/plugins/action/planned_access_points_v1.py index 623295f2eb..b39d5f9e75 100644 --- a/plugins/action/planned_access_points_v1.py +++ b/plugins/action/planned_access_points_v1.py @@ -87,7 +87,8 @@ def create_params(self): def delete_by_id_params(self): new_object_params = {} new_object_params['floor_id'] = self.new_object.get('floor_id') - new_object_params['planned_access_point_uuid'] = self.new_object.get('planned_access_point_uuid') + new_object_params['planned_access_point_uuid'] = self.new_object.get( + 'planned_access_point_uuid') return new_object_params def update_all_params(self): @@ -152,7 +153,8 @@ def exists(self): _id = prev_obj.get("id") _id = _id or prev_obj.get("plannedAccessPointUuid") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) self.new_object.update(dict(planned_access_point_uuid=_id)) @@ -223,7 +225,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/planned_access_points_v1_info.py b/plugins/action/planned_access_points_v1_info.py index 549ba04bff..a1285a62b3 100644 --- a/plugins/action/planned_access_points_v1_info.py +++ b/plugins/action/planned_access_points_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/platform_nodes_configuration_summary_info.py b/plugins/action/platform_nodes_configuration_summary_info.py index 3d0309c70f..78de994b53 100644 --- a/plugins/action/platform_nodes_configuration_summary_info.py +++ b/plugins/action/platform_nodes_configuration_summary_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/platform_nodes_configuration_summary_v1_info.py b/plugins/action/platform_nodes_configuration_summary_v1_info.py index 8063ae16c9..5019d8bb0e 100644 --- a/plugins/action/platform_nodes_configuration_summary_v1_info.py +++ b/plugins/action/platform_nodes_configuration_summary_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/platform_release_summary_info.py b/plugins/action/platform_release_summary_info.py index 260438fd3a..fd92e54987 100644 --- a/plugins/action/platform_release_summary_info.py +++ b/plugins/action/platform_release_summary_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/platform_release_summary_v1_info.py b/plugins/action/platform_release_summary_v1_info.py index 449ac4cf89..eae1e063c8 100644 --- a/plugins/action/platform_release_summary_v1_info.py +++ b/plugins/action/platform_release_summary_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/pnp_device.py b/plugins/action/pnp_device.py index 779c932cd8..17f99737c1 100644 --- a/plugins/action/pnp_device.py +++ b/plugins/action/pnp_device.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_device_authorize.py b/plugins/action/pnp_device_authorize.py index 875151abf4..39518bdb6b 100644 --- a/plugins/action/pnp_device_authorize.py +++ b/plugins/action/pnp_device_authorize.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_device_authorize_v1.py b/plugins/action/pnp_device_authorize_v1.py index 2dc592e3cd..ea54c3a8b9 100644 --- a/plugins/action/pnp_device_authorize_v1.py +++ b/plugins/action/pnp_device_authorize_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/pnp_device_claim.py b/plugins/action/pnp_device_claim.py index 9a25b2ce7c..4c3fa67ee8 100644 --- a/plugins/action/pnp_device_claim.py +++ b/plugins/action/pnp_device_claim.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_device_claim_to_site.py b/plugins/action/pnp_device_claim_to_site.py index 2e55f788f5..61b506b793 100644 --- a/plugins/action/pnp_device_claim_to_site.py +++ b/plugins/action/pnp_device_claim_to_site.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_device_claim_to_site_v1.py b/plugins/action/pnp_device_claim_to_site_v1.py index d6ca917681..fed4292bdd 100644 --- a/plugins/action/pnp_device_claim_to_site_v1.py +++ b/plugins/action/pnp_device_claim_to_site_v1.py @@ -49,7 +49,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/pnp_device_claim_v1.py b/plugins/action/pnp_device_claim_v1.py index 33bcac97a6..a158eac5cb 100644 --- a/plugins/action/pnp_device_claim_v1.py +++ b/plugins/action/pnp_device_claim_v1.py @@ -46,7 +46,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/pnp_device_config_preview.py b/plugins/action/pnp_device_config_preview.py index fac9f45293..933d07573d 100644 --- a/plugins/action/pnp_device_config_preview.py +++ b/plugins/action/pnp_device_config_preview.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_device_config_preview_v1.py b/plugins/action/pnp_device_config_preview_v1.py index c341141e42..5c042a2f9d 100644 --- a/plugins/action/pnp_device_config_preview_v1.py +++ b/plugins/action/pnp_device_config_preview_v1.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/pnp_device_count_info.py b/plugins/action/pnp_device_count_info.py index b7917353d4..c629d223b9 100644 --- a/plugins/action/pnp_device_count_info.py +++ b/plugins/action/pnp_device_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_device_count_v1_info.py b/plugins/action/pnp_device_count_v1_info.py index a43bf56827..0b2cc4145f 100644 --- a/plugins/action/pnp_device_count_v1_info.py +++ b/plugins/action/pnp_device_count_v1_info.py @@ -48,7 +48,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/pnp_device_history_info.py b/plugins/action/pnp_device_history_info.py index 6e18870567..2391cd5894 100644 --- a/plugins/action/pnp_device_history_info.py +++ b/plugins/action/pnp_device_history_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_device_history_v1_info.py b/plugins/action/pnp_device_history_v1_info.py index ad19e48cef..664aa49660 100644 --- a/plugins/action/pnp_device_history_v1_info.py +++ b/plugins/action/pnp_device_history_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/pnp_device_import.py b/plugins/action/pnp_device_import.py index 130448d8a6..cf2680f239 100644 --- a/plugins/action/pnp_device_import.py +++ b/plugins/action/pnp_device_import.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_device_import_v1.py b/plugins/action/pnp_device_import_v1.py index 9ff45ccc0c..8ccfe151e9 100644 --- a/plugins/action/pnp_device_import_v1.py +++ b/plugins/action/pnp_device_import_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/pnp_device_info.py b/plugins/action/pnp_device_info.py index 54b122625b..266a127ccf 100644 --- a/plugins/action/pnp_device_info.py +++ b/plugins/action/pnp_device_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_device_reset.py b/plugins/action/pnp_device_reset.py index efaf3bc48d..febf394411 100644 --- a/plugins/action/pnp_device_reset.py +++ b/plugins/action/pnp_device_reset.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_device_reset_v1.py b/plugins/action/pnp_device_reset_v1.py index 24174dde0b..1c90e422fd 100644 --- a/plugins/action/pnp_device_reset_v1.py +++ b/plugins/action/pnp_device_reset_v1.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/pnp_device_unclaim.py b/plugins/action/pnp_device_unclaim.py index 3a3efecd0c..844ee774f1 100644 --- a/plugins/action/pnp_device_unclaim.py +++ b/plugins/action/pnp_device_unclaim.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_device_unclaim_v1.py b/plugins/action/pnp_device_unclaim_v1.py index aeb4c8a1b3..41338c4519 100644 --- a/plugins/action/pnp_device_unclaim_v1.py +++ b/plugins/action/pnp_device_unclaim_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/pnp_device_v1.py b/plugins/action/pnp_device_v1.py index 3ed4c1f5f9..8590d121e6 100644 --- a/plugins/action/pnp_device_v1.py +++ b/plugins/action/pnp_device_v1.py @@ -149,7 +149,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) if _id: @@ -220,7 +221,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/pnp_device_v1_info.py b/plugins/action/pnp_device_v1_info.py index 9b2cee5cfc..13cd478f10 100644 --- a/plugins/action/pnp_device_v1_info.py +++ b/plugins/action/pnp_device_v1_info.py @@ -56,7 +56,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/pnp_global_settings.py b/plugins/action/pnp_global_settings.py index 81e159331a..7ae3e4c85a 100644 --- a/plugins/action/pnp_global_settings.py +++ b/plugins/action/pnp_global_settings.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_global_settings_info.py b/plugins/action/pnp_global_settings_info.py index 340469d720..6d08248b16 100644 --- a/plugins/action/pnp_global_settings_info.py +++ b/plugins/action/pnp_global_settings_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_global_settings_v1.py b/plugins/action/pnp_global_settings_v1.py index 0d855b0e0e..f7b618bde9 100644 --- a/plugins/action/pnp_global_settings_v1.py +++ b/plugins/action/pnp_global_settings_v1.py @@ -62,8 +62,10 @@ def update_all_params(self): new_object_params = {} new_object_params['id'] = self.new_object.get('id') new_object_params['acceptEula'] = self.new_object.get('acceptEula') - new_object_params['defaultProfile'] = self.new_object.get('defaultProfile') - new_object_params['savaMappingList'] = self.new_object.get('savaMappingList') + new_object_params['defaultProfile'] = self.new_object.get( + 'defaultProfile') + new_object_params['savaMappingList'] = self.new_object.get( + 'savaMappingList') return new_object_params def get_object_by_name(self, name): @@ -103,7 +105,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -140,7 +143,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -186,7 +190,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/pnp_global_settings_v1_info.py b/plugins/action/pnp_global_settings_v1_info.py index babc612523..ede086f1d8 100644 --- a/plugins/action/pnp_global_settings_v1_info.py +++ b/plugins/action/pnp_global_settings_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/pnp_server_profile_update.py b/plugins/action/pnp_server_profile_update.py index 4215fe326f..2835db1e19 100644 --- a/plugins/action/pnp_server_profile_update.py +++ b/plugins/action/pnp_server_profile_update.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_server_profile_update_v1.py b/plugins/action/pnp_server_profile_update_v1.py index 4cba6281bd..e5251d5249 100644 --- a/plugins/action/pnp_server_profile_update_v1.py +++ b/plugins/action/pnp_server_profile_update_v1.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/pnp_smart_account_domains_info.py b/plugins/action/pnp_smart_account_domains_info.py index 2ca6657846..d03a1c693b 100644 --- a/plugins/action/pnp_smart_account_domains_info.py +++ b/plugins/action/pnp_smart_account_domains_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_smart_account_domains_v1_info.py b/plugins/action/pnp_smart_account_domains_v1_info.py index 1e5fc449d5..dbc66957b4 100644 --- a/plugins/action/pnp_smart_account_domains_v1_info.py +++ b/plugins/action/pnp_smart_account_domains_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/pnp_virtual_account_add.py b/plugins/action/pnp_virtual_account_add.py index cdfffe8d8b..5e8527e902 100644 --- a/plugins/action/pnp_virtual_account_add.py +++ b/plugins/action/pnp_virtual_account_add.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_virtual_account_add_v1.py b/plugins/action/pnp_virtual_account_add_v1.py index 6b450d92f8..a64c3f195c 100644 --- a/plugins/action/pnp_virtual_account_add_v1.py +++ b/plugins/action/pnp_virtual_account_add_v1.py @@ -49,7 +49,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/pnp_virtual_account_deregister.py b/plugins/action/pnp_virtual_account_deregister.py index ed3c5e1bd8..d7112368e7 100644 --- a/plugins/action/pnp_virtual_account_deregister.py +++ b/plugins/action/pnp_virtual_account_deregister.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_virtual_account_deregister_v1.py b/plugins/action/pnp_virtual_account_deregister_v1.py index df56b46be1..07886c06f8 100644 --- a/plugins/action/pnp_virtual_account_deregister_v1.py +++ b/plugins/action/pnp_virtual_account_deregister_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/pnp_virtual_account_devices_sync.py b/plugins/action/pnp_virtual_account_devices_sync.py index 62f5d1b06f..7c88ab3496 100644 --- a/plugins/action/pnp_virtual_account_devices_sync.py +++ b/plugins/action/pnp_virtual_account_devices_sync.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_virtual_account_devices_sync_v1.py b/plugins/action/pnp_virtual_account_devices_sync_v1.py index 22f43d588f..b9aa8ba7aa 100644 --- a/plugins/action/pnp_virtual_account_devices_sync_v1.py +++ b/plugins/action/pnp_virtual_account_devices_sync_v1.py @@ -49,7 +49,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/pnp_virtual_account_sync_result_info.py b/plugins/action/pnp_virtual_account_sync_result_info.py index 3ae0281746..1005ba1c4f 100644 --- a/plugins/action/pnp_virtual_account_sync_result_info.py +++ b/plugins/action/pnp_virtual_account_sync_result_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_virtual_account_sync_result_v1_info.py b/plugins/action/pnp_virtual_account_sync_result_v1_info.py index 5e3550be02..3623862040 100644 --- a/plugins/action/pnp_virtual_account_sync_result_v1_info.py +++ b/plugins/action/pnp_virtual_account_sync_result_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/pnp_virtual_accounts_info.py b/plugins/action/pnp_virtual_accounts_info.py index 2320f638f4..8f7b31eeb2 100644 --- a/plugins/action/pnp_virtual_accounts_info.py +++ b/plugins/action/pnp_virtual_accounts_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_virtual_accounts_v1_info.py b/plugins/action/pnp_virtual_accounts_v1_info.py index 620f47348c..8bbd1d0e13 100644 --- a/plugins/action/pnp_virtual_accounts_v1_info.py +++ b/plugins/action/pnp_virtual_accounts_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/pnp_workflow.py b/plugins/action/pnp_workflow.py index c619360d78..683fe16207 100644 --- a/plugins/action/pnp_workflow.py +++ b/plugins/action/pnp_workflow.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_workflow_count_info.py b/plugins/action/pnp_workflow_count_info.py index 5de3f5553f..899ae0ee90 100644 --- a/plugins/action/pnp_workflow_count_info.py +++ b/plugins/action/pnp_workflow_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_workflow_count_v1_info.py b/plugins/action/pnp_workflow_count_v1_info.py index 5f70c0306d..5b957fb439 100644 --- a/plugins/action/pnp_workflow_count_v1_info.py +++ b/plugins/action/pnp_workflow_count_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/pnp_workflow_info.py b/plugins/action/pnp_workflow_info.py index 358eccc4fe..c45203619e 100644 --- a/plugins/action/pnp_workflow_info.py +++ b/plugins/action/pnp_workflow_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/pnp_workflow_v1.py b/plugins/action/pnp_workflow_v1.py index 76f51efa0a..256e7ccc5c 100644 --- a/plugins/action/pnp_workflow_v1.py +++ b/plugins/action/pnp_workflow_v1.py @@ -102,7 +102,8 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} new_object_params['_id'] = self.new_object.get('_id') - new_object_params['addToInventory'] = self.new_object.get('addToInventory') + new_object_params['addToInventory'] = self.new_object.get( + 'addToInventory') new_object_params['addedOn'] = self.new_object.get('addedOn') new_object_params['configId'] = self.new_object.get('configId') new_object_params['currTaskIdx'] = self.new_object.get('currTaskIdx') @@ -130,7 +131,8 @@ def delete_by_id_params(self): def update_by_id_params(self): new_object_params = {} new_object_params['_id'] = self.new_object.get('_id') - new_object_params['addToInventory'] = self.new_object.get('addToInventory') + new_object_params['addToInventory'] = self.new_object.get( + 'addToInventory') new_object_params['addedOn'] = self.new_object.get('addedOn') new_object_params['configId'] = self.new_object.get('configId') new_object_params['currTaskIdx'] = self.new_object.get('currTaskIdx') @@ -199,7 +201,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) if _id: @@ -288,7 +291,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/pnp_workflow_v1_info.py b/plugins/action/pnp_workflow_v1_info.py index e2962979fe..c93342fc0b 100644 --- a/plugins/action/pnp_workflow_v1_info.py +++ b/plugins/action/pnp_workflow_v1_info.py @@ -44,7 +44,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/product_names_count_info.py b/plugins/action/product_names_count_info.py index 660049d844..8500205d0f 100644 --- a/plugins/action/product_names_count_info.py +++ b/plugins/action/product_names_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/product_names_count_v1_info.py b/plugins/action/product_names_count_v1_info.py index 6cc3cecdb5..2878ea3f69 100644 --- a/plugins/action/product_names_count_v1_info.py +++ b/plugins/action/product_names_count_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/product_names_info.py b/plugins/action/product_names_info.py index 7c56f739d4..5ef5280641 100644 --- a/plugins/action/product_names_info.py +++ b/plugins/action/product_names_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/product_names_v1_info.py b/plugins/action/product_names_v1_info.py index e8e76ad749..0accbef6dd 100644 --- a/plugins/action/product_names_v1_info.py +++ b/plugins/action/product_names_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/projects_details_info.py b/plugins/action/projects_details_info.py index 6470a563f8..71ed86a10b 100644 --- a/plugins/action/projects_details_info.py +++ b/plugins/action/projects_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/projects_details_v2_info.py b/plugins/action/projects_details_v2_info.py index 224619693b..a56a4d35b2 100644 --- a/plugins/action/projects_details_v2_info.py +++ b/plugins/action/projects_details_v2_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/provisioning_settings.py b/plugins/action/provisioning_settings.py index 8a4ecf747e..fb5d617efa 100644 --- a/plugins/action/provisioning_settings.py +++ b/plugins/action/provisioning_settings.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/provisioning_settings_info.py b/plugins/action/provisioning_settings_info.py index 894356abd5..a1d461cbbc 100644 --- a/plugins/action/provisioning_settings_info.py +++ b/plugins/action/provisioning_settings_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/provisioning_settings_v1.py b/plugins/action/provisioning_settings_v1.py index e5e739dcd2..443d0f0388 100644 --- a/plugins/action/provisioning_settings_v1.py +++ b/plugins/action/provisioning_settings_v1.py @@ -56,8 +56,10 @@ def get_all_params(self, name=None, id=None): def update_all_params(self): new_object_params = {} - new_object_params['requireItsmApproval'] = self.new_object.get('requireItsmApproval') - new_object_params['requirePreview'] = self.new_object.get('requirePreview') + new_object_params['requireItsmApproval'] = self.new_object.get( + 'requireItsmApproval') + new_object_params['requirePreview'] = self.new_object.get( + 'requirePreview') return new_object_params def get_object_by_name(self, name): @@ -97,7 +99,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -132,7 +135,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -178,7 +182,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/provisioning_settings_v1_info.py b/plugins/action/provisioning_settings_v1_info.py index 9f68860ee6..ad925f9f00 100644 --- a/plugins/action/provisioning_settings_v1_info.py +++ b/plugins/action/provisioning_settings_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/qos_device_interface.py b/plugins/action/qos_device_interface.py index e3c8f64091..d3c7bad185 100644 --- a/plugins/action/qos_device_interface.py +++ b/plugins/action/qos_device_interface.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/qos_device_interface_info.py b/plugins/action/qos_device_interface_info.py index c5a53afb35..365c66141b 100644 --- a/plugins/action/qos_device_interface_info.py +++ b/plugins/action/qos_device_interface_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/qos_device_interface_info_count_info.py b/plugins/action/qos_device_interface_info_count_info.py index 18f99f151b..9ab5bfffea 100644 --- a/plugins/action/qos_device_interface_info_count_info.py +++ b/plugins/action/qos_device_interface_info_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/qos_device_interface_info_count_v1_info.py b/plugins/action/qos_device_interface_info_count_v1_info.py index 959be2dc1c..9be6963bca 100644 --- a/plugins/action/qos_device_interface_info_count_v1_info.py +++ b/plugins/action/qos_device_interface_info_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/qos_device_interface_v1.py b/plugins/action/qos_device_interface_v1.py index 6de306109f..e891e38721 100644 --- a/plugins/action/qos_device_interface_v1.py +++ b/plugins/action/qos_device_interface_v1.py @@ -127,7 +127,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -201,7 +202,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/qos_device_interface_v1_info.py b/plugins/action/qos_device_interface_v1_info.py index cdc0331ef8..42354bbeda 100644 --- a/plugins/action/qos_device_interface_v1_info.py +++ b/plugins/action/qos_device_interface_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/reports.py b/plugins/action/reports.py index b149d49c2e..9fcae6bd11 100644 --- a/plugins/action/reports.py +++ b/plugins/action/reports.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/reports_executions_info.py b/plugins/action/reports_executions_info.py index 742a9a5682..2d235ba941 100644 --- a/plugins/action/reports_executions_info.py +++ b/plugins/action/reports_executions_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/reports_executions_v1_info.py b/plugins/action/reports_executions_v1_info.py index 863c9a73b5..788f687a2c 100644 --- a/plugins/action/reports_executions_v1_info.py +++ b/plugins/action/reports_executions_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/reports_info.py b/plugins/action/reports_info.py index 95dfb25bc3..ce2aaad364 100644 --- a/plugins/action/reports_info.py +++ b/plugins/action/reports_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/reports_v1.py b/plugins/action/reports_v1.py index 42bde4a918..b958c7c3e3 100644 --- a/plugins/action/reports_v1.py +++ b/plugins/action/reports_v1.py @@ -82,7 +82,8 @@ def create_params(self): new_object_params['schedule'] = self.new_object.get('schedule') new_object_params['view'] = self.new_object.get('view') new_object_params['viewGroupId'] = self.new_object.get('viewGroupId') - new_object_params['viewGroupVersion'] = self.new_object.get('viewGroupVersion') + new_object_params['viewGroupVersion'] = self.new_object.get( + 'viewGroupVersion') new_object_params['dataCategory'] = self.new_object.get('dataCategory') return new_object_params @@ -141,7 +142,8 @@ def exists(self): _id = prev_obj.get("id") _id = _id or prev_obj.get("reportId") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) self.new_object.update(dict(report_id=_id)) @@ -203,7 +205,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/reports_v1_info.py b/plugins/action/reports_v1_info.py index 4a93415dda..51502af0cc 100644 --- a/plugins/action/reports_v1_info.py +++ b/plugins/action/reports_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/reports_view_group_info.py b/plugins/action/reports_view_group_info.py index 814a056466..2855b6457e 100644 --- a/plugins/action/reports_view_group_info.py +++ b/plugins/action/reports_view_group_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/reports_view_group_v1_info.py b/plugins/action/reports_view_group_v1_info.py index 5ab2f1368a..fd25b68b2a 100644 --- a/plugins/action/reports_view_group_v1_info.py +++ b/plugins/action/reports_view_group_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/reports_view_group_view_info.py b/plugins/action/reports_view_group_view_info.py index 5e59647c0f..a349c499a0 100644 --- a/plugins/action/reports_view_group_view_info.py +++ b/plugins/action/reports_view_group_view_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/reports_view_group_view_v1_info.py b/plugins/action/reports_view_group_view_v1_info.py index 32bd3026da..93f94d67ae 100644 --- a/plugins/action/reports_view_group_view_v1_info.py +++ b/plugins/action/reports_view_group_view_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -94,7 +95,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/reserve_ip_subpool.py b/plugins/action/reserve_ip_subpool.py index 7b0f9b0214..230971cf2c 100644 --- a/plugins/action/reserve_ip_subpool.py +++ b/plugins/action/reserve_ip_subpool.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/reserve_ip_subpool_create.py b/plugins/action/reserve_ip_subpool_create.py index fc01348467..705b0fd4e8 100644 --- a/plugins/action/reserve_ip_subpool_create.py +++ b/plugins/action/reserve_ip_subpool_create.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/reserve_ip_subpool_create_v1.py b/plugins/action/reserve_ip_subpool_create_v1.py index 2cd67fc306..dfe43cbdd1 100644 --- a/plugins/action/reserve_ip_subpool_create_v1.py +++ b/plugins/action/reserve_ip_subpool_create_v1.py @@ -57,7 +57,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/reserve_ip_subpool_delete.py b/plugins/action/reserve_ip_subpool_delete.py index e24aa5f92a..4e4adc59b9 100644 --- a/plugins/action/reserve_ip_subpool_delete.py +++ b/plugins/action/reserve_ip_subpool_delete.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/reserve_ip_subpool_delete_v1.py b/plugins/action/reserve_ip_subpool_delete_v1.py index 8cce47dfa1..c6cdeeecde 100644 --- a/plugins/action/reserve_ip_subpool_delete_v1.py +++ b/plugins/action/reserve_ip_subpool_delete_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/reserve_ip_subpool_info.py b/plugins/action/reserve_ip_subpool_info.py index 2180c906a4..be78dcc733 100644 --- a/plugins/action/reserve_ip_subpool_info.py +++ b/plugins/action/reserve_ip_subpool_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/reserve_ip_subpool_update.py b/plugins/action/reserve_ip_subpool_update.py index ed514d83ea..c085dc2d3c 100644 --- a/plugins/action/reserve_ip_subpool_update.py +++ b/plugins/action/reserve_ip_subpool_update.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/reserve_ip_subpool_update_v1.py b/plugins/action/reserve_ip_subpool_update_v1.py index a98d146be4..d9cfa0b822 100644 --- a/plugins/action/reserve_ip_subpool_update_v1.py +++ b/plugins/action/reserve_ip_subpool_update_v1.py @@ -52,7 +52,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/reserve_ip_subpool_v1.py b/plugins/action/reserve_ip_subpool_v1.py index dc951e4c74..2f4f7ed2fd 100644 --- a/plugins/action/reserve_ip_subpool_v1.py +++ b/plugins/action/reserve_ip_subpool_v1.py @@ -110,23 +110,34 @@ def create_params(self): new_object_params = {} new_object_params['name'] = self.new_object.get('name') new_object_params['type'] = self.new_object.get('type') - new_object_params['ipv6AddressSpace'] = self.new_object.get('ipv6AddressSpace') - new_object_params['ipv4GlobalPool'] = self.new_object.get('ipv4GlobalPool') + new_object_params['ipv6AddressSpace'] = self.new_object.get( + 'ipv6AddressSpace') + new_object_params['ipv4GlobalPool'] = self.new_object.get( + 'ipv4GlobalPool') new_object_params['ipv4Prefix'] = self.new_object.get('ipv4Prefix') - new_object_params['ipv4PrefixLength'] = self.new_object.get('ipv4PrefixLength') + new_object_params['ipv4PrefixLength'] = self.new_object.get( + 'ipv4PrefixLength') new_object_params['ipv4Subnet'] = self.new_object.get('ipv4Subnet') new_object_params['ipv4GateWay'] = self.new_object.get('ipv4GateWay') - new_object_params['ipv4DhcpServers'] = self.new_object.get('ipv4DhcpServers') - new_object_params['ipv4DnsServers'] = self.new_object.get('ipv4DnsServers') - new_object_params['ipv6GlobalPool'] = self.new_object.get('ipv6GlobalPool') + new_object_params['ipv4DhcpServers'] = self.new_object.get( + 'ipv4DhcpServers') + new_object_params['ipv4DnsServers'] = self.new_object.get( + 'ipv4DnsServers') + new_object_params['ipv6GlobalPool'] = self.new_object.get( + 'ipv6GlobalPool') new_object_params['ipv6Prefix'] = self.new_object.get('ipv6Prefix') - new_object_params['ipv6PrefixLength'] = self.new_object.get('ipv6PrefixLength') + new_object_params['ipv6PrefixLength'] = self.new_object.get( + 'ipv6PrefixLength') new_object_params['ipv6Subnet'] = self.new_object.get('ipv6Subnet') new_object_params['ipv6GateWay'] = self.new_object.get('ipv6GateWay') - new_object_params['ipv6DhcpServers'] = self.new_object.get('ipv6DhcpServers') - new_object_params['ipv6DnsServers'] = self.new_object.get('ipv6DnsServers') - new_object_params['ipv4TotalHost'] = self.new_object.get('ipv4TotalHost') - new_object_params['ipv6TotalHost'] = self.new_object.get('ipv6TotalHost') + new_object_params['ipv6DhcpServers'] = self.new_object.get( + 'ipv6DhcpServers') + new_object_params['ipv6DnsServers'] = self.new_object.get( + 'ipv6DnsServers') + new_object_params['ipv4TotalHost'] = self.new_object.get( + 'ipv4TotalHost') + new_object_params['ipv6TotalHost'] = self.new_object.get( + 'ipv6TotalHost') new_object_params['slaacSupport'] = self.new_object.get('slaacSupport') new_object_params['siteId'] = self.new_object.get('siteId') return new_object_params @@ -139,17 +150,25 @@ def delete_by_id_params(self): def update_by_id_params(self): new_object_params = {} new_object_params['name'] = self.new_object.get('name') - new_object_params['ipv6AddressSpace'] = self.new_object.get('ipv6AddressSpace') - new_object_params['ipv4DhcpServers'] = self.new_object.get('ipv4DhcpServers') - new_object_params['ipv4DnsServers'] = self.new_object.get('ipv4DnsServers') - new_object_params['ipv6GlobalPool'] = self.new_object.get('ipv6GlobalPool') + new_object_params['ipv6AddressSpace'] = self.new_object.get( + 'ipv6AddressSpace') + new_object_params['ipv4DhcpServers'] = self.new_object.get( + 'ipv4DhcpServers') + new_object_params['ipv4DnsServers'] = self.new_object.get( + 'ipv4DnsServers') + new_object_params['ipv6GlobalPool'] = self.new_object.get( + 'ipv6GlobalPool') new_object_params['ipv6Prefix'] = self.new_object.get('ipv6Prefix') - new_object_params['ipv6PrefixLength'] = self.new_object.get('ipv6PrefixLength') + new_object_params['ipv6PrefixLength'] = self.new_object.get( + 'ipv6PrefixLength') new_object_params['ipv6Subnet'] = self.new_object.get('ipv6Subnet') - new_object_params['ipv6TotalHost'] = self.new_object.get('ipv6TotalHost') + new_object_params['ipv6TotalHost'] = self.new_object.get( + 'ipv6TotalHost') new_object_params['ipv6GateWay'] = self.new_object.get('ipv6GateWay') - new_object_params['ipv6DhcpServers'] = self.new_object.get('ipv6DhcpServers') - new_object_params['ipv6DnsServers'] = self.new_object.get('ipv6DnsServers') + new_object_params['ipv6DhcpServers'] = self.new_object.get( + 'ipv6DhcpServers') + new_object_params['ipv6DnsServers'] = self.new_object.get( + 'ipv6DnsServers') new_object_params['slaacSupport'] = self.new_object.get('slaacSupport') new_object_params['ipv4GateWay'] = self.new_object.get('ipv4GateWay') new_object_params['siteId'] = self.new_object.get('siteId') @@ -206,7 +225,8 @@ def exists(self): _id = prev_obj.get("id") _id = _id or prev_obj.get("siteId") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) self.new_object.update(dict(site_id=_id)) @@ -300,7 +320,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/reserve_ip_subpool_v1_info.py b/plugins/action/reserve_ip_subpool_v1_info.py index e4483795f5..9b482d2f83 100644 --- a/plugins/action/reserve_ip_subpool_v1_info.py +++ b/plugins/action/reserve_ip_subpool_v1_info.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/role_permissions_info.py b/plugins/action/role_permissions_info.py index 6ffdd65794..fb1ea812d1 100644 --- a/plugins/action/role_permissions_info.py +++ b/plugins/action/role_permissions_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/role_permissions_v1_info.py b/plugins/action/role_permissions_v1_info.py index 9a1dbf13ed..555e3f715a 100644 --- a/plugins/action/role_permissions_v1_info.py +++ b/plugins/action/role_permissions_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/roles.py b/plugins/action/roles.py index 5914331c26..24a652b1fe 100644 --- a/plugins/action/roles.py +++ b/plugins/action/roles.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/roles_info.py b/plugins/action/roles_info.py index 8a314aae93..d893b8977a 100644 --- a/plugins/action/roles_info.py +++ b/plugins/action/roles_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/roles_v1.py b/plugins/action/roles_v1.py index 3d4d0c3578..9762ecac1d 100644 --- a/plugins/action/roles_v1.py +++ b/plugins/action/roles_v1.py @@ -65,7 +65,8 @@ def create_params(self): new_object_params = {} new_object_params['role'] = self.new_object.get('role') new_object_params['description'] = self.new_object.get('description') - new_object_params['resourceTypes'] = self.new_object.get('resourceTypes') + new_object_params['resourceTypes'] = self.new_object.get( + 'resourceTypes') return new_object_params def delete_by_id_params(self): @@ -77,7 +78,8 @@ def update_all_params(self): new_object_params = {} new_object_params['roleId'] = self.new_object.get('roleId') new_object_params['description'] = self.new_object.get('description') - new_object_params['resourceTypes'] = self.new_object.get('resourceTypes') + new_object_params['resourceTypes'] = self.new_object.get( + 'resourceTypes') return new_object_params def get_object_by_name(self, name): @@ -131,7 +133,8 @@ def exists(self): _id = prev_obj.get("id") _id = _id or prev_obj.get("roleId") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) self.new_object.update(dict(role_id=_id)) @@ -199,7 +202,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/roles_v1_info.py b/plugins/action/roles_v1_info.py index 3d4a51f8d2..98e9332151 100644 --- a/plugins/action/roles_v1_info.py +++ b/plugins/action/roles_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_anycast_gateways.py b/plugins/action/sda_anycast_gateways.py index 407e32cbd7..343bf67bff 100644 --- a/plugins/action/sda_anycast_gateways.py +++ b/plugins/action/sda_anycast_gateways.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_anycast_gateways_count_info.py b/plugins/action/sda_anycast_gateways_count_info.py index a62131b423..082a4bc986 100644 --- a/plugins/action/sda_anycast_gateways_count_info.py +++ b/plugins/action/sda_anycast_gateways_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_anycast_gateways_count_v1_info.py b/plugins/action/sda_anycast_gateways_count_v1_info.py index 88501e814a..d619224e61 100644 --- a/plugins/action/sda_anycast_gateways_count_v1_info.py +++ b/plugins/action/sda_anycast_gateways_count_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_anycast_gateways_info.py b/plugins/action/sda_anycast_gateways_info.py index a75c2610d7..667e11ec0d 100644 --- a/plugins/action/sda_anycast_gateways_info.py +++ b/plugins/action/sda_anycast_gateways_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_anycast_gateways_v1.py b/plugins/action/sda_anycast_gateways_v1.py index 0112c92033..811dbf0540 100644 --- a/plugins/action/sda_anycast_gateways_v1.py +++ b/plugins/action/sda_anycast_gateways_v1.py @@ -131,7 +131,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -156,8 +157,10 @@ def requires_update(self, current_obj): ("isIpDirectedBroadcast", "isIpDirectedBroadcast"), ("isIntraSubnetRoutingEnabled", "isIntraSubnetRoutingEnabled"), ("isMultipleIpToMacAddresses", "isMultipleIpToMacAddresses"), - ("isSupplicantBasedExtendedNodeOnboarding", "isSupplicantBasedExtendedNodeOnboarding"), - ("isGroupBasedPolicyEnforcementEnabled", "isGroupBasedPolicyEnforcementEnabled"), + ("isSupplicantBasedExtendedNodeOnboarding", + "isSupplicantBasedExtendedNodeOnboarding"), + ("isGroupBasedPolicyEnforcementEnabled", + "isGroupBasedPolicyEnforcementEnabled"), ("id", "id"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) params @@ -220,7 +223,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -271,7 +275,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: @@ -282,7 +287,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_anycast_gateways_v1_info.py b/plugins/action/sda_anycast_gateways_v1_info.py index 0df3a9d5d7..acc6676126 100644 --- a/plugins/action/sda_anycast_gateways_v1_info.py +++ b/plugins/action/sda_anycast_gateways_v1_info.py @@ -45,7 +45,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_authentication_profiles.py b/plugins/action/sda_authentication_profiles.py index ba67f1c52c..0c974fcbca 100644 --- a/plugins/action/sda_authentication_profiles.py +++ b/plugins/action/sda_authentication_profiles.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_authentication_profiles_info.py b/plugins/action/sda_authentication_profiles_info.py index 77509a1ef6..9ff33a91ec 100644 --- a/plugins/action/sda_authentication_profiles_info.py +++ b/plugins/action/sda_authentication_profiles_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_authentication_profiles_v1.py b/plugins/action/sda_authentication_profiles_v1.py index 0be1cfe06d..75075d3c28 100644 --- a/plugins/action/sda_authentication_profiles_v1.py +++ b/plugins/action/sda_authentication_profiles_v1.py @@ -97,7 +97,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -140,7 +141,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -186,7 +188,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_authentication_profiles_v1_info.py b/plugins/action/sda_authentication_profiles_v1_info.py index 368b9462e7..6249d6de68 100644 --- a/plugins/action/sda_authentication_profiles_v1_info.py +++ b/plugins/action/sda_authentication_profiles_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -68,7 +69,8 @@ def _check_argspec(self): def get_object(self, params): new_object = dict( fabric_id=params.get("fabricId"), - authentication_profile_name=params.get("authenticationProfileName"), + authentication_profile_name=params.get( + "authenticationProfileName"), offset=params.get("offset"), limit=params.get("limit"), headers=params.get("headers"), diff --git a/plugins/action/sda_device_info.py b/plugins/action/sda_device_info.py index a7ae87dc47..f43d7d2e54 100644 --- a/plugins/action/sda_device_info.py +++ b/plugins/action/sda_device_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_device_role_info.py b/plugins/action/sda_device_role_info.py index dad1c84f47..04f141e7e3 100644 --- a/plugins/action/sda_device_role_info.py +++ b/plugins/action/sda_device_role_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_device_role_v1_info.py b/plugins/action/sda_device_role_v1_info.py index 4fc6eb1ba1..d05a7786e0 100644 --- a/plugins/action/sda_device_role_v1_info.py +++ b/plugins/action/sda_device_role_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -64,7 +65,8 @@ def _check_argspec(self): def get_object(self, params): new_object = dict( - device_management_ip_address=params.get("deviceManagementIpAddress"), + device_management_ip_address=params.get( + "deviceManagementIpAddress"), headers=params.get("headers"), ) return new_object diff --git a/plugins/action/sda_device_v1_info.py b/plugins/action/sda_device_v1_info.py index 111300278c..4b051d23c7 100644 --- a/plugins/action/sda_device_v1_info.py +++ b/plugins/action/sda_device_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -64,7 +65,8 @@ def _check_argspec(self): def get_object(self, params): new_object = dict( - device_management_ip_address=params.get("deviceManagementIpAddress"), + device_management_ip_address=params.get( + "deviceManagementIpAddress"), headers=params.get("headers"), ) return new_object diff --git a/plugins/action/sda_extranet_policies.py b/plugins/action/sda_extranet_policies.py index bfda0e62d4..d5e8643bc5 100644 --- a/plugins/action/sda_extranet_policies.py +++ b/plugins/action/sda_extranet_policies.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_extranet_policies_count_info.py b/plugins/action/sda_extranet_policies_count_info.py index dedf8ffc84..30c393b0af 100644 --- a/plugins/action/sda_extranet_policies_count_info.py +++ b/plugins/action/sda_extranet_policies_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_extranet_policies_count_v1_info.py b/plugins/action/sda_extranet_policies_count_v1_info.py index e63bb74ee9..9e9bec3f56 100644 --- a/plugins/action/sda_extranet_policies_count_v1_info.py +++ b/plugins/action/sda_extranet_policies_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_extranet_policies_info.py b/plugins/action/sda_extranet_policies_info.py index b1944c9ba2..2bcaff3f3c 100644 --- a/plugins/action/sda_extranet_policies_info.py +++ b/plugins/action/sda_extranet_policies_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_extranet_policies_v1.py b/plugins/action/sda_extranet_policies_v1.py index 4a49bc8c8b..ef5803e1ef 100644 --- a/plugins/action/sda_extranet_policies_v1.py +++ b/plugins/action/sda_extranet_policies_v1.py @@ -124,7 +124,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -201,7 +202,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -252,7 +254,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: @@ -263,7 +266,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_extranet_policies_v1_info.py b/plugins/action/sda_extranet_policies_v1_info.py index 2430793609..49baf6fd20 100644 --- a/plugins/action/sda_extranet_policies_v1_info.py +++ b/plugins/action/sda_extranet_policies_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_fabric_authentication_profile.py b/plugins/action/sda_fabric_authentication_profile.py index c857f8e2af..a019ffe997 100644 --- a/plugins/action/sda_fabric_authentication_profile.py +++ b/plugins/action/sda_fabric_authentication_profile.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_authentication_profile_info.py b/plugins/action/sda_fabric_authentication_profile_info.py index 37229b54be..409df15af3 100644 --- a/plugins/action/sda_fabric_authentication_profile_info.py +++ b/plugins/action/sda_fabric_authentication_profile_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_authentication_profile_v1.py b/plugins/action/sda_fabric_authentication_profile_v1.py index 7111c2aa98..afb37fd6f4 100644 --- a/plugins/action/sda_fabric_authentication_profile_v1.py +++ b/plugins/action/sda_fabric_authentication_profile_v1.py @@ -68,7 +68,8 @@ def create_params(self): def delete_all_params(self): new_object_params = {} - new_object_params['site_name_hierarchy'] = self.new_object.get('site_name_hierarchy') + new_object_params['site_name_hierarchy'] = self.new_object.get( + 'site_name_hierarchy') return new_object_params def update_all_params(self): @@ -120,7 +121,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -190,7 +192,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -241,7 +244,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: @@ -252,7 +256,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_fabric_authentication_profile_v1_info.py b/plugins/action/sda_fabric_authentication_profile_v1_info.py index fc99a83d1c..c4846147a9 100644 --- a/plugins/action/sda_fabric_authentication_profile_v1_info.py +++ b/plugins/action/sda_fabric_authentication_profile_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_fabric_border_device.py b/plugins/action/sda_fabric_border_device.py index d0a42e2faf..6ad2a82af0 100644 --- a/plugins/action/sda_fabric_border_device.py +++ b/plugins/action/sda_fabric_border_device.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_border_device_info.py b/plugins/action/sda_fabric_border_device_info.py index f6d1386d78..ac3bc653fc 100644 --- a/plugins/action/sda_fabric_border_device_info.py +++ b/plugins/action/sda_fabric_border_device_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_border_device_v1.py b/plugins/action/sda_fabric_border_device_v1.py index d7d7531c7b..e6461f6ed8 100644 --- a/plugins/action/sda_fabric_border_device_v1.py +++ b/plugins/action/sda_fabric_border_device_v1.py @@ -50,7 +50,8 @@ def __init__(self, params, dnac): self.dnac = dnac self.new_object = dict( payload=params.get("payload"), - device_management_ip_address=params.get("deviceManagementIpAddress"), + device_management_ip_address=params.get( + "deviceManagementIpAddress"), ) def get_all_params(self, name=None, id=None): @@ -66,7 +67,8 @@ def create_params(self): def delete_all_params(self): new_object_params = {} - new_object_params['device_management_ip_address'] = self.new_object.get('device_management_ip_address') + new_object_params['device_management_ip_address'] = self.new_object.get( + 'device_management_ip_address') return new_object_params def get_object_by_name(self, name, is_absent=False): @@ -101,7 +103,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -114,7 +117,8 @@ def requires_update(self, current_obj): ("siteNameHierarchy", "siteNameHierarchy"), ("deviceRole", "deviceRole"), ("routeDistributionProtocol", "routeDistributionProtocol"), - ("externalDomainRoutingProtocolName", "externalDomainRoutingProtocolName"), + ("externalDomainRoutingProtocolName", + "externalDomainRoutingProtocolName"), ("externalConnectivityIpPoolName", "externalConnectivityIpPoolName"), ("internalAutonomouSystemNumber", "internalAutonomouSystemNumber"), ("borderPriority", "borderPriority"), @@ -163,7 +167,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -213,7 +218,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: (obj_exists, prev_obj) = obj.exists(is_absent=True) @@ -223,7 +229,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_fabric_border_device_v1_info.py b/plugins/action/sda_fabric_border_device_v1_info.py index bf3c2aefd4..7614ea20a8 100644 --- a/plugins/action/sda_fabric_border_device_v1_info.py +++ b/plugins/action/sda_fabric_border_device_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -64,7 +65,8 @@ def _check_argspec(self): def get_object(self, params): new_object = dict( - device_management_ip_address=params.get("deviceManagementIpAddress"), + device_management_ip_address=params.get( + "deviceManagementIpAddress"), headers=params.get("headers"), ) return new_object diff --git a/plugins/action/sda_fabric_control_plane_device.py b/plugins/action/sda_fabric_control_plane_device.py index 1c290b0c59..71dc65c352 100644 --- a/plugins/action/sda_fabric_control_plane_device.py +++ b/plugins/action/sda_fabric_control_plane_device.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_control_plane_device_info.py b/plugins/action/sda_fabric_control_plane_device_info.py index 09f09edf68..96274bd770 100644 --- a/plugins/action/sda_fabric_control_plane_device_info.py +++ b/plugins/action/sda_fabric_control_plane_device_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_control_plane_device_v1.py b/plugins/action/sda_fabric_control_plane_device_v1.py index 1226a75821..967825f5d1 100644 --- a/plugins/action/sda_fabric_control_plane_device_v1.py +++ b/plugins/action/sda_fabric_control_plane_device_v1.py @@ -51,7 +51,8 @@ def __init__(self, params, dnac): deviceManagementIpAddress=params.get("deviceManagementIpAddress"), siteNameHierarchy=params.get("siteNameHierarchy"), routeDistributionProtocol=params.get("routeDistributionProtocol"), - device_management_ip_address=params.get("deviceManagementIpAddress"), + device_management_ip_address=params.get( + "deviceManagementIpAddress"), ) def get_all_params(self, name=None, id=None): @@ -62,14 +63,18 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['deviceManagementIpAddress'] = self.new_object.get('deviceManagementIpAddress') - new_object_params['siteNameHierarchy'] = self.new_object.get('siteNameHierarchy') - new_object_params['routeDistributionProtocol'] = self.new_object.get('routeDistributionProtocol') + new_object_params['deviceManagementIpAddress'] = self.new_object.get( + 'deviceManagementIpAddress') + new_object_params['siteNameHierarchy'] = self.new_object.get( + 'siteNameHierarchy') + new_object_params['routeDistributionProtocol'] = self.new_object.get( + 'routeDistributionProtocol') return new_object_params def delete_all_params(self): new_object_params = {} - new_object_params['device_management_ip_address'] = self.new_object.get('device_management_ip_address') + new_object_params['device_management_ip_address'] = self.new_object.get( + 'device_management_ip_address') return new_object_params def get_object_by_name(self, name, is_absent=False): @@ -104,7 +109,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -151,7 +157,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -201,7 +208,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: (obj_exists, prev_obj) = obj.exists(is_absent=True) @@ -211,7 +219,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_fabric_control_plane_device_v1_info.py b/plugins/action/sda_fabric_control_plane_device_v1_info.py index 27a324ea93..edfdf7e350 100644 --- a/plugins/action/sda_fabric_control_plane_device_v1_info.py +++ b/plugins/action/sda_fabric_control_plane_device_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -64,7 +65,8 @@ def _check_argspec(self): def get_object(self, params): new_object = dict( - device_management_ip_address=params.get("deviceManagementIpAddress"), + device_management_ip_address=params.get( + "deviceManagementIpAddress"), headers=params.get("headers"), ) return new_object diff --git a/plugins/action/sda_fabric_devices.py b/plugins/action/sda_fabric_devices.py index 4ddc389148..c26f66e106 100644 --- a/plugins/action/sda_fabric_devices.py +++ b/plugins/action/sda_fabric_devices.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_devices_count_info.py b/plugins/action/sda_fabric_devices_count_info.py index 3ea428e410..5d5f93f726 100644 --- a/plugins/action/sda_fabric_devices_count_info.py +++ b/plugins/action/sda_fabric_devices_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_devices_count_v1_info.py b/plugins/action/sda_fabric_devices_count_v1_info.py index 7f966e178f..fba05b6226 100644 --- a/plugins/action/sda_fabric_devices_count_v1_info.py +++ b/plugins/action/sda_fabric_devices_count_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_fabric_devices_info.py b/plugins/action/sda_fabric_devices_info.py index f46b4dc7a2..bcf83ec5cf 100644 --- a/plugins/action/sda_fabric_devices_info.py +++ b/plugins/action/sda_fabric_devices_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs.py b/plugins/action/sda_fabric_devices_layer2_handoffs.py index cc7ebe6902..ab41572e25 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs_count_info.py b/plugins/action/sda_fabric_devices_layer2_handoffs_count_info.py index 73a21518fe..c31e556324 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs_count_info.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs_count_v1_info.py b/plugins/action/sda_fabric_devices_layer2_handoffs_count_v1_info.py index 7ff342fe5f..c0e4da45df 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs_count_v1_info.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs_count_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs_info.py b/plugins/action/sda_fabric_devices_layer2_handoffs_info.py index 154d923b1e..7e514f9f7b 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs_info.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits.py b/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits.py index 27f79b257e..48846fc9d7 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_count_info.py b/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_count_info.py index fc12d6a16c..aa5d745820 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_count_info.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_count_v1_info.py b/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_count_v1_info.py index b86cabf469..4c91d3b43a 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_count_v1_info.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_count_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_info.py b/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_info.py index 832435337f..72484f5cb2 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_info.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_v1.py b/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_v1.py index ea818fb97b..c43d4aca78 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_v1.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_v1.py @@ -128,7 +128,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -214,7 +215,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -265,7 +267,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: @@ -276,7 +279,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_v1_info.py b/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_v1_info.py index 8ac869c110..a307e32557 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_v1_info.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs_ip_transits_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits.py b/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits.py index f5118ef0ab..102f1cbbcc 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_count_info.py b/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_count_info.py index 89b86ea448..df74103731 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_count_info.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_count_v1_info.py b/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_count_v1_info.py index 81226673da..f05725ea15 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_count_v1_info.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_count_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_info.py b/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_info.py index 472de5b597..2b295464c3 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_info.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_v1.py b/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_v1.py index cb6c15314f..b029285dcc 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_v1.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_v1.py @@ -73,7 +73,8 @@ def create_params(self): def delete_all_params(self): new_object_params = {} new_object_params['fabric_id'] = self.new_object.get('fabric_id') - new_object_params['network_device_id'] = self.new_object.get('network_device_id') + new_object_params['network_device_id'] = self.new_object.get( + 'network_device_id') return new_object_params def update_all_params(self): @@ -125,7 +126,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -197,7 +199,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -228,7 +231,8 @@ def run(self, tmp=None, task_vars=None): self._check_argspec() dnac = DNACSDK(self._task.args) - obj = SdaFabricDevicesLayer2HandoffsSdaTransitsV1(self._task.args, dnac) + obj = SdaFabricDevicesLayer2HandoffsSdaTransitsV1( + self._task.args, dnac) state = self._task.args.get("state") @@ -248,7 +252,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: @@ -259,7 +264,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_v1_info.py b/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_v1_info.py index 6d84c8eb82..2a3fca589c 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_v1_info.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs_sda_transits_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs_v1.py b/plugins/action/sda_fabric_devices_layer2_handoffs_v1.py index 4d41469c72..638f588a6d 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs_v1.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs_v1.py @@ -123,7 +123,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -196,7 +197,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -247,7 +249,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: @@ -258,7 +261,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs_v1_info.py b/plugins/action/sda_fabric_devices_layer2_handoffs_v1_info.py index ee1398fbad..74419f3906 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs_v1_info.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_fabric_devices_v1.py b/plugins/action/sda_fabric_devices_v1.py index 30530d76e1..f44cee7842 100644 --- a/plugins/action/sda_fabric_devices_v1.py +++ b/plugins/action/sda_fabric_devices_v1.py @@ -132,7 +132,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -211,7 +212,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -262,7 +264,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: @@ -273,7 +276,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_fabric_devices_v1_info.py b/plugins/action/sda_fabric_devices_v1_info.py index 6562d54ec7..f2ac170b00 100644 --- a/plugins/action/sda_fabric_devices_v1_info.py +++ b/plugins/action/sda_fabric_devices_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_fabric_edge_device.py b/plugins/action/sda_fabric_edge_device.py index 7e0d0dc0da..434630d19c 100644 --- a/plugins/action/sda_fabric_edge_device.py +++ b/plugins/action/sda_fabric_edge_device.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_edge_device_info.py b/plugins/action/sda_fabric_edge_device_info.py index 6279ca2a67..d561321780 100644 --- a/plugins/action/sda_fabric_edge_device_info.py +++ b/plugins/action/sda_fabric_edge_device_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_edge_device_v1.py b/plugins/action/sda_fabric_edge_device_v1.py index ab69c932c3..38470e9897 100644 --- a/plugins/action/sda_fabric_edge_device_v1.py +++ b/plugins/action/sda_fabric_edge_device_v1.py @@ -49,7 +49,8 @@ def __init__(self, params, dnac): self.new_object = dict( deviceManagementIpAddress=params.get("deviceManagementIpAddress"), siteNameHierarchy=params.get("siteNameHierarchy"), - device_management_ip_address=params.get("deviceManagementIpAddress"), + device_management_ip_address=params.get( + "deviceManagementIpAddress"), ) def get_all_params(self, name=None, id=None): @@ -60,13 +61,16 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['deviceManagementIpAddress'] = self.new_object.get('deviceManagementIpAddress') - new_object_params['siteNameHierarchy'] = self.new_object.get('siteNameHierarchy') + new_object_params['deviceManagementIpAddress'] = self.new_object.get( + 'deviceManagementIpAddress') + new_object_params['siteNameHierarchy'] = self.new_object.get( + 'siteNameHierarchy') return new_object_params def delete_all_params(self): new_object_params = {} - new_object_params['device_management_ip_address'] = self.new_object.get('device_management_ip_address') + new_object_params['device_management_ip_address'] = self.new_object.get( + 'device_management_ip_address') return new_object_params def get_object_by_name(self, name, is_absent=False): @@ -101,7 +105,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -147,7 +152,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -197,7 +203,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: (obj_exists, prev_obj) = obj.exists(is_absent=True) @@ -207,7 +214,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_fabric_edge_device_v1_info.py b/plugins/action/sda_fabric_edge_device_v1_info.py index ca369d7385..d521e22dc7 100644 --- a/plugins/action/sda_fabric_edge_device_v1_info.py +++ b/plugins/action/sda_fabric_edge_device_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -64,7 +65,8 @@ def _check_argspec(self): def get_object(self, params): new_object = dict( - device_management_ip_address=params.get("deviceManagementIpAddress"), + device_management_ip_address=params.get( + "deviceManagementIpAddress"), headers=params.get("headers"), ) return new_object diff --git a/plugins/action/sda_fabric_site.py b/plugins/action/sda_fabric_site.py index 536b2bee32..75f3bf628a 100644 --- a/plugins/action/sda_fabric_site.py +++ b/plugins/action/sda_fabric_site.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_site_info.py b/plugins/action/sda_fabric_site_info.py index f51abc5024..37c3af8400 100644 --- a/plugins/action/sda_fabric_site_info.py +++ b/plugins/action/sda_fabric_site_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_site_v1.py b/plugins/action/sda_fabric_site_v1.py index dce99df3a0..8f751154ad 100644 --- a/plugins/action/sda_fabric_site_v1.py +++ b/plugins/action/sda_fabric_site_v1.py @@ -63,13 +63,15 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} new_object_params['fabricName'] = self.new_object.get('fabricName') - new_object_params['siteNameHierarchy'] = self.new_object.get('siteNameHierarchy') + new_object_params['siteNameHierarchy'] = self.new_object.get( + 'siteNameHierarchy') new_object_params['fabricType'] = self.new_object.get('fabricType') return new_object_params def delete_all_params(self): new_object_params = {} - new_object_params['site_name_hierarchy'] = self.new_object.get('site_name_hierarchy') + new_object_params['site_name_hierarchy'] = self.new_object.get( + 'site_name_hierarchy') return new_object_params def get_object_by_name(self, name, is_absent=False): @@ -104,7 +106,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -151,7 +154,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -201,7 +205,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: (obj_exists, prev_obj) = obj.exists(is_absent=True) @@ -211,7 +216,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_fabric_site_v1_info.py b/plugins/action/sda_fabric_site_v1_info.py index 09cf70756c..d4a86082a3 100644 --- a/plugins/action/sda_fabric_site_v1_info.py +++ b/plugins/action/sda_fabric_site_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_fabric_sites.py b/plugins/action/sda_fabric_sites.py index 199dd57e0e..24d2632f55 100644 --- a/plugins/action/sda_fabric_sites.py +++ b/plugins/action/sda_fabric_sites.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_sites_count_info.py b/plugins/action/sda_fabric_sites_count_info.py index e326dce614..4debd692af 100644 --- a/plugins/action/sda_fabric_sites_count_info.py +++ b/plugins/action/sda_fabric_sites_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_sites_count_v1_info.py b/plugins/action/sda_fabric_sites_count_v1_info.py index 956bb7d2de..4e4e8c2268 100644 --- a/plugins/action/sda_fabric_sites_count_v1_info.py +++ b/plugins/action/sda_fabric_sites_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_fabric_sites_info.py b/plugins/action/sda_fabric_sites_info.py index d2feabde6f..09235e8a09 100644 --- a/plugins/action/sda_fabric_sites_info.py +++ b/plugins/action/sda_fabric_sites_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_sites_v1.py b/plugins/action/sda_fabric_sites_v1.py index b99ae85664..5bc5f5da57 100644 --- a/plugins/action/sda_fabric_sites_v1.py +++ b/plugins/action/sda_fabric_sites_v1.py @@ -123,7 +123,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -198,7 +199,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -249,7 +251,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: @@ -260,7 +263,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_fabric_sites_v1_info.py b/plugins/action/sda_fabric_sites_v1_info.py index 9575fdac50..e560ec77fb 100644 --- a/plugins/action/sda_fabric_sites_v1_info.py +++ b/plugins/action/sda_fabric_sites_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_fabric_zones.py b/plugins/action/sda_fabric_zones.py index 21235b1c30..3ae36339cb 100644 --- a/plugins/action/sda_fabric_zones.py +++ b/plugins/action/sda_fabric_zones.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_zones_count_info.py b/plugins/action/sda_fabric_zones_count_info.py index 6aeaf3a9ed..2806fc033f 100644 --- a/plugins/action/sda_fabric_zones_count_info.py +++ b/plugins/action/sda_fabric_zones_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_zones_count_v1_info.py b/plugins/action/sda_fabric_zones_count_v1_info.py index 1055856d48..7506c9f4b3 100644 --- a/plugins/action/sda_fabric_zones_count_v1_info.py +++ b/plugins/action/sda_fabric_zones_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_fabric_zones_info.py b/plugins/action/sda_fabric_zones_info.py index 8846c2283d..beb0e0199a 100644 --- a/plugins/action/sda_fabric_zones_info.py +++ b/plugins/action/sda_fabric_zones_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabric_zones_v1.py b/plugins/action/sda_fabric_zones_v1.py index f6ec02e6d2..4c4dd45c54 100644 --- a/plugins/action/sda_fabric_zones_v1.py +++ b/plugins/action/sda_fabric_zones_v1.py @@ -123,7 +123,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -197,7 +198,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -248,7 +250,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: @@ -259,7 +262,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_fabric_zones_v1_info.py b/plugins/action/sda_fabric_zones_v1_info.py index ed323e04f9..4ca2af49a1 100644 --- a/plugins/action/sda_fabric_zones_v1_info.py +++ b/plugins/action/sda_fabric_zones_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_fabrics_vlan_to_ssids_count_info.py b/plugins/action/sda_fabrics_vlan_to_ssids_count_info.py index 2b337739da..2cfbbcfc09 100644 --- a/plugins/action/sda_fabrics_vlan_to_ssids_count_info.py +++ b/plugins/action/sda_fabrics_vlan_to_ssids_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabrics_vlan_to_ssids_count_v1_info.py b/plugins/action/sda_fabrics_vlan_to_ssids_count_v1_info.py index 641e1ea8bb..6d02acc836 100644 --- a/plugins/action/sda_fabrics_vlan_to_ssids_count_v1_info.py +++ b/plugins/action/sda_fabrics_vlan_to_ssids_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id.py b/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id.py index f004ae912d..8e2e34c185 100644 --- a/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id.py +++ b/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_count_info.py b/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_count_info.py index 929fdbfb68..a9a666c683 100644 --- a/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_count_info.py +++ b/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_count_v1_info.py b/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_count_v1_info.py index d1180ae0a6..2199239bf3 100644 --- a/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_count_v1_info.py +++ b/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_count_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_info.py b/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_info.py index 10c153cfc2..73912ee165 100644 --- a/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_info.py +++ b/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_v1.py b/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_v1.py index 707a1b73ce..c35b11c4e2 100644 --- a/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_v1.py +++ b/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_v1.py @@ -99,7 +99,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -137,7 +138,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -183,7 +185,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_v1_info.py b/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_v1_info.py index 9053eb856f..1373ddf600 100644 --- a/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_v1_info.py +++ b/plugins/action/sda_fabrics_vlan_to_ssids_fabric_id_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_fabrics_vlan_to_ssids_info.py b/plugins/action/sda_fabrics_vlan_to_ssids_info.py index 1c3f21d63e..a938d7bb5d 100644 --- a/plugins/action/sda_fabrics_vlan_to_ssids_info.py +++ b/plugins/action/sda_fabrics_vlan_to_ssids_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_fabrics_vlan_to_ssids_v1_info.py b/plugins/action/sda_fabrics_vlan_to_ssids_v1_info.py index b28c14ddb6..10ebef1473 100644 --- a/plugins/action/sda_fabrics_vlan_to_ssids_v1_info.py +++ b/plugins/action/sda_fabrics_vlan_to_ssids_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_layer2_virtual_networks.py b/plugins/action/sda_layer2_virtual_networks.py index db890ace4a..77ab30e4b5 100644 --- a/plugins/action/sda_layer2_virtual_networks.py +++ b/plugins/action/sda_layer2_virtual_networks.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_layer2_virtual_networks_count_info.py b/plugins/action/sda_layer2_virtual_networks_count_info.py index f211856471..080bd6739d 100644 --- a/plugins/action/sda_layer2_virtual_networks_count_info.py +++ b/plugins/action/sda_layer2_virtual_networks_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_layer2_virtual_networks_count_v1_info.py b/plugins/action/sda_layer2_virtual_networks_count_v1_info.py index 1b86bca6ba..99dc7067a2 100644 --- a/plugins/action/sda_layer2_virtual_networks_count_v1_info.py +++ b/plugins/action/sda_layer2_virtual_networks_count_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -72,7 +73,8 @@ def get_object(self, params): vlan_name=params.get("vlanName"), vlan_id=params.get("vlanId"), traffic_type=params.get("trafficType"), - associated_layer3_virtual_network_name=params.get("associatedLayer3VirtualNetworkName"), + associated_layer3_virtual_network_name=params.get( + "associatedLayer3VirtualNetworkName"), headers=params.get("headers"), ) return new_object diff --git a/plugins/action/sda_layer2_virtual_networks_info.py b/plugins/action/sda_layer2_virtual_networks_info.py index 48854069b5..36934c8f5c 100644 --- a/plugins/action/sda_layer2_virtual_networks_info.py +++ b/plugins/action/sda_layer2_virtual_networks_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_layer2_virtual_networks_v1.py b/plugins/action/sda_layer2_virtual_networks_v1.py index 115de09d98..4dca7aa266 100644 --- a/plugins/action/sda_layer2_virtual_networks_v1.py +++ b/plugins/action/sda_layer2_virtual_networks_v1.py @@ -61,7 +61,8 @@ def __init__(self, params, dnac): vlan_name=params.get("vlanName"), vlan_id=params.get("vlanId"), traffic_type=params.get("trafficType"), - associated_layer3_virtual_network_name=params.get("associatedLayer3VirtualNetworkName"), + associated_layer3_virtual_network_name=params.get( + "associatedLayer3VirtualNetworkName"), id=params.get("id"), ) @@ -141,7 +142,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -156,12 +158,14 @@ def requires_update(self, current_obj): ("vlanId", "vlanId"), ("trafficType", "trafficType"), ("isFabricEnabledWireless", "isFabricEnabledWireless"), - ("associatedLayer3VirtualNetworkName", "associatedLayer3VirtualNetworkName"), + ("associatedLayer3VirtualNetworkName", + "associatedLayer3VirtualNetworkName"), ("fabricId", "fabric_id"), ("vlanName", "vlan_name"), ("vlanId", "vlan_id"), ("trafficType", "traffic_type"), - ("associatedLayer3VirtualNetworkName", "associated_layer3_virtual_network_name"), + ("associatedLayer3VirtualNetworkName", + "associated_layer3_virtual_network_name"), ("id", "id"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) params @@ -224,7 +228,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -275,7 +280,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: @@ -286,7 +292,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_layer2_virtual_networks_v1_info.py b/plugins/action/sda_layer2_virtual_networks_v1_info.py index dbd26f3043..bbcc1e68da 100644 --- a/plugins/action/sda_layer2_virtual_networks_v1_info.py +++ b/plugins/action/sda_layer2_virtual_networks_v1_info.py @@ -45,7 +45,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -76,7 +77,8 @@ def get_object(self, params): vlan_name=params.get("vlanName"), vlan_id=params.get("vlanId"), traffic_type=params.get("trafficType"), - associated_layer3_virtual_network_name=params.get("associatedLayer3VirtualNetworkName"), + associated_layer3_virtual_network_name=params.get( + "associatedLayer3VirtualNetworkName"), offset=params.get("offset"), limit=params.get("limit"), headers=params.get("headers"), diff --git a/plugins/action/sda_layer3_virtual_networks.py b/plugins/action/sda_layer3_virtual_networks.py index b9d3a5e011..dec875f1b2 100644 --- a/plugins/action/sda_layer3_virtual_networks.py +++ b/plugins/action/sda_layer3_virtual_networks.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_layer3_virtual_networks_count_info.py b/plugins/action/sda_layer3_virtual_networks_count_info.py index e8f8a79380..26c353bce0 100644 --- a/plugins/action/sda_layer3_virtual_networks_count_info.py +++ b/plugins/action/sda_layer3_virtual_networks_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_layer3_virtual_networks_count_v1_info.py b/plugins/action/sda_layer3_virtual_networks_count_v1_info.py index 3fc8534b99..1b29f85a6d 100644 --- a/plugins/action/sda_layer3_virtual_networks_count_v1_info.py +++ b/plugins/action/sda_layer3_virtual_networks_count_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_layer3_virtual_networks_info.py b/plugins/action/sda_layer3_virtual_networks_info.py index 7ab3e8fa02..fd0ec12f46 100644 --- a/plugins/action/sda_layer3_virtual_networks_info.py +++ b/plugins/action/sda_layer3_virtual_networks_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_layer3_virtual_networks_v1.py b/plugins/action/sda_layer3_virtual_networks_v1.py index 9989d519f5..b300c9dd96 100644 --- a/plugins/action/sda_layer3_virtual_networks_v1.py +++ b/plugins/action/sda_layer3_virtual_networks_v1.py @@ -72,7 +72,8 @@ def create_params(self): def delete_all_params(self): new_object_params = {} - new_object_params['virtual_network_name'] = self.new_object.get('virtual_network_name') + new_object_params['virtual_network_name'] = self.new_object.get( + 'virtual_network_name') return new_object_params def update_all_params(self): @@ -124,7 +125,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -192,7 +194,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -243,7 +246,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: @@ -254,7 +258,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_layer3_virtual_networks_v1_info.py b/plugins/action/sda_layer3_virtual_networks_v1_info.py index ed1cd0a902..81b9fbb7e0 100644 --- a/plugins/action/sda_layer3_virtual_networks_v1_info.py +++ b/plugins/action/sda_layer3_virtual_networks_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_multicast.py b/plugins/action/sda_multicast.py index 68cdc9f58b..8b8bd871e8 100644 --- a/plugins/action/sda_multicast.py +++ b/plugins/action/sda_multicast.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_multicast_info.py b/plugins/action/sda_multicast_info.py index 10b01c6a50..47db047b57 100644 --- a/plugins/action/sda_multicast_info.py +++ b/plugins/action/sda_multicast_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_multicast_v1.py b/plugins/action/sda_multicast_v1.py index 4bace2156f..89251a8c71 100644 --- a/plugins/action/sda_multicast_v1.py +++ b/plugins/action/sda_multicast_v1.py @@ -95,7 +95,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -132,7 +133,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -178,7 +180,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_multicast_v1_info.py b/plugins/action/sda_multicast_v1_info.py index 2b75f68195..acb5cc3162 100644 --- a/plugins/action/sda_multicast_v1_info.py +++ b/plugins/action/sda_multicast_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_multicast_virtual_networks.py b/plugins/action/sda_multicast_virtual_networks.py index b1aa5baa93..16e86d5bf5 100644 --- a/plugins/action/sda_multicast_virtual_networks.py +++ b/plugins/action/sda_multicast_virtual_networks.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_multicast_virtual_networks_count_info.py b/plugins/action/sda_multicast_virtual_networks_count_info.py index cc7ebe0d39..d9943e5bdf 100644 --- a/plugins/action/sda_multicast_virtual_networks_count_info.py +++ b/plugins/action/sda_multicast_virtual_networks_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_multicast_virtual_networks_count_v1_info.py b/plugins/action/sda_multicast_virtual_networks_count_v1_info.py index 82f38e0d2b..298091874b 100644 --- a/plugins/action/sda_multicast_virtual_networks_count_v1_info.py +++ b/plugins/action/sda_multicast_virtual_networks_count_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_multicast_virtual_networks_info.py b/plugins/action/sda_multicast_virtual_networks_info.py index b15a415e6e..5ce4979030 100644 --- a/plugins/action/sda_multicast_virtual_networks_info.py +++ b/plugins/action/sda_multicast_virtual_networks_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_multicast_virtual_networks_v1.py b/plugins/action/sda_multicast_virtual_networks_v1.py index b73c02fbc3..cd589ee660 100644 --- a/plugins/action/sda_multicast_virtual_networks_v1.py +++ b/plugins/action/sda_multicast_virtual_networks_v1.py @@ -124,7 +124,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -201,7 +202,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -252,7 +254,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: @@ -263,7 +266,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_multicast_virtual_networks_v1_info.py b/plugins/action/sda_multicast_virtual_networks_v1_info.py index 6ddd84cf3b..5bb703d206 100644 --- a/plugins/action/sda_multicast_virtual_networks_v1_info.py +++ b/plugins/action/sda_multicast_virtual_networks_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_port_assignment_for_access_point.py b/plugins/action/sda_port_assignment_for_access_point.py index d75f9afd9a..0fa983e73b 100644 --- a/plugins/action/sda_port_assignment_for_access_point.py +++ b/plugins/action/sda_port_assignment_for_access_point.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_port_assignment_for_access_point_info.py b/plugins/action/sda_port_assignment_for_access_point_info.py index 1edbbe001f..05f3e5a247 100644 --- a/plugins/action/sda_port_assignment_for_access_point_info.py +++ b/plugins/action/sda_port_assignment_for_access_point_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_port_assignment_for_access_point_v1.py b/plugins/action/sda_port_assignment_for_access_point_v1.py index ee8b843fab..1013ed2880 100644 --- a/plugins/action/sda_port_assignment_for_access_point_v1.py +++ b/plugins/action/sda_port_assignment_for_access_point_v1.py @@ -57,7 +57,8 @@ def __init__(self, params, dnac): dataIpAddressPoolName=params.get("dataIpAddressPoolName"), authenticateTemplateName=params.get("authenticateTemplateName"), interfaceDescription=params.get("interfaceDescription"), - device_management_ip_address=params.get("deviceManagementIpAddress"), + device_management_ip_address=params.get( + "deviceManagementIpAddress"), interface_name=params.get("interfaceName"), ) @@ -71,18 +72,26 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['siteNameHierarchy'] = self.new_object.get('siteNameHierarchy') - new_object_params['deviceManagementIpAddress'] = self.new_object.get('deviceManagementIpAddress') - new_object_params['interfaceName'] = self.new_object.get('interfaceName') - new_object_params['dataIpAddressPoolName'] = self.new_object.get('dataIpAddressPoolName') - new_object_params['authenticateTemplateName'] = self.new_object.get('authenticateTemplateName') - new_object_params['interfaceDescription'] = self.new_object.get('interfaceDescription') + new_object_params['siteNameHierarchy'] = self.new_object.get( + 'siteNameHierarchy') + new_object_params['deviceManagementIpAddress'] = self.new_object.get( + 'deviceManagementIpAddress') + new_object_params['interfaceName'] = self.new_object.get( + 'interfaceName') + new_object_params['dataIpAddressPoolName'] = self.new_object.get( + 'dataIpAddressPoolName') + new_object_params['authenticateTemplateName'] = self.new_object.get( + 'authenticateTemplateName') + new_object_params['interfaceDescription'] = self.new_object.get( + 'interfaceDescription') return new_object_params def delete_all_params(self): new_object_params = {} - new_object_params['device_management_ip_address'] = self.new_object.get('device_management_ip_address') - new_object_params['interface_name'] = self.new_object.get('interface_name') + new_object_params['device_management_ip_address'] = self.new_object.get( + 'device_management_ip_address') + new_object_params['interface_name'] = self.new_object.get( + 'interface_name') return new_object_params def get_object_by_name(self, name, is_absent=False): @@ -117,7 +126,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -168,7 +178,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -218,7 +229,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: (obj_exists, prev_obj) = obj.exists(is_absent=True) @@ -228,7 +240,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_port_assignment_for_access_point_v1_info.py b/plugins/action/sda_port_assignment_for_access_point_v1_info.py index 8ff3784499..2dca037e36 100644 --- a/plugins/action/sda_port_assignment_for_access_point_v1_info.py +++ b/plugins/action/sda_port_assignment_for_access_point_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -65,7 +66,8 @@ def _check_argspec(self): def get_object(self, params): new_object = dict( - device_management_ip_address=params.get("deviceManagementIpAddress"), + device_management_ip_address=params.get( + "deviceManagementIpAddress"), interface_name=params.get("interfaceName"), headers=params.get("headers"), ) diff --git a/plugins/action/sda_port_assignment_for_user_device.py b/plugins/action/sda_port_assignment_for_user_device.py index a9c18cc664..d49f1674fb 100644 --- a/plugins/action/sda_port_assignment_for_user_device.py +++ b/plugins/action/sda_port_assignment_for_user_device.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_port_assignment_for_user_device_info.py b/plugins/action/sda_port_assignment_for_user_device_info.py index b37e3caccc..7ef7cc2c6a 100644 --- a/plugins/action/sda_port_assignment_for_user_device_info.py +++ b/plugins/action/sda_port_assignment_for_user_device_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_port_assignment_for_user_device_v1.py b/plugins/action/sda_port_assignment_for_user_device_v1.py index 86065b9dde..ee97dab364 100644 --- a/plugins/action/sda_port_assignment_for_user_device_v1.py +++ b/plugins/action/sda_port_assignment_for_user_device_v1.py @@ -63,7 +63,8 @@ def __init__(self, params, dnac): authenticateTemplateName=params.get("authenticateTemplateName"), scalableGroupName=params.get("scalableGroupName"), interfaceDescription=params.get("interfaceDescription"), - device_management_ip_address=params.get("deviceManagementIpAddress"), + device_management_ip_address=params.get( + "deviceManagementIpAddress"), interface_name=params.get("interfaceName"), ) @@ -77,21 +78,32 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['siteNameHierarchy'] = self.new_object.get('siteNameHierarchy') - new_object_params['deviceManagementIpAddress'] = self.new_object.get('deviceManagementIpAddress') - new_object_params['interfaceName'] = self.new_object.get('interfaceName') - new_object_params['interfaceNames'] = self.new_object.get('interfaceNames') - new_object_params['dataIpAddressPoolName'] = self.new_object.get('dataIpAddressPoolName') - new_object_params['voiceIpAddressPoolName'] = self.new_object.get('voiceIpAddressPoolName') - new_object_params['authenticateTemplateName'] = self.new_object.get('authenticateTemplateName') - new_object_params['scalableGroupName'] = self.new_object.get('scalableGroupName') - new_object_params['interfaceDescription'] = self.new_object.get('interfaceDescription') + new_object_params['siteNameHierarchy'] = self.new_object.get( + 'siteNameHierarchy') + new_object_params['deviceManagementIpAddress'] = self.new_object.get( + 'deviceManagementIpAddress') + new_object_params['interfaceName'] = self.new_object.get( + 'interfaceName') + new_object_params['interfaceNames'] = self.new_object.get( + 'interfaceNames') + new_object_params['dataIpAddressPoolName'] = self.new_object.get( + 'dataIpAddressPoolName') + new_object_params['voiceIpAddressPoolName'] = self.new_object.get( + 'voiceIpAddressPoolName') + new_object_params['authenticateTemplateName'] = self.new_object.get( + 'authenticateTemplateName') + new_object_params['scalableGroupName'] = self.new_object.get( + 'scalableGroupName') + new_object_params['interfaceDescription'] = self.new_object.get( + 'interfaceDescription') return new_object_params def delete_all_params(self): new_object_params = {} - new_object_params['device_management_ip_address'] = self.new_object.get('device_management_ip_address') - new_object_params['interface_name'] = self.new_object.get('interface_name') + new_object_params['device_management_ip_address'] = self.new_object.get( + 'device_management_ip_address') + new_object_params['interface_name'] = self.new_object.get( + 'interface_name') return new_object_params def get_object_by_name(self, name, is_absent=False): @@ -126,7 +138,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -180,7 +193,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -230,7 +244,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: (obj_exists, prev_obj) = obj.exists(is_absent=True) @@ -240,7 +255,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_port_assignment_for_user_device_v1_info.py b/plugins/action/sda_port_assignment_for_user_device_v1_info.py index 978a8b042d..eac69b78af 100644 --- a/plugins/action/sda_port_assignment_for_user_device_v1_info.py +++ b/plugins/action/sda_port_assignment_for_user_device_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -65,7 +66,8 @@ def _check_argspec(self): def get_object(self, params): new_object = dict( - device_management_ip_address=params.get("deviceManagementIpAddress"), + device_management_ip_address=params.get( + "deviceManagementIpAddress"), interface_name=params.get("interfaceName"), headers=params.get("headers"), ) diff --git a/plugins/action/sda_port_assignments.py b/plugins/action/sda_port_assignments.py index 270fa8793e..e9610f98cd 100644 --- a/plugins/action/sda_port_assignments.py +++ b/plugins/action/sda_port_assignments.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_port_assignments_count_info.py b/plugins/action/sda_port_assignments_count_info.py index 92f234a7d5..c250650efe 100644 --- a/plugins/action/sda_port_assignments_count_info.py +++ b/plugins/action/sda_port_assignments_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_port_assignments_count_v1_info.py b/plugins/action/sda_port_assignments_count_v1_info.py index 06d6383904..0c646a119e 100644 --- a/plugins/action/sda_port_assignments_count_v1_info.py +++ b/plugins/action/sda_port_assignments_count_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_port_assignments_info.py b/plugins/action/sda_port_assignments_info.py index 3b769febcd..651fb52b9c 100644 --- a/plugins/action/sda_port_assignments_info.py +++ b/plugins/action/sda_port_assignments_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_port_assignments_v1.py b/plugins/action/sda_port_assignments_v1.py index b0cc3e3437..d85faf11ba 100644 --- a/plugins/action/sda_port_assignments_v1.py +++ b/plugins/action/sda_port_assignments_v1.py @@ -140,7 +140,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -226,7 +227,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -277,7 +279,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: @@ -288,7 +291,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_port_assignments_v1_info.py b/plugins/action/sda_port_assignments_v1_info.py index f04e91004e..c92ed779b5 100644 --- a/plugins/action/sda_port_assignments_v1_info.py +++ b/plugins/action/sda_port_assignments_v1_info.py @@ -44,7 +44,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_port_channels.py b/plugins/action/sda_port_channels.py index 2c4cba7a68..ef5fb0fc57 100644 --- a/plugins/action/sda_port_channels.py +++ b/plugins/action/sda_port_channels.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_port_channels_count_info.py b/plugins/action/sda_port_channels_count_info.py index 8ff21bea4f..b94efa22ff 100644 --- a/plugins/action/sda_port_channels_count_info.py +++ b/plugins/action/sda_port_channels_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_port_channels_count_v1_info.py b/plugins/action/sda_port_channels_count_v1_info.py index 9d74db7363..027d93144f 100644 --- a/plugins/action/sda_port_channels_count_v1_info.py +++ b/plugins/action/sda_port_channels_count_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_port_channels_info.py b/plugins/action/sda_port_channels_info.py index d1950153b7..29aaf966f4 100644 --- a/plugins/action/sda_port_channels_info.py +++ b/plugins/action/sda_port_channels_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_port_channels_v1.py b/plugins/action/sda_port_channels_v1.py index dc9a353290..ed0a1f1b70 100644 --- a/plugins/action/sda_port_channels_v1.py +++ b/plugins/action/sda_port_channels_v1.py @@ -136,7 +136,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -219,7 +220,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -270,7 +272,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: @@ -281,7 +284,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_port_channels_v1_info.py b/plugins/action/sda_port_channels_v1_info.py index bf8d1b811d..8a7ae8e261 100644 --- a/plugins/action/sda_port_channels_v1_info.py +++ b/plugins/action/sda_port_channels_v1_info.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_provision_device.py b/plugins/action/sda_provision_device.py index 22cea34a31..79748af524 100644 --- a/plugins/action/sda_provision_device.py +++ b/plugins/action/sda_provision_device.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_provision_device_info.py b/plugins/action/sda_provision_device_info.py index 89c03e5e03..37b78c0fe8 100644 --- a/plugins/action/sda_provision_device_info.py +++ b/plugins/action/sda_provision_device_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_provision_device_v1.py b/plugins/action/sda_provision_device_v1.py index 10decd34bd..cb4b0204ff 100644 --- a/plugins/action/sda_provision_device_v1.py +++ b/plugins/action/sda_provision_device_v1.py @@ -49,7 +49,8 @@ def __init__(self, params, dnac): self.new_object = dict( deviceManagementIpAddress=params.get("deviceManagementIpAddress"), siteNameHierarchy=params.get("siteNameHierarchy"), - device_management_ip_address=params.get("deviceManagementIpAddress"), + device_management_ip_address=params.get( + "deviceManagementIpAddress"), ) def get_all_params(self, name=None, id=None): @@ -60,19 +61,24 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['deviceManagementIpAddress'] = self.new_object.get('deviceManagementIpAddress') - new_object_params['siteNameHierarchy'] = self.new_object.get('siteNameHierarchy') + new_object_params['deviceManagementIpAddress'] = self.new_object.get( + 'deviceManagementIpAddress') + new_object_params['siteNameHierarchy'] = self.new_object.get( + 'siteNameHierarchy') return new_object_params def delete_all_params(self): new_object_params = {} - new_object_params['device_management_ip_address'] = self.new_object.get('device_management_ip_address') + new_object_params['device_management_ip_address'] = self.new_object.get( + 'device_management_ip_address') return new_object_params def update_all_params(self): new_object_params = {} - new_object_params['deviceManagementIpAddress'] = self.new_object.get('deviceManagementIpAddress') - new_object_params['siteNameHierarchy'] = self.new_object.get('siteNameHierarchy') + new_object_params['deviceManagementIpAddress'] = self.new_object.get( + 'deviceManagementIpAddress') + new_object_params['siteNameHierarchy'] = self.new_object.get( + 'siteNameHierarchy') return new_object_params def get_object_by_name(self, name, is_absent=False): @@ -119,7 +125,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -177,7 +184,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -228,7 +236,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: @@ -239,7 +248,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_provision_device_v1_info.py b/plugins/action/sda_provision_device_v1_info.py index e1f5dc0efc..5977bf3d9b 100644 --- a/plugins/action/sda_provision_device_v1_info.py +++ b/plugins/action/sda_provision_device_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -64,7 +65,8 @@ def _check_argspec(self): def get_object(self, params): new_object = dict( - device_management_ip_address=params.get("deviceManagementIpAddress"), + device_management_ip_address=params.get( + "deviceManagementIpAddress"), headers=params.get("headers"), ) return new_object diff --git a/plugins/action/sda_provision_devices.py b/plugins/action/sda_provision_devices.py index 797436e5cd..61639c7f3d 100644 --- a/plugins/action/sda_provision_devices.py +++ b/plugins/action/sda_provision_devices.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_provision_devices_count_info.py b/plugins/action/sda_provision_devices_count_info.py index 57fd7b6c33..8cf29bac02 100644 --- a/plugins/action/sda_provision_devices_count_info.py +++ b/plugins/action/sda_provision_devices_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_provision_devices_count_v1_info.py b/plugins/action/sda_provision_devices_count_v1_info.py index 4c2ee370e1..88bf40902a 100644 --- a/plugins/action/sda_provision_devices_count_v1_info.py +++ b/plugins/action/sda_provision_devices_count_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_provision_devices_info.py b/plugins/action/sda_provision_devices_info.py index 3a12b9045e..0ce332eb65 100644 --- a/plugins/action/sda_provision_devices_info.py +++ b/plugins/action/sda_provision_devices_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_provision_devices_v1.py b/plugins/action/sda_provision_devices_v1.py index b2db8cf029..1b17b9b4e5 100644 --- a/plugins/action/sda_provision_devices_v1.py +++ b/plugins/action/sda_provision_devices_v1.py @@ -129,7 +129,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -205,7 +206,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -256,7 +258,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: @@ -267,7 +270,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_provision_devices_v1_info.py b/plugins/action/sda_provision_devices_v1_info.py index d44df78be2..b8e5b276f5 100644 --- a/plugins/action/sda_provision_devices_v1_info.py +++ b/plugins/action/sda_provision_devices_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_site_member_member_info.py b/plugins/action/sda_site_member_member_info.py index dafa736e65..e869157c9c 100644 --- a/plugins/action/sda_site_member_member_info.py +++ b/plugins/action/sda_site_member_member_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_site_member_member_v1_info.py b/plugins/action/sda_site_member_member_v1_info.py index a7f832ed4e..5832d76e61 100644 --- a/plugins/action/sda_site_member_member_v1_info.py +++ b/plugins/action/sda_site_member_member_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_transit_networks.py b/plugins/action/sda_transit_networks.py index 81f5fcc89a..7211915683 100644 --- a/plugins/action/sda_transit_networks.py +++ b/plugins/action/sda_transit_networks.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_transit_networks_count_info.py b/plugins/action/sda_transit_networks_count_info.py index def8ea2dd6..f328e54109 100644 --- a/plugins/action/sda_transit_networks_count_info.py +++ b/plugins/action/sda_transit_networks_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_transit_networks_count_v1_info.py b/plugins/action/sda_transit_networks_count_v1_info.py index 8674434f1f..914c9d8c92 100644 --- a/plugins/action/sda_transit_networks_count_v1_info.py +++ b/plugins/action/sda_transit_networks_count_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_transit_networks_info.py b/plugins/action/sda_transit_networks_info.py index acb54be017..d7627a3cae 100644 --- a/plugins/action/sda_transit_networks_info.py +++ b/plugins/action/sda_transit_networks_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_transit_networks_v1.py b/plugins/action/sda_transit_networks_v1.py index 31dbebc72e..e5aed58b16 100644 --- a/plugins/action/sda_transit_networks_v1.py +++ b/plugins/action/sda_transit_networks_v1.py @@ -114,7 +114,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -178,7 +179,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -229,7 +231,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: @@ -240,7 +243,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_transit_networks_v1_info.py b/plugins/action/sda_transit_networks_v1_info.py index 9b274db502..5f2684ed29 100644 --- a/plugins/action/sda_transit_networks_v1_info.py +++ b/plugins/action/sda_transit_networks_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_virtual_network.py b/plugins/action/sda_virtual_network.py index 7118281697..9a0b937b6c 100644 --- a/plugins/action/sda_virtual_network.py +++ b/plugins/action/sda_virtual_network.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_virtual_network_info.py b/plugins/action/sda_virtual_network_info.py index 06bdb82b40..a0d93bc64e 100644 --- a/plugins/action/sda_virtual_network_info.py +++ b/plugins/action/sda_virtual_network_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_virtual_network_ip_pool.py b/plugins/action/sda_virtual_network_ip_pool.py index 0d25721719..55376f49d4 100644 --- a/plugins/action/sda_virtual_network_ip_pool.py +++ b/plugins/action/sda_virtual_network_ip_pool.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_virtual_network_ip_pool_info.py b/plugins/action/sda_virtual_network_ip_pool_info.py index 26a0e58b06..fcf9a15d5e 100644 --- a/plugins/action/sda_virtual_network_ip_pool_info.py +++ b/plugins/action/sda_virtual_network_ip_pool_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sda_virtual_network_ip_pool_v1.py b/plugins/action/sda_virtual_network_ip_pool_v1.py index 40deb3fab4..2265a484c1 100644 --- a/plugins/action/sda_virtual_network_ip_pool_v1.py +++ b/plugins/action/sda_virtual_network_ip_pool_v1.py @@ -94,28 +94,39 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['siteNameHierarchy'] = self.new_object.get('siteNameHierarchy') - new_object_params['virtualNetworkName'] = self.new_object.get('virtualNetworkName') + new_object_params['siteNameHierarchy'] = self.new_object.get( + 'siteNameHierarchy') + new_object_params['virtualNetworkName'] = self.new_object.get( + 'virtualNetworkName') new_object_params['isLayer2Only'] = self.new_object.get('isLayer2Only') new_object_params['ipPoolName'] = self.new_object.get('ipPoolName') new_object_params['vlanId'] = self.new_object.get('vlanId') new_object_params['vlanName'] = self.new_object.get('vlanName') - new_object_params['autoGenerateVlanName'] = self.new_object.get('autoGenerateVlanName') + new_object_params['autoGenerateVlanName'] = self.new_object.get( + 'autoGenerateVlanName') new_object_params['trafficType'] = self.new_object.get('trafficType') - new_object_params['scalableGroupName'] = self.new_object.get('scalableGroupName') - new_object_params['isL2FloodingEnabled'] = self.new_object.get('isL2FloodingEnabled') - new_object_params['isThisCriticalPool'] = self.new_object.get('isThisCriticalPool') - new_object_params['isWirelessPool'] = self.new_object.get('isWirelessPool') - new_object_params['isIpDirectedBroadcast'] = self.new_object.get('isIpDirectedBroadcast') + new_object_params['scalableGroupName'] = self.new_object.get( + 'scalableGroupName') + new_object_params['isL2FloodingEnabled'] = self.new_object.get( + 'isL2FloodingEnabled') + new_object_params['isThisCriticalPool'] = self.new_object.get( + 'isThisCriticalPool') + new_object_params['isWirelessPool'] = self.new_object.get( + 'isWirelessPool') + new_object_params['isIpDirectedBroadcast'] = self.new_object.get( + 'isIpDirectedBroadcast') new_object_params['isCommonPool'] = self.new_object.get('isCommonPool') - new_object_params['isBridgeModeVm'] = self.new_object.get('isBridgeModeVm') + new_object_params['isBridgeModeVm'] = self.new_object.get( + 'isBridgeModeVm') new_object_params['poolType'] = self.new_object.get('poolType') return new_object_params def delete_all_params(self): new_object_params = {} - new_object_params['site_name_hierarchy'] = self.new_object.get('site_name_hierarchy') - new_object_params['virtual_network_name'] = self.new_object.get('virtual_network_name') + new_object_params['site_name_hierarchy'] = self.new_object.get( + 'site_name_hierarchy') + new_object_params['virtual_network_name'] = self.new_object.get( + 'virtual_network_name') new_object_params['ip_pool_name'] = self.new_object.get('ip_pool_name') return new_object_params @@ -151,7 +162,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -213,7 +225,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -263,7 +276,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: (obj_exists, prev_obj) = obj.exists(is_absent=True) @@ -273,7 +287,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_virtual_network_ip_pool_v1_info.py b/plugins/action/sda_virtual_network_ip_pool_v1_info.py index 964f963bff..cb3cf64eb5 100644 --- a/plugins/action/sda_virtual_network_ip_pool_v1_info.py +++ b/plugins/action/sda_virtual_network_ip_pool_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_virtual_network_v1.py b/plugins/action/sda_virtual_network_v1.py index fb4aff3c44..319b8f5451 100644 --- a/plugins/action/sda_virtual_network_v1.py +++ b/plugins/action/sda_virtual_network_v1.py @@ -63,14 +63,18 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['virtualNetworkName'] = self.new_object.get('virtualNetworkName') - new_object_params['siteNameHierarchy'] = self.new_object.get('siteNameHierarchy') + new_object_params['virtualNetworkName'] = self.new_object.get( + 'virtualNetworkName') + new_object_params['siteNameHierarchy'] = self.new_object.get( + 'siteNameHierarchy') return new_object_params def delete_all_params(self): new_object_params = {} - new_object_params['virtual_network_name'] = self.new_object.get('virtual_network_name') - new_object_params['site_name_hierarchy'] = self.new_object.get('site_name_hierarchy') + new_object_params['virtual_network_name'] = self.new_object.get( + 'virtual_network_name') + new_object_params['site_name_hierarchy'] = self.new_object.get( + 'site_name_hierarchy') return new_object_params def get_object_by_name(self, name, is_absent=False): @@ -105,7 +109,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -152,7 +157,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -202,7 +208,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: (obj_exists, prev_obj) = obj.exists(is_absent=True) @@ -212,7 +219,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_virtual_network_v1_info.py b/plugins/action/sda_virtual_network_v1_info.py index 1397d9e0a6..3fc29bfdd3 100644 --- a/plugins/action/sda_virtual_network_v1_info.py +++ b/plugins/action/sda_virtual_network_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sda_virtual_network_v2.py b/plugins/action/sda_virtual_network_v2.py index 0629730f99..6b96ec1d2f 100644 --- a/plugins/action/sda_virtual_network_v2.py +++ b/plugins/action/sda_virtual_network_v2.py @@ -64,22 +64,29 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['virtualNetworkName'] = self.new_object.get('virtualNetworkName') - new_object_params['isGuestVirtualNetwork'] = self.new_object.get('isGuestVirtualNetwork') - new_object_params['scalableGroupNames'] = self.new_object.get('scalableGroupNames') + new_object_params['virtualNetworkName'] = self.new_object.get( + 'virtualNetworkName') + new_object_params['isGuestVirtualNetwork'] = self.new_object.get( + 'isGuestVirtualNetwork') + new_object_params['scalableGroupNames'] = self.new_object.get( + 'scalableGroupNames') new_object_params['vManageVpnId'] = self.new_object.get('vManageVpnId') return new_object_params def delete_all_params(self): new_object_params = {} - new_object_params['virtual_network_name'] = self.new_object.get('virtual_network_name') + new_object_params['virtual_network_name'] = self.new_object.get( + 'virtual_network_name') return new_object_params def update_all_params(self): new_object_params = {} - new_object_params['virtualNetworkName'] = self.new_object.get('virtualNetworkName') - new_object_params['isGuestVirtualNetwork'] = self.new_object.get('isGuestVirtualNetwork') - new_object_params['scalableGroupNames'] = self.new_object.get('scalableGroupNames') + new_object_params['virtualNetworkName'] = self.new_object.get( + 'virtualNetworkName') + new_object_params['isGuestVirtualNetwork'] = self.new_object.get( + 'isGuestVirtualNetwork') + new_object_params['scalableGroupNames'] = self.new_object.get( + 'scalableGroupNames') new_object_params['vManageVpnId'] = self.new_object.get('vManageVpnId') return new_object_params @@ -115,7 +122,8 @@ def get_object_by_id(self, id): def exists(self, is_absent=False): name = self.new_object.get("name") prev_obj = self.get_object_by_name(name, is_absent=is_absent) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) and prev_obj.get("status") != "failed" + it_exists = prev_obj is not None and isinstance( + prev_obj, dict) and prev_obj.get("status") != "failed" return (it_exists, prev_obj) def requires_update(self, current_obj): @@ -175,7 +183,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -226,7 +235,8 @@ def run(self, tmp=None, task_vars=None): response = obj.create() dnac.object_created() except AnsibleSDAException as e: - dnac.fail_json("Could not create object {e}".format(e=e._response)) + dnac.fail_json( + "Could not create object {e}".format(e=e._response)) elif state == "absent": try: @@ -237,7 +247,8 @@ def run(self, tmp=None, task_vars=None): else: dnac.object_already_absent() except AnsibleSDAException as e: - dnac.fail_json("Could not get object to be delete {e}".format(e=e._response)) + dnac.fail_json( + "Could not get object to be delete {e}".format(e=e._response)) self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sda_virtual_network_v2_info.py b/plugins/action/sda_virtual_network_v2_info.py index 616aad03b6..7ac941580d 100644 --- a/plugins/action/sda_virtual_network_v2_info.py +++ b/plugins/action/sda_virtual_network_v2_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/security_advisories_devices_info.py b/plugins/action/security_advisories_devices_info.py index 4e44303fc2..3a65cd78de 100644 --- a/plugins/action/security_advisories_devices_info.py +++ b/plugins/action/security_advisories_devices_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/security_advisories_devices_v1_info.py b/plugins/action/security_advisories_devices_v1_info.py index 7e2389b721..babc38f81e 100644 --- a/plugins/action/security_advisories_devices_v1_info.py +++ b/plugins/action/security_advisories_devices_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/security_advisories_ids_per_device_info.py b/plugins/action/security_advisories_ids_per_device_info.py index 2e5ae5430d..e2849822e9 100644 --- a/plugins/action/security_advisories_ids_per_device_info.py +++ b/plugins/action/security_advisories_ids_per_device_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/security_advisories_ids_per_device_v1_info.py b/plugins/action/security_advisories_ids_per_device_v1_info.py index e66fc4bae8..8e997556f5 100644 --- a/plugins/action/security_advisories_ids_per_device_v1_info.py +++ b/plugins/action/security_advisories_ids_per_device_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/security_advisories_info.py b/plugins/action/security_advisories_info.py index e13b79f4f1..b9e845ddfe 100644 --- a/plugins/action/security_advisories_info.py +++ b/plugins/action/security_advisories_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/security_advisories_per_device_info.py b/plugins/action/security_advisories_per_device_info.py index fbb394ee22..97a59b45eb 100644 --- a/plugins/action/security_advisories_per_device_info.py +++ b/plugins/action/security_advisories_per_device_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/security_advisories_per_device_v1_info.py b/plugins/action/security_advisories_per_device_v1_info.py index 8f116eebed..5a6de83ebc 100644 --- a/plugins/action/security_advisories_per_device_v1_info.py +++ b/plugins/action/security_advisories_per_device_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/security_advisories_summary_info.py b/plugins/action/security_advisories_summary_info.py index c092045507..fc46f60c01 100644 --- a/plugins/action/security_advisories_summary_info.py +++ b/plugins/action/security_advisories_summary_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/security_advisories_summary_v1_info.py b/plugins/action/security_advisories_summary_v1_info.py index 0dfc0278b0..df2e5d5675 100644 --- a/plugins/action/security_advisories_summary_v1_info.py +++ b/plugins/action/security_advisories_summary_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/security_advisories_v1_info.py b/plugins/action/security_advisories_v1_info.py index 6997b4040f..cfca8af8bb 100644 --- a/plugins/action/security_advisories_v1_info.py +++ b/plugins/action/security_advisories_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/security_rogue_additional_details.py b/plugins/action/security_rogue_additional_details.py index a6d2828cd4..b6eacccad0 100644 --- a/plugins/action/security_rogue_additional_details.py +++ b/plugins/action/security_rogue_additional_details.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/security_rogue_additional_details_count.py b/plugins/action/security_rogue_additional_details_count.py index cae1acc626..6c614e1e4a 100644 --- a/plugins/action/security_rogue_additional_details_count.py +++ b/plugins/action/security_rogue_additional_details_count.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/security_rogue_additional_details_count_v1.py b/plugins/action/security_rogue_additional_details_count_v1.py index 399cc928c2..049cb75c9b 100644 --- a/plugins/action/security_rogue_additional_details_count_v1.py +++ b/plugins/action/security_rogue_additional_details_count_v1.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/security_rogue_additional_details_v1.py b/plugins/action/security_rogue_additional_details_v1.py index 9c9be45cda..1a634afecd 100644 --- a/plugins/action/security_rogue_additional_details_v1.py +++ b/plugins/action/security_rogue_additional_details_v1.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/security_rogue_wireless_containment_start.py b/plugins/action/security_rogue_wireless_containment_start.py index 7977546147..fb52779d8f 100644 --- a/plugins/action/security_rogue_wireless_containment_start.py +++ b/plugins/action/security_rogue_wireless_containment_start.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/security_rogue_wireless_containment_start_v1.py b/plugins/action/security_rogue_wireless_containment_start_v1.py index 8615773437..2a071303e4 100644 --- a/plugins/action/security_rogue_wireless_containment_start_v1.py +++ b/plugins/action/security_rogue_wireless_containment_start_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/security_rogue_wireless_containment_status_info.py b/plugins/action/security_rogue_wireless_containment_status_info.py index 5fe19863b9..76d5fcab51 100644 --- a/plugins/action/security_rogue_wireless_containment_status_info.py +++ b/plugins/action/security_rogue_wireless_containment_status_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/security_rogue_wireless_containment_status_v1_info.py b/plugins/action/security_rogue_wireless_containment_status_v1_info.py index 0657ac4491..43c0b36b46 100644 --- a/plugins/action/security_rogue_wireless_containment_status_v1_info.py +++ b/plugins/action/security_rogue_wireless_containment_status_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/security_rogue_wireless_containment_stop.py b/plugins/action/security_rogue_wireless_containment_stop.py index 40bcfc12dc..028948cbc8 100644 --- a/plugins/action/security_rogue_wireless_containment_stop.py +++ b/plugins/action/security_rogue_wireless_containment_stop.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/security_rogue_wireless_containment_stop_v1.py b/plugins/action/security_rogue_wireless_containment_stop_v1.py index 1732749a80..4752667788 100644 --- a/plugins/action/security_rogue_wireless_containment_stop_v1.py +++ b/plugins/action/security_rogue_wireless_containment_stop_v1.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/security_threats_details.py b/plugins/action/security_threats_details.py index e0d5c837be..a41f5fcfdd 100644 --- a/plugins/action/security_threats_details.py +++ b/plugins/action/security_threats_details.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/security_threats_details_count.py b/plugins/action/security_threats_details_count.py index e980e52adb..82804de8ea 100644 --- a/plugins/action/security_threats_details_count.py +++ b/plugins/action/security_threats_details_count.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/security_threats_details_count_v1.py b/plugins/action/security_threats_details_count_v1.py index 60f441bf40..58003260bd 100644 --- a/plugins/action/security_threats_details_count_v1.py +++ b/plugins/action/security_threats_details_count_v1.py @@ -44,7 +44,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/security_threats_details_v1.py b/plugins/action/security_threats_details_v1.py index fde933458c..39ff022990 100644 --- a/plugins/action/security_threats_details_v1.py +++ b/plugins/action/security_threats_details_v1.py @@ -44,7 +44,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/security_threats_level_info.py b/plugins/action/security_threats_level_info.py index d677d448b7..579c59d1c9 100644 --- a/plugins/action/security_threats_level_info.py +++ b/plugins/action/security_threats_level_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/security_threats_level_v1_info.py b/plugins/action/security_threats_level_v1_info.py index e92ca2c262..ebd6749f9e 100644 --- a/plugins/action/security_threats_level_v1_info.py +++ b/plugins/action/security_threats_level_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/security_threats_rogue_allowed_list.py b/plugins/action/security_threats_rogue_allowed_list.py index fcc322b1ec..177c41dcfd 100644 --- a/plugins/action/security_threats_rogue_allowed_list.py +++ b/plugins/action/security_threats_rogue_allowed_list.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/security_threats_rogue_allowed_list_count_info.py b/plugins/action/security_threats_rogue_allowed_list_count_info.py index 7dd7f49fac..6034fa82b8 100644 --- a/plugins/action/security_threats_rogue_allowed_list_count_info.py +++ b/plugins/action/security_threats_rogue_allowed_list_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/security_threats_rogue_allowed_list_count_v1_info.py b/plugins/action/security_threats_rogue_allowed_list_count_v1_info.py index dd08003cb8..846842b068 100644 --- a/plugins/action/security_threats_rogue_allowed_list_count_v1_info.py +++ b/plugins/action/security_threats_rogue_allowed_list_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/security_threats_rogue_allowed_list_info.py b/plugins/action/security_threats_rogue_allowed_list_info.py index 71cd28f5f9..995364612e 100644 --- a/plugins/action/security_threats_rogue_allowed_list_info.py +++ b/plugins/action/security_threats_rogue_allowed_list_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/security_threats_rogue_allowed_list_v1.py b/plugins/action/security_threats_rogue_allowed_list_v1.py index b1da210778..23b2b388fd 100644 --- a/plugins/action/security_threats_rogue_allowed_list_v1.py +++ b/plugins/action/security_threats_rogue_allowed_list_v1.py @@ -100,7 +100,8 @@ def exists(self): if requested_obj and len(requested_obj) > 0: requested_obj = requested_obj[0] o_id = self.new_object.get("id") or requested_obj.get("id") - o_id = o_id or self.new_object.get("mac_address") or requested_obj.get("macAddress") + o_id = o_id or self.new_object.get( + "mac_address") or requested_obj.get("macAddress") name = self.new_object.get("name") or requested_obj.get("name") if o_id: prev_obj = self.get_object_by_id(o_id) @@ -112,7 +113,8 @@ def exists(self): _id = prev_obj.get("id") _id = _id or prev_obj.get("macAddress") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) self.new_object.update(dict(mac_address=_id)) @@ -149,7 +151,8 @@ def delete(self): if requested_obj and len(requested_obj) > 0: requested_obj = requested_obj[0] id = self.new_object.get("id") or requested_obj.get("id") - id = id or self.new_object.get("mac_address") or requested_obj.get("macAddress") + id = id or self.new_object.get( + "mac_address") or requested_obj.get("macAddress") name = self.new_object.get("name") or requested_obj.get("name") result = None if not id: @@ -171,7 +174,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/security_threats_rogue_allowed_list_v1_info.py b/plugins/action/security_threats_rogue_allowed_list_v1_info.py index 67558aa3da..2886448290 100644 --- a/plugins/action/security_threats_rogue_allowed_list_v1_info.py +++ b/plugins/action/security_threats_rogue_allowed_list_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/security_threats_summary.py b/plugins/action/security_threats_summary.py index 7d5062e6b8..5056c30cd6 100644 --- a/plugins/action/security_threats_summary.py +++ b/plugins/action/security_threats_summary.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/security_threats_summary_v1.py b/plugins/action/security_threats_summary_v1.py index 00c2bd0882..eed49e9dfe 100644 --- a/plugins/action/security_threats_summary_v1.py +++ b/plugins/action/security_threats_summary_v1.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/security_threats_type_info.py b/plugins/action/security_threats_type_info.py index 3434d536db..13b55acdc0 100644 --- a/plugins/action/security_threats_type_info.py +++ b/plugins/action/security_threats_type_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/security_threats_type_v1_info.py b/plugins/action/security_threats_type_v1_info.py index eaf53f444d..c5baf413ae 100644 --- a/plugins/action/security_threats_type_v1_info.py +++ b/plugins/action/security_threats_type_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sensor.py b/plugins/action/sensor.py index f7a4cf6d75..fc737ba9b1 100644 --- a/plugins/action/sensor.py +++ b/plugins/action/sensor.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sensor_info.py b/plugins/action/sensor_info.py index 5d735729a0..aeb59bb8cc 100644 --- a/plugins/action/sensor_info.py +++ b/plugins/action/sensor_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sensor_test_run.py b/plugins/action/sensor_test_run.py index f5ec966d0a..cddf0f4648 100644 --- a/plugins/action/sensor_test_run.py +++ b/plugins/action/sensor_test_run.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sensor_test_run_v1.py b/plugins/action/sensor_test_run_v1.py index f7edde46f8..31d3e8387d 100644 --- a/plugins/action/sensor_test_run_v1.py +++ b/plugins/action/sensor_test_run_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/sensor_test_template_duplicate.py b/plugins/action/sensor_test_template_duplicate.py index 7a6edf9e88..61620eb9db 100644 --- a/plugins/action/sensor_test_template_duplicate.py +++ b/plugins/action/sensor_test_template_duplicate.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sensor_test_template_duplicate_v1.py b/plugins/action/sensor_test_template_duplicate_v1.py index 6cd4924c18..a9a77e3016 100644 --- a/plugins/action/sensor_test_template_duplicate_v1.py +++ b/plugins/action/sensor_test_template_duplicate_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/sensor_test_template_edit.py b/plugins/action/sensor_test_template_edit.py index e3446b3fca..3d3fabf29f 100644 --- a/plugins/action/sensor_test_template_edit.py +++ b/plugins/action/sensor_test_template_edit.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sensor_test_template_edit_v1.py b/plugins/action/sensor_test_template_edit_v1.py index 5290cb614a..cac501934b 100644 --- a/plugins/action/sensor_test_template_edit_v1.py +++ b/plugins/action/sensor_test_template_edit_v1.py @@ -64,7 +64,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/sensor_v1.py b/plugins/action/sensor_v1.py index abf7e8fae0..dfab5b2eba 100644 --- a/plugins/action/sensor_v1.py +++ b/plugins/action/sensor_v1.py @@ -86,16 +86,19 @@ def create_params(self): new_object_params['connection'] = self.new_object.get('connection') new_object_params['ssids'] = self.new_object.get('ssids') new_object_params['profiles'] = self.new_object.get('profiles') - new_object_params['encryptionMode'] = self.new_object.get('encryptionMode') + new_object_params['encryptionMode'] = self.new_object.get( + 'encryptionMode') new_object_params['runNow'] = self.new_object.get('runNow') - new_object_params['locationInfoList'] = self.new_object.get('locationInfoList') + new_object_params['locationInfoList'] = self.new_object.get( + 'locationInfoList') new_object_params['sensors'] = self.new_object.get('sensors') new_object_params['apCoverage'] = self.new_object.get('apCoverage') return new_object_params def delete_all_params(self): new_object_params = {} - new_object_params['template_name'] = self.new_object.get('template_name') + new_object_params['template_name'] = self.new_object.get( + 'template_name') return new_object_params def get_object_by_name(self, name): @@ -135,7 +138,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -188,7 +192,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/sensor_v1_info.py b/plugins/action/sensor_v1_info.py index 514ddc22bd..eecfe8fc0a 100644 --- a/plugins/action/sensor_v1_info.py +++ b/plugins/action/sensor_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/service_provider_create.py b/plugins/action/service_provider_create.py index a466204e4a..749ad37ec5 100644 --- a/plugins/action/service_provider_create.py +++ b/plugins/action/service_provider_create.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/service_provider_create_v1.py b/plugins/action/service_provider_create_v1.py index d7c1339428..1db461155e 100644 --- a/plugins/action/service_provider_create_v1.py +++ b/plugins/action/service_provider_create_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/service_provider_info.py b/plugins/action/service_provider_info.py index f6a15a18af..66e412c0fa 100644 --- a/plugins/action/service_provider_info.py +++ b/plugins/action/service_provider_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/service_provider_profile_delete.py b/plugins/action/service_provider_profile_delete.py index ee60cdbe58..f3084b455e 100644 --- a/plugins/action/service_provider_profile_delete.py +++ b/plugins/action/service_provider_profile_delete.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/service_provider_profile_delete_v1.py b/plugins/action/service_provider_profile_delete_v1.py index 93f62fdcfc..1cf49feccd 100644 --- a/plugins/action/service_provider_profile_delete_v1.py +++ b/plugins/action/service_provider_profile_delete_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/service_provider_update.py b/plugins/action/service_provider_update.py index 76e8e10b16..07113dcf67 100644 --- a/plugins/action/service_provider_update.py +++ b/plugins/action/service_provider_update.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/service_provider_update_v1.py b/plugins/action/service_provider_update_v1.py index b89836bf5d..30e3d8d1fc 100644 --- a/plugins/action/service_provider_update_v1.py +++ b/plugins/action/service_provider_update_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/service_provider_v1_info.py b/plugins/action/service_provider_v1_info.py index 85c9de5624..c990566462 100644 --- a/plugins/action/service_provider_v1_info.py +++ b/plugins/action/service_provider_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/service_provider_v2.py b/plugins/action/service_provider_v2.py index 36ce8ab086..60ad823873 100644 --- a/plugins/action/service_provider_v2.py +++ b/plugins/action/service_provider_v2.py @@ -100,7 +100,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -143,7 +144,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/service_provider_v2_info.py b/plugins/action/service_provider_v2_info.py index f81c0e81c8..78db2f2552 100644 --- a/plugins/action/service_provider_v2_info.py +++ b/plugins/action/service_provider_v2_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/site_assign_credential.py b/plugins/action/site_assign_credential.py index f75e26b54d..fd75d67ce6 100644 --- a/plugins/action/site_assign_credential.py +++ b/plugins/action/site_assign_credential.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/site_assign_credential_v1.py b/plugins/action/site_assign_credential_v1.py index 233ad821dc..e082610199 100644 --- a/plugins/action/site_assign_credential_v1.py +++ b/plugins/action/site_assign_credential_v1.py @@ -44,7 +44,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/site_count_info.py b/plugins/action/site_count_info.py index f69db05651..4916bda049 100644 --- a/plugins/action/site_count_info.py +++ b/plugins/action/site_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/site_count_v1_info.py b/plugins/action/site_count_v1_info.py index a72efdf4f2..8b2884a9bc 100644 --- a/plugins/action/site_count_v1_info.py +++ b/plugins/action/site_count_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/site_count_v2_info.py b/plugins/action/site_count_v2_info.py index 8f74ffe04e..cde64c38b7 100644 --- a/plugins/action/site_count_v2_info.py +++ b/plugins/action/site_count_v2_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/site_create.py b/plugins/action/site_create.py index 3d9ca073ee..cb32af1aba 100644 --- a/plugins/action/site_create.py +++ b/plugins/action/site_create.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/site_create_v1.py b/plugins/action/site_create_v1.py index b798b3f02c..2412421873 100644 --- a/plugins/action/site_create_v1.py +++ b/plugins/action/site_create_v1.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/site_delete.py b/plugins/action/site_delete.py index 68f404b45d..4aa3c0270b 100644 --- a/plugins/action/site_delete.py +++ b/plugins/action/site_delete.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/site_delete_v1.py b/plugins/action/site_delete_v1.py index a8fb989da6..72cf6b734d 100644 --- a/plugins/action/site_delete_v1.py +++ b/plugins/action/site_delete_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/site_health_info.py b/plugins/action/site_health_info.py index 1d90c1a27a..b7e82ddaad 100644 --- a/plugins/action/site_health_info.py +++ b/plugins/action/site_health_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/site_health_summaries_count_info.py b/plugins/action/site_health_summaries_count_info.py index b14a9d5de0..40553b47a6 100644 --- a/plugins/action/site_health_summaries_count_info.py +++ b/plugins/action/site_health_summaries_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/site_health_summaries_count_v1_info.py b/plugins/action/site_health_summaries_count_v1_info.py index d14cb86925..d7cfb4b9fa 100644 --- a/plugins/action/site_health_summaries_count_v1_info.py +++ b/plugins/action/site_health_summaries_count_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/site_health_summaries_info.py b/plugins/action/site_health_summaries_info.py index f9548ce92d..8ade37b0e6 100644 --- a/plugins/action/site_health_summaries_info.py +++ b/plugins/action/site_health_summaries_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/site_health_summaries_summary_analytics.py b/plugins/action/site_health_summaries_summary_analytics.py index 4a94ea0c30..62880b4cf6 100644 --- a/plugins/action/site_health_summaries_summary_analytics.py +++ b/plugins/action/site_health_summaries_summary_analytics.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/site_health_summaries_summary_analytics_info.py b/plugins/action/site_health_summaries_summary_analytics_info.py index 196aa3b093..70c0b88f3a 100644 --- a/plugins/action/site_health_summaries_summary_analytics_info.py +++ b/plugins/action/site_health_summaries_summary_analytics_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/site_health_summaries_summary_analytics_v1.py b/plugins/action/site_health_summaries_summary_analytics_v1.py index 8b8ad19112..a4b9892880 100644 --- a/plugins/action/site_health_summaries_summary_analytics_v1.py +++ b/plugins/action/site_health_summaries_summary_analytics_v1.py @@ -124,7 +124,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -162,7 +163,8 @@ def create(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/site_health_summaries_summary_analytics_v1_info.py b/plugins/action/site_health_summaries_summary_analytics_v1_info.py index 693a5f194d..ec86944300 100644 --- a/plugins/action/site_health_summaries_summary_analytics_v1_info.py +++ b/plugins/action/site_health_summaries_summary_analytics_v1_info.py @@ -45,7 +45,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/site_health_summaries_v1_info.py b/plugins/action/site_health_summaries_v1_info.py index b074d5f3ea..7e794c07e6 100644 --- a/plugins/action/site_health_summaries_v1_info.py +++ b/plugins/action/site_health_summaries_v1_info.py @@ -49,7 +49,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/site_health_v1_info.py b/plugins/action/site_health_v1_info.py index 51bc661638..8d6b9f1c3b 100644 --- a/plugins/action/site_health_v1_info.py +++ b/plugins/action/site_health_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/site_info.py b/plugins/action/site_info.py index b9adb4e2c9..8199c0aa34 100644 --- a/plugins/action/site_info.py +++ b/plugins/action/site_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/site_membership_info.py b/plugins/action/site_membership_info.py index e7e07118ad..e0a1634c63 100644 --- a/plugins/action/site_membership_info.py +++ b/plugins/action/site_membership_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/site_membership_v1_info.py b/plugins/action/site_membership_v1_info.py index e16b8aca4e..d3c16253d5 100644 --- a/plugins/action/site_membership_v1_info.py +++ b/plugins/action/site_membership_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -100,7 +101,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/site_update.py b/plugins/action/site_update.py index 48e86c9eb0..a2e384340a 100644 --- a/plugins/action/site_update.py +++ b/plugins/action/site_update.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/site_update_v1.py b/plugins/action/site_update_v1.py index 283d4af025..2473199bdc 100644 --- a/plugins/action/site_update_v1.py +++ b/plugins/action/site_update_v1.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/site_v1_info.py b/plugins/action/site_v1_info.py index 289f4dc865..73b2f3b44e 100644 --- a/plugins/action/site_v1_info.py +++ b/plugins/action/site_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/site_v2_info.py b/plugins/action/site_v2_info.py index de6f8d2504..a341364b50 100644 --- a/plugins/action/site_v2_info.py +++ b/plugins/action/site_v2_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/site_wise_product_names_count_info.py b/plugins/action/site_wise_product_names_count_info.py index 8bbeae7fcd..f8f2409a83 100644 --- a/plugins/action/site_wise_product_names_count_info.py +++ b/plugins/action/site_wise_product_names_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/site_wise_product_names_count_v1_info.py b/plugins/action/site_wise_product_names_count_v1_info.py index 9ad3612579..6c4fb58517 100644 --- a/plugins/action/site_wise_product_names_count_v1_info.py +++ b/plugins/action/site_wise_product_names_count_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/site_wise_product_names_info.py b/plugins/action/site_wise_product_names_info.py index c0e56ee8cf..88d3c74966 100644 --- a/plugins/action/site_wise_product_names_info.py +++ b/plugins/action/site_wise_product_names_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/site_wise_product_names_v1_info.py b/plugins/action/site_wise_product_names_v1_info.py index 80c6016b5a..d73070409f 100644 --- a/plugins/action/site_wise_product_names_v1_info.py +++ b/plugins/action/site_wise_product_names_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sites_aaa_settings.py b/plugins/action/sites_aaa_settings.py index dbe1f458e2..6109270e25 100644 --- a/plugins/action/sites_aaa_settings.py +++ b/plugins/action/sites_aaa_settings.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_aaa_settings_info.py b/plugins/action/sites_aaa_settings_info.py index b24db9f904..e27ead0cd9 100644 --- a/plugins/action/sites_aaa_settings_info.py +++ b/plugins/action/sites_aaa_settings_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_aaa_settings_v1.py b/plugins/action/sites_aaa_settings_v1.py index 61a0e86be6..ed107f11db 100644 --- a/plugins/action/sites_aaa_settings_v1.py +++ b/plugins/action/sites_aaa_settings_v1.py @@ -104,7 +104,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -140,7 +141,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -186,7 +188,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sites_aaa_settings_v1_info.py b/plugins/action/sites_aaa_settings_v1_info.py index 62f9488eb2..0575f84017 100644 --- a/plugins/action/sites_aaa_settings_v1_info.py +++ b/plugins/action/sites_aaa_settings_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sites_banner_settings.py b/plugins/action/sites_banner_settings.py index a746f6ac28..44721f4c96 100644 --- a/plugins/action/sites_banner_settings.py +++ b/plugins/action/sites_banner_settings.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_banner_settings_info.py b/plugins/action/sites_banner_settings_info.py index 145c7333e6..623b4023b0 100644 --- a/plugins/action/sites_banner_settings_info.py +++ b/plugins/action/sites_banner_settings_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_banner_settings_v1.py b/plugins/action/sites_banner_settings_v1.py index 3972c33ce7..104570e6f0 100644 --- a/plugins/action/sites_banner_settings_v1.py +++ b/plugins/action/sites_banner_settings_v1.py @@ -101,7 +101,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -136,7 +137,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -182,7 +184,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sites_banner_settings_v1_info.py b/plugins/action/sites_banner_settings_v1_info.py index a5d64caf7a..4782b363f0 100644 --- a/plugins/action/sites_banner_settings_v1_info.py +++ b/plugins/action/sites_banner_settings_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sites_bulk.py b/plugins/action/sites_bulk.py index efaf1d4403..913c83b45a 100644 --- a/plugins/action/sites_bulk.py +++ b/plugins/action/sites_bulk.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_bulk_v1.py b/plugins/action/sites_bulk_v1.py index 47b8cc81fe..729fef3666 100644 --- a/plugins/action/sites_bulk_v1.py +++ b/plugins/action/sites_bulk_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/sites_count_info.py b/plugins/action/sites_count_info.py index 77a066abcc..69fb81ee44 100644 --- a/plugins/action/sites_count_info.py +++ b/plugins/action/sites_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_count_v1_info.py b/plugins/action/sites_count_v1_info.py index 922aff217b..6ae7c1398c 100644 --- a/plugins/action/sites_count_v1_info.py +++ b/plugins/action/sites_count_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sites_device_credentials.py b/plugins/action/sites_device_credentials.py index 34b50a600d..e39a6a31f6 100644 --- a/plugins/action/sites_device_credentials.py +++ b/plugins/action/sites_device_credentials.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_device_credentials_apply.py b/plugins/action/sites_device_credentials_apply.py index f0f7902786..ffa3f66104 100644 --- a/plugins/action/sites_device_credentials_apply.py +++ b/plugins/action/sites_device_credentials_apply.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_device_credentials_apply_v1.py b/plugins/action/sites_device_credentials_apply_v1.py index 2a325f3238..1c18bac8d1 100644 --- a/plugins/action/sites_device_credentials_apply_v1.py +++ b/plugins/action/sites_device_credentials_apply_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/sites_device_credentials_info.py b/plugins/action/sites_device_credentials_info.py index 7c4b0fd0f3..f29ddf940b 100644 --- a/plugins/action/sites_device_credentials_info.py +++ b/plugins/action/sites_device_credentials_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_device_credentials_status_info.py b/plugins/action/sites_device_credentials_status_info.py index 6c1ecb2f7b..e5a473b866 100644 --- a/plugins/action/sites_device_credentials_status_info.py +++ b/plugins/action/sites_device_credentials_status_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_device_credentials_status_v1_info.py b/plugins/action/sites_device_credentials_status_v1_info.py index cf49ca816f..d3c284a825 100644 --- a/plugins/action/sites_device_credentials_status_v1_info.py +++ b/plugins/action/sites_device_credentials_status_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sites_device_credentials_v1.py b/plugins/action/sites_device_credentials_v1.py index 70694d4c56..1c52602167 100644 --- a/plugins/action/sites_device_credentials_v1.py +++ b/plugins/action/sites_device_credentials_v1.py @@ -70,12 +70,18 @@ def get_all_params(self, name=None, id=None): def update_all_params(self): new_object_params = {} - new_object_params['cliCredentialsId'] = self.new_object.get('cliCredentialsId') - new_object_params['snmpv2cReadCredentialsId'] = self.new_object.get('snmpv2cReadCredentialsId') - new_object_params['snmpv2cWriteCredentialsId'] = self.new_object.get('snmpv2cWriteCredentialsId') - new_object_params['snmpv3CredentialsId'] = self.new_object.get('snmpv3CredentialsId') - new_object_params['httpReadCredentialsId'] = self.new_object.get('httpReadCredentialsId') - new_object_params['httpWriteCredentialsId'] = self.new_object.get('httpWriteCredentialsId') + new_object_params['cliCredentialsId'] = self.new_object.get( + 'cliCredentialsId') + new_object_params['snmpv2cReadCredentialsId'] = self.new_object.get( + 'snmpv2cReadCredentialsId') + new_object_params['snmpv2cWriteCredentialsId'] = self.new_object.get( + 'snmpv2cWriteCredentialsId') + new_object_params['snmpv3CredentialsId'] = self.new_object.get( + 'snmpv3CredentialsId') + new_object_params['httpReadCredentialsId'] = self.new_object.get( + 'httpReadCredentialsId') + new_object_params['httpWriteCredentialsId'] = self.new_object.get( + 'httpWriteCredentialsId') new_object_params['id'] = self.new_object.get('id') return new_object_params @@ -116,7 +122,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -156,7 +163,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -202,7 +210,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sites_device_credentials_v1_info.py b/plugins/action/sites_device_credentials_v1_info.py index 1eea30e284..4bba789bcb 100644 --- a/plugins/action/sites_device_credentials_v1_info.py +++ b/plugins/action/sites_device_credentials_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sites_dhcp_settings.py b/plugins/action/sites_dhcp_settings.py index b73a16c385..9f395dddd5 100644 --- a/plugins/action/sites_dhcp_settings.py +++ b/plugins/action/sites_dhcp_settings.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_dhcp_settings_info.py b/plugins/action/sites_dhcp_settings_info.py index 33180e7db1..603a8179bf 100644 --- a/plugins/action/sites_dhcp_settings_info.py +++ b/plugins/action/sites_dhcp_settings_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_dhcp_settings_v1.py b/plugins/action/sites_dhcp_settings_v1.py index 9773513d29..d1ee4060ad 100644 --- a/plugins/action/sites_dhcp_settings_v1.py +++ b/plugins/action/sites_dhcp_settings_v1.py @@ -101,7 +101,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -136,7 +137,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -182,7 +184,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sites_dhcp_settings_v1_info.py b/plugins/action/sites_dhcp_settings_v1_info.py index 33d5dd2fea..22086e7a40 100644 --- a/plugins/action/sites_dhcp_settings_v1_info.py +++ b/plugins/action/sites_dhcp_settings_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sites_dns_settings.py b/plugins/action/sites_dns_settings.py index 3f4cff7ea5..b058fdd543 100644 --- a/plugins/action/sites_dns_settings.py +++ b/plugins/action/sites_dns_settings.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_dns_settings_info.py b/plugins/action/sites_dns_settings_info.py index aa2eeba54f..44dad33b69 100644 --- a/plugins/action/sites_dns_settings_info.py +++ b/plugins/action/sites_dns_settings_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_dns_settings_v1.py b/plugins/action/sites_dns_settings_v1.py index 373ddd643e..f8d65903d0 100644 --- a/plugins/action/sites_dns_settings_v1.py +++ b/plugins/action/sites_dns_settings_v1.py @@ -101,7 +101,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -136,7 +137,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -182,7 +184,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sites_dns_settings_v1_info.py b/plugins/action/sites_dns_settings_v1_info.py index f5e113524b..528010daf8 100644 --- a/plugins/action/sites_dns_settings_v1_info.py +++ b/plugins/action/sites_dns_settings_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sites_image_distribution_settings.py b/plugins/action/sites_image_distribution_settings.py index 1eca30ed0b..ae1d4be7a0 100644 --- a/plugins/action/sites_image_distribution_settings.py +++ b/plugins/action/sites_image_distribution_settings.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_image_distribution_settings_info.py b/plugins/action/sites_image_distribution_settings_info.py index 02bb360d53..ba2b3c99a5 100644 --- a/plugins/action/sites_image_distribution_settings_info.py +++ b/plugins/action/sites_image_distribution_settings_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_image_distribution_settings_v1.py b/plugins/action/sites_image_distribution_settings_v1.py index cd2f06a472..0884fba927 100644 --- a/plugins/action/sites_image_distribution_settings_v1.py +++ b/plugins/action/sites_image_distribution_settings_v1.py @@ -60,7 +60,8 @@ def get_all_params(self, name=None, id=None): def update_all_params(self): new_object_params = {} - new_object_params['imageDistribution'] = self.new_object.get('imageDistribution') + new_object_params['imageDistribution'] = self.new_object.get( + 'imageDistribution') new_object_params['id'] = self.new_object.get('id') return new_object_params @@ -101,7 +102,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -136,7 +138,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -182,7 +185,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sites_image_distribution_settings_v1_info.py b/plugins/action/sites_image_distribution_settings_v1_info.py index 6ba7a5edfc..be0f7b59b8 100644 --- a/plugins/action/sites_image_distribution_settings_v1_info.py +++ b/plugins/action/sites_image_distribution_settings_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sites_info.py b/plugins/action/sites_info.py index 228fdf6b86..ee99c5efa6 100644 --- a/plugins/action/sites_info.py +++ b/plugins/action/sites_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_ntp_settings.py b/plugins/action/sites_ntp_settings.py index 76ea058652..b5a716bd20 100644 --- a/plugins/action/sites_ntp_settings.py +++ b/plugins/action/sites_ntp_settings.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_ntp_settings_info.py b/plugins/action/sites_ntp_settings_info.py index 59fcf65fbe..411d8dd882 100644 --- a/plugins/action/sites_ntp_settings_info.py +++ b/plugins/action/sites_ntp_settings_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_ntp_settings_v1.py b/plugins/action/sites_ntp_settings_v1.py index 5c5bacaa89..b571ee371c 100644 --- a/plugins/action/sites_ntp_settings_v1.py +++ b/plugins/action/sites_ntp_settings_v1.py @@ -101,7 +101,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -136,7 +137,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -182,7 +184,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sites_ntp_settings_v1_info.py b/plugins/action/sites_ntp_settings_v1_info.py index 6602817676..97bb434b49 100644 --- a/plugins/action/sites_ntp_settings_v1_info.py +++ b/plugins/action/sites_ntp_settings_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sites_profile_assignments_count_info.py b/plugins/action/sites_profile_assignments_count_info.py index 7173a8356b..0a7360372b 100644 --- a/plugins/action/sites_profile_assignments_count_info.py +++ b/plugins/action/sites_profile_assignments_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_profile_assignments_count_v1_info.py b/plugins/action/sites_profile_assignments_count_v1_info.py index d7211af47e..898b7ececb 100644 --- a/plugins/action/sites_profile_assignments_count_v1_info.py +++ b/plugins/action/sites_profile_assignments_count_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sites_profile_assignments_info.py b/plugins/action/sites_profile_assignments_info.py index a6e37a931c..f158bfae0b 100644 --- a/plugins/action/sites_profile_assignments_info.py +++ b/plugins/action/sites_profile_assignments_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_profile_assignments_v1_info.py b/plugins/action/sites_profile_assignments_v1_info.py index b3ade01f20..c164efcc67 100644 --- a/plugins/action/sites_profile_assignments_v1_info.py +++ b/plugins/action/sites_profile_assignments_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sites_telemetry_settings.py b/plugins/action/sites_telemetry_settings.py index ebd116ecc3..fd3e7fadce 100644 --- a/plugins/action/sites_telemetry_settings.py +++ b/plugins/action/sites_telemetry_settings.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_telemetry_settings_info.py b/plugins/action/sites_telemetry_settings_info.py index 43bbbc5c63..66c3b942cb 100644 --- a/plugins/action/sites_telemetry_settings_info.py +++ b/plugins/action/sites_telemetry_settings_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_telemetry_settings_v1.py b/plugins/action/sites_telemetry_settings_v1.py index 2689bac327..4a328ab621 100644 --- a/plugins/action/sites_telemetry_settings_v1.py +++ b/plugins/action/sites_telemetry_settings_v1.py @@ -68,11 +68,14 @@ def get_all_params(self, name=None, id=None): def update_all_params(self): new_object_params = {} - new_object_params['wiredDataCollection'] = self.new_object.get('wiredDataCollection') - new_object_params['wirelessTelemetry'] = self.new_object.get('wirelessTelemetry') + new_object_params['wiredDataCollection'] = self.new_object.get( + 'wiredDataCollection') + new_object_params['wirelessTelemetry'] = self.new_object.get( + 'wirelessTelemetry') new_object_params['snmpTraps'] = self.new_object.get('snmpTraps') new_object_params['syslogs'] = self.new_object.get('syslogs') - new_object_params['applicationVisibility'] = self.new_object.get('applicationVisibility') + new_object_params['applicationVisibility'] = self.new_object.get( + 'applicationVisibility') new_object_params['id'] = self.new_object.get('id') return new_object_params @@ -113,7 +116,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -152,7 +156,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -198,7 +203,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sites_telemetry_settings_v1_info.py b/plugins/action/sites_telemetry_settings_v1_info.py index 2cd75d9795..e84f24ca1e 100644 --- a/plugins/action/sites_telemetry_settings_v1_info.py +++ b/plugins/action/sites_telemetry_settings_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sites_time_zone_settings.py b/plugins/action/sites_time_zone_settings.py index 776547912b..c720021af5 100644 --- a/plugins/action/sites_time_zone_settings.py +++ b/plugins/action/sites_time_zone_settings.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_time_zone_settings_info.py b/plugins/action/sites_time_zone_settings_info.py index 78062d348c..61e3d257c4 100644 --- a/plugins/action/sites_time_zone_settings_info.py +++ b/plugins/action/sites_time_zone_settings_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_time_zone_settings_v1.py b/plugins/action/sites_time_zone_settings_v1.py index 5c5c3b22b4..09bec50353 100644 --- a/plugins/action/sites_time_zone_settings_v1.py +++ b/plugins/action/sites_time_zone_settings_v1.py @@ -101,7 +101,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -136,7 +137,8 @@ def update(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -182,7 +184,8 @@ def run(self, tmp=None, task_vars=None): response = prev_obj dnac.object_already_present() else: - dnac.fail_json("Object does not exists, plugin only has update") + dnac.fail_json( + "Object does not exists, plugin only has update") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) diff --git a/plugins/action/sites_time_zone_settings_v1_info.py b/plugins/action/sites_time_zone_settings_v1_info.py index 5ab604a68e..981199e735 100644 --- a/plugins/action/sites_time_zone_settings_v1_info.py +++ b/plugins/action/sites_time_zone_settings_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sites_v1_info.py b/plugins/action/sites_v1_info.py index d6a1604d20..60ce58338b 100644 --- a/plugins/action/sites_v1_info.py +++ b/plugins/action/sites_v1_info.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sites_wireless_settings_ssids.py b/plugins/action/sites_wireless_settings_ssids.py index be5fa068bb..889c68e471 100644 --- a/plugins/action/sites_wireless_settings_ssids.py +++ b/plugins/action/sites_wireless_settings_ssids.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_wireless_settings_ssids_count_info.py b/plugins/action/sites_wireless_settings_ssids_count_info.py index b31f170ce6..c103a3810c 100644 --- a/plugins/action/sites_wireless_settings_ssids_count_info.py +++ b/plugins/action/sites_wireless_settings_ssids_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_wireless_settings_ssids_count_v1_info.py b/plugins/action/sites_wireless_settings_ssids_count_v1_info.py index f33c1f3571..ca44f301d9 100644 --- a/plugins/action/sites_wireless_settings_ssids_count_v1_info.py +++ b/plugins/action/sites_wireless_settings_ssids_count_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sites_wireless_settings_ssids_info.py b/plugins/action/sites_wireless_settings_ssids_info.py index 2291dc2e6b..40c41eb9e8 100644 --- a/plugins/action/sites_wireless_settings_ssids_info.py +++ b/plugins/action/sites_wireless_settings_ssids_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sites_wireless_settings_ssids_v1.py b/plugins/action/sites_wireless_settings_ssids_v1.py index 1e91e0d207..6e2026e8e2 100644 --- a/plugins/action/sites_wireless_settings_ssids_v1.py +++ b/plugins/action/sites_wireless_settings_ssids_v1.py @@ -126,15 +126,20 @@ def __init__(self, params, dnac): sessionTimeOut=params.get("sessionTimeOut"), clientExclusionEnable=params.get("clientExclusionEnable"), clientExclusionTimeout=params.get("clientExclusionTimeout"), - basicServiceSetMaxIdleEnable=params.get("basicServiceSetMaxIdleEnable"), - basicServiceSetClientIdleTimeout=params.get("basicServiceSetClientIdleTimeout"), - directedMulticastServiceEnable=params.get("directedMulticastServiceEnable"), + basicServiceSetMaxIdleEnable=params.get( + "basicServiceSetMaxIdleEnable"), + basicServiceSetClientIdleTimeout=params.get( + "basicServiceSetClientIdleTimeout"), + directedMulticastServiceEnable=params.get( + "directedMulticastServiceEnable"), neighborListEnable=params.get("neighborListEnable"), - managementFrameProtectionClientprotection=params.get("managementFrameProtectionClientprotection"), + managementFrameProtectionClientprotection=params.get( + "managementFrameProtectionClientprotection"), nasOptions=params.get("nasOptions"), profileName=params.get("profileName"), aaaOverride=params.get("aaaOverride"), - coverageHoleDetectionEnable=params.get("coverageHoleDetectionEnable"), + coverageHoleDetectionEnable=params.get( + "coverageHoleDetectionEnable"), protectedManagementFrame=params.get("protectedManagementFrame"), multiPSKSettings=params.get("multiPSKSettings"), clientRateLimit=params.get("clientRateLimit"), @@ -173,13 +178,15 @@ def __init__(self, params, dnac): isAuthKeySuiteB1921x=params.get("isAuthKeySuiteB1921x"), isAuthKeySaeExt=params.get("isAuthKeySaeExt"), isAuthKeySaeExtPlusFT=params.get("isAuthKeySaeExtPlusFT"), - isApBeaconProtectionEnabled=params.get("isApBeaconProtectionEnabled"), + isApBeaconProtectionEnabled=params.get( + "isApBeaconProtectionEnabled"), ghz24Policy=params.get("ghz24Policy"), cckmTsfTolerance=params.get("cckmTsfTolerance"), isCckmEnabled=params.get("isCckmEnabled"), isHex=params.get("isHex"), isRandomMacFilterEnabled=params.get("isRandomMacFilterEnabled"), - fastTransitionOverTheDistributedSystemEnable=params.get("fastTransitionOverTheDistributedSystemEnable"), + fastTransitionOverTheDistributedSystemEnable=params.get( + "fastTransitionOverTheDistributedSystemEnable"), site_id=params.get("siteId"), id=params.get("id"), ) @@ -197,44 +204,75 @@ def create_params(self): new_object_params['ssid'] = self.new_object.get('ssid') new_object_params['authType'] = self.new_object.get('authType') new_object_params['passphrase'] = self.new_object.get('passphrase') - new_object_params['isFastLaneEnabled'] = self.new_object.get('isFastLaneEnabled') - new_object_params['isMacFilteringEnabled'] = self.new_object.get('isMacFilteringEnabled') - new_object_params['ssidRadioType'] = self.new_object.get('ssidRadioType') - new_object_params['isBroadcastSSID'] = self.new_object.get('isBroadcastSSID') - new_object_params['fastTransition'] = self.new_object.get('fastTransition') - new_object_params['sessionTimeOutEnable'] = self.new_object.get('sessionTimeOutEnable') - new_object_params['sessionTimeOut'] = self.new_object.get('sessionTimeOut') - new_object_params['clientExclusionEnable'] = self.new_object.get('clientExclusionEnable') - new_object_params['clientExclusionTimeout'] = self.new_object.get('clientExclusionTimeout') - new_object_params['basicServiceSetMaxIdleEnable'] = self.new_object.get('basicServiceSetMaxIdleEnable') - new_object_params['basicServiceSetClientIdleTimeout'] = self.new_object.get('basicServiceSetClientIdleTimeout') - new_object_params['directedMulticastServiceEnable'] = self.new_object.get('directedMulticastServiceEnable') - new_object_params['neighborListEnable'] = self.new_object.get('neighborListEnable') - new_object_params['managementFrameProtectionClientprotection'] = self.new_object.get('managementFrameProtectionClientprotection') + new_object_params['isFastLaneEnabled'] = self.new_object.get( + 'isFastLaneEnabled') + new_object_params['isMacFilteringEnabled'] = self.new_object.get( + 'isMacFilteringEnabled') + new_object_params['ssidRadioType'] = self.new_object.get( + 'ssidRadioType') + new_object_params['isBroadcastSSID'] = self.new_object.get( + 'isBroadcastSSID') + new_object_params['fastTransition'] = self.new_object.get( + 'fastTransition') + new_object_params['sessionTimeOutEnable'] = self.new_object.get( + 'sessionTimeOutEnable') + new_object_params['sessionTimeOut'] = self.new_object.get( + 'sessionTimeOut') + new_object_params['clientExclusionEnable'] = self.new_object.get( + 'clientExclusionEnable') + new_object_params['clientExclusionTimeout'] = self.new_object.get( + 'clientExclusionTimeout') + new_object_params['basicServiceSetMaxIdleEnable'] = self.new_object.get( + 'basicServiceSetMaxIdleEnable') + new_object_params['basicServiceSetClientIdleTimeout'] = self.new_object.get( + 'basicServiceSetClientIdleTimeout') + new_object_params['directedMulticastServiceEnable'] = self.new_object.get( + 'directedMulticastServiceEnable') + new_object_params['neighborListEnable'] = self.new_object.get( + 'neighborListEnable') + new_object_params['managementFrameProtectionClientprotection'] = self.new_object.get( + 'managementFrameProtectionClientprotection') new_object_params['nasOptions'] = self.new_object.get('nasOptions') new_object_params['profileName'] = self.new_object.get('profileName') new_object_params['aaaOverride'] = self.new_object.get('aaaOverride') - new_object_params['coverageHoleDetectionEnable'] = self.new_object.get('coverageHoleDetectionEnable') - new_object_params['protectedManagementFrame'] = self.new_object.get('protectedManagementFrame') - new_object_params['multiPSKSettings'] = self.new_object.get('multiPSKSettings') - new_object_params['clientRateLimit'] = self.new_object.get('clientRateLimit') - new_object_params['rsnCipherSuiteGcmp256'] = self.new_object.get('rsnCipherSuiteGcmp256') - new_object_params['rsnCipherSuiteCcmp256'] = self.new_object.get('rsnCipherSuiteCcmp256') - new_object_params['rsnCipherSuiteGcmp128'] = self.new_object.get('rsnCipherSuiteGcmp128') - new_object_params['rsnCipherSuiteCcmp128'] = self.new_object.get('rsnCipherSuiteCcmp128') - new_object_params['ghz6PolicyClientSteering'] = self.new_object.get('ghz6PolicyClientSteering') - new_object_params['isAuthKey8021x'] = self.new_object.get('isAuthKey8021x') - new_object_params['isAuthKey8021xPlusFT'] = self.new_object.get('isAuthKey8021xPlusFT') - new_object_params['isAuthKey8021x_SHA256'] = self.new_object.get('isAuthKey8021x_SHA256') + new_object_params['coverageHoleDetectionEnable'] = self.new_object.get( + 'coverageHoleDetectionEnable') + new_object_params['protectedManagementFrame'] = self.new_object.get( + 'protectedManagementFrame') + new_object_params['multiPSKSettings'] = self.new_object.get( + 'multiPSKSettings') + new_object_params['clientRateLimit'] = self.new_object.get( + 'clientRateLimit') + new_object_params['rsnCipherSuiteGcmp256'] = self.new_object.get( + 'rsnCipherSuiteGcmp256') + new_object_params['rsnCipherSuiteCcmp256'] = self.new_object.get( + 'rsnCipherSuiteCcmp256') + new_object_params['rsnCipherSuiteGcmp128'] = self.new_object.get( + 'rsnCipherSuiteGcmp128') + new_object_params['rsnCipherSuiteCcmp128'] = self.new_object.get( + 'rsnCipherSuiteCcmp128') + new_object_params['ghz6PolicyClientSteering'] = self.new_object.get( + 'ghz6PolicyClientSteering') + new_object_params['isAuthKey8021x'] = self.new_object.get( + 'isAuthKey8021x') + new_object_params['isAuthKey8021xPlusFT'] = self.new_object.get( + 'isAuthKey8021xPlusFT') + new_object_params['isAuthKey8021x_SHA256'] = self.new_object.get( + 'isAuthKey8021x_SHA256') new_object_params['isAuthKeySae'] = self.new_object.get('isAuthKeySae') - new_object_params['isAuthKeySaePlusFT'] = self.new_object.get('isAuthKeySaePlusFT') + new_object_params['isAuthKeySaePlusFT'] = self.new_object.get( + 'isAuthKeySaePlusFT') new_object_params['isAuthKeyPSK'] = self.new_object.get('isAuthKeyPSK') - new_object_params['isAuthKeyPSKPlusFT'] = self.new_object.get('isAuthKeyPSKPlusFT') + new_object_params['isAuthKeyPSKPlusFT'] = self.new_object.get( + 'isAuthKeyPSKPlusFT') new_object_params['isAuthKeyOWE'] = self.new_object.get('isAuthKeyOWE') - new_object_params['isAuthKeyEasyPSK'] = self.new_object.get('isAuthKeyEasyPSK') - new_object_params['isAuthKeyPSKSHA256'] = self.new_object.get('isAuthKeyPSKSHA256') + new_object_params['isAuthKeyEasyPSK'] = self.new_object.get( + 'isAuthKeyEasyPSK') + new_object_params['isAuthKeyPSKSHA256'] = self.new_object.get( + 'isAuthKeyPSKSHA256') new_object_params['openSsid'] = self.new_object.get('openSsid') - new_object_params['wlanBandSelectEnable'] = self.new_object.get('wlanBandSelectEnable') + new_object_params['wlanBandSelectEnable'] = self.new_object.get( + 'wlanBandSelectEnable') new_object_params['isEnabled'] = self.new_object.get('isEnabled') new_object_params['authServers'] = self.new_object.get('authServers') new_object_params['acctServers'] = self.new_object.get('acctServers') @@ -243,23 +281,37 @@ def create_params(self): new_object_params['wlanType'] = self.new_object.get('wlanType') new_object_params['l3AuthType'] = self.new_object.get('l3AuthType') new_object_params['authServer'] = self.new_object.get('authServer') - new_object_params['externalAuthIpAddress'] = self.new_object.get('externalAuthIpAddress') - new_object_params['webPassthrough'] = self.new_object.get('webPassthrough') - new_object_params['sleepingClientEnable'] = self.new_object.get('sleepingClientEnable') - new_object_params['sleepingClientTimeout'] = self.new_object.get('sleepingClientTimeout') + new_object_params['externalAuthIpAddress'] = self.new_object.get( + 'externalAuthIpAddress') + new_object_params['webPassthrough'] = self.new_object.get( + 'webPassthrough') + new_object_params['sleepingClientEnable'] = self.new_object.get( + 'sleepingClientEnable') + new_object_params['sleepingClientTimeout'] = self.new_object.get( + 'sleepingClientTimeout') new_object_params['aclName'] = self.new_object.get('aclName') - new_object_params['isPosturingEnabled'] = self.new_object.get('isPosturingEnabled') - new_object_params['isAuthKeySuiteB1x'] = self.new_object.get('isAuthKeySuiteB1x') - new_object_params['isAuthKeySuiteB1921x'] = self.new_object.get('isAuthKeySuiteB1921x') - new_object_params['isAuthKeySaeExt'] = self.new_object.get('isAuthKeySaeExt') - new_object_params['isAuthKeySaeExtPlusFT'] = self.new_object.get('isAuthKeySaeExtPlusFT') - new_object_params['isApBeaconProtectionEnabled'] = self.new_object.get('isApBeaconProtectionEnabled') + new_object_params['isPosturingEnabled'] = self.new_object.get( + 'isPosturingEnabled') + new_object_params['isAuthKeySuiteB1x'] = self.new_object.get( + 'isAuthKeySuiteB1x') + new_object_params['isAuthKeySuiteB1921x'] = self.new_object.get( + 'isAuthKeySuiteB1921x') + new_object_params['isAuthKeySaeExt'] = self.new_object.get( + 'isAuthKeySaeExt') + new_object_params['isAuthKeySaeExtPlusFT'] = self.new_object.get( + 'isAuthKeySaeExtPlusFT') + new_object_params['isApBeaconProtectionEnabled'] = self.new_object.get( + 'isApBeaconProtectionEnabled') new_object_params['ghz24Policy'] = self.new_object.get('ghz24Policy') - new_object_params['cckmTsfTolerance'] = self.new_object.get('cckmTsfTolerance') - new_object_params['isCckmEnabled'] = self.new_object.get('isCckmEnabled') + new_object_params['cckmTsfTolerance'] = self.new_object.get( + 'cckmTsfTolerance') + new_object_params['isCckmEnabled'] = self.new_object.get( + 'isCckmEnabled') new_object_params['isHex'] = self.new_object.get('isHex') - new_object_params['isRandomMacFilterEnabled'] = self.new_object.get('isRandomMacFilterEnabled') - new_object_params['fastTransitionOverTheDistributedSystemEnable'] = self.new_object.get('fastTransitionOverTheDistributedSystemEnable') + new_object_params['isRandomMacFilterEnabled'] = self.new_object.get( + 'isRandomMacFilterEnabled') + new_object_params['fastTransitionOverTheDistributedSystemEnable'] = self.new_object.get( + 'fastTransitionOverTheDistributedSystemEnable') new_object_params['siteId'] = self.new_object.get('siteId') return new_object_params @@ -274,44 +326,75 @@ def update_by_id_params(self): new_object_params['ssid'] = self.new_object.get('ssid') new_object_params['authType'] = self.new_object.get('authType') new_object_params['passphrase'] = self.new_object.get('passphrase') - new_object_params['isFastLaneEnabled'] = self.new_object.get('isFastLaneEnabled') - new_object_params['isMacFilteringEnabled'] = self.new_object.get('isMacFilteringEnabled') - new_object_params['ssidRadioType'] = self.new_object.get('ssidRadioType') - new_object_params['isBroadcastSSID'] = self.new_object.get('isBroadcastSSID') - new_object_params['fastTransition'] = self.new_object.get('fastTransition') - new_object_params['sessionTimeOutEnable'] = self.new_object.get('sessionTimeOutEnable') - new_object_params['sessionTimeOut'] = self.new_object.get('sessionTimeOut') - new_object_params['clientExclusionEnable'] = self.new_object.get('clientExclusionEnable') - new_object_params['clientExclusionTimeout'] = self.new_object.get('clientExclusionTimeout') - new_object_params['basicServiceSetMaxIdleEnable'] = self.new_object.get('basicServiceSetMaxIdleEnable') - new_object_params['basicServiceSetClientIdleTimeout'] = self.new_object.get('basicServiceSetClientIdleTimeout') - new_object_params['directedMulticastServiceEnable'] = self.new_object.get('directedMulticastServiceEnable') - new_object_params['neighborListEnable'] = self.new_object.get('neighborListEnable') - new_object_params['managementFrameProtectionClientprotection'] = self.new_object.get('managementFrameProtectionClientprotection') + new_object_params['isFastLaneEnabled'] = self.new_object.get( + 'isFastLaneEnabled') + new_object_params['isMacFilteringEnabled'] = self.new_object.get( + 'isMacFilteringEnabled') + new_object_params['ssidRadioType'] = self.new_object.get( + 'ssidRadioType') + new_object_params['isBroadcastSSID'] = self.new_object.get( + 'isBroadcastSSID') + new_object_params['fastTransition'] = self.new_object.get( + 'fastTransition') + new_object_params['sessionTimeOutEnable'] = self.new_object.get( + 'sessionTimeOutEnable') + new_object_params['sessionTimeOut'] = self.new_object.get( + 'sessionTimeOut') + new_object_params['clientExclusionEnable'] = self.new_object.get( + 'clientExclusionEnable') + new_object_params['clientExclusionTimeout'] = self.new_object.get( + 'clientExclusionTimeout') + new_object_params['basicServiceSetMaxIdleEnable'] = self.new_object.get( + 'basicServiceSetMaxIdleEnable') + new_object_params['basicServiceSetClientIdleTimeout'] = self.new_object.get( + 'basicServiceSetClientIdleTimeout') + new_object_params['directedMulticastServiceEnable'] = self.new_object.get( + 'directedMulticastServiceEnable') + new_object_params['neighborListEnable'] = self.new_object.get( + 'neighborListEnable') + new_object_params['managementFrameProtectionClientprotection'] = self.new_object.get( + 'managementFrameProtectionClientprotection') new_object_params['nasOptions'] = self.new_object.get('nasOptions') new_object_params['profileName'] = self.new_object.get('profileName') new_object_params['aaaOverride'] = self.new_object.get('aaaOverride') - new_object_params['coverageHoleDetectionEnable'] = self.new_object.get('coverageHoleDetectionEnable') - new_object_params['protectedManagementFrame'] = self.new_object.get('protectedManagementFrame') - new_object_params['multiPSKSettings'] = self.new_object.get('multiPSKSettings') - new_object_params['clientRateLimit'] = self.new_object.get('clientRateLimit') - new_object_params['rsnCipherSuiteGcmp256'] = self.new_object.get('rsnCipherSuiteGcmp256') - new_object_params['rsnCipherSuiteCcmp256'] = self.new_object.get('rsnCipherSuiteCcmp256') - new_object_params['rsnCipherSuiteGcmp128'] = self.new_object.get('rsnCipherSuiteGcmp128') - new_object_params['rsnCipherSuiteCcmp128'] = self.new_object.get('rsnCipherSuiteCcmp128') - new_object_params['ghz6PolicyClientSteering'] = self.new_object.get('ghz6PolicyClientSteering') - new_object_params['isAuthKey8021x'] = self.new_object.get('isAuthKey8021x') - new_object_params['isAuthKey8021xPlusFT'] = self.new_object.get('isAuthKey8021xPlusFT') - new_object_params['isAuthKey8021x_SHA256'] = self.new_object.get('isAuthKey8021x_SHA256') + new_object_params['coverageHoleDetectionEnable'] = self.new_object.get( + 'coverageHoleDetectionEnable') + new_object_params['protectedManagementFrame'] = self.new_object.get( + 'protectedManagementFrame') + new_object_params['multiPSKSettings'] = self.new_object.get( + 'multiPSKSettings') + new_object_params['clientRateLimit'] = self.new_object.get( + 'clientRateLimit') + new_object_params['rsnCipherSuiteGcmp256'] = self.new_object.get( + 'rsnCipherSuiteGcmp256') + new_object_params['rsnCipherSuiteCcmp256'] = self.new_object.get( + 'rsnCipherSuiteCcmp256') + new_object_params['rsnCipherSuiteGcmp128'] = self.new_object.get( + 'rsnCipherSuiteGcmp128') + new_object_params['rsnCipherSuiteCcmp128'] = self.new_object.get( + 'rsnCipherSuiteCcmp128') + new_object_params['ghz6PolicyClientSteering'] = self.new_object.get( + 'ghz6PolicyClientSteering') + new_object_params['isAuthKey8021x'] = self.new_object.get( + 'isAuthKey8021x') + new_object_params['isAuthKey8021xPlusFT'] = self.new_object.get( + 'isAuthKey8021xPlusFT') + new_object_params['isAuthKey8021x_SHA256'] = self.new_object.get( + 'isAuthKey8021x_SHA256') new_object_params['isAuthKeySae'] = self.new_object.get('isAuthKeySae') - new_object_params['isAuthKeySaePlusFT'] = self.new_object.get('isAuthKeySaePlusFT') + new_object_params['isAuthKeySaePlusFT'] = self.new_object.get( + 'isAuthKeySaePlusFT') new_object_params['isAuthKeyPSK'] = self.new_object.get('isAuthKeyPSK') - new_object_params['isAuthKeyPSKPlusFT'] = self.new_object.get('isAuthKeyPSKPlusFT') + new_object_params['isAuthKeyPSKPlusFT'] = self.new_object.get( + 'isAuthKeyPSKPlusFT') new_object_params['isAuthKeyOWE'] = self.new_object.get('isAuthKeyOWE') - new_object_params['isAuthKeyEasyPSK'] = self.new_object.get('isAuthKeyEasyPSK') - new_object_params['isAuthKeyPSKSHA256'] = self.new_object.get('isAuthKeyPSKSHA256') + new_object_params['isAuthKeyEasyPSK'] = self.new_object.get( + 'isAuthKeyEasyPSK') + new_object_params['isAuthKeyPSKSHA256'] = self.new_object.get( + 'isAuthKeyPSKSHA256') new_object_params['openSsid'] = self.new_object.get('openSsid') - new_object_params['wlanBandSelectEnable'] = self.new_object.get('wlanBandSelectEnable') + new_object_params['wlanBandSelectEnable'] = self.new_object.get( + 'wlanBandSelectEnable') new_object_params['isEnabled'] = self.new_object.get('isEnabled') new_object_params['authServers'] = self.new_object.get('authServers') new_object_params['acctServers'] = self.new_object.get('acctServers') @@ -320,23 +403,37 @@ def update_by_id_params(self): new_object_params['wlanType'] = self.new_object.get('wlanType') new_object_params['l3AuthType'] = self.new_object.get('l3AuthType') new_object_params['authServer'] = self.new_object.get('authServer') - new_object_params['externalAuthIpAddress'] = self.new_object.get('externalAuthIpAddress') - new_object_params['webPassthrough'] = self.new_object.get('webPassthrough') - new_object_params['sleepingClientEnable'] = self.new_object.get('sleepingClientEnable') - new_object_params['sleepingClientTimeout'] = self.new_object.get('sleepingClientTimeout') + new_object_params['externalAuthIpAddress'] = self.new_object.get( + 'externalAuthIpAddress') + new_object_params['webPassthrough'] = self.new_object.get( + 'webPassthrough') + new_object_params['sleepingClientEnable'] = self.new_object.get( + 'sleepingClientEnable') + new_object_params['sleepingClientTimeout'] = self.new_object.get( + 'sleepingClientTimeout') new_object_params['aclName'] = self.new_object.get('aclName') - new_object_params['isPosturingEnabled'] = self.new_object.get('isPosturingEnabled') - new_object_params['isAuthKeySuiteB1x'] = self.new_object.get('isAuthKeySuiteB1x') - new_object_params['isAuthKeySuiteB1921x'] = self.new_object.get('isAuthKeySuiteB1921x') - new_object_params['isAuthKeySaeExt'] = self.new_object.get('isAuthKeySaeExt') - new_object_params['isAuthKeySaeExtPlusFT'] = self.new_object.get('isAuthKeySaeExtPlusFT') - new_object_params['isApBeaconProtectionEnabled'] = self.new_object.get('isApBeaconProtectionEnabled') + new_object_params['isPosturingEnabled'] = self.new_object.get( + 'isPosturingEnabled') + new_object_params['isAuthKeySuiteB1x'] = self.new_object.get( + 'isAuthKeySuiteB1x') + new_object_params['isAuthKeySuiteB1921x'] = self.new_object.get( + 'isAuthKeySuiteB1921x') + new_object_params['isAuthKeySaeExt'] = self.new_object.get( + 'isAuthKeySaeExt') + new_object_params['isAuthKeySaeExtPlusFT'] = self.new_object.get( + 'isAuthKeySaeExtPlusFT') + new_object_params['isApBeaconProtectionEnabled'] = self.new_object.get( + 'isApBeaconProtectionEnabled') new_object_params['ghz24Policy'] = self.new_object.get('ghz24Policy') - new_object_params['cckmTsfTolerance'] = self.new_object.get('cckmTsfTolerance') - new_object_params['isCckmEnabled'] = self.new_object.get('isCckmEnabled') + new_object_params['cckmTsfTolerance'] = self.new_object.get( + 'cckmTsfTolerance') + new_object_params['isCckmEnabled'] = self.new_object.get( + 'isCckmEnabled') new_object_params['isHex'] = self.new_object.get('isHex') - new_object_params['isRandomMacFilterEnabled'] = self.new_object.get('isRandomMacFilterEnabled') - new_object_params['fastTransitionOverTheDistributedSystemEnable'] = self.new_object.get('fastTransitionOverTheDistributedSystemEnable') + new_object_params['isRandomMacFilterEnabled'] = self.new_object.get( + 'isRandomMacFilterEnabled') + new_object_params['fastTransitionOverTheDistributedSystemEnable'] = self.new_object.get( + 'fastTransitionOverTheDistributedSystemEnable') new_object_params['siteId'] = self.new_object.get('siteId') new_object_params['id'] = self.new_object.get('id') return new_object_params @@ -389,7 +486,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) if _id: @@ -414,10 +512,12 @@ def requires_update(self, current_obj): ("clientExclusionEnable", "clientExclusionEnable"), ("clientExclusionTimeout", "clientExclusionTimeout"), ("basicServiceSetMaxIdleEnable", "basicServiceSetMaxIdleEnable"), - ("basicServiceSetClientIdleTimeout", "basicServiceSetClientIdleTimeout"), + ("basicServiceSetClientIdleTimeout", + "basicServiceSetClientIdleTimeout"), ("directedMulticastServiceEnable", "directedMulticastServiceEnable"), ("neighborListEnable", "neighborListEnable"), - ("managementFrameProtectionClientprotection", "managementFrameProtectionClientprotection"), + ("managementFrameProtectionClientprotection", + "managementFrameProtectionClientprotection"), ("nasOptions", "nasOptions"), ("profileName", "profileName"), ("aaaOverride", "aaaOverride"), @@ -466,7 +566,8 @@ def requires_update(self, current_obj): ("isCckmEnabled", "isCckmEnabled"), ("isHex", "isHex"), ("isRandomMacFilterEnabled", "isRandomMacFilterEnabled"), - ("fastTransitionOverTheDistributedSystemEnable", "fastTransitionOverTheDistributedSystemEnable"), + ("fastTransitionOverTheDistributedSystemEnable", + "fastTransitionOverTheDistributedSystemEnable"), ("siteId", "site_id"), ("id", "id"), ] @@ -526,7 +627,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/sites_wireless_settings_ssids_v1_info.py b/plugins/action/sites_wireless_settings_ssids_v1_info.py index d4672288fc..743a11b565 100644 --- a/plugins/action/sites_wireless_settings_ssids_v1_info.py +++ b/plugins/action/sites_wireless_settings_ssids_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/snmp_properties.py b/plugins/action/snmp_properties.py index 198ae92413..fc1612a95c 100644 --- a/plugins/action/snmp_properties.py +++ b/plugins/action/snmp_properties.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/snmp_properties_info.py b/plugins/action/snmp_properties_info.py index 659301b686..d949ec116e 100644 --- a/plugins/action/snmp_properties_info.py +++ b/plugins/action/snmp_properties_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/snmp_properties_v1.py b/plugins/action/snmp_properties_v1.py index 70804c5828..9141c53ab3 100644 --- a/plugins/action/snmp_properties_v1.py +++ b/plugins/action/snmp_properties_v1.py @@ -98,7 +98,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -135,7 +136,8 @@ def create(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/snmp_properties_v1_info.py b/plugins/action/snmp_properties_v1_info.py index c60a6db8a8..40777c180b 100644 --- a/plugins/action/snmp_properties_v1_info.py +++ b/plugins/action/snmp_properties_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/sp_profile_delete.py b/plugins/action/sp_profile_delete.py index 5e6ec803f8..f67f2eea5b 100644 --- a/plugins/action/sp_profile_delete.py +++ b/plugins/action/sp_profile_delete.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/sp_profile_delete_v2.py b/plugins/action/sp_profile_delete_v2.py index 52219be6a4..a90a65b611 100644 --- a/plugins/action/sp_profile_delete_v2.py +++ b/plugins/action/sp_profile_delete_v2.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/swim_image_details_info.py b/plugins/action/swim_image_details_info.py index eaf2f3c6ab..ef9eb01a23 100644 --- a/plugins/action/swim_image_details_info.py +++ b/plugins/action/swim_image_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/swim_image_details_v1_info.py b/plugins/action/swim_image_details_v1_info.py index 8f454ffc5f..8ea0e1f8ad 100644 --- a/plugins/action/swim_image_details_v1_info.py +++ b/plugins/action/swim_image_details_v1_info.py @@ -55,7 +55,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/swim_import_local.py b/plugins/action/swim_import_local.py index bcb15c69b1..f9c7b8bca3 100644 --- a/plugins/action/swim_import_local.py +++ b/plugins/action/swim_import_local.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/swim_import_local_v1.py b/plugins/action/swim_import_local_v1.py index 173448b698..3406c31f1f 100644 --- a/plugins/action/swim_import_local_v1.py +++ b/plugins/action/swim_import_local_v1.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -69,7 +70,8 @@ def get_object(self, params): is_third_party=params.get("isThirdParty"), third_party_vendor=params.get("thirdPartyVendor"), third_party_image_family=params.get("thirdPartyImageFamily"), - third_party_application_type=params.get("thirdPartyApplicationType"), + third_party_application_type=params.get( + "thirdPartyApplicationType"), ) return new_object diff --git a/plugins/action/swim_import_via_url.py b/plugins/action/swim_import_via_url.py index 7bec3aa9ae..c64b5449be 100644 --- a/plugins/action/swim_import_via_url.py +++ b/plugins/action/swim_import_via_url.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/swim_import_via_url_v1.py b/plugins/action/swim_import_via_url_v1.py index c575cc2ea7..5ecd2f2e6c 100644 --- a/plugins/action/swim_import_via_url_v1.py +++ b/plugins/action/swim_import_via_url_v1.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/swim_trigger_activation.py b/plugins/action/swim_trigger_activation.py index f1878cce4a..c208e1f9d1 100644 --- a/plugins/action/swim_trigger_activation.py +++ b/plugins/action/swim_trigger_activation.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/swim_trigger_activation_v1.py b/plugins/action/swim_trigger_activation_v1.py index d49d3eaacf..913030e975 100644 --- a/plugins/action/swim_trigger_activation_v1.py +++ b/plugins/action/swim_trigger_activation_v1.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/swim_trigger_distribution.py b/plugins/action/swim_trigger_distribution.py index f594563977..50641cb06c 100644 --- a/plugins/action/swim_trigger_distribution.py +++ b/plugins/action/swim_trigger_distribution.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/swim_trigger_distribution_v1.py b/plugins/action/swim_trigger_distribution_v1.py index 25569ac7ab..b524843162 100644 --- a/plugins/action/swim_trigger_distribution_v1.py +++ b/plugins/action/swim_trigger_distribution_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/system_health_count_info.py b/plugins/action/system_health_count_info.py index 07c3e6d45b..70a645e56b 100644 --- a/plugins/action/system_health_count_info.py +++ b/plugins/action/system_health_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/system_health_count_v1_info.py b/plugins/action/system_health_count_v1_info.py index 58b74f6caa..d10d50ff43 100644 --- a/plugins/action/system_health_count_v1_info.py +++ b/plugins/action/system_health_count_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/system_health_info.py b/plugins/action/system_health_info.py index 14e52ac9b1..e81a48c12d 100644 --- a/plugins/action/system_health_info.py +++ b/plugins/action/system_health_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/system_health_v1_info.py b/plugins/action/system_health_v1_info.py index 6c97265c28..bf18a7782f 100644 --- a/plugins/action/system_health_v1_info.py +++ b/plugins/action/system_health_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/system_issue_definitions.py b/plugins/action/system_issue_definitions.py index 80731e7477..39516127bb 100644 --- a/plugins/action/system_issue_definitions.py +++ b/plugins/action/system_issue_definitions.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/system_issue_definitions_count.py b/plugins/action/system_issue_definitions_count.py index 148d518596..b1dca2bd74 100644 --- a/plugins/action/system_issue_definitions_count.py +++ b/plugins/action/system_issue_definitions_count.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/system_issue_definitions_count_info.py b/plugins/action/system_issue_definitions_count_info.py index c27b80bb42..fdf5520d7d 100644 --- a/plugins/action/system_issue_definitions_count_info.py +++ b/plugins/action/system_issue_definitions_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/system_issue_definitions_count_v1.py b/plugins/action/system_issue_definitions_count_v1.py index 357a60c2ed..dd2ed107bf 100644 --- a/plugins/action/system_issue_definitions_count_v1.py +++ b/plugins/action/system_issue_definitions_count_v1.py @@ -96,7 +96,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -117,7 +118,8 @@ def requires_update(self, current_obj): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/system_issue_definitions_count_v1_info.py b/plugins/action/system_issue_definitions_count_v1_info.py index 88fc49204c..daa67610c4 100644 --- a/plugins/action/system_issue_definitions_count_v1_info.py +++ b/plugins/action/system_issue_definitions_count_v1_info.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/system_issue_definitions_info.py b/plugins/action/system_issue_definitions_info.py index 378864644b..3b2204b485 100644 --- a/plugins/action/system_issue_definitions_info.py +++ b/plugins/action/system_issue_definitions_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/system_issue_definitions_v1.py b/plugins/action/system_issue_definitions_v1.py index 0e826935ef..45d83dffe4 100644 --- a/plugins/action/system_issue_definitions_v1.py +++ b/plugins/action/system_issue_definitions_v1.py @@ -50,7 +50,8 @@ class SystemIssueDefinitionsV1(object): def __init__(self, params, dnac): self.dnac = dnac self.new_object = dict( - synchronizeToHealthThreshold=params.get("synchronizeToHealthThreshold"), + synchronizeToHealthThreshold=params.get( + "synchronizeToHealthThreshold"), priority=params.get("priority"), issueEnabled=params.get("issueEnabled"), thresholdValue=params.get("thresholdValue"), @@ -124,7 +125,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) if _id: @@ -152,7 +154,8 @@ def requires_update(self, current_obj): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/system_issue_definitions_v1_info.py b/plugins/action/system_issue_definitions_v1_info.py index c4b74a5003..0aa8be6e59 100644 --- a/plugins/action/system_issue_definitions_v1_info.py +++ b/plugins/action/system_issue_definitions_v1_info.py @@ -52,7 +52,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -90,7 +91,8 @@ def get_object(self, params): sort_by=params.get("sortBy"), order=params.get("order"), headers=params.get("headers"), - synchronizeToHealthThreshold=params.get("synchronizeToHealthThreshold"), + synchronizeToHealthThreshold=params.get( + "synchronizeToHealthThreshold"), priority=params.get("priority"), issueEnabled=params.get("issueEnabled"), thresholdValue=params.get("thresholdValue"), diff --git a/plugins/action/system_performance_historical_info.py b/plugins/action/system_performance_historical_info.py index 3191468b96..1a0848cd46 100644 --- a/plugins/action/system_performance_historical_info.py +++ b/plugins/action/system_performance_historical_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/system_performance_historical_v1_info.py b/plugins/action/system_performance_historical_v1_info.py index 27eab29637..4b271fb4d1 100644 --- a/plugins/action/system_performance_historical_v1_info.py +++ b/plugins/action/system_performance_historical_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/system_performance_info.py b/plugins/action/system_performance_info.py index dca166056b..25f36e27fd 100644 --- a/plugins/action/system_performance_info.py +++ b/plugins/action/system_performance_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/system_performance_v1_info.py b/plugins/action/system_performance_v1_info.py index 3535f9fb6b..6aeb16b1eb 100644 --- a/plugins/action/system_performance_v1_info.py +++ b/plugins/action/system_performance_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/tag.py b/plugins/action/tag.py index 7551ece4ab..a8c9d7e2c9 100644 --- a/plugins/action/tag.py +++ b/plugins/action/tag.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/tag_count_info.py b/plugins/action/tag_count_info.py index 20c386b596..d3d2b40599 100644 --- a/plugins/action/tag_count_info.py +++ b/plugins/action/tag_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/tag_count_v1_info.py b/plugins/action/tag_count_v1_info.py index 9c1a7a85b4..046203ae5c 100644 --- a/plugins/action/tag_count_v1_info.py +++ b/plugins/action/tag_count_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/tag_info.py b/plugins/action/tag_info.py index 1429debfe7..fbf440b855 100644 --- a/plugins/action/tag_info.py +++ b/plugins/action/tag_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/tag_member.py b/plugins/action/tag_member.py index cbf75d2624..76211620ea 100644 --- a/plugins/action/tag_member.py +++ b/plugins/action/tag_member.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/tag_member_count_info.py b/plugins/action/tag_member_count_info.py index e2ce516563..b03f58de40 100644 --- a/plugins/action/tag_member_count_info.py +++ b/plugins/action/tag_member_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/tag_member_count_v1_info.py b/plugins/action/tag_member_count_v1_info.py index 4a35a92150..679e168364 100644 --- a/plugins/action/tag_member_count_v1_info.py +++ b/plugins/action/tag_member_count_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/tag_member_info.py b/plugins/action/tag_member_info.py index ac821abaf4..c3b515f72d 100644 --- a/plugins/action/tag_member_info.py +++ b/plugins/action/tag_member_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/tag_member_type_info.py b/plugins/action/tag_member_type_info.py index aea9e6ae0c..9dd6bed26a 100644 --- a/plugins/action/tag_member_type_info.py +++ b/plugins/action/tag_member_type_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/tag_member_type_v1_info.py b/plugins/action/tag_member_type_v1_info.py index cba954c243..010af1559e 100644 --- a/plugins/action/tag_member_type_v1_info.py +++ b/plugins/action/tag_member_type_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/tag_member_v1.py b/plugins/action/tag_member_v1.py index 77e8bc42e5..cff12e0b1e 100644 --- a/plugins/action/tag_member_v1.py +++ b/plugins/action/tag_member_v1.py @@ -117,7 +117,8 @@ def exists(self): _id = prev_obj.get("id") _id = _id or prev_obj.get("memberId") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) self.new_object.update(dict(member_id=_id)) @@ -171,7 +172,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/tag_member_v1_info.py b/plugins/action/tag_member_v1_info.py index 037b658036..6573c34368 100644 --- a/plugins/action/tag_member_v1_info.py +++ b/plugins/action/tag_member_v1_info.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/tag_membership.py b/plugins/action/tag_membership.py index 7ea1cf0e09..39e22c2daa 100644 --- a/plugins/action/tag_membership.py +++ b/plugins/action/tag_membership.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/tag_membership_v1.py b/plugins/action/tag_membership_v1.py index 661aa77406..7f3edf2910 100644 --- a/plugins/action/tag_membership_v1.py +++ b/plugins/action/tag_membership_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/tag_v1.py b/plugins/action/tag_v1.py index e359b63f3b..7350c003fd 100644 --- a/plugins/action/tag_v1.py +++ b/plugins/action/tag_v1.py @@ -86,7 +86,8 @@ def create_params(self): new_object_params['dynamicRules'] = self.new_object.get('dynamicRules') new_object_params['name'] = self.new_object.get('name') new_object_params['id'] = self.new_object.get('id') - new_object_params['instanceTenantId'] = self.new_object.get('instanceTenantId') + new_object_params['instanceTenantId'] = self.new_object.get( + 'instanceTenantId') return new_object_params def delete_by_id_params(self): @@ -101,7 +102,8 @@ def update_all_params(self): new_object_params['dynamicRules'] = self.new_object.get('dynamicRules') new_object_params['name'] = self.new_object.get('name') new_object_params['id'] = self.new_object.get('id') - new_object_params['instanceTenantId'] = self.new_object.get('instanceTenantId') + new_object_params['instanceTenantId'] = self.new_object.get( + 'instanceTenantId') return new_object_params def get_object_by_name(self, name): @@ -152,7 +154,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) if _id: @@ -220,7 +223,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/tag_v1_info.py b/plugins/action/tag_v1_info.py index 1362a78e16..65910c2972 100644 --- a/plugins/action/tag_v1_info.py +++ b/plugins/action/tag_v1_info.py @@ -49,7 +49,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/tags_interfaces_members_associations_count_info.py b/plugins/action/tags_interfaces_members_associations_count_info.py index 5467a4b59d..f85ae8a725 100644 --- a/plugins/action/tags_interfaces_members_associations_count_info.py +++ b/plugins/action/tags_interfaces_members_associations_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/tags_interfaces_members_associations_count_v1_info.py b/plugins/action/tags_interfaces_members_associations_count_v1_info.py index e54f225615..f5da22b87f 100644 --- a/plugins/action/tags_interfaces_members_associations_count_v1_info.py +++ b/plugins/action/tags_interfaces_members_associations_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/tags_interfaces_members_associations_info.py b/plugins/action/tags_interfaces_members_associations_info.py index adba50fe39..4bcee7a4cd 100644 --- a/plugins/action/tags_interfaces_members_associations_info.py +++ b/plugins/action/tags_interfaces_members_associations_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/tags_interfaces_members_associations_query.py b/plugins/action/tags_interfaces_members_associations_query.py index 6b6c141155..5cb393267d 100644 --- a/plugins/action/tags_interfaces_members_associations_query.py +++ b/plugins/action/tags_interfaces_members_associations_query.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/tags_interfaces_members_associations_query_v1.py b/plugins/action/tags_interfaces_members_associations_query_v1.py index 933f97ccb2..c9ffedb01c 100644 --- a/plugins/action/tags_interfaces_members_associations_query_v1.py +++ b/plugins/action/tags_interfaces_members_associations_query_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/tags_interfaces_members_associations_v1_info.py b/plugins/action/tags_interfaces_members_associations_v1_info.py index 026965be63..7c8b720a4d 100644 --- a/plugins/action/tags_interfaces_members_associations_v1_info.py +++ b/plugins/action/tags_interfaces_members_associations_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/tags_network_devices_members_associations_count_info.py b/plugins/action/tags_network_devices_members_associations_count_info.py index f4fec3677a..8ee629e506 100644 --- a/plugins/action/tags_network_devices_members_associations_count_info.py +++ b/plugins/action/tags_network_devices_members_associations_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/tags_network_devices_members_associations_count_v1_info.py b/plugins/action/tags_network_devices_members_associations_count_v1_info.py index e6bf2db045..c8d1fc0a57 100644 --- a/plugins/action/tags_network_devices_members_associations_count_v1_info.py +++ b/plugins/action/tags_network_devices_members_associations_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/tags_network_devices_members_associations_info.py b/plugins/action/tags_network_devices_members_associations_info.py index 2c6d78b0f3..5a8e5729c2 100644 --- a/plugins/action/tags_network_devices_members_associations_info.py +++ b/plugins/action/tags_network_devices_members_associations_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/tags_network_devices_members_associations_query.py b/plugins/action/tags_network_devices_members_associations_query.py index d1c33452e0..efaca26fc4 100644 --- a/plugins/action/tags_network_devices_members_associations_query.py +++ b/plugins/action/tags_network_devices_members_associations_query.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/tags_network_devices_members_associations_query_v1.py b/plugins/action/tags_network_devices_members_associations_query_v1.py index d5087024a2..9fdf5e6f33 100644 --- a/plugins/action/tags_network_devices_members_associations_query_v1.py +++ b/plugins/action/tags_network_devices_members_associations_query_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/tags_network_devices_members_associations_v1_info.py b/plugins/action/tags_network_devices_members_associations_v1_info.py index 62a7f04ece..a2d7d41d67 100644 --- a/plugins/action/tags_network_devices_members_associations_v1_info.py +++ b/plugins/action/tags_network_devices_members_associations_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/task_count_info.py b/plugins/action/task_count_info.py index 54af2a88ce..586009dc20 100644 --- a/plugins/action/task_count_info.py +++ b/plugins/action/task_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/task_count_v1_info.py b/plugins/action/task_count_v1_info.py index 04458c4196..efce2f0316 100644 --- a/plugins/action/task_count_v1_info.py +++ b/plugins/action/task_count_v1_info.py @@ -47,7 +47,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/task_info.py b/plugins/action/task_info.py index 2282583afb..76295fbb2f 100644 --- a/plugins/action/task_info.py +++ b/plugins/action/task_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/task_operation_info.py b/plugins/action/task_operation_info.py index 45abfa0e1c..24d0755486 100644 --- a/plugins/action/task_operation_info.py +++ b/plugins/action/task_operation_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/task_operation_v1_info.py b/plugins/action/task_operation_v1_info.py index cd17674cad..6af6838c3f 100644 --- a/plugins/action/task_operation_v1_info.py +++ b/plugins/action/task_operation_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -96,7 +97,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/task_tree_info.py b/plugins/action/task_tree_info.py index 53a4ac4769..8d1cbbd357 100644 --- a/plugins/action/task_tree_info.py +++ b/plugins/action/task_tree_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/task_tree_v1_info.py b/plugins/action/task_tree_v1_info.py index 439a3ad46a..530b172880 100644 --- a/plugins/action/task_tree_v1_info.py +++ b/plugins/action/task_tree_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/task_v1_info.py b/plugins/action/task_v1_info.py index 15809c2df4..98364b1f62 100644 --- a/plugins/action/task_v1_info.py +++ b/plugins/action/task_v1_info.py @@ -52,7 +52,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/tasks_count_info.py b/plugins/action/tasks_count_info.py index ed707b6800..ca593fe939 100644 --- a/plugins/action/tasks_count_info.py +++ b/plugins/action/tasks_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/tasks_count_v1_info.py b/plugins/action/tasks_count_v1_info.py index 4236920bff..fd0e4e8564 100644 --- a/plugins/action/tasks_count_v1_info.py +++ b/plugins/action/tasks_count_v1_info.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/tasks_detail_info.py b/plugins/action/tasks_detail_info.py index c8b955fe97..7dd80ac12d 100644 --- a/plugins/action/tasks_detail_info.py +++ b/plugins/action/tasks_detail_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/tasks_detail_v1_info.py b/plugins/action/tasks_detail_v1_info.py index e0e1d632bf..35d3b0ae81 100644 --- a/plugins/action/tasks_detail_v1_info.py +++ b/plugins/action/tasks_detail_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/tasks_info.py b/plugins/action/tasks_info.py index 3afb7c9f6f..7561352f94 100644 --- a/plugins/action/tasks_info.py +++ b/plugins/action/tasks_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/tasks_v1_info.py b/plugins/action/tasks_v1_info.py index e41da4e635..60410bc404 100644 --- a/plugins/action/tasks_v1_info.py +++ b/plugins/action/tasks_v1_info.py @@ -47,7 +47,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/telemetry_settings_apply.py b/plugins/action/telemetry_settings_apply.py index 0bcdb2c2fe..de9c3ce6c9 100644 --- a/plugins/action/telemetry_settings_apply.py +++ b/plugins/action/telemetry_settings_apply.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/telemetry_settings_apply_v1.py b/plugins/action/telemetry_settings_apply_v1.py index 07e373b2bb..dcfabde2bb 100644 --- a/plugins/action/telemetry_settings_apply_v1.py +++ b/plugins/action/telemetry_settings_apply_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/template_preview.py b/plugins/action/template_preview.py index ce58398142..537a6c9f7c 100644 --- a/plugins/action/template_preview.py +++ b/plugins/action/template_preview.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/template_preview_v1.py b/plugins/action/template_preview_v1.py index 12b294ed1b..081b27440b 100644 --- a/plugins/action/template_preview_v1.py +++ b/plugins/action/template_preview_v1.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/templates_details_info.py b/plugins/action/templates_details_info.py index fa9ba9e5e7..9afb8f1bd0 100644 --- a/plugins/action/templates_details_info.py +++ b/plugins/action/templates_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/templates_details_v2_info.py b/plugins/action/templates_details_v2_info.py index c55e4a90d4..18a901f66b 100644 --- a/plugins/action/templates_details_v2_info.py +++ b/plugins/action/templates_details_v2_info.py @@ -54,7 +54,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -89,7 +90,8 @@ def get_object(self, params): product_family=params.get("productFamily"), product_series=params.get("productSeries"), product_type=params.get("productType"), - filter_conflicting_templates=params.get("filterConflictingTemplates"), + filter_conflicting_templates=params.get( + "filterConflictingTemplates"), tags=params.get("tags"), un_committed=params.get("unCommitted"), sort_order=params.get("sortOrder"), diff --git a/plugins/action/topology_layer_2_info.py b/plugins/action/topology_layer_2_info.py index f4871af753..1dad9afc5e 100644 --- a/plugins/action/topology_layer_2_info.py +++ b/plugins/action/topology_layer_2_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/topology_layer_2_v1_info.py b/plugins/action/topology_layer_2_v1_info.py index c69f7b3c39..1ecc80d642 100644 --- a/plugins/action/topology_layer_2_v1_info.py +++ b/plugins/action/topology_layer_2_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/topology_layer_3_info.py b/plugins/action/topology_layer_3_info.py index f3383655a6..e3bfda11ae 100644 --- a/plugins/action/topology_layer_3_info.py +++ b/plugins/action/topology_layer_3_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/topology_layer_3_v1_info.py b/plugins/action/topology_layer_3_v1_info.py index 10502e95ed..5111378498 100644 --- a/plugins/action/topology_layer_3_v1_info.py +++ b/plugins/action/topology_layer_3_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True @@ -92,7 +93,8 @@ def run(self, tmp=None, task_vars=None): if not id: # NOTE: Does not have a get all method or it is in another action response = None - dnac.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + dnac.object_modify_result( + changed=False, result="Module does not have get all, check arguments of module") self._result.update(dict(dnac_response=response)) self._result.update(dnac.exit_json()) return self._result diff --git a/plugins/action/topology_network_health_info.py b/plugins/action/topology_network_health_info.py index 8a3aa46656..bfb0a3fdf1 100644 --- a/plugins/action/topology_network_health_info.py +++ b/plugins/action/topology_network_health_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/topology_network_health_v1_info.py b/plugins/action/topology_network_health_v1_info.py index 318f8a2363..7477969ad6 100644 --- a/plugins/action/topology_network_health_v1_info.py +++ b/plugins/action/topology_network_health_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/topology_physical_info.py b/plugins/action/topology_physical_info.py index e5cc9d1b8f..e1350a64ce 100644 --- a/plugins/action/topology_physical_info.py +++ b/plugins/action/topology_physical_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/topology_physical_v1_info.py b/plugins/action/topology_physical_v1_info.py index db45b93b05..5a5479fad1 100644 --- a/plugins/action/topology_physical_v1_info.py +++ b/plugins/action/topology_physical_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/topology_site_info.py b/plugins/action/topology_site_info.py index 6d036b91ba..c3afafa5fe 100644 --- a/plugins/action/topology_site_info.py +++ b/plugins/action/topology_site_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/topology_site_v1_info.py b/plugins/action/topology_site_v1_info.py index 4f36aaaf8a..f6c4772022 100644 --- a/plugins/action/topology_site_v1_info.py +++ b/plugins/action/topology_site_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/topology_vlan_details_info.py b/plugins/action/topology_vlan_details_info.py index 5441366668..327b071932 100644 --- a/plugins/action/topology_vlan_details_info.py +++ b/plugins/action/topology_vlan_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/topology_vlan_details_v1_info.py b/plugins/action/topology_vlan_details_v1_info.py index 6a2ad06247..1149fd3744 100644 --- a/plugins/action/topology_vlan_details_v1_info.py +++ b/plugins/action/topology_vlan_details_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/transit_peer_network.py b/plugins/action/transit_peer_network.py index 3f6317d780..f0f692b071 100644 --- a/plugins/action/transit_peer_network.py +++ b/plugins/action/transit_peer_network.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/transit_peer_network_info.py b/plugins/action/transit_peer_network_info.py index 73be252be8..d1ea12c93e 100644 --- a/plugins/action/transit_peer_network_info.py +++ b/plugins/action/transit_peer_network_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/transit_peer_network_v1.py b/plugins/action/transit_peer_network_v1.py index 056913a310..db777f31ce 100644 --- a/plugins/action/transit_peer_network_v1.py +++ b/plugins/action/transit_peer_network_v1.py @@ -63,15 +63,20 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['transitPeerNetworkName'] = self.new_object.get('transitPeerNetworkName') - new_object_params['transitPeerNetworkType'] = self.new_object.get('transitPeerNetworkType') - new_object_params['ipTransitSettings'] = self.new_object.get('ipTransitSettings') - new_object_params['sdaTransitSettings'] = self.new_object.get('sdaTransitSettings') + new_object_params['transitPeerNetworkName'] = self.new_object.get( + 'transitPeerNetworkName') + new_object_params['transitPeerNetworkType'] = self.new_object.get( + 'transitPeerNetworkType') + new_object_params['ipTransitSettings'] = self.new_object.get( + 'ipTransitSettings') + new_object_params['sdaTransitSettings'] = self.new_object.get( + 'sdaTransitSettings') return new_object_params def delete_all_params(self): new_object_params = {} - new_object_params['transit_peer_network_name'] = self.new_object.get('transit_peer_network_name') + new_object_params['transit_peer_network_name'] = self.new_object.get( + 'transit_peer_network_name') return new_object_params def get_object_by_name(self, name): @@ -111,7 +116,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -157,7 +163,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/transit_peer_network_v1_info.py b/plugins/action/transit_peer_network_v1_info.py index 9b8ad23fcf..6412bf0ae3 100644 --- a/plugins/action/transit_peer_network_v1_info.py +++ b/plugins/action/transit_peer_network_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/trusted_certificates_import.py b/plugins/action/trusted_certificates_import.py index cd10c16dc8..f3122bcf37 100644 --- a/plugins/action/trusted_certificates_import.py +++ b/plugins/action/trusted_certificates_import.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/trusted_certificates_import_v1.py b/plugins/action/trusted_certificates_import_v1.py index bb63f6f4ed..f92654748b 100644 --- a/plugins/action/trusted_certificates_import_v1.py +++ b/plugins/action/trusted_certificates_import_v1.py @@ -36,7 +36,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/user.py b/plugins/action/user.py index e23a451cac..518f5b0c12 100644 --- a/plugins/action/user.py +++ b/plugins/action/user.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/user_enrichment_details_info.py b/plugins/action/user_enrichment_details_info.py index f0c485a771..5771958569 100644 --- a/plugins/action/user_enrichment_details_info.py +++ b/plugins/action/user_enrichment_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/user_enrichment_details_v1_info.py b/plugins/action/user_enrichment_details_v1_info.py index b2c930d393..7fb515cef4 100644 --- a/plugins/action/user_enrichment_details_v1_info.py +++ b/plugins/action/user_enrichment_details_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/user_info.py b/plugins/action/user_info.py index 53b931197e..9c0ce03b82 100644 --- a/plugins/action/user_info.py +++ b/plugins/action/user_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/user_v1.py b/plugins/action/user_v1.py index b81e8847df..0193d65f32 100644 --- a/plugins/action/user_v1.py +++ b/plugins/action/user_v1.py @@ -147,7 +147,8 @@ def exists(self): _id = prev_obj.get("id") _id = _id or prev_obj.get("userId") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) self.new_object.update(dict(user_id=_id)) @@ -217,7 +218,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/user_v1_info.py b/plugins/action/user_v1_info.py index e98d26cbdd..1485a73781 100644 --- a/plugins/action/user_v1_info.py +++ b/plugins/action/user_v1_info.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/users_external_authentication.py b/plugins/action/users_external_authentication.py index cc2f6b56e1..ff810bb8a0 100644 --- a/plugins/action/users_external_authentication.py +++ b/plugins/action/users_external_authentication.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/users_external_authentication_info.py b/plugins/action/users_external_authentication_info.py index 12f1ad8f30..6382460392 100644 --- a/plugins/action/users_external_authentication_info.py +++ b/plugins/action/users_external_authentication_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/users_external_authentication_v1.py b/plugins/action/users_external_authentication_v1.py index b860e8242a..c902720571 100644 --- a/plugins/action/users_external_authentication_v1.py +++ b/plugins/action/users_external_authentication_v1.py @@ -94,7 +94,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -125,7 +126,8 @@ def create(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/users_external_authentication_v1_info.py b/plugins/action/users_external_authentication_v1_info.py index 466b7ec56e..2da22eada0 100644 --- a/plugins/action/users_external_authentication_v1_info.py +++ b/plugins/action/users_external_authentication_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/users_external_servers_aaa_attribute.py b/plugins/action/users_external_servers_aaa_attribute.py index dec82552e7..858915bb54 100644 --- a/plugins/action/users_external_servers_aaa_attribute.py +++ b/plugins/action/users_external_servers_aaa_attribute.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/users_external_servers_aaa_attribute_info.py b/plugins/action/users_external_servers_aaa_attribute_info.py index c74df03b85..2bb821bf2f 100644 --- a/plugins/action/users_external_servers_aaa_attribute_info.py +++ b/plugins/action/users_external_servers_aaa_attribute_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/users_external_servers_aaa_attribute_v1.py b/plugins/action/users_external_servers_aaa_attribute_v1.py index 2c5d5c94da..d9308d1b4f 100644 --- a/plugins/action/users_external_servers_aaa_attribute_v1.py +++ b/plugins/action/users_external_servers_aaa_attribute_v1.py @@ -54,7 +54,8 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['attributeName'] = self.new_object.get('attributeName') + new_object_params['attributeName'] = self.new_object.get( + 'attributeName') return new_object_params def delete_all_params(self): @@ -98,7 +99,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -140,7 +142,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/users_external_servers_aaa_attribute_v1_info.py b/plugins/action/users_external_servers_aaa_attribute_v1_info.py index 70e525aeed..48b317c7c4 100644 --- a/plugins/action/users_external_servers_aaa_attribute_v1_info.py +++ b/plugins/action/users_external_servers_aaa_attribute_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/users_external_servers_info.py b/plugins/action/users_external_servers_info.py index 0ad7b2d490..10c96994be 100644 --- a/plugins/action/users_external_servers_info.py +++ b/plugins/action/users_external_servers_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/users_external_servers_v1_info.py b/plugins/action/users_external_servers_v1_info.py index cf442c6541..a587bba889 100644 --- a/plugins/action/users_external_servers_v1_info.py +++ b/plugins/action/users_external_servers_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_accespoint_configuration.py b/plugins/action/wireless_accespoint_configuration.py index 6a219ae2bb..1bdf8800cf 100644 --- a/plugins/action/wireless_accespoint_configuration.py +++ b/plugins/action/wireless_accespoint_configuration.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_accespoint_configuration_v1.py b/plugins/action/wireless_accespoint_configuration_v1.py index 45b2e78225..969122bd1b 100644 --- a/plugins/action/wireless_accespoint_configuration_v1.py +++ b/plugins/action/wireless_accespoint_configuration_v1.py @@ -58,7 +58,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -93,7 +94,8 @@ def get_object(self, params): failoverPriority=params.get("failoverPriority"), configureLedStatus=params.get("configureLedStatus"), ledStatus=params.get("ledStatus"), - configureLedBrightnessLevel=params.get("configureLedBrightnessLevel"), + configureLedBrightnessLevel=params.get( + "configureLedBrightnessLevel"), ledBrightnessLevel=params.get("ledBrightnessLevel"), configureLocation=params.get("configureLocation"), location=params.get("location"), diff --git a/plugins/action/wireless_access_points_factory_reset_request_provision.py b/plugins/action/wireless_access_points_factory_reset_request_provision.py index 617a1d1a31..f758f65303 100644 --- a/plugins/action/wireless_access_points_factory_reset_request_provision.py +++ b/plugins/action/wireless_access_points_factory_reset_request_provision.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_access_points_factory_reset_request_provision_v1.py b/plugins/action/wireless_access_points_factory_reset_request_provision_v1.py index 422994c928..cc410bbdd7 100644 --- a/plugins/action/wireless_access_points_factory_reset_request_provision_v1.py +++ b/plugins/action/wireless_access_points_factory_reset_request_provision_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_access_points_factory_reset_request_status_info.py b/plugins/action/wireless_access_points_factory_reset_request_status_info.py index 875819d63f..f003d94e66 100644 --- a/plugins/action/wireless_access_points_factory_reset_request_status_info.py +++ b/plugins/action/wireless_access_points_factory_reset_request_status_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_access_points_factory_reset_request_status_v1_info.py b/plugins/action/wireless_access_points_factory_reset_request_status_v1_info.py index 5baa45755c..8572f0dfc5 100644 --- a/plugins/action/wireless_access_points_factory_reset_request_status_v1_info.py +++ b/plugins/action/wireless_access_points_factory_reset_request_status_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_access_points_provision.py b/plugins/action/wireless_access_points_provision.py index 37f20f9276..44233c8e32 100644 --- a/plugins/action/wireless_access_points_provision.py +++ b/plugins/action/wireless_access_points_provision.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_access_points_provision_v1.py b/plugins/action/wireless_access_points_provision_v1.py index fde70f4856..5c72b18c7d 100644 --- a/plugins/action/wireless_access_points_provision_v1.py +++ b/plugins/action/wireless_access_points_provision_v1.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_accesspoint_configuration_create.py b/plugins/action/wireless_accesspoint_configuration_create.py index 821632573c..e2fede8889 100644 --- a/plugins/action/wireless_accesspoint_configuration_create.py +++ b/plugins/action/wireless_accesspoint_configuration_create.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_accesspoint_configuration_create_v2.py b/plugins/action/wireless_accesspoint_configuration_create_v2.py index 8778b67576..021fece7d4 100644 --- a/plugins/action/wireless_accesspoint_configuration_create_v2.py +++ b/plugins/action/wireless_accesspoint_configuration_create_v2.py @@ -64,7 +64,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -99,7 +100,8 @@ def get_object(self, params): failoverPriority=params.get("failoverPriority"), configureLedStatus=params.get("configureLedStatus"), ledStatus=params.get("ledStatus"), - configureLedBrightnessLevel=params.get("configureLedBrightnessLevel"), + configureLedBrightnessLevel=params.get( + "configureLedBrightnessLevel"), ledBrightnessLevel=params.get("ledBrightnessLevel"), configureLocation=params.get("configureLocation"), location=params.get("location"), diff --git a/plugins/action/wireless_accesspoint_configuration_summary_info.py b/plugins/action/wireless_accesspoint_configuration_summary_info.py index 5331eccd82..5e4b1a38e6 100644 --- a/plugins/action/wireless_accesspoint_configuration_summary_info.py +++ b/plugins/action/wireless_accesspoint_configuration_summary_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_accesspoint_configuration_summary_v1_info.py b/plugins/action/wireless_accesspoint_configuration_summary_v1_info.py index d825258498..8e760a855e 100644 --- a/plugins/action/wireless_accesspoint_configuration_summary_v1_info.py +++ b/plugins/action/wireless_accesspoint_configuration_summary_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_controllers_anchor_managed_ap_locations_info.py b/plugins/action/wireless_controllers_anchor_managed_ap_locations_info.py index 5902cceefe..a1fc133985 100644 --- a/plugins/action/wireless_controllers_anchor_managed_ap_locations_info.py +++ b/plugins/action/wireless_controllers_anchor_managed_ap_locations_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_controllers_anchor_managed_ap_locations_v1_info.py b/plugins/action/wireless_controllers_anchor_managed_ap_locations_v1_info.py index 5cb5e8994a..2c39ed0ee6 100644 --- a/plugins/action/wireless_controllers_anchor_managed_ap_locations_v1_info.py +++ b/plugins/action/wireless_controllers_anchor_managed_ap_locations_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_controllers_assign_managed_ap_locations.py b/plugins/action/wireless_controllers_assign_managed_ap_locations.py index 9257f05945..408ec42c63 100644 --- a/plugins/action/wireless_controllers_assign_managed_ap_locations.py +++ b/plugins/action/wireless_controllers_assign_managed_ap_locations.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_controllers_assign_managed_ap_locations_v1.py b/plugins/action/wireless_controllers_assign_managed_ap_locations_v1.py index 718b57d668..3e8dcf7d88 100644 --- a/plugins/action/wireless_controllers_assign_managed_ap_locations_v1.py +++ b/plugins/action/wireless_controllers_assign_managed_ap_locations_v1.py @@ -39,7 +39,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False @@ -65,8 +66,10 @@ def _check_argspec(self): def get_object(self, params): new_object = dict( - primaryManagedAPLocationsSiteIds=params.get("primaryManagedAPLocationsSiteIds"), - secondaryManagedAPLocationsSiteIds=params.get("secondaryManagedAPLocationsSiteIds"), + primaryManagedAPLocationsSiteIds=params.get( + "primaryManagedAPLocationsSiteIds"), + secondaryManagedAPLocationsSiteIds=params.get( + "secondaryManagedAPLocationsSiteIds"), device_id=params.get("deviceId"), ) return new_object diff --git a/plugins/action/wireless_controllers_managed_ap_locations_count_info.py b/plugins/action/wireless_controllers_managed_ap_locations_count_info.py index 6b228aef20..00a5481320 100644 --- a/plugins/action/wireless_controllers_managed_ap_locations_count_info.py +++ b/plugins/action/wireless_controllers_managed_ap_locations_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_controllers_managed_ap_locations_count_v1_info.py b/plugins/action/wireless_controllers_managed_ap_locations_count_v1_info.py index 7b7521caf0..98ac39e04b 100644 --- a/plugins/action/wireless_controllers_managed_ap_locations_count_v1_info.py +++ b/plugins/action/wireless_controllers_managed_ap_locations_count_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_controllers_primary_managed_ap_locations_info.py b/plugins/action/wireless_controllers_primary_managed_ap_locations_info.py index 4f82ad9257..43367c5407 100644 --- a/plugins/action/wireless_controllers_primary_managed_ap_locations_info.py +++ b/plugins/action/wireless_controllers_primary_managed_ap_locations_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_controllers_primary_managed_ap_locations_v1_info.py b/plugins/action/wireless_controllers_primary_managed_ap_locations_v1_info.py index 4c68fa845f..67d94cb502 100644 --- a/plugins/action/wireless_controllers_primary_managed_ap_locations_v1_info.py +++ b/plugins/action/wireless_controllers_primary_managed_ap_locations_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_controllers_provision.py b/plugins/action/wireless_controllers_provision.py index 8bd8e91706..3df1abdae2 100644 --- a/plugins/action/wireless_controllers_provision.py +++ b/plugins/action/wireless_controllers_provision.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_controllers_provision_v1.py b/plugins/action/wireless_controllers_provision_v1.py index ffc77f7376..193d2e512d 100644 --- a/plugins/action/wireless_controllers_provision_v1.py +++ b/plugins/action/wireless_controllers_provision_v1.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_controllers_secondary_managed_ap_locations_info.py b/plugins/action/wireless_controllers_secondary_managed_ap_locations_info.py index dc3ef9106b..77c1e2f6e2 100644 --- a/plugins/action/wireless_controllers_secondary_managed_ap_locations_info.py +++ b/plugins/action/wireless_controllers_secondary_managed_ap_locations_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_controllers_secondary_managed_ap_locations_v1_info.py b/plugins/action/wireless_controllers_secondary_managed_ap_locations_v1_info.py index b6d82f5603..59883782eb 100644 --- a/plugins/action/wireless_controllers_secondary_managed_ap_locations_v1_info.py +++ b/plugins/action/wireless_controllers_secondary_managed_ap_locations_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_controllers_ssid_details_count_info.py b/plugins/action/wireless_controllers_ssid_details_count_info.py index 9d737f7d2e..95b0e73868 100644 --- a/plugins/action/wireless_controllers_ssid_details_count_info.py +++ b/plugins/action/wireless_controllers_ssid_details_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_controllers_ssid_details_count_v1_info.py b/plugins/action/wireless_controllers_ssid_details_count_v1_info.py index de11bc4659..d44b5f0318 100644 --- a/plugins/action/wireless_controllers_ssid_details_count_v1_info.py +++ b/plugins/action/wireless_controllers_ssid_details_count_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_controllers_ssid_details_info.py b/plugins/action/wireless_controllers_ssid_details_info.py index 481a1193bf..2c23c9be85 100644 --- a/plugins/action/wireless_controllers_ssid_details_info.py +++ b/plugins/action/wireless_controllers_ssid_details_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_controllers_ssid_details_v1_info.py b/plugins/action/wireless_controllers_ssid_details_v1_info.py index 3b4923d001..a5c359143b 100644 --- a/plugins/action/wireless_controllers_ssid_details_v1_info.py +++ b/plugins/action/wireless_controllers_ssid_details_v1_info.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_controllers_wireless_mobility_groups_count_info.py b/plugins/action/wireless_controllers_wireless_mobility_groups_count_info.py index 0509c6d8d1..640a49b9a5 100644 --- a/plugins/action/wireless_controllers_wireless_mobility_groups_count_info.py +++ b/plugins/action/wireless_controllers_wireless_mobility_groups_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_controllers_wireless_mobility_groups_count_v1_info.py b/plugins/action/wireless_controllers_wireless_mobility_groups_count_v1_info.py index 5875f26103..65ec6bcdad 100644 --- a/plugins/action/wireless_controllers_wireless_mobility_groups_count_v1_info.py +++ b/plugins/action/wireless_controllers_wireless_mobility_groups_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_controllers_wireless_mobility_groups_info.py b/plugins/action/wireless_controllers_wireless_mobility_groups_info.py index 562567ccdd..0b24748706 100644 --- a/plugins/action/wireless_controllers_wireless_mobility_groups_info.py +++ b/plugins/action/wireless_controllers_wireless_mobility_groups_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_controllers_wireless_mobility_groups_mobility_provision.py b/plugins/action/wireless_controllers_wireless_mobility_groups_mobility_provision.py index 711e272bd0..b997eec5a2 100644 --- a/plugins/action/wireless_controllers_wireless_mobility_groups_mobility_provision.py +++ b/plugins/action/wireless_controllers_wireless_mobility_groups_mobility_provision.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_controllers_wireless_mobility_groups_mobility_provision_v1.py b/plugins/action/wireless_controllers_wireless_mobility_groups_mobility_provision_v1.py index bfb059c6b6..ddd69f14e5 100644 --- a/plugins/action/wireless_controllers_wireless_mobility_groups_mobility_provision_v1.py +++ b/plugins/action/wireless_controllers_wireless_mobility_groups_mobility_provision_v1.py @@ -43,7 +43,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_controllers_wireless_mobility_groups_mobility_reset.py b/plugins/action/wireless_controllers_wireless_mobility_groups_mobility_reset.py index 557b69aa8b..84ea45837c 100644 --- a/plugins/action/wireless_controllers_wireless_mobility_groups_mobility_reset.py +++ b/plugins/action/wireless_controllers_wireless_mobility_groups_mobility_reset.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_controllers_wireless_mobility_groups_mobility_reset_v1.py b/plugins/action/wireless_controllers_wireless_mobility_groups_mobility_reset_v1.py index fd7f7f7365..4e3f708371 100644 --- a/plugins/action/wireless_controllers_wireless_mobility_groups_mobility_reset_v1.py +++ b/plugins/action/wireless_controllers_wireless_mobility_groups_mobility_reset_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_controllers_wireless_mobility_groups_v1_info.py b/plugins/action/wireless_controllers_wireless_mobility_groups_v1_info.py index 524e353e7b..d0ad1ab601 100644 --- a/plugins/action/wireless_controllers_wireless_mobility_groups_v1_info.py +++ b/plugins/action/wireless_controllers_wireless_mobility_groups_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_dynamic_interface.py b/plugins/action/wireless_dynamic_interface.py index fc976e2c5e..91491441b7 100644 --- a/plugins/action/wireless_dynamic_interface.py +++ b/plugins/action/wireless_dynamic_interface.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_dynamic_interface_info.py b/plugins/action/wireless_dynamic_interface_info.py index 388aa85625..136c1ecc50 100644 --- a/plugins/action/wireless_dynamic_interface_info.py +++ b/plugins/action/wireless_dynamic_interface_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_dynamic_interface_v1.py b/plugins/action/wireless_dynamic_interface_v1.py index 197483440f..037b6e52ab 100644 --- a/plugins/action/wireless_dynamic_interface_v1.py +++ b/plugins/action/wireless_dynamic_interface_v1.py @@ -53,18 +53,21 @@ def __init__(self, params, dnac): def get_all_params(self, name=None, id=None): new_object_params = {} - new_object_params['interface_name'] = self.new_object.get('interface_name') + new_object_params['interface_name'] = self.new_object.get( + 'interface_name') return new_object_params def create_params(self): new_object_params = {} - new_object_params['interfaceName'] = self.new_object.get('interfaceName') + new_object_params['interfaceName'] = self.new_object.get( + 'interfaceName') new_object_params['vlanId'] = self.new_object.get('vlanId') return new_object_params def delete_all_params(self): new_object_params = {} - new_object_params['interface_name'] = self.new_object.get('interface_name') + new_object_params['interface_name'] = self.new_object.get( + 'interface_name') new_object_params['headers'] = self.new_object.get('headers') return new_object_params @@ -105,7 +108,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -149,7 +153,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_dynamic_interface_v1_info.py b/plugins/action/wireless_dynamic_interface_v1_info.py index 16fbdd0423..fe32c8c64f 100644 --- a/plugins/action/wireless_dynamic_interface_v1_info.py +++ b/plugins/action/wireless_dynamic_interface_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_enterprise_ssid.py b/plugins/action/wireless_enterprise_ssid.py index 89a3cc01a4..b5f70117c6 100644 --- a/plugins/action/wireless_enterprise_ssid.py +++ b/plugins/action/wireless_enterprise_ssid.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_enterprise_ssid_info.py b/plugins/action/wireless_enterprise_ssid_info.py index 9113653fac..fba453c9f4 100644 --- a/plugins/action/wireless_enterprise_ssid_info.py +++ b/plugins/action/wireless_enterprise_ssid_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_enterprise_ssid_v1.py b/plugins/action/wireless_enterprise_ssid_v1.py index 0147f06c26..9b84d27585 100644 --- a/plugins/action/wireless_enterprise_ssid_v1.py +++ b/plugins/action/wireless_enterprise_ssid_v1.py @@ -92,16 +92,20 @@ def __init__(self, params, dnac): sessionTimeOut=params.get("sessionTimeOut"), enableClientExclusion=params.get("enableClientExclusion"), clientExclusionTimeout=params.get("clientExclusionTimeout"), - enableBasicServiceSetMaxIdle=params.get("enableBasicServiceSetMaxIdle"), - basicServiceSetClientIdleTimeout=params.get("basicServiceSetClientIdleTimeout"), - enableDirectedMulticastService=params.get("enableDirectedMulticastService"), + enableBasicServiceSetMaxIdle=params.get( + "enableBasicServiceSetMaxIdle"), + basicServiceSetClientIdleTimeout=params.get( + "basicServiceSetClientIdleTimeout"), + enableDirectedMulticastService=params.get( + "enableDirectedMulticastService"), enableNeighborList=params.get("enableNeighborList"), mfpClientProtection=params.get("mfpClientProtection"), nasOptions=params.get("nasOptions"), profileName=params.get("profileName"), policyProfileName=params.get("policyProfileName"), aaaOverride=params.get("aaaOverride"), - coverageHoleDetectionEnable=params.get("coverageHoleDetectionEnable"), + coverageHoleDetectionEnable=params.get( + "coverageHoleDetectionEnable"), protectedManagementFrame=params.get("protectedManagementFrame"), multiPSKSettings=params.get("multiPSKSettings"), clientRateLimit=params.get("clientRateLimit"), @@ -123,36 +127,59 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} new_object_params['name'] = self.new_object.get('name') - new_object_params['securityLevel'] = self.new_object.get('securityLevel') + new_object_params['securityLevel'] = self.new_object.get( + 'securityLevel') new_object_params['passphrase'] = self.new_object.get('passphrase') - new_object_params['enableFastLane'] = self.new_object.get('enableFastLane') - new_object_params['enableMACFiltering'] = self.new_object.get('enableMACFiltering') + new_object_params['enableFastLane'] = self.new_object.get( + 'enableFastLane') + new_object_params['enableMACFiltering'] = self.new_object.get( + 'enableMACFiltering') new_object_params['trafficType'] = self.new_object.get('trafficType') new_object_params['radioPolicy'] = self.new_object.get('radioPolicy') - new_object_params['enableBroadcastSSID'] = self.new_object.get('enableBroadcastSSID') - new_object_params['fastTransition'] = self.new_object.get('fastTransition') - new_object_params['enableSessionTimeOut'] = self.new_object.get('enableSessionTimeOut') - new_object_params['sessionTimeOut'] = self.new_object.get('sessionTimeOut') - new_object_params['enableClientExclusion'] = self.new_object.get('enableClientExclusion') - new_object_params['clientExclusionTimeout'] = self.new_object.get('clientExclusionTimeout') - new_object_params['enableBasicServiceSetMaxIdle'] = self.new_object.get('enableBasicServiceSetMaxIdle') - new_object_params['basicServiceSetClientIdleTimeout'] = self.new_object.get('basicServiceSetClientIdleTimeout') - new_object_params['enableDirectedMulticastService'] = self.new_object.get('enableDirectedMulticastService') - new_object_params['enableNeighborList'] = self.new_object.get('enableNeighborList') - new_object_params['mfpClientProtection'] = self.new_object.get('mfpClientProtection') + new_object_params['enableBroadcastSSID'] = self.new_object.get( + 'enableBroadcastSSID') + new_object_params['fastTransition'] = self.new_object.get( + 'fastTransition') + new_object_params['enableSessionTimeOut'] = self.new_object.get( + 'enableSessionTimeOut') + new_object_params['sessionTimeOut'] = self.new_object.get( + 'sessionTimeOut') + new_object_params['enableClientExclusion'] = self.new_object.get( + 'enableClientExclusion') + new_object_params['clientExclusionTimeout'] = self.new_object.get( + 'clientExclusionTimeout') + new_object_params['enableBasicServiceSetMaxIdle'] = self.new_object.get( + 'enableBasicServiceSetMaxIdle') + new_object_params['basicServiceSetClientIdleTimeout'] = self.new_object.get( + 'basicServiceSetClientIdleTimeout') + new_object_params['enableDirectedMulticastService'] = self.new_object.get( + 'enableDirectedMulticastService') + new_object_params['enableNeighborList'] = self.new_object.get( + 'enableNeighborList') + new_object_params['mfpClientProtection'] = self.new_object.get( + 'mfpClientProtection') new_object_params['nasOptions'] = self.new_object.get('nasOptions') new_object_params['profileName'] = self.new_object.get('profileName') - new_object_params['policyProfileName'] = self.new_object.get('policyProfileName') + new_object_params['policyProfileName'] = self.new_object.get( + 'policyProfileName') new_object_params['aaaOverride'] = self.new_object.get('aaaOverride') - new_object_params['coverageHoleDetectionEnable'] = self.new_object.get('coverageHoleDetectionEnable') - new_object_params['protectedManagementFrame'] = self.new_object.get('protectedManagementFrame') - new_object_params['multiPSKSettings'] = self.new_object.get('multiPSKSettings') - new_object_params['clientRateLimit'] = self.new_object.get('clientRateLimit') + new_object_params['coverageHoleDetectionEnable'] = self.new_object.get( + 'coverageHoleDetectionEnable') + new_object_params['protectedManagementFrame'] = self.new_object.get( + 'protectedManagementFrame') + new_object_params['multiPSKSettings'] = self.new_object.get( + 'multiPSKSettings') + new_object_params['clientRateLimit'] = self.new_object.get( + 'clientRateLimit') new_object_params['authKeyMgmt'] = self.new_object.get('authKeyMgmt') - new_object_params['rsnCipherSuiteGcmp256'] = self.new_object.get('rsnCipherSuiteGcmp256') - new_object_params['rsnCipherSuiteCcmp256'] = self.new_object.get('rsnCipherSuiteCcmp256') - new_object_params['rsnCipherSuiteGcmp128'] = self.new_object.get('rsnCipherSuiteGcmp128') - new_object_params['ghz6PolicyClientSteering'] = self.new_object.get('ghz6PolicyClientSteering') + new_object_params['rsnCipherSuiteGcmp256'] = self.new_object.get( + 'rsnCipherSuiteGcmp256') + new_object_params['rsnCipherSuiteCcmp256'] = self.new_object.get( + 'rsnCipherSuiteCcmp256') + new_object_params['rsnCipherSuiteGcmp128'] = self.new_object.get( + 'rsnCipherSuiteGcmp128') + new_object_params['ghz6PolicyClientSteering'] = self.new_object.get( + 'ghz6PolicyClientSteering') new_object_params['ghz24Policy'] = self.new_object.get('ghz24Policy') return new_object_params @@ -164,36 +191,59 @@ def delete_by_name_params(self): def update_all_params(self): new_object_params = {} new_object_params['name'] = self.new_object.get('name') - new_object_params['securityLevel'] = self.new_object.get('securityLevel') + new_object_params['securityLevel'] = self.new_object.get( + 'securityLevel') new_object_params['passphrase'] = self.new_object.get('passphrase') - new_object_params['enableFastLane'] = self.new_object.get('enableFastLane') - new_object_params['enableMACFiltering'] = self.new_object.get('enableMACFiltering') + new_object_params['enableFastLane'] = self.new_object.get( + 'enableFastLane') + new_object_params['enableMACFiltering'] = self.new_object.get( + 'enableMACFiltering') new_object_params['trafficType'] = self.new_object.get('trafficType') new_object_params['radioPolicy'] = self.new_object.get('radioPolicy') - new_object_params['enableBroadcastSSID'] = self.new_object.get('enableBroadcastSSID') - new_object_params['fastTransition'] = self.new_object.get('fastTransition') - new_object_params['enableSessionTimeOut'] = self.new_object.get('enableSessionTimeOut') - new_object_params['sessionTimeOut'] = self.new_object.get('sessionTimeOut') - new_object_params['enableClientExclusion'] = self.new_object.get('enableClientExclusion') - new_object_params['clientExclusionTimeout'] = self.new_object.get('clientExclusionTimeout') - new_object_params['enableBasicServiceSetMaxIdle'] = self.new_object.get('enableBasicServiceSetMaxIdle') - new_object_params['basicServiceSetClientIdleTimeout'] = self.new_object.get('basicServiceSetClientIdleTimeout') - new_object_params['enableDirectedMulticastService'] = self.new_object.get('enableDirectedMulticastService') - new_object_params['enableNeighborList'] = self.new_object.get('enableNeighborList') - new_object_params['mfpClientProtection'] = self.new_object.get('mfpClientProtection') + new_object_params['enableBroadcastSSID'] = self.new_object.get( + 'enableBroadcastSSID') + new_object_params['fastTransition'] = self.new_object.get( + 'fastTransition') + new_object_params['enableSessionTimeOut'] = self.new_object.get( + 'enableSessionTimeOut') + new_object_params['sessionTimeOut'] = self.new_object.get( + 'sessionTimeOut') + new_object_params['enableClientExclusion'] = self.new_object.get( + 'enableClientExclusion') + new_object_params['clientExclusionTimeout'] = self.new_object.get( + 'clientExclusionTimeout') + new_object_params['enableBasicServiceSetMaxIdle'] = self.new_object.get( + 'enableBasicServiceSetMaxIdle') + new_object_params['basicServiceSetClientIdleTimeout'] = self.new_object.get( + 'basicServiceSetClientIdleTimeout') + new_object_params['enableDirectedMulticastService'] = self.new_object.get( + 'enableDirectedMulticastService') + new_object_params['enableNeighborList'] = self.new_object.get( + 'enableNeighborList') + new_object_params['mfpClientProtection'] = self.new_object.get( + 'mfpClientProtection') new_object_params['nasOptions'] = self.new_object.get('nasOptions') new_object_params['profileName'] = self.new_object.get('profileName') - new_object_params['policyProfileName'] = self.new_object.get('policyProfileName') + new_object_params['policyProfileName'] = self.new_object.get( + 'policyProfileName') new_object_params['aaaOverride'] = self.new_object.get('aaaOverride') - new_object_params['coverageHoleDetectionEnable'] = self.new_object.get('coverageHoleDetectionEnable') - new_object_params['protectedManagementFrame'] = self.new_object.get('protectedManagementFrame') - new_object_params['multiPSKSettings'] = self.new_object.get('multiPSKSettings') - new_object_params['clientRateLimit'] = self.new_object.get('clientRateLimit') + new_object_params['coverageHoleDetectionEnable'] = self.new_object.get( + 'coverageHoleDetectionEnable') + new_object_params['protectedManagementFrame'] = self.new_object.get( + 'protectedManagementFrame') + new_object_params['multiPSKSettings'] = self.new_object.get( + 'multiPSKSettings') + new_object_params['clientRateLimit'] = self.new_object.get( + 'clientRateLimit') new_object_params['authKeyMgmt'] = self.new_object.get('authKeyMgmt') - new_object_params['rsnCipherSuiteGcmp256'] = self.new_object.get('rsnCipherSuiteGcmp256') - new_object_params['rsnCipherSuiteCcmp256'] = self.new_object.get('rsnCipherSuiteCcmp256') - new_object_params['rsnCipherSuiteGcmp128'] = self.new_object.get('rsnCipherSuiteGcmp128') - new_object_params['ghz6PolicyClientSteering'] = self.new_object.get('ghz6PolicyClientSteering') + new_object_params['rsnCipherSuiteGcmp256'] = self.new_object.get( + 'rsnCipherSuiteGcmp256') + new_object_params['rsnCipherSuiteCcmp256'] = self.new_object.get( + 'rsnCipherSuiteCcmp256') + new_object_params['rsnCipherSuiteGcmp128'] = self.new_object.get( + 'rsnCipherSuiteGcmp128') + new_object_params['ghz6PolicyClientSteering'] = self.new_object.get( + 'ghz6PolicyClientSteering') new_object_params['ghz24Policy'] = self.new_object.get('ghz24Policy') return new_object_params @@ -252,7 +302,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -276,7 +327,8 @@ def requires_update(self, current_obj): ("enableClientExclusion", "enableClientExclusion"), ("clientExclusionTimeout", "clientExclusionTimeout"), ("enableBasicServiceSetMaxIdle", "enableBasicServiceSetMaxIdle"), - ("basicServiceSetClientIdleTimeout", "basicServiceSetClientIdleTimeout"), + ("basicServiceSetClientIdleTimeout", + "basicServiceSetClientIdleTimeout"), ("enableDirectedMulticastService", "enableDirectedMulticastService"), ("enableNeighborList", "enableNeighborList"), ("mfpClientProtection", "mfpClientProtection"), @@ -347,7 +399,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_enterprise_ssid_v1_info.py b/plugins/action/wireless_enterprise_ssid_v1_info.py index 736cd32195..00d4883737 100644 --- a/plugins/action/wireless_enterprise_ssid_v1_info.py +++ b/plugins/action/wireless_enterprise_ssid_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_profile.py b/plugins/action/wireless_profile.py index 18ce4eb985..b9a1faf446 100644 --- a/plugins/action/wireless_profile.py +++ b/plugins/action/wireless_profile.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_profile_info.py b/plugins/action/wireless_profile_info.py index eb16f7b623..2046d7aef3 100644 --- a/plugins/action/wireless_profile_info.py +++ b/plugins/action/wireless_profile_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_profile_v1.py b/plugins/action/wireless_profile_v1.py index ef96d0599d..bb9443cbfa 100644 --- a/plugins/action/wireless_profile_v1.py +++ b/plugins/action/wireless_profile_v1.py @@ -60,17 +60,20 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['profileDetails'] = self.new_object.get('profileDetails') + new_object_params['profileDetails'] = self.new_object.get( + 'profileDetails') return new_object_params def delete_by_name_params(self): new_object_params = {} - new_object_params['wireless_profile_name'] = self.new_object.get('wireless_profile_name') + new_object_params['wireless_profile_name'] = self.new_object.get( + 'wireless_profile_name') return new_object_params def update_all_params(self): new_object_params = {} - new_object_params['profileDetails'] = self.new_object.get('profileDetails') + new_object_params['profileDetails'] = self.new_object.get( + 'profileDetails') return new_object_params def get_object_by_name(self, name): @@ -128,7 +131,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -192,7 +196,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_profile_v1_info.py b/plugins/action/wireless_profile_v1_info.py index 8d40cd4939..8322ce86c8 100644 --- a/plugins/action/wireless_profile_v1_info.py +++ b/plugins/action/wireless_profile_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_profiles.py b/plugins/action/wireless_profiles.py index e571e2d44c..6f7585e144 100644 --- a/plugins/action/wireless_profiles.py +++ b/plugins/action/wireless_profiles.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_profiles_count_info.py b/plugins/action/wireless_profiles_count_info.py index 043f3a3777..1c6e890fc0 100644 --- a/plugins/action/wireless_profiles_count_info.py +++ b/plugins/action/wireless_profiles_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_profiles_count_v1_info.py b/plugins/action/wireless_profiles_count_v1_info.py index 18586e9e68..3702539ce7 100644 --- a/plugins/action/wireless_profiles_count_v1_info.py +++ b/plugins/action/wireless_profiles_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_profiles_info.py b/plugins/action/wireless_profiles_info.py index 7fcde96f3d..780c5bba84 100644 --- a/plugins/action/wireless_profiles_info.py +++ b/plugins/action/wireless_profiles_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_profiles_v1.py b/plugins/action/wireless_profiles_v1.py index 458d74316a..19342d83f9 100644 --- a/plugins/action/wireless_profiles_v1.py +++ b/plugins/action/wireless_profiles_v1.py @@ -62,7 +62,8 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['wirelessProfileName'] = self.new_object.get('wirelessProfileName') + new_object_params['wirelessProfileName'] = self.new_object.get( + 'wirelessProfileName') new_object_params['ssidDetails'] = self.new_object.get('ssidDetails') return new_object_params @@ -73,7 +74,8 @@ def delete_by_id_params(self): def update_by_id_params(self): new_object_params = {} - new_object_params['wirelessProfileName'] = self.new_object.get('wirelessProfileName') + new_object_params['wirelessProfileName'] = self.new_object.get( + 'wirelessProfileName') new_object_params['ssidDetails'] = self.new_object.get('ssidDetails') new_object_params['id'] = self.new_object.get('id') return new_object_params @@ -126,7 +128,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) if _id: @@ -198,7 +201,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_profiles_v1_info.py b/plugins/action/wireless_profiles_v1_info.py index a9bf046cc5..9fdd41de2f 100644 --- a/plugins/action/wireless_profiles_v1_info.py +++ b/plugins/action/wireless_profiles_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_provision_access_point.py b/plugins/action/wireless_provision_access_point.py index e97781b4bd..41bd65497c 100644 --- a/plugins/action/wireless_provision_access_point.py +++ b/plugins/action/wireless_provision_access_point.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_provision_access_point_v1.py b/plugins/action/wireless_provision_access_point_v1.py index 8dbf5c68af..ed2bd27f21 100644 --- a/plugins/action/wireless_provision_access_point_v1.py +++ b/plugins/action/wireless_provision_access_point_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_provision_device_create.py b/plugins/action/wireless_provision_device_create.py index d3e06ac516..4132f3844c 100644 --- a/plugins/action/wireless_provision_device_create.py +++ b/plugins/action/wireless_provision_device_create.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_provision_device_create_v1.py b/plugins/action/wireless_provision_device_create_v1.py index 9772cb6a77..2024f18c96 100644 --- a/plugins/action/wireless_provision_device_create_v1.py +++ b/plugins/action/wireless_provision_device_create_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_provision_device_update.py b/plugins/action/wireless_provision_device_update.py index fd820b8e55..e5be21df09 100644 --- a/plugins/action/wireless_provision_device_update.py +++ b/plugins/action/wireless_provision_device_update.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_provision_device_update_v1.py b/plugins/action/wireless_provision_device_update_v1.py index c62d176e23..6e367b45bc 100644 --- a/plugins/action/wireless_provision_device_update_v1.py +++ b/plugins/action/wireless_provision_device_update_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_provision_ssid_create_provision.py b/plugins/action/wireless_provision_ssid_create_provision.py index 4df2a20945..5987c3332e 100644 --- a/plugins/action/wireless_provision_ssid_create_provision.py +++ b/plugins/action/wireless_provision_ssid_create_provision.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_provision_ssid_create_provision_v1.py b/plugins/action/wireless_provision_ssid_create_provision_v1.py index affed97ef1..44b080ac28 100644 --- a/plugins/action/wireless_provision_ssid_create_provision_v1.py +++ b/plugins/action/wireless_provision_ssid_create_provision_v1.py @@ -42,7 +42,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_provision_ssid_delete_reprovision.py b/plugins/action/wireless_provision_ssid_delete_reprovision.py index 64fca16d71..1938ba1547 100644 --- a/plugins/action/wireless_provision_ssid_delete_reprovision.py +++ b/plugins/action/wireless_provision_ssid_delete_reprovision.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_provision_ssid_delete_reprovision_v1.py b/plugins/action/wireless_provision_ssid_delete_reprovision_v1.py index 0b19c9f554..3302030a89 100644 --- a/plugins/action/wireless_provision_ssid_delete_reprovision_v1.py +++ b/plugins/action/wireless_provision_ssid_delete_reprovision_v1.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_psk_override.py b/plugins/action/wireless_psk_override.py index c9f7a09b0b..f6f1c949d9 100644 --- a/plugins/action/wireless_psk_override.py +++ b/plugins/action/wireless_psk_override.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_psk_override_v1.py b/plugins/action/wireless_psk_override_v1.py index 6fe372d58b..4116373eec 100644 --- a/plugins/action/wireless_psk_override_v1.py +++ b/plugins/action/wireless_psk_override_v1.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_rf_profile.py b/plugins/action/wireless_rf_profile.py index 7b6da5f49b..ba8f266001 100644 --- a/plugins/action/wireless_rf_profile.py +++ b/plugins/action/wireless_rf_profile.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_rf_profile_info.py b/plugins/action/wireless_rf_profile_info.py index cb1e1f91d0..12ea9ee294 100644 --- a/plugins/action/wireless_rf_profile_info.py +++ b/plugins/action/wireless_rf_profile_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_rf_profile_v1.py b/plugins/action/wireless_rf_profile_v1.py index 7ba7dd82d8..10f96533b6 100644 --- a/plugins/action/wireless_rf_profile_v1.py +++ b/plugins/action/wireless_rf_profile_v1.py @@ -74,27 +74,37 @@ def __init__(self, params, dnac): def get_all_params(self, name=None, id=None): new_object_params = {} - new_object_params['rf_profile_name'] = self.new_object.get('rf_profile_name') + new_object_params['rf_profile_name'] = self.new_object.get( + 'rf_profile_name') return new_object_params def create_params(self): new_object_params = {} new_object_params['name'] = self.new_object.get('name') - new_object_params['defaultRfProfile'] = self.new_object.get('defaultRfProfile') - new_object_params['enableRadioTypeA'] = self.new_object.get('enableRadioTypeA') - new_object_params['enableRadioTypeB'] = self.new_object.get('enableRadioTypeB') + new_object_params['defaultRfProfile'] = self.new_object.get( + 'defaultRfProfile') + new_object_params['enableRadioTypeA'] = self.new_object.get( + 'enableRadioTypeA') + new_object_params['enableRadioTypeB'] = self.new_object.get( + 'enableRadioTypeB') new_object_params['channelWidth'] = self.new_object.get('channelWidth') new_object_params['enableCustom'] = self.new_object.get('enableCustom') - new_object_params['enableBrownField'] = self.new_object.get('enableBrownField') - new_object_params['radioTypeAProperties'] = self.new_object.get('radioTypeAProperties') - new_object_params['radioTypeBProperties'] = self.new_object.get('radioTypeBProperties') - new_object_params['radioTypeCProperties'] = self.new_object.get('radioTypeCProperties') - new_object_params['enableRadioTypeC'] = self.new_object.get('enableRadioTypeC') + new_object_params['enableBrownField'] = self.new_object.get( + 'enableBrownField') + new_object_params['radioTypeAProperties'] = self.new_object.get( + 'radioTypeAProperties') + new_object_params['radioTypeBProperties'] = self.new_object.get( + 'radioTypeBProperties') + new_object_params['radioTypeCProperties'] = self.new_object.get( + 'radioTypeCProperties') + new_object_params['enableRadioTypeC'] = self.new_object.get( + 'enableRadioTypeC') return new_object_params def delete_by_name_params(self): new_object_params = {} - new_object_params['rf_profile_name'] = self.new_object.get('rf_profile_name') + new_object_params['rf_profile_name'] = self.new_object.get( + 'rf_profile_name') return new_object_params def get_object_by_name(self, name): @@ -140,7 +150,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) it_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -202,7 +213,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_rf_profile_v1_info.py b/plugins/action/wireless_rf_profile_v1_info.py index 36b160a6ce..4256884783 100644 --- a/plugins/action/wireless_rf_profile_v1_info.py +++ b/plugins/action/wireless_rf_profile_v1_info.py @@ -38,7 +38,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_sensor_test_results_info.py b/plugins/action/wireless_sensor_test_results_info.py index 452f3840ff..722d6a873c 100644 --- a/plugins/action/wireless_sensor_test_results_info.py +++ b/plugins/action/wireless_sensor_test_results_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_sensor_test_results_v1_info.py b/plugins/action/wireless_sensor_test_results_v1_info.py index f90b2b1f9a..a30e62ee81 100644 --- a/plugins/action/wireless_sensor_test_results_v1_info.py +++ b/plugins/action/wireless_sensor_test_results_v1_info.py @@ -41,7 +41,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_settings_dot11be_profiles.py b/plugins/action/wireless_settings_dot11be_profiles.py index e0586d5887..a93abf916a 100644 --- a/plugins/action/wireless_settings_dot11be_profiles.py +++ b/plugins/action/wireless_settings_dot11be_profiles.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_settings_dot11be_profiles_count_info.py b/plugins/action/wireless_settings_dot11be_profiles_count_info.py index 17b49a8dfe..bd4a43f0d5 100644 --- a/plugins/action/wireless_settings_dot11be_profiles_count_info.py +++ b/plugins/action/wireless_settings_dot11be_profiles_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_settings_dot11be_profiles_count_v1_info.py b/plugins/action/wireless_settings_dot11be_profiles_count_v1_info.py index 34eb40a543..b2108a806f 100644 --- a/plugins/action/wireless_settings_dot11be_profiles_count_v1_info.py +++ b/plugins/action/wireless_settings_dot11be_profiles_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_settings_dot11be_profiles_info.py b/plugins/action/wireless_settings_dot11be_profiles_info.py index 9425daeb2e..983fddd8fb 100644 --- a/plugins/action/wireless_settings_dot11be_profiles_info.py +++ b/plugins/action/wireless_settings_dot11be_profiles_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_settings_dot11be_profiles_v1.py b/plugins/action/wireless_settings_dot11be_profiles_v1.py index e7cd254d56..e04d25448a 100644 --- a/plugins/action/wireless_settings_dot11be_profiles_v1.py +++ b/plugins/action/wireless_settings_dot11be_profiles_v1.py @@ -71,9 +71,11 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} new_object_params['profileName'] = self.new_object.get('profileName') - new_object_params['ofdmaDownLink'] = self.new_object.get('ofdmaDownLink') + new_object_params['ofdmaDownLink'] = self.new_object.get( + 'ofdmaDownLink') new_object_params['ofdmaUpLink'] = self.new_object.get('ofdmaUpLink') - new_object_params['muMimoDownLink'] = self.new_object.get('muMimoDownLink') + new_object_params['muMimoDownLink'] = self.new_object.get( + 'muMimoDownLink') new_object_params['muMimoUpLink'] = self.new_object.get('muMimoUpLink') new_object_params['ofdmaMultiRu'] = self.new_object.get('ofdmaMultiRu') return new_object_params @@ -86,9 +88,11 @@ def delete_by_id_params(self): def update_by_id_params(self): new_object_params = {} new_object_params['profileName'] = self.new_object.get('profileName') - new_object_params['ofdmaDownLink'] = self.new_object.get('ofdmaDownLink') + new_object_params['ofdmaDownLink'] = self.new_object.get( + 'ofdmaDownLink') new_object_params['ofdmaUpLink'] = self.new_object.get('ofdmaUpLink') - new_object_params['muMimoDownLink'] = self.new_object.get('muMimoDownLink') + new_object_params['muMimoDownLink'] = self.new_object.get( + 'muMimoDownLink') new_object_params['muMimoUpLink'] = self.new_object.get('muMimoUpLink') new_object_params['ofdmaMultiRu'] = self.new_object.get('ofdmaMultiRu') new_object_params['id'] = self.new_object.get('id') @@ -142,7 +146,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) if _id: @@ -218,7 +223,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_settings_dot11be_profiles_v1_info.py b/plugins/action/wireless_settings_dot11be_profiles_v1_info.py index 3826419e3a..8fc6559610 100644 --- a/plugins/action/wireless_settings_dot11be_profiles_v1_info.py +++ b/plugins/action/wireless_settings_dot11be_profiles_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_settings_interfaces.py b/plugins/action/wireless_settings_interfaces.py index ed53021ec9..8a488678c5 100644 --- a/plugins/action/wireless_settings_interfaces.py +++ b/plugins/action/wireless_settings_interfaces.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_settings_interfaces_count_info.py b/plugins/action/wireless_settings_interfaces_count_info.py index 76e6814df2..124c4ed857 100644 --- a/plugins/action/wireless_settings_interfaces_count_info.py +++ b/plugins/action/wireless_settings_interfaces_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_settings_interfaces_count_v1_info.py b/plugins/action/wireless_settings_interfaces_count_v1_info.py index 5d2734fc29..3b9cc48270 100644 --- a/plugins/action/wireless_settings_interfaces_count_v1_info.py +++ b/plugins/action/wireless_settings_interfaces_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_settings_interfaces_info.py b/plugins/action/wireless_settings_interfaces_info.py index 42460a82aa..2f3182169e 100644 --- a/plugins/action/wireless_settings_interfaces_info.py +++ b/plugins/action/wireless_settings_interfaces_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_settings_interfaces_v1.py b/plugins/action/wireless_settings_interfaces_v1.py index 1409f64ae1..5ff97a330e 100644 --- a/plugins/action/wireless_settings_interfaces_v1.py +++ b/plugins/action/wireless_settings_interfaces_v1.py @@ -62,7 +62,8 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['interfaceName'] = self.new_object.get('interfaceName') + new_object_params['interfaceName'] = self.new_object.get( + 'interfaceName') new_object_params['vlanId'] = self.new_object.get('vlanId') return new_object_params @@ -73,7 +74,8 @@ def delete_by_id_params(self): def update_by_id_params(self): new_object_params = {} - new_object_params['interfaceName'] = self.new_object.get('interfaceName') + new_object_params['interfaceName'] = self.new_object.get( + 'interfaceName') new_object_params['vlanId'] = self.new_object.get('vlanId') new_object_params['id'] = self.new_object.get('id') return new_object_params @@ -126,7 +128,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) if _id: @@ -198,7 +201,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_settings_interfaces_v1_info.py b/plugins/action/wireless_settings_interfaces_v1_info.py index 6dd7f1ff6e..2ab47417f6 100644 --- a/plugins/action/wireless_settings_interfaces_v1_info.py +++ b/plugins/action/wireless_settings_interfaces_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_settings_rf_profiles.py b/plugins/action/wireless_settings_rf_profiles.py index 9359bdae26..729f0adeda 100644 --- a/plugins/action/wireless_settings_rf_profiles.py +++ b/plugins/action/wireless_settings_rf_profiles.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_settings_rf_profiles_count_info.py b/plugins/action/wireless_settings_rf_profiles_count_info.py index 5294563b95..73f6cfe246 100644 --- a/plugins/action/wireless_settings_rf_profiles_count_info.py +++ b/plugins/action/wireless_settings_rf_profiles_count_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_settings_rf_profiles_count_v1_info.py b/plugins/action/wireless_settings_rf_profiles_count_v1_info.py index 348336dd30..340db244ba 100644 --- a/plugins/action/wireless_settings_rf_profiles_count_v1_info.py +++ b/plugins/action/wireless_settings_rf_profiles_count_v1_info.py @@ -37,7 +37,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/action/wireless_settings_rf_profiles_info.py b/plugins/action/wireless_settings_rf_profiles_info.py index 9c120eecbf..39e2c0c4c7 100644 --- a/plugins/action/wireless_settings_rf_profiles_info.py +++ b/plugins/action/wireless_settings_rf_profiles_info.py @@ -14,4 +14,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) \ No newline at end of file + return module.run(tmp, task_vars) diff --git a/plugins/action/wireless_settings_rf_profiles_v1.py b/plugins/action/wireless_settings_rf_profiles_v1.py index bbdb00a772..89263f6bf9 100644 --- a/plugins/action/wireless_settings_rf_profiles_v1.py +++ b/plugins/action/wireless_settings_rf_profiles_v1.py @@ -74,14 +74,22 @@ def get_all_params(self, name=None, id=None): def create_params(self): new_object_params = {} - new_object_params['rfProfileName'] = self.new_object.get('rfProfileName') - new_object_params['defaultRfProfile'] = self.new_object.get('defaultRfProfile') - new_object_params['enableRadioTypeA'] = self.new_object.get('enableRadioTypeA') - new_object_params['enableRadioTypeB'] = self.new_object.get('enableRadioTypeB') - new_object_params['enableRadioType6GHz'] = self.new_object.get('enableRadioType6GHz') - new_object_params['radioTypeAProperties'] = self.new_object.get('radioTypeAProperties') - new_object_params['radioTypeBProperties'] = self.new_object.get('radioTypeBProperties') - new_object_params['radioType6GHzProperties'] = self.new_object.get('radioType6GHzProperties') + new_object_params['rfProfileName'] = self.new_object.get( + 'rfProfileName') + new_object_params['defaultRfProfile'] = self.new_object.get( + 'defaultRfProfile') + new_object_params['enableRadioTypeA'] = self.new_object.get( + 'enableRadioTypeA') + new_object_params['enableRadioTypeB'] = self.new_object.get( + 'enableRadioTypeB') + new_object_params['enableRadioType6GHz'] = self.new_object.get( + 'enableRadioType6GHz') + new_object_params['radioTypeAProperties'] = self.new_object.get( + 'radioTypeAProperties') + new_object_params['radioTypeBProperties'] = self.new_object.get( + 'radioTypeBProperties') + new_object_params['radioType6GHzProperties'] = self.new_object.get( + 'radioType6GHzProperties') return new_object_params def delete_by_id_params(self): @@ -91,14 +99,22 @@ def delete_by_id_params(self): def update_by_id_params(self): new_object_params = {} - new_object_params['rfProfileName'] = self.new_object.get('rfProfileName') - new_object_params['defaultRfProfile'] = self.new_object.get('defaultRfProfile') - new_object_params['enableRadioTypeA'] = self.new_object.get('enableRadioTypeA') - new_object_params['enableRadioTypeB'] = self.new_object.get('enableRadioTypeB') - new_object_params['enableRadioType6GHz'] = self.new_object.get('enableRadioType6GHz') - new_object_params['radioTypeAProperties'] = self.new_object.get('radioTypeAProperties') - new_object_params['radioTypeBProperties'] = self.new_object.get('radioTypeBProperties') - new_object_params['radioType6GHzProperties'] = self.new_object.get('radioType6GHzProperties') + new_object_params['rfProfileName'] = self.new_object.get( + 'rfProfileName') + new_object_params['defaultRfProfile'] = self.new_object.get( + 'defaultRfProfile') + new_object_params['enableRadioTypeA'] = self.new_object.get( + 'enableRadioTypeA') + new_object_params['enableRadioTypeB'] = self.new_object.get( + 'enableRadioTypeB') + new_object_params['enableRadioType6GHz'] = self.new_object.get( + 'enableRadioType6GHz') + new_object_params['radioTypeAProperties'] = self.new_object.get( + 'radioTypeAProperties') + new_object_params['radioTypeBProperties'] = self.new_object.get( + 'radioTypeBProperties') + new_object_params['radioType6GHzProperties'] = self.new_object.get( + 'radioType6GHzProperties') new_object_params['id'] = self.new_object.get('id') return new_object_params @@ -150,7 +166,8 @@ def exists(self): if name_exists: _id = prev_obj.get("id") if id_exists and name_exists and o_id != _id: - raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object") + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") if _id: self.new_object.update(dict(id=_id)) if _id: @@ -228,7 +245,8 @@ def delete(self): class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = False diff --git a/plugins/action/wireless_settings_rf_profiles_v1_info.py b/plugins/action/wireless_settings_rf_profiles_v1_info.py index 75592364fd..1235836297 100644 --- a/plugins/action/wireless_settings_rf_profiles_v1_info.py +++ b/plugins/action/wireless_settings_rf_profiles_v1_info.py @@ -40,7 +40,8 @@ class ActionModule(ActionBase): def __init__(self, *args, **kwargs): if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") + raise AnsibleActionFail( + "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") super(ActionModule, self).__init__(*args, **kwargs) self._supports_async = False self._supports_check_mode = True diff --git a/plugins/module_utils/dnac.py b/plugins/module_utils/dnac.py index 18d9f70788..b6761317a8 100644 --- a/plugins/module_utils/dnac.py +++ b/plugins/module_utils/dnac.py @@ -77,8 +77,10 @@ def __init__(self, module): self.max_timeout = self.params.get('dnac_api_task_timeout') self.payload = module.params - self.dnac_version = int(self.payload.get("dnac_version").replace(".", "")) - self.dnac_version_in_integer = int(self.payload.get("dnac_version").replace(".", "")) + self.dnac_version = int(self.payload.get( + "dnac_version").replace(".", "")) + self.dnac_version_in_integer = int( + self.payload.get("dnac_version").replace(".", "")) self.dnac_version_in_string = self.payload.get("dnac_version") # Dictionary to store multiple versions for easy maintenance and scalability # To add a new version, simply update the 'dnac_versions' dictionary with the new version string as the key @@ -95,15 +97,19 @@ def __init__(self, module): # Dynamically create variables based on dictionary keys for version_key, version_value in self.dnac_versions.items(): - setattr(self, "version_" + version_key.replace(".", "_"), version_value) + setattr(self, "version_" + + version_key.replace(".", "_"), version_value) if self.dnac_log and not DnacBase.__is_log_init: - self.dnac_log_level = dnac_params.get("dnac_log_level") or 'WARNING' + self.dnac_log_level = dnac_params.get( + "dnac_log_level") or 'WARNING' self.dnac_log_level = self.dnac_log_level.upper() self.validate_dnac_log_level() - self.dnac_log_file_path = dnac_params.get("dnac_log_file_path") or 'dnac.log' + self.dnac_log_file_path = dnac_params.get( + "dnac_log_file_path") or 'dnac.log' self.validate_dnac_log_file_path() - self.dnac_log_mode = 'w' if not dnac_params.get("dnac_log_append") else 'a' + self.dnac_log_mode = 'w' if not dnac_params.get( + "dnac_log_append") else 'a' self.setup_logger('logger') self.logger = logging.getLogger('logger') DnacBase.__is_log_init = True @@ -113,9 +119,12 @@ def __init__(self, module): self.logger = logging.getLogger('empty_logger') self.logger.addHandler(logging.NullHandler()) - self.log('Cisco Catalyst Center parameters: {0}'.format(dnac_params), "DEBUG") - self.supported_states = ["merged", "deleted", "replaced", "overridden", "gathered", "rendered", "parsed"] - self.result = {"changed": False, "diff": [], "response": [], "warnings": []} + self.log('Cisco Catalyst Center parameters: {0}'.format( + dnac_params), "DEBUG") + self.supported_states = [ + "merged", "deleted", "replaced", "overridden", "gathered", "rendered", "parsed"] + self.result = {"changed": False, "diff": [], + "response": [], "warnings": []} def compare_dnac_versions(self, version1, version2): """ @@ -247,9 +256,11 @@ def setup_logger(self, logger_name): logger = logging.getLogger(logger_name) # formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(module)s: %(funcName)s: %(lineno)d --- %(message)s', datefmt='%m-%d-%Y %H:%M:%S') - formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s', datefmt='%m-%d-%Y %H:%M:%S') + formatter = logging.Formatter( + '%(asctime)s %(levelname)s %(message)s', datefmt='%m-%d-%Y %H:%M:%S') - file_handler = logging.FileHandler(self.dnac_log_file_path, mode=self.dnac_log_mode) + file_handler = logging.FileHandler( + self.dnac_log_file_path, mode=self.dnac_log_mode) file_handler.setFormatter(formatter) logger.setLevel(level) @@ -258,7 +269,8 @@ def setup_logger(self, logger_name): def validate_dnac_log_level(self): """Validates if the logging level is string and of expected value""" if self.dnac_log_level not in ('INFO', 'DEBUG', 'WARNING', 'ERROR', 'CRITICAL'): - raise ValueError("Invalid log level: 'dnac_log_level:{0}'".format(self.dnac_log_level)) + raise ValueError( + "Invalid log level: 'dnac_log_level:{0}'".format(self.dnac_log_level)) def validate_dnac_log_file_path(self): """ @@ -271,7 +283,8 @@ def validate_dnac_log_file_path(self): # Validate if the directory exists log_directory = os.path.dirname(dnac_log_file_path) if not os.path.exists(log_directory): - raise FileNotFoundError("The directory for log file '{0}' does not exist.".format(dnac_log_file_path)) + raise FileNotFoundError( + "The directory for log file '{0}' does not exist.".format(dnac_log_file_path)) def log(self, message, level="WARNING", frameIncrement=0): """Logs formatted messages with specified log level and incrementing the call stack frame @@ -289,7 +302,8 @@ def log(self, message, level="WARNING", frameIncrement=0): callerframerecord = inspect.stack()[1 + frameIncrement] frame = callerframerecord[0] info = inspect.getframeinfo(frame) - log_message = " %s: %s: %s: %s \n" % (class_name, info.function, info.lineno, message) + log_message = " %s: %s: %s: %s \n" % ( + class_name, info.function, info.lineno, message) log_method = getattr(self.logger, level.lower()) log_method(log_message) @@ -304,11 +318,13 @@ def check_return_status(self): .format(line_no=line_no, status=self.status, msg=self.msg), "DEBUG" ) if "failed" in self.status: - self.module.fail_json(msg=self.msg, response=self.result.get('response', [])) + self.module.fail_json( + msg=self.msg, response=self.result.get('response', [])) elif "exited" in self.status: self.module.exit_json(**self.result) elif "invalid" in self.status: - self.module.fail_json(msg=self.msg, response=self.result.get('response', [])) + self.module.fail_json( + msg=self.msg, response=self.result.get('response', [])) def is_valid_password(self, password): """ @@ -396,11 +412,13 @@ def get_task_details(self, task_id): .format(task_id, response), "DEBUG") if not isinstance(response, dict): - self.log("Failed to retrieve task details for task ID: {}".format(task_id), "ERROR") + self.log("Failed to retrieve task details for task ID: {}".format( + task_id), "ERROR") return task_status task_status = response.get('response') - self.log("Successfully retrieved Task status: {0}".format(task_status), "DEBUG") + self.log("Successfully retrieved Task status: {0}".format( + task_status), "DEBUG") except Exception as e: # Log an error message and fail if an exception occurs self.log_traceback() @@ -469,13 +487,15 @@ def check_task_response_status(self, response, validation_string, api_name, data if (end_time - start_time) >= self.max_timeout: self.msg = "Max timeout of {max_timeout} sec has reached for the task id '{task_id}'. " \ .format(max_timeout=self.max_timeout, task_id=task_id) + \ - "Exiting the loop due to unexpected API '{api_name}' status.".format(api_name=api_name) + "Exiting the loop due to unexpected API '{api_name}' status.".format( + api_name=api_name) self.log(self.msg, "WARNING") self.status = "failed" break task_details = self.get_task_details(task_id) - self.log('Getting task details from task ID {0}: {1}'.format(task_id, task_details), "DEBUG") + self.log('Getting task details from task ID {0}: {1}'.format( + task_id, task_details), "DEBUG") if task_details.get("isError") is True: if task_details.get("failureReason"): @@ -496,7 +516,8 @@ def check_task_response_status(self, response, validation_string, api_name, data self.status = "success" break - self.log("Progress is {0} for task ID: {1}".format(task_details.get('progress'), task_id), "DEBUG") + self.log("Progress is {0} for task ID: {1}".format( + task_details.get('progress'), task_id), "DEBUG") return self @@ -565,7 +586,8 @@ def check_execution_response_status(self, response, api_name): if (end_time - start_time) >= self.max_timeout: self.msg = "Max timeout of {max_timeout} sec has reached for the execution id '{execution_id}'. "\ .format(max_timeout=self.max_timeout, execution_id=execution_id) + \ - "Exiting the loop due to unexpected API '{api_name}' status.".format(api_name=api_name) + "Exiting the loop due to unexpected API '{api_name}' status.".format( + api_name=api_name) self.log(self.msg, "WARNING") self.status = "failed" break @@ -624,12 +646,14 @@ def get_sites_type(self, site_name): if item["nameSpace"] == "Location": site_type = item.get("attributes").get("type") else: - self.log("Received API response from 'get_sites': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_sites': {0}".format( + str(response)), "DEBUG") site = response.get("response") site_type = site[0].get("type") except Exception as e: - self.msg = "An exception occurred while fetching the site '{0}'. Error: {1}".format(site_name, e) + self.msg = "An exception occurred while fetching the site '{0}'. Error: {1}".format( + site_name, e) self.fail_and_exit(self.msg) return site_type @@ -649,43 +673,56 @@ def get_device_ids_from_site(self, site_name, site_id=None): # If site_id is not provided, retrieve it based on the site_name if site_id is None: - self.log("Site ID not provided. Retrieving Site ID for site name: '{0}'.".format(site_name), "DEBUG") + self.log("Site ID not provided. Retrieving Site ID for site name: '{0}'.".format( + site_name), "DEBUG") site_id, site_exists = self.get_site_id(site_name) if not site_exists: - self.log("Site '{0}' does not exist, cannot proceed with device retrieval.".format(site_name), "ERROR") + self.log("Site '{0}' does not exist, cannot proceed with device retrieval.".format( + site_name), "ERROR") return api_response, device_ids - self.log("Retrieved site ID '{0}' for site name '{1}'.".format(site_id, site_name), "DEBUG") + self.log("Retrieved site ID '{0}' for site name '{1}'.".format( + site_id, site_name), "DEBUG") - self.log("Initiating retrieval of device IDs for site ID: '{0}'.".format(site_id), "DEBUG") + self.log("Initiating retrieval of device IDs for site ID: '{0}'.".format( + site_id), "DEBUG") # Determine API based on dnac_version if self.dnac_version <= self.version_2_3_5_3: - self.log("Using 'get_membership' API for Catalyst Center version: '{0}'.".format(self.dnac_version), "DEBUG") + self.log("Using 'get_membership' API for Catalyst Center version: '{0}'.".format( + self.dnac_version), "DEBUG") get_membership_params = {"site_id": site_id} - api_response = self.execute_get_request("sites", "get_membership", get_membership_params) + api_response = self.execute_get_request( + "sites", "get_membership", get_membership_params) - self.log("Received response from 'get_membership'. Extracting device IDs.", "DEBUG") + self.log( + "Received response from 'get_membership'. Extracting device IDs.", "DEBUG") if api_response and "device" in api_response: for device in api_response.get("device", []): for item in device.get("response", []): device_ids.append(item.get("instanceUuid")) - self.log("Retrieved device IDs from membership for site '{0}': {1}".format(site_id, device_ids), "DEBUG") + self.log("Retrieved device IDs from membership for site '{0}': {1}".format( + site_id, device_ids), "DEBUG") else: - self.log("Using 'get_site_assigned_network_devices' API for DNAC version: '{0}'.".format(self.dnac_version), "DEBUG") + self.log("Using 'get_site_assigned_network_devices' API for DNAC version: '{0}'.".format( + self.dnac_version), "DEBUG") get_site_assigned_network_devices_params = {"site_id": site_id} - api_response = self.execute_get_request("site_design", "get_site_assigned_network_devices", get_site_assigned_network_devices_params) + api_response = self.execute_get_request( + "site_design", "get_site_assigned_network_devices", get_site_assigned_network_devices_params) - self.log("Received response from 'get_site_assigned_network_devices'. Extracting device IDs.", "DEBUG") + self.log( + "Received response from 'get_site_assigned_network_devices'. Extracting device IDs.", "DEBUG") if api_response and "response" in api_response: for device in api_response.get("response", []): device_ids.append(device.get("deviceId")) - self.log("Retrieved device IDs from assigned devices for site '{0}': {1}".format(site_id, device_ids), "DEBUG") + self.log("Retrieved device IDs from assigned devices for site '{0}': {1}".format( + site_id, device_ids), "DEBUG") if not device_ids: - self.log("No devices found for site '{0}' with site ID: '{1}'.".format(site_name, site_id), "WARNING") + self.log("No devices found for site '{0}' with site ID: '{1}'.".format( + site_name, site_id), "WARNING") return api_response, device_ids @@ -700,41 +737,52 @@ def get_device_details_from_site(self, site_name, site_id=None): SystemExit: If the API call to get device IDs or device details fails. """ device_details_list = [] - self.log("Initiating retrieval of device IDs for site ID: '{0}'.".format(site_id), "INFO") + self.log("Initiating retrieval of device IDs for site ID: '{0}'.".format( + site_id), "INFO") # If site_id is not provided, retrieve it based on the site_name if site_id is None: - self.log("Site ID not provided. Retrieving Site ID for site name: '{0}'.".format(site_name), "DEBUG") + self.log("Site ID not provided. Retrieving Site ID for site name: '{0}'.".format( + site_name), "DEBUG") site_id, site_exists = self.get_site_id(site_name) if not site_exists: - self.log("Site '{0}' does not exist, cannot proceed with device retrieval.".format(site_name), "ERROR") + self.log("Site '{0}' does not exist, cannot proceed with device retrieval.".format( + site_name), "ERROR") return device_details_list - self.log("Retrieved site ID '{0}' for site name '{1}'.".format(site_id, site_name), "DEBUG") + self.log("Retrieved site ID '{0}' for site name '{1}'.".format( + site_id, site_name), "DEBUG") # Retrieve device IDs from the specified site - api_response, device_ids = self.get_device_ids_from_site(site_name, site_id) + api_response, device_ids = self.get_device_ids_from_site( + site_name, site_id) if not api_response: - self.msg = "No response received from API call 'get_device_ids_from_site' for site ID: {0}".format(site_id) + self.msg = "No response received from API call 'get_device_ids_from_site' for site ID: {0}".format( + site_id) self.fail_and_exit(self.msg) - self.log("Device IDs retrieved from site '{0}': {1}".format(site_id, str(device_ids)), "DEBUG") + self.log("Device IDs retrieved from site '{0}': {1}".format( + site_id, str(device_ids)), "DEBUG") # Iterate through each device ID to retrieve its details for device_id in device_ids: - self.log("Initiating retrieval of device details for device ID: '{0}'.".format(device_id), "INFO") + self.log("Initiating retrieval of device details for device ID: '{0}'.".format( + device_id), "INFO") get_device_by_id_params = {"id": device_id} # Execute GET API call to retrieve device details - device_info = self.execute_get_request("devices", "get_device_by_id", get_device_by_id_params) + device_info = self.execute_get_request( + "devices", "get_device_by_id", get_device_by_id_params) if not device_info: - self.msg = "No response received from API call 'get_device_by_id' for device ID: {0}".format(device_id) + self.msg = "No response received from API call 'get_device_by_id' for device ID: {0}".format( + device_id) self.fail_and_exit(self.msg) # Append the retrieved device details to the list device_details_list.append(device_info.get("response")) - self.log("Device details retrieved for device ID: '{0}'.".format(device_id), "DEBUG") + self.log("Device details retrieved for device ID: '{0}'.".format( + device_id), "DEBUG") return device_details_list @@ -753,14 +801,18 @@ def get_reachable_devices_from_site(self, site_name): (site_exists, site_id) = self.get_site_id(site_name) if not site_exists: - self.msg = "Site '{0}' does not exist in the Cisco Catalyst Center, cannot proceed with device(s) retrieval.".format(site_name) + self.msg = "Site '{0}' does not exist in the Cisco Catalyst Center, cannot proceed with device(s) retrieval.".format( + site_name) self.fail_and_exit(self.msg) - self.log("Initiating retrieval of device details for site ID: '{0}'.".format(site_id), "INFO") + self.log("Initiating retrieval of device details for site ID: '{0}'.".format( + site_id), "INFO") # Retrieve the list of device details from the specified site - device_details_list = self.get_device_details_from_site(site_name, site_id) - self.log("Device details retrieved for site ID: '{0}': {1}".format(site_id, device_details_list), "DEBUG") + device_details_list = self.get_device_details_from_site( + site_name, site_id) + self.log("Device details retrieved for site ID: '{0}': {1}".format( + site_id, device_details_list), "DEBUG") # Iterate through each device's details for device_info in device_details_list: @@ -773,7 +825,7 @@ def get_reachable_devices_from_site(self, site_name): # Check if the device is reachable and managed if reachability_status == "Reachable" and collection_status == "Managed": # Exclude Unified AP devices - if device_family != "Unified AP" : + if device_family != "Unified AP": mgmt_ip_to_instance_id_map[management_ip] = instance_uuid else: skipped_devices_list.append(management_ip) @@ -789,7 +841,8 @@ def get_reachable_devices_from_site(self, site_name): self.log(msg, "WARNING") if not mgmt_ip_to_instance_id_map: - self.log("No reachable devices found at Site: {0}".format(site_id), "INFO") + self.log("No reachable devices found at Site: {0}".format( + site_id), "INFO") return mgmt_ip_to_instance_id_map, skipped_devices_list @@ -806,17 +859,22 @@ def get_site(self, site_name): - If the response is empty, a warning is logged. - Any exceptions during the API call are caught, logged as errors, and the function returns None. """ - self.log("Initiating retrieval of site details for site name: '{0}'.".format(site_name), "DEBUG") + self.log("Initiating retrieval of site details for site name: '{0}'.".format( + site_name), "DEBUG") # Determine API call based on dnac_version if self.dnac_version <= self.version_2_3_5_3: - self.log("Using 'get_site' API for Catalyst Center version: '{0}'.".format(self.dnac_version), "DEBUG") + self.log("Using 'get_site' API for Catalyst Center version: '{0}'.".format( + self.dnac_version), "DEBUG") get_site_params = {"name": site_name} - response = self.execute_get_request("sites", "get_site", get_site_params) + response = self.execute_get_request( + "sites", "get_site", get_site_params) else: - self.log("Using 'get_sites' API for Catalyst Center version: '{0}'.".format(self.dnac_version), "DEBUG") + self.log("Using 'get_sites' API for Catalyst Center version: '{0}'.".format( + self.dnac_version), "DEBUG") get_sites_params = {"name_hierarchy": site_name} - response = self.execute_get_request("site_design", "get_sites", get_sites_params) + response = self.execute_get_request( + "site_design", "get_sites", get_sites_params) return response @@ -839,10 +897,12 @@ def get_site_id(self, site_name): # Check if the response is empty if response is None: - self.msg = "No site details retrieved for site name: {0}".format(site_name) + self.msg = "No site details retrieved for site name: {0}".format( + site_name) self.fail_and_exit(self.msg) - self.log("Site details retrieved for site '{0}'': {1}".format(site_name, str(response)), "DEBUG") + self.log("Site details retrieved for site '{0}'': {1}".format( + site_name, str(response)), "DEBUG") site = response.get("response") site_id = site[0].get("id") site_exists = True @@ -875,7 +935,8 @@ def assign_device_to_site(self, device_ids, site_name, site_id): site_type = site_response["response"][0].get("type") if site_type not in ("building", "floor"): self.msg = "Device(s) can only be assigned to building/floor" - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() if self.get_ccc_version_as_integer() <= self.get_ccc_version_as_int_from_str("2.3.5.3"): try: @@ -889,10 +950,12 @@ def assign_device_to_site(self, device_ids, site_name, site_id): }, ) - self.check_execution_response_status(response, "assign_devices_to_site") + self.check_execution_response_status( + response, "assign_devices_to_site") if self.status == "success": self.result["changed"] = True - self.result['msg'] = "Successfully assigned device(s) {0} to site {1}.".format(str(device_ids), site_name) + self.result['msg'] = "Successfully assigned device(s) {0} to site {1}.".format( + str(device_ids), site_name) self.result['response'] = response.get("executionId") self.log(self.result['msg'], "INFO") return self @@ -920,7 +983,8 @@ def assign_device_to_site(self, device_ids, site_name, site_id): self.log("Received API response from 'assign_network_device_to_site' while assigning devices to site: {0}, {1}, {2}".format( site_name, str(assign_network_device_to_site), str(response["response"])), "INFO") - self.check_tasks_response_status(response, api_name='assign_device_to_site') + self.check_tasks_response_status( + response, api_name='assign_device_to_site') if self.result["changed"]: return True @@ -1006,7 +1070,8 @@ def camel_to_snake_case(self, config): for key, value in config.items(): new_key = re.sub(r'([a-z0-9])([A-Z])', r'\1_\2', key).lower() if new_key != key: - self.log("{0} will be deprecated soon. Please use {1}.".format(key, new_key), "DEBUG") + self.log("{0} will be deprecated soon. Please use {1}.".format( + key, new_key), "DEBUG") new_value = self.camel_to_snake_case(value) new_config[new_key] = new_value elif isinstance(config, list): @@ -1030,7 +1095,8 @@ def update_site_type_key(self, config): if key == "site_type": new_key = "type" else: - new_key = re.sub(r'([a-z0-9])([A-Z])', r'\1_\2', key).lower() + new_key = re.sub(r'([a-z0-9])([A-Z])', + r'\1_\2', key).lower() new_value = self.update_site_type_key(value) new_config[new_key] = new_value elif isinstance(config, list): @@ -1053,7 +1119,8 @@ def get_device_ips_from_hostnames(self, hostnames): list of hostnames. If a device is not found in Cisco Catalyst Center, an error log message is printed. """ - self.log("Entering 'get_device_ips_from_hostnames' with hostname_list: {0}".format(str(hostnames)), "INFO") + self.log("Entering 'get_device_ips_from_hostnames' with hostname_list: {0}".format( + str(hostnames)), "INFO") device_ip_mapping = {} for hostname in hostnames: @@ -1065,29 +1132,36 @@ def get_device_ips_from_hostnames(self, hostnames): params={"hostname": hostname} ) if response: - self.log("Received API response for hostname '{0}': {1}".format(hostname, str(response)), "DEBUG") + self.log("Received API response for hostname '{0}': {1}".format( + hostname, str(response)), "DEBUG") response = response.get("response") if response: device_ip = response[0]["managementIpAddress"] if device_ip: device_ip_mapping[hostname] = device_ip - self.log("Added device IP '{0}' for hostname '{1}'.".format(device_ip, hostname), "INFO") + self.log("Added device IP '{0}' for hostname '{1}'.".format( + device_ip, hostname), "INFO") else: device_ip_mapping[hostname] = None - self.log("No management IP found for hostname '{0}'.".format(hostname), "WARNING") + self.log("No management IP found for hostname '{0}'.".format( + hostname), "WARNING") else: device_ip_mapping[hostname] = None - self.log("No response received for hostname '{0}'.".format(hostname), "WARNING") + self.log("No response received for hostname '{0}'.".format( + hostname), "WARNING") else: device_ip_mapping[hostname] = None - self.log("No response received from 'get_device_list' for hostname '{0}'.".format(hostname), "ERROR") + self.log("No response received from 'get_device_list' for hostname '{0}'.".format( + hostname), "ERROR") except Exception as e: - error_message = "Exception occurred while fetching device IP for hostname '{0}': {1}".format(hostname, str(e)) + error_message = "Exception occurred while fetching device IP for hostname '{0}': {1}".format( + hostname, str(e)) self.log(error_message, "ERROR") device_ip_mapping[hostname] = None - self.log("Exiting 'get_device_ips_from_hostnames' with device IP mapping: {0}".format(device_ip_mapping), "INFO") + self.log("Exiting 'get_device_ips_from_hostnames' with device IP mapping: {0}".format( + device_ip_mapping), "INFO") return device_ip_mapping def get_device_ips_from_serial_numbers(self, serial_numbers): @@ -1103,12 +1177,14 @@ def get_device_ips_from_serial_numbers(self, serial_numbers): serial numbers.If a device is not found in Cisco Catalyst Center, an error log message is printed. """ - self.log("Entering 'get_device_ips_from_serial_numbers' with serial_numbers: {0}".format(str(serial_numbers)), "INFO") + self.log("Entering 'get_device_ips_from_serial_numbers' with serial_numbers: {0}".format( + str(serial_numbers)), "INFO") device_ip_mapping = {} for serial_number in serial_numbers: try: - self.log("Fetching device info for serial number: {0}".format(serial_number), "INFO") + self.log("Fetching device info for serial number: {0}".format( + serial_number), "INFO") response = self.dnac._exec( family="devices", function='get_device_list', @@ -1116,29 +1192,36 @@ def get_device_ips_from_serial_numbers(self, serial_numbers): params={"serialNumber": serial_number} ) if response: - self.log("Received API response for serial number '{0}': {1}".format(serial_number, str(response)), "DEBUG") + self.log("Received API response for serial number '{0}': {1}".format( + serial_number, str(response)), "DEBUG") response = response.get("response") if response: device_ip = response[0]["managementIpAddress"] if device_ip: device_ip_mapping[serial_number] = device_ip - self.log("Added device IP '{0}' for serial number '{1}'.".format(device_ip, serial_number), "INFO") + self.log("Added device IP '{0}' for serial number '{1}'.".format( + device_ip, serial_number), "INFO") else: device_ip_mapping[serial_number] = None - self.log("No management IP found for serial number '{0}'.".format(serial_number), "WARNING") + self.log("No management IP found for serial number '{0}'.".format( + serial_number), "WARNING") else: device_ip_mapping[serial_number] = None - self.log("No response received for serial number '{0}'.".format(serial_number), "WARNING") + self.log("No response received for serial number '{0}'.".format( + serial_number), "WARNING") else: device_ip_mapping[serial_number] = None - self.log("No response received from 'get_device_list' for serial number '{0}'.".format(serial_number), "ERROR") + self.log("No response received from 'get_device_list' for serial number '{0}'.".format( + serial_number), "ERROR") except Exception as e: - error_message = "Exception occurred while fetching device IP for serial number '{0}': {1}".format(serial_number, str(e)) + error_message = "Exception occurred while fetching device IP for serial number '{0}': {1}".format( + serial_number, str(e)) self.log(error_message, "ERROR") device_ip_mapping[serial_number] = None - self.log("Exiting 'get_device_ips_from_serial_numbers' with device IP mapping: {0}".format(device_ip_mapping), "INFO") + self.log("Exiting 'get_device_ips_from_serial_numbers' with device IP mapping: {0}".format( + device_ip_mapping), "INFO") return device_ip_mapping def get_device_ips_from_mac_addresses(self, mac_addresses): @@ -1154,12 +1237,14 @@ def get_device_ips_from_mac_addresses(self, mac_addresses): mac addresses. If a device is not found in Cisco Catalyst Center, an error log message is printed. """ - self.log("Entering 'get_device_ips_from_mac_addresses' with mac_addresses: {0}".format(str(mac_addresses)), "INFO") + self.log("Entering 'get_device_ips_from_mac_addresses' with mac_addresses: {0}".format( + str(mac_addresses)), "INFO") device_ip_mapping = {} for mac_address in mac_addresses: try: - self.log("Fetching device info for mac_address: {0}".format(mac_address), "INFO") + self.log("Fetching device info for mac_address: {0}".format( + mac_address), "INFO") response = self.dnac._exec( family="devices", function='get_device_list', @@ -1167,29 +1252,36 @@ def get_device_ips_from_mac_addresses(self, mac_addresses): params={"macAddress": mac_address} ) if response: - self.log("Received API response for mac address '{0}': {1}".format(mac_address, str(response)), "DEBUG") + self.log("Received API response for mac address '{0}': {1}".format( + mac_address, str(response)), "DEBUG") response = response.get("response") if response: device_ip = response[0]["managementIpAddress"] if device_ip: device_ip_mapping[mac_address] = device_ip - self.log("Added device IP '{0}' for mac address '{1}'.".format(device_ip, mac_address), "INFO") + self.log("Added device IP '{0}' for mac address '{1}'.".format( + device_ip, mac_address), "INFO") else: device_ip_mapping[mac_address] = None - self.log("No management IP found for mac address '{0}'.".format(mac_address), "WARNING") + self.log("No management IP found for mac address '{0}'.".format( + mac_address), "WARNING") else: device_ip_mapping[mac_address] = None - self.log("No response received for mac address '{0}'.".format(mac_address), "WARNING") + self.log("No response received for mac address '{0}'.".format( + mac_address), "WARNING") else: device_ip_mapping[mac_address] = None - self.log("No response received from 'get_device_list' for mac address '{0}'.".format(mac_address), "ERROR") + self.log("No response received from 'get_device_list' for mac address '{0}'.".format( + mac_address), "ERROR") except Exception as e: - error_message = "Exception occurred while fetching device IP for mac address '{0}': {1}".format(mac_address, str(e)) + error_message = "Exception occurred while fetching device IP for mac address '{0}': {1}".format( + mac_address, str(e)) self.log(error_message, "ERROR") device_ip_mapping[mac_address] = None - self.log("Exiting 'get_device_ips_from_mac_addresses' with device IP mapping: {0}".format(device_ip_mapping), "INFO") + self.log("Exiting 'get_device_ips_from_mac_addresses' with device IP mapping: {0}".format( + device_ip_mapping), "INFO") return device_ip_mapping def get_device_ids_from_device_ips(self, device_ips): @@ -1205,12 +1297,14 @@ def get_device_ids_from_device_ips(self, device_ips): list of hostnames. If a device is not found in Cisco Catalyst Center, an error log message is printed. """ - self.log("Entering 'get_device_ids_from_device_ips' with device ips: {0}".format(str(device_ips)), "INFO") + self.log("Entering 'get_device_ids_from_device_ips' with device ips: {0}".format( + str(device_ips)), "INFO") device_id_mapping = {} for device_ip in device_ips: try: - self.log("Fetching device id for device ip: {0}".format(device_ip), "INFO") + self.log("Fetching device id for device ip: {0}".format( + device_ip), "INFO") response = self.dnac._exec( family="devices", function='get_device_list', @@ -1218,29 +1312,36 @@ def get_device_ids_from_device_ips(self, device_ips): params={"management_ip_address": device_ip} ) if response: - self.log("Received API response for device ip '{0}': {1}".format(device_ip, str(response)), "DEBUG") + self.log("Received API response for device ip '{0}': {1}".format( + device_ip, str(response)), "DEBUG") response = response.get("response") if response: device_id = response[0]["id"] if device_id: device_id_mapping[device_ip] = device_id - self.log("Added device ID '{0}' for device ip '{1}'.".format(device_id, device_ip), "INFO") + self.log("Added device ID '{0}' for device ip '{1}'.".format( + device_id, device_ip), "INFO") else: device_id_mapping[device_ip] = None - self.log("No device ID found for device ip '{0}'.".format(device_ip), "WARNING") + self.log("No device ID found for device ip '{0}'.".format( + device_ip), "WARNING") else: device_id_mapping[device_ip] = None - self.log("No response received for device ip '{0}'.".format(device_ip), "WARNING") + self.log("No response received for device ip '{0}'.".format( + device_ip), "WARNING") else: device_id_mapping[device_ip] = None - self.log("No response received from 'get_device_list' for device ip '{0}'.".format(device_ip), "ERROR") + self.log("No response received from 'get_device_list' for device ip '{0}'.".format( + device_ip), "ERROR") except Exception as e: - error_message = "Exception occurred while fetching device ID for device ip '{0}': {1}".format(device_ip, str(e)) + error_message = "Exception occurred while fetching device ID for device ip '{0}': {1}".format( + device_ip, str(e)) self.log(error_message, "ERROR") device_id_mapping[device_ip] = None - self.log("Exiting 'get_device_ids_from_device_ips' with unique device ID mapping: {0}".format(device_id_mapping), "INFO") + self.log("Exiting 'get_device_ids_from_device_ips' with unique device ID mapping: {0}".format( + device_id_mapping), "INFO") return device_id_mapping def get_device_ips_from_device_ids(self, device_ids): @@ -1257,12 +1358,14 @@ def get_device_ips_from_device_ids(self, device_ids): or an exception occurs, it logs the error or warning and continues to the next device ID. """ - self.log("Entering 'get_device_ips_from_device_ids' with device ips: {0}".format(str(device_ids)), "INFO") + self.log("Entering 'get_device_ips_from_device_ids' with device ips: {0}".format( + str(device_ids)), "INFO") device_ip_mapping = {} for device_id in device_ids: try: - self.log("Fetching device ip for device id: {0}".format(device_id), "INFO") + self.log("Fetching device ip for device id: {0}".format( + device_id), "INFO") response = self.dnac._exec( family="devices", function='get_device_list', @@ -1270,29 +1373,36 @@ def get_device_ips_from_device_ids(self, device_ids): params={"id": device_id} ) if response: - self.log("Received API response for device id '{0}': {1}".format(device_id, str(response)), "DEBUG") + self.log("Received API response for device id '{0}': {1}".format( + device_id, str(response)), "DEBUG") response = response.get("response") if response: device_ip = response[0]["managementIpAddress"] if device_ip: device_ip_mapping[device_id] = device_ip - self.log("Added device IP '{0}' for device id '{1}'.".format(device_ip, device_id), "INFO") + self.log("Added device IP '{0}' for device id '{1}'.".format( + device_ip, device_id), "INFO") else: device_ip_mapping[device_id] = None - self.log("No device ID found for device id '{0}'.".format(device_id), "WARNING") + self.log("No device ID found for device id '{0}'.".format( + device_id), "WARNING") else: device_ip_mapping[device_id] = None - self.log("No response received for device id '{0}'.".format(device_id), "WARNING") + self.log("No response received for device id '{0}'.".format( + device_id), "WARNING") else: device_ip_mapping[device_id] = None - self.log("No response received from 'get_device_list' for device id '{0}'.".format(device_id), "ERROR") + self.log("No response received from 'get_device_list' for device id '{0}'.".format( + device_id), "ERROR") except Exception as e: - error_message = "Exception occurred while fetching device ip for device id '{0}': {1}".format(device_id, str(e)) + error_message = "Exception occurred while fetching device ip for device id '{0}': {1}".format( + device_id, str(e)) self.log(error_message, "ERROR") device_ip_mapping[device_id] = None - self.log("Exiting 'get_device_ips_from_device_ids' with device IP mapping: '{0}'".format(device_ip_mapping), "INFO") + self.log("Exiting 'get_device_ips_from_device_ids' with device IP mapping: '{0}'".format( + device_ip_mapping), "INFO") return device_ip_mapping def get_network_device_tag_id(self, tag_name): @@ -1311,7 +1421,8 @@ def get_network_device_tag_id(self, tag_name): it logs appropriate messages and returns `None`. """ - self.log("Entering 'get_network_device_tag_id' with tag_name: '{0}'".format(tag_name), "INFO") + self.log("Entering 'get_network_device_tag_id' with tag_name: '{0}'".format( + tag_name), "INFO") device_tag_id = None try: @@ -1322,27 +1433,33 @@ def get_network_device_tag_id(self, tag_name): params={"name": tag_name} ) if not response: - self.log("No response received from 'get_tag' for tag '{0}'.".format(tag_name), "WARNING") + self.log("No response received from 'get_tag' for tag '{0}'.".format( + tag_name), "WARNING") return device_tag_id response_data = response.get("response") if not response_data: - self.log("Unable to fetch the tag details for the tag '{0}'.".format(tag_name), "WARNING") + self.log("Unable to fetch the tag details for the tag '{0}'.".format( + tag_name), "WARNING") return device_tag_id - self.log("Received API response from 'get_tag': {0}".format(str(response_data)), "DEBUG") + self.log("Received API response from 'get_tag': {0}".format( + str(response_data)), "DEBUG") device_tag_id = response_data[0]["id"] if device_tag_id: - self.log("Received the tag ID '{0}' for the tag: {1}".format(device_tag_id, tag_name), "INFO") + self.log("Received the tag ID '{0}' for the tag: {1}".format( + device_tag_id, tag_name), "INFO") else: - self.log("Tag ID not found in the response for tag '{0}'.".format(tag_name), "WARNING") + self.log("Tag ID not found in the response for tag '{0}'.".format( + tag_name), "WARNING") except Exception as e: self.msg = ( "Exception occurred while fetching tag id for the tag '{0} 'from " "Cisco Catalyst Center: {1}" ).format(tag_name, str(e)) - self.set_operation_result("failed", False, self.msg, "INFO").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "INFO").check_return_status() return device_tag_id @@ -1367,17 +1484,20 @@ def get_list_from_dict_values(self, dict_name): for key, value in dict_name.items(): try: if value is None: - self.log("Value for the key {0} is None so not including in the list.".format(key), "DEBUG") + self.log("Value for the key {0} is None so not including in the list.".format( + key), "DEBUG") continue else: - self.log("Fetch the value '{0}' for the key '{1}'".format(value, key), "DEBUG") + self.log("Fetch the value '{0}' for the key '{1}'".format( + value, key), "DEBUG") values_list.append(value) except Exception as e: self.msg = ( "Exception occurred while fetching value for the key '{0} 'from " "Cisco Catalyst Center: {1}" ).format(key, str(e)) - self.set_operation_result("failed", False, self.msg, "INFO").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "INFO").check_return_status() return values_list @@ -1466,7 +1586,8 @@ def pprint(self, jsondata): try: return json.dumps(jsondata, indent=4, separators=(',', ': ')) except (TypeError, ValueError) as e: - raise TypeError("Invalid input for JSON serialization: {0}".format(str(e))) + raise TypeError( + "Invalid input for JSON serialization: {0}".format(str(e))) def check_status_api_events(self, status_execution_id): """ @@ -1501,7 +1622,8 @@ def check_status_api_events(self, status_execution_id): op_modifies=True, params={"execution_id": status_execution_id} ) - self.log("Received API response from 'get_status_api_for_events': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_status_api_for_events': {0}".format( + str(response)), "DEBUG") if response['apiStatus'] != "IN_PROGRESS": events_response = response break @@ -1528,9 +1650,11 @@ def is_valid_server_address(self, server_address): # Define the regex for a valid hostname hostname_regex = re.compile( r'^(' # Start of the string - r'([A-Za-z0-9]+([A-Za-z0-9-]*[A-Za-z0-9])?\.)+[A-Za-z]{2,6}|' # Domain name (e.g., example.com) + # Domain name (e.g., example.com) + r'([A-Za-z0-9]+([A-Za-z0-9-]*[A-Za-z0-9])?\.)+[A-Za-z]{2,6}|' r'localhost|' # Localhost - r'(\d{1,3}\.)+\d{1,3}|' # Custom IPv4-like format (e.g., 2.2.3.31.3.4.4) + # Custom IPv4-like format (e.g., 2.2.3.31.3.4.4) + r'(\d{1,3}\.)+\d{1,3}|' r'[A-Fa-f0-9:]+$' # IPv6 address (e.g., 2f8:192:3::40:41:41:42) r')$' # End of the string ) @@ -1554,7 +1678,8 @@ def is_path_exists(self, file_path): final_file_path = os.path.join(current_working_directory, file_path) self.log(str(final_file_path)) if not os.path.exists(final_file_path): - self.log("The specified path '{0}' is not valid. Please provide a valid path.".format(final_file_path), "ERROR") + self.log("The specified path '{0}' is not valid. Please provide a valid path.".format( + final_file_path), "ERROR") return False return True @@ -1574,7 +1699,8 @@ def is_json(self, file_path): return True except (ValueError, FileNotFoundError): - self.log("The provided file '{0}' is not in JSON format".format(file_path), "CRITICAL") + self.log("The provided file '{0}' is not in JSON format".format( + file_path), "CRITICAL") return False def check_task_tree_response(self, task_id): @@ -1628,11 +1754,13 @@ def get_task_details_by_id(self, task_id): params={"id": task_id} ) if not isinstance(response, dict): - self.log("Invalid response received when fetching task details for task ID: {}".format(task_id), "ERROR") + self.log("Invalid response received when fetching task details for task ID: {}".format( + task_id), "ERROR") return task_details task_details = response.get("response") - self.log("Task Details: {task_details}".format(task_details=task_details), "DEBUG") + self.log("Task Details: {task_details}".format( + task_details=task_details), "DEBUG") except Exception as e: # Log an error message and fail if an exception occurs self.log_traceback() @@ -1669,7 +1797,8 @@ def get_tasks_by_id(self, task_id): .format(task_id, response), "DEBUG") if not isinstance(response, dict): - self.log("Failed to retrieve task details for task ID: {}".format(task_id), "ERROR") + self.log("Failed to retrieve task details for task ID: {}".format( + task_id), "ERROR") return task_status task_status = response.get('response') @@ -1722,7 +1851,8 @@ def check_tasks_response_status(self, response, api_name): if elapsed_time >= self.max_timeout: self.msg = "Max timeout of {0} sec has reached for the task id '{1}'. " \ .format(self.max_timeout, task_id) + \ - "Exiting the loop due to unexpected API '{0}' status.".format(api_name) + "Exiting the loop due to unexpected API '{0}' status.".format( + api_name) self.log(self.msg, "WARNING") self.status = "failed" break @@ -1875,7 +2005,8 @@ def execute_get_request(self, api_family, api_function, api_parameters): self.log_traceback() self.msg = ( "An error occurred while executing GET API call to Function: '{0}' from Family: '{1}'. " - "Parameters: {2}. Exception: {3}.".format(api_function, api_family, api_parameters, str(e)) + "Parameters: {2}. Exception: {3}.".format( + api_function, api_family, api_parameters, str(e)) ) self.fail_and_exit(self.msg) @@ -1889,7 +2020,8 @@ def get_taskid_post_api_call(self, api_family, api_function, api_parameters): """ try: - self.log("Requested payload for the the function: '{0}' is: '{1}'".format(api_function, api_parameters), "INFO") + self.log("Requested payload for the the function: '{0}' is: '{1}'".format( + api_function, api_parameters), "INFO") # Execute the API call response = self.dnac._exec( @@ -1931,7 +2063,8 @@ def get_taskid_post_api_call(self, api_family, api_function, api_parameters): self.log_traceback() self.msg = ( "An error occurred while executing API call to Function: '{0}' from Family: '{1}'. " - "Parameters: {2}. Exception: {3}.".format(api_function, api_family, api_parameters, str(e)) + "Parameters: {2}. Exception: {3}.".format( + api_function, api_family, api_parameters, str(e)) ) self.fail_and_exit(self.msg) @@ -1949,18 +2082,21 @@ def get_task_status_from_tasks_by_id(self, task_id, task_name, success_msg): self: The instance of the class with updated status and message. """ loop_start_time = time.time() - self.log("Starting task monitoring for '{0}' with task ID '{1}'.".format(task_name, task_id), "DEBUG") + self.log("Starting task monitoring for '{0}' with task ID '{1}'.".format( + task_name, task_id), "DEBUG") while True: response = self.get_tasks_by_id(task_id) # Check if response is returned if not response: - self.msg = "Error retrieving task status for '{0}' with task ID '{1}'".format(task_name, task_id) + self.msg = "Error retrieving task status for '{0}' with task ID '{1}'".format( + task_name, task_id) self.set_operation_result("failed", False, self.msg, "ERROR") break - self.log("Successfully retrieved task details: {0}".format(response), "INFO") + self.log("Successfully retrieved task details: {0}".format( + response), "INFO") status = response.get("status") end_time = response.get("endTime") @@ -1979,31 +2115,39 @@ def get_task_status_from_tasks_by_id(self, task_id, task_name, success_msg): # Check if the task has completed (either success or failure) if end_time: if status == "FAILURE": - get_task_details_response = self.get_task_details_by_id(task_id) - failure_reason = get_task_details_response.get("failureReason") + get_task_details_response = self.get_task_details_by_id( + task_id) + failure_reason = get_task_details_response.get( + "failureReason") if failure_reason: self.msg = ( "Failed to execute the task {0} with Task ID: {1}." - "Failure reason: {2}".format(task_name, task_id, failure_reason) + "Failure reason: {2}".format( + task_name, task_id, failure_reason) ) else: self.msg = ( - "Failed to execute the task {0} with Task ID: {1}.".format(task_name, task_id) + "Failed to execute the task {0} with Task ID: {1}.".format( + task_name, task_id) ).format(task_name, task_id) - self.set_operation_result("failed", False, self.msg, "ERROR") + self.set_operation_result( + "failed", False, self.msg, "ERROR") break elif status == "SUCCESS": self.msg = success_msg - self.set_operation_result("success", True, self.msg, "INFO") + self.set_operation_result( + "success", True, self.msg, "INFO") break # Wait for the specified poll interval before the next check poll_interval = self.params.get("dnac_task_poll_interval") - self.log("Waiting for the next poll interval of {0} seconds before checking task status again.".format(poll_interval), "DEBUG") + self.log("Waiting for the next poll interval of {0} seconds before checking task status again.".format( + poll_interval), "DEBUG") time.sleep(poll_interval) total_elapsed_time = time.time() - loop_start_time - self.log("Completed monitoring task '{0}' with task ID '{1}' after {2:.2f} seconds.".format(task_name, task_id, total_elapsed_time), "DEBUG") + self.log("Completed monitoring task '{0}' with task ID '{1}' after {2:.2f} seconds.".format( + task_name, task_id, total_elapsed_time), "DEBUG") return self def get_task_status_from_task_by_id(self, task_id, task_name, failure_msg, success_msg, progress_validation=None, data_validation=None): @@ -2020,7 +2164,8 @@ def get_task_status_from_task_by_id(self, task_id, task_name, failure_msg, succe self: The instance of the class. """ loop_start_time = time.time() - self.log("Starting task monitoring for '{0}' with task ID '{1}'.".format(task_name, task_id), "DEBUG") + self.log("Starting task monitoring for '{0}' with task ID '{1}'.".format( + task_name, task_id), "DEBUG") while True: # Retrieve task details by task ID @@ -2028,7 +2173,8 @@ def get_task_status_from_task_by_id(self, task_id, task_name, failure_msg, succe # Check if response is returned if not response: - self.msg = "Error retrieving task status for '{0}' with task ID '{1}'".format(task_name, task_id) + self.msg = "Error retrieving task status for '{0}' with task ID '{1}'".format( + task_name, task_id) self.set_operation_result("failed", False, self.msg, "ERROR") break @@ -2041,7 +2187,8 @@ def get_task_status_from_task_by_id(self, task_id, task_name, failure_msg, succe self.set_operation_result("failed", False, self.msg, "ERROR") break - self.log("Successfully retrieved task details: {0}".format(response), "INFO") + self.log("Successfully retrieved task details: {0}".format( + response), "INFO") # Check if the elapsed time exceeds the timeout elapsed_time = time.time() - loop_start_time @@ -2058,29 +2205,34 @@ def get_task_status_from_task_by_id(self, task_id, task_name, failure_msg, succe data = response.get("data") progress = response.get("progress") end_time = response.get("endTime") - self.log("Current task progress for '{0}': {1}, Data: {2}".format(task_name, progress, data), "INFO") + self.log("Current task progress for '{0}': {1}, Data: {2}".format( + task_name, progress, data), "INFO") # Validate task data or progress if validation keys are provided if end_time: if data_validation and data_validation in data: self.msg = success_msg - self.set_operation_result("success", True, self.msg, "INFO") + self.set_operation_result( + "success", True, self.msg, "INFO") self.log(self.msg, "INFO") break if progress_validation and progress_validation in progress: self.msg = success_msg - self.set_operation_result("success", True, self.msg, "INFO") + self.set_operation_result( + "success", True, self.msg, "INFO") self.log(self.msg, "INFO") break # Wait for the specified poll interval before the next check poll_interval = self.params.get("dnac_task_poll_interval") - self.log("Waiting for the next poll interval of {0} seconds before checking task status again.".format(poll_interval), "DEBUG") + self.log("Waiting for the next poll interval of {0} seconds before checking task status again.".format( + poll_interval), "DEBUG") time.sleep(poll_interval) total_elapsed_time = time.time() - loop_start_time - self.log("Completed monitoring task '{0}' with task ID '{1}' after {2:.2f} seconds.".format(task_name, task_id, total_elapsed_time), "DEBUG") + self.log("Completed monitoring task '{0}' with task ID '{1}' after {2:.2f} seconds.".format( + task_name, task_id, total_elapsed_time), "DEBUG") return self def requires_update(self, have, want, obj_params): @@ -2115,8 +2267,10 @@ def requires_update(self, have, want, obj_params): current_obj = have requested_obj = want - self.log("Current State (have): {current_obj}".format(current_obj=current_obj), "DEBUG") - self.log("Desired State (want): {requested_obj}".format(requested_obj=requested_obj), "DEBUG") + self.log("Current State (have): {current_obj}".format( + current_obj=current_obj), "DEBUG") + self.log("Desired State (want): {requested_obj}".format( + requested_obj=requested_obj), "DEBUG") return any(not dnac_compare_equality(current_obj.get(dnac_param), requested_obj.get(ansible_param)) @@ -2168,7 +2322,8 @@ def dnac_compare_equality(current_value, requested_value): if current_value is None: return True if isinstance(current_value, dict) and isinstance(requested_value, dict): - all_dict_params = list(current_value.keys()) + list(requested_value.keys()) + all_dict_params = list(current_value.keys()) + \ + list(requested_value.keys()) return not any((not fn_comp_key(param, current_value, requested_value) for param in all_dict_params)) elif isinstance(current_value, list) and isinstance(requested_value, list): return compare_list(current_value, requested_value) @@ -2245,7 +2400,8 @@ def validate_str(item, param_spec, param_name, invalid_params): else: invalid_params.append( "{0}:{1} : The string exceeds the allowed " - "range of max {2} char".format(param_name, item, param_spec.get("length_max")) + "range of max {2} char".format( + param_name, item, param_spec.get("length_max")) ) return item @@ -2275,7 +2431,8 @@ def validate_integer_within_range(item, param_spec, param_name, invalid_params): try: item = validation.check_type_int(item) except TypeError as e: - invalid_params.append("{0}: value: {1} {2}".format(param_name, item, str(e))) + invalid_params.append( + "{0}: value: {1} {2}".format(param_name, item, str(e))) return item min_value = param_spec.get("range_min", 1) @@ -2339,14 +2496,17 @@ def validate_list(item, param_spec, param_name, invalid_params): for element in item: if type(element).__name__ != get_spec_element: invalid_params.append( - "{0} is not of the same datatype as expected which is {1}".format(element, get_spec_element) + "{0} is not of the same datatype as expected which is {1}".format( + element, get_spec_element) ) else: invalid_params.append( - "{0} is not of the same datatype as expected which is {1}".format(item, get_spec_type) + "{0} is not of the same datatype as expected which is {1}".format( + item, get_spec_type) ) except Exception as e: - item, list_invalid_params = validate_list_of_dicts(item, temp_dict) + item, list_invalid_params = validate_list_of_dicts( + item, temp_dict) invalid_params.extend(list_invalid_params) else: invalid_params.append("{0} : is not a valid list".format(item)) @@ -2394,7 +2554,8 @@ def validate_list_of_dicts(param_list, spec, module=None): valid_params_dict = {} if not spec: # Handle the case when spec becomes empty but param list is still there - invalid_params.append("No more spec to validate, but parameters remain") + invalid_params.append( + "No more spec to validate, but parameters remain") break for param in spec: item = list_entry.get(param) @@ -2421,7 +2582,8 @@ def validate_list_of_dicts(param_list, spec, module=None): item = validator(item, spec[param], param, invalid_params) else: invalid_params.append( - "{0}:{1} : Unsupported data type {2}.".format(param, item, data_type) + "{0}:{1} : Unsupported data type {2}.".format( + param, item, data_type) ) choice = spec[param].get("choices") @@ -2470,7 +2632,8 @@ def __init__(self, params): if params.get("dnac_debug") and LOGGING_IN_STANDARD: self.logger.addHandler(logging.StreamHandler()) else: - self.fail_json(msg="DNA Center Python SDK is not installed. Execute 'pip install dnacentersdk'") + self.fail_json( + msg="DNA Center Python SDK is not installed. Execute 'pip install dnacentersdk'") def changed(self): self.result["changed"] = True @@ -2527,7 +2690,8 @@ def _exec(self, family, function, params=None, op_modifies=False, **kwargs): if isinstance(params.get(key), str) and self.is_file(params[key]): file_name = self.extract_file_name(params[key]) file_path = params[key] - multipart_fields[value] = (file_name, open(file_path, 'rb')) + multipart_fields[value] = ( + file_name, open(file_path, 'rb')) params.setdefault("multipart_fields", multipart_fields) params.setdefault("multipart_monitor_callback", None) @@ -2548,14 +2712,16 @@ def _exec(self, family, function, params=None, op_modifies=False, **kwargs): ) while True: - execution_details = exec_details_func(**exec_details_params) + execution_details = exec_details_func( + **exec_details_params) if execution_details.get("status") == "SUCCESS": break bapi_error = execution_details.get("bapiError") if bapi_error: if RATE_LIMIT_MESSAGE in bapi_error: - self.logger.warning("!!!!! %s !!!!!", RATE_LIMIT_MESSAGE) + self.logger.warning( + "!!!!! %s !!!!!", RATE_LIMIT_MESSAGE) time.sleep(RATE_LIMIT_RETRY_AFTER) return self._exec( family_name, function_name, params, op_modifies, **kwargs diff --git a/plugins/modules/accesspoint_workflow_manager.py b/plugins/modules/accesspoint_workflow_manager.py index 11b24c9d9a..c8006ee88d 100644 --- a/plugins/modules/accesspoint_workflow_manager.py +++ b/plugins/modules/accesspoint_workflow_manager.py @@ -4,8 +4,18 @@ # 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 +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + validate_str, + get_dict_result, +) +import re +import time __metaclass__ = type -__author__ = ("A Mohamed Rafeek, Megha Kandari, Sonali Deepthi Kesali, Natarajan, Madhan Sankaranarayanan, Abhishek Maheshwari") +__author__ = ( + "A Mohamed Rafeek, Megha Kandari, Sonali Deepthi Kesali, Natarajan, Madhan Sankaranarayanan, Abhishek Maheshwari") DOCUMENTATION = r""" --- @@ -1649,17 +1659,6 @@ """ -import time -import re -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - validate_str, - get_dict_result, -) -from ansible.module_utils.basic import AnsibleModule - - class Accesspoint(DnacBase): """Class containing member attributes for DNAC Access Point Automation module""" @@ -1766,7 +1765,8 @@ def validate_input_yml(self): "channel_width": {"required": False, "type": "str"}, "radio_band": {"required": False, "type": "str"} } - ap_list = self.update_site_type_key(self.camel_to_snake_case(self.payload.get("config"))) + ap_list = self.update_site_type_key( + self.camel_to_snake_case(self.payload.get("config"))) invalid_list_radio = [] for each_ap in ap_list: @@ -1774,11 +1774,14 @@ def validate_input_yml(self): radio_config = each_ap.get(each_radio) if radio_config: valid_param_radio, invalid_params_radio = \ - validate_list_of_dicts([radio_config], radio_config_spec) + validate_list_of_dicts( + [radio_config], radio_config_spec) if len(invalid_params_radio) > 0: - invalid_list_radio.append(each_radio + str(invalid_params_radio)) + invalid_list_radio.append( + each_radio + str(invalid_params_radio)) - valid_param, invalid_params = validate_list_of_dicts(ap_list, accesspoint_spec) + valid_param, invalid_params = validate_list_of_dicts( + ap_list, accesspoint_spec) if invalid_params or invalid_list_radio: self.msg = "Invalid parameters in playbook: {0} ".format( @@ -1789,7 +1792,8 @@ def validate_input_yml(self): return self self.validated_config = valid_param - self.msg = "Successfully validated playbook config params:{0}".format(self.pprint(valid_param)) + self.msg = "Successfully validated playbook config params:{0}".format( + self.pprint(valid_param)) self.log(self.msg, "INFO") self.status = "success" return self @@ -1820,7 +1824,8 @@ def get_want(self, ap_config): want[key] = value self.want = want - self.log("Desired State (want): {0}".format(self.pprint(self.want)), "INFO") + self.log("Desired State (want): {0}".format( + self.pprint(self.want)), "INFO") return self def get_have(self, input_config): @@ -1855,7 +1860,8 @@ def get_have(self, input_config): have["current_ap_config"] = current_ap_config have["ip_address"] = self.payload["access_point_details"]["management_ip_address"] have["device_id"] = self.payload["access_point_details"]["id"] - have["wlc_provision_status"] = self.payload.get("wlc_provision_status") + have["wlc_provision_status"] = self.payload.get( + "wlc_provision_status") have["associated_wlc_ip"] = self.payload["access_point_details"]["associated_wlc_ip"] have["hostname"] = self.payload["access_point_details"]["hostname"] have["ap_type"] = self.payload["access_point_details"]["family"] @@ -1867,7 +1873,8 @@ def get_have(self, input_config): have["site_id"] = self.payload["current_site"]["site_id"] self.have = have - self.log("Current State (have): {0}".format(self.pprint(self.have)), "INFO") + self.log("Current State (have): {0}".format( + self.pprint(self.have)), "INFO") return self def get_diff_merged(self, ap_config): @@ -1912,7 +1919,8 @@ def get_diff_merged(self, ap_config): provision_status, provision_details = self.provision_device() if provision_status == "SUCCESS": self.result["changed"] = True - self.msg = "AP {0} provisioned successfully.".format(self.have["hostname"]) + self.msg = "AP {0} provisioned successfully.".format( + self.have["hostname"]) self.log(self.msg, "INFO") responses["accesspoints_updates"].update({ "provision_message": self.msg @@ -1922,7 +1930,8 @@ def get_diff_merged(self, ap_config): self.have["hostname"], self.have.get("site_name_hierarchy")) self.log(self.msg, "INFO") self.result["changed"] = False - responses["accesspoints_updates"].update({"provision_message": self.msg}) + responses["accesspoints_updates"].update( + {"provision_message": self.msg}) if not self.ap_update_required: return self @@ -1932,7 +1941,8 @@ def get_diff_merged(self, ap_config): self.log("Comparing current AP configuration with input data.", "INFO") consolidated_data = self.config_diff(self.have["current_ap_config"]) if not consolidated_data: - self.msg = "AP - {0} does not need any update".format(self.have.get("current_ap_config").get("ap_name")) + self.msg = "AP - {0} does not need any update".format( + self.have.get("current_ap_config").get("ap_name")) self.log(self.msg, "INFO") del self.payload["access_point_details"] responses["accesspoints_updates"].update({ @@ -1945,7 +1955,8 @@ def get_diff_merged(self, ap_config): self.log("Final AP Configuration data to update {0}".format(self.pprint( consolidated_data)), "INFO") task_response = self.update_ap_configuration(consolidated_data) - self.log("Access Point update response: {0} .".format(task_response), "INFO") + self.log("Access Point update response: {0} .".format( + task_response), "INFO") if task_response and isinstance(task_response, dict): resync_retry_count = self.payload.get("dnac_api_task_timeout") @@ -1953,7 +1964,8 @@ def get_diff_merged(self, ap_config): while resync_retry_count: task_details_response = self.get_tasks_by_id( task_response["response"]["taskId"]) - self.log("Status of the task: {0} .".format(self.status), "INFO") + self.log("Status of the task: {0} .".format( + self.status), "INFO") if task_details_response.get("endTime") is not None: if task_details_response.get("status") == "FAILURE": @@ -1962,8 +1974,10 @@ def get_diff_merged(self, ap_config): self.log(self.msg, "ERROR") self.log("Task Details: {0} .".format(self.pprint( task_details_response)), "ERROR") - failure_details = self.get_task_details_by_id(task_response["response"]["taskId"]) - self.log("Failure Details: {0} .".format(self.pprint(failure_details)), "ERROR") + failure_details = self.get_task_details_by_id( + task_response["response"]["taskId"]) + self.log("Failure Details: {0} .".format( + self.pprint(failure_details)), "ERROR") self.set_operation_result("failed", self.result["changed"], self.msg, "ERROR", failure_details).check_return_status() else: @@ -2006,7 +2020,8 @@ def ap_update_required(self): "xor_radio", "radio_band", "tri_radio", "dual_radio_mode" ] want_key_list = self.want.keys() - has_required_keys = bool(set(want_key_list).intersection(required_keys_for_updates)) + has_required_keys = bool( + set(want_key_list).intersection(required_keys_for_updates)) return has_required_keys def verify_diff_merged(self, config): @@ -2029,15 +2044,18 @@ def verify_diff_merged(self, config): """ self.get_have(config) - self.log("Current AP Config (have): {0}".format(str(self.have)), "INFO") - self.log("Desired AP Config (want): {0}".format(str(self.want)), "INFO") + self.log("Current AP Config (have): {0}".format( + str(self.have)), "INFO") + self.log("Desired AP Config (want): {0}".format( + str(self.want)), "INFO") ap_exists = self.have.get("ap_exists") ap_name = self.have.get("current_ap_config").get("ap_name") if not ap_exists: self.status = "failed" - self.msg = "AP Config '{0}' does not exist in the system.".format(ap_name) + self.msg = "AP Config '{0}' does not exist in the system.".format( + ap_name) self.log(self.msg, "ERROR") return self @@ -2050,7 +2068,8 @@ def verify_diff_merged(self, config): require_update = self.config_diff(self.have["current_ap_config"]) self.log(self.pprint(require_update), "INFO") if require_update: - radio_list = require_update.get(self.keymap["radio_configurations"], []) + radio_list = require_update.get( + self.keymap["radio_configurations"], []) if len(radio_list) > 0: for each_radio in radio_list: radio_key_list = list(each_radio.keys()) @@ -2071,7 +2090,8 @@ def verify_diff_merged(self, config): self.keymap["clean_air_si_6ghz"]): unmatch_count += 1 - self.log("Unmatch count for the radio configuration : {0}".format(str(unmatch_count)), "INFO") + self.log("Unmatch count for the radio configuration : {0}".format( + str(unmatch_count)), "INFO") self.log(str(require_update), "INFO") responses = {} responses["accesspoints_verify"] = {} @@ -2082,15 +2102,18 @@ def verify_diff_merged(self, config): responses["accesspoints_verify"]["ap_provision_update_status"] = msg self.result["changed"] = True - self.log("Unmatch count for the radio configuration : {0}".format(str(unmatch_count)), "INFO") + self.log("Unmatch count for the radio configuration : {0}".format( + str(unmatch_count)), "INFO") if self.result.get("ap_update_status") is True: if unmatch_count < 1: - msg = "The update for AP Config '{0}' has been successfully verified.".format(ap_name) + msg = "The update for AP Config '{0}' has been successfully verified.".format( + ap_name) self.log(msg, "INFO") self.status = "success" self.result["changed"] = True - ap_selected_fields = self.payload.get("config")[0].get("ap_selected_fields") + ap_selected_fields = self.payload.get( + "config")[0].get("ap_selected_fields") if ap_selected_fields is None or ap_selected_fields == "" or ap_selected_fields == "all": self.payload["access_point_details"] = self.payload["access_point_details"] else: @@ -2098,7 +2121,8 @@ def verify_diff_merged(self, config): ap_selected_fields, [self.payload["access_point_details"]]) ap_config_selected_fields =\ - self.payload.get("config")[0].get("ap_config_selected_fields") + self.payload.get("config")[0].get( + "ap_config_selected_fields") if ap_config_selected_fields is None or ap_config_selected_fields == "" \ or ap_config_selected_fields == "all": self.payload["access_point_config"] = self.payload["access_point_config"] @@ -2136,15 +2160,18 @@ def validate_radio_series(self, ap_config): for further action or validation. """ invalid_series = [] - self.log("Starting validation of radio series with configuration: {0}".format(str(ap_config)), "INFO") + self.log("Starting validation of radio series with configuration: {0}".format( + str(ap_config)), "INFO") for radio_type in self.radio_interface: ap_series = ap_config.get(radio_type) self.log("Validating radio type: {0}".format(radio_type), "INFO") if ap_series is not None: for series in self.allowed_series[radio_type]: - compiled_pattern = re.compile(r'\b{0}\w+|\b{0}\b'.format(re.escape(series))) - is_valid = compiled_pattern.search(self.payload["access_point_details"]["series"]) + compiled_pattern = re.compile( + r'\b{0}\w+|\b{0}\b'.format(re.escape(series))) + is_valid = compiled_pattern.search( + self.payload["access_point_details"]["series"]) if is_valid: invalid_series = [] break @@ -2154,10 +2181,12 @@ def validate_radio_series(self, ap_config): radio_type, str(series) ) - self.log("Invalid series detected: {}".format(invalid_entry), "DEBUG") + self.log("Invalid series detected: {}".format( + invalid_entry), "DEBUG") invalid_series.append(invalid_entry) - self.log("Completed validation. Invalid series: {}".format(invalid_series), "INFO") + self.log("Completed validation. Invalid series: {}".format( + invalid_series), "INFO") return invalid_series def validate_ap_config_parameters(self, ap_config): @@ -2189,24 +2218,30 @@ def validate_ap_config_parameters(self, ap_config): for reboot_reset in ("reboot_aps", "factory_reset_aps"): reboot_reset_aps = ap_config.get(reboot_reset) if reboot_reset_aps is not None: - ap_identity_type = list(reboot_reset_aps.keys())[0] # Retrieve the type (mac, hostname, or IP) + # Retrieve the type (mac, hostname, or IP) + ap_identity_type = list(reboot_reset_aps.keys())[0] if ap_identity_type and ap_identity_type in self.keymap and len(reboot_reset_aps.get(ap_identity_type)) > 0: for ap_identifier in reboot_reset_aps[ap_identity_type]: if ap_identity_type == "mac_addresses": - mac_regex = re.compile(r'^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$') + mac_regex = re.compile( + r'^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$') if not mac_regex.match(ap_identifier): errormsg.append("mac_addresses: Invalid MAC Address '{0}' in playbook.".format( str(ap_identifier))) - self.log("Invalid MAC address for {0}: {1}".format(reboot_reset, ap_identifier), "ERROR") + self.log("Invalid MAC address for {0}: {1}".format( + reboot_reset, ap_identifier), "ERROR") elif ap_identity_type == "management_ip_addresses": if not (self.is_valid_ipv4(ap_identifier) or self.is_valid_ipv6(ap_identifier)): errormsg.append("management_ip_addresses: Invalid Management IP Address '{0}' in playbook." .format(ap_identifier)) - self.log("Invalid Management IP address for {0}: {1}".format(reboot_reset, ap_identifier), "ERROR") + self.log("Invalid Management IP address for {0}: {1}".format( + reboot_reset, ap_identifier), "ERROR") elif ap_identity_type == "hostnames": param_spec = dict(type="str", length_max=32) - validate_str(ap_identifier, param_spec, "hostnames", errormsg) - self.log("Hostname validation for '{0}' in {1} completed.".format(ap_identifier, reboot_reset), "DEBUG") + validate_str(ap_identifier, param_spec, + "hostnames", errormsg) + self.log("Hostname validation for '{0}' in {1} completed.".format( + ap_identifier, reboot_reset), "DEBUG") ap_identifier = ap_config.get("ap_identifier") common_fields_to_change = ap_config.get("common_fields_to_change") @@ -2226,24 +2261,29 @@ def validate_ap_config_parameters(self, ap_config): hostname = each_ap.get("hostname") if hostname: - self.log("Validating Hostname: {0}".format(hostname), "DEBUG") + self.log("Validating Hostname: {0}".format( + hostname), "DEBUG") param_spec = dict(type="str", length_max=32) validate_str(hostname, param_spec, "hostname", errormsg) - self.log("Hostname validation for '{0}' completed.".format(hostname), "INFO") + self.log("Hostname validation for '{0}' completed.".format( + hostname), "INFO") ap_name = each_ap.get("ap_name") if ap_name: - self.log("Validating AP Name: {0}".format(ap_name), "DEBUG") + self.log("Validating AP Name: {0}".format( + ap_name), "DEBUG") param_spec = dict(type="str", length_max=32) validate_str(ap_name, param_spec, "ap_name", errormsg) if re.search(r'[ ?<]', ap_name): errormsg.append("ap_name: Invalid '{0}' in playbook. Space, '?', '<' and XSS characters are not allowed". format(ap_name)) else: - self.log("AP Name '{0}' is valid.".format(ap_name), "INFO") + self.log("AP Name '{0}' is valid.".format( + ap_name), "INFO") if common_fields_to_change is not None: ap_config = common_fields_to_change - self.log("Updated ap_config with common_fields_to_change: {0}".format(common_fields_to_change), "DEBUG") + self.log("Updated ap_config with common_fields_to_change: {0}".format( + common_fields_to_change), "DEBUG") invalid_series = self.validate_radio_series(ap_config) if invalid_series: @@ -2253,7 +2293,8 @@ def validate_ap_config_parameters(self, ap_config): mac_address = ap_config.get("mac_address") if mac_address: - mac_regex = re.compile(r'^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$') + mac_regex = re.compile( + r'^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$') if not mac_regex.match(mac_address): errormsg.append("mac_address: Invalid MAC Address '{0}' in playbook.".format( mac_address)) @@ -2269,7 +2310,8 @@ def validate_ap_config_parameters(self, ap_config): self.log("Validating RF profile: {0}".format(rf_profile), "DEBUG") param_spec = dict(type="str", length_max=32) validate_str(rf_profile, param_spec, "rf_profile", errormsg) - self.log("RF profile '{0}' validation completed.".format(rf_profile), "DEBUG") + self.log("RF profile '{0}' validation completed.".format( + rf_profile), "DEBUG") site = ap_config.get("site") if site: @@ -2277,18 +2319,21 @@ def validate_ap_config_parameters(self, ap_config): if floor: floor_name = floor.get("name") if floor_name and (not isinstance(floor_name, str) or len(floor_name) > 32): - errormsg.append("name: Invalid type or length > 32 characters in playbook.") + errormsg.append( + "name: Invalid type or length > 32 characters in playbook.") parent_name = floor.get("parent_name") if parent_name and (not isinstance(parent_name, str) or len(parent_name) > 64): - errormsg.append("parent_name: Invalid type or length > 64 characters in playbook.") + errormsg.append( + "parent_name: Invalid type or length > 64 characters in playbook.") ap_name = ap_config.get("ap_name") if ap_name: param_spec = dict(type="str", length_max=32) validate_str(ap_name, param_spec, "ap_name", errormsg) if re.search(r'[ ?<]', ap_name): - errormsg.append("ap_name: Invalid '{0}' in playbook. Space, '?', '<' and XSS characters are not allowed".format(ap_name)) + errormsg.append( + "ap_name: Invalid '{0}' in playbook. Space, '?', '<' and XSS characters are not allowed".format(ap_name)) admin_status = ap_config.get("admin_status") if admin_status and admin_status not in ("Enabled", "Disabled"): @@ -2302,14 +2347,16 @@ def validate_ap_config_parameters(self, ap_config): led_status = ap_config.get("led_status") if led_status and led_status not in ("Disabled", "Enabled"): - errormsg.append("led_status: Invalid LED Status '{0}' in playbook.".format(led_status)) + errormsg.append( + "led_status: Invalid LED Status '{0}' in playbook.".format(led_status)) location = ap_config.get("location") if location: param_spec = dict(type="str", length_max=255) validate_str(location, param_spec, "location", errormsg) - is_assigned_site_as_location = ap_config.get("is_assigned_site_as_location") + is_assigned_site_as_location = ap_config.get( + "is_assigned_site_as_location") if is_assigned_site_as_location and is_assigned_site_as_location not in ("Disabled", "Enabled"): errormsg.append("is_assigned_site_as_location: Invalid value '{0}' for is_assigned_site_as_location in playbook.\ Must be either 'Disabled' or 'Enabled'.".format(is_assigned_site_as_location)) @@ -2339,19 +2386,23 @@ def validate_ap_config_parameters(self, ap_config): errormsg.append("{0}: Invalid {1} in playbook. Please select one of: Inherit from site / Clear or Controller name." .format(ctrl_name, controller)) elif controller != "Inherit from site / Clear" and controller in check_duplicate_controller: - errormsg.append("{0}: Duplicate {1} in playbook.".format(ctrl_name, controller)) + errormsg.append("{0}: Duplicate {1} in playbook.".format( + ctrl_name, controller)) check_duplicate_controller.append(controller) # Validate controller IP Addresses check_duplicate_ip = [] for ip_address in ["primary_ip_address", "secondary_ip_address", "tertiary_ip_address"]: ap_config_ip_address = ap_config.get(ip_address) - address = ap_config_ip_address.get("address") if ap_config_ip_address else None + address = ap_config_ip_address.get( + "address") if ap_config_ip_address else None if address: if not self.is_valid_ipv4(address) and not self.is_valid_ipv6(address): - errormsg.append("{0}: Invalid IP address '{1}' in playbook".format(ip_address, address)) + errormsg.append( + "{0}: Invalid IP address '{1}' in playbook".format(ip_address, address)) elif address != "0.0.0.0" and address in check_duplicate_ip: - errormsg.append("{0}: Duplicate IP address '{1}' in playbook".format(ip_address, address)) + errormsg.append( + "{0}: Duplicate IP address '{1}' in playbook".format(ip_address, address)) check_duplicate_ip.append(address) # Validate Dual Radio Mode @@ -2366,15 +2417,18 @@ def validate_ap_config_parameters(self, ap_config): if ap_config.get("ap_mode") not in ("Local/FlexConnect", "Local"): errormsg.append("Radio Params cannot be changed when AP mode is in {0}." .format(ap_config.get("ap_mode"))) - self.validate_radio_parameters(radio_config, radio_series, errormsg) + self.validate_radio_parameters( + radio_config, radio_series, errormsg) if len(errormsg) > 0: - self.msg = "Invalid parameters in playbook config: '{0}' ".format(str(errormsg)) + self.msg = "Invalid parameters in playbook config: '{0}' ".format( + str(errormsg)) self.log(self.msg, "ERROR") self.status = "failed" return self - self.msg = "Successfully validated config params: {0}".format(str(ap_config)) + self.msg = "Successfully validated config params: {0}".format( + str(ap_config)) self.log(self.msg, "INFO") self.status = "success" return self @@ -2399,7 +2453,8 @@ def validate_mac_address(self, mac_address, errormsg): mac_regex = re.compile(r'^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$') if mac_address and not mac_regex.match(mac_address): - errormsg.append("mac_address: Invalid MAC Address '{0}' in playbook.".format(mac_address)) + errormsg.append( + "mac_address: Invalid MAC Address '{0}' in playbook.".format(mac_address)) else: self.log("MAC address '{0}' is valid.".format(mac_address), "INFO") @@ -2419,9 +2474,11 @@ def validate_ip_address(self, ip_address, ip_type, errormsg): self.log("Validating {0}: {1}".format(ip_type, ip_address), "DEBUG") if ip_address and not (self.is_valid_ipv4(ip_address) or self.is_valid_ipv6(ip_address)): - errormsg.append("{0}: Invalid {0} '{1}' in playbook.".format(ip_type, ip_address)) + errormsg.append( + "{0}: Invalid {0} '{1}' in playbook.".format(ip_type, ip_address)) else: - self.log("{0}: '{1}' is valid.".format(ip_type, ip_address), "INFO") + self.log("{0}: '{1}' is valid.".format( + ip_type, ip_address), "INFO") def validate_radio_parameters(self, radio_config, radio_series, errormsg): """ @@ -2460,7 +2517,8 @@ def validate_radio_parameters(self, radio_config, radio_series, errormsg): cable_loss = radio_config.get("cable_loss") if cable_loss: if not 0 <= cable_loss <= 40: - errormsg.append("cable_loss: Invalid '{0}' in playbook. Must be between 0 and 40.".format(cable_loss)) + errormsg.append( + "cable_loss: Invalid '{0}' in playbook. Must be between 0 and 40.".format(cable_loss)) elif antenna_gain and cable_loss >= antenna_gain: errormsg.append("cable_loss: Invalid '{0}' in playbook. Must be less than antenna_gain: {1}." .format(cable_loss, antenna_gain)) @@ -2493,7 +2551,7 @@ def validate_radio_parameters(self, radio_config, radio_series, errormsg): ) else: current_radio_role = self.check_current_radio_role_assignment( - radio_series, self.have["current_ap_config"].get("radio_dtos" , []), radio_band) + radio_series, self.have["current_ap_config"].get("radio_dtos", []), radio_band) if self.want.get(radio_series).get("radio_role_assignment") != "Client-Serving" and radio_series != "5ghz_radio": errormsg.append( "channel_number: This configuration is only supported with Client-Serving Radio Role Assignment {0} " @@ -2504,7 +2562,8 @@ def validate_radio_parameters(self, radio_config, radio_series, errormsg): valid_channel_widths = ["20 MHz", "40 MHz", "80 MHz", "160 MHz"] if channel_width: if radio_series == "2.4ghz_radio": - errormsg.append("channel_width is not applicable for the 2.4GHz radio") + errormsg.append( + "channel_width is not applicable for the 2.4GHz radio") elif radio_series != "6ghz_radio" and channel_width not in valid_channel_widths: errormsg.append( "channel_width: Invalid value '{0}' for Channel width in playbook. " @@ -2643,7 +2702,8 @@ def get_accesspoint_details(self, input_config): current_configuration = {} ap_response = None input_param = {} - self.keymap = self.map_config_key_to_api_param(self.keymap, input_config) + self.keymap = self.map_config_key_to_api_param( + self.keymap, input_config) self.keymap.update({ "mac_address": "macAddress", "management_ip_address": "managementIpAddress", @@ -2666,7 +2726,8 @@ def get_accesspoint_details(self, input_config): if ap_identifier: ap_list = [] selected_key = None - self.log("Starting to process AP identifiers from input configuration.", "DEBUG") + self.log( + "Starting to process AP identifiers from input configuration.", "DEBUG") for each_ap in ap_identifier: for key in ["mac_address", "management_ip_address", "hostname"]: @@ -2680,12 +2741,14 @@ def get_accesspoint_details(self, input_config): self.log("At AP details {0}".format(self.pprint(input_param))) self.log("Completed AP identifier processing. Mapped {0} to input_param with values: {1}". format(self.keymap[selected_key], ap_list), "DEBUG") - self.log("Final AP details structure: {0}".format(self.pprint(input_param)), "DEBUG") + self.log("Final AP details structure: {0}".format( + self.pprint(input_param)), "DEBUG") if not input_param: msg = "Required param of mac_address,ip_address or hostname is not in playbook config" self.log(msg, "WARNING") - self.set_operation_result("failed", False, msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, msg, "ERROR").check_return_status() try: ap_response = self.dnac._exec( @@ -2695,7 +2758,8 @@ def get_accesspoint_details(self, input_config): params=input_param, ) - ap_response_data = ap_response.get("response") if ap_response else None + ap_response_data = ap_response.get( + "response") if ap_response else None ap_identifier_present = input_config.get("ap_identifier") if ap_response_data: @@ -2704,9 +2768,11 @@ def get_accesspoint_details(self, input_config): if not ap_identifier_present: current_configuration = ap_response[0] - self.log("AP response found without 'ap_identifier'; current configuration set.", "DEBUG") + self.log( + "AP response found without 'ap_identifier'; current configuration set.", "DEBUG") else: - self.log("AP response found with 'ap_identifier'; processed AP response data.", "DEBUG") + self.log( + "AP response found with 'ap_identifier'; processed AP response data.", "DEBUG") except Exception as e: self.msg = "The provided device '{0}' is either invalid or not present in the \ @@ -2716,7 +2782,8 @@ def get_accesspoint_details(self, input_config): if not accesspoint_exists: self.msg = "The provided device '{0}' is either invalid or not present in the \ Cisco Catalyst Center.".format(str(input_param)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() else: ap_identifier_present = input_config.get("ap_identifier") is_unified_ap = current_configuration.get("family") == "Unified AP" @@ -2725,16 +2792,19 @@ def get_accesspoint_details(self, input_config): filter_response = [] for each_response in ap_response: if each_response["family"] != "Unified AP": - self.msg = "Provided device {0} is not Access Point.".format(each_response["mac_address"]) + self.msg = "Provided device {0} is not Access Point.".format( + each_response["mac_address"]) self.log(self.msg, "WARNING") else: filter_response.append(each_response) - self.log("Filtered Access points List: {0} ".format(self.pprint(filter_response)), "INFO") + self.log("Filtered Access points List: {0} ".format( + self.pprint(filter_response)), "INFO") return accesspoint_exists, filter_response if not is_unified_ap: self.msg = "Provided device is not Access Point." - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() return accesspoint_exists, current_configuration @@ -2767,7 +2837,8 @@ def get_current_config(self, input_config): management IP address, or hostname. If found, it retrieves the current Access Point configuration and returns it. """ - self.log("Starting to retrieve current configuration with input: {0}".format(str(input_config)), "INFO") + self.log("Starting to retrieve current configuration with input: {0}".format( + str(input_config)), "INFO") accesspoint_exists, current_configuration = self.get_accesspoint_details( input_config) self.log("Access point exists: {0}, Current configuration: {1}" @@ -2775,7 +2846,8 @@ def get_current_config(self, input_config): if input_config.get("site"): site_exists, current_site = self.site_exists(input_config) - self.log("Site exists: {0}, Current site: {1}".format(site_exists, current_site), "INFO") + self.log("Site exists: {0}, Current site: {1}".format( + site_exists, current_site), "INFO") if site_exists: self.payload.update({ @@ -2788,7 +2860,8 @@ def get_current_config(self, input_config): provision_status, wlc_details = self.verify_ap_provision( current_configuration["associated_wlc_ip"]) self.payload["wlc_provision_status"] = provision_status - self.log("WLC provision status: {0}".format(provision_status), "INFO") + self.log("WLC provision status: {0}".format( + provision_status), "INFO") if accesspoint_exists: self.payload["access_point_details"] = current_configuration @@ -2800,7 +2873,8 @@ def get_current_config(self, input_config): if ap_config_exists: self.payload["access_point_config"] = current_configuration - self.log("Updated payload with access point configuration: {0}".format(str(self.payload)), "INFO") + self.log("Updated payload with access point configuration: {0}".format( + str(self.payload)), "INFO") self.log("Completed retrieving current configuration. Access point exists: {0}, Current configuration: {1}" .format(accesspoint_exists, current_configuration), "INFO") @@ -2845,13 +2919,17 @@ def get_accesspoint_config(self, ap_ethernet_mac_address): ) if ap_config_response: - self.keymap = self.map_config_key_to_api_param(self.keymap, ap_config_response) - current_configuration = self.camel_to_snake_case(ap_config_response) - self.log("Received API response from get_access_point_configuration: {0}".format(self.pprint(current_configuration)), "INFO") + self.keymap = self.map_config_key_to_api_param( + self.keymap, ap_config_response) + current_configuration = self.camel_to_snake_case( + ap_config_response) + self.log("Received API response from get_access_point_configuration: {0}".format( + self.pprint(current_configuration)), "INFO") accesspoint_config_exists = True except Exception as e: - self.log("Unable to get the Accesspoint configuration for '{0}'.".format(str(input_param) + str(e)), "WARNING") + self.log("Unable to get the Accesspoint configuration for '{0}'.".format( + str(input_param) + str(e)), "WARNING") return (accesspoint_config_exists, current_configuration) @@ -2889,15 +2967,19 @@ def site_exists(self, input_config): response = self.get_site(site_name) if response.get("response"): site = response["response"][0] - self.log("Site response: {0}".format(self.pprint(site)), "INFO") + self.log("Site response: {0}".format( + self.pprint(site)), "INFO") if self.dnac_version <= self.dnac_versions["2.3.5.3"]: - location = get_dict_result(site.get("additionalInfo"), 'nameSpace', "Location") + location = get_dict_result( + site.get("additionalInfo"), 'nameSpace', "Location") type_info = location.get("attributes", {}).get("type") - parent_name = site.get("siteNameHierarchy").split("/" + site.get("name"))[0] + parent_name = site.get("siteNameHierarchy").split( + "/" + site.get("name"))[0] else: type_info = site.get("type") - parent_name = site.get("nameHierarchy").split("/" + site.get("name"))[0] + parent_name = site.get("nameHierarchy").split( + "/" + site.get("name"))[0] if type_info == "floor": site_info = { @@ -2913,20 +2995,24 @@ def site_exists(self, input_config): "site_id": site.get("id"), "site_name": site_info["floor"]["parentName"] + "/" + site_info["floor"]["name"] } - self.log("Current site details: {0}".format(str(current_site)), "INFO") - self.log("Site {0} exists in Cisco Catalyst Center".format(site.get("name")), "INFO") + self.log("Current site details: {0}".format( + str(current_site)), "INFO") + self.log("Site {0} exists in Cisco Catalyst Center".format( + site.get("name")), "INFO") site_exists = True else: msg = "The provided site name '{0}' is either invalid or not present in the \ Cisco Catalyst Center.".format(self.want.get("site_name")) self.log(msg, "WARNING") - self.set_operation_result("failed", False, msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, msg, "ERROR").check_return_status() except Exception as e: msg = "The provided site name '{0}' is either invalid or not present in the \ Cisco Catalyst Center.".format(self.want.get("site_name")) self.log(msg + str(e), "WARNING") - self.set_operation_result("failed", False, msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, msg, "ERROR").check_return_status() return site_exists, current_site @@ -2953,14 +3039,17 @@ def get_site_device(self, site_id, ap_mac_address, site_exist=None, current_site not found or if an error occurs during the API call, it returns False. """ try: - site_name = self.have.get("site_name_hierarchy", self.want.get("site_name")) - api_response, device_list = self.get_device_ids_from_site(site_name, site_id) + site_name = self.have.get( + "site_name_hierarchy", self.want.get("site_name")) + api_response, device_list = self.get_device_ids_from_site( + site_name, site_id) if current_config.get("id") is not None and current_config.get("id") in device_list: self.log("Device with MAC address: {0} found in site: {1} Proceeding with ap_site updation." .format(ap_mac_address, site_id), "INFO") return True else: - self.log("Given device not found on the site: {sId},".format(sId=site_id), "INFO") + self.log("Given device not found on the site: {sId},".format( + sId=site_id), "INFO") return False except Exception as e: @@ -3039,7 +3128,8 @@ def access_point_provision_old(self, rf_profile, hostname, type_name, site_name_ "site_name_hierarchy: {0}, rf_profile: {1}, host_name: {2}" .format(site_name_hierarchy, rf_profile, hostname)) self.log(error_msg, "ERROR") - self.set_operation_result("failed", False, error_msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, error_msg, "ERROR").check_return_status() provision_params = [{ "rfProfile": rf_profile, @@ -3047,7 +3137,8 @@ def access_point_provision_old(self, rf_profile, hostname, type_name, site_name_ "type": type_name, "siteNameHierarchy": site_name_hierarchy }] - self.log('Before AP provision: {0}'.format(self.pprint(provision_params)), "INFO") + self.log('Before AP provision: {0}'.format( + self.pprint(provision_params)), "INFO") response = self.dnac._exec( family="wireless", @@ -3056,7 +3147,8 @@ def access_point_provision_old(self, rf_profile, hostname, type_name, site_name_ params={"payload": provision_params}, ) - self.log('Response from ap_provision: {0}'.format(str(response.get("response"))), "INFO") + self.log('Response from ap_provision: {0}'.format( + str(response.get("response"))), "INFO") if response and isinstance(response, dict): return response return None @@ -3084,7 +3176,8 @@ def access_point_provision_new(self, rf_profile, device_id, site_id): "device_id: {0}, rf_profile: {1}, site_id: {2}" .format(device_id, rf_profile, site_id)) self.log(error_msg, "ERROR") - self.set_operation_result("failed", False, error_msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, error_msg, "ERROR").check_return_status() provision_params = { "rfProfileName": rf_profile, @@ -3094,17 +3187,20 @@ def access_point_provision_new(self, rf_profile, device_id, site_id): try: site_assign_status = self.assign_device_to_site([self.have.get("device_id")], - self.have.get("site_name_hierarchy"), + self.have.get( + "site_name_hierarchy"), self.have.get("site_id")) if site_assign_status: - self.log('Current device details: {0}'.format(self.pprint(provision_params)), "INFO") + self.log('Current device details: {0}'.format( + self.pprint(provision_params)), "INFO") response = self.dnac._exec( family="wireless", function='ap_provision', op_modifies=True, params={"payload": provision_params}, ) - self.log('Response from ap_provision: {0}'.format(str(response.get("response"))), "INFO") + self.log('Response from ap_provision: {0}'.format( + str(response.get("response"))), "INFO") if response and isinstance(response, dict): return response @@ -3112,9 +3208,11 @@ def access_point_provision_new(self, rf_profile, device_id, site_id): return None except Exception as e: - error_msg = 'An error occurred during device provisioning: {0}'.format(str(e)) + error_msg = 'An error occurred during device provisioning: {0}'.format( + str(e)) self.log(error_msg, "ERROR") - self.set_operation_result("failed", False, error_msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, error_msg, "ERROR").check_return_status() def provision_device(self): """ @@ -3147,11 +3245,14 @@ def provision_device(self): type_name, site_name_hierarchy) if response and isinstance(response, dict): executionid = response.get("executionId") - resync_retry_count = int(self.payload.get("dnac_api_task_timeout", 100)) - resync_retry_interval = int(self.payload.get("dnac_task_poll_interval", 5)) + resync_retry_count = int( + self.payload.get("dnac_api_task_timeout", 100)) + resync_retry_interval = int( + self.payload.get("dnac_task_poll_interval", 5)) while resync_retry_count: - execution_details = self.get_execution_details(executionid) + execution_details = self.get_execution_details( + executionid) if execution_details.get("status") == "SUCCESS": self.result['changed'] = True self.result['response'] = execution_details @@ -3167,15 +3268,19 @@ def provision_device(self): time.sleep(resync_retry_interval) resync_retry_count = resync_retry_count - 1 else: - response = self.access_point_provision_new(rf_profile, device_id, site_id) + response = self.access_point_provision_new( + rf_profile, device_id, site_id) if response and isinstance(response, dict): task_id = response.get("response", {}).get("taskId") - resync_retry_count = int(self.payload.get("dnac_api_task_timeout")) - resync_retry_interval = int(self.payload.get("dnac_task_poll_interval")) + resync_retry_count = int( + self.payload.get("dnac_api_task_timeout")) + resync_retry_interval = int( + self.payload.get("dnac_task_poll_interval")) while resync_retry_count: task_details_response = self.get_tasks_by_id(task_id) - self.log("Status of the task: {0} .".format(self.status), "INFO") + self.log("Status of the task: {0} .".format( + self.status), "INFO") responses = {} if task_details_response.get("endTime") is not None: if task_details_response.get("status") == "SUCCESS": @@ -3187,7 +3292,8 @@ def provision_device(self): self.result['changed'] = True self.result['response'] = self.msg provision_status = "SUCCESS" - provision_details = self.get_task_details_by_id(task_id) + provision_details = self.get_task_details_by_id( + task_id) break else: self.result['changed'] = True if self.result['changed'] is True else False @@ -3195,7 +3301,8 @@ def provision_device(self): self.log(self.msg, "ERROR") self.log("Task Details: {0} .".format(self.pprint( task_details_response)), "ERROR") - provision_details = self.get_task_details_by_id(task_id) + provision_details = self.get_task_details_by_id( + task_id) self.log("Provision error details: {0} .".format(self.pprint( provision_details)), "ERROR") self.set_operation_result("failed", self.result['changed'], @@ -3206,7 +3313,8 @@ def provision_device(self): self.log("Provisioned device with host '{0}' to site '{1}' successfully.".format( hostname, site_name_hierarchy), "INFO") except Exception as e: - error_msg = 'An error occurred during device provisioning: {0}'.format(str(e)) + error_msg = 'An error occurred during device provisioning: {0}'.format( + str(e)) self.log(error_msg, "ERROR") self.msg = error_msg self.status = "failed" @@ -3232,7 +3340,8 @@ def compare_radio_config(self, current_radio, want_radio): are found, they are collected and returned in a dictionary. """ self.log("Starting radio configuration comparison.", "INFO") - self.log("Current radio configuration: {}".format(current_radio), "INFO") + self.log("Current radio configuration: {}".format( + current_radio), "INFO") self.log("Desired radio configuration: {}".format(want_radio), "INFO") available_key = { "_0": ("admin_status", "antenna_gain", "antenna_name", "radio_role_assignment", @@ -3260,34 +3369,41 @@ def compare_radio_config(self, current_radio, want_radio): unmatch_count = 0 dtos_keys = list(want_radio.keys()) slot_id_key = "_" + str(current_radio["slot_id"]) - self.log("Comparing keys for slot ID: {}".format(current_radio["slot_id"]), "INFO") + self.log("Comparing keys for slot ID: {}".format( + current_radio["slot_id"]), "INFO") for dto_key in dtos_keys: if dto_key in available_key[slot_id_key]: if dto_key == "antenna_name": temp_dtos[dto_key] = want_radio[dto_key] unmatch_count = unmatch_count + 1 - self.log("Antenna name unmatched: {0}".format(want_radio[dto_key]), "INFO") + self.log("Antenna name unmatched: {0}".format( + want_radio[dto_key]), "INFO") elif dto_key == "cable_loss": cable_loss = int(want_radio[dto_key]) antenna_gain = int(want_radio.get("antenna_gain", 0)) actual_gain = antenna_gain - cable_loss if current_radio.get(self.keymap["antenna_gain"]) != actual_gain: temp_dtos[dto_key] = cable_loss - self.log("Cable loss set to: {0}".format(want_radio[dto_key]), "INFO") + self.log("Cable loss set to: {0}".format( + want_radio[dto_key]), "INFO") elif dto_key == "antenna_cable_name": temp_dtos[dto_key] = want_radio[dto_key] - self.log("Antenna cable name set to: {0}".format(want_radio[dto_key]), "INFO") + self.log("Antenna cable name set to: {0}".format( + want_radio[dto_key]), "INFO") elif dto_key == "radio_type": temp_dtos[self.keymap[dto_key]] = want_radio[dto_key] - self.log("Radio type set to: {0}".format(want_radio[dto_key]), "INFO") + self.log("Radio type set to: {0}".format( + want_radio[dto_key]), "INFO") elif dto_key == "radio_role_assignment": temp_dtos[self.keymap[dto_key]] = want_radio[dto_key] - self.log("Radio Role Assignment set to: {0}".format(want_radio[dto_key]), "INFO") + self.log("Radio Role Assignment set to: {0}".format( + want_radio[dto_key]), "INFO") unmatch_count = unmatch_count + 1 elif dto_key == "radio_band": temp_dtos[self.keymap[dto_key]] = want_radio[dto_key] - self.log("Radio band set to: {0}".format(want_radio[dto_key]), "INFO") + self.log("Radio band set to: {0}".format( + want_radio[dto_key]), "INFO") else: if want_radio[dto_key] != current_radio[dto_key]: temp_dtos[self.keymap[dto_key]] = want_radio[dto_key] @@ -3297,7 +3413,8 @@ def compare_radio_config(self, current_radio, want_radio): temp_dtos["unmatch"] = unmatch_count self.log("Total unmatched keys: {0}".format(unmatch_count), "INFO") - self.log("Completed radio configuration comparison. Result: {0}".format(temp_dtos), "INFO") + self.log("Completed radio configuration comparison. Result: {0}".format( + temp_dtos), "INFO") return temp_dtos def config_diff(self, current_ap_config): @@ -3331,16 +3448,18 @@ def config_diff(self, current_ap_config): configurable_keys.remove(value) temp_dtos_list = [] - for each_key in configurable_keys : + for each_key in configurable_keys: if each_key == "ap_name": if self.want["ap_name"] != current_ap_config.get("ap_name"): update_config["apNameNew"] = self.want["ap_name"] - update_config["apName"] = current_ap_config.get("ap_name") + update_config["apName"] = current_ap_config.get( + "ap_name") elif each_key == "is_assigned_site_as_location": update_config["isAssignedSiteAsLocation"] = self.want["is_assigned_site_as_location"] elif each_key in ("2.4ghz_radio", "5ghz_radio", "6ghz_radio", "xor_radio", "tri_radio"): - current_radio_dtos = current_ap_config.get("radio_dtos") + current_radio_dtos = current_ap_config.get( + "radio_dtos") radio_data = {} for each_radio in current_radio_dtos: if each_key == "2.4ghz_radio" and each_radio["slot_id"] == 0: @@ -3362,7 +3481,8 @@ def config_diff(self, current_ap_config): temp_dtos_list.append(radio_data) elif each_key in ("clean_air_si_2.4ghz", "clean_air_si_5ghz", "clean_air_si_6ghz"): - current_radio_dtos = current_ap_config.get("radio_dtos") + current_radio_dtos = current_ap_config.get( + "radio_dtos") for each_dtos in current_radio_dtos: if each_key == "clean_air_si_2.4ghz" and each_dtos["slot_id"] == 0 \ and each_dtos["clean_air_si"] != self.want.get(each_key): @@ -3378,7 +3498,8 @@ def config_diff(self, current_ap_config): break else: if self.want[each_key] != current_ap_config.get(each_key): - update_config[self.keymap[each_key]] = self.want[each_key] + update_config[self.keymap[each_key] + ] = self.want[each_key] if temp_dtos_list: update_config["radioConfigurations"] = temp_dtos_list @@ -3389,52 +3510,73 @@ def config_diff(self, current_ap_config): for ctrl_name in ["primary_controller_name", "secondary_controller_name", "tertiary_controller_name"]: if ctrl_name == "primary_controller_name" and self.want.get(ctrl_name): if self.want.get(ctrl_name) == "Inherit from site / Clear": - update_config[self.keymap[ctrl_name]] = self.want.get(ctrl_name) + update_config[self.keymap[ctrl_name] + ] = self.want.get(ctrl_name) update_config[self.keymap["primary_ip_address"]] = {} - update_config[self.keymap["primary_ip_address"]]["address"] = "0.0.0.0" - update_config[self.keymap["secondary_controller_name"]] = self.want.get(ctrl_name) - update_config[self.keymap["secondary_ip_address"]] = {} - update_config[self.keymap["secondary_ip_address"]]["address"] = "0.0.0.0" - update_config[self.keymap["tertiary_controller_name"]] = self.want.get(ctrl_name) + update_config[self.keymap["primary_ip_address"] + ]["address"] = "0.0.0.0" + update_config[self.keymap["secondary_controller_name"]] = self.want.get( + ctrl_name) + update_config[self.keymap["secondary_ip_address"]] = { + } + update_config[self.keymap["secondary_ip_address"] + ]["address"] = "0.0.0.0" + update_config[self.keymap["tertiary_controller_name"]] = self.want.get( + ctrl_name) update_config[self.keymap["tertiary_ip_address"]] = {} - update_config[self.keymap["tertiary_ip_address"]]["address"] = "0.0.0.0" + update_config[self.keymap["tertiary_ip_address"] + ]["address"] = "0.0.0.0" else: - update_config[self.keymap[ctrl_name]] = self.want[ctrl_name] + update_config[self.keymap[ctrl_name] + ] = self.want[ctrl_name] update_config[self.keymap["primary_ip_address"]] = {} if self.want.get("primary_ip_address", {}).get("address"): update_config[self.keymap["primary_ip_address"]]["address"] = \ self.want["primary_ip_address"]["address"] else: - update_config[self.keymap["primary_ip_address"]]["address"] = "0.0.0.0" + update_config[self.keymap["primary_ip_address"] + ]["address"] = "0.0.0.0" elif ctrl_name == "secondary_controller_name" and self.want.get(ctrl_name): if self.want.get(ctrl_name) == "Inherit from site / Clear": - update_config[self.keymap[ctrl_name]] = self.want.get(ctrl_name) - update_config[self.keymap["secondary_ip_address"]] = {} - update_config[self.keymap["secondary_ip_address"]]["address"] = "0.0.0.0" - update_config[self.keymap["tertiary_controller_name"]] = self.want.get(ctrl_name) + update_config[self.keymap[ctrl_name] + ] = self.want.get(ctrl_name) + update_config[self.keymap["secondary_ip_address"]] = { + } + update_config[self.keymap["secondary_ip_address"] + ]["address"] = "0.0.0.0" + update_config[self.keymap["tertiary_controller_name"]] = self.want.get( + ctrl_name) update_config[self.keymap["tertiary_ip_address"]] = {} - update_config[self.keymap["tertiary_ip_address"]]["address"] = "0.0.0.0" + update_config[self.keymap["tertiary_ip_address"] + ]["address"] = "0.0.0.0" else: - update_config[self.keymap[ctrl_name]] = self.want[ctrl_name] - update_config[self.keymap["secondary_ip_address"]] = {} + update_config[self.keymap[ctrl_name] + ] = self.want[ctrl_name] + update_config[self.keymap["secondary_ip_address"]] = { + } if self.want.get("secondary_ip_address", {}).get("address"): update_config[self.keymap["secondary_ip_address"]]["address"] = \ self.want["secondary_ip_address"]["address"] else: - update_config[self.keymap["secondary_ip_address"]]["address"] = "0.0.0.0" + update_config[self.keymap["secondary_ip_address"] + ]["address"] = "0.0.0.0" elif ctrl_name == "tertiary_controller_name" and self.want.get(ctrl_name): if self.want.get(ctrl_name) == "Inherit from site / Clear": - update_config[self.keymap[ctrl_name]] = self.want.get(ctrl_name) + update_config[self.keymap[ctrl_name] + ] = self.want.get(ctrl_name) update_config[self.keymap["tertiary_ip_address"]] = {} - update_config[self.keymap["tertiary_ip_address"]]["address"] = "0.0.0.0" + update_config[self.keymap["tertiary_ip_address"] + ]["address"] = "0.0.0.0" else: - update_config[self.keymap[ctrl_name]] = self.want[ctrl_name] + update_config[self.keymap[ctrl_name] + ] = self.want[ctrl_name] update_config[self.keymap["tertiary_ip_address"]] = {} if self.want.get("tertiary_ip_address", {}).get("address"): update_config[self.keymap["tertiary_ip_address"]]["address"] = \ self.want["tertiary_ip_address"]["address"] else: - update_config[self.keymap["tertiary_ip_address"]]["address"] = "0.0.0.0" + update_config[self.keymap["tertiary_ip_address"] + ]["address"] = "0.0.0.0" if update_config: update_config["macAddress"] = current_ap_config["eth_mac"] @@ -3444,7 +3586,8 @@ def config_diff(self, current_ap_config): .format(self.pprint(update_config)), "INFO") return update_config - self.log("Playbook AP configuration remain same in current AP configration", "INFO") + self.log( + "Playbook AP configuration remain same in current AP configration", "INFO") return None def update_ap_configuration(self, ap_config): @@ -3487,9 +3630,11 @@ def update_ap_configuration(self, ap_config): del ap_config["apNameNew"] elif mac_address is not None: temp_dict[self.keymap["mac_address"]] = mac_address - self.log("Populated temp_dict with MAC address: {0}".format(mac_address), "DEBUG") + self.log("Populated temp_dict with MAC address: {0}".format( + mac_address), "DEBUG") else: - self.log("No AP name or MAC address found in ap_config.", "WARNING") + self.log( + "No AP name or MAC address found in ap_config.", "WARNING") ap_config["apList"].append(temp_dict) self.log("Added temp_dict to apList. Current apList: {0}". format(self.pprint(ap_config["apList"])), "INFO") @@ -3502,9 +3647,11 @@ def update_ap_configuration(self, ap_config): if ap_config.get(self.keymap["ap_name"]) and ap_config.get("apNameNew"): del ap_config[self.keymap["ap_name"]] del ap_config["apNameNew"] - self.log("Removed old AP name and new AP name from ap_config.", "DEBUG") + self.log( + "Removed old AP name and new AP name from ap_config.", "DEBUG") else: - self.log("No AP name or new AP name to remove from ap_config.", "DEBUG") + self.log( + "No AP name or new AP name to remove from ap_config.", "DEBUG") if ap_config.get(self.keymap["location"]) is not None: ap_config["configureLocation"] = True @@ -3538,7 +3685,7 @@ def update_ap_configuration(self, ap_config): ap_config.get(self.keymap["tertiary_controller_name"]) is not None or \ ap_config.get(self.keymap["primary_ip_address"]) is not None or \ ap_config.get(self.keymap["secondary_ip_address"]) is not None or \ - ap_config.get(self.keymap["tertiary_ip_address"]) is not None : + ap_config.get(self.keymap["tertiary_ip_address"]) is not None: ap_config["configureHAController"] = True if ap_config.get(self.keymap["failover_priority"]) is not None: @@ -3621,7 +3768,8 @@ def update_ap_configuration(self, ap_config): radio_dtos["configureAntennaCable"] = True if each_radio.get("antenna_name") is not None: - radio_dtos["antennaPatternName"] = each_radio.get("antenna_name") + radio_dtos["antennaPatternName"] = each_radio.get( + "antenna_name") radio_dtos["configureAntennaPatternName"] = True if each_radio.get(self.keymap["radio_band"]) is not None: @@ -3632,9 +3780,11 @@ def update_ap_configuration(self, ap_config): if each_radio.get(self.keymap["radio_role_assignment"]) == "Auto": radio_dtos[self.keymap["radio_role_assignment"]] = "AUTO" elif each_radio.get(self.keymap["radio_role_assignment"]) == "Client-Serving": - radio_dtos[self.keymap["radio_role_assignment"]] = "SERVING" + radio_dtos[self.keymap["radio_role_assignment"] + ] = "SERVING" else: - radio_dtos[self.keymap["radio_role_assignment"]] = "MONITOR" + radio_dtos[self.keymap["radio_role_assignment"] + ] = "MONITOR" radio_dtos["configureRadioRoleAssignment"] = True if each_radio.get(self.keymap["radio_type"]) is not None: @@ -3661,7 +3811,8 @@ def update_ap_configuration(self, ap_config): if ap_config.get(key_to_remove): del ap_config[key_to_remove] - self.log("Update access point before update: {0}".format(self.pprint(ap_config)), "INFO") + self.log("Update access point before update: {0}".format( + self.pprint(ap_config)), "INFO") try: response = self.dnac._exec( family="wireless", @@ -3708,7 +3859,8 @@ def data_frame(self, fields_to_include=None, records=list): if not fields_to_include or fields_to_include.strip() == "": return records - field_names = [field.strip() for field in fields_to_include.split(",")] + field_names = [field.strip() + for field in fields_to_include.split(",")] filtered_data = [] for record in records: @@ -3722,7 +3874,7 @@ def data_frame(self, fields_to_include=None, records=list): return filtered_data except Exception as e: - self.log("Unable to filter fields: {0}".format(str(e)) , "ERROR") + self.log("Unable to filter fields: {0}".format(str(e)), "ERROR") return None def consolidate_output(self): @@ -3769,30 +3921,37 @@ def reboot_access_point(self, ap_list): dict: A dictionary containing the result of the access point reboot response. """ try: - self.log('Rebooting the list of APs: {0}'.format(self.pprint(ap_list)), "INFO") + self.log('Rebooting the list of APs: {0}'.format( + self.pprint(ap_list)), "INFO") response = self.dnac._exec( family="wireless", function='reboot_access_points', op_modifies=True, params={"apMacAddresses": ap_list}, ) - self.log("Response from reboot_access_points: {0}".format(str(response.get("response"))), "INFO") + self.log("Response from reboot_access_points: {0}".format( + str(response.get("response"))), "INFO") if response and isinstance(response, dict): task_id = response.get("response", {}).get("taskId") - resync_retry_count = int(self.payload.get("dnac_api_task_timeout")) - resync_retry_interval = int(self.payload.get("dnac_task_poll_interval")) + resync_retry_count = int( + self.payload.get("dnac_api_task_timeout")) + resync_retry_interval = int( + self.payload.get("dnac_task_poll_interval")) while resync_retry_count: task_details_response = self.get_tasks_by_id(task_id) - self.log("Status of the reboot task: {0} .".format(self.status), "INFO") + self.log("Status of the reboot task: {0} .".format( + self.status), "INFO") responses = {} if task_details_response.get("endTime") is not None: if task_details_response.get("status") == "SUCCESS": self.log("Reboot Task Details: {0} .".format(self.pprint( task_details_response)), "INFO") - self.msg = "APs {0} rebooted successfully".format(str(ap_list)) - reboot_status = self.access_point_reboot_status(task_id) + self.msg = "APs {0} rebooted successfully".format( + str(ap_list)) + reboot_status = self.access_point_reboot_status( + task_id) responses = { "accesspoints_updates": { "ap_reboot_task_details": {"reboot_api_response": reboot_status["apList"]}, @@ -3810,7 +3969,8 @@ def reboot_access_point(self, ap_list): self.log(self.msg, "ERROR") self.log("Reboot Task Details: {0} .".format(self.pprint( task_details_response)), "ERROR") - reboot_status = self.access_point_reboot_status(task_id) + reboot_status = self.access_point_reboot_status( + task_id) responses["accesspoints_updates"] = { "ap_reboot_task_details": { "status": task_details_response.get("status"), @@ -3824,12 +3984,15 @@ def reboot_access_point(self, ap_list): else: self.msg = "Failed to receive a valid response from AP reboot API." self.log(self.msg, "ERROR") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() except Exception as e: - error_msg = 'An error occurred during access point reboot: {0}'.format(str(e)) + error_msg = 'An error occurred during access point reboot: {0}'.format( + str(e)) self.log(error_msg, "ERROR") - self.set_operation_result("failed", False, error_msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, error_msg, "ERROR").check_return_status() def access_point_reboot_status(self, task_id): """ @@ -3849,16 +4012,20 @@ def access_point_reboot_status(self, task_id): op_modifies=True, params={"parentTaskId": task_id}, ) - self.log("Response from ap reboot status: {0}".format(self.pprint(response)), "INFO") + self.log("Response from ap reboot status: {0}".format( + self.pprint(response)), "INFO") if response and isinstance(response[0], dict): return response[0] error_msg = "Invalid response format or missing data in AP reboot status." self.log(error_msg, "ERROR") - self.set_operation_result("failed", False, error_msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, error_msg, "ERROR").check_return_status() except Exception as e: - error_msg = 'An error occurred during access point reboot status: {0}'.format(str(e)) + error_msg = 'An error occurred during access point reboot status: {0}'.format( + str(e)) self.log(error_msg, "ERROR") - self.set_operation_result("failed", False, error_msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, error_msg, "ERROR").check_return_status() def reset_access_point(self, ap_list): """ @@ -3872,38 +4039,46 @@ def reset_access_point(self, ap_list): dict: A dictionary containing the result of the access point factory reset response. """ try: - self.log('Resetting the list of APs: {0}'.format(self.pprint(ap_list)), "INFO") + self.log('Resetting the list of APs: {0}'.format( + self.pprint(ap_list)), "INFO") response = self.dnac._exec( family="wireless", function='factory_reset_access_points', op_modifies=True, - params={"apMacAddresses": ap_list, "keepStaticIPConfig": False}, + params={"apMacAddresses": ap_list, + "keepStaticIPConfig": False}, ) - self.log("Response from factory_reset_access_points: {0}".format(str(response.get("response"))), "INFO") + self.log("Response from factory_reset_access_points: {0}".format( + str(response.get("response"))), "INFO") if not (response or isinstance(response, dict)): self.msg = "Failed to receive a valid response from 'factory_reset_access_points' API." self.log(self.msg, "ERROR") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() task_id = response.get("response", {}).get("taskId") if not task_id: self.msg = "Failed to retrieve task id from 'factory_reset_access_points' API response." self.log(self.msg, "ERROR") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() resync_retry_count = int(self.payload.get("dnac_api_task_timeout")) - resync_retry_interval = int(self.payload.get("dnac_task_poll_interval")) + resync_retry_interval = int( + self.payload.get("dnac_task_poll_interval")) while resync_retry_count: task_details_response = self.get_tasks_by_id(task_id) - self.log("Status of the reset task: {0} .".format(self.status), "INFO") + self.log("Status of the reset task: {0} .".format( + self.status), "INFO") responses = {} if task_details_response.get("endTime") is not None: if task_details_response.get("status") == "SUCCESS": self.log("Reset Task Details: {0} .".format(self.pprint( task_details_response)), "INFO") - self.msg = "APs {0} reset successfully".format(str(ap_list)) + self.msg = "APs {0} reset successfully".format( + str(ap_list)) reset_status = self.access_point_reset_status(task_id) responses = { "accesspoints_updates": { @@ -3922,22 +4097,26 @@ def reset_access_point(self, ap_list): self.log("Reset Task Details: {0} .".format(self.pprint( task_details_response)), "ERROR") reset_status = self.access_point_reset_status(task_id) - self.log("Reset Error Details: {0} .".format(self.pprint(reset_status)), "ERROR") + self.log("Reset Error Details: {0} .".format( + self.pprint(reset_status)), "ERROR") responses["accesspoints_updates"] = { "ap_reset_task_details": { "status": task_details_response.get("status"), "reset_api_response": reset_status.get("apResponseInfoList") }, "ap_reset_status": self.msg} - self.set_operation_result("failed", False, self.msg, "ERROR", responses).check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR", responses).check_return_status() time.sleep(resync_retry_interval) resync_retry_count = resync_retry_count - 1 except Exception as e: - error_msg = 'An error occurred during access point reset: {0}'.format(str(e)) + error_msg = 'An error occurred during access point reset: {0}'.format( + str(e)) self.log(error_msg, "ERROR") - self.set_operation_result("failed", False, error_msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, error_msg, "ERROR").check_return_status() def access_point_reset_status(self, task_id): """ @@ -3956,18 +4135,22 @@ def access_point_reset_status(self, task_id): function='get_access_points_factory_reset_status', params={"task_id": task_id}, ) - self.log("Response from ap reset status: {0}".format(self.pprint(response)), "INFO") + self.log("Response from ap reset status: {0}".format( + self.pprint(response)), "INFO") if response and isinstance(response.get("response")[0], dict): return response.get("response", {})[0] error_msg = "Invalid response format or missing data in AP reset status." self.log(error_msg, "ERROR") - self.set_operation_result("failed", False, error_msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, error_msg, "ERROR").check_return_status() except Exception as e: - error_msg = 'An error occurred during access point reset status: {0}'.format(str(e)) + error_msg = 'An error occurred during access point reset status: {0}'.format( + str(e)) self.log(error_msg, "ERROR") - self.set_operation_result("failed", False, error_msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, error_msg, "ERROR").check_return_status() def reboot_factory_reset_function(self, ap_list, reboot_or_reset): """ @@ -3983,26 +4166,32 @@ def reboot_factory_reset_function(self, ap_list, reboot_or_reset): """ ap_indentity = list(ap_list.keys())[0] if ap_indentity and len(ap_list.get(ap_indentity)) > 100: - error_msg = "Maximum allowed AP list 100 but passed {0}".format(str(len(ap_list.get(ap_indentity)))) + error_msg = "Maximum allowed AP list 100 but passed {0}".format( + str(len(ap_list.get(ap_indentity)))) self.log(error_msg, "ERROR") - self.set_operation_result("failed", False, error_msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, error_msg, "ERROR").check_return_status() if ap_indentity and ap_indentity in self.keymap and len(ap_list.get(ap_indentity)) > 0: eth_mac_list = [] for each_ap in ap_list[ap_indentity]: ap_indentity_param = {self.keymap[ap_indentity]: each_ap} - self.log("{0}: {1}".format(reboot_or_reset, str(ap_indentity_param)), "INFO") - ap_exist, ap_details = self.get_accesspoint_details(ap_indentity_param) + self.log("{0}: {1}".format(reboot_or_reset, + str(ap_indentity_param)), "INFO") + ap_exist, ap_details = self.get_accesspoint_details( + ap_indentity_param) eth_mac_list.append(ap_details.get("ap_ethernet_mac_address")) if eth_mac_list: - self.log("Ethernet MAC addresses to {0}: {1}".format(reboot_or_reset, eth_mac_list), "INFO") + self.log("Ethernet MAC addresses to {0}: {1}".format( + reboot_or_reset, eth_mac_list), "INFO") if reboot_or_reset == "reboot_aps": self.reboot_access_point(eth_mac_list) else: self.reset_access_point(eth_mac_list) else: - self.log("No valid Ethernet MAC addresses found for {0}.".format(reboot_or_reset), "WARNING") + self.log("No valid Ethernet MAC addresses found for {0}.".format( + reboot_or_reset), "WARNING") return self @@ -4024,10 +4213,12 @@ def bulk_ap_update(self, bulk_config): ap_output_list = [] if ap_exist and len(ap_details) > 0: - self.log("Access points exist. Total count: {0}".format(str(len(ap_details))), "INFO") + self.log("Access points exist. Total count: {0}".format( + str(len(ap_details))), "INFO") for each_ap in ap_details: - ap_config_exists, ap_configuration = self.get_accesspoint_config(each_ap["ap_ethernet_mac_address"]) + ap_config_exists, ap_configuration = self.get_accesspoint_config( + each_ap["ap_ethernet_mac_address"]) self.log("Access point configuration exists: {0}, Current configuration: {1}" .format(ap_config_exists, self.pprint(ap_configuration)), "INFO") self.want = bulk_config.get("common_fields_to_change") @@ -4039,9 +4230,11 @@ def bulk_ap_update(self, bulk_config): if ap_name: self.want["ap_name"] = ap_name[0] ap_output_list.append(ap_name[0]) - self.log("Identified AP name: {0}".format(ap_name[0]), "INFO") + self.log("Identified AP name: {0}".format( + ap_name[0]), "INFO") else: - self.log("No matching AP name found for MAC: {0}".format(each_ap["mac_address"]), "WARNING") + self.log("No matching AP name found for MAC: {0}".format( + each_ap["mac_address"]), "WARNING") self.log("Access point WANT configuration exists: {0}, Current configuration: {1}" .format(ap_config_exists, self.pprint(self.want)), "INFO") @@ -4051,40 +4244,51 @@ def bulk_ap_update(self, bulk_config): temp_dict = {} if consolidated_config.get(self.keymap["ap_name"]) is not None: - temp_dict[self.keymap["ap_name"]] = consolidated_config.get(self.keymap["ap_name"]) + temp_dict[self.keymap["ap_name"]] = consolidated_config.get( + self.keymap["ap_name"]) temp_dict["apNameNew"] = consolidated_config["apNameNew"] - temp_dict[self.keymap["mac_address"]] = consolidated_config[self.keymap["mac_address"]] + temp_dict[self.keymap["mac_address"] + ] = consolidated_config[self.keymap["mac_address"]] elif consolidated_config.get(self.keymap["mac_address"]) is not None: - temp_dict[self.keymap["mac_address"]] = consolidated_config.get(self.keymap["mac_address"]) + temp_dict[self.keymap["mac_address"]] = consolidated_config.get( + self.keymap["mac_address"]) ap_update_list.append(temp_dict) - self.log("Temp dict for AP {0}: {1}".format(each_ap["mac_address"], self.pprint(temp_dict)), "DEBUG") + self.log("Temp dict for AP {0}: {1}".format( + each_ap["mac_address"], self.pprint(temp_dict)), "DEBUG") common_config.update(consolidated_config) common_config["bulk_update"] = True common_config["ap_list"] = ap_update_list - self.log("Common configuration for bulk update: {0}".format(self.pprint(common_config)), "INFO") + self.log("Common configuration for bulk update: {0}".format( + self.pprint(common_config)), "INFO") task_response = self.update_ap_configuration(common_config) - self.log("Access Point update response: {0} .".format(task_response), "INFO") + self.log("Access Point update response: {0} .".format( + task_response), "INFO") responses = {} if task_response and isinstance(task_response, dict): resync_retry_count = self.payload.get("dnac_api_task_timeout") - resync_retry_interval = self.payload.get("dnac_task_poll_interval") + resync_retry_interval = self.payload.get( + "dnac_task_poll_interval") self.log("Starting task polling with timeout: {0} and interval: {1}". format(str(resync_retry_count), str(resync_retry_interval)), "INFO") while resync_retry_count: task_details_response = self.get_tasks_by_id( task_response["response"]["taskId"]) - self.log("Status of the task: {0} .".format(self.status), "INFO") + self.log("Status of the task: {0} .".format( + self.status), "INFO") if task_details_response.get("endTime") is not None: if task_details_response.get("status") == "FAILURE": self.result["changed"] = True if self.result["changed"] is True else False self.msg = "Unable to get success response, hence AP config not updated" self.log(self.msg, "ERROR") - self.log("Task Details: {0} .".format(self.pprint(task_details_response)), "ERROR") - failure_response = self.get_task_details_by_id(task_response["response"]["taskId"]) - self.log("Failure Details: {0} .".format(self.pprint(failure_response)), "ERROR") + self.log("Task Details: {0} .".format( + self.pprint(task_details_response)), "ERROR") + failure_response = self.get_task_details_by_id( + task_response["response"]["taskId"]) + self.log("Failure Details: {0} .".format( + self.pprint(failure_response)), "ERROR") self.set_operation_result("failed", self.result["changed"], self.msg, "ERROR", failure_response).check_return_status() else: @@ -4092,7 +4296,8 @@ def bulk_ap_update(self, bulk_config): self.result["ap_update_status"] = True self.log("Task Details: {0} .".format(self.pprint( task_details_response)), "INFO") - self.msg = "List of AP Configuration {0} updated Successfully".format(str(ap_output_list)) + self.msg = "List of AP Configuration {0} updated Successfully".format( + str(ap_output_list)) self.log(self.msg, "INFO") responses["accesspoints_updates"] = { "ap_update_config_task_details": self.get_task_details_by_id(task_details_response["id"]), @@ -4150,7 +4355,8 @@ def main(): ccc_network.status = "failed" ccc_network.msg = ( "The specified version '{0}' does not support the access point workflow feature." - "Supported version(s) start from '2.3.5.3' onwards.".format(ccc_network.get_ccc_version()) + "Supported version(s) start from '2.3.5.3' onwards.".format( + ccc_network.get_ccc_version()) ) ccc_network.log(ccc_network.msg, "ERROR") ccc_network.check_return_status() @@ -4162,15 +4368,18 @@ def main(): for reboot_reset in ("reboot_aps", "factory_reset_aps"): ap_list = ccc_network.validated_config[0].get(reboot_reset) if ap_list is not None: - ccc_network.validate_ap_config_parameters(ccc_network.validated_config[0]).check_return_status() + ccc_network.validate_ap_config_parameters( + ccc_network.validated_config[0]).check_return_status() ccc_network.reboot_factory_reset_function(ap_list, reboot_reset) module.exit_json(**ccc_network.result) bulk_updates = ccc_network.validated_config[0].get("bulk_update_aps") if bulk_updates is not None: - ccc_network.log("Bulk List: {0}".format(ccc_network.pprint(bulk_updates)), "INFO") + ccc_network.log("Bulk List: {0}".format( + ccc_network.pprint(bulk_updates)), "INFO") ccc_network.reset_values() - ccc_network.validate_ap_config_parameters(bulk_updates).check_return_status() + ccc_network.validate_ap_config_parameters( + bulk_updates).check_return_status() ccc_network.bulk_ap_update(bulk_updates) module.exit_json(**ccc_network.result) @@ -4185,7 +4394,8 @@ def main(): ccc_network.log("Starting verify AP details after {0} seconds".format( str(waiting_time_to_verify)), "INFO") time.sleep(waiting_time_to_verify) - ccc_network.verify_diff_state_apply[state](config).check_return_status() + ccc_network.verify_diff_state_apply[state]( + config).check_return_status() ccc_network.consolidate_output() module.exit_json(**ccc_network.result) diff --git a/plugins/modules/device_configs_backup_workflow_manager.py b/plugins/modules/device_configs_backup_workflow_manager.py index b8118c01e0..56c9176f7b 100644 --- a/plugins/modules/device_configs_backup_workflow_manager.py +++ b/plugins/modules/device_configs_backup_workflow_manager.py @@ -5,9 +5,20 @@ # 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 +import time +import re +import string +import random +from io import BytesIO +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts +) +from ansible.module_utils.basic import AnsibleModule __metaclass__ = type -__author__ = ("Abinash Mishra, Rugvedi Kapse, Madhan Sankaranarayanan, Sonali Deepthi Kesali") +__author__ = ( + "Abinash Mishra, Rugvedi Kapse, Madhan Sankaranarayanan, Sonali Deepthi Kesali") DOCUMENTATION = r""" --- @@ -378,23 +389,13 @@ HAS_PATHLIB = False pathlib = None -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts -) -from io import BytesIO -import random -import string -import re -import time - class Device_configs_backup(DnacBase): """ Class containing member attributes for device_configs_backup workflow_manager module """ + def __init__(self, module): super().__init__(module) self.skipped_devices_list = [] @@ -463,7 +464,8 @@ def validate_input(self): # If validation is successful, update the result self.validated_config = valid_device_configs_backup - self.msg = "Successfully validated playbook configuration parameters using 'validate_input': {0}".format(str(valid_device_configs_backup)) + self.msg = "Successfully validated playbook configuration parameters using 'validate_input': {0}".format( + str(valid_device_configs_backup)) self.status = "success" return self @@ -498,7 +500,8 @@ def get_device_list_params(self, config): for parameter, parameter_name in parameters_list.items(): if config.get(parameter): get_device_list_params[parameter_name] = config.get(parameter) - self.log("get_device_list_params: {0}".format(get_device_list_params), "DEBUG") + self.log("get_device_list_params: {0}".format( + get_device_list_params), "DEBUG") return get_device_list_params def get_device_ids_by_params(self, get_device_list_params): @@ -534,22 +537,25 @@ def get_device_ids_by_params(self, get_device_list_params): op_modifies=True, params=get_device_list_params ) - self.log("Response received post 'get_device_list' API call with offset {0}: {1}".format(offset, str(response)), "DEBUG") + self.log("Response received post 'get_device_list' API call with offset {0}: {1}".format( + offset, str(response)), "DEBUG") # Check if a valid response is received if not response.get("response"): - self.log("Exiting the loop because no devices were returned after increasing the offset. Current offset: {0}".format(offset)) + self.log( + "Exiting the loop because no devices were returned after increasing the offset. Current offset: {0}".format(offset)) break # Exit loop if no devices are returned # Iterate over the devices in the response for device_info in response.get("response", []): processed_device_count += 1 - device_ip = device_info.get("managementIpAddress", "Unknown IP") + device_ip = device_info.get( + "managementIpAddress", "Unknown IP") # Check if the device is reachable and managed if device_info.get("reachabilityStatus") == "Reachable" and device_info.get("collectionStatus") == "Managed": # Skip Unified AP devices - if device_info.get("family") != "Unified AP" : + if device_info.get("family") != "Unified AP": device_id = device_info["id"] mgmt_ip_to_instance_id_map[device_ip] = device_id else: @@ -566,7 +572,8 @@ def get_device_ids_by_params(self, get_device_list_params): skipped_device_count += 1 msg = ( "Skipping device {0} as its status is {1} or its collectionStatus is {2}.".format( - device_ip, device_info.get("reachabilityStatus"), device_info.get("collectionStatus") + device_ip, device_info.get( + "reachabilityStatus"), device_info.get("collectionStatus") ) ) self.log(msg, "INFO") @@ -575,17 +582,22 @@ def get_device_ids_by_params(self, get_device_list_params): offset += limit # Log the total number of devices processed and skipped - self.log("Total number of devices received: {0}".format(processed_device_count), "INFO") - self.log("Number of devices that are Unreachable or APs: {0}".format(skipped_device_count), "INFO") - self.log("Config Backup Operation can be performed on the following filtered devices: {0}".format(len(mgmt_ip_to_instance_id_map)), "INFO") + self.log("Total number of devices received: {0}".format( + processed_device_count), "INFO") + self.log("Number of devices that are Unreachable or APs: {0}".format( + skipped_device_count), "INFO") + self.log("Config Backup Operation can be performed on the following filtered devices: {0}".format( + len(mgmt_ip_to_instance_id_map)), "INFO") except Exception as e: # Log an error message if any exception occurs during the process - self.log("Error fetching device IDs from Cisco Catalyst Center. Error details: {0}".format(str(e)), "ERROR") + self.log("Error fetching device IDs from Cisco Catalyst Center. Error details: {0}".format( + str(e)), "ERROR") # Log an error if no reachable devices are found if not mgmt_ip_to_instance_id_map: - self.log("No reachable devices found among the provided parameters: {0}".format(mgmt_ip_to_instance_id_map), "ERROR") + self.log("No reachable devices found among the provided parameters: {0}".format( + mgmt_ip_to_instance_id_map), "ERROR") return mgmt_ip_to_instance_id_map @@ -607,26 +619,32 @@ def get_device_id_list(self, config): # Check if site_list is provided in the config site_list = config.get("site_list") if site_list: - self.log("List of site(s) provided in the input: {0}".format(site_list)) + self.log( + "List of site(s) provided in the input: {0}".format(site_list)) # Use a set to ensure unique sites unique_sites = set(site_list) - self.log("Attempting to get Device Id(s) of all device(s) from the provided for site(s): {0}".format(unique_sites), "DEBUG") + self.log("Attempting to get Device Id(s) of all device(s) from the provided for site(s): {0}".format( + unique_sites), "DEBUG") # Retrieve device IDs for each site in the unique_sites set for site_name in unique_sites: - site_mgmt_ip_to_instance_id_map, skipped_devices_list = self.get_reachable_devices_from_site(site_name) + site_mgmt_ip_to_instance_id_map, skipped_devices_list = self.get_reachable_devices_from_site( + site_name) self.log("Retrieved following Device Id(s) of device(s): {0} from the provided site: {1}".format( site_mgmt_ip_to_instance_id_map, site_name), "DEBUG") - mgmt_ip_to_instance_id_map.update(site_mgmt_ip_to_instance_id_map) + mgmt_ip_to_instance_id_map.update( + site_mgmt_ip_to_instance_id_map) # Get additional device list parameters excluding site_list get_device_list_params = self.get_device_list_params(config) if get_device_list_params: self.log("Attempting to get Device Id(s) of all device(s) using parameters(excluding site_list): {0}".format( get_device_list_params), "DEBUG") - params_mgmt_ip_to_instance_id_map = self.get_device_ids_by_params(get_device_list_params) - mgmt_ip_to_instance_id_map.update(params_mgmt_ip_to_instance_id_map) + params_mgmt_ip_to_instance_id_map = self.get_device_ids_by_params( + get_device_list_params) + mgmt_ip_to_instance_id_map.update( + params_mgmt_ip_to_instance_id_map) self.log("Retrieved following Device Id(s) of device(s): {0} from the provided parameters(excluding site_list).".format( mgmt_ip_to_instance_id_map), "DEBUG") @@ -635,8 +653,10 @@ def get_device_id_list(self, config): get_device_list_params = self.get_device_list_params(config) self.log("Attempting to get Device Id(s) of all device(s) using parameters(excluding site_list): {0}".format( get_device_list_params), "DEBUG") - params_mgmt_ip_to_instance_id_map = self.get_device_ids_by_params(get_device_list_params) - mgmt_ip_to_instance_id_map.update(params_mgmt_ip_to_instance_id_map) + params_mgmt_ip_to_instance_id_map = self.get_device_ids_by_params( + get_device_list_params) + mgmt_ip_to_instance_id_map.update( + params_mgmt_ip_to_instance_id_map) self.log("Retrieved following Device Id(s) of device(s): {0} from the provided parameters(excluding site_list).".format( mgmt_ip_to_instance_id_map), "DEBUG") @@ -662,7 +682,8 @@ def validate_ip4_address_list(self, ip_address_list): # Log a success message indicating all IP addresses are valid ip_address_list_str = ", ".join(ip_address_list) - self.log("Successfully validated the IP address(es): {0}".format(ip_address_list_str), "DEBUG") + self.log("Successfully validated the IP address(es): {0}".format( + ip_address_list_str), "DEBUG") def validate_file_password(self, file_password): """ @@ -726,7 +747,8 @@ def password_generator(self): password = "".join(password_list) # Log the password generation event - self.log("File password is generated using the password generator API", "INFO") + self.log( + "File password is generated using the password generator API", "INFO") return password @@ -767,7 +789,8 @@ def export_device_configurations(self, export_device_configurations_params): task ID of the export operation. If an error occurs, it logs an error message, updates the result, and checks the return status. """ - task_id = self.get_taskid_post_api_call("configuration_archive", "export_device_configurations", export_device_configurations_params) + task_id = self.get_taskid_post_api_call( + "configuration_archive", "export_device_configurations", export_device_configurations_params) try: # Make an API call to export device configurations response = self.dnac._exec( @@ -776,24 +799,28 @@ def export_device_configurations(self, export_device_configurations_params): op_modifies=True, params=export_device_configurations_params, ) - self.log("Response received post 'export_device_configurations' API call: {0}".format(str(response)), "DEBUG") + self.log("Response received post 'export_device_configurations' API call: {0}".format( + str(response)), "DEBUG") # Process the response if available if response["response"]: self.result.update(dict(response=response["response"])) task_id = response["response"].get("taskId") - self.log("Task Id for the 'export_device_configurations' task is {0}".format(task_id), "INFO") + self.log("Task Id for the 'export_device_configurations' task is {0}".format( + task_id), "INFO") # Return the task ID return task_id else: - self.log("No response received from the 'export_device_configurations' API call.", "WARNING") + self.log( + "No response received from the 'export_device_configurations' API call.", "WARNING") return None except Exception as e: # Log an error message and fail if an exception occurs self.msg = ( "An error occurred while Exporting Device Configurations from the Cisco Catalyst Center. " - "export_device_configurations_params: {0} Error: {1}".format(export_device_configurations_params, str(e)) + "export_device_configurations_params: {0} Error: {1}".format( + export_device_configurations_params, str(e)) ) self.set_operation_result("failed", False, self.msg, "ERROR") self.check_return_status() @@ -812,7 +839,8 @@ def download_file(self, additional_status_url=None): If an error occurs, it logs an error message, updates the result, and checks the return status. """ # Log the download URL for debugging purposes - self.log("Initiating download from URL: {0}".format(additional_status_url), "INFO") + self.log("Initiating download from URL: {0}".format( + additional_status_url), "INFO") file_id = additional_status_url.split("/")[-1] try: response = self.dnac._exec( @@ -821,7 +849,8 @@ def download_file(self, additional_status_url=None): op_modifies=True, params={"file_id": file_id}, ) - self.log("Response received post 'download_a_file_by_fileid' API Call : {0}".format(str(response)), "DEBUG") + self.log("Response received post 'download_a_file_by_fileid' API Call : {0}".format( + str(response)), "DEBUG") # Check if response returned if response and response.data: @@ -830,7 +859,8 @@ def download_file(self, additional_status_url=None): self.msg = "No response received post the 'download_a_file_by_fileid' API call." return None except Exception as e: - self.msg = "The Backup Config file with File ID: {0} could not be downloaded due to the following error: {1}".format(file_id, e) + self.msg = "The Backup Config file with File ID: {0} could not be downloaded due to the following error: {1}".format( + file_id, e) self.set_operation_result("failed", False, self.msg, "ERROR") self.check_return_status() @@ -853,7 +883,8 @@ def unzip_data(self, file_id, file_data): # Convert the binary file data to a BytesIO object for processing zip_data = BytesIO(file_data) - self.log("Collected ZIP Data for file with ID: {0}".format(file_id), "INFO") + self.log("Collected ZIP Data for file with ID: {0}".format( + file_id), "INFO") # Create the directory path if it does not exist self.log("Creating directory path: {0}".format(file_path), "DEBUG") @@ -861,13 +892,15 @@ def unzip_data(self, file_id, file_data): try: # Unzip the file using the provided file password - self.log("Unzipping Backup Config file with file ID: {0} after completion of download.".format(file_id), "INFO") + self.log("Unzipping Backup Config file with file ID: {0} after completion of download.".format( + file_id), "INFO") with pyzipper.AESZipFile(zip_data, "r") as f: f.pwd = bytes(file_password, encoding="utf-8") f.extractall(path=str(file_path)) return True except Exception as e: - self.msg = "Error in unzipping Backup Config file with file ID: {0}. Error: {1}".format(file_id, e) + self.msg = "Error in unzipping Backup Config file with file ID: {0}. Error: {1}".format( + file_id, e) self.set_operation_result("failed", False, self.msg, "ERROR") self.check_return_status() @@ -884,19 +917,23 @@ def get_export_device_config_task_status(self, task_id): file if the task completes successfully. """ task_name = "Backup Device Configuration" - success_msg = "{0} Task with task ID {1} completed successfully. Exiting the loop.".format(task_name, task_id) + success_msg = "{0} Task with task ID {1} completed successfully. Exiting the loop.".format( + task_name, task_id) if self.dnac_version <= self.version_2_3_5_3: progress_validation = "Device configuration Successfully exported as password protected ZIP" failure_msg = ( "An error occurred while performing {0} task with task ID {1} for export_device_configurations_params: {2}" .format(task_name, task_id, self.want.get("export_device_configurations_params")) ) - self.get_task_status_from_task_by_id(task_id, task_name, failure_msg, success_msg, progress_validation=progress_validation) + self.get_task_status_from_task_by_id( + task_id, task_name, failure_msg, success_msg, progress_validation=progress_validation) else: - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) if self.status == "success": - self.log("Task '{0}' completed successfully for task ID {1}.".format(task_name, task_id), "INFO") + self.log("Task '{0}' completed successfully for task ID {1}.".format( + task_name, task_id), "INFO") if self.dnac_version <= self.version_2_3_5_3: response = self.get_task_details(task_id) additional_status_url = response.get("additionalStatusURL") @@ -905,23 +942,31 @@ def get_export_device_config_task_status(self, task_id): additional_status_url = response.get("resultLocation") if not additional_status_url: - self.msg = "Error retrieving the Device Config Backup file ID for task ID {0}".format(task_id) + self.msg = "Error retrieving the Device Config Backup file ID for task ID {0}".format( + task_id) self.fail_and_exit(self.msg) - self.log("Additional status URL retrieved: {0}".format(additional_status_url), "DEBUG") + self.log("Additional status URL retrieved: {0}".format( + additional_status_url), "DEBUG") # Perform additional tasks after breaking the loop - mgmt_ip_to_instance_id_map = self.want.get("mgmt_ip_to_instance_id_map") + mgmt_ip_to_instance_id_map = self.want.get( + "mgmt_ip_to_instance_id_map") # Download the file using the additional status URL - self.log("Downloading the Device Config Backup file from {0}.".format(additional_status_url), "DEBUG") - file_id, downloaded_file = self.download_file(additional_status_url=additional_status_url) - self.log("Retrived file data for file ID: {0}.".format(file_id), "DEBUG") + self.log("Downloading the Device Config Backup file from {0}.".format( + additional_status_url), "DEBUG") + file_id, downloaded_file = self.download_file( + additional_status_url=additional_status_url) + self.log("Retrived file data for file ID: {0}.".format( + file_id), "DEBUG") if not downloaded_file: - self.msg = "Error downloading Device Config Backup file(s) with file ID: {0}. ".format(file_id) + self.msg = "Error downloading Device Config Backup file(s) with file ID: {0}. ".format( + file_id) self.fail_and_exit(self.msg) # Unzip the downloaded file - self.log("Unzipping the downloaded Device Config Backup file(s) for file ID: {0}.".format(file_id), "DEBUG") + self.log("Unzipping the downloaded Device Config Backup file(s) for file ID: {0}.".format( + file_id), "DEBUG") download_status = self.unzip_data(file_id, downloaded_file) if download_status: self.log("{0} task has been successfully performed on {1} device(s): {2}.".format( @@ -935,7 +980,8 @@ def get_export_device_config_task_status(self, task_id): ) self.set_operation_result("success", True, self.msg, "INFO") else: - self.msg = "Error unzipping Device Config Backup file(s) with file ID: {0}. ".format(file_id) + self.msg = "Error unzipping Device Config Backup file(s) with file ID: {0}. ".format( + file_id) self.fail_and_exit(self.msg) return self @@ -971,9 +1017,11 @@ def get_want(self, config): # Retrieve the device ID list based on the provided configuration mgmt_ip_to_instance_id_map = self.get_device_id_list(config) - self.log("Retrived the Device ID list based on the provided parameters: {0}".format(mgmt_ip_to_instance_id_map), "DEBUG") + self.log("Retrived the Device ID list based on the provided parameters: {0}".format( + mgmt_ip_to_instance_id_map), "DEBUG") if not mgmt_ip_to_instance_id_map: - self.msg = "No reachable devices found among the provided parameters: {0}".format(config) + self.msg = "No reachable devices found among the provided parameters: {0}".format( + config) self.set_operation_result("failed", False, self.msg, "WARNING") return self @@ -981,7 +1029,8 @@ def get_want(self, config): len(mgmt_ip_to_instance_id_map), mgmt_ip_to_instance_id_map)) # Prepare the desired state (want) - self.want["export_device_configurations_params"] = self.export_device_configurations_params(file_password, mgmt_ip_to_instance_id_map) + self.want["export_device_configurations_params"] = self.export_device_configurations_params( + file_password, mgmt_ip_to_instance_id_map) self.want["mgmt_ip_to_instance_id_map"] = mgmt_ip_to_instance_id_map self.want["file_password"] = file_password self.want["file_path"] = file_path @@ -1047,7 +1096,8 @@ def verify_diff_merged(self): self.msg = ( "An error occurred while verifying the success of the backup configuration operation. " "The Device Config Backup operation may not have been successful since the backup files " - "were not found at the specified path. Error: {0}".format(str(e)) + "were not found at the specified path. Error: {0}".format( + str(e)) ) self.set_operation_result("failed", False, self.msg, "ERROR") return self @@ -1114,9 +1164,11 @@ def main(): for config in ccc_device_configs_backup.validated_config: ccc_device_configs_backup.reset_values() ccc_device_configs_backup.get_want(config).check_return_status() - ccc_device_configs_backup.get_diff_state_apply[state]().check_return_status() + ccc_device_configs_backup.get_diff_state_apply[state]( + ).check_return_status() if config_verify: - ccc_device_configs_backup.verify_diff_state_apply[state]().check_return_status() + ccc_device_configs_backup.verify_diff_state_apply[state]( + ).check_return_status() # Exit with the result obtained from the NetworkCompliance object module.exit_json(**ccc_device_configs_backup.result) diff --git a/plugins/modules/device_credential_intent.py b/plugins/modules/device_credential_intent.py index f012e0bbca..69058c460b 100644 --- a/plugins/modules/device_credential_intent.py +++ b/plugins/modules/device_credential_intent.py @@ -5,6 +5,13 @@ """Ansible module to perform operations on device credentials in Cisco DNA Center.""" from __future__ import absolute_import, division, print_function +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + get_dict_result, +) +from ansible.module_utils.basic import AnsibleModule +import copy __metaclass__ = type __author__ = ['Muthu Rakesh, Madhan Sankaranarayanan'] @@ -701,14 +708,6 @@ } """ -import copy -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - get_dict_result, -) - class DnacCredential(DnacBase): """Class containing member attributes for device credential intent module""" @@ -853,14 +852,17 @@ def validate_input(self): # Validate playbook params against the specification (temp_spec) self.config = self.camel_to_snake_case(self.config) - valid_temp, invalid_params = validate_list_of_dicts(self.config, temp_spec) + valid_temp, invalid_params = validate_list_of_dicts( + self.config, temp_spec) if invalid_params: - self.msg = "Invalid parameters in playbook: {0}".format("\n".join(invalid_params)) + self.msg = "Invalid parameters in playbook: {0}".format( + "\n".join(invalid_params)) self.status = "failed" return self self.validated_config = valid_temp - self.log("Successfully validated playbook config params: {0}".format(valid_temp), "INFO") + self.log("Successfully validated playbook config params: {0}".format( + valid_temp), "INFO") self.msg = "Successfully validated input from the playbook" self.status = "success" return self @@ -884,14 +886,16 @@ def get_site_id(self, site_name): op_modifies=True, params={"name": site_name}, ) - self.log("Received API response from 'get_site': {0}".format(response), "DEBUG") + self.log("Received API response from 'get_site': {0}".format( + response), "DEBUG") if not response: self.log("Failed to retrieve the site ID for the site name: {0}" .format(site_name), "ERROR") return None _id = response.get("response")[0].get("id") - self.log("Site ID for the site name {0}: {1}".format(site_name, _id), "INFO") + self.log("Site ID for the site name {0}: {1}".format( + site_name, _id), "INFO") except Exception as e: self.log("Exception occurred while getting site_id from the site_name: {0}" .format(e), "CRITICAL") @@ -1179,13 +1183,15 @@ def get_snmpV2cRead_credentials(self, CredentialDetails, global_credentials): snmpV2cReadDetail = None snmpV2cReadId = snmpV2cReadCredential.get("id") if snmpV2cReadId: - snmpV2cReadDetail = get_dict_result(snmpV2cRead_details, "id", snmpV2cReadId) + snmpV2cReadDetail = get_dict_result( + snmpV2cRead_details, "id", snmpV2cReadId) if not snmpV2cReadDetail: self.msg = "snmpV2cRead credential ID is invalid" self.status = "failed" return self - snmpV2cReadOldDescription = snmpV2cReadCredential.get("old_description") + snmpV2cReadOldDescription = snmpV2cReadCredential.get( + "old_description") if snmpV2cReadOldDescription and (not snmpV2cReadDetail): snmpV2cReadDetail = get_dict_result( snmpV2cRead_details, @@ -1197,7 +1203,8 @@ def get_snmpV2cRead_credentials(self, CredentialDetails, global_credentials): self.status = "failed" return self - snmpV2cReadDescription = snmpV2cReadCredential.get("description") + snmpV2cReadDescription = snmpV2cReadCredential.get( + "description") if snmpV2cReadDescription and (not snmpV2cReadDetail): snmpV2cReadDetail = get_dict_result( snmpV2cRead_details, @@ -1232,13 +1239,15 @@ def get_snmpV2cWrite_credentials(self, CredentialDetails, global_credentials): snmpV2cWriteDetail = None snmpV2cWriteId = snmpV2cWriteCredential.get("id") if snmpV2cWriteId: - snmpV2cWriteDetail = get_dict_result(snmpV2cWrite_details, "id", snmpV2cWriteId) + snmpV2cWriteDetail = get_dict_result( + snmpV2cWrite_details, "id", snmpV2cWriteId) if not snmpV2cWriteDetail: self.msg = "snmpV2cWrite credential ID is invalid" self.status = "failed" return self - snmpV2cWriteOldDescription = snmpV2cWriteCredential.get("old_description") + snmpV2cWriteOldDescription = snmpV2cWriteCredential.get( + "old_description") if snmpV2cWriteOldDescription and (not snmpV2cWriteDetail): snmpV2cWriteDetail = get_dict_result( snmpV2cWrite_details, @@ -1250,7 +1259,8 @@ def get_snmpV2cWrite_credentials(self, CredentialDetails, global_credentials): self.status = "failed" return self - snmpV2cWriteDescription = snmpV2cWriteCredential.get("description") + snmpV2cWriteDescription = snmpV2cWriteCredential.get( + "description") if snmpV2cWriteDescription and (not snmpV2cWriteDetail): snmpV2cWriteDetail = get_dict_result( snmpV2cWrite_details, @@ -1285,13 +1295,15 @@ def get_httpsRead_credentials(self, CredentialDetails, global_credentials): httpsReadDetail = None httpsReadId = httpsReadCredential.get("id") if httpsReadId: - httpsReadDetail = get_dict_result(httpsRead_details, "id", httpsReadId) + httpsReadDetail = get_dict_result( + httpsRead_details, "id", httpsReadId) if not httpsReadDetail: self.msg = "httpsRead credential Id is invalid" self.status = "failed" return self - httpsReadOldDescription = httpsReadCredential.get("old_description") + httpsReadOldDescription = httpsReadCredential.get( + "old_description") httpsReadOldUsername = httpsReadCredential.get("old_username") if httpsReadOldDescription and httpsReadOldUsername and (not httpsReadDetail): for item in httpsRead_details: @@ -1348,14 +1360,17 @@ def get_httpsWrite_credentials(self, CredentialDetails, global_credentials): httpsWriteDetail = None httpsWriteId = httpsWriteCredential.get("id") if httpsWriteId: - httpsWriteDetail = get_dict_result(httpsWrite_details, "id", httpsWriteId) + httpsWriteDetail = get_dict_result( + httpsWrite_details, "id", httpsWriteId) if not httpsWriteDetail: self.msg = "httpsWrite credential Id is invalid" self.status = "failed" return self - httpsWriteOldDescription = httpsWriteCredential.get("old_description") - httpsWriteOldUsername = httpsWriteCredential.get("old_username") + httpsWriteOldDescription = httpsWriteCredential.get( + "old_description") + httpsWriteOldUsername = httpsWriteCredential.get( + "old_username") if httpsWriteOldDescription and httpsWriteOldUsername and (not httpsWriteDetail): for item in httpsWrite_details: if item.get("description") == httpsWriteOldDescription \ @@ -1407,7 +1422,8 @@ def get_snmpV3_credentials(self, CredentialDetails, global_credentials): snmpV3Detail = None snmpV3Id = snmpV3Credential.get("id") if snmpV3Id: - snmpV3Detail = get_dict_result(snmpV3_details, "id", snmpV3Id) + snmpV3Detail = get_dict_result( + snmpV3_details, "id", snmpV3Id) if not snmpV3Detail: self.msg = "snmpV3 credential id is invalid" self.status = "failed" @@ -1424,7 +1440,8 @@ def get_snmpV3_credentials(self, CredentialDetails, global_credentials): snmpV3Description = snmpV3Credential.get("description") if snmpV3Description and (not snmpV3Detail): - snmpV3Detail = get_dict_result(snmpV3_details, "description", snmpV3Description) + snmpV3Detail = get_dict_result( + snmpV3_details, "description", snmpV3Description) snmpV3Details.append(snmpV3Detail) return snmpV3Details @@ -1442,29 +1459,38 @@ def get_have_device_credentials(self, CredentialDetails): """ global_credentials = self.get_global_credentials_params() - cliDetails = self.get_cli_credentials(CredentialDetails, global_credentials) - snmpV2cReadDetails = self.get_snmpV2cRead_credentials(CredentialDetails, global_credentials) + cliDetails = self.get_cli_credentials( + CredentialDetails, global_credentials) + snmpV2cReadDetails = self.get_snmpV2cRead_credentials( + CredentialDetails, global_credentials) snmpV2cWriteDetails = self.get_snmpV2cWrite_credentials(CredentialDetails, global_credentials) - httpsReadDetails = self.get_httpsRead_credentials(CredentialDetails, global_credentials) - httpsWriteDetails = self.get_httpsWrite_credentials(CredentialDetails, global_credentials) - snmpV3Details = self.get_snmpV3_credentials(CredentialDetails, global_credentials) + httpsReadDetails = self.get_httpsRead_credentials( + CredentialDetails, global_credentials) + httpsWriteDetails = self.get_httpsWrite_credentials( + CredentialDetails, global_credentials) + snmpV3Details = self.get_snmpV3_credentials( + CredentialDetails, global_credentials) self.have.update({"globalCredential": {}}) if cliDetails: cliCredential = self.get_cli_params(cliDetails) - self.have.get("globalCredential").update({"cliCredential": cliCredential}) + self.have.get("globalCredential").update( + {"cliCredential": cliCredential}) if snmpV2cReadDetails: snmpV2cRead = self.get_snmpV2cRead_params(snmpV2cReadDetails) - self.have.get("globalCredential").update({"snmpV2cRead": snmpV2cRead}) + self.have.get("globalCredential").update( + {"snmpV2cRead": snmpV2cRead}) if snmpV2cWriteDetails: snmpV2cWrite = self.get_snmpV2cWrite_params(snmpV2cWriteDetails) - self.have.get("globalCredential").update({"snmpV2cWrite": snmpV2cWrite}) + self.have.get("globalCredential").update( + {"snmpV2cWrite": snmpV2cWrite}) if httpsReadDetails: httpsRead = self.get_httpsRead_params(httpsReadDetails) self.have.get("globalCredential").update({"httpsRead": httpsRead}) if httpsWriteDetails: httpsWrite = self.get_httpsWrite_params(httpsWriteDetails) - self.have.get("globalCredential").update({"httpsWrite": httpsWrite}) + self.have.get("globalCredential").update( + {"httpsWrite": httpsWrite}) if snmpV3Details: snmpV3 = self.get_snmpV3_params(snmpV3Details) self.have.get("globalCredential").update({"snmpV3": snmpV3}) @@ -1492,7 +1518,8 @@ def get_have(self, config): if config.get("global_credential_details") is not None: CredentialDetails = config.get("global_credential_details") - self.get_have_device_credentials(CredentialDetails).check_return_status() + self.get_have_device_credentials( + CredentialDetails).check_return_status() self.log("Current State (have): {0}".format(self.have), "INFO") self.msg = "Successfully retrieved the details from the Cisco DNA Center" @@ -1522,12 +1549,14 @@ def get_want_device_credentials(self, CredentialDetails): create_cli_ptr = 0 update_cli_ptr = 0 values = ["password", "description", "username", "id"] - have_cliCredential = self.have.get("globalCredential").get("cliCredential") + have_cliCredential = self.have.get( + "globalCredential").get("cliCredential") for item in cli: if not have_cliCredential or have_cliCredential[have_cli_ptr] is None: if want.get("want_create").get("cliCredential") is None: want.get("want_create").update({"cliCredential": []}) - create_credential = want.get("want_create").get("cliCredential") + create_credential = want.get( + "want_create").get("cliCredential") create_credential.append({}) for i in range(0, 3): if item.get(values[i]): @@ -1546,7 +1575,8 @@ def get_want_device_credentials(self, CredentialDetails): else: if want.get("want_update").get("cliCredential") is None: want.get("want_update").update({"cliCredential": []}) - update_credential = want.get("want_update").get("cliCredential") + update_credential = want.get( + "want_update").get("cliCredential") update_credential.append({}) if item.get("password"): update_credential[update_cli_ptr] \ @@ -1581,12 +1611,14 @@ def get_want_device_credentials(self, CredentialDetails): update_snmpv2cread_ptr = 0 values = ["read_community", "description", "id"] keys = ["readCommunity", "description", "id"] - have_snmpV2cRead = self.have.get("globalCredential").get("snmpV2cRead") + have_snmpV2cRead = self.have.get( + "globalCredential").get("snmpV2cRead") for item in snmpV2cRead: if not have_snmpV2cRead or have_snmpV2cRead[have_snmpv2cread_ptr] is None: if want.get("want_create").get("snmpV2cRead") is None: want.get("want_create").update({"snmpV2cRead": []}) - create_credential = want.get("want_create").get("snmpV2cRead") + create_credential = want.get( + "want_create").get("snmpV2cRead") create_credential.append({}) for i in range(0, 2): if item.get(values[i]): @@ -1601,7 +1633,8 @@ def get_want_device_credentials(self, CredentialDetails): else: if want.get("want_update").get("snmpV2cRead") is None: want.get("want_update").update({"snmpV2cRead": []}) - update_credential = want.get("want_update").get("snmpV2cRead") + update_credential = want.get( + "want_update").get("snmpV2cRead") update_credential.append({}) if item.get("read_community"): update_credential[update_snmpv2cread_ptr] \ @@ -1630,12 +1663,14 @@ def get_want_device_credentials(self, CredentialDetails): update_snmpv2cwrite_ptr = 0 values = ["write_community", "description", "id"] keys = ["writeCommunity", "description", "id"] - have_snmpV2cWrite = self.have.get("globalCredential").get("snmpV2cWrite") + have_snmpV2cWrite = self.have.get( + "globalCredential").get("snmpV2cWrite") for item in snmpV2cWrite: if not have_snmpV2cWrite or have_snmpV2cWrite[have_snmpv2cwrite_ptr] is None: if want.get("want_create").get("snmpV2cWrite") is None: want.get("want_create").update({"snmpV2cWrite": []}) - create_credential = want.get("want_create").get("snmpV2cWrite") + create_credential = want.get( + "want_create").get("snmpV2cWrite") create_credential.append({}) for i in range(0, 2): if item.get(values[i]): @@ -1650,7 +1685,8 @@ def get_want_device_credentials(self, CredentialDetails): else: if want.get("want_update").get("snmpV2cWrite") is None: want.get("want_update").update({"snmpV2cWrite": []}) - update_credential = want.get("want_update").get("snmpV2cWrite") + update_credential = want.get( + "want_update").get("snmpV2cWrite") update_credential.append({}) if item.get("write_community"): update_credential[update_snmpv2cwrite_ptr] \ @@ -1685,7 +1721,8 @@ def get_want_device_credentials(self, CredentialDetails): if not have_httpsRead or have_httpsRead[have_httpsread_ptr] is None: if want.get("want_create").get("httpsRead") is None: want.get("want_create").update({"httpsRead": []}) - create_credential = want.get("want_create").get("httpsRead") + create_credential = want.get( + "want_create").get("httpsRead") create_credential.append({}) for i in range(0, 3): if item.get(values[i]): @@ -1706,7 +1743,8 @@ def get_want_device_credentials(self, CredentialDetails): else: if want.get("want_update").get("httpsRead") is None: want.get("want_update").update({"httpsRead": []}) - update_credential = want.get("want_update").get("httpsRead") + update_credential = want.get( + "want_update").get("httpsRead") update_credential.append({}) if item.get("password"): update_credential[update_httpsread_ptr] \ @@ -1734,12 +1772,14 @@ def get_want_device_credentials(self, CredentialDetails): create_httpswrite_ptr = 0 update_httpswrite_ptr = 0 values = ["password", "description", "username", "id", "port"] - have_httpsWrite = self.have.get("globalCredential").get("httpsWrite") + have_httpsWrite = self.have.get( + "globalCredential").get("httpsWrite") for item in httpsWrite: if not have_httpsWrite or have_httpsWrite[have_httpswrite_ptr] is None: if want.get("want_create").get("httpsWrite") is None: want.get("want_create").update({"httpsWrite": []}) - create_credential = want.get("want_create").get("httpsWrite") + create_credential = want.get( + "want_create").get("httpsWrite") create_credential.append({}) for i in range(0, 3): if item.get(values[i]): @@ -1760,7 +1800,8 @@ def get_want_device_credentials(self, CredentialDetails): else: if want.get("want_update").get("httpsWrite") is None: want.get("want_update").update({"httpsWrite": []}) - update_credential = want.get("want_update").get("httpsWrite") + update_credential = want.get( + "want_update").get("httpsWrite") update_credential.append({}) if item.get("password"): update_credential[update_httpswrite_ptr] \ @@ -1996,7 +2037,8 @@ def get_want_assign_credentials(self, AssignCredentials): self.msg = "The username and description of the CLI credential are invalid" self.status = "failed" return self - want.get("assign_credentials").update({"cliId": cliDetail.get("id")}) + want.get("assign_credentials").update( + {"cliId": cliDetail.get("id")}) snmp_v2c_read = AssignCredentials.get("snmp_v2c_read") if snmp_v2c_read: @@ -2012,7 +2054,8 @@ def get_want_assign_credentials(self, AssignCredentials): return self snmpV2cReadDetail = None if snmpV2cReadId: - snmpV2cReadDetail = get_dict_result(snmpV2cRead_details, "id", snmpV2cReadId) + snmpV2cReadDetail = get_dict_result( + snmpV2cRead_details, "id", snmpV2cReadId) if not snmpV2cReadDetail: self.msg = "The ID of the snmpV2cRead credential is not valid." self.status = "failed" @@ -2025,7 +2068,8 @@ def get_want_assign_credentials(self, AssignCredentials): self.msg = "The username and description for the snmpV2cRead credential are invalid." self.status = "failed" return self - want.get("assign_credentials").update({"snmpV2ReadId": snmpV2cReadDetail.get("id")}) + want.get("assign_credentials").update( + {"snmpV2ReadId": snmpV2cReadDetail.get("id")}) snmp_v2c_write = AssignCredentials.get("snmp_v2c_write") if snmp_v2c_write: @@ -2041,7 +2085,8 @@ def get_want_assign_credentials(self, AssignCredentials): return self snmpV2cWriteDetail = None if snmpV2cWriteId: - snmpV2cWriteDetail = get_dict_result(snmpV2cWrite_details, "id", snmpV2cWriteId) + snmpV2cWriteDetail = get_dict_result( + snmpV2cWrite_details, "id", snmpV2cWriteId) if not snmpV2cWriteDetail: self.msg = "The ID of the snmpV2cWrite credential is invalid." self.status = "failed" @@ -2054,7 +2099,8 @@ def get_want_assign_credentials(self, AssignCredentials): self.msg = "The username and description of the snmpV2cWrite credential are invalid." self.status = "failed" return self - want.get("assign_credentials").update({"snmpV2WriteId": snmpV2cWriteDetail.get("id")}) + want.get("assign_credentials").update( + {"snmpV2WriteId": snmpV2cWriteDetail.get("id")}) https_read = AssignCredentials.get("https_read") if https_read: @@ -2071,7 +2117,8 @@ def get_want_assign_credentials(self, AssignCredentials): return self httpReadDetail = None if httpReadId: - httpReadDetail = get_dict_result(httpRead_details, "id", httpReadId) + httpReadDetail = get_dict_result( + httpRead_details, "id", httpReadId) if not httpReadDetail: self.msg = "The ID of the httpRead credential is not valid." self.status = "failed" @@ -2085,7 +2132,8 @@ def get_want_assign_credentials(self, AssignCredentials): self.msg = "The description and username for the httpRead credential are invalid." self.status = "failed" return self - want.get("assign_credentials").update({"httpRead": httpReadDetail.get("id")}) + want.get("assign_credentials").update( + {"httpRead": httpReadDetail.get("id")}) https_write = AssignCredentials.get("https_write") if https_write: @@ -2102,7 +2150,8 @@ def get_want_assign_credentials(self, AssignCredentials): return self httpWriteDetail = None if httpWriteId: - httpWriteDetail = get_dict_result(httpWrite_details, "id", httpWriteId) + httpWriteDetail = get_dict_result( + httpWrite_details, "id", httpWriteId) if not httpWriteDetail: self.msg = "The ID of the httpWrite credential is not valid." self.status = "failed" @@ -2116,7 +2165,8 @@ def get_want_assign_credentials(self, AssignCredentials): self.msg = "The description and username for the httpWrite credential are invalid." self.status = "failed" return self - want.get("assign_credentials").update({"httpWrite": httpWriteDetail.get("id")}) + want.get("assign_credentials").update( + {"httpWrite": httpWriteDetail.get("id")}) snmp_v3 = AssignCredentials.get("snmp_v3") if snmp_v3: @@ -2132,7 +2182,8 @@ def get_want_assign_credentials(self, AssignCredentials): return self snmpV3Detail = None if snmpV3Id: - snmpV3Detail = get_dict_result(snmpV3_details, "id", snmpV3Id) + snmpV3Detail = get_dict_result( + snmpV3_details, "id", snmpV3Id) if not snmpV3Detail: self.msg = "The ID of the snmpV3 credential is not valid." self.status = "failed" @@ -2145,7 +2196,8 @@ def get_want_assign_credentials(self, AssignCredentials): self.msg = "The username and description for the snmpV2cWrite credential are invalid." self.status = "failed" return self - want.get("assign_credentials").update({"snmpV3Id": snmpV3Detail.get("id")}) + want.get("assign_credentials").update( + {"snmpV3Id": snmpV3Detail.get("id")}) self.log("Desired State (want): {0}".format(want), "INFO") self.want.update(want) self.msg = "Collected the Credentials needed to be assigned from the Cisco DNA Center" @@ -2169,11 +2221,13 @@ def get_want(self, config): if config.get("global_credential_details"): CredentialDetails = config.get("global_credential_details") - self.get_want_device_credentials(CredentialDetails).check_return_status() + self.get_want_device_credentials( + CredentialDetails).check_return_status() if config.get("assign_credentials_to_site"): AssignCredentials = config.get("assign_credentials_to_site") - self.get_want_assign_credentials(AssignCredentials).check_return_status() + self.get_want_assign_credentials( + AssignCredentials).check_return_status() self.log("Desired State (want): {0}".format(self.want), "INFO") self.msg = "Successfully retrieved details from the playbook" @@ -2193,7 +2247,8 @@ def create_device_credentials(self): self """ - result_global_credential = self.result.get("response")[0].get("globalCredential") + result_global_credential = self.result.get( + "response")[0].get("globalCredential") want_create = self.want.get("want_create") if not want_create: result_global_credential.update({ @@ -2216,7 +2271,8 @@ def create_device_credentials(self): self.log("Received API response from 'create_global_credentials_v2': {0}" .format(response), "DEBUG") validation_string = "global credential addition performed" - self.check_task_response_status(response, validation_string).check_return_status() + self.check_task_response_status( + response, validation_string).check_return_status() self.log("Global credential created successfully", "INFO") result_global_credential.update({ "Creation": { @@ -2240,7 +2296,8 @@ def update_device_credentials(self): self """ - result_global_credential = self.result.get("response")[0].get("globalCredential") + result_global_credential = self.result.get( + "response")[0].get("globalCredential") # Get the result global credential and want_update from the current object want_update = self.want.get("want_update") @@ -2268,7 +2325,8 @@ def update_device_credentials(self): for value in values: if want_update.get(value) and i < len(want_update.get(value)): flag = True - credential_params.update({value: want_update.get(value)[i]}) + credential_params.update( + {value: want_update.get(value)[i]}) i = i + 1 if credential_params: final_response.append(credential_params) @@ -2281,7 +2339,8 @@ def update_device_credentials(self): self.log("Received API response for 'update_global_credentials_v2': {0}" .format(response), "DEBUG") validation_string = "global credential update performed" - self.check_task_response_status(response, validation_string).check_return_status() + self.check_task_response_status( + response, validation_string).check_return_status() self.log("Updating device credential API input parameters: {0}" .format(final_response), "DEBUG") self.log("Global device credential updated successfully", "INFO") @@ -2308,7 +2367,8 @@ def assign_credentials_to_site(self): self """ - result_assign_credential = self.result.get("response")[0].get("assignCredential") + result_assign_credential = self.result.get( + "response")[0].get("assignCredential") credential_params = self.want.get("assign_credentials") final_response = [] self.log("Assigning device credential to site API input parameters: {0}" @@ -2337,7 +2397,8 @@ def assign_credentials_to_site(self): self.log("Received API response for 'assign_device_credential_to_site_v2': {0}" .format(response), "DEBUG") validation_string = "desired common settings operation successful" - self.check_task_response_status(response, validation_string).check_return_status() + self.check_task_response_status( + response, validation_string).check_return_status() self.log("Device credential assigned to site {0} is successfully." .format(site_ids), "INFO") self.log("Desired State for assign credentials to a site: {0}" @@ -2389,10 +2450,12 @@ def delete_device_credential(self, config): self """ - result_global_credential = self.result.get("response")[0].get("globalCredential") + result_global_credential = self.result.get( + "response")[0].get("globalCredential") have_values = self.have.get("globalCredential") final_response = {} - self.log("Global device credentials to be deleted: {0}".format(have_values), "DEBUG") + self.log("Global device credentials to be deleted: {0}".format( + have_values), "DEBUG") credential_mapping = { "cliCredential": "cli_credential", "snmpV2cRead": "snmp_v2c_read", @@ -2424,7 +2487,8 @@ def delete_device_credential(self, config): self.log("Received API response for 'delete_global_credential_v2': {0}" .format(response), "DEBUG") validation_string = "global credential deleted successfully" - self.check_task_response_status(response, validation_string).check_return_status() + self.check_task_response_status( + response, validation_string).check_return_status() final_response.get(item).append(_id) config_itr = config_itr + 1 @@ -2501,18 +2565,23 @@ def verify_diff_merged(self, config): have_credential = self.have.get(credential_type) values = value_mapping.get(credential_type) for value in values: - equality = have_credential.get(value) is want_credential.get(value) + equality = have_credential.get( + value) is want_credential.get(value) if not have_credential or not equality: - self.msg = "{0} config is not applied ot the DNAC".format(credential_type) + self.msg = "{0} config is not applied ot the DNAC".format( + credential_type) self.status = "failed" return self self.log("Successfully validated global device credential", "INFO") - self.result.get("response")[0].get("globalCredential").update({"Validation": "Success"}) + self.result.get("response")[0].get( + "globalCredential").update({"Validation": "Success"}) if config.get("assign_credentials_to_site") is not None: - self.log("Successfully validated the assign device credential to site", "INFO") - self.result.get("response")[0].get("assignCredential").update({"Validation": "Success"}) + self.log( + "Successfully validated the assign device credential to site", "INFO") + self.result.get("response")[0].get( + "assignCredential").update({"Validation": "Success"}) self.msg = "Successfully validated the Global Device Credential and \ Assign Device Credential to Site." @@ -2548,8 +2617,10 @@ def verify_diff_deleted(self, config): self.status = "failed" return self - self.log("Successfully validated absence of global device credential.", "INFO") - self.result.get("response")[0].get("globalCredential").update({"Validation": "Success"}) + self.log( + "Successfully validated absence of global device credential.", "INFO") + self.result.get("response")[0].get( + "globalCredential").update({"Validation": "Success"}) self.msg = "Successfully validated the absence of Global Device Credential." self.status = "success" @@ -2596,7 +2667,8 @@ def main(): } # Create an AnsibleModule object with argument specifications - module = AnsibleModule(argument_spec=element_spec, supports_check_mode=False) + module = AnsibleModule(argument_spec=element_spec, + supports_check_mode=False) dnac_credential = DnacCredential(module) state = dnac_credential.params.get("state") config_verify = dnac_credential.params.get("config_verify") @@ -2612,9 +2684,11 @@ def main(): dnac_credential.get_have(config).check_return_status() if state != "deleted": dnac_credential.get_want(config).check_return_status() - dnac_credential.get_diff_state_apply[state](config).check_return_status() + dnac_credential.get_diff_state_apply[state]( + config).check_return_status() if config_verify: - dnac_credential.verify_diff_state_apply[state](config).check_return_status() + dnac_credential.verify_diff_state_apply[state]( + config).check_return_status() module.exit_json(**dnac_credential.result) diff --git a/plugins/modules/device_credential_workflow_manager.py b/plugins/modules/device_credential_workflow_manager.py index 163a31b293..a722ae7120 100644 --- a/plugins/modules/device_credential_workflow_manager.py +++ b/plugins/modules/device_credential_workflow_manager.py @@ -5,6 +5,13 @@ """Ansible module to perform operations on device credentials in Cisco Catalyst Center.""" from __future__ import absolute_import, division, print_function +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + get_dict_result, +) +from ansible.module_utils.basic import AnsibleModule +import copy __metaclass__ = type __author__ = ['Muthu Rakesh, Madhan Sankaranarayanan, Megha Kandari'] @@ -789,14 +796,6 @@ """ -import copy -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - get_dict_result, -) - class DeviceCredential(DnacBase): """Class containing member attributes for device_credential_workflow_manager module""" @@ -970,14 +969,17 @@ def validate_input(self): } # Validate playbook params against the specification (temp_spec) - valid_temp, invalid_params = validate_list_of_dicts(self.config, temp_spec) + valid_temp, invalid_params = validate_list_of_dicts( + self.config, temp_spec) if invalid_params: - self.msg = "Invalid parameters in playbook: {0}".format("\n".join(invalid_params)) + self.msg = "Invalid parameters in playbook: {0}".format( + "\n".join(invalid_params)) self.status = "failed" return self self.validated_config = valid_temp - self.log("Successfully validated playbook config params: {0}".format(valid_temp), "INFO") + self.log("Successfully validated playbook config params: {0}".format( + valid_temp), "INFO") self.msg = "Successfully validated input from the playbook" self.status = "success" return self @@ -1003,7 +1005,8 @@ def get_global_credentials_params(self): .format(global_credentials), "DEBUG") except Exception as msg: self.msg = ( - "Exception occurred while getting global device credentials: {0}".format(msg) + "Exception occurred while getting global device credentials: {0}".format( + msg) ) self.log(self.msg, "CRITICAL") self.status = "failed" @@ -1210,7 +1213,8 @@ def get_cli_credentials(self, credential_details, global_credentials): cli_detail = None cli_id = cli_credential.get("id") if cli_id: - cli_detail = get_dict_result(global_cli_details, "id", cli_id) + cli_detail = get_dict_result( + global_cli_details, "id", cli_id) if not cli_detail: self.msg = "CLI credential ID is invalid" self.status = "failed" @@ -1279,13 +1283,15 @@ def get_snmp_v2c_read_credentials(self, credential_details, global_credentials): snmp_v2c_read_detail = None snmp_v2c_read_id = snmp_v2c_read_credential.get("id") if snmp_v2c_read_id: - snmp_v2c_read_detail = get_dict_result(global_snmp_v2c_read_details, "id", snmp_v2c_read_id) + snmp_v2c_read_detail = get_dict_result( + global_snmp_v2c_read_details, "id", snmp_v2c_read_id) if not snmp_v2c_read_detail: self.msg = "snmp_v2c_read credential ID is invalid" self.status = "failed" return self.check_return_status() - snmp_v2c_read_description = snmp_v2c_read_credential.get("description") + snmp_v2c_read_description = snmp_v2c_read_credential.get( + "description") if snmp_v2c_read_description and (not snmp_v2c_read_detail): snmp_v2c_read_detail = get_dict_result( global_snmp_v2c_read_details, @@ -1294,7 +1300,8 @@ def get_snmp_v2c_read_credentials(self, credential_details, global_credentials): ) if not snmp_v2c_read_detail: - snmp_v2c_read_old_description = snmp_v2c_read_credential.get("old_description") + snmp_v2c_read_old_description = snmp_v2c_read_credential.get( + "old_description") if snmp_v2c_read_old_description and (not snmp_v2c_read_detail): snmp_v2c_read_detail = get_dict_result( global_snmp_v2c_read_details, @@ -1337,13 +1344,15 @@ def get_snmp_v2c_write_credentials(self, credential_details, global_credentials) snmp_v2c_write_detail = None snmp_v2c_write_id = snmp_v2c_write_credential.get("id") if snmp_v2c_write_id: - snmp_v2c_write_detail = get_dict_result(global_snmp_v2c_write_details, "id", snmp_v2c_write_id) + snmp_v2c_write_detail = get_dict_result( + global_snmp_v2c_write_details, "id", snmp_v2c_write_id) if not snmp_v2c_write_detail: self.msg = "snmp_v2c_write credential ID is invalid" self.status = "failed" return self.check_return_status() - snmp_v2c_write_description = snmp_v2c_write_credential.get("description") + snmp_v2c_write_description = snmp_v2c_write_credential.get( + "description") if snmp_v2c_write_description and (not snmp_v2c_write_detail): snmp_v2c_write_detail = get_dict_result( @@ -1353,7 +1362,8 @@ def get_snmp_v2c_write_credentials(self, credential_details, global_credentials) ) if not snmp_v2c_write_detail: - snmp_v2c_write_old_description = snmp_v2c_write_credential.get("old_description") + snmp_v2c_write_old_description = snmp_v2c_write_credential.get( + "old_description") if snmp_v2c_write_old_description and (not snmp_v2c_write_detail): snmp_v2c_write_detail = get_dict_result( global_snmp_v2c_write_details, @@ -1396,13 +1406,15 @@ def get_https_read_credentials(self, credential_details, global_credentials): https_read__detail = None https_read_id = https_read_credential.get("id") if https_read_id: - https_read__detail = get_dict_result(global_https_read_details, "id", https_read_id) + https_read__detail = get_dict_result( + global_https_read_details, "id", https_read_id) if not https_read__detail: self.msg = "https_read credential Id is invalid" self.status = "failed" return self.check_return_status() - https_read_description = https_read_credential.get("description") + https_read_description = https_read_credential.get( + "description") https_read_username = https_read_credential.get("username") if https_read_description and https_read_username and (not https_read__detail): @@ -1417,8 +1429,10 @@ def get_https_read_credentials(self, credential_details, global_credentials): https_read__detail = item if not https_read__detail: - https_read_old_description = https_read_credential.get("old_description") - https_read_old_username = https_read_credential.get("old_username") + https_read_old_description = https_read_credential.get( + "old_description") + https_read_old_username = https_read_credential.get( + "old_username") if https_read_old_description and https_read_old_username and (not https_read__detail): for item in global_https_read_details: if item.get("description") == https_read_old_description \ @@ -1465,13 +1479,15 @@ def get_https_write_credentials(self, credential_details, global_credentials): https_write_detail = None https_write_id = https_write_credential.get("id") if https_write_id: - https_write_detail = get_dict_result(global_https_write_details, "id", https_write_id) + https_write_detail = get_dict_result( + global_https_write_details, "id", https_write_id) if not https_write_detail: self.msg = "https_write credential Id is invalid" self.status = "failed" return self.check_return_status() - https_write_description = https_write_credential.get("description") + https_write_description = https_write_credential.get( + "description") https_write_username = https_write_credential.get("username") if https_write_description and https_write_username and (not https_write_detail): for item in global_https_write_details: @@ -1485,8 +1501,10 @@ def get_https_write_credentials(self, credential_details, global_credentials): https_write_detail = item if not https_write_detail: - https_write_old_description = https_write_credential.get("old_description") - https_write_old_username = https_write_credential.get("old_username") + https_write_old_description = https_write_credential.get( + "old_description") + https_write_old_username = https_write_credential.get( + "old_username") if https_write_old_description and https_write_old_username and (not https_write_detail): for item in global_https_write_details: if item.get("description") == https_write_old_description \ @@ -1535,7 +1553,8 @@ def get_snmp_v3_credentials(self, credential_details, global_credentials): snmp_v3_detail = None snmp_v3_id = snmp_v3_credential.get("id") if snmp_v3_id: - snmp_v3_detail = get_dict_result(global_snmp_v3_details, "id", snmp_v3_id) + snmp_v3_detail = get_dict_result( + global_snmp_v3_details, "id", snmp_v3_id) if not snmp_v3_detail: self.msg = "snmp_v3 credential id is invalid" self.status = "failed" @@ -1544,12 +1563,15 @@ def get_snmp_v3_credentials(self, credential_details, global_credentials): snmp_v3_description = snmp_v3_credential.get("description") if snmp_v3_description and (not snmp_v3_detail): - snmp_v3_detail = get_dict_result(global_snmp_v3_details, "description", snmp_v3_description) + snmp_v3_detail = get_dict_result( + global_snmp_v3_details, "description", snmp_v3_description) if not snmp_v3_detail: - snmp_v3_old_description = snmp_v3_credential.get("old_description") + snmp_v3_old_description = snmp_v3_credential.get( + "old_description") if snmp_v3_old_description and (not snmp_v3_detail): - snmp_v3_detail = get_dict_result(global_snmp_v3_details, "description", snmp_v3_old_description) + snmp_v3_detail = get_dict_result( + global_snmp_v3_details, "description", snmp_v3_old_description) if not snmp_v3_detail: self.msg = "snmp_v3 credential old_description is invalid" self.status = "failed" @@ -1572,33 +1594,46 @@ def get_have_device_credentials(self, credential_details): """ global_credentials = self.get_global_credentials_params() - cli_details = self.get_cli_credentials(credential_details, global_credentials) - snmp_v2c_read_details = self.get_snmp_v2c_read_credentials(credential_details, global_credentials) - snmp_v2c_write_details = self.get_snmp_v2c_write_credentials(credential_details, global_credentials) - https_read_details = self.get_https_read_credentials(credential_details, global_credentials) - https_write_details = self.get_https_write_credentials(credential_details, global_credentials) - snmp_v3_details = self.get_snmp_v3_credentials(credential_details, global_credentials) + cli_details = self.get_cli_credentials( + credential_details, global_credentials) + snmp_v2c_read_details = self.get_snmp_v2c_read_credentials( + credential_details, global_credentials) + snmp_v2c_write_details = self.get_snmp_v2c_write_credentials( + credential_details, global_credentials) + https_read_details = self.get_https_read_credentials( + credential_details, global_credentials) + https_write_details = self.get_https_write_credentials( + credential_details, global_credentials) + snmp_v3_details = self.get_snmp_v3_credentials( + credential_details, global_credentials) self.have.update({"global_credential": {}}) if cli_details: cli_credential = self.get_cli_params(cli_details) - self.have.get("global_credential").update({"cliCredential": cli_credential}) + self.have.get("global_credential").update( + {"cliCredential": cli_credential}) if snmp_v2c_read_details: - snmp_v2c_read = self.get_snmp_v2c_read_params(snmp_v2c_read_details) - self.have.get("global_credential").update({"snmpV2cRead": snmp_v2c_read}) + snmp_v2c_read = self.get_snmp_v2c_read_params( + snmp_v2c_read_details) + self.have.get("global_credential").update( + {"snmpV2cRead": snmp_v2c_read}) if snmp_v2c_write_details: - snmp_v2c_write = self.get_snmp_v2c_write_params(snmp_v2c_write_details) - self.have.get("global_credential").update({"snmpV2cWrite": snmp_v2c_write}) + snmp_v2c_write = self.get_snmp_v2c_write_params( + snmp_v2c_write_details) + self.have.get("global_credential").update( + {"snmpV2cWrite": snmp_v2c_write}) if https_read_details: https_read = self.get_https_read_params(https_read_details) - self.have.get("global_credential").update({"httpsRead": https_read}) + self.have.get("global_credential").update( + {"httpsRead": https_read}) if https_write_details: https_write = self.get_https_write_params(https_write_details) - self.have.get("global_credential").update({"httpsWrite": https_write}) + self.have.get("global_credential").update( + {"httpsWrite": https_write}) if snmp_v3_details: snmp_v3 = self.get_snmp_v3_params(snmp_v3_details) @@ -1627,7 +1662,8 @@ def get_have(self, config): if config.get("global_credential_details") is not None: credential_details = config.get("global_credential_details") - self.get_have_device_credentials(credential_details).check_return_status() + self.get_have_device_credentials( + credential_details).check_return_status() self.log("Current State (have): {0}".format(self.have), "INFO") self.msg = "Successfully retrieved the details from the Cisco Catalyst Center" @@ -1658,20 +1694,23 @@ def get_want_device_credentials(self, credential_details): create_cli_ptr = 0 update_cli_ptr = 0 values = ["password", "description", "username", "id"] - have_cli_credential = self.have.get("global_credential").get("cliCredential") + have_cli_credential = self.have.get( + "global_credential").get("cliCredential") for item in cli: if not have_cli_credential or have_cli_credential[have_cli_ptr] is None: if want.get("want_create").get("cliCredential") is None: want.get("want_create").update({"cliCredential": []}) - create_credential = want.get("want_create").get("cliCredential") + create_credential = want.get( + "want_create").get("cliCredential") create_credential.append({}) for i in range(0, 3): if item.get(values[i]): create_credential[create_cli_ptr] \ .update({values[i]: item.get(values[i])}) else: - self.msg = values[i] + " is mandatory for creating cli_credential " + str(have_cli_ptr) + self.msg = values[i] + " is mandatory for creating cli_credential " + str( + have_cli_ptr) self.status = "failed" return self @@ -1682,13 +1721,15 @@ def get_want_device_credentials(self, credential_details): else: if want.get("want_update").get("cliCredential") is None: want.get("want_update").update({"cliCredential": []}) - update_credential = want.get("want_update").get("cliCredential") + update_credential = want.get( + "want_update").get("cliCredential") update_credential.append({}) if item.get("password"): update_credential[update_cli_ptr] \ .update({"password": item.get("password")}) else: - self.msg = "password is mandatory for updating cli_credential " + str(have_cli_ptr) + self.msg = "password is mandatory for updating cli_credential " + \ + str(have_cli_ptr) self.status = "failed" return self @@ -1716,33 +1757,38 @@ def get_want_device_credentials(self, credential_details): update_snmpv2cread_ptr = 0 values = ["read_community", "description", "id"] keys = ["readCommunity", "description", "id"] - have_snmp_v2c_read = self.have.get("global_credential").get("snmpV2cRead") + have_snmp_v2c_read = self.have.get( + "global_credential").get("snmpV2cRead") for item in snmp_v2c_read: if not have_snmp_v2c_read or have_snmp_v2c_read[have_snmpv2cread_ptr] is None: if want.get("want_create").get("snmpV2cRead") is None: want.get("want_create").update({"snmpV2cRead": []}) - create_credential = want.get("want_create").get("snmpV2cRead") + create_credential = want.get( + "want_create").get("snmpV2cRead") create_credential.append({}) for i in range(0, 2): if item.get(values[i]): create_credential[create_snmpv2cread_ptr] \ .update({keys[i]: item.get(values[i])}) else: - self.msg = values[i] + " is mandatory for creating snmp_v2c_read " + str(have_snmpv2cread_ptr) + self.msg = values[i] + " is mandatory for creating snmp_v2c_read " + str( + have_snmpv2cread_ptr) self.status = "failed" return self create_snmpv2cread_ptr = create_snmpv2cread_ptr + 1 else: if want.get("want_update").get("snmpV2cRead") is None: want.get("want_update").update({"snmpV2cRead": []}) - update_credential = want.get("want_update").get("snmpV2cRead") + update_credential = want.get( + "want_update").get("snmpV2cRead") update_credential.append({}) if item.get("read_community"): update_credential[update_snmpv2cread_ptr] \ .update({"readCommunity": item.get("read_community")}) else: - self.msg = "read_community is mandatory for updating snmp_v2c_read " + str(have_snmpv2cread_ptr) + self.msg = "read_community is mandatory for updating snmp_v2c_read " + \ + str(have_snmpv2cread_ptr) self.status = "failed" return self for i in range(1, 3): @@ -1764,33 +1810,38 @@ def get_want_device_credentials(self, credential_details): update_snmpv2cwrite_ptr = 0 values = ["write_community", "description", "id"] keys = ["writeCommunity", "description", "id"] - have_snmp_v2c_write = self.have.get("global_credential").get("snmpV2cWrite") + have_snmp_v2c_write = self.have.get( + "global_credential").get("snmpV2cWrite") for item in snmp_v2c_write: if not have_snmp_v2c_write or have_snmp_v2c_write[have_snmpv2cwrite_ptr] is None: if want.get("want_create").get("snmpV2cWrite") is None: want.get("want_create").update({"snmpV2cWrite": []}) - create_credential = want.get("want_create").get("snmpV2cWrite") + create_credential = want.get( + "want_create").get("snmpV2cWrite") create_credential.append({}) for i in range(0, 2): if item.get(values[i]): create_credential[create_snmpv2cwrite_ptr] \ .update({keys[i]: item.get(values[i])}) else: - self.msg = values[i] + " is mandatory for creating snmp_v2c_write " + str(have_snmpv2cwrite_ptr) + self.msg = values[i] + " is mandatory for creating snmp_v2c_write " + str( + have_snmpv2cwrite_ptr) self.status = "failed" return self create_snmpv2cwrite_ptr = create_snmpv2cwrite_ptr + 1 else: if want.get("want_update").get("snmpV2cWrite") is None: want.get("want_update").update({"snmpV2cWrite": []}) - update_credential = want.get("want_update").get("snmpV2cWrite") + update_credential = want.get( + "want_update").get("snmpV2cWrite") update_credential.append({}) if item.get("write_community"): update_credential[update_snmpv2cwrite_ptr] \ .update({"writeCommunity": item.get("write_community")}) else: - self.msg = "write_community is mandatory for updating snmp_v2c_write " + str(have_snmpv2cwrite_ptr) + self.msg = "write_community is mandatory for updating snmp_v2c_write " + \ + str(have_snmpv2cwrite_ptr) self.status = "failed" return self for i in range(1, 3): @@ -1811,7 +1862,8 @@ def get_want_device_credentials(self, credential_details): create_httpsread_ptr = 0 update_httpsread_ptr = 0 values = ["password", "description", "username", "id", "port"] - have_https_read = self.have.get("global_credential").get("httpsRead") + have_https_read = self.have.get( + "global_credential").get("httpsRead") for item in https_read: self.log("Global credentials details: {0}" @@ -1819,14 +1871,16 @@ def get_want_device_credentials(self, credential_details): if not have_https_read or have_https_read[have_httpsread_ptr] is None: if want.get("want_create").get("httpsRead") is None: want.get("want_create").update({"httpsRead": []}) - create_credential = want.get("want_create").get("httpsRead") + create_credential = want.get( + "want_create").get("httpsRead") create_credential.append({}) for i in range(0, 3): if item.get(values[i]): create_credential[create_httpsread_ptr] \ .update({values[i]: item.get(values[i])}) else: - self.msg = values[i] + " is mandatory for creating https_read " + str(have_httpsread_ptr) + self.msg = values[i] + " is mandatory for creating https_read " + str( + have_httpsread_ptr) self.status = "failed" return self if item.get("port"): @@ -1839,13 +1893,15 @@ def get_want_device_credentials(self, credential_details): else: if want.get("want_update").get("httpsRead") is None: want.get("want_update").update({"httpsRead": []}) - update_credential = want.get("want_update").get("httpsRead") + update_credential = want.get( + "want_update").get("httpsRead") update_credential.append({}) if item.get("password"): update_credential[update_httpsread_ptr] \ .update({"password": item.get("password")}) else: - self.msg = "The password is mandatory for updating https_read " + str(have_httpsread_ptr) + self.msg = "The password is mandatory for updating https_read " + \ + str(have_httpsread_ptr) self.status = "failed" return self for i in range(1, 5): @@ -1866,20 +1922,23 @@ def get_want_device_credentials(self, credential_details): create_httpswrite_ptr = 0 update_httpswrite_ptr = 0 values = ["password", "description", "username", "id", "port"] - have_https_write = self.have.get("global_credential").get("httpsWrite") + have_https_write = self.have.get( + "global_credential").get("httpsWrite") for item in https_write: if not have_https_write or have_https_write[have_httpswrite_ptr] is None: if want.get("want_create").get("httpsWrite") is None: want.get("want_create").update({"httpsWrite": []}) - create_credential = want.get("want_create").get("httpsWrite") + create_credential = want.get( + "want_create").get("httpsWrite") create_credential.append({}) for i in range(0, 3): if item.get(values[i]): create_credential[create_httpswrite_ptr] \ .update({values[i]: item.get(values[i])}) else: - self.msg = values[i] + " is mandatory for creating https_write " + str(have_httpswrite_ptr) + self.msg = values[i] + " is mandatory for creating https_write " + str( + have_httpswrite_ptr) self.status = "failed" return self if item.get("port"): @@ -1892,13 +1951,15 @@ def get_want_device_credentials(self, credential_details): else: if want.get("want_update").get("httpsWrite") is None: want.get("want_update").update({"httpsWrite": []}) - update_credential = want.get("want_update").get("httpsWrite") + update_credential = want.get( + "want_update").get("httpsWrite") update_credential.append({}) if item.get("password"): update_credential[update_httpswrite_ptr] \ .update({"password": item.get("password")}) else: - self.msg = "The password is mandatory for updating https_write " + str(have_httpswrite_ptr) + self.msg = "The password is mandatory for updating https_write " + \ + str(have_httpswrite_ptr) self.status = "failed" return self for i in range(1, 5): @@ -1932,7 +1993,8 @@ def get_want_device_credentials(self, credential_details): create_credential[create_snmpv3_ptr] \ .update({values[i]: item.get(values[i])}) else: - self.msg = values[i] + " is mandatory for creating snmp_v3 " + str(have_snmpv3_ptr) + self.msg = values[i] + " is mandatory for creating snmp_v3 " + str( + have_snmpv3_ptr) self.status = "failed" return self if item.get("snmp_mode"): @@ -1953,7 +2015,8 @@ def get_want_device_credentials(self, credential_details): create_credential[create_snmpv3_ptr] \ .update({keys[auth]: item.get(auth)}) else: - self.msg = auth + " is mandatory for creating snmp_v3 " + str(have_snmpv3_ptr) + self.msg = auth + " is mandatory for creating snmp_v3 " + \ + str(have_snmpv3_ptr) self.status = "failed" return self if len(item.get("auth_password")) < 8: @@ -1973,7 +2036,8 @@ def get_want_device_credentials(self, credential_details): create_credential[create_snmpv3_ptr] \ .update({key[priv]: item.get(priv)}) else: - self.msg = priv + " is mandatory for creating snmp_v3 " + str(have_snmpv3_ptr) + self.msg = priv + " is mandatory for creating snmp_v3 " + \ + str(have_snmpv3_ptr) self.status = "failed" return self if len(item.get("privacy_password")) < 8: @@ -2093,7 +2157,8 @@ def get_want_assign_credentials(self, assign_credentials): for site_name in site_names: site_exists, current_site_id = self.get_site_id(site_name) if not current_site_id: - self.msg = "The site_name '{0}' is invalid in 'assign_credentials_to_site'".format(site_name) + self.msg = "The site_name '{0}' is invalid in 'assign_credentials_to_site'".format( + site_name) self.status = "failed" return self site_ids.append(current_site_id) @@ -2118,7 +2183,8 @@ def get_want_assign_credentials(self, assign_credentials): cli_detail = None if cli_id: - cli_detail = get_dict_result(global_cli_details, "id", cli_id) + cli_detail = get_dict_result( + global_cli_details, "id", cli_id) if not cli_detail: self.msg = "The ID for the CLI credential is not valid." self.status = "failed" @@ -2134,7 +2200,8 @@ def get_want_assign_credentials(self, assign_credentials): return self if current_ccc_version_as_int <= self.get_ccc_version_as_int_from_str("2.3.5.3"): - want.get("assign_credentials").update({"cliId": global_cli_details.get("id")}) + want.get("assign_credentials").update( + {"cliId": global_cli_details.get("id")}) else: want.get("assign_credentials").update({ "cliCredentialsId": {"credentialsId": global_cli_details.get("id")} @@ -2147,7 +2214,8 @@ def get_want_assign_credentials(self, assign_credentials): if snmp_v2c_read_id or snmp_v2c_read_description: # All snmp_v2c_read details from the Cisco Catalyst Center - global_snmp_v2c_read_details = global_credentials.get("snmpV2cRead") + global_snmp_v2c_read_details = global_credentials.get( + "snmpV2cRead") if not global_snmp_v2c_read_details: self.msg = "Global snmp_v2c_read credential is not available" self.status = "failed" @@ -2155,7 +2223,8 @@ def get_want_assign_credentials(self, assign_credentials): snmp_v2c_read_detail = None if snmp_v2c_read_id: - snmp_v2c_read_detail = get_dict_result(global_snmp_v2c_read_details, "id", snmp_v2c_read_id) + snmp_v2c_read_detail = get_dict_result( + global_snmp_v2c_read_details, "id", snmp_v2c_read_id) if not snmp_v2c_read_detail: self.msg = "The ID of the snmp_v2c_read credential is not valid." self.status = "failed" @@ -2170,7 +2239,8 @@ def get_want_assign_credentials(self, assign_credentials): return self if current_ccc_version_as_int <= self.get_ccc_version_as_int_from_str("2.3.5.3"): - want.get("assign_credentials").update({"snmpV2ReadId": snmp_v2c_read_detail.get("id")}) + want.get("assign_credentials").update( + {"snmpV2ReadId": snmp_v2c_read_detail.get("id")}) else: want.get("assign_credentials").update({ "snmpv2cReadCredentialsId": {"credentialsId": snmp_v2c_read_detail.get("id")} @@ -2182,7 +2252,8 @@ def get_want_assign_credentials(self, assign_credentials): snmp_v2c_write_description = snmp_v2c_write.get("description") if snmp_v2c_write_id or snmp_v2c_write_description: # All snmp_v2c_write details from the Cisco Catalyst Center - global_snmp_v2c_write_details = global_credentials.get("snmpV2cWrite") + global_snmp_v2c_write_details = global_credentials.get( + "snmpV2cWrite") if not global_snmp_v2c_write_details: self.msg = "Global snmp_v2c_write Credential is not available" @@ -2191,7 +2262,8 @@ def get_want_assign_credentials(self, assign_credentials): snmp_v2c_write_detail = None if snmp_v2c_write_id: - snmp_v2c_write_detail = get_dict_result(global_snmp_v2c_write_details, "id", snmp_v2c_write_id) + snmp_v2c_write_detail = get_dict_result( + global_snmp_v2c_write_details, "id", snmp_v2c_write_id) if not snmp_v2c_write_detail: self.msg = "The ID of the snmp_v2c_write credential is invalid." self.status = "failed" @@ -2207,7 +2279,8 @@ def get_want_assign_credentials(self, assign_credentials): return self if current_ccc_version_as_int <= self.get_ccc_version_as_int_from_str("2.3.5.3"): - want.get("assign_credentials").update({"snmpV2WriteId": snmp_v2c_write_detail.get("id")}) + want.get("assign_credentials").update( + {"snmpV2WriteId": snmp_v2c_write_detail.get("id")}) else: want.get("assign_credentials").update({ "snmpv2cWriteCredentialsId": {"credentialsId": snmp_v2c_write_detail.get("id")} @@ -2229,7 +2302,8 @@ def get_want_assign_credentials(self, assign_credentials): https_read_detail = None if https_read_id: - https_read_detail = get_dict_result(global_https_read_details, "id", https_read_id) + https_read_detail = get_dict_result( + global_https_read_details, "id", https_read_id) if not https_read_detail: self.msg = "The ID of the https_read credential is not valid." self.status = "failed" @@ -2246,7 +2320,8 @@ def get_want_assign_credentials(self, assign_credentials): return self if current_ccc_version_as_int <= self.get_ccc_version_as_int_from_str("2.3.5.3"): - want.get("assign_credentials").update({"httpRead": https_read_detail.get("id")}) + want.get("assign_credentials").update( + {"httpRead": https_read_detail.get("id")}) else: want.get("assign_credentials").update({ "httpReadCredentialsId": {"credentialsId": https_read_detail.get("id")} @@ -2260,7 +2335,8 @@ def get_want_assign_credentials(self, assign_credentials): if https_write_id or https_write_description and https_write_username: # All httpWrite details from the Cisco Catalyst Center - global_https_write_details = global_credentials.get("httpsWrite") + global_https_write_details = global_credentials.get( + "httpsWrite") if not global_https_write_details: self.msg = "Global https_write credential is not available." self.status = "failed" @@ -2268,7 +2344,8 @@ def get_want_assign_credentials(self, assign_credentials): https_write_detail = None if https_write_id: - https_write_detail = get_dict_result(global_https_write_details, "id", https_write_id) + https_write_detail = get_dict_result( + global_https_write_details, "id", https_write_id) if not https_write_detail: self.msg = "The ID of the https_write credential is not valid." self.status = "failed" @@ -2285,7 +2362,8 @@ def get_want_assign_credentials(self, assign_credentials): return self if current_ccc_version_as_int <= self.get_ccc_version_as_int_from_str("2.3.5.3"): - want.get("assign_credentials").update({"httpWrite": https_write_detail.get("id")}) + want.get("assign_credentials").update( + {"httpWrite": https_write_detail.get("id")}) else: want.get("assign_credentials").update({ "httpWriteCredentialsId": {"credentialsId": https_write_detail.get("id")} @@ -2306,7 +2384,8 @@ def get_want_assign_credentials(self, assign_credentials): snmp_v3_detail = None if snmp_v3_id: - snmp_v3_detail = get_dict_result(global_snmp_v3_details, "id", snmp_v3_id) + snmp_v3_detail = get_dict_result( + global_snmp_v3_details, "id", snmp_v3_id) if not snmp_v3_detail: self.msg = "The ID of the snmp_v3 credential is not valid." self.status = "failed" @@ -2322,7 +2401,8 @@ def get_want_assign_credentials(self, assign_credentials): return self if current_ccc_version_as_int <= self.get_ccc_version_as_int_from_str("2.3.5.3"): - want.get("assign_credentials").update({"snmpV3Id": snmp_v3_detail.get("id")}) + want.get("assign_credentials").update( + {"snmpV3Id": snmp_v3_detail.get("id")}) else: want.get("assign_credentials").update({ "snmpv3CredentialsId": {"credentialsId": snmp_v3_detail.get("id")} @@ -2361,7 +2441,8 @@ def get_want_apply_credentials(self, apply_credentials): for site_name in site_names: site_exists, current_site_id = self.get_site_id(site_name) if not current_site_id: - self.msg = "The site_name '{0}' is invalid in 'apply_credentials_to_site'".format(site_name) + self.msg = "The site_name '{0}' is invalid in 'apply_credentials_to_site'".format( + site_name) self.status = "failed" return self site_ids.append(current_site_id) @@ -2386,7 +2467,8 @@ def get_want_apply_credentials(self, apply_credentials): cli_detail = None if cli_id: - cli_detail = get_dict_result(global_cli_details, "id", cli_id) + cli_detail = get_dict_result( + global_cli_details, "id", cli_id) if not cli_detail: self.msg = "The ID for the CLI credential is not valid." self.status = "failed" @@ -2410,7 +2492,8 @@ def get_want_apply_credentials(self, apply_credentials): snmp_v2c_read_description = snmp_v2c_read.get("description") if snmp_v2c_read_id or snmp_v2c_read_description: # All snmp_v2c_read details from the Cisco Catalyst Center - global_snmp_v2c_read_details = global_credentials.get("snmpV2cRead") + global_snmp_v2c_read_details = global_credentials.get( + "snmpV2cRead") if not global_snmp_v2c_read_details: self.msg = "Global snmp_v2c_read credential is not available" @@ -2444,7 +2527,8 @@ def get_want_apply_credentials(self, apply_credentials): snmp_v2c_write_description = snmp_v2c_write.get("description") if snmp_v2c_write_id or snmp_v2c_write_description: # All snmp_v2c_write details from the Cisco Catalyst Center - global_snmp_v2c_write_details = global_credentials.get("snmpV2cWrite") + global_snmp_v2c_write_details = global_credentials.get( + "snmpV2cWrite") if not global_snmp_v2c_write_details: self.msg = "Global snmp_v2c_write Credential is not available" @@ -2502,7 +2586,8 @@ def get_want_apply_credentials(self, apply_credentials): self.status = "failed" return self - want["apply_credentials"]["snmpV3Id"] = snmp_v3_detail.get("id") + want["apply_credentials"]["snmpV3Id"] = snmp_v3_detail.get( + "id") self.log("Desired State (want): {0}".format(want), "INFO") self.want.update(want) @@ -2527,15 +2612,18 @@ def get_want(self, config): if config.get("global_credential_details"): credential_details = config.get("global_credential_details") - self.get_want_device_credentials(credential_details).check_return_status() + self.get_want_device_credentials( + credential_details).check_return_status() if config.get("assign_credentials_to_site"): assign_credentials = config.get("assign_credentials_to_site") - self.get_want_assign_credentials(assign_credentials).check_return_status() + self.get_want_assign_credentials( + assign_credentials).check_return_status() if config.get("apply_credentials_to_site"): apply_credentials = config.get("apply_credentials_to_site") - self.get_want_apply_credentials(apply_credentials).check_return_status() + self.get_want_apply_credentials( + apply_credentials).check_return_status() self.log("Desired State (want): {0}".format(self.want), "INFO") self.msg = "Successfully retrieved details from the playbook" @@ -2555,7 +2643,8 @@ def create_device_credentials(self): self """ - result_global_credential = self.result.get("response")[0].get("global_credential") + result_global_credential = self.result.get( + "response")[0].get("global_credential") want_create = self.want.get("want_create") if not want_create: result_global_credential.update({ @@ -2580,9 +2669,11 @@ def create_device_credentials(self): if self.get_ccc_version_as_integer() <= self.get_ccc_version_as_int_from_str("2.3.5.3"): validation_string = "global credential addition performed" - self.check_task_response_status(response, validation_string, "create_global_credentials_v2").check_return_status() + self.check_task_response_status( + response, validation_string, "create_global_credentials_v2").check_return_status() else: - self.check_tasks_response_status(response, "create_global_credentials_v2").check_return_status() + self.check_tasks_response_status( + response, "create_global_credentials_v2").check_return_status() self.log("Global credential created successfully", "INFO") result_global_credential.update({ @@ -2607,7 +2698,8 @@ def update_device_credentials(self): self """ - result_global_credential = self.result.get("response")[0].get("global_credential") + result_global_credential = self.result.get( + "response")[0].get("global_credential") # Get the result global credential and want_update from the current object want_update = self.want.get("want_update") @@ -2635,7 +2727,8 @@ def update_device_credentials(self): for value in values: if want_update.get(value) and i < len(want_update.get(value)): flag = True - credential_params.update({value: want_update.get(value)[i]}) + credential_params.update( + {value: want_update.get(value)[i]}) i = i + 1 if credential_params: final_response.append(credential_params) @@ -2650,9 +2743,11 @@ def update_device_credentials(self): if self.get_ccc_version_as_integer() <= self.get_ccc_version_as_int_from_str("2.3.5.3"): validation_string = "global credential update performed" - self.check_task_response_status(response, validation_string, "update_global_credentials_v2").check_return_status() + self.check_task_response_status( + response, validation_string, "update_global_credentials_v2").check_return_status() else: - self.check_tasks_response_status(response, "update_global_credentials_v2").check_return_status() + self.check_tasks_response_status( + response, "update_global_credentials_v2").check_return_status() self.log("Updating device credential API input parameters: {0}" .format(final_response), "DEBUG") @@ -2680,7 +2775,8 @@ def assign_credentials_to_site(self): self """ - result_assign_credential = self.result.get("response")[0].get("assign_credential") + result_assign_credential = self.result.get( + "response")[0].get("assign_credential") credential_params = self.want.get("assign_credentials") final_response = [] self.log("Assigning device credential to site API input parameters: {0}" @@ -2791,7 +2887,8 @@ def get_assigned_device_credential(self, site_id): params={"id": site_id} ) - self.log("Received API response: {0}".format(credential_settings), "DEBUG") + self.log("Received API response: {0}".format( + credential_settings), "DEBUG") site_credential_response = credential_settings.get("response") self.log("Device credential settings details: {0}".format( site_credential_response), "DEBUG") @@ -2816,10 +2913,12 @@ def apply_credentials_to_site(self): for site_id, site_name in zip(site_ids, site_names): if self.get_ccc_version_as_integer() >= self.get_ccc_version_as_int_from_str("2.3.7.6"): - result_apply_credential = self.result.get("response")[0].get("apply_credential") + result_apply_credential = self.result.get( + "response")[0].get("apply_credential") credential_params = self.want.get("apply_credentials") final_response = [] - self.log("Applying device credential to site API input parameters: {0}".format(credential_params), "DEBUG") + self.log("Applying device credential to site API input parameters: {0}".format( + credential_params), "DEBUG") if not credential_params: result_apply_credential.update({ @@ -2832,7 +2931,8 @@ def apply_credentials_to_site(self): self.status = "success" return self - site_response = self.get_device_ids_from_site(site_name, site_id) + site_response = self.get_device_ids_from_site( + site_name, site_id) if not site_response[1]: result_apply_credential.update({ @@ -2841,12 +2941,14 @@ def apply_credentials_to_site(self): "msg": "No device available in the site" } }) - self.msg = "No device available in the site: '{0}' with site id {1}".format(site_name, site_id) + self.msg = "No device available in the site: '{0}' with site id {1}".format( + site_name, site_id) self.log(self.msg, "WARNING") self.status = "exited" return self - cred_sync_status = self.get_network_devices_credentials_sync_status(site_id) + cred_sync_status = self.get_network_devices_credentials_sync_status( + site_id) credential_mapping = { "cli": "cliId", "snmpV2Read": "snmpV2ReadId", @@ -2862,8 +2964,10 @@ def apply_credentials_to_site(self): for status in status_list: if status.get('status') != 'Synced': if credential_params.get(param_key): - not_synced_ids.append(credential_params[param_key]) - assigned_device_credential = self.get_assigned_device_credential(site_id) + not_synced_ids.append( + credential_params[param_key]) + assigned_device_credential = self.get_assigned_device_credential( + site_id) for value in assigned_device_credential.values(): if isinstance(value, dict) and "credentialsId" in value: @@ -2876,7 +2980,8 @@ def apply_credentials_to_site(self): valid_sync_cred_ids.append(id) else: invalid_sync_cred_ids.append(id) - self.log("Credential IDs {0} not assigned to site, so Sync not possible.".format(invalid_sync_cred_ids), "INFO") + self.log("Credential IDs {0} not assigned to site, so Sync not possible.".format( + invalid_sync_cred_ids), "INFO") if not valid_sync_cred_ids: result_apply_credential.update({ @@ -2886,7 +2991,8 @@ def apply_credentials_to_site(self): } }) self.msg = ( - "Provided credentials category is/are already synced: {0}".format(credential_params) + "Provided credentials category is/are already synced: {0}".format( + credential_params) ) self.log(self.msg, "WARNING") self.status = "skipped" @@ -2895,7 +3001,8 @@ def apply_credentials_to_site(self): for credential_id in valid_sync_cred_ids: param = {"deviceCredentialId": credential_id, "siteId": site_id} - self.log("Credential {0} to be synced with {1} site id." .format(credential_id, site_id), "INFO") + self.log("Credential {0} to be synced with {1} site id." .format( + credential_id, site_id), "INFO") final_response.append(copy.deepcopy(param)) response = self.dnac._exec( family="network_settings", @@ -2903,12 +3010,15 @@ def apply_credentials_to_site(self): op_modifies=True, params=param ) - self.log("Received API response for 'sync_network_devices_credential': {0}".format(response), "DEBUG") + self.log("Received API response for 'sync_network_devices_credential': {0}".format( + response), "DEBUG") self.check_tasks_response_status(response, "sync_network_devices_credential").check_return_status() - self.log("Device credential applied to site {0} successfully.".format(site_id), "INFO") - self.log("Desired State for applying credentials to a site: {0}".format(final_response), "DEBUG") + self.log("Device credential applied to site {0} successfully.".format( + site_id), "INFO") + self.log("Desired State for applying credentials to a site: {0}".format( + final_response), "DEBUG") result_apply_credential.update({ "Applied Credentials": { "response": final_response, @@ -2968,10 +3078,12 @@ def delete_device_credential(self, config): self """ - result_global_credential = self.result.get("response")[0].get("global_credential") + result_global_credential = self.result.get( + "response")[0].get("global_credential") have_values = self.have.get("global_credential") final_response = {} - self.log("Global device credentials to be deleted: {0}".format(have_values), "DEBUG") + self.log("Global device credentials to be deleted: {0}".format( + have_values), "DEBUG") credential_mapping = { "cliCredential": "cli_credential", "snmpV2cRead": "snmp_v2c_read", @@ -3021,11 +3133,13 @@ def delete_device_credential(self, config): task_id = response.get("taskId") while True: task_details = self.get_task_details(task_id) - self.log('Getting task details from task ID {0}: {1}'.format(task_id, task_details), "DEBUG") + self.log('Getting task details from task ID {0}: {1}'.format( + task_id, task_details), "DEBUG") if task_details.get("isError") is True: if task_details.get("failureReason"): - failure_msg = str(task_details.get("failureReason")) + failure_msg = str( + task_details.get("failureReason")) else: failure_msg = str(task_details.get("progress")) self.status = "failed" @@ -3035,7 +3149,8 @@ def delete_device_credential(self, config): self.status = "success" break - self.log("progress set to {0} for taskid: {1}".format(task_details.get('progress'), task_id), "DEBUG") + self.log("progress set to {0} for taskid: {1}".format( + task_details.get('progress'), task_id), "DEBUG") if self.status == "failed": failed_status = True @@ -3129,22 +3244,29 @@ def verify_diff_merged(self, config): have_credential = self.have.get(credential_type) values = value_mapping.get(credential_type) for value in values: - equality = have_credential.get(value) is want_credential.get(value) + equality = have_credential.get( + value) is want_credential.get(value) if not have_credential or not equality: - self.msg = "{0} config is not applied ot the Cisco Catalyst Center".format(credential_type) + self.msg = "{0} config is not applied ot the Cisco Catalyst Center".format( + credential_type) self.status = "failed" return self self.log("Successfully validated global device credential", "INFO") - self.result.get("response")[0].get("global_credential").update({"Validation": "Success"}) + self.result.get("response")[0].get( + "global_credential").update({"Validation": "Success"}) if config.get("assign_credentials_to_site") is not None: - self.log("Successfully validated the assign device credential to site", "INFO") - self.result.get("response")[0].get("assign_credential").update({"Validation": "Success"}) + self.log( + "Successfully validated the assign device credential to site", "INFO") + self.result.get("response")[0].get( + "assign_credential").update({"Validation": "Success"}) if config.get("apply_credentials_to_site") is not None: - self.log("Successfully validated the assign device credential to site", "INFO") - self.result.get("response")[0].get("apply_credential").update({"Validation": "Success"}) + self.log( + "Successfully validated the assign device credential to site", "INFO") + self.result.get("response")[0].get( + "apply_credential").update({"Validation": "Success"}) self.msg = "Successfully validated the global device credential, assigned and applied device credential to site." self.status = "success" @@ -3172,7 +3294,8 @@ def verify_diff_deleted(self, config): credential_types = ["cliCredential", "snmpV2cRead", "snmpV2cWrite", "httpsRead", "httpsWrite", "snmpV3"] for credential_type in credential_types: - have_global_credential_type = have_global_credential.get(credential_type) + have_global_credential_type = have_global_credential.get( + credential_type) if have_global_credential_type is not None: for item in have_global_credential_type: if item is not None: @@ -3181,8 +3304,10 @@ def verify_diff_deleted(self, config): self.status = "failed" return self - self.log("Successfully validated absence of global device credential.", "INFO") - self.result.get("response")[0].get("global_credential").update({"Validation": "Success"}) + self.log( + "Successfully validated absence of global device credential.", "INFO") + self.result.get("response")[0].get( + "global_credential").update({"Validation": "Success"}) self.msg = "Successfully validated the absence of Global Device Credential." self.status = "success" @@ -3229,7 +3354,8 @@ def main(): } # Create an AnsibleModule object with argument specifications - module = AnsibleModule(argument_spec=element_spec, supports_check_mode=False) + module = AnsibleModule(argument_spec=element_spec, + supports_check_mode=False) ccc_credential = DeviceCredential(module) state = ccc_credential.params.get("state") config_verify = ccc_credential.params.get("config_verify") @@ -3245,9 +3371,11 @@ def main(): ccc_credential.get_have(config).check_return_status() if state != "deleted": ccc_credential.get_want(config).check_return_status() - ccc_credential.get_diff_state_apply[state](config).check_return_status() + ccc_credential.get_diff_state_apply[state]( + config).check_return_status() if config_verify: - ccc_credential.verify_diff_state_apply[state](config).check_return_status() + ccc_credential.verify_diff_state_apply[state]( + config).check_return_status() module.exit_json(**ccc_credential.result) diff --git a/plugins/modules/discovery_intent.py b/plugins/modules/discovery_intent.py index 26e481544c..8d7b527aba 100644 --- a/plugins/modules/discovery_intent.py +++ b/plugins/modules/discovery_intent.py @@ -4,6 +4,13 @@ # Copyright (c) 2024, Cisco Systems # 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 +import re +import time +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts +) +from ansible.module_utils.basic import AnsibleModule __metaclass__ = type __author__ = ("Abinash Mishra, Phan Nguyen, Madhan Sankaranarayanan") @@ -616,13 +623,6 @@ "msg": String } """ -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts -) -import time -import re class Discovery(DnacBase): @@ -696,7 +696,8 @@ def validate_input(self, state=None): if state == "merged": discovery_spec["ip_address_list"] = {'type': 'list', 'required': True, 'elements': 'str'} - discovery_spec["discovery_type"] = {'type': 'str', 'required': True} + discovery_spec["discovery_type"] = { + 'type': 'str', 'required': True} elif state == "deleted": if self.config[0].get("delete_all") is True: @@ -717,7 +718,8 @@ def validate_input(self, state=None): return self self.validated_config = valid_discovery - self.msg = "Successfully validated playbook configuration parameters using 'validate_input': {0}".format(str(valid_discovery)) + self.msg = "Successfully validated playbook configuration parameters using 'validate_input': {0}".format( + str(valid_discovery)) self.log(str(self.msg), "INFO") self.status = "success" return self @@ -746,11 +748,13 @@ def validate_ip4_address_list(self): ip2_parts = list(map(int, ip2.split('.'))) for part in range(4): if ip1_parts[part] > ip2_parts[part]: - msg = "Incorrect range passed: {0}. Please pass correct IP address range".format(ip) + msg = "Incorrect range passed: {0}. Please pass correct IP address range".format( + ip) self.log(msg, "CRITICAL") self.module.fail_json(msg=msg) else: - msg = "Provided range '{0}' is incorrect. IP address range should have only upper and lower limit values".format(ip) + msg = "Provided range '{0}' is incorrect. IP address range should have only upper and lower limit values".format( + ip) self.log(msg, "CRITICAL") self.module.fail_json(msg=msg) if self.is_valid_ipv4(ip) is False and '-' not in ip: @@ -769,7 +773,8 @@ def get_creds_ids_list(self): the class instance. """ - self.log("Credential Ids list passed is {0}".format(str(self.creds_ids_list)), "INFO") + self.log("Credential Ids list passed is {0}".format( + str(self.creds_ids_list)), "INFO") return self.creds_ids_list def handle_global_credentials(self, response=None): @@ -805,13 +810,15 @@ def handle_global_credentials(self, response=None): if cli_cred.get('description') and cli_cred.get('username'): for cli in response.get("cliCredential"): if cli.get("description") == cli_cred.get('description') and cli.get("username") == cli_cred.get('username'): - global_credentials_all["cliCredential"].append(cli.get("id")) + global_credentials_all["cliCredential"].append( + cli.get("id")) global_credentials_all["cliCredential"] = global_credentials_all["cliCredential"][:cred_len] else: msg = "Kindly ensure you include both the description and the username for the Global CLI credential to discover the devices" self.discovery_specific_cred_failure(msg=msg) - http_read_credential_list = global_credentials.get('http_read_credential_list') + http_read_credential_list = global_credentials.get( + 'http_read_credential_list') if http_read_credential_list: if not isinstance(http_read_credential_list, list): msg = "Global HTTP read credentials must be passed as a list" @@ -828,13 +835,15 @@ def handle_global_credentials(self, response=None): if http_cred.get('description') and http_cred.get('username'): for http in response.get("httpsRead"): if http.get("description") == http.get('description') and http.get("username") == http.get('username'): - global_credentials_all["httpsRead"].append(http.get("id")) + global_credentials_all["httpsRead"].append( + http.get("id")) global_credentials_all["httpsRead"] = global_credentials_all["httpsRead"][:cred_len] else: msg = "Kindly ensure you include both the description and the username for the Global HTTP Read credential to discover the devices" self.discovery_specific_cred_failure(msg=msg) - http_write_credential_list = global_credentials.get('http_write_credential_list') + http_write_credential_list = global_credentials.get( + 'http_write_credential_list') if http_write_credential_list: if not isinstance(http_write_credential_list, list): msg = "Global HTTP write credentials must be passed as a list" @@ -851,13 +860,15 @@ def handle_global_credentials(self, response=None): if http_cred.get('description') and http_cred.get('username'): for http in response.get("httpsWrite"): if http.get("description") == http.get('description') and http.get("username") == http.get('username'): - global_credentials_all["httpsWrite"].append(http.get("id")) + global_credentials_all["httpsWrite"].append( + http.get("id")) global_credentials_all["httpsWrite"] = global_credentials_all["httpsWrite"][:cred_len] else: msg = "Kindly ensure you include both the description and the username for the Global HTTP Write credential to discover the devices" self.discovery_specific_cred_failure(msg=msg) - snmp_v2_read_credential_list = global_credentials.get('snmp_v2_read_credential_list') + snmp_v2_read_credential_list = global_credentials.get( + 'snmp_v2_read_credential_list') if snmp_v2_read_credential_list: if not isinstance(snmp_v2_read_credential_list, list): msg = "Global SNMPv2 read credentials must be passed as a list" @@ -874,14 +885,16 @@ def handle_global_credentials(self, response=None): if snmp_cred.get('description'): for snmp in response.get("snmpV2cRead"): if snmp.get("description") == snmp_cred.get('description'): - global_credentials_all["snmpV2cRead"].append(snmp.get("id")) + global_credentials_all["snmpV2cRead"].append( + snmp.get("id")) global_credentials_all["snmpV2cRead"] = global_credentials_all["snmpV2cRead"][:cred_len] else: msg = "Kindly ensure you include the description for the Global SNMPv2 Read \ credential to discover the devices" self.discovery_specific_cred_failure(msg=msg) - snmp_v2_write_credential_list = global_credentials.get('snmp_v2_write_credential_list') + snmp_v2_write_credential_list = global_credentials.get( + 'snmp_v2_write_credential_list') if snmp_v2_write_credential_list: if not isinstance(snmp_v2_write_credential_list, list): msg = "Global SNMPv2 write credentials must be passed as a list" @@ -898,13 +911,15 @@ def handle_global_credentials(self, response=None): if snmp_cred.get('description'): for snmp in response.get("snmpV2cWrite"): if snmp.get("description") == snmp_cred.get('description'): - global_credentials_all["snmpV2cWrite"].append(snmp.get("id")) + global_credentials_all["snmpV2cWrite"].append( + snmp.get("id")) global_credentials_all["snmpV2cWrite"] = global_credentials_all["snmpV2cWrite"][:cred_len] else: msg = "Kindly ensure you include the description for the Global SNMPV2 write credential to discover the devices" self.discovery_specific_cred_failure(msg=msg) - snmp_v3_credential_list = global_credentials.get('snmp_v3_credential_list') + snmp_v3_credential_list = global_credentials.get( + 'snmp_v3_credential_list') if snmp_v3_credential_list: if not isinstance(snmp_v3_credential_list, list): msg = "Global SNMPv3 write credentials must be passed as a list" @@ -921,7 +936,8 @@ def handle_global_credentials(self, response=None): if snmp_cred.get('description') and snmp_cred.get('username'): for snmp in response.get("snmpV3"): if snmp.get("description") == snmp_cred.get('description') and snmp.get("username") == snmp_cred.get('username'): - global_credentials_all["snmpV3"].append(snmp.get("id")) + global_credentials_all["snmpV3"].append( + snmp.get("id")) global_credentials_all["snmpV3"] = global_credentials_all["snmpV3"][:cred_len] else: msg = "Kindly ensure you include both the description and the username for the Global SNMPv3 \ @@ -945,13 +961,15 @@ def handle_global_credentials(self, response=None): if port.get("description"): for netconf in response.get("netconfCredential"): if port.get('description') == netconf.get('description'): - global_credentials_all["netconfCredential"].append(netconf.get("id")) + global_credentials_all["netconfCredential"].append( + netconf.get("id")) global_credentials_all["netconfCredential"] = global_credentials_all["netconfCredential"][:cred_len] else: msg = "Please provide valid description of the Global Netconf port to be used" self.discovery_specific_cred_failure(msg=msg) - self.log("Fetched Global credentials IDs are {0}".format(global_credentials_all), "INFO") + self.log("Fetched Global credentials IDs are {0}".format( + global_credentials_all), "INFO") return global_credentials_all def get_ccc_global_credentials_v2_info(self): @@ -975,11 +993,13 @@ def get_ccc_global_credentials_v2_info(self): op_modifies=True ) response = response.get('response') - self.log("The Global credentials response from 'get all global credentials v2' API is {0}".format(str(response)), "DEBUG") + self.log("The Global credentials response from 'get all global credentials v2' API is {0}".format( + str(response)), "DEBUG") global_credentials_all = {} global_credentials = self.validated_config[0].get("global_credentials") if global_credentials: - global_credentials_all = self.handle_global_credentials(response=response) + global_credentials_all = self.handle_global_credentials( + response=response) global_cred_set = set(global_credentials_all.keys()) response_cred_set = set(response.keys()) @@ -1013,7 +1033,8 @@ def get_devices_list_info(self): """ ip_address_list = self.validated_config[0].get('ip_address_list') self.result.update(dict(devices_info=ip_address_list)) - self.log("Details of the device list passed: {0}".format(str(ip_address_list)), "INFO") + self.log("Details of the device list passed: {0}".format( + str(ip_address_list)), "INFO") return ip_address_list def preprocess_device_discovery(self, ip_address_list=None): @@ -1035,7 +1056,8 @@ def preprocess_device_discovery(self, ip_address_list=None): if ip_address_list is None: ip_address_list = [] discovery_type = self.validated_config[0].get('discovery_type') - self.log("Discovery type passed for the discovery is {0}".format(discovery_type), "INFO") + self.log("Discovery type passed for the discovery is {0}".format( + discovery_type), "INFO") if discovery_type in ["SINGLE", "CDP", "LLDP"]: if len(ip_address_list) == 1: ip_address_list = ip_address_list[0] @@ -1061,7 +1083,8 @@ def preprocess_device_discovery(self, ip_address_list=None): if len(str(ip_address_list[0]).split("-")) == 2: ip_address_list = ip_address_list[0] else: - ip_address_list = "{0}-{1}".format(ip_address_list[0], ip_address_list[0]) + ip_address_list = "{0}-{1}".format( + ip_address_list[0], ip_address_list[0]) else: self.preprocess_device_discovery_handle_error() else: @@ -1077,7 +1100,8 @@ def preprocess_device_discovery(self, ip_address_list=None): else: new_ip_collected.append(ip) ip_address_list = ','.join(new_ip_collected) - self.log("Collected IP address/addresses are {0}".format(str(ip_address_list)), "INFO") + self.log( + "Collected IP address/addresses are {0}".format(str(ip_address_list)), "INFO") return str(ip_address_list) def preprocess_device_discovery_handle_error(self): @@ -1087,7 +1111,8 @@ def preprocess_device_discovery_handle_error(self): """ self.log("IP Address list's length is longer than 1", "ERROR") - self.module.fail_json(msg="IP Address list's length is longer than 1", response=[]) + self.module.fail_json( + msg="IP Address list's length is longer than 1", response=[]) def discovery_specific_cred_failure(self, msg=None): """ @@ -1112,13 +1137,20 @@ def handle_discovery_specific_credentials(self, new_object_params=None): start discovery API in an updated fashion """ - discovery_specific_credentials = self.validated_config[0].get('discovery_specific_credentials') - cli_credentials_list = discovery_specific_credentials.get('cli_credentials_list') - http_read_credential = discovery_specific_credentials.get('http_read_credential') - http_write_credential = discovery_specific_credentials.get('http_write_credential') - snmp_v2_read_credential = discovery_specific_credentials.get('snmp_v2_read_credential') - snmp_v2_write_credential = discovery_specific_credentials.get('snmp_v2_write_credential') - snmp_v3_credential = discovery_specific_credentials.get('snmp_v3_credential') + discovery_specific_credentials = self.validated_config[0].get( + 'discovery_specific_credentials') + cli_credentials_list = discovery_specific_credentials.get( + 'cli_credentials_list') + http_read_credential = discovery_specific_credentials.get( + 'http_read_credential') + http_write_credential = discovery_specific_credentials.get( + 'http_write_credential') + snmp_v2_read_credential = discovery_specific_credentials.get( + 'snmp_v2_read_credential') + snmp_v2_write_credential = discovery_specific_credentials.get( + 'snmp_v2_write_credential') + snmp_v3_credential = discovery_specific_credentials.get( + 'snmp_v3_credential') net_conf_port = discovery_specific_credentials.get('net_conf_port') if cli_credentials_list: @@ -1133,7 +1165,8 @@ def handle_discovery_specific_credentials(self, new_object_params=None): if cli_cred.get('username') and cli_cred.get('password') and cli_cred.get('enable_password'): username_list.append(cli_cred.get('username')) password_list.append(cli_cred.get('password')) - enable_password_list.append(cli_cred.get('enable_password')) + enable_password_list.append( + cli_cred.get('enable_password')) else: msg = "username, password and enable_password must be passed toether for creating CLI credentials" self.discovery_specific_cred_failure(msg=msg) @@ -1178,8 +1211,10 @@ def handle_discovery_specific_credentials(self, new_object_params=None): if not (snmp_v2_read_credential.get('community')) and isinstance(snmp_v2_read_credential.get('community'), str): msg = "The community string must be of string type" self.discovery_specific_cred_failure(msg=msg) - new_object_params['snmpROCommunityDesc'] = snmp_v2_read_credential.get('description') - new_object_params['snmpROCommunity'] = snmp_v2_read_credential.get('community') + new_object_params['snmpROCommunityDesc'] = snmp_v2_read_credential.get( + 'description') + new_object_params['snmpROCommunity'] = snmp_v2_read_credential.get( + 'community') new_object_params['snmpVersion'] = "v2" if snmp_v2_write_credential: @@ -1189,8 +1224,10 @@ def handle_discovery_specific_credentials(self, new_object_params=None): if not (snmp_v2_write_credential.get('community')) and isinstance(snmp_v2_write_credential.get('community'), str): msg = "The community string must be of string type" self.discovery_specific_cred_failure(msg=msg) - new_object_params['snmpRWCommunityDesc'] = snmp_v2_write_credential.get('description') - new_object_params['snmpRWCommunity'] = snmp_v2_write_credential.get('community') + new_object_params['snmpRWCommunityDesc'] = snmp_v2_write_credential.get( + 'description') + new_object_params['snmpRWCommunity'] = snmp_v2_write_credential.get( + 'community') new_object_params['snmpVersion'] = "v2" if snmp_v3_credential: @@ -1214,12 +1251,17 @@ def handle_discovery_specific_credentials(self, new_object_params=None): if not (snmp_v3_credential.get('privacy_password')) and isinstance(snmp_v3_credential.get('privacy_password'), str): msg = "Privacy password must be of string type" self.discovery_specific_cred_failure(msg=msg) - new_object_params['snmpUserName'] = snmp_v3_credential.get('username') + new_object_params['snmpUserName'] = snmp_v3_credential.get( + 'username') new_object_params['snmpMode'] = snmp_v3_credential.get('snmp_mode') - new_object_params['snmpAuthPassphrase'] = snmp_v3_credential.get('auth_password') - new_object_params['snmpAuthProtocol'] = snmp_v3_credential.get('auth_type') - new_object_params['snmpPrivProtocol'] = snmp_v3_credential.get('privacy_type') - new_object_params['snmpPrivPassphrase'] = snmp_v3_credential.get('privacy_password') + new_object_params['snmpAuthPassphrase'] = snmp_v3_credential.get( + 'auth_password') + new_object_params['snmpAuthProtocol'] = snmp_v3_credential.get( + 'auth_type') + new_object_params['snmpPrivProtocol'] = snmp_v3_credential.get( + 'privacy_type') + new_object_params['snmpPrivPassphrase'] = snmp_v3_credential.get( + 'privacy_password') new_object_params['snmpVersion'] = "v3" if net_conf_port: @@ -1246,21 +1288,30 @@ def create_params(self, ip_address_list=None): credential_ids = [] new_object_params = {} - new_object_params['cdpLevel'] = self.validated_config[0].get('cdp_level') - new_object_params['discoveryType'] = self.validated_config[0].get('discovery_type') + new_object_params['cdpLevel'] = self.validated_config[0].get( + 'cdp_level') + new_object_params['discoveryType'] = self.validated_config[0].get( + 'discovery_type') new_object_params['ipAddressList'] = ip_address_list - new_object_params['ipFilterList'] = self.validated_config[0].get('ip_filter_list') - new_object_params['lldpLevel'] = self.validated_config[0].get('lldp_level') - new_object_params['name'] = self.validated_config[0].get('discovery_name') - new_object_params['preferredMgmtIPMethod'] = self.validated_config[0].get('preferred_mgmt_ip_method') - new_object_params['protocolOrder'] = self.validated_config[0].get('protocol_order') + new_object_params['ipFilterList'] = self.validated_config[0].get( + 'ip_filter_list') + new_object_params['lldpLevel'] = self.validated_config[0].get( + 'lldp_level') + new_object_params['name'] = self.validated_config[0].get( + 'discovery_name') + new_object_params['preferredMgmtIPMethod'] = self.validated_config[0].get( + 'preferred_mgmt_ip_method') + new_object_params['protocolOrder'] = self.validated_config[0].get( + 'protocol_order') new_object_params['retry'] = self.validated_config[0].get('retry') new_object_params['timeout'] = self.validated_config[0].get('timeout') if self.validated_config[0].get('discovery_specific_credentials'): - self.handle_discovery_specific_credentials(new_object_params=new_object_params) + self.handle_discovery_specific_credentials( + new_object_params=new_object_params) - global_cred_flag = self.validated_config[0].get('use_global_credentials') + global_cred_flag = self.validated_config[0].get( + 'use_global_credentials') global_credentials_all = {} if global_cred_flag is True: @@ -1269,7 +1320,8 @@ def create_params(self, ip_address_list=None): credential_ids.extend(global_cred_list) new_object_params['globalCredentialIdList'] = credential_ids - self.log("All the global credentials used for the discovery task are {0}".format(str(global_credentials_all)), "DEBUG") + self.log("All the global credentials used for the discovery task are {0}".format( + str(global_credentials_all)), "DEBUG") if not (new_object_params.get('snmpUserName') or new_object_params.get('snmpROCommunityDesc') or new_object_params.get('snmpRWCommunityDesc') or global_credentials_all.get('snmpV2cRead') or global_credentials_all.get('snmpV2cWrite') or global_credentials_all.get('snmpV3')): @@ -1280,7 +1332,8 @@ def create_params(self, ip_address_list=None): msg = "Please provide atleast one valid CLI credential to perform Discovery" self.discovery_specific_cred_failure(msg=msg) - self.log("The payload/object created for calling the start discovery API is {0}".format(str(new_object_params)), "INFO") + self.log("The payload/object created for calling the start discovery API is {0}".format( + str(new_object_params)), "INFO") return new_object_params @@ -1308,10 +1361,12 @@ def create_discovery(self, ip_address_list=None): op_modifies=True, ) - self.log("The response received post discovery creation API called is {0}".format(str(result)), "DEBUG") + self.log("The response received post discovery creation API called is {0}".format( + str(result)), "DEBUG") self.result.update(dict(discovery_result=result)) - self.log("Task Id of the API task created is {0}".format(result.response.get('taskId')), "INFO") + self.log("Task Id of the API task created is {0}".format( + result.response.get('taskId')), "INFO") return result.response.get('taskId') def get_merged_task_status(self, task_id=None): @@ -1338,7 +1393,8 @@ def get_merged_task_status(self, task_id=None): op_modifies=True, ) response = response.response - self.log("Task status for the task id {0} is {1}, is_error: {2}".format(str(task_id), str(response), str(response.get('isError'))), "INFO") + self.log("Task status for the task id {0} is {1}, is_error: {2}".format( + str(task_id), str(response), str(response.get('isError'))), "INFO") if response.get('isError') or re.search( 'failed', response.get('progress'), flags=re.IGNORECASE ): @@ -1348,7 +1404,8 @@ def get_merged_task_status(self, task_id=None): self.module.fail_json(msg=msg) return False - self.log("Task status for the task id (before checking status) {0} is {1}".format(str(task_id), str(response)), "INFO") + self.log("Task status for the task id (before checking status) {0} is {1}".format( + str(task_id), str(response)), "INFO") progress = response.get('progress') try: progress_value = int(progress) @@ -1357,7 +1414,8 @@ def get_merged_task_status(self, task_id=None): self.result.update(dict(discovery_task=response)) return result except Exception: - self.log("The progress status is {0}, continue to check the status after 3 seconds. Putting into sleep for 3 seconds".format(progress)) + self.log( + "The progress status is {0}, continue to check the status after 3 seconds. Putting into sleep for 3 seconds".format(progress)) time.sleep(3) def get_deleted_task_status(self, task_id=None): @@ -1383,7 +1441,8 @@ def get_deleted_task_status(self, task_id=None): op_modifies=True, ) response = response.response - self.log("Task status for the task id {0} is {1}, is_error: {2}".format(str(task_id), str(response), str(response.get('isError'))), "INFO") + self.log("Task status for the task id {0} is {1}, is_error: {2}".format( + str(task_id), str(response), str(response.get('isError'))), "INFO") if response.get('isError') or re.search( 'failed', response.get('progress'), flags=re.IGNORECASE ): @@ -1393,7 +1452,8 @@ def get_deleted_task_status(self, task_id=None): self.module.fail_json(msg=msg) return False - self.log("Task status for the task id (before checking status) {0} is {1}".format(str(task_id), str(response)), "INFO") + self.log("Task status for the task id (before checking status) {0} is {1}".format( + str(task_id), str(response)), "INFO") progress = response.get('progress') if re.search('Discovery deleted successfully.', response.get('progress')): result = True @@ -1401,7 +1461,8 @@ def get_deleted_task_status(self, task_id=None): self.result.update(dict(discovery_task=response)) return result - self.log("The progress status is {0}, continue to check the status after 3 seconds. Putting into sleep for 3 seconds".format(progress)) + self.log( + "The progress status is {0}, continue to check the status after 3 seconds. Putting into sleep for 3 seconds".format(progress)) time.sleep(3) def lookup_discovery_by_range_via_name(self): @@ -1436,7 +1497,8 @@ def lookup_discovery_by_range_via_name(self): else: params = dict( start_index=self.validated_config[0].get("start_index"), - records_to_return=self.validated_config[0].get("records_to_return"), + records_to_return=self.validated_config[0].get( + "records_to_return"), headers=self.validated_config[0].get("headers"), ) @@ -1446,11 +1508,13 @@ def lookup_discovery_by_range_via_name(self): params=params, op_modifies=True, ) - self.log("Response of the get discoveries via range API is {0}".format(str(response)), "DEBUG") + self.log("Response of the get discoveries via range API is {0}".format( + str(response)), "DEBUG") return next( filter( - lambda x: x['name'] == self.validated_config[0].get('discovery_name'), + lambda x: x['name'] == self.validated_config[0].get( + 'discovery_name'), response.get("response") ), None ) @@ -1490,7 +1554,8 @@ def get_discoveries_by_range_until_success(self): if not result: if aborted is True: - msg = 'Discovery with name {0} is aborted by the user on the GUI'.format(str(self.validated_config[0].get("discovery_name"))) + msg = 'Discovery with name {0} is aborted by the user on the GUI'.format( + str(self.validated_config[0].get("discovery_name"))) self.log(msg, "CRITICAL") self.module.fail_json(msg=msg) else: @@ -1533,7 +1598,8 @@ def get_discovery_device_info(self, discovery_id=None, task_id=None): ) devices = response.response - self.log("Retrieved device details using the API 'get_discovered_network_devices_by_discovery_id': {0}".format(str(devices)), "DEBUG") + self.log("Retrieved device details using the API 'get_discovered_network_devices_by_discovery_id': {0}".format( + str(devices)), "DEBUG") if all(res.get('reachabilityStatus') == 'Success' for res in devices): result = True self.log("All devices in the range are reachable", "INFO") @@ -1546,7 +1612,8 @@ def get_discovery_device_info(self, discovery_id=None, task_id=None): elif all(res.get('reachabilityStatus') != 'Success' for res in devices): result = True - self.log("All devices are not reachable, but discovery is completed", "WARNING") + self.log( + "All devices are not reachable, but discovery is completed", "WARNING") break count += 1 @@ -1556,11 +1623,13 @@ def get_discovery_device_info(self, discovery_id=None, task_id=None): time.sleep(3) if not result: - msg = 'Discovery network device with id {0} has not completed'.format(discovery_id) + msg = 'Discovery network device with id {0} has not completed'.format( + discovery_id) self.log(msg, "CRITICAL") self.module.fail_json(msg=msg) - self.log('Discovery network device with id {0} got completed'.format(discovery_id), "INFO") + self.log('Discovery network device with id {0} got completed'.format( + discovery_id), "INFO") self.result.update(dict(discovery_device_info=devices)) return result @@ -1603,9 +1672,11 @@ def delete_exist_discovery(self, params): op_modifies=True, ) - self.log("Response collected from API 'delete_discovery_by_id': {0}".format(str(response)), "DEBUG") + self.log("Response collected from API 'delete_discovery_by_id': {0}".format( + str(response)), "DEBUG") self.result.update(dict(delete_discovery=response)) - self.log("Task Id of the deletion task is {0}".format(response.response.get('taskId')), "INFO") + self.log("Task Id of the deletion task is {0}".format( + response.response.get('taskId')), "INFO") return response.response.get('taskId') def get_diff_merged(self): @@ -1626,13 +1697,16 @@ def get_diff_merged(self): if exist_discovery: params = dict(id=exist_discovery.get('id')) discovery_task_id = self.delete_exist_discovery(params=params) - complete_discovery = self.get_deleted_task_status(task_id=discovery_task_id) + complete_discovery = self.get_deleted_task_status( + task_id=discovery_task_id) discovery_task_id = self.create_discovery( ip_address_list=ip_address_list) - complete_discovery = self.get_merged_task_status(task_id=discovery_task_id) + complete_discovery = self.get_merged_task_status( + task_id=discovery_task_id) discovery_task_info = self.get_discoveries_by_range_until_success() - result = self.get_discovery_device_info(discovery_id=discovery_task_info.get('id')) + result = self.get_discovery_device_info( + discovery_id=discovery_task_info.get('id')) self.result["changed"] = True self.result['msg'] = "Discovery Created Successfully" self.result['diff'] = self.validated_config @@ -1668,7 +1742,8 @@ def get_diff_deleted(self): family="discovery", function="delete_all_discovery", ) - discovery_task_id = delete_all_response.get('response').get('taskId') + discovery_task_id = delete_all_response.get( + 'response').get('taskId') self.result["changed"] = True self.result['msg'] = "All of the Discoveries Deleted Successfully" self.result['diff'] = self.validated_config @@ -1683,7 +1758,8 @@ def get_diff_deleted(self): params = dict(id=exist_discovery.get('id')) discovery_task_id = self.delete_exist_discovery(params=params) - complete_discovery = self.get_deleted_task_status(task_id=discovery_task_id) + complete_discovery = self.get_deleted_task_status( + task_id=discovery_task_id) self.result["changed"] = True self.result['msg'] = "Successfully deleted discovery" self.result['diff'] = self.validated_config @@ -1723,10 +1799,12 @@ def verify_diff_merged(self, config): ) discovery_name = config.get('discovery_name') if response: - self.log("Requested Discovery with name {0} is completed".format(discovery_name), "INFO") + self.log("Requested Discovery with name {0} is completed".format( + discovery_name), "INFO") else: - self.log("Requested Discovery with name {0} is not completed".format(discovery_name), "WARNING") + self.log("Requested Discovery with name {0} is not completed".format( + discovery_name), "WARNING") self.status = "success" return self @@ -1763,10 +1841,12 @@ def verify_diff_deleted(self, config): discovery_task_info = self.lookup_discovery_by_range_via_name() discovery_name = config.get('discovery_name') if discovery_task_info: - self.log("Requested Discovery with name {0} is present".format(discovery_name), "WARNING") + self.log("Requested Discovery with name {0} is present".format( + discovery_name), "WARNING") else: - self.log("Requested Discovery with name {0} is not present and deleted".format(discovery_name), "INFO") + self.log("Requested Discovery with name {0} is not present and deleted".format( + discovery_name), "INFO") self.status = "success" return self @@ -1812,7 +1892,8 @@ def main(): ccc_discovery.reset_values() ccc_discovery.get_diff_state_apply[state]().check_return_status() if config_verify: - ccc_discovery.verify_diff_state_apply[state](config).check_return_status() + ccc_discovery.verify_diff_state_apply[state]( + config).check_return_status() module.exit_json(**ccc_discovery.result) diff --git a/plugins/modules/discovery_workflow_manager.py b/plugins/modules/discovery_workflow_manager.py index 49693835cf..00f272e485 100644 --- a/plugins/modules/discovery_workflow_manager.py +++ b/plugins/modules/discovery_workflow_manager.py @@ -4,6 +4,13 @@ # Copyright (c) 2024, Cisco Systems # 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 +import re +import time +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts +) +from ansible.module_utils.basic import AnsibleModule __metaclass__ = type __author__ = ("Abinash Mishra, Phan Nguyen, Madhan Sankaranarayanan") @@ -616,13 +623,6 @@ "msg": String } """ -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts -) -import time -import re class Discovery(DnacBase): @@ -696,7 +696,8 @@ def validate_input(self, state=None): if state == "merged": discovery_spec["ip_address_list"] = {'type': 'list', 'required': True, 'elements': 'str'} - discovery_spec["discovery_type"] = {'type': 'str', 'required': True} + discovery_spec["discovery_type"] = { + 'type': 'str', 'required': True} elif state == "deleted": if self.config[0].get("delete_all") is True: @@ -717,7 +718,8 @@ def validate_input(self, state=None): return self self.validated_config = valid_discovery - self.msg = "Successfully validated playbook configuration parameters using 'validate_input': {0}".format(str(valid_discovery)) + self.msg = "Successfully validated playbook configuration parameters using 'validate_input': {0}".format( + str(valid_discovery)) self.log(str(self.msg), "INFO") self.status = "success" return self @@ -746,11 +748,13 @@ def validate_ip4_address_list(self): ip2_parts = list(map(int, ip2.split('.'))) for part in range(4): if ip1_parts[part] > ip2_parts[part]: - msg = "Incorrect range passed: {0}. Please pass correct IP address range".format(ip) + msg = "Incorrect range passed: {0}. Please pass correct IP address range".format( + ip) self.log(msg, "CRITICAL") self.module.fail_json(msg=msg) else: - msg = "Provided range '{0}' is incorrect. IP address range should have only upper and lower limit values".format(ip) + msg = "Provided range '{0}' is incorrect. IP address range should have only upper and lower limit values".format( + ip) self.log(msg, "CRITICAL") self.module.fail_json(msg=msg) if self.is_valid_ipv4(ip) is False and '-' not in ip: @@ -769,7 +773,8 @@ def get_creds_ids_list(self): the class instance. """ - self.log("Credential Ids list passed is {0}".format(str(self.creds_ids_list)), "INFO") + self.log("Credential Ids list passed is {0}".format( + str(self.creds_ids_list)), "INFO") return self.creds_ids_list def handle_global_credentials(self, response=None): @@ -805,13 +810,15 @@ def handle_global_credentials(self, response=None): if cli_cred.get('description') and cli_cred.get('username'): for cli in response.get("cliCredential"): if cli.get("description") == cli_cred.get('description') and cli.get("username") == cli_cred.get('username'): - global_credentials_all["cliCredential"].append(cli.get("id")) + global_credentials_all["cliCredential"].append( + cli.get("id")) global_credentials_all["cliCredential"] = global_credentials_all["cliCredential"][:cred_len] else: msg = "Kindly ensure you include both the description and the username for the Global CLI credential to discover the devices" self.discovery_specific_cred_failure(msg=msg) - http_read_credential_list = global_credentials.get('http_read_credential_list') + http_read_credential_list = global_credentials.get( + 'http_read_credential_list') if http_read_credential_list: if not isinstance(http_read_credential_list, list): msg = "Global HTTP read credentials must be passed as a list" @@ -828,13 +835,15 @@ def handle_global_credentials(self, response=None): if http_cred.get('description') and http_cred.get('username'): for http in response.get("httpsRead"): if http.get("description") == http.get('description') and http.get("username") == http.get('username'): - global_credentials_all["httpsRead"].append(http.get("id")) + global_credentials_all["httpsRead"].append( + http.get("id")) global_credentials_all["httpsRead"] = global_credentials_all["httpsRead"][:cred_len] else: msg = "Kindly ensure you include both the description and the username for the Global HTTP Read credential to discover the devices" self.discovery_specific_cred_failure(msg=msg) - http_write_credential_list = global_credentials.get('http_write_credential_list') + http_write_credential_list = global_credentials.get( + 'http_write_credential_list') if http_write_credential_list: if not isinstance(http_write_credential_list, list): msg = "Global HTTP write credentials must be passed as a list" @@ -851,13 +860,15 @@ def handle_global_credentials(self, response=None): if http_cred.get('description') and http_cred.get('username'): for http in response.get("httpsWrite"): if http.get("description") == http.get('description') and http.get("username") == http.get('username'): - global_credentials_all["httpsWrite"].append(http.get("id")) + global_credentials_all["httpsWrite"].append( + http.get("id")) global_credentials_all["httpsWrite"] = global_credentials_all["httpsWrite"][:cred_len] else: msg = "Kindly ensure you include both the description and the username for the Global HTTP Write credential to discover the devices" self.discovery_specific_cred_failure(msg=msg) - snmp_v2_read_credential_list = global_credentials.get('snmp_v2_read_credential_list') + snmp_v2_read_credential_list = global_credentials.get( + 'snmp_v2_read_credential_list') if snmp_v2_read_credential_list: if not isinstance(snmp_v2_read_credential_list, list): msg = "Global SNMPv2 read credentials must be passed as a list" @@ -874,14 +885,16 @@ def handle_global_credentials(self, response=None): if snmp_cred.get('description'): for snmp in response.get("snmpV2cRead"): if snmp.get("description") == snmp_cred.get('description'): - global_credentials_all["snmpV2cRead"].append(snmp.get("id")) + global_credentials_all["snmpV2cRead"].append( + snmp.get("id")) global_credentials_all["snmpV2cRead"] = global_credentials_all["snmpV2cRead"][:cred_len] else: msg = "Kindly ensure you include the description for the Global SNMPv2 Read \ credential to discover the devices" self.discovery_specific_cred_failure(msg=msg) - snmp_v2_write_credential_list = global_credentials.get('snmp_v2_write_credential_list') + snmp_v2_write_credential_list = global_credentials.get( + 'snmp_v2_write_credential_list') if snmp_v2_write_credential_list: if not isinstance(snmp_v2_write_credential_list, list): msg = "Global SNMPv2 write credentials must be passed as a list" @@ -898,13 +911,15 @@ def handle_global_credentials(self, response=None): if snmp_cred.get('description'): for snmp in response.get("snmpV2cWrite"): if snmp.get("description") == snmp_cred.get('description'): - global_credentials_all["snmpV2cWrite"].append(snmp.get("id")) + global_credentials_all["snmpV2cWrite"].append( + snmp.get("id")) global_credentials_all["snmpV2cWrite"] = global_credentials_all["snmpV2cWrite"][:cred_len] else: msg = "Kindly ensure you include the description for the Global SNMPV2 write credential to discover the devices" self.discovery_specific_cred_failure(msg=msg) - snmp_v3_credential_list = global_credentials.get('snmp_v3_credential_list') + snmp_v3_credential_list = global_credentials.get( + 'snmp_v3_credential_list') if snmp_v3_credential_list: if not isinstance(snmp_v3_credential_list, list): msg = "Global SNMPv3 write credentials must be passed as a list" @@ -921,7 +936,8 @@ def handle_global_credentials(self, response=None): if snmp_cred.get('description') and snmp_cred.get('username'): for snmp in response.get("snmpV3"): if snmp.get("description") == snmp_cred.get('description') and snmp.get("username") == snmp_cred.get('username'): - global_credentials_all["snmpV3"].append(snmp.get("id")) + global_credentials_all["snmpV3"].append( + snmp.get("id")) global_credentials_all["snmpV3"] = global_credentials_all["snmpV3"][:cred_len] else: msg = "Kindly ensure you include both the description and the username for the Global SNMPv3 \ @@ -945,13 +961,15 @@ def handle_global_credentials(self, response=None): if port.get("description"): for netconf in response.get("netconfCredential"): if port.get('description') == netconf.get('description'): - global_credentials_all["netconfCredential"].append(netconf.get("id")) + global_credentials_all["netconfCredential"].append( + netconf.get("id")) global_credentials_all["netconfCredential"] = global_credentials_all["netconfCredential"][:cred_len] else: msg = "Please provide valid description of the Global Netconf port to be used" self.discovery_specific_cred_failure(msg=msg) - self.log("Fetched Global credentials IDs are {0}".format(global_credentials_all), "INFO") + self.log("Fetched Global credentials IDs are {0}".format( + global_credentials_all), "INFO") return global_credentials_all def get_ccc_global_credentials_v2_info(self): @@ -975,11 +993,13 @@ def get_ccc_global_credentials_v2_info(self): op_modifies=True ) response = response.get('response') - self.log("The Global credentials response from 'get all global credentials v2' API is {0}".format(str(response)), "DEBUG") + self.log("The Global credentials response from 'get all global credentials v2' API is {0}".format( + str(response)), "DEBUG") global_credentials_all = {} global_credentials = self.validated_config[0].get("global_credentials") if global_credentials: - global_credentials_all = self.handle_global_credentials(response=response) + global_credentials_all = self.handle_global_credentials( + response=response) global_cred_set = set(global_credentials_all.keys()) response_cred_set = set(response.keys()) @@ -1013,7 +1033,8 @@ def get_devices_list_info(self): """ ip_address_list = self.validated_config[0].get('ip_address_list') self.result.update(dict(devices_info=ip_address_list)) - self.log("Details of the device list passed: {0}".format(str(ip_address_list)), "INFO") + self.log("Details of the device list passed: {0}".format( + str(ip_address_list)), "INFO") return ip_address_list def preprocess_device_discovery(self, ip_address_list=None): @@ -1035,7 +1056,8 @@ def preprocess_device_discovery(self, ip_address_list=None): if ip_address_list is None: ip_address_list = [] discovery_type = self.validated_config[0].get('discovery_type') - self.log("Discovery type passed for the discovery is {0}".format(discovery_type), "INFO") + self.log("Discovery type passed for the discovery is {0}".format( + discovery_type), "INFO") if discovery_type in ["SINGLE", "CDP", "LLDP"]: if len(ip_address_list) == 1: ip_address_list = ip_address_list[0] @@ -1061,7 +1083,8 @@ def preprocess_device_discovery(self, ip_address_list=None): if len(str(ip_address_list[0]).split("-")) == 2: ip_address_list = ip_address_list[0] else: - ip_address_list = "{0}-{1}".format(ip_address_list[0], ip_address_list[0]) + ip_address_list = "{0}-{1}".format( + ip_address_list[0], ip_address_list[0]) else: self.preprocess_device_discovery_handle_error() else: @@ -1077,7 +1100,8 @@ def preprocess_device_discovery(self, ip_address_list=None): else: new_ip_collected.append(ip) ip_address_list = ','.join(new_ip_collected) - self.log("Collected IP address/addresses are {0}".format(str(ip_address_list)), "INFO") + self.log( + "Collected IP address/addresses are {0}".format(str(ip_address_list)), "INFO") return str(ip_address_list) def preprocess_device_discovery_handle_error(self): @@ -1087,7 +1111,8 @@ def preprocess_device_discovery_handle_error(self): """ self.log("IP Address list's length is longer than 1", "ERROR") - self.module.fail_json(msg="IP Address list's length is longer than 1", response=[]) + self.module.fail_json( + msg="IP Address list's length is longer than 1", response=[]) def discovery_specific_cred_failure(self, msg=None): """ @@ -1112,13 +1137,20 @@ def handle_discovery_specific_credentials(self, new_object_params=None): start discovery API in an updated fashion """ - discovery_specific_credentials = self.validated_config[0].get('discovery_specific_credentials') - cli_credentials_list = discovery_specific_credentials.get('cli_credentials_list') - http_read_credential = discovery_specific_credentials.get('http_read_credential') - http_write_credential = discovery_specific_credentials.get('http_write_credential') - snmp_v2_read_credential = discovery_specific_credentials.get('snmp_v2_read_credential') - snmp_v2_write_credential = discovery_specific_credentials.get('snmp_v2_write_credential') - snmp_v3_credential = discovery_specific_credentials.get('snmp_v3_credential') + discovery_specific_credentials = self.validated_config[0].get( + 'discovery_specific_credentials') + cli_credentials_list = discovery_specific_credentials.get( + 'cli_credentials_list') + http_read_credential = discovery_specific_credentials.get( + 'http_read_credential') + http_write_credential = discovery_specific_credentials.get( + 'http_write_credential') + snmp_v2_read_credential = discovery_specific_credentials.get( + 'snmp_v2_read_credential') + snmp_v2_write_credential = discovery_specific_credentials.get( + 'snmp_v2_write_credential') + snmp_v3_credential = discovery_specific_credentials.get( + 'snmp_v3_credential') net_conf_port = discovery_specific_credentials.get('net_conf_port') if cli_credentials_list: @@ -1133,7 +1165,8 @@ def handle_discovery_specific_credentials(self, new_object_params=None): if cli_cred.get('username') and cli_cred.get('password') and cli_cred.get('enable_password'): username_list.append(cli_cred.get('username')) password_list.append(cli_cred.get('password')) - enable_password_list.append(cli_cred.get('enable_password')) + enable_password_list.append( + cli_cred.get('enable_password')) else: msg = "username, password and enable_password must be passed toether for creating CLI credentials" self.discovery_specific_cred_failure(msg=msg) @@ -1178,8 +1211,10 @@ def handle_discovery_specific_credentials(self, new_object_params=None): if not (snmp_v2_read_credential.get('community')) and isinstance(snmp_v2_read_credential.get('community'), str): msg = "The community string must be of string type" self.discovery_specific_cred_failure(msg=msg) - new_object_params['snmpROCommunityDesc'] = snmp_v2_read_credential.get('description') - new_object_params['snmpROCommunity'] = snmp_v2_read_credential.get('community') + new_object_params['snmpROCommunityDesc'] = snmp_v2_read_credential.get( + 'description') + new_object_params['snmpROCommunity'] = snmp_v2_read_credential.get( + 'community') new_object_params['snmpVersion'] = "v2" if snmp_v2_write_credential: @@ -1189,8 +1224,10 @@ def handle_discovery_specific_credentials(self, new_object_params=None): if not (snmp_v2_write_credential.get('community')) and isinstance(snmp_v2_write_credential.get('community'), str): msg = "The community string must be of string type" self.discovery_specific_cred_failure(msg=msg) - new_object_params['snmpRWCommunityDesc'] = snmp_v2_write_credential.get('description') - new_object_params['snmpRWCommunity'] = snmp_v2_write_credential.get('community') + new_object_params['snmpRWCommunityDesc'] = snmp_v2_write_credential.get( + 'description') + new_object_params['snmpRWCommunity'] = snmp_v2_write_credential.get( + 'community') new_object_params['snmpVersion'] = "v2" if snmp_v3_credential: @@ -1214,12 +1251,17 @@ def handle_discovery_specific_credentials(self, new_object_params=None): if not (snmp_v3_credential.get('privacy_password')) and isinstance(snmp_v3_credential.get('privacy_password'), str): msg = "Privacy password must be of string type" self.discovery_specific_cred_failure(msg=msg) - new_object_params['snmpUserName'] = snmp_v3_credential.get('username') + new_object_params['snmpUserName'] = snmp_v3_credential.get( + 'username') new_object_params['snmpMode'] = snmp_v3_credential.get('snmp_mode') - new_object_params['snmpAuthPassphrase'] = snmp_v3_credential.get('auth_password') - new_object_params['snmpAuthProtocol'] = snmp_v3_credential.get('auth_type') - new_object_params['snmpPrivProtocol'] = snmp_v3_credential.get('privacy_type') - new_object_params['snmpPrivPassphrase'] = snmp_v3_credential.get('privacy_password') + new_object_params['snmpAuthPassphrase'] = snmp_v3_credential.get( + 'auth_password') + new_object_params['snmpAuthProtocol'] = snmp_v3_credential.get( + 'auth_type') + new_object_params['snmpPrivProtocol'] = snmp_v3_credential.get( + 'privacy_type') + new_object_params['snmpPrivPassphrase'] = snmp_v3_credential.get( + 'privacy_password') new_object_params['snmpVersion'] = "v3" if net_conf_port: @@ -1246,21 +1288,30 @@ def create_params(self, ip_address_list=None): credential_ids = [] new_object_params = {} - new_object_params['cdpLevel'] = self.validated_config[0].get('cdp_level') - new_object_params['discoveryType'] = self.validated_config[0].get('discovery_type') + new_object_params['cdpLevel'] = self.validated_config[0].get( + 'cdp_level') + new_object_params['discoveryType'] = self.validated_config[0].get( + 'discovery_type') new_object_params['ipAddressList'] = ip_address_list - new_object_params['ipFilterList'] = self.validated_config[0].get('ip_filter_list') - new_object_params['lldpLevel'] = self.validated_config[0].get('lldp_level') - new_object_params['name'] = self.validated_config[0].get('discovery_name') - new_object_params['preferredMgmtIPMethod'] = self.validated_config[0].get('preferred_mgmt_ip_method') - new_object_params['protocolOrder'] = self.validated_config[0].get('protocol_order') + new_object_params['ipFilterList'] = self.validated_config[0].get( + 'ip_filter_list') + new_object_params['lldpLevel'] = self.validated_config[0].get( + 'lldp_level') + new_object_params['name'] = self.validated_config[0].get( + 'discovery_name') + new_object_params['preferredMgmtIPMethod'] = self.validated_config[0].get( + 'preferred_mgmt_ip_method') + new_object_params['protocolOrder'] = self.validated_config[0].get( + 'protocol_order') new_object_params['retry'] = self.validated_config[0].get('retry') new_object_params['timeout'] = self.validated_config[0].get('timeout') if self.validated_config[0].get('discovery_specific_credentials'): - self.handle_discovery_specific_credentials(new_object_params=new_object_params) + self.handle_discovery_specific_credentials( + new_object_params=new_object_params) - global_cred_flag = self.validated_config[0].get('use_global_credentials') + global_cred_flag = self.validated_config[0].get( + 'use_global_credentials') global_credentials_all = {} if global_cred_flag is True: @@ -1269,7 +1320,8 @@ def create_params(self, ip_address_list=None): credential_ids.extend(global_cred_list) new_object_params['globalCredentialIdList'] = credential_ids - self.log("All the global credentials used for the discovery task are {0}".format(str(global_credentials_all)), "DEBUG") + self.log("All the global credentials used for the discovery task are {0}".format( + str(global_credentials_all)), "DEBUG") if not (new_object_params.get('snmpUserName') or new_object_params.get('snmpROCommunityDesc') or new_object_params.get('snmpRWCommunityDesc') or global_credentials_all.get('snmpV2cRead') or global_credentials_all.get('snmpV2cWrite') or global_credentials_all.get('snmpV3')): @@ -1280,7 +1332,8 @@ def create_params(self, ip_address_list=None): msg = "Please provide atleast one valid CLI credential to perform Discovery" self.discovery_specific_cred_failure(msg=msg) - self.log("The payload/object created for calling the start discovery API is {0}".format(str(new_object_params)), "INFO") + self.log("The payload/object created for calling the start discovery API is {0}".format( + str(new_object_params)), "INFO") return new_object_params @@ -1308,10 +1361,12 @@ def create_discovery(self, ip_address_list=None): op_modifies=True, ) - self.log("The response received post discovery creation API called is {0}".format(str(result)), "DEBUG") + self.log("The response received post discovery creation API called is {0}".format( + str(result)), "DEBUG") self.result.update(dict(discovery_result=result)) - self.log("Task Id of the API task created is {0}".format(result.response.get('taskId')), "INFO") + self.log("Task Id of the API task created is {0}".format( + result.response.get('taskId')), "INFO") return result.response.get('taskId') def get_merged_task_status(self, task_id=None): @@ -1338,7 +1393,8 @@ def get_merged_task_status(self, task_id=None): op_modifies=True, ) response = response.response - self.log("Task status for the task id {0} is {1}, is_error: {2}".format(str(task_id), str(response), str(response.get('isError'))), "INFO") + self.log("Task status for the task id {0} is {1}, is_error: {2}".format( + str(task_id), str(response), str(response.get('isError'))), "INFO") if response.get('isError') or re.search( 'failed', response.get('progress'), flags=re.IGNORECASE ): @@ -1348,7 +1404,8 @@ def get_merged_task_status(self, task_id=None): self.module.fail_json(msg=msg) return False - self.log("Task status for the task id (before checking status) {0} is {1}".format(str(task_id), str(response)), "INFO") + self.log("Task status for the task id (before checking status) {0} is {1}".format( + str(task_id), str(response)), "INFO") progress = response.get('progress') try: progress_value = int(progress) @@ -1357,7 +1414,8 @@ def get_merged_task_status(self, task_id=None): self.result.update(dict(discovery_task=response)) return result except Exception: - self.log("The progress status is {0}, continue to check the status after 3 seconds. Putting into sleep for 3 seconds".format(progress)) + self.log( + "The progress status is {0}, continue to check the status after 3 seconds. Putting into sleep for 3 seconds".format(progress)) time.sleep(3) def get_deleted_task_status(self, task_id=None): @@ -1383,7 +1441,8 @@ def get_deleted_task_status(self, task_id=None): op_modifies=True, ) response = response.response - self.log("Task status for the task id {0} is {1}, is_error: {2}".format(str(task_id), str(response), str(response.get('isError'))), "INFO") + self.log("Task status for the task id {0} is {1}, is_error: {2}".format( + str(task_id), str(response), str(response.get('isError'))), "INFO") if response.get('isError') or re.search( 'failed', response.get('progress'), flags=re.IGNORECASE ): @@ -1393,7 +1452,8 @@ def get_deleted_task_status(self, task_id=None): self.module.fail_json(msg=msg) return False - self.log("Task status for the task id (before checking status) {0} is {1}".format(str(task_id), str(response)), "INFO") + self.log("Task status for the task id (before checking status) {0} is {1}".format( + str(task_id), str(response)), "INFO") progress = response.get('progress') if re.search('Discovery deleted successfully.', response.get('progress')): result = True @@ -1401,7 +1461,8 @@ def get_deleted_task_status(self, task_id=None): self.result.update(dict(discovery_task=response)) return result - self.log("The progress status is {0}, continue to check the status after 3 seconds. Putting into sleep for 3 seconds".format(progress)) + self.log( + "The progress status is {0}, continue to check the status after 3 seconds. Putting into sleep for 3 seconds".format(progress)) time.sleep(3) def lookup_discovery_by_range_via_name(self): @@ -1436,7 +1497,8 @@ def lookup_discovery_by_range_via_name(self): else: params = dict( start_index=self.validated_config[0].get("start_index"), - records_to_return=self.validated_config[0].get("records_to_return"), + records_to_return=self.validated_config[0].get( + "records_to_return"), headers=self.validated_config[0].get("headers"), ) @@ -1446,11 +1508,13 @@ def lookup_discovery_by_range_via_name(self): params=params, op_modifies=True, ) - self.log("Response of the get discoveries via range API is {0}".format(str(response)), "DEBUG") + self.log("Response of the get discoveries via range API is {0}".format( + str(response)), "DEBUG") return next( filter( - lambda x: x['name'] == self.validated_config[0].get('discovery_name'), + lambda x: x['name'] == self.validated_config[0].get( + 'discovery_name'), response.get("response") ), None ) @@ -1490,7 +1554,8 @@ def get_discoveries_by_range_until_success(self): if not result: if aborted is True: - msg = 'Discovery with name {0} is aborted by the user on the GUI'.format(str(self.validated_config[0].get("discovery_name"))) + msg = 'Discovery with name {0} is aborted by the user on the GUI'.format( + str(self.validated_config[0].get("discovery_name"))) self.log(msg, "CRITICAL") self.module.fail_json(msg=msg) else: @@ -1533,7 +1598,8 @@ def get_discovery_device_info(self, discovery_id=None, task_id=None): ) devices = response.response - self.log("Retrieved device details using the API 'get_discovered_network_devices_by_discovery_id': {0}".format(str(devices)), "DEBUG") + self.log("Retrieved device details using the API 'get_discovered_network_devices_by_discovery_id': {0}".format( + str(devices)), "DEBUG") if all(res.get('reachabilityStatus') == 'Success' for res in devices): result = True self.log("All devices in the range are reachable", "INFO") @@ -1546,7 +1612,8 @@ def get_discovery_device_info(self, discovery_id=None, task_id=None): elif all(res.get('reachabilityStatus') != 'Success' for res in devices): result = True - self.log("All devices are not reachable, but discovery is completed", "WARNING") + self.log( + "All devices are not reachable, but discovery is completed", "WARNING") break count += 1 @@ -1556,11 +1623,13 @@ def get_discovery_device_info(self, discovery_id=None, task_id=None): time.sleep(3) if not result: - msg = 'Discovery network device with id {0} has not completed'.format(discovery_id) + msg = 'Discovery network device with id {0} has not completed'.format( + discovery_id) self.log(msg, "CRITICAL") self.module.fail_json(msg=msg) - self.log('Discovery network device with id {0} got completed'.format(discovery_id), "INFO") + self.log('Discovery network device with id {0} got completed'.format( + discovery_id), "INFO") self.result.update(dict(discovery_device_info=devices)) return result @@ -1603,9 +1672,11 @@ def delete_exist_discovery(self, params): op_modifies=True, ) - self.log("Response collected from API 'delete_discovery_by_id': {0}".format(str(response)), "DEBUG") + self.log("Response collected from API 'delete_discovery_by_id': {0}".format( + str(response)), "DEBUG") self.result.update(dict(delete_discovery=response)) - self.log("Task Id of the deletion task is {0}".format(response.response.get('taskId')), "INFO") + self.log("Task Id of the deletion task is {0}".format( + response.response.get('taskId')), "INFO") return response.response.get('taskId') def get_diff_merged(self): @@ -1626,13 +1697,16 @@ def get_diff_merged(self): if exist_discovery: params = dict(id=exist_discovery.get('id')) discovery_task_id = self.delete_exist_discovery(params=params) - complete_discovery = self.get_deleted_task_status(task_id=discovery_task_id) + complete_discovery = self.get_deleted_task_status( + task_id=discovery_task_id) discovery_task_id = self.create_discovery( ip_address_list=ip_address_list) - complete_discovery = self.get_merged_task_status(task_id=discovery_task_id) + complete_discovery = self.get_merged_task_status( + task_id=discovery_task_id) discovery_task_info = self.get_discoveries_by_range_until_success() - result = self.get_discovery_device_info(discovery_id=discovery_task_info.get('id')) + result = self.get_discovery_device_info( + discovery_id=discovery_task_info.get('id')) self.result["changed"] = True self.result['msg'] = "Discovery Created Successfully" self.result['diff'] = self.validated_config @@ -1668,7 +1742,8 @@ def get_diff_deleted(self): family="discovery", function="delete_all_discovery", ) - discovery_task_id = delete_all_response.get('response').get('taskId') + discovery_task_id = delete_all_response.get( + 'response').get('taskId') self.result["changed"] = True self.result['msg'] = "All of the Discoveries Deleted Successfully" self.result['diff'] = self.validated_config @@ -1683,7 +1758,8 @@ def get_diff_deleted(self): params = dict(id=exist_discovery.get('id')) discovery_task_id = self.delete_exist_discovery(params=params) - complete_discovery = self.get_deleted_task_status(task_id=discovery_task_id) + complete_discovery = self.get_deleted_task_status( + task_id=discovery_task_id) self.result["changed"] = True self.result['msg'] = "Successfully deleted discovery" self.result['diff'] = self.validated_config @@ -1723,10 +1799,12 @@ def verify_diff_merged(self, config): ) discovery_name = config.get('discovery_name') if response: - self.log("Requested Discovery with name {0} is completed".format(discovery_name), "INFO") + self.log("Requested Discovery with name {0} is completed".format( + discovery_name), "INFO") else: - self.log("Requested Discovery with name {0} is not completed".format(discovery_name), "WARNING") + self.log("Requested Discovery with name {0} is not completed".format( + discovery_name), "WARNING") self.status = "success" return self @@ -1763,10 +1841,12 @@ def verify_diff_deleted(self, config): discovery_task_info = self.lookup_discovery_by_range_via_name() discovery_name = config.get('discovery_name') if discovery_task_info: - self.log("Requested Discovery with name {0} is present".format(discovery_name), "WARNING") + self.log("Requested Discovery with name {0} is present".format( + discovery_name), "WARNING") else: - self.log("Requested Discovery with name {0} is not present and deleted".format(discovery_name), "INFO") + self.log("Requested Discovery with name {0} is not present and deleted".format( + discovery_name), "INFO") self.status = "success" return self @@ -1812,7 +1892,8 @@ def main(): ccc_discovery.reset_values() ccc_discovery.get_diff_state_apply[state]().check_return_status() if config_verify: - ccc_discovery.verify_diff_state_apply[state](config).check_return_status() + ccc_discovery.verify_diff_state_apply[state]( + config).check_return_status() module.exit_json(**ccc_discovery.result) diff --git a/plugins/modules/events_and_notifications_workflow_manager.py b/plugins/modules/events_and_notifications_workflow_manager.py index 4c0aa2016e..ab1361ce20 100644 --- a/plugins/modules/events_and_notifications_workflow_manager.py +++ b/plugins/modules/events_and_notifications_workflow_manager.py @@ -5,6 +5,13 @@ # 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 +import time +import re +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, +) +from ansible.module_utils.basic import AnsibleModule __metaclass__ = type __author__ = ("Abhishek Maheshwari, Madhan Sankaranarayanan") @@ -929,14 +936,6 @@ } """ -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, -) -import re -import time - class Events(DnacBase): """Class containing member attributes for inventory workflow manager module""" @@ -1097,14 +1096,16 @@ def validate_input(self): ) if invalid_params: - self.msg = "The playbook contains invalid parameters: {0}".format(invalid_params) + self.msg = "The playbook contains invalid parameters: {0}".format( + invalid_params) self.log(self.msg, "ERROR") self.status = "failed" self.result['response'] = self.msg return self self.validated_config = valid_temp - self.msg = "Successfully validated playbook configuration parameters using 'validate_input': {0}".format(str(valid_temp)) + self.msg = "Successfully validated playbook configuration parameters using 'validate_input': {0}".format( + str(valid_temp)) self.log(self.msg, "INFO") self.status = "success" @@ -1162,19 +1163,22 @@ def get_have(self, config): if config.get("syslog_event_notification"): name = config.get("syslog_event_notification").get("name") - syslog_subscription_notifications = self.get_syslog_notification_details(name) + syslog_subscription_notifications = self.get_syslog_notification_details( + name) if syslog_subscription_notifications: have["syslog_subscription_notifications"] = syslog_subscription_notifications if config.get("webhook_event_notification"): name = config.get("webhook_event_notification").get("name") - webhook_subscription_notifications = self.get_webhook_notification_details(name) + webhook_subscription_notifications = self.get_webhook_notification_details( + name) if webhook_subscription_notifications: have["webhook_subscription_notifications"] = webhook_subscription_notifications if config.get("email_event_notification"): name = config.get("email_event_notification").get("name") - email_subscription_notifications = self.get_email_notification_details(name) + email_subscription_notifications = self.get_email_notification_details( + name) if email_subscription_notifications: have["email_subscription_notifications"] = email_subscription_notifications @@ -1215,13 +1219,16 @@ def get_want(self, config): want['itsm_details'] = config.get('itsm_setting') if config.get('webhook_event_notification'): - want['webhook_event_notification'] = config.get('webhook_event_notification') + want['webhook_event_notification'] = config.get( + 'webhook_event_notification') if config.get('email_event_notification'): - want['email_event_notification'] = config.get('email_event_notification') + want['email_event_notification'] = config.get( + 'email_event_notification') if config.get('syslog_event_notification'): - want['syslog_event_notification'] = config.get('syslog_event_notification') + want['syslog_event_notification'] = config.get( + 'syslog_event_notification') self.want = want self.msg = "Successfully collected all parameters from the playbook " @@ -1252,11 +1259,13 @@ def get_syslog_destination_in_ccc(self, name): op_modifies=True, params={"name": name} ) - self.log("Received API response from 'get_syslog_destination': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_syslog_destination': {0}".format( + str(response)), "DEBUG") response = response.get('statusMessage') if not response: - self.log("There is no Syslog destination '{0}' present in Cisco Catalyst Center".format(name), "INFO") + self.log("There is no Syslog destination '{0}' present in Cisco Catalyst Center".format( + name), "INFO") return response return response @@ -1272,12 +1281,14 @@ def get_syslog_destination_in_ccc(self, name): if msg in str(e): self.log( "An exception occurred while checking for the Syslog destination with the name '{0}'. " - "It was not found in Cisco Catalyst Center.".format(name), "WARNING" + "It was not found in Cisco Catalyst Center.".format( + name), "WARNING" ) return None self.status = "failed" - self.msg = "Error while getting the details of Syslog destination present in Cisco Catalyst Center: {0}".format(str(e)) + self.msg = "Error while getting the details of Syslog destination present in Cisco Catalyst Center: {0}".format( + str(e)) self.log(self.msg, "ERROR") self.result['response'] = self.msg self.check_return_status() @@ -1339,7 +1350,8 @@ def add_syslog_destination(self, syslog_details): if not protocol: self.status = "failed" - self.msg = "Protocol is needed while configuring the syslog destionation with name '{0}' in Cisco Catalyst Center".format(name) + self.msg = "Protocol is needed while configuring the syslog destionation with name '{0}' in Cisco Catalyst Center".format( + name) self.log(self.msg, "ERROR") self.result['response'] = self.msg return self @@ -1368,13 +1380,15 @@ def add_syslog_destination(self, syslog_details): op_modifies=True, params=add_syslog_params ) - self.log("Received API response from 'create_syslog_destination': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'create_syslog_destination': {0}".format( + str(response)), "DEBUG") status = response.get('apiStatus') if status == 'SUCCESS': self.status = "success" self.result['changed'] = True - self.msg = "Syslog Destination with name '{0}' added successfully in Cisco Catalyst Center".format(name) + self.msg = "Syslog Destination with name '{0}' added successfully in Cisco Catalyst Center".format( + name) self.log(self.msg, "INFO") self.create_dest.append(name) return self @@ -1383,7 +1397,8 @@ def add_syslog_destination(self, syslog_details): try: failure_msg = response.get('errorMessage').get('errors') except Exception as e: - failure_msg = "Unable to add syslog destination with name '{0}' in Cisco Catalyst Center".format(name) + failure_msg = "Unable to add syslog destination with name '{0}' in Cisco Catalyst Center".format( + name) self.msg = failure_msg self.log(self.msg, "ERROR") @@ -1391,7 +1406,8 @@ def add_syslog_destination(self, syslog_details): except Exception as e: self.status = "failed" - self.msg = "Error while adding the Syslog destination with the name '{0}' in Cisco Catalyst Center: {1}".format(name, str(e)) + self.msg = "Error while adding the Syslog destination with the name '{0}' in Cisco Catalyst Center: {1}".format( + name, str(e)) self.log(self.msg, "ERROR") return self @@ -1416,12 +1432,18 @@ def update_syslog_destination(self, syslog_details, syslog_details_in_ccc): try: update_syslog_params = {} - update_syslog_params['name'] = syslog_details.get('name') or syslog_details_in_ccc.get('name') - update_syslog_params['description'] = syslog_details.get('description') or syslog_details_in_ccc.get('description') - update_syslog_params['host'] = syslog_details.get('server_address') or syslog_details_in_ccc.get('host') - update_syslog_params['protocol'] = syslog_details.get('protocol') or syslog_details_in_ccc.get('protocol') - update_syslog_params['port'] = int(syslog_details.get('port') or syslog_details_in_ccc.get('port')) - update_syslog_params['configId'] = syslog_details_in_ccc.get('configId') + update_syslog_params['name'] = syslog_details.get( + 'name') or syslog_details_in_ccc.get('name') + update_syslog_params['description'] = syslog_details.get( + 'description') or syslog_details_in_ccc.get('description') + update_syslog_params['host'] = syslog_details.get( + 'server_address') or syslog_details_in_ccc.get('host') + update_syslog_params['protocol'] = syslog_details.get( + 'protocol') or syslog_details_in_ccc.get('protocol') + update_syslog_params['port'] = int(syslog_details.get( + 'port') or syslog_details_in_ccc.get('port')) + update_syslog_params['configId'] = syslog_details_in_ccc.get( + 'configId') name = update_syslog_params.get('name') if update_syslog_params.get('protocol').upper() not in ["TCP", "UDP"]: @@ -1438,13 +1460,15 @@ def update_syslog_destination(self, syslog_details, syslog_details_in_ccc): op_modifies=True, params=update_syslog_params ) - self.log("Received API response from 'update_syslog_destination': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'update_syslog_destination': {0}".format( + str(response)), "DEBUG") status = response.get('apiStatus') if status == 'SUCCESS': self.status = "success" self.result['changed'] = True - self.msg = "Syslog Destination with name '{0}' updated successfully in Cisco Catalyst Center".format(name) + self.msg = "Syslog Destination with name '{0}' updated successfully in Cisco Catalyst Center".format( + name) self.log(self.msg, "INFO") self.update_dest.append(name) return self @@ -1453,7 +1477,8 @@ def update_syslog_destination(self, syslog_details, syslog_details_in_ccc): try: failure_msg = response.get('errorMessage').get('errors') except Exception as e: - failure_msg = "Unable to update syslog destination with name '{0}' in Cisco Catalyst Center".format(name) + failure_msg = "Unable to update syslog destination with name '{0}' in Cisco Catalyst Center".format( + name) self.msg = failure_msg self.log(self.msg, "ERROR") @@ -1461,7 +1486,8 @@ def update_syslog_destination(self, syslog_details, syslog_details_in_ccc): except Exception as e: self.status = "failed" - self.msg = "Error while updating the Syslog destination with the name '{0}' in Cisco Catalyst Center: {1}".format(name, str(e)) + self.msg = "Error while updating the Syslog destination with the name '{0}' in Cisco Catalyst Center: {1}".format( + name, str(e)) self.log(self.msg, "ERROR") return self @@ -1496,15 +1522,18 @@ def get_snmp_destination_in_ccc(self, name): } ) offset = offset + 1 - self.log("Received API response from 'get_snmp_destination': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_snmp_destination': {0}".format( + str(response)), "DEBUG") if not response: - self.log("There is no SNMP destination with name '{0}' present in Cisco Catalyst Center".format(name), "INFO") + self.log("There is no SNMP destination with name '{0}' present in Cisco Catalyst Center".format( + name), "INFO") return response for destination in response: if destination.get("name") == name: - self.log("SNMP Destination '{0}' present in Cisco Catalyst Center".format(name), "INFO") + self.log( + "SNMP Destination '{0}' present in Cisco Catalyst Center".format(name), "INFO") return destination time.sleep(1) except Exception as e: @@ -1517,13 +1546,15 @@ def get_snmp_destination_in_ccc(self, name): if msg in str(e): self.log( "An exception occurred while checking for the SNMP destination with the name '{0}'. " - "It was not found in Cisco Catalyst Center.".format(name), "WARNING" + "It was not found in Cisco Catalyst Center.".format( + name), "WARNING" ) return None except Exception as e: self.status = "failed" - self.msg = "Error while getting the details of SNMP destination present in Cisco Catalyst Center: {0}".format(str(e)) + self.msg = "Error while getting the details of SNMP destination present in Cisco Catalyst Center: {0}".format( + str(e)) self.log(self.msg, "ERROR") self.check_return_status() @@ -1553,14 +1584,16 @@ def collect_snmp_playbook_params(self, snmp_details): if snmp_version and snmp_version not in ["V2C", "V3"]: self.status = "failed" - self.msg = "Invalid SNMP version '{0}' given in the playbook for configuring SNMP destination".format(snmp_version) + self.msg = "Invalid SNMP version '{0}' given in the playbook for configuring SNMP destination".format( + snmp_version) self.log(self.msg, "ERROR") self.result['response'] = self.msg self.check_return_status() if server_address and not self.is_valid_server_address(server_address): self.status = "failed" - self.msg = "Invalid server address '{0}' given in the playbook for configuring SNMP destination".format(server_address) + self.msg = "Invalid server address '{0}' given in the playbook for configuring SNMP destination".format( + server_address) self.log(self.msg, "ERROR") self.result['response'] = self.msg self.check_return_status() @@ -1591,12 +1624,16 @@ def collect_snmp_playbook_params(self, snmp_details): if playbook_params.get("snmpMode") == "AUTH_PRIVACY": playbook_params['snmpAuthType'] = auth_type - playbook_params['authPassword'] = snmp_details.get('auth_password') - playbook_params['snmpPrivacyType'] = snmp_details.get('privacy_type', 'AES128') - playbook_params['privacyPassword'] = snmp_details.get('privacy_password') + playbook_params['authPassword'] = snmp_details.get( + 'auth_password') + playbook_params['snmpPrivacyType'] = snmp_details.get( + 'privacy_type', 'AES128') + playbook_params['privacyPassword'] = snmp_details.get( + 'privacy_password') elif playbook_params.get("snmpMode") == "AUTH_NO_PRIVACY": playbook_params['snmpAuthType'] = auth_type - playbook_params['authPassword'] = snmp_details.get('auth_password') + playbook_params['authPassword'] = snmp_details.get( + 'auth_password') return playbook_params @@ -1619,16 +1656,19 @@ def check_snmp_required_parameters(self, snmp_params): """ missing_params_list = [] - required_parameter_list = ["name", "description", "ipAddress", "port", "snmpVersion"] + required_parameter_list = [ + "name", "description", "ipAddress", "port", "snmpVersion"] if snmp_params['snmpVersion'] == "V2C": required_parameter_list.append("community") else: required_parameter_list.extend(["userName", "snmpMode"]) if snmp_params['snmpMode'] == "AUTH_PRIVACY": - required_parameter_list.extend(["snmpAuthType", "authPassword", "privacyPassword"]) + required_parameter_list.extend( + ["snmpAuthType", "authPassword", "privacyPassword"]) elif snmp_params['snmpMode'] == "AUTH_NO_PRIVACY": - required_parameter_list.extend(["snmpAuthType", "authPassword"]) + required_parameter_list.extend( + ["snmpAuthType", "authPassword"]) for item in required_parameter_list: if snmp_params[item] is None: @@ -1641,7 +1681,8 @@ def check_snmp_required_parameters(self, snmp_params): return self self.status = "failed" - self.msg = "Required parameter '{0}' is missing for adding SNMP Destination in Cisco Catalyst Center".format(str(missing_params_list)) + self.msg = "Required parameter '{0}' is missing for adding SNMP Destination in Cisco Catalyst Center".format( + str(missing_params_list)) self.log(self.msg, "ERROR") self.result['response'] = self.msg @@ -1674,13 +1715,15 @@ def add_snmp_destination(self, snmp_params): op_modifies=True, params=snmp_params ) - self.log("Received API response from 'create_snmp_destination': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'create_snmp_destination': {0}".format( + str(response)), "DEBUG") status = response.get('apiStatus') if status == 'SUCCESS': self.status = "success" self.result['changed'] = True - self.msg = "SNMP Destination with name '{0}' added successfully in Cisco Catalyst Center".format(snmp_params.get('name')) + self.msg = "SNMP Destination with name '{0}' added successfully in Cisco Catalyst Center".format( + snmp_params.get('name')) self.log(self.msg, "INFO") self.create_dest.append(snmp_params.get('name')) return self @@ -1690,7 +1733,8 @@ def add_snmp_destination(self, snmp_params): if error_messages: self.msg = error_messages.get('errors') else: - self.msg = "Unable to add SNMP destination with name '{0}' in Cisco Catalyst Center".format(snmp_params.get('name')) + self.msg = "Unable to add SNMP destination with name '{0}' in Cisco Catalyst Center".format( + snmp_params.get('name')) self.log(self.msg, "ERROR") self.result['response'] = self.msg @@ -1752,18 +1796,24 @@ def update_snmp_destination(self, snmp_params, snmp_dest_detail_in_ccc): """ try: update_snmp_params = {} - update_snmp_params['name'] = snmp_params.get('name') or snmp_dest_detail_in_ccc.get('name') - update_snmp_params['description'] = snmp_params.get('description') or snmp_dest_detail_in_ccc.get('description') - update_snmp_params['ipAddress'] = snmp_params.get('ipAddress') or snmp_dest_detail_in_ccc.get('ipAddress') - update_snmp_params['port'] = snmp_params.get('port') or snmp_dest_detail_in_ccc.get('port') - update_snmp_params['snmpVersion'] = snmp_params.get('snmpVersion') or snmp_dest_detail_in_ccc.get('snmpVersion') + update_snmp_params['name'] = snmp_params.get( + 'name') or snmp_dest_detail_in_ccc.get('name') + update_snmp_params['description'] = snmp_params.get( + 'description') or snmp_dest_detail_in_ccc.get('description') + update_snmp_params['ipAddress'] = snmp_params.get( + 'ipAddress') or snmp_dest_detail_in_ccc.get('ipAddress') + update_snmp_params['port'] = snmp_params.get( + 'port') or snmp_dest_detail_in_ccc.get('port') + update_snmp_params['snmpVersion'] = snmp_params.get( + 'snmpVersion') or snmp_dest_detail_in_ccc.get('snmpVersion') if update_snmp_params.get('port'): try: port = int(update_snmp_params.get('port')) if port not in range(1, 65536): self.status = "failed" - self.msg = "Invalid Notification trap port '{0}' given in playbook. Select port from the number range(1, 65535)".format(port) + self.msg = "Invalid Notification trap port '{0}' given in playbook. Select port from the number range(1, 65535)".format( + port) self.log(self.msg, "ERROR") self.result['response'] = self.msg return self @@ -1775,20 +1825,30 @@ def update_snmp_destination(self, snmp_params, snmp_dest_detail_in_ccc): return self if update_snmp_params['snmpVersion'] == "V2C": - update_snmp_params['community'] = snmp_params.get('community') or snmp_dest_detail_in_ccc.get('community') + update_snmp_params['community'] = snmp_params.get( + 'community') or snmp_dest_detail_in_ccc.get('community') else: - update_snmp_params['userName'] = snmp_params.get('userName') or snmp_dest_detail_in_ccc.get('userName') - update_snmp_params['snmpMode'] = snmp_params.get('snmpMode') or snmp_dest_detail_in_ccc.get('snmpMode') + update_snmp_params['userName'] = snmp_params.get( + 'userName') or snmp_dest_detail_in_ccc.get('userName') + update_snmp_params['snmpMode'] = snmp_params.get( + 'snmpMode') or snmp_dest_detail_in_ccc.get('snmpMode') if update_snmp_params['snmpMode'] == "AUTH_PRIVACY": - update_snmp_params['snmpAuthType'] = snmp_params.get('snmpAuthType') or snmp_dest_detail_in_ccc.get('snmpAuthType') - update_snmp_params['authPassword'] = snmp_params.get('authPassword') or snmp_dest_detail_in_ccc.get('authPassword') - update_snmp_params['snmpPrivacyType'] = snmp_params.get('snmpPrivacyType', 'AES128') - update_snmp_params['privacyPassword'] = snmp_params.get('privacyPassword') or snmp_dest_detail_in_ccc.get('privacyPassword') + update_snmp_params['snmpAuthType'] = snmp_params.get( + 'snmpAuthType') or snmp_dest_detail_in_ccc.get('snmpAuthType') + update_snmp_params['authPassword'] = snmp_params.get( + 'authPassword') or snmp_dest_detail_in_ccc.get('authPassword') + update_snmp_params['snmpPrivacyType'] = snmp_params.get( + 'snmpPrivacyType', 'AES128') + update_snmp_params['privacyPassword'] = snmp_params.get( + 'privacyPassword') or snmp_dest_detail_in_ccc.get('privacyPassword') elif update_snmp_params['snmpMode'] == "AUTH_NO_PRIVACY": - update_snmp_params['snmpAuthType'] = snmp_params.get('snmpAuthType') or snmp_dest_detail_in_ccc.get('snmpAuthType') - update_snmp_params['authPassword'] = snmp_params.get('authPassword') or snmp_dest_detail_in_ccc.get('authPassword') + update_snmp_params['snmpAuthType'] = snmp_params.get( + 'snmpAuthType') or snmp_dest_detail_in_ccc.get('snmpAuthType') + update_snmp_params['authPassword'] = snmp_params.get( + 'authPassword') or snmp_dest_detail_in_ccc.get('authPassword') - update_snmp_params['configId'] = snmp_dest_detail_in_ccc.get('configId') + update_snmp_params['configId'] = snmp_dest_detail_in_ccc.get( + 'configId') response = self.dnac._exec( family="event_management", @@ -1796,13 +1856,15 @@ def update_snmp_destination(self, snmp_params, snmp_dest_detail_in_ccc): op_modifies=True, params=update_snmp_params ) - self.log("Received API response from 'update_snmp_destination': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'update_snmp_destination': {0}".format( + str(response)), "DEBUG") status = response.get('apiStatus') if status == 'SUCCESS': self.status = "success" self.result['changed'] = True - self.msg = "SNMP Destination with name '{0}' updated successfully in Cisco Catalyst Center".format(update_snmp_params.get('name')) + self.msg = "SNMP Destination with name '{0}' updated successfully in Cisco Catalyst Center".format( + update_snmp_params.get('name')) self.log(self.msg, "INFO") self.update_dest.append(update_snmp_params.get('name')) return self @@ -1812,14 +1874,16 @@ def update_snmp_destination(self, snmp_params, snmp_dest_detail_in_ccc): if error_messages: self.msg = error_messages.get('errors') else: - self.msg = "Unable to update SNMP destination with name '{0}' in Cisco Catalyst Center".format(update_snmp_params.get('name')) + self.msg = "Unable to update SNMP destination with name '{0}' in Cisco Catalyst Center".format( + update_snmp_params.get('name')) self.log(self.msg, "ERROR") self.result['response'] = self.msg except Exception as e: self.status = "failed" - self.msg = "Error while updating the SNMP destination with name '{0}' in Cisco Catalyst Center: {1}".format(update_snmp_params.get('name'), str(e)) + self.msg = "Error while updating the SNMP destination with name '{0}' in Cisco Catalyst Center: {1}".format( + update_snmp_params.get('name'), str(e)) self.log(self.msg, "ERROR") return self @@ -1853,16 +1917,19 @@ def get_webhook_destination_in_ccc(self, name): } ) offset = offset + 1 - self.log("Received API response from 'get_webhook_destination': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_webhook_destination': {0}".format( + str(response)), "DEBUG") response = response.get('statusMessage') if not response: - self.log("There is no Rest Webhook destination present in Cisco Catalyst Center", "INFO") + self.log( + "There is no Rest Webhook destination present in Cisco Catalyst Center", "INFO") return response for destination in response: if destination.get("name") == name: - self.log("Webhook Destination '{0}' present in Cisco Catalyst Center".format(name), "INFO") + self.log("Webhook Destination '{0}' present in Cisco Catalyst Center".format( + name), "INFO") return destination time.sleep(1) @@ -1876,13 +1943,15 @@ def get_webhook_destination_in_ccc(self, name): if msg in str(e): self.log( "An exception occurred while checking for the Webhook destination with the name '{0}'. " - "It was not found in Cisco Catalyst Center.".format(name), "WARNING" + "It was not found in Cisco Catalyst Center.".format( + name), "WARNING" ) return None except Exception as e: self.status = "failed" - self.msg = "Error while getting the details of Webhook destination(s) present in Cisco Catalyst Center: {0}".format(str(e)) + self.msg = "Error while getting the details of Webhook destination(s) present in Cisco Catalyst Center: {0}".format( + str(e)) self.log(self.msg, "ERROR") self.check_return_status() @@ -1940,20 +2009,23 @@ def add_webhook_destination(self, webhook_params): if webhook_params.get("isProxyRoute") is None: webhook_params["isProxyRoute"] = True - self.log("Requested payload for creating webhook destination - {0}".format(str(webhook_params)), "INFO") + self.log( + "Requested payload for creating webhook destination - {0}".format(str(webhook_params)), "INFO") response = self.dnac._exec( family="event_management", function='create_webhook_destination', op_modifies=True, params=webhook_params ) - self.log("Received API response from 'create_webhook_destination': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'create_webhook_destination': {0}".format( + str(response)), "DEBUG") status = response.get('apiStatus') if status == 'SUCCESS': self.status = "success" self.result['changed'] = True - self.msg = "Webhook Destination with name '{0}' added successfully in Cisco Catalyst Center".format(webhook_params.get('name')) + self.msg = "Webhook Destination with name '{0}' added successfully in Cisco Catalyst Center".format( + webhook_params.get('name')) self.log(self.msg, "INFO") self.create_dest.append(webhook_params.get('name')) return self @@ -1963,14 +2035,16 @@ def add_webhook_destination(self, webhook_params): if error_messages: self.msg = error_messages.get('errors') else: - self.msg = "Unable to add Webhook destination with name '{0}' in Cisco Catalyst Center".format(webhook_params.get('name')) + self.msg = "Unable to add Webhook destination with name '{0}' in Cisco Catalyst Center".format( + webhook_params.get('name')) self.log(self.msg, "ERROR") self.result['response'] = self.msg except Exception as e: self.status = "failed" - self.msg = "Error while adding the Webhook destination with the name '{0}' in Cisco Catalyst Center: {1}".format(webhook_params.get('name'), str(e)) + self.msg = "Error while adding the Webhook destination with the name '{0}' in Cisco Catalyst Center: {1}".format( + webhook_params.get('name'), str(e)) self.log(self.msg, "ERROR") return self @@ -2001,7 +2075,8 @@ def webhook_header_needs_update(self, playbook_header, ccc_header): if playbook_header and not ccc_header: return True - playbook_dict = {item['name']: item['value'] for item in playbook_header} + playbook_dict = {item['name']: item['value'] + for item in playbook_header} ccc_dict = {item['name']: item['value'] for item in ccc_header} return playbook_dict != ccc_dict @@ -2027,7 +2102,8 @@ def webhook_dest_needs_update(self, webhook_params, webhook_dest_detail_in_ccc): for key, value in webhook_params.items(): if isinstance(value, list): - update_needed = self.webhook_header_needs_update(value, webhook_dest_detail_in_ccc[key]) + update_needed = self.webhook_header_needs_update( + value, webhook_dest_detail_in_ccc[key]) if update_needed: break elif webhook_dest_detail_in_ccc[key] == value or value is None: @@ -2058,24 +2134,34 @@ def update_webhook_destination(self, webhook_params, webhook_dest_detail_in_ccc) try: update_webhook_params = {} - update_webhook_params['name'] = webhook_params.get('name') or webhook_dest_detail_in_ccc.get('name') - update_webhook_params['description'] = webhook_params.get('description') or webhook_dest_detail_in_ccc.get('description') - update_webhook_params['url'] = webhook_params.get('url') or webhook_dest_detail_in_ccc.get('url') - update_webhook_params['method'] = webhook_params.get('method') or webhook_dest_detail_in_ccc.get('method') - update_webhook_params['trustCert'] = webhook_params.get('trustCert') - update_webhook_params['isProxyRoute'] = webhook_params.get('isProxyRoute') + update_webhook_params['name'] = webhook_params.get( + 'name') or webhook_dest_detail_in_ccc.get('name') + update_webhook_params['description'] = webhook_params.get( + 'description') or webhook_dest_detail_in_ccc.get('description') + update_webhook_params['url'] = webhook_params.get( + 'url') or webhook_dest_detail_in_ccc.get('url') + update_webhook_params['method'] = webhook_params.get( + 'method') or webhook_dest_detail_in_ccc.get('method') + update_webhook_params['trustCert'] = webhook_params.get( + 'trustCert') + update_webhook_params['isProxyRoute'] = webhook_params.get( + 'isProxyRoute') update_webhook_params['headers'] = webhook_params.get('headers') - update_webhook_params['webhookId'] = webhook_dest_detail_in_ccc.get('webhookId') + update_webhook_params['webhookId'] = webhook_dest_detail_in_ccc.get( + 'webhookId') name = update_webhook_params.get('name') if update_webhook_params.get("trustCert") is None: - update_webhook_params["trustCert"] = webhook_dest_detail_in_ccc.get('trustCert') + update_webhook_params["trustCert"] = webhook_dest_detail_in_ccc.get( + 'trustCert') if update_webhook_params.get("isProxyRoute") is None: - update_webhook_params["isProxyRoute"] = webhook_dest_detail_in_ccc.get('isProxyRoute') + update_webhook_params["isProxyRoute"] = webhook_dest_detail_in_ccc.get( + 'isProxyRoute') if update_webhook_params['headers'] != [] and not update_webhook_params['headers'] and webhook_dest_detail_in_ccc.get('headers'): - update_webhook_params['headers'] = webhook_dest_detail_in_ccc.get('headers') + update_webhook_params['headers'] = webhook_dest_detail_in_ccc.get( + 'headers') response = self.dnac._exec( family="event_management", @@ -2083,13 +2169,15 @@ def update_webhook_destination(self, webhook_params, webhook_dest_detail_in_ccc) op_modifies=True, params=update_webhook_params ) - self.log("Received API response from 'update_webhook_destination': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'update_webhook_destination': {0}".format( + str(response)), "DEBUG") status = response.get('apiStatus') if status == 'SUCCESS': self.status = "success" self.result['changed'] = True - self.msg = "Rest Webhook Destination with name '{0}' updated successfully in Cisco Catalyst Center".format(name) + self.msg = "Rest Webhook Destination with name '{0}' updated successfully in Cisco Catalyst Center".format( + name) self.log(self.msg, "INFO") self.update_dest.append(name) return self @@ -2100,14 +2188,16 @@ def update_webhook_destination(self, webhook_params, webhook_dest_detail_in_ccc) if error_messages: self.msg = error_messages.get('errors') else: - self.msg = "Unable to update rest webhook destination with name '{0}' in Cisco Catalyst Center".format(name) + self.msg = "Unable to update rest webhook destination with name '{0}' in Cisco Catalyst Center".format( + name) self.log(self.msg, "ERROR") self.result['response'] = self.msg except Exception as e: self.status = "failed" - self.msg = "Error while updating the Rest Webhook destination with the name '{0}' in Cisco Catalyst Center: {1}".format(name, str(e)) + self.msg = "Error while updating the Rest Webhook destination with the name '{0}' in Cisco Catalyst Center: {1}".format( + name, str(e)) self.log(self.msg, "ERROR") return self @@ -2131,10 +2221,12 @@ def get_email_destination_in_ccc(self): family="event_management", function='get_email_destination' ) - self.log("Received API response from 'get_email_destination': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_email_destination': {0}".format( + str(response)), "DEBUG") if not response: - self.log("There is no Email destination present in Cisco Catalyst Center", "INFO") + self.log( + "There is no Email destination present in Cisco Catalyst Center", "INFO") return response return response[0] @@ -2154,7 +2246,8 @@ def get_email_destination_in_ccc(self): return None self.status = "failed" - self.msg = "Error while getting the details of Email destination present in Cisco Catalyst Center: {0}".format(str(e)) + self.msg = "Error while getting the details of Email destination present in Cisco Catalyst Center: {0}".format( + str(e)) self.log(self.msg, "ERROR") self.check_return_status() @@ -2180,7 +2273,8 @@ def collect_email_playbook_params(self, email_details): if email_details.get('primary_smtp_config'): primary_smtp_details = email_details.get('primary_smtp_config') - primary_smtp_type = primary_smtp_details.get('smtp_type', "DEFAULT") + primary_smtp_type = primary_smtp_details.get( + 'smtp_type', "DEFAULT") if primary_smtp_type is None: primary_smtp_type = "DEFAULT" @@ -2193,19 +2287,24 @@ def collect_email_playbook_params(self, email_details): self.check_return_status() playbook_params['primarySMTPConfig'] = {} - playbook_params['primarySMTPConfig']['hostName'] = primary_smtp_details.get('server_address') + playbook_params['primarySMTPConfig']['hostName'] = primary_smtp_details.get( + 'server_address') playbook_params['primarySMTPConfig']['smtpType'] = primary_smtp_type if primary_smtp_type == 'DEFAULT': playbook_params['primarySMTPConfig']['port'] = "25" else: - playbook_params['primarySMTPConfig']['port'] = primary_smtp_details.get('port') - playbook_params['primarySMTPConfig']['userName'] = primary_smtp_details.get('username', '') - playbook_params['primarySMTPConfig']['password'] = primary_smtp_details.get('password', '') + playbook_params['primarySMTPConfig']['port'] = primary_smtp_details.get( + 'port') + playbook_params['primarySMTPConfig']['userName'] = primary_smtp_details.get( + 'username', '') + playbook_params['primarySMTPConfig']['password'] = primary_smtp_details.get( + 'password', '') if email_details.get('secondary_smtp_config'): secondary_smtp_details = email_details.get('secondary_smtp_config') - secondary_smtp_type = secondary_smtp_details.get('smtp_type', "DEFAULT") + secondary_smtp_type = secondary_smtp_details.get( + 'smtp_type', "DEFAULT") if secondary_smtp_type is None: secondary_smtp_type = "DEFAULT" @@ -2218,15 +2317,19 @@ def collect_email_playbook_params(self, email_details): self.check_return_status() playbook_params['secondarySMTPConfig'] = {} - playbook_params['secondarySMTPConfig']['hostName'] = secondary_smtp_details.get('server_address') + playbook_params['secondarySMTPConfig']['hostName'] = secondary_smtp_details.get( + 'server_address') playbook_params['secondarySMTPConfig']['smtpType'] = secondary_smtp_type if playbook_params['secondarySMTPConfig']['smtpType'] == 'DEFAULT': playbook_params['secondarySMTPConfig']['port'] = "25" else: - playbook_params['secondarySMTPConfig']['port'] = secondary_smtp_details.get('port') - playbook_params['secondarySMTPConfig']['userName'] = secondary_smtp_details.get('username', '') - playbook_params['secondarySMTPConfig']['password'] = secondary_smtp_details.get('password', '') + playbook_params['secondarySMTPConfig']['port'] = secondary_smtp_details.get( + 'port') + playbook_params['secondarySMTPConfig']['userName'] = secondary_smtp_details.get( + 'username', '') + playbook_params['secondarySMTPConfig']['password'] = secondary_smtp_details.get( + 'password', '') return playbook_params @@ -2254,7 +2357,8 @@ def add_email_destination(self, email_params): op_modifies=True, params=email_params ) - self.log("Received API response from 'create_email_destination': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'create_email_destination': {0}".format( + str(response)), "DEBUG") time.sleep(2) status = response.get('statusUri') status_execution_id = status.split("/")[-1] @@ -2281,7 +2385,8 @@ def add_email_destination(self, email_params): except Exception as e: self.status = "failed" - self.msg = "Error while adding the Email destination in Cisco Catalyst Center: {0}".format(str(e)) + self.msg = "Error while adding the Email destination in Cisco Catalyst Center: {0}".format( + str(e)) self.log(self.msg, "ERROR") return self @@ -2314,7 +2419,8 @@ def email_dest_needs_update(self, email_params, email_dest_detail_in_ccc): if isinstance(value, dict): # Recursive call should impact the update_needed flag - update_needed = self.email_dest_needs_update(value, email_dest_detail_in_ccc[key]) + update_needed = self.email_dest_needs_update( + value, email_dest_detail_in_ccc[key]) if update_needed: break elif email_dest_detail_in_ccc.get(key) != value and value != "": @@ -2344,12 +2450,18 @@ def update_email_destination(self, email_details, email_dest_detail_in_ccc): try: update_email_params = {} - update_email_params['primarySMTPConfig'] = email_details.get('primarySMTPConfig') or email_dest_detail_in_ccc.get('primarySMTPConfig') - update_email_params['secondarySMTPConfig'] = email_details.get('secondarySMTPConfig') or email_dest_detail_in_ccc.get('secondarySMTPConfig', 'None') - update_email_params['fromEmail'] = email_details.get('fromEmail') or email_dest_detail_in_ccc.get('fromEmail') - update_email_params['toEmail'] = email_details.get('toEmail') or email_dest_detail_in_ccc.get('toEmail') - update_email_params['subject'] = email_details.get('subject') or email_dest_detail_in_ccc.get('subject') - update_email_params['emailConfigId'] = email_dest_detail_in_ccc.get('emailConfigId') + update_email_params['primarySMTPConfig'] = email_details.get( + 'primarySMTPConfig') or email_dest_detail_in_ccc.get('primarySMTPConfig') + update_email_params['secondarySMTPConfig'] = email_details.get( + 'secondarySMTPConfig') or email_dest_detail_in_ccc.get('secondarySMTPConfig', 'None') + update_email_params['fromEmail'] = email_details.get( + 'fromEmail') or email_dest_detail_in_ccc.get('fromEmail') + update_email_params['toEmail'] = email_details.get( + 'toEmail') or email_dest_detail_in_ccc.get('toEmail') + update_email_params['subject'] = email_details.get( + 'subject') or email_dest_detail_in_ccc.get('subject') + update_email_params['emailConfigId'] = email_dest_detail_in_ccc.get( + 'emailConfigId') response = self.dnac._exec( family="event_management", @@ -2357,7 +2469,8 @@ def update_email_destination(self, email_details, email_dest_detail_in_ccc): op_modifies=True, params=update_email_params ) - self.log("Received API response from 'update_email_destination': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'update_email_destination': {0}".format( + str(response)), "DEBUG") time.sleep(2) status = response.get('statusUri') status_execution_id = status.split("/")[-1] @@ -2383,7 +2496,8 @@ def update_email_destination(self, email_details, email_dest_detail_in_ccc): except Exception as e: self.status = "failed" - self.msg = "Error while updating the Email destination in Cisco Catalyst Center: {0}".format(str(e)) + self.msg = "Error while updating the Email destination in Cisco Catalyst Center: {0}".format( + str(e)) self.log(self.msg, "ERROR") return self @@ -2411,16 +2525,19 @@ def get_itsm_settings_in_ccc(self, name): op_modifies=True, params={"name": name} ) - self.log("Received API response from 'get_all_itsm_integration_settings': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_all_itsm_integration_settings': {0}".format( + str(response)), "DEBUG") response = response.get('data') if not response: - self.log("There is no ITSM Integration settings present in Cisco Catalyst Center", "INFO") + self.log( + "There is no ITSM Integration settings present in Cisco Catalyst Center", "INFO") return response except Exception as e: self.status = "failed" - self.msg = "Error while getting the details of ITSM Integration Settings present in Cisco Catalyst Center: {0}".format(str(e)) + self.msg = "Error while getting the details of ITSM Integration Settings present in Cisco Catalyst Center: {0}".format( + str(e)) self.log(self.msg, "ERROR") self.check_return_status() @@ -2446,16 +2563,19 @@ def get_itsm_settings_by_id(self, itsm_id): op_modifies=True, params={"instance_id": itsm_id} ) - self.log("Received API response from 'get_itsm_integration_setting_by_id': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_itsm_integration_setting_by_id': {0}".format( + str(response)), "DEBUG") if not response: - self.log("There is no ITSM Integration settings with given ID present in Cisco Catalyst Center", "INFO") + self.log( + "There is no ITSM Integration settings with given ID present in Cisco Catalyst Center", "INFO") return response except Exception as e: self.status = "failed" - self.msg = "Error while getting the details of ITSM Integration Setting by id present in Cisco Catalyst Center: {0}".format(str(e)) + self.msg = "Error while getting the details of ITSM Integration Setting by id present in Cisco Catalyst Center: {0}".format( + str(e)) self.log(self.msg, "ERROR") self.check_return_status() @@ -2483,9 +2603,12 @@ def collect_itsm_playbook_params(self, itsm_details): if connection_details: playbook_params['data']['ConnectionSettings'] = {} - playbook_params['data']['ConnectionSettings']['Url'] = connection_details.get('url') - playbook_params['data']['ConnectionSettings']['Auth_UserName'] = connection_details.get('username') - playbook_params['data']['ConnectionSettings']['Auth_Password'] = connection_details.get('password') + playbook_params['data']['ConnectionSettings']['Url'] = connection_details.get( + 'url') + playbook_params['data']['ConnectionSettings']['Auth_UserName'] = connection_details.get( + 'username') + playbook_params['data']['ConnectionSettings']['Auth_Password'] = connection_details.get( + 'password') return playbook_params @@ -2542,13 +2665,15 @@ def create_itsm_integration_setting(self, itsm_params): op_modifies=True, params=itsm_params ) - self.log("Received API response from 'create_itsm_integration_setting': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'create_itsm_integration_setting': {0}".format( + str(response)), "DEBUG") created_date = response.get('createdDate') if created_date: self.status = "success" self.result['changed'] = True - self.msg = "ITSM Integration Settings with name '{0}' has been created successfully in Cisco Catalyst Center".format(instance_name) + self.msg = "ITSM Integration Settings with name '{0}' has been created successfully in Cisco Catalyst Center".format( + instance_name) self.log(self.msg, "INFO") self.create_dest.append(instance_name) return self @@ -2557,7 +2682,8 @@ def create_itsm_integration_setting(self, itsm_params): failure_msg = response.get('errors') if not failure_msg: - failure_msg = "Unable to create ITSM Integration Settings with name '{0}' in Cisco Catalyst Center".format(instance_name) + failure_msg = "Unable to create ITSM Integration Settings with name '{0}' in Cisco Catalyst Center".format( + instance_name) self.msg = failure_msg self.log(self.msg, "ERROR") @@ -2565,7 +2691,8 @@ def create_itsm_integration_setting(self, itsm_params): except Exception as e: self.status = "failed" - self.msg = "Error while creating the ITSM Integration Settings with name '{0}' in Cisco Catalyst Center: {1}".format(instance_name, str(e)) + self.msg = "Error while creating the ITSM Integration Settings with name '{0}' in Cisco Catalyst Center: {1}".format( + instance_name, str(e)) self.log(self.msg, "ERROR") return self @@ -2598,11 +2725,13 @@ def itsm_needs_update(self, itsm_params, itsm_in_ccc): return itsm_require_update if itsm_params.get('data') is None or itsm_params.get('data').get('ConnectionSettings') is None: - self.log("ITSM Connection settings parameters are not given in the input playbook so no update required.", "INFO") + self.log( + "ITSM Connection settings parameters are not given in the input playbook so no update required.", "INFO") return itsm_require_update url = itsm_params.get('data').get('ConnectionSettings').get('Url') - username = itsm_params.get('data').get('ConnectionSettings').get('Auth_UserName') + username = itsm_params.get('data').get( + 'ConnectionSettings').get('Auth_UserName') if url and url != itsm_in_ccc.get('data').get('ConnectionSettings').get('Url'): itsm_require_update = True @@ -2634,22 +2763,29 @@ def update_itsm_integration_setting(self, itsm_params, itsm_in_ccc): try: update_itsm_params = {} - update_itsm_params['name'] = itsm_params.get('name') or itsm_in_ccc.get('name') - update_itsm_params['description'] = itsm_params.get('description') or itsm_in_ccc.get('description') + update_itsm_params['name'] = itsm_params.get( + 'name') or itsm_in_ccc.get('name') + update_itsm_params['description'] = itsm_params.get( + 'description') or itsm_in_ccc.get('description') update_itsm_params['dypName'] = 'ServiceNowConnection' update_itsm_params['data'] = {} update_itsm_params['data']['ConnectionSettings'] = {} - url_in_ccc = itsm_in_ccc.get('data').get('ConnectionSettings').get('Url') - username_in_ccc = itsm_in_ccc.get('data').get('ConnectionSettings').get('Auth_UserName') + url_in_ccc = itsm_in_ccc.get('data').get( + 'ConnectionSettings').get('Url') + username_in_ccc = itsm_in_ccc.get('data').get( + 'ConnectionSettings').get('Auth_UserName') if itsm_params.get('data') is None or itsm_params.get('data').get('ConnectionSettings') is None: update_itsm_params['data']['ConnectionSettings']['Url'] = url_in_ccc update_itsm_params['data']['ConnectionSettings']['Auth_UserName'] = username_in_ccc else: - connection_params = itsm_params.get('data').get('ConnectionSettings') - update_itsm_params['data']['ConnectionSettings']['Url'] = connection_params.get('Url') or url_in_ccc - update_itsm_params['data']['ConnectionSettings']['Auth_UserName'] = connection_params.get('Auth_UserName') or username_in_ccc + connection_params = itsm_params.get( + 'data').get('ConnectionSettings') + update_itsm_params['data']['ConnectionSettings']['Url'] = connection_params.get( + 'Url') or url_in_ccc + update_itsm_params['data']['ConnectionSettings']['Auth_UserName'] = connection_params.get( + 'Auth_UserName') or username_in_ccc if not connection_params.get('Auth_Password'): self.status = "failed" @@ -2659,15 +2795,18 @@ def update_itsm_integration_setting(self, itsm_params, itsm_in_ccc): self.result['response'] = self.msg return self - update_itsm_params['data']['ConnectionSettings']['Auth_Password'] = connection_params.get('Auth_Password') + update_itsm_params['data']['ConnectionSettings']['Auth_Password'] = connection_params.get( + 'Auth_Password') # Check whether the given url is valid or not - url = update_itsm_params.get('data').get('ConnectionSettings').get('Url') + url = update_itsm_params.get('data').get( + 'ConnectionSettings').get('Url') regex_pattern = r'https://\S+' if not re.match(regex_pattern, url): self.status = "failed" - self.msg = "Given url '{0}' is invalid url for ITSM Intergartion setting. It must start with 'https://'".format(url) + self.msg = "Given url '{0}' is invalid url for ITSM Intergartion setting. It must start with 'https://'".format( + url) self.log(self.msg, "ERROR") self.result['response'] = self.msg return self @@ -2683,7 +2822,8 @@ def update_itsm_integration_setting(self, itsm_params, itsm_in_ccc): op_modifies=True, params=itsm_param_dict, ) - self.log("Received API response from 'update_itsm_integration_setting': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'update_itsm_integration_setting': {0}".format( + str(response)), "DEBUG") updated_date = response.get('updatedDate') @@ -2701,7 +2841,8 @@ def update_itsm_integration_setting(self, itsm_params, itsm_in_ccc): failure_msg = response.get('errors') if not failure_msg: - failure_msg = "Unable to update ITSM Integration Settings with name '{0}' in Cisco Catalyst Center".format(update_itsm_params.get('name')) + failure_msg = "Unable to update ITSM Integration Settings with name '{0}' in Cisco Catalyst Center".format( + update_itsm_params.get('name')) self.msg = failure_msg self.log(self.msg, "ERROR") @@ -2739,10 +2880,12 @@ def delete_itsm_integration_setting(self, itsm_name, itsm_id): op_modifies=True, params={"instance_id": itsm_id} ) - self.log("Received API response from 'delete_itsm_integration_setting': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'delete_itsm_integration_setting': {0}".format( + str(response)), "DEBUG") if "successfully" in response: - self.msg = "ITSM Integration settings instance with name '{0}' deleted successfully from Cisco Catalyst Center".format(itsm_name) + self.msg = "ITSM Integration settings instance with name '{0}' deleted successfully from Cisco Catalyst Center".format( + itsm_name) self.status = "success" self.log(self.msg, "INFO") self.result['changed'] = True @@ -2750,13 +2893,15 @@ def delete_itsm_integration_setting(self, itsm_name, itsm_id): return self self.status = "failed" - self.msg = "Cannot delete ITSM Integration settings instance with name '{0}' from Cisco Catalyst Center".format(itsm_name) + self.msg = "Cannot delete ITSM Integration settings instance with name '{0}' from Cisco Catalyst Center".format( + itsm_name) self.log(self.msg, "ERROR") self.result['response'] = self.msg except Exception as e: self.status = "failed" - self.msg = "Error while deleting ITSM Integration Setting with name '{0}' from Cisco Catalyst Center due to: {1}".format(itsm_name, str(e)) + self.msg = "Error while deleting ITSM Integration Setting with name '{0}' from Cisco Catalyst Center due to: {1}".format( + itsm_name, str(e)) self.log(self.msg, "ERROR") return self @@ -2783,10 +2928,12 @@ def get_syslog_notification_details(self, name): op_modifies=True, params={"name": name} ) - self.log("Received API response from 'get_syslog_event_subscriptions': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_syslog_event_subscriptions': {0}".format( + str(response)), "DEBUG") if not response: - self.log("There is no Syslog Event Notification with given name '{0}' present in Cisco Catalyst Center.".format(name), "INFO") + self.log("There is no Syslog Event Notification with given name '{0}' present in Cisco Catalyst Center.".format( + name), "INFO") return response return response @@ -2801,7 +2948,8 @@ def get_syslog_notification_details(self, name): if msg in str(e): self.log( "An exception occurred while checking for the Syslog Event Notification with the name '{0}'. " - "It was not found in Cisco Catalyst Center.".format(name), "WARNING" + "It was not found in Cisco Catalyst Center.".format( + name), "WARNING" ) return None @@ -2837,10 +2985,12 @@ def get_syslog_subscription_detail(self, destination): op_modifies=True, params={"name": destination} ) - self.log("Received API response from 'get_syslog_subscription_details': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_syslog_subscription_details': {0}".format( + str(response)), "DEBUG") if not response: - self.log("Syslog destination with the name '{0}' not found in Cisco Catalyst Center.".format(destination), "INFO") + self.log("Syslog destination with the name '{0}' not found in Cisco Catalyst Center.".format( + destination), "INFO") return response return response[0] @@ -2855,7 +3005,8 @@ def get_syslog_subscription_detail(self, destination): if msg in str(e): self.log( "An exception occurred while checking for the Syslog destination with the name '{0}'. " - "It was not found in Cisco Catalyst Center.".format(destination), "WARNING" + "It was not found in Cisco Catalyst Center.".format( + destination), "WARNING" ) return None @@ -2882,12 +3033,14 @@ def is_valid_event_types(self, event_types): and logs an error message. The function returns the instance itself to allow for method chaining. """ - defined_types = ["SECURITY", "APP", "NETWORK", "SYSTEM", "AUDIT_LOG", "INTEGRATIONS"] + defined_types = ["SECURITY", "APP", "NETWORK", + "SYSTEM", "AUDIT_LOG", "INTEGRATIONS"] invalid_event_types = [] if not isinstance(event_types, list): self.status = "failed" - self.msg = "Given event types '{0}' should be a list of strings.".format(event_types) + self.msg = "Given event types '{0}' should be a list of strings.".format( + event_types) self.log(self.msg, "ERROR") self.result['response'] = self.msg return self @@ -2923,12 +3076,14 @@ def is_valid_event_categories(self, event_categories): sets an appropriate error message. It also logs the error message. """ - categories = ["TASK_FAILURE", "TASK_COMPLETE", "WARN", "TASK_PROGRESS", "QUERY", "COMMAND", "ALERT", "INFO", "CONVERSATION", "ERROR"] + categories = ["TASK_FAILURE", "TASK_COMPLETE", "WARN", "TASK_PROGRESS", + "QUERY", "COMMAND", "ALERT", "INFO", "CONVERSATION", "ERROR"] invalid_event_categories = [] if not isinstance(event_categories, list): self.status = "failed" - self.msg = "Given event categories '{0}' should be a list of strings.".format(event_categories) + self.msg = "Given event categories '{0}' should be a list of strings.".format( + event_categories) self.log(self.msg, "ERROR") self.result['response'] = self.msg return self @@ -2968,7 +3123,8 @@ def is_valid_event_severities(self, event_severities): if not isinstance(event_severities, list): self.status = "failed" - self.msg = "Given event severities '{0}' should be a list of strings.".format(event_severities) + self.msg = "Given event severities '{0}' should be a list of strings.".format( + event_severities) self.log(self.msg, "ERROR") self.result['response'] = self.msg return self @@ -2986,7 +3142,8 @@ def is_valid_event_severities(self, event_severities): self.msg = ( "Invalid event severity/severities provided in the playbook: {0}. " "Unable to create or update event subscription notifications in Cisco Catalyst Center. " - "Severity levels must be integers within the range 1 to 5.".format(invalid_event_severities) + "Severity levels must be integers within the range 1 to 5.".format( + invalid_event_severities) ) self.log(self.msg, "ERROR") self.result['response'] = self.msg @@ -3019,10 +3176,12 @@ def get_event_ids(self, events): op_modifies=True, params={"search": event_name} ) - self.log("Received API response from 'get_eventartifacts': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_eventartifacts': {0}".format( + str(response)), "DEBUG") if not response: - self.log("There is no Event with name '{0}' present in Cisco Catalyst Center.".format(event_name), "INFO") + self.log("There is no Event with name '{0}' present in Cisco Catalyst Center.".format( + event_name), "INFO") continue response = response[0] @@ -3063,14 +3222,17 @@ def get_site_ids(self, sites): op_modifies=True, params={"name": site}, ) - self.log("Received API response from 'get_site': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_site': {0}".format( + str(response)), "DEBUG") response = response.get('response') if not response: - self.log("No site with the name '{0}' found in Cisco Catalyst Center.".format(site), "INFO") + self.log("No site with the name '{0}' found in Cisco Catalyst Center.".format( + site), "INFO") continue site_id = response[0].get("id") if not site_id: - self.log("Site '{0}' found, but no ID available in the response.".format(site), "WARNING") + self.log("Site '{0}' found, but no ID available in the response.".format( + site), "WARNING") continue site_ids.append(site_id) @@ -3108,11 +3270,13 @@ def collect_syslog_notification_playbook_params(self, syslog_notification_detail } # Collect the Instance ID of the syslog destination - self.log("Collecting parameters for Syslog Event Notification named '{0}'.".format(name), "INFO") + self.log("Collecting parameters for Syslog Event Notification named '{0}'.".format( + name), "INFO") destination = syslog_notification_details.get('destination') if destination: - subscription_details = self.get_syslog_subscription_detail(destination) + subscription_details = self.get_syslog_subscription_detail( + destination) if not subscription_details: self.status = "failed" @@ -3130,7 +3294,8 @@ def collect_syslog_notification_playbook_params(self, syslog_notification_detail "connectorType": connector_type } } - playbook_params["subscriptionEndpoints"].append(temp_subscript_endpoint) + playbook_params["subscriptionEndpoints"].append( + temp_subscript_endpoint) events = syslog_notification_details.get('events') if events: @@ -3158,7 +3323,8 @@ def collect_syslog_notification_playbook_params(self, syslog_notification_detail playbook_params["filter"]["domainsSubdomains"].append(domain_dict) # Add other filter parameters if present - filter_keys = ["event_types", "event_categories", "event_severities", "event_sources"] + filter_keys = ["event_types", "event_categories", + "event_severities", "event_sources"] filter_mapping = { "event_types": "types", "event_categories": "categories", @@ -3167,13 +3333,16 @@ def collect_syslog_notification_playbook_params(self, syslog_notification_detail } if syslog_notification_details.get("event_types"): - self.is_valid_event_types(syslog_notification_details.get("event_types")).check_return_status() + self.is_valid_event_types(syslog_notification_details.get( + "event_types")).check_return_status() if syslog_notification_details.get("event_categories"): - self.is_valid_event_categories(syslog_notification_details.get("event_categories")).check_return_status() + self.is_valid_event_categories(syslog_notification_details.get( + "event_categories")).check_return_status() if syslog_notification_details.get("event_severities"): - self.is_valid_event_severities(syslog_notification_details.get("event_severities")).check_return_status() + self.is_valid_event_severities(syslog_notification_details.get( + "event_severities")).check_return_status() for key in filter_keys: value = syslog_notification_details.get(key) @@ -3192,7 +3361,8 @@ def collect_syslog_notification_playbook_params(self, syslog_notification_detail playbook_params["filter"]["siteIds"] = site_ids syslog_notification_params.append(playbook_params) - self.log("Syslog notification playbook parameters collected successfully for '{0}': {1}".format(name, playbook_params), "INFO") + self.log("Syslog notification playbook parameters collected successfully for '{0}': {1}".format( + name, playbook_params), "INFO") return syslog_notification_params @@ -3221,7 +3391,8 @@ def mandatory_syslog_notification_parameter_check(self, syslog_notification_para if not description: required_params_absent.append("description") - subs_endpoints = syslog_notification_params.get('subscriptionEndpoints') + subs_endpoints = syslog_notification_params.get( + 'subscriptionEndpoints') if not subs_endpoints: required_params_absent.append("destination") @@ -3262,7 +3433,8 @@ def create_syslog_notification(self, syslog_notification_params): try: notification_name = syslog_notification_params[0].get('name') - self.log("Requested payload for create_syslog_event_subscription - {0}".format(str(syslog_notification_params)), "INFO") + self.log("Requested payload for create_syslog_event_subscription - {0}".format( + str(syslog_notification_params)), "INFO") response = self.dnac._exec( family="event_management", function='create_syslog_event_subscription', @@ -3270,7 +3442,8 @@ def create_syslog_notification(self, syslog_notification_params): params={'payload': syslog_notification_params} ) time.sleep(1) - self.log("Received API response from 'create_syslog_event_subscription': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'create_syslog_event_subscription': {0}".format( + str(response)), "DEBUG") status = response.get('statusUri') status_execution_id = status.split("/")[-1] status_response = self.check_status_api_events(status_execution_id) @@ -3278,7 +3451,8 @@ def create_syslog_notification(self, syslog_notification_params): if status_response['apiStatus'] == "SUCCESS": self.status = "success" self.result['changed'] = True - self.msg = "Syslog Event Notification '{0}' created successfully in Cisco Catalyst Center".format(notification_name) + self.msg = "Syslog Event Notification '{0}' created successfully in Cisco Catalyst Center".format( + notification_name) self.log(self.msg, "INFO") self.create_notification.append(notification_name) return self @@ -3289,7 +3463,8 @@ def create_syslog_notification(self, syslog_notification_params): if error_messages: self.msg = error_messages.get('errors') else: - self.msg = "Unable to add Syslog Event Notification '{0}' in Cisco Catalyst Center.".format(notification_name) + self.msg = "Unable to add Syslog Event Notification '{0}' in Cisco Catalyst Center.".format( + notification_name) self.log(self.msg, "ERROR") self.result['response'] = self.msg @@ -3342,27 +3517,33 @@ def compare_notification_filters(self, filters_in_playbook, filters_in_ccc): for key, value in filters_in_playbook.items(): if key == "domainsSubdomains": - domain_subdomain_input = filters_in_playbook.get("domainsSubdomains") - domain_subdomain_in_ccc = filters_in_ccc.get("domainsSubdomains") + domain_subdomain_input = filters_in_playbook.get( + "domainsSubdomains") + domain_subdomain_in_ccc = filters_in_ccc.get( + "domainsSubdomains") if domain_subdomain_input: # Ensure that there is input for 'domainsSubdomains' domain_input = domain_subdomain_input[0].get("domain") - subdomains_input = domain_subdomain_input[0].get("subDomains") + subdomains_input = domain_subdomain_input[0].get( + "subDomains") else: domain_input = subdomains_input = None if not domain_subdomain_in_ccc: - self.log("Since no domain or subdomains are present in Catalyst Center, the notification needs an update.", "INFO") + self.log( + "Since no domain or subdomains are present in Catalyst Center, the notification needs an update.", "INFO") return True domain_in_ccc = domain_subdomain_in_ccc.get("domain") subdomain_in_ccc = domain_subdomain_in_ccc.get("subDomains") if domain_input and domain_input != domain_in_ccc: - self.log("Domain '{0}' given in the playbook does not match with domain in Cisco Catalyst Center".format(domain_input), "INFO") + self.log("Domain '{0}' given in the playbook does not match with domain in Cisco Catalyst Center".format( + domain_input), "INFO") return True if subdomains_input: - list_needs_update = self.is_element_missing(subdomains_input, subdomain_in_ccc) + list_needs_update = self.is_element_missing( + subdomains_input, subdomain_in_ccc) if list_needs_update: self.log(("Given subdomain_names '{0}' in the playbook do not match with the values present in " "Cisco Catalyst Center, so the notification needs an update.").format(subdomains_input), "INFO") @@ -3372,9 +3553,11 @@ def compare_notification_filters(self, filters_in_playbook, filters_in_ccc): severity_list = [] for item in value: severity_list.append(int(item)) - list_needs_update = self.is_element_missing(severity_list, filters_in_ccc[key]) + list_needs_update = self.is_element_missing( + severity_list, filters_in_ccc[key]) else: - list_needs_update = self.is_element_missing(value, filters_in_ccc[key]) + list_needs_update = self.is_element_missing( + value, filters_in_ccc[key]) if list_needs_update: self.log(("Parameter '{0}' given in the playbook does not match with the value present in Cisco Catalyst " @@ -3404,8 +3587,10 @@ def syslog_notification_needs_update(self, syslog_notification_params, syslog_no name = syslog_notification_params.get("name") description_in_playbook = syslog_notification_params.get("description") description_in_ccc = syslog_notification_in_ccc.get("description") - subs_endpoints = syslog_notification_params.get("subscriptionEndpoints") - ccc_endpoints = syslog_notification_in_ccc.get("subscriptionEndpoints")[0] + subs_endpoints = syslog_notification_params.get( + "subscriptionEndpoints") + ccc_endpoints = syslog_notification_in_ccc.get( + "subscriptionEndpoints")[0] if description_in_playbook and description_in_playbook != description_in_ccc: self.log("Parameter 'description' does not match with the value of description present in Cisco Catalyst Center " @@ -3447,11 +3632,13 @@ def collect_notification_filter_params(self, playbook_params, filter, ccc_filter with the filter parameters from Cisco Catalyst Center. """ - filter_keys = ["eventIds", "domainsSubdomains", "types", "categories", "severities", "sources", "siteIds"] + filter_keys = ["eventIds", "domainsSubdomains", "types", + "categories", "severities", "sources", "siteIds"] if filter: for key in filter_keys: - playbook_params["filter"][key] = filter.get(key) or ccc_filter.get(key) + playbook_params["filter"][key] = filter.get( + key) or ccc_filter.get(key) else: # Need to take all required/optional parameter from Cisco Catalyst Center for key in filter_keys: @@ -3487,13 +3674,15 @@ def update_syslog_notification(self, syslog_notification_params, syslog_notifica "version": syslog_notification_params.get("version") or syslog_notification_in_ccc.get("version"), "filter": {} } - subs_endpoints = syslog_notification_params.get("subscriptionEndpoints") + subs_endpoints = syslog_notification_params.get( + "subscriptionEndpoints") if subs_endpoints: playbook_params["subscriptionEndpoints"] = subs_endpoints else: playbook_params["subscriptionEndpoints"] = [] - instance_id = syslog_notification_in_ccc.get("subscriptionEndpoints")[0].get("instanceId") + instance_id = syslog_notification_in_ccc.get( + "subscriptionEndpoints")[0].get("instanceId") playbook_params["subscriptionEndpoints"] = [{ "instanceId": instance_id, "subscriptionDetails": { @@ -3503,11 +3692,13 @@ def update_syslog_notification(self, syslog_notification_params, syslog_notifica filter = syslog_notification_params.get("filter") ccc_filter = syslog_notification_in_ccc.get("filter") - notification_params = self.collect_notification_filter_params(playbook_params, filter, ccc_filter) + notification_params = self.collect_notification_filter_params( + playbook_params, filter, ccc_filter) sys_notification_update_params.append(notification_params) try: - self.log("Requested payload for update_syslog_event_subscription - {0}".format(str(sys_notification_update_params)), "INFO") + self.log("Requested payload for update_syslog_event_subscription - {0}".format( + str(sys_notification_update_params)), "INFO") response = self.dnac._exec( family="event_management", function='update_syslog_event_subscription', @@ -3515,7 +3706,8 @@ def update_syslog_notification(self, syslog_notification_params, syslog_notifica params={'payload': sys_notification_update_params} ) time.sleep(1) - self.log("Received API response from 'update_syslog_event_subscription': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'update_syslog_event_subscription': {0}".format( + str(response)), "DEBUG") status = response.get('statusUri') status_execution_id = status.split("/")[-1] status_response = self.check_status_api_events(status_execution_id) @@ -3523,7 +3715,8 @@ def update_syslog_notification(self, syslog_notification_params, syslog_notifica if status_response['apiStatus'] == "SUCCESS": self.status = "success" self.result['changed'] = True - self.msg = "Syslog Event Notification '{0}' updated successfully in Cisco Catalyst Center".format(name) + self.msg = "Syslog Event Notification '{0}' updated successfully in Cisco Catalyst Center".format( + name) self.log(self.msg, "INFO") self.update_notification.append(name) return self @@ -3534,14 +3727,16 @@ def update_syslog_notification(self, syslog_notification_params, syslog_notifica if error_messages: self.msg = error_messages.get('errors') else: - self.msg = "Unable to update Syslog Event Notification '{0}' in Cisco Catalyst Center.".format(name) + self.msg = "Unable to update Syslog Event Notification '{0}' in Cisco Catalyst Center.".format( + name) self.log(self.msg, "ERROR") self.result['response'] = self.msg except Exception as e: self.status = "failed" - self.msg = "Error while updating the Syslog Event Notification with name '{0}' in Cisco Catalyst Center: {1}".format(name, str(e)) + self.msg = "Error while updating the Syslog Event Notification with name '{0}' in Cisco Catalyst Center: {1}".format( + name, str(e)) self.log(self.msg, "ERROR") return self @@ -3568,10 +3763,12 @@ def get_webhook_notification_details(self, name): op_modifies=True, params={"name": name} ) - self.log("Received API response from 'get_rest_webhook_event_subscriptions': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_rest_webhook_event_subscriptions': {0}".format( + str(response)), "DEBUG") if not response: - self.log("There is no Webhook Event Notification with given name '{0}' present in Cisco Catalyst Center.".format(name), "INFO") + self.log("There is no Webhook Event Notification with given name '{0}' present in Cisco Catalyst Center.".format( + name), "INFO") return response return response @@ -3586,12 +3783,14 @@ def get_webhook_notification_details(self, name): if msg in str(e): self.log( "An exception occurred while checking for the Webhook Event Notification with the name '{0}'. " - "It was not found in Cisco Catalyst Center.".format(name), "WARNING" + "It was not found in Cisco Catalyst Center.".format( + name), "WARNING" ) return None self.status = "failed" - self.log("Error while retrieving Webhook Event Notification details: {0}".format(str(e)), "ERROR") + self.log("Error while retrieving Webhook Event Notification details: {0}".format( + str(e)), "ERROR") self.log(self.msg, "ERROR") self.check_return_status() @@ -3618,9 +3817,11 @@ def get_webhook_subscription_detail(self, destination): op_modifies=True, params={"name": destination} ) - self.log("Received API response from 'get_rest_webhook_subscription_details': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_rest_webhook_subscription_details': {0}".format( + str(response)), "DEBUG") if not response: - self.log("Webhook destination with the name '{0}' not found in Cisco Catalyst Center.".format(destination), "INFO") + self.log("Webhook destination with the name '{0}' not found in Cisco Catalyst Center.".format( + destination), "INFO") return response return response[0] @@ -3635,7 +3836,8 @@ def get_webhook_subscription_detail(self, destination): if msg in str(e): self.log( "An exception occurred while checking for the Webhook destination with the name '{0}'. " - "It was not found in Cisco Catalyst Center.".format(destination), "WARNING" + "It was not found in Cisco Catalyst Center.".format( + destination), "WARNING" ) return None @@ -3672,11 +3874,13 @@ def collect_webhook_notification_playbook_params(self, webhook_notification_deta } # Collect the Instance ID of the webhook destination - self.log("Collecting parameters for Webhook Event Notification named '{0}'.".format(name), "INFO") + self.log("Collecting parameters for Webhook Event Notification named '{0}'.".format( + name), "INFO") destination = webhook_notification_details.get('destination') if destination: - subscription_details = self.get_webhook_subscription_detail(destination) + subscription_details = self.get_webhook_subscription_detail( + destination) if not subscription_details: self.status = "failed" @@ -3694,7 +3898,8 @@ def collect_webhook_notification_playbook_params(self, webhook_notification_deta "connectorType": connector_type } } - playbook_params["subscriptionEndpoints"].append(temp_subscript_endpoint) + playbook_params["subscriptionEndpoints"].append( + temp_subscript_endpoint) events = webhook_notification_details.get('events') if events: @@ -3722,7 +3927,8 @@ def collect_webhook_notification_playbook_params(self, webhook_notification_deta playbook_params["filter"]["domainsSubdomains"].append(domain_dict) # Add other filter parameters if present - filter_keys = ["event_types", "event_categories", "event_severities", "event_sources"] + filter_keys = ["event_types", "event_categories", + "event_severities", "event_sources"] filter_mapping = { "event_types": "types", "event_categories": "categories", @@ -3731,13 +3937,16 @@ def collect_webhook_notification_playbook_params(self, webhook_notification_deta } if webhook_notification_details.get("event_types"): - self.is_valid_event_types(webhook_notification_details.get("event_types")).check_return_status() + self.is_valid_event_types(webhook_notification_details.get( + "event_types")).check_return_status() if webhook_notification_details.get("event_categories"): - self.is_valid_event_categories(webhook_notification_details.get("event_categories")).check_return_status() + self.is_valid_event_categories(webhook_notification_details.get( + "event_categories")).check_return_status() if webhook_notification_details.get("event_severities"): - self.is_valid_event_severities(webhook_notification_details.get("event_severities")).check_return_status() + self.is_valid_event_severities(webhook_notification_details.get( + "event_severities")).check_return_status() for key in filter_keys: value = webhook_notification_details.get(key) @@ -3755,9 +3964,11 @@ def collect_webhook_notification_playbook_params(self, webhook_notification_deta self.log(site_msg, "INFO") playbook_params["filter"]["siteIds"] = site_ids - self.log("Site IDs '{0}' found for site names '{1}'. Added to filter.".format(site_ids, sites), "INFO") + self.log("Site IDs '{0}' found for site names '{1}'. Added to filter.".format( + site_ids, sites), "INFO") - self.log("Webhook notification playbook parameters collected successfully for '{0}': {1}".format(name, playbook_params), "INFO") + self.log("Webhook notification playbook parameters collected successfully for '{0}': {1}".format( + name, playbook_params), "INFO") webhook_notification_params.append(playbook_params) return webhook_notification_params @@ -3828,7 +4039,8 @@ def create_webhook_notification(self, webhook_notification_params): try: notification_name = webhook_notification_params[0].get('name') - self.log("Requested payload for create_rest_webhook_event_subscription - {0}".format(str(webhook_notification_params)), "INFO") + self.log("Requested payload for create_rest_webhook_event_subscription - {0}".format( + str(webhook_notification_params)), "INFO") response = self.dnac._exec( family="event_management", function='create_rest_webhook_event_subscription', @@ -3836,7 +4048,8 @@ def create_webhook_notification(self, webhook_notification_params): params={'payload': webhook_notification_params} ) time.sleep(1) - self.log("Received API response from 'create_rest_webhook_event_subscription': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'create_rest_webhook_event_subscription': {0}".format( + str(response)), "DEBUG") status = response.get('statusUri') status_execution_id = status.split("/")[-1] status_response = self.check_status_api_events(status_execution_id) @@ -3844,7 +4057,8 @@ def create_webhook_notification(self, webhook_notification_params): if status_response['apiStatus'] == "SUCCESS": self.status = "success" self.result['changed'] = True - self.msg = "Webhook Event Subscription Notification '{0}' created successfully in Cisco Catalyst Center".format(notification_name) + self.msg = "Webhook Event Subscription Notification '{0}' created successfully in Cisco Catalyst Center".format( + notification_name) self.log(self.msg, "INFO") self.create_notification.append(notification_name) return self @@ -3855,14 +4069,16 @@ def create_webhook_notification(self, webhook_notification_params): if error_messages: self.msg = error_messages.get('errors') else: - self.msg = "Unable to add Webhook Events Subscription Notification '{0}' in Cisco Catalyst Center.".format(notification_name) + self.msg = "Unable to add Webhook Events Subscription Notification '{0}' in Cisco Catalyst Center.".format( + notification_name) self.log(self.msg, "ERROR") self.result['response'] = self.msg except Exception as e: self.status = "failed" - self.msg = "Error while adding the webhook Event Notification with name '{0}' in Cisco Catalyst Center: {1}".format(notification_name, str(e)) + self.msg = "Error while adding the webhook Event Notification with name '{0}' in Cisco Catalyst Center: {1}".format( + notification_name, str(e)) self.log(self.msg, "ERROR") return self @@ -3889,7 +4105,8 @@ def webhook_notification_needs_update(self, webhook_notification_params, webhook description_in_playbook = webhook_params.get("description") description_in_ccc = webhook_notification_in_ccc.get("description") subs_endpoints = webhook_params.get("subscriptionEndpoints") - ccc_endpoints = webhook_notification_in_ccc.get("subscriptionEndpoints")[0] + ccc_endpoints = webhook_notification_in_ccc.get( + "subscriptionEndpoints")[0] if description_in_playbook and description_in_playbook != description_in_ccc: self.log("Parameter 'description' does not match with the value of description present in Cisco Catalyst Center " @@ -3947,22 +4164,26 @@ def update_webhook_notification(self, webhook_notification_params, webhook_notif playbook_params["subscriptionEndpoints"] = subs_endpoints else: playbook_params["subscriptionEndpoints"] = [] - instance_id = webhook_notification_in_ccc.get("subscriptionEndpoints")[0].get("instanceId") + instance_id = webhook_notification_in_ccc.get( + "subscriptionEndpoints")[0].get("instanceId") temp_subscript_endpoint = { "instanceId": instance_id, "subscriptionDetails": { "connectorType": "REST" } } - playbook_params['subscriptionEndpoints'].append(temp_subscript_endpoint) + playbook_params['subscriptionEndpoints'].append( + temp_subscript_endpoint) filter = webhook_params.get("filter") ccc_filter = webhook_notification_in_ccc.get("filter") - webhook_update_params = self.collect_notification_filter_params(playbook_params, filter, ccc_filter) + webhook_update_params = self.collect_notification_filter_params( + playbook_params, filter, ccc_filter) web_notification_update_params.append(webhook_update_params) try: - self.log("Requested payload for update_rest_webhook_event_subscription - {0}".format(str(web_notification_update_params)), "INFO") + self.log("Requested payload for update_rest_webhook_event_subscription - {0}".format( + str(web_notification_update_params)), "INFO") response = self.dnac._exec( family="event_management", function='update_rest_webhook_event_subscription', @@ -3970,7 +4191,8 @@ def update_webhook_notification(self, webhook_notification_params, webhook_notif params={'payload': web_notification_update_params} ) time.sleep(1) - self.log("Received API response from 'update_rest_webhook_event_subscription': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'update_rest_webhook_event_subscription': {0}".format( + str(response)), "DEBUG") status = response.get('statusUri') status_execution_id = status.split("/")[-1] status_response = self.check_status_api_events(status_execution_id) @@ -3978,7 +4200,8 @@ def update_webhook_notification(self, webhook_notification_params, webhook_notif if status_response['apiStatus'] == "SUCCESS": self.status = "success" self.result['changed'] = True - self.msg = "Webhook Event Subscription Notification '{0}' updated successfully in Cisco Catalyst Center".format(name) + self.msg = "Webhook Event Subscription Notification '{0}' updated successfully in Cisco Catalyst Center".format( + name) self.log(self.msg, "INFO") self.update_notification.append(name) return self @@ -3989,14 +4212,16 @@ def update_webhook_notification(self, webhook_notification_params, webhook_notif if error_messages: self.msg = error_messages.get('errors') else: - self.msg = "Unable to update webhook Event Subscription Notification '{0}' in Cisco Catalyst Center.".format(name) + self.msg = "Unable to update webhook Event Subscription Notification '{0}' in Cisco Catalyst Center.".format( + name) self.log(self.msg, "ERROR") self.result['response'] = self.msg except Exception as e: self.status = "failed" - self.msg = "Exception occurred while updating Webhook Notification with name '{0}': {1}.".format(name, str(e)) + self.msg = "Exception occurred while updating Webhook Notification with name '{0}': {1}.".format( + name, str(e)) self.log(self.msg, "ERROR") return self @@ -4023,10 +4248,12 @@ def get_email_notification_details(self, name): op_modifies=True, params={"name": name} ) - self.log("Received API response from 'get_email_event_subscriptions': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_email_event_subscriptions': {0}".format( + str(response)), "DEBUG") if not response: - self.log("There is no Email Event Notification with given name '{0}' present in Cisco Catalyst Center.".format(name), "INFO") + self.log("There is no Email Event Notification with given name '{0}' present in Cisco Catalyst Center.".format( + name), "INFO") return response return response @@ -4041,11 +4268,13 @@ def get_email_notification_details(self, name): if msg in str(e): self.log( "An exception occurred while checking for the Email Event Notification with the name '{0}'. " - "It was not found in Cisco Catalyst Center.".format(name), "WARNING" + "It was not found in Cisco Catalyst Center.".format( + name), "WARNING" ) return None - self.msg = "Exception occurred while retrieving Email Event Subscription Notification: {0}".format(str(e)) + self.msg = "Exception occurred while retrieving Email Event Subscription Notification: {0}".format( + str(e)) self.log(self.msg, "ERROR") self.check_return_status() @@ -4072,11 +4301,13 @@ def get_email_subscription_detail(self, instance): op_modifies=True, params={"name": instance} ) - self.log("Received API response from 'get_email_subscription_details': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_email_subscription_details': {0}".format( + str(response)), "DEBUG") email_destination_details = None if not response: - self.log("Email instance with given name '{0}' present in Cisco Catalyst Center.".format(instance), "INFO") + self.log("Email instance with given name '{0}' present in Cisco Catalyst Center.".format( + instance), "INFO") return response return response[0] @@ -4091,7 +4322,8 @@ def get_email_subscription_detail(self, instance): if msg in str(e): self.log( "An exception occurred while checking for the Email instance with the name '{0}'. " - "It was not found in Cisco Catalyst Center.".format(instance), "WARNING" + "It was not found in Cisco Catalyst Center.".format( + instance), "WARNING" ) return None @@ -4128,12 +4360,14 @@ def collect_email_notification_playbook_params(self, email_notification_details) } # Collect the Instance ID of the email destination - self.log("Collecting parameters for Email Event Notification named '{0}'.".format(email_notf_name), "INFO") + self.log("Collecting parameters for Email Event Notification named '{0}'.".format( + email_notf_name), "INFO") instance = email_notification_details.get('instance') if not instance: self.status = "failed" - self.msg = "Instance name for Subscription Endpoints is required for Email notification '{0}'.".format(email_notf_name) + self.msg = "Instance name for Subscription Endpoints is required for Email notification '{0}'.".format( + email_notf_name) self.log(self.msg, "ERROR") self.result['response'] = self.msg self.check_return_status() @@ -4143,15 +4377,21 @@ def collect_email_notification_playbook_params(self, email_notification_details) if not subscription_details: instance_id = None sender_email = email_notification_details.get("sender_email") - recipient_emails = email_notification_details.get("recipient_emails") + recipient_emails = email_notification_details.get( + "recipient_emails") subject = email_notification_details.get("subject") - description = email_notification_details.get("instance_description") + description = email_notification_details.get( + "instance_description") else: instance_id = subscription_details.get("instanceId") - sender_email = email_notification_details.get("sender_email") or subscription_details.get("fromEmailAddress") - recipient_emails = email_notification_details.get("recipient_emails") or subscription_details.get("toEmailAddresses") - subject = email_notification_details.get("subject") or subscription_details.get("subject") - description = email_notification_details.get("instance_description") or subscription_details.get("description") + sender_email = email_notification_details.get( + "sender_email") or subscription_details.get("fromEmailAddress") + recipient_emails = email_notification_details.get( + "recipient_emails") or subscription_details.get("toEmailAddresses") + subject = email_notification_details.get( + "subject") or subscription_details.get("subject") + description = email_notification_details.get( + "instance_description") or subscription_details.get("description") if not sender_email: self.status = "failed" @@ -4215,7 +4455,8 @@ def collect_email_notification_playbook_params(self, email_notification_details) "description": description } } - playbook_params["subscriptionEndpoints"].append(temp_subscript_endpoint) + playbook_params["subscriptionEndpoints"].append( + temp_subscript_endpoint) events = email_notification_details.get('events') if events: @@ -4243,7 +4484,8 @@ def collect_email_notification_playbook_params(self, email_notification_details) playbook_params["filter"]["domainsSubdomains"].append(domain_dict) # Add other filter parameters if present - filter_keys = ["event_types", "event_categories", "event_severities", "event_sources"] + filter_keys = ["event_types", "event_categories", + "event_severities", "event_sources"] filter_mapping = { "event_types": "types", "event_categories": "categories", @@ -4252,13 +4494,16 @@ def collect_email_notification_playbook_params(self, email_notification_details) } if email_notification_details.get("event_types"): - self.is_valid_event_types(email_notification_details.get("event_types")).check_return_status() + self.is_valid_event_types(email_notification_details.get( + "event_types")).check_return_status() if email_notification_details.get("event_categories"): - self.is_valid_event_categories(email_notification_details.get("event_categories")).check_return_status() + self.is_valid_event_categories(email_notification_details.get( + "event_categories")).check_return_status() if email_notification_details.get("event_severities"): - self.is_valid_event_severities(email_notification_details.get("event_severities")).check_return_status() + self.is_valid_event_severities(email_notification_details.get( + "event_severities")).check_return_status() for key in filter_keys: value = email_notification_details.get(key) @@ -4317,11 +4562,13 @@ def mandatory_email_notification_parameter_check(self, email_notification_params if required_params_absent: self.status = "failed" missing_params = ", ".join(required_params_absent) - self.msg = "Missing required parameters [{0}] for adding Email Events Subscription Notification '{1}'.".format(missing_params, notification_name) + self.msg = "Missing required parameters [{0}] for adding Email Events Subscription Notification '{1}'.".format( + missing_params, notification_name) self.log(self.msg, "ERROR") self.result['response'] = self.msg self.check_return_status() - self.log("All mandatory parameters for Email Event Subscription Notification are present.", "INFO") + self.log( + "All mandatory parameters for Email Event Subscription Notification are present.", "INFO") return self @@ -4346,7 +4593,8 @@ def create_email_notification(self, email_notification_params): try: notification_name = email_notification_params[0].get('name') - self.log("Requested payload for create_email_event_subscription - {0}".format(str(email_notification_params)), "INFO") + self.log("Requested payload for create_email_event_subscription - {0}".format( + str(email_notification_params)), "INFO") response = self.dnac._exec( family="event_management", function='create_email_event_subscription', @@ -4354,7 +4602,8 @@ def create_email_notification(self, email_notification_params): params={'payload': email_notification_params} ) time.sleep(1) - self.log("Received API response from 'create_email_event_subscription': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'create_email_event_subscription': {0}".format( + str(response)), "DEBUG") status = response.get('statusUri') status_execution_id = status.split("/")[-1] status_response = self.check_status_api_events(status_execution_id) @@ -4362,7 +4611,8 @@ def create_email_notification(self, email_notification_params): if status_response['apiStatus'] == "SUCCESS": self.status = "success" self.result['changed'] = True - self.msg = "Email Event Subscription Notification '{0}' created successfully in Cisco Catalyst Center".format(notification_name) + self.msg = "Email Event Subscription Notification '{0}' created successfully in Cisco Catalyst Center".format( + notification_name) self.log(self.msg, "INFO") self.create_notification.append(notification_name) return self @@ -4373,14 +4623,16 @@ def create_email_notification(self, email_notification_params): if error_messages: self.msg = error_messages.get('errors') else: - self.msg = "Unable to add Email Events Subscription Notification '{0}' in Cisco Catalyst Center.".format(notification_name) + self.msg = "Unable to add Email Events Subscription Notification '{0}' in Cisco Catalyst Center.".format( + notification_name) self.log(self.msg, "ERROR") self.result['response'] = self.msg except Exception as e: self.status = "failed" - self.msg = "Error while adding the Email Event Notification with name '{0}' in Cisco Catalyst Center: {1}".format(notification_name, str(e)) + self.msg = "Error while adding the Email Event Notification with name '{0}' in Cisco Catalyst Center: {1}".format( + notification_name, str(e)) self.log(self.msg, "ERROR") return self @@ -4400,7 +4652,8 @@ def compare_email_subs_endpoints(self, subs_endpoints, ccc_endpoints): that the subscription endpoints need to be updated. If all parameters match, the function returns False. """ - params_to_compare = ["fromEmailAddress", "toEmailAddresses", "subject", "name", "description"] + params_to_compare = ["fromEmailAddress", + "toEmailAddresses", "subject", "name", "description"] subs_endpoints = subs_endpoints.get("subscriptionDetails") ccc_endpoints = ccc_endpoints.get("subscriptionDetails") @@ -4408,7 +4661,8 @@ def compare_email_subs_endpoints(self, subs_endpoints, ccc_endpoints): playbook_param = subs_endpoints.get(param) if isinstance(playbook_param, list): ccc_list_param = ccc_endpoints.get(param) - list_needs_update = self.is_element_missing(playbook_param, ccc_list_param) + list_needs_update = self.is_element_missing( + playbook_param, ccc_list_param) if list_needs_update: self.log("""Parameter '{0}' given in the playbook does not match with the value present in Cisco Catalyst Center @@ -4441,7 +4695,8 @@ def email_notification_needs_update(self, email_notification_params, email_notif description_in_playbook = email_notification_params.get("description") description_in_ccc = email_notification_in_ccc.get("description") subs_endpoints = email_notification_params.get("subscriptionEndpoints") - ccc_endpoints = email_notification_in_ccc.get("subscriptionEndpoints")[0] + ccc_endpoints = email_notification_in_ccc.get( + "subscriptionEndpoints")[0] if description_in_playbook and description_in_playbook != description_in_ccc: self.log("Parameter 'description' does not match with the value of description present in Cisco Catalyst Center " @@ -4450,7 +4705,8 @@ def email_notification_needs_update(self, email_notification_params, email_notif if subs_endpoints: subs_endpoints = subs_endpoints[0] - notification_update = self.compare_email_subs_endpoints(subs_endpoints, ccc_endpoints) + notification_update = self.compare_email_subs_endpoints( + subs_endpoints, ccc_endpoints) if notification_update: self.log("Given Email Instance details in the playbook is different from email instance present in Cisco Catalyst " @@ -4497,7 +4753,8 @@ def update_email_notification(self, email_notification_params, email_notificatio "subscriptionEndpoints": [] } subs_endpoints = email_notification_params.get("subscriptionEndpoints") - subs_endpoints_in_ccc = email_notification_in_ccc.get("subscriptionEndpoints")[0] + subs_endpoints_in_ccc = email_notification_in_ccc.get( + "subscriptionEndpoints")[0] instance_id = subs_endpoints_in_ccc.get("instanceId") if subs_endpoints: @@ -4517,11 +4774,13 @@ def update_email_notification(self, email_notification_params, email_notificatio filter = email_notification_params.get("filter") ccc_filter = email_notification_in_ccc.get("filter") - email_update_params = self.collect_notification_filter_params(playbook_params, filter, ccc_filter) + email_update_params = self.collect_notification_filter_params( + playbook_params, filter, ccc_filter) notification_update_params.append(email_update_params) try: - self.log("Updating Email Event Notification '{0}' with following payload: {1}".format(name, str(notification_update_params)), "INFO") + self.log("Updating Email Event Notification '{0}' with following payload: {1}".format( + name, str(notification_update_params)), "INFO") response = self.dnac._exec( family="event_management", function='update_email_event_subscription', @@ -4529,7 +4788,8 @@ def update_email_notification(self, email_notification_params, email_notificatio params={'payload': notification_update_params} ) time.sleep(2) - self.log("Received API response from 'update_email_event_subscription': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'update_email_event_subscription': {0}".format( + str(response)), "DEBUG") status = response.get('statusUri') status_execution_id = status.split("/")[-1] status_response = self.check_status_api_events(status_execution_id) @@ -4537,7 +4797,8 @@ def update_email_notification(self, email_notification_params, email_notificatio if status_response['apiStatus'] == "SUCCESS": self.status = "success" self.result['changed'] = True - self.msg = "Email Event Subscription Notification '{0}' updated successfully in Cisco Catalyst Center".format(name) + self.msg = "Email Event Subscription Notification '{0}' updated successfully in Cisco Catalyst Center".format( + name) self.log(self.msg, "INFO") self.update_notification.append(name) return self @@ -4548,14 +4809,16 @@ def update_email_notification(self, email_notification_params, email_notificatio if error_messages: self.msg = error_messages.get('errors') else: - self.msg = "Unable to update Email Event Subscription Notification '{0}' in Cisco Catalyst Center.".format(name) + self.msg = "Unable to update Email Event Subscription Notification '{0}' in Cisco Catalyst Center.".format( + name) self.log(self.msg, "ERROR") self.result['response'] = self.msg except Exception as e: self.status = "failed" - self.msg = "An error occurred while updating Email Event Subscription Notification '{0}': {1}".format(name, str(e)) + self.msg = "An error occurred while updating Email Event Subscription Notification '{0}': {1}".format( + name, str(e)) self.log(self.msg, "ERROR") return self @@ -4585,7 +4848,8 @@ def delete_events_subscription_notification(self, subscription_id, subscription_ op_modifies=True, params={"subscriptions": subscription_id}, ) - self.log("Received API response from 'update_email_event_subscription': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'update_email_event_subscription': {0}".format( + str(response)), "DEBUG") status = response.get('statusUri') status_execution_id = status.split("/")[-1] status_response = self.check_status_api_events(status_execution_id) @@ -4593,7 +4857,8 @@ def delete_events_subscription_notification(self, subscription_id, subscription_ if status_response['apiStatus'] == "SUCCESS": self.status = "success" self.result['changed'] = True - self.msg = "Event Subscription Notification '{0}' deleted successfully from Cisco Catalyst Center".format(subscription_name) + self.msg = "Event Subscription Notification '{0}' deleted successfully from Cisco Catalyst Center".format( + subscription_name) self.log(self.msg, "INFO") self.delete_notification.append(subscription_name) return self @@ -4604,13 +4869,15 @@ def delete_events_subscription_notification(self, subscription_id, subscription_ if error_messages: self.msg = error_messages.get('errors') else: - self.msg = "Unable to delete Event Subscription Notification '{0}' from Cisco Catalyst Center.".format(subscription_name) + self.msg = "Unable to delete Event Subscription Notification '{0}' from Cisco Catalyst Center.".format( + subscription_name) self.log(self.msg, "ERROR") self.result['response'] = self.msg except Exception as e: self.status = "failed" - self.msg = "Exception occurred while deleting Event Subscription Notification '{0}' due to: {1}".format(subscription_name, str(e)) + self.msg = "Exception occurred while deleting Event Subscription Notification '{0}' due to: {1}".format( + subscription_name, str(e)) self.log(self.msg, "ERROR") return self @@ -4644,35 +4911,43 @@ def update_destination_notification_messages(self): result_msg_list = [] if self.create_dest: - create_dest_msg = "Destination(s) '{0}' created successfully in Cisco Catalyst Center.".format(self.create_dest) + create_dest_msg = "Destination(s) '{0}' created successfully in Cisco Catalyst Center.".format( + self.create_dest) result_msg_list.append(create_dest_msg) if self.update_dest: - update_dest_msg = "Destination(s) '{0}' updated successfully in Cisco Catalyst Center.".format(self.update_dest) + update_dest_msg = "Destination(s) '{0}' updated successfully in Cisco Catalyst Center.".format( + self.update_dest) result_msg_list.append(update_dest_msg) if self.no_update_dest: - no_update_dest_msg = "Destination(s) '{0}' need no update in Cisco Catalyst Center.".format(self.no_update_dest) + no_update_dest_msg = "Destination(s) '{0}' need no update in Cisco Catalyst Center.".format( + self.no_update_dest) result_msg_list.append(no_update_dest_msg) if self.create_notification: - create_notf_msg = "Event subscription notification(s) '{0}' created successfully in Cisco Catalyst Center.".format(self.create_notification) + create_notf_msg = "Event subscription notification(s) '{0}' created successfully in Cisco Catalyst Center.".format( + self.create_notification) result_msg_list.append(create_notf_msg) if self.update_notification: - update_notf_msg = "Event subscription notification(s) '{0}' updated successfully in Cisco Catalyst Center.".format(self.update_notification) + update_notf_msg = "Event subscription notification(s) '{0}' updated successfully in Cisco Catalyst Center.".format( + self.update_notification) result_msg_list.append(update_notf_msg) if self.no_update_notification: - no_update_notf_msg = "Event subscription notification(s) '{0}' need no update in Cisco Catalyst Center.".format(self.no_update_notification) + no_update_notf_msg = "Event subscription notification(s) '{0}' need no update in Cisco Catalyst Center.".format( + self.no_update_notification) result_msg_list.append(no_update_notf_msg) if self.delete_dest: - delete_dest_msg = "Destination(s) '{0}' deleted successfully from the Cisco Catalyst Center.".format(self.delete_dest) + delete_dest_msg = "Destination(s) '{0}' deleted successfully from the Cisco Catalyst Center.".format( + self.delete_dest) result_msg_list.append(delete_dest_msg) if self.absent_dest: - absent_dest_msg = "Unable to delete destination(s) '{0}' as they are not present in Cisco Catalyst Center.".format(self.absent_dest) + absent_dest_msg = "Unable to delete destination(s) '{0}' as they are not present in Cisco Catalyst Center.".format( + self.absent_dest) result_msg_list.append(absent_dest_msg) if self.delete_notification: @@ -4731,7 +5006,8 @@ def get_diff_merged(self, config): self.result['response'] = self.msg return self - webhook_params = self.collect_webhook_playbook_params(webhook_details) + webhook_params = self.collect_webhook_playbook_params( + webhook_details) url = webhook_params.get('url') regex_pattern = re.compile( @@ -4750,7 +5026,8 @@ def get_diff_merged(self, config): self.status = "failed" self.msg = ( "Given url '{0}' is invalid url for Creating/Updating Webhook destination. It must starts with " - "'https://' and follow the valid https url format.".format(url) + "'https://' and follow the valid https url format.".format( + url) ) self.log(self.msg, "ERROR") self.result['response'] = self.msg @@ -4760,7 +5037,8 @@ def get_diff_merged(self, config): self.status = "failed" self.msg = ( "Invalid Webhook method name '{0}' for creating/updating Webhook destination in Cisco Catalyst Center. " - "Select one of the following method 'POST/PUT'.".format(webhook_params.get('method')) + "Select one of the following method 'POST/PUT'.".format( + webhook_params.get('method')) ) self.log(self.msg, "ERROR") self.result['response'] = self.msg @@ -4777,18 +5055,22 @@ def get_diff_merged(self, config): self.result['response'] = self.msg return self - self.add_webhook_destination(webhook_params).check_return_status() + self.add_webhook_destination( + webhook_params).check_return_status() else: # Check destination needs update and if yes then update SNMP Destination - webhook_need_update = self.webhook_dest_needs_update(webhook_params, webhook_dest_detail_in_ccc) + webhook_need_update = self.webhook_dest_needs_update( + webhook_params, webhook_dest_detail_in_ccc) if not webhook_need_update: - self.msg = "Webhook Destination with name '{0}' needs no update in Cisco Catalyst Center".format(destination) + self.msg = "Webhook Destination with name '{0}' needs no update in Cisco Catalyst Center".format( + destination) self.log(self.msg, "INFO") self.no_update_dest.append(destination) else: # Update the syslog destination with given - self.update_webhook_destination(webhook_params, webhook_dest_detail_in_ccc).check_return_status() + self.update_webhook_destination( + webhook_params, webhook_dest_detail_in_ccc).check_return_status() # Create/Update Email destination in Cisco Catalyst Center if config.get("email_destination"): @@ -4804,7 +5086,8 @@ def get_diff_merged(self, config): self.status = "failed" self.msg = ( "Invalid Primary SMTP server hostname '{0}' as special character present in the input server " - "address so unable to add/update the email destination in CCC".format(server_address) + "address so unable to add/update the email destination in CCC".format( + server_address) ) self.log(self.msg, "ERROR") self.result['response'] = self.msg @@ -4823,12 +5106,14 @@ def get_diff_merged(self, config): self.log(self.msg, "ERROR") self.result['response'] = self.msg return self - self.log("Required parameter validated successfully for adding Email Destination in Cisco Catalyst Center.", "INFO") + self.log( + "Required parameter validated successfully for adding Email Destination in Cisco Catalyst Center.", "INFO") self.add_email_destination(email_params).check_return_status() else: # Check destination needs update and if yes then update Email Destination email_dest_detail_in_ccc = self.have.get('email_destination') - email_need_update = self.email_dest_needs_update(email_params, email_dest_detail_in_ccc) + email_need_update = self.email_dest_needs_update( + email_params, email_dest_detail_in_ccc) if not email_need_update: self.msg = "Email Destination needs no update in Cisco Catalyst Center" @@ -4836,7 +5121,8 @@ def get_diff_merged(self, config): self.no_update_dest.append("Email destination") else: # Update the email destination with given details in the playbook - self.update_email_destination(email_params, email_dest_detail_in_ccc).check_return_status() + self.update_email_destination( + email_params, email_dest_detail_in_ccc).check_return_status() # Create/Update Syslog destination in Cisco Catalyst Center if config.get("syslog_destination"): @@ -4863,14 +5149,16 @@ def get_diff_merged(self, config): if isinstance(port, int) and (int(port) not in range(1, 65536)): self.status = "failed" - self.msg = "Invalid Syslog destination port '{0}' given in playbook. Please choose a port within the range of numbers (1, 65535)".format(port) + self.msg = "Invalid Syslog destination port '{0}' given in playbook. Please choose a port within the range of numbers (1, 65535)".format( + port) self.log(self.msg, "ERROR") self.result['response'] = self.msg return self if server_address and not self.is_valid_server_address(server_address): self.status = "failed" - self.msg = "Invalid server address '{0}' given in the playbook for configuring Syslog destination".format(server_address) + self.msg = "Invalid server address '{0}' given in the playbook for configuring Syslog destination".format( + server_address) self.log(self.msg, "ERROR") self.result['response'] = self.msg return self @@ -4879,17 +5167,21 @@ def get_diff_merged(self, config): if not syslog_details_in_ccc: # We need to add the Syslog Destination in the Catalyst Center - self.add_syslog_destination(syslog_details).check_return_status() + self.add_syslog_destination( + syslog_details).check_return_status() else: # Check destination needs update and if yes then update Syslog Destination - syslog_need_update = self.syslog_dest_needs_update(syslog_details, syslog_details_in_ccc) + syslog_need_update = self.syslog_dest_needs_update( + syslog_details, syslog_details_in_ccc) if not syslog_need_update: - self.msg = "Syslog Destination with name '{0}' needs no update in Cisco Catalyst Center".format(name) + self.msg = "Syslog Destination with name '{0}' needs no update in Cisco Catalyst Center".format( + name) self.log(self.msg, "INFO") self.no_update_dest.append(name) else: # Update the syslog destination with given - self.update_syslog_destination(syslog_details, syslog_details_in_ccc).check_return_status() + self.update_syslog_destination( + syslog_details, syslog_details_in_ccc).check_return_status() # Create/Update snmp destination in Cisco Catalyst Center if config.get("snmp_destination"): @@ -4911,13 +5203,15 @@ def get_diff_merged(self, config): port = int(snmp_params.get('port')) if port not in range(1, 65536): self.status = "failed" - self.msg = "Invalid Notification trap port '{0}' given in playbook. Select port from the number range(1, 65535)".format(port) + self.msg = "Invalid Notification trap port '{0}' given in playbook. Select port from the number range(1, 65535)".format( + port) self.log(self.msg, "ERROR") self.result['response'] = self.msg return self except Exception as e: self.status = "failed" - self.msg = "Invalid Notification trap port '{0}' given in playbook. Select port from the number range(1, 65535)".format(port) + self.msg = "Invalid Notification trap port '{0}' given in playbook. Select port from the number range(1, 65535)".format( + port) self.log(self.msg, "ERROR") self.result['response'] = self.msg return self @@ -4933,22 +5227,26 @@ def get_diff_merged(self, config): if not self.have.get("snmp_destinations"): # Need to add snmp destination in Cisco Catalyst Center with given playbook params - self.check_snmp_required_parameters(snmp_params).check_return_status() + self.check_snmp_required_parameters( + snmp_params).check_return_status() self.log("""Required parameter validated successfully for adding SNMP Destination with name '{0}' in Cisco Catalyst Center.""".format(destination), "INFO") self.add_snmp_destination(snmp_params).check_return_status() else: # Check destination needs update and if yes then update SNMP Destination - snmp_need_update = self.snmp_dest_needs_update(snmp_params, snmp_dest_detail_in_ccc) + snmp_need_update = self.snmp_dest_needs_update( + snmp_params, snmp_dest_detail_in_ccc) if not snmp_need_update: - self.msg = "SNMP Destination with name '{0}' needs no update in Cisco Catalyst Center".format(destination) + self.msg = "SNMP Destination with name '{0}' needs no update in Cisco Catalyst Center".format( + destination) self.log(self.msg, "INFO") self.no_update_dest.append(destination) self.result['changed'] = False self.result['response'] = self.msg else: # Update the email destination with given details in the playbook - self.update_snmp_destination(snmp_params, snmp_dest_detail_in_ccc).check_return_status() + self.update_snmp_destination( + snmp_params, snmp_dest_detail_in_ccc).check_return_status() # Create/Update ITSM Integration Settings in Cisco Catalyst Center if config.get("itsm_setting"): @@ -4965,7 +5263,8 @@ def get_diff_merged(self, config): itsm_detail_in_ccc = self.have.get('itsm_setting') if not itsm_detail_in_ccc: - self.log("There is no ITSM Intergartion setting present in Cisco Catalyst Center", "INFO") + self.log( + "There is no ITSM Intergartion setting present in Cisco Catalyst Center", "INFO") else: # collect the ITSM id with given name itsm_id = itsm_detail_in_ccc[0].get("id") @@ -4973,8 +5272,10 @@ def get_diff_merged(self, config): if not itsm_detail_in_ccc: # Need to add snmp destination in Cisco Catalyst Center with given playbook params invalid_itsm_params = [] - invalid_itsm_params = self.check_required_itsm_param(itsm_params, invalid_itsm_params) - connection_setting = itsm_params.get('data').get('ConnectionSettings') + invalid_itsm_params = self.check_required_itsm_param( + itsm_params, invalid_itsm_params) + connection_setting = itsm_params.get( + 'data').get('ConnectionSettings') if not connection_setting: invalid_itsm_params.extend(["url", "username", "password"]) @@ -5005,36 +5306,44 @@ def get_diff_merged(self, config): regex_pattern = r'https://\S+' if not re.match(regex_pattern, url): self.status = "failed" - self.msg = "Given url '{0}' is invalid url for ITSM Intergartion setting. It must starts with 'https://'".format(url) + self.msg = "Given url '{0}' is invalid url for ITSM Intergartion setting. It must starts with 'https://'".format( + url) self.log(self.msg, "ERROR") self.result['response'] = self.msg return self - self.log("Required parameter validated successfully for configuring ITSM Intergartion setting in Cisco Catalyst Center.", "INFO") - self.create_itsm_integration_setting(itsm_params).check_return_status() + self.log( + "Required parameter validated successfully for configuring ITSM Intergartion setting in Cisco Catalyst Center.", "INFO") + self.create_itsm_integration_setting( + itsm_params).check_return_status() else: itsm_in_ccc = self.get_itsm_settings_by_id(itsm_id) if not itsm_in_ccc: self.status = "failed" - self.msg = "Unable to update as there is no ITSM Integration setting with name '{0}' present in Cisco Catalyst Center".format(itsm_name) + self.msg = "Unable to update as there is no ITSM Integration setting with name '{0}' present in Cisco Catalyst Center".format( + itsm_name) self.log(self.msg, "ERROR") self.result['response'] = self.msg return self # Check destination needs update and if yes then update Email Destination - itsm_need_update = self.itsm_needs_update(itsm_params, itsm_in_ccc) + itsm_need_update = self.itsm_needs_update( + itsm_params, itsm_in_ccc) if not itsm_need_update: - self.msg = "ITSM Intergartion setting with name '{0}' needs no update in Cisco Catalyst Center".format(itsm_name) + self.msg = "ITSM Intergartion setting with name '{0}' needs no update in Cisco Catalyst Center".format( + itsm_name) self.log(self.msg, "INFO") self.no_update_dest.append(itsm_name) else: # Update the ITSM integration settings with given details in the playbook - self.update_itsm_integration_setting(itsm_params, itsm_in_ccc).check_return_status() + self.update_itsm_integration_setting( + itsm_params, itsm_in_ccc).check_return_status() # Create Rest Webhook Events Subscription Notification in Cisco Catalyst Center if config.get("webhook_event_notification"): - webhook_notification_details = self.want.get("webhook_event_notification") + webhook_notification_details = self.want.get( + "webhook_event_notification") notification_name = webhook_notification_details.get("name") if not notification_name: @@ -5047,29 +5356,37 @@ def get_diff_merged(self, config): self.result['response'] = self.msg return self - webhook_notification_params = self.collect_webhook_notification_playbook_params(webhook_notification_details) + webhook_notification_params = self.collect_webhook_notification_playbook_params( + webhook_notification_details) if not self.have.get("webhook_subscription_notifications"): # Need to create webhook event notification in Cisco Catalyst Center - self.mandatory_webhook_notification_parameter_check(webhook_notification_params).check_return_status() + self.mandatory_webhook_notification_parameter_check( + webhook_notification_params).check_return_status() self.log("""Successfully validated the required parameter for creating the Webhook Event Notification with given name '{0}'""".format(notification_name), "INFO") - self.create_webhook_notification(webhook_notification_params).check_return_status() + self.create_webhook_notification( + webhook_notification_params).check_return_status() else: - webhook_notification_in_ccc = self.have.get("webhook_subscription_notifications")[0] + webhook_notification_in_ccc = self.have.get( + "webhook_subscription_notifications")[0] # Check whether the webhook evenet notification needs any update or not. - notification_update = self.webhook_notification_needs_update(webhook_notification_params, webhook_notification_in_ccc) + notification_update = self.webhook_notification_needs_update( + webhook_notification_params, webhook_notification_in_ccc) if not notification_update: - self.msg = "Webhook Notification with name '{0}' needs no update in Cisco Catalyst Center".format(notification_name) + self.msg = "Webhook Notification with name '{0}' needs no update in Cisco Catalyst Center".format( + notification_name) self.log(self.msg, "INFO") self.no_update_notification.append(notification_name) else: # Update the webhook notification with given playbook parameters - self.update_webhook_notification(webhook_notification_params, webhook_notification_in_ccc).check_return_status() + self.update_webhook_notification( + webhook_notification_params, webhook_notification_in_ccc).check_return_status() # Create Email Events Subscription Notification in Cisco Catalyst Center if config.get("email_event_notification"): - email_notification_details = self.want.get("email_event_notification") + email_notification_details = self.want.get( + "email_event_notification") notification_name = email_notification_details.get("name") if not notification_name: @@ -5082,30 +5399,38 @@ def get_diff_merged(self, config): self.result['response'] = self.msg return self - email_notification_params = self.collect_email_notification_playbook_params(email_notification_details) + email_notification_params = self.collect_email_notification_playbook_params( + email_notification_details) if not self.have.get("email_subscription_notifications"): # Need to create email event notification in Cisco Catalyst Center - self.mandatory_email_notification_parameter_check(email_notification_params).check_return_status() + self.mandatory_email_notification_parameter_check( + email_notification_params).check_return_status() self.log("""Successfully validated the required parameter for creating the email Event Notification with given name '{0}'""".format(notification_name), "INFO") - self.create_email_notification(email_notification_params).check_return_status() + self.create_email_notification( + email_notification_params).check_return_status() else: - email_notification_in_ccc = self.have.get("email_subscription_notifications")[0] + email_notification_in_ccc = self.have.get( + "email_subscription_notifications")[0] # Check whether the email evenet notification needs any update or not. - notification_update = self.email_notification_needs_update(email_notification_params, email_notification_in_ccc) + notification_update = self.email_notification_needs_update( + email_notification_params, email_notification_in_ccc) if not notification_update: - self.msg = "Email Notification with name '{0}' needs no update in Cisco Catalyst Center".format(notification_name) + self.msg = "Email Notification with name '{0}' needs no update in Cisco Catalyst Center".format( + notification_name) self.log(self.msg, "INFO") self.no_update_notification.append(notification_name) else: # Update the email notification with given playbook parameters - self.update_email_notification(email_notification_params, email_notification_in_ccc).check_return_status() + self.update_email_notification( + email_notification_params, email_notification_in_ccc).check_return_status() # Create Syslog Events Subscription Notification in Cisco Catalyst Center if config.get("syslog_event_notification"): - syslog_notification_details = self.want.get("syslog_event_notification") + syslog_notification_details = self.want.get( + "syslog_event_notification") notification_name = syslog_notification_details.get("name") if not notification_name: @@ -5118,25 +5443,32 @@ def get_diff_merged(self, config): self.result['response'] = self.msg return self - syslog_notification_params = self.collect_syslog_notification_playbook_params(syslog_notification_details) + syslog_notification_params = self.collect_syslog_notification_playbook_params( + syslog_notification_details) if not self.have.get("syslog_subscription_notifications"): # Need to create syslog event notification in Cisco Catalyst Center - self.mandatory_syslog_notification_parameter_check(syslog_notification_params).check_return_status() + self.mandatory_syslog_notification_parameter_check( + syslog_notification_params).check_return_status() self.log("""Successfully validated the required parameter for creating the Syslog Event Notification with given name '{0}'""".format(notification_name), "INFO") - self.create_syslog_notification(syslog_notification_params).check_return_status() + self.create_syslog_notification( + syslog_notification_params).check_return_status() else: - syslog_notification_in_ccc = self.have.get("syslog_subscription_notifications")[0] + syslog_notification_in_ccc = self.have.get( + "syslog_subscription_notifications")[0] # Check whether the syslog evenet notification needs any update or not. - sys_notification_update = self.syslog_notification_needs_update(syslog_notification_params, syslog_notification_in_ccc) + sys_notification_update = self.syslog_notification_needs_update( + syslog_notification_params, syslog_notification_in_ccc) if not sys_notification_update: - self.msg = "Syslog Notification with name '{0}' needs no update in Cisco Catalyst Center".format(notification_name) + self.msg = "Syslog Notification with name '{0}' needs no update in Cisco Catalyst Center".format( + notification_name) self.log(self.msg, "INFO") self.no_update_notification.append(notification_name) else: # Update the syslog notification with given playbook parameters - self.update_syslog_notification(syslog_notification_params, syslog_notification_in_ccc).check_return_status() + self.update_syslog_notification( + syslog_notification_params, syslog_notification_in_ccc).check_return_status() return self @@ -5208,16 +5540,20 @@ def get_diff_deleted(self, config): itsm_exist = True break if itsm_exist: - self.delete_itsm_integration_setting(itsm_name, itsm_id).check_return_status() + self.delete_itsm_integration_setting( + itsm_name, itsm_id).check_return_status() else: - self.msg = "Unable to delete ITSM Integartion setting with name '{0}' as it is not present in Cisco Catalyst Center".format(itsm_name) + self.msg = "Unable to delete ITSM Integartion setting with name '{0}' as it is not present in Cisco Catalyst Center".format( + itsm_name) self.log(self.msg, "INFO") self.absent_dest.append(itsm_name) # Delete Webhook Events Subscription Notification from Cisco Catalyst Center if config.get('webhook_event_notification'): - webhook_notification_details = self.want.get('webhook_event_notification') - webhook_notification_name = webhook_notification_details.get('name') + webhook_notification_details = self.want.get( + 'webhook_event_notification') + webhook_notification_name = webhook_notification_details.get( + 'name') if not webhook_notification_name: self.status = "failed" @@ -5233,16 +5569,19 @@ def get_diff_deleted(self, config): self.status = "success" self.msg = ( "There is no Webhook Event Subscription Notification with name '{0}' present in in Cisco Catalyst Center " - "so cannot delete the notification.".format(webhook_notification_name) + "so cannot delete the notification.".format( + webhook_notification_name) ) self.log(self.msg, "INFO") self.absent_notification.append(webhook_notification_name) return self - webhook_notification_id = self.have.get("webhook_subscription_notifications")[0].get("subscriptionId") + webhook_notification_id = self.have.get("webhook_subscription_notifications")[ + 0].get("subscriptionId") if webhook_notification_id: - self.delete_events_subscription_notification(webhook_notification_id, webhook_notification_name).check_return_status() + self.delete_events_subscription_notification( + webhook_notification_id, webhook_notification_name).check_return_status() else: self.msg = ( "Unable to delete Webhook Event Subscription Notification with name '{0}' as it is not present in " @@ -5253,7 +5592,8 @@ def get_diff_deleted(self, config): # Delete Email Events Subscription Notification from Cisco Catalyst Center if config.get('email_event_notification'): - email_notification_details = self.want.get('email_event_notification') + email_notification_details = self.want.get( + 'email_event_notification') email_notification_name = email_notification_details.get('name') if not email_notification_name: @@ -5270,16 +5610,19 @@ def get_diff_deleted(self, config): self.status = "success" self.msg = ( "There is no Email Event Subscription Notification with name '{0}' present in in Cisco Catalyst Center " - "so cannot delete the notification.".format(email_notification_name) + "so cannot delete the notification.".format( + email_notification_name) ) self.log(self.msg, "INFO") self.absent_notification.append(email_notification_name) return self - email_notification_id = self.have.get("email_subscription_notifications")[0].get("subscriptionId") + email_notification_id = self.have.get("email_subscription_notifications")[ + 0].get("subscriptionId") if email_notification_id: - self.delete_events_subscription_notification(email_notification_id, email_notification_name).check_return_status() + self.delete_events_subscription_notification( + email_notification_id, email_notification_name).check_return_status() else: self.msg = ( "Unable to delete Email Event Subscription Notification with name '{0}' as it is not present in " @@ -5290,7 +5633,8 @@ def get_diff_deleted(self, config): # Delete Syslog Events Subscription Notification from Cisco Catalyst Center if config.get('syslog_event_notification'): - syslog_notification_details = self.want.get('syslog_event_notification') + syslog_notification_details = self.want.get( + 'syslog_event_notification') syslog_notification_name = syslog_notification_details.get('name') if not syslog_notification_name: @@ -5307,16 +5651,19 @@ def get_diff_deleted(self, config): self.status = "success" self.msg = ( "There is no Syslog Event Subscription Notification with name '{0}' present in in Cisco Catalyst Center " - "so cannot delete the notification.".format(syslog_notification_name) + "so cannot delete the notification.".format( + syslog_notification_name) ) self.log(self.msg, "INFO") self.absent_notification.append(syslog_notification_name) return self - syslog_notification_id = self.have.get("syslog_subscription_notifications")[0].get("subscriptionId") + syslog_notification_id = self.have.get("syslog_subscription_notifications")[ + 0].get("subscriptionId") if syslog_notification_id: - self.delete_events_subscription_notification(syslog_notification_id, syslog_notification_name).check_return_status() + self.delete_events_subscription_notification( + syslog_notification_id, syslog_notification_name).check_return_status() else: self.msg = ( "Unable to delete Syslog Event Subscription Notification with name '{0}' as it is not present in " @@ -5410,7 +5757,8 @@ def verify_diff_merged(self, config): name '{0}' addition/updation task may not have executed successfully.""".format(itsm_name), "INFO") if config.get("webhook_event_notification"): - webhook_notification_details = self.want.get("webhook_event_notification") + webhook_notification_details = self.want.get( + "webhook_event_notification") web_notification_name = webhook_notification_details.get("name") if self.have.get("webhook_subscription_notifications"): @@ -5423,7 +5771,8 @@ def verify_diff_merged(self, config): name '{0}' creation/updation task may not have executed successfully.""".format(web_notification_name), "INFO") if config.get("email_event_notification"): - email_notification_details = self.want.get("email_event_notification") + email_notification_details = self.want.get( + "email_event_notification") email_notification_name = email_notification_details.get("name") if self.have.get("email_subscription_notifications"): @@ -5436,7 +5785,8 @@ def verify_diff_merged(self, config): name '{0}' creation/updation task may not have executed successfully.""".format(email_notification_name), "INFO") if config.get("syslog_event_notification"): - syslog_notification_details = self.want.get("syslog_event_notification") + syslog_notification_details = self.want.get( + "syslog_event_notification") syslog_notification_name = syslog_notification_details.get("name") if self.have.get("syslog_subscription_notifications"): @@ -5482,7 +5832,8 @@ def verify_diff_deleted(self, config): name '{0}' deletion task may not have executed successfully.""".format(itsm_name), "INFO") if config.get("webhook_event_notification"): - webhook_notification_details = self.want.get("webhook_event_notification") + webhook_notification_details = self.want.get( + "webhook_event_notification") web_notification_name = webhook_notification_details.get("name") if not self.have.get("webhook_subscription_notifications"): @@ -5495,7 +5846,8 @@ def verify_diff_deleted(self, config): with name '{0}' deletion task may not have executed successfully.""".format(web_notification_name), "INFO") if config.get("email_event_notification"): - email_notification_details = self.want.get("email_event_notification") + email_notification_details = self.want.get( + "email_event_notification") email_notification_name = email_notification_details.get("name") if not self.have.get("email_subscription_notifications"): @@ -5508,7 +5860,8 @@ def verify_diff_deleted(self, config): with name '{0}' deletion task may not have executed successfully.""".format(email_notification_name), "INFO") if config.get("syslog_event_notification"): - syslog_notification_details = self.want.get("syslog_event_notification") + syslog_notification_details = self.want.get( + "syslog_event_notification") syslog_notification_name = syslog_notification_details.get("name") if not self.have.get("syslog_subscription_notifications"): @@ -5564,7 +5917,8 @@ def main(): "Supported versions start from '2.3.5.3' onwards." .format(ccc_events.get_ccc_version()) ) - ccc_events.set_operation_result("failed", False, ccc_events.msg, "ERROR").check_return_status() + ccc_events.set_operation_result( + "failed", False, ccc_events.msg, "ERROR").check_return_status() config_verify = ccc_events.params.get("config_verify") @@ -5574,7 +5928,8 @@ def main(): ccc_events.get_have(config).check_return_status() ccc_events.get_diff_state_apply[state](config).check_return_status() if config_verify: - ccc_events.verify_diff_state_apply[state](config).check_return_status() + ccc_events.verify_diff_state_apply[state]( + config).check_return_status() # Invoke the API to check the status and log the output of each destination and notification on the console ccc_events.update_destination_notification_messages().check_return_status() diff --git a/plugins/modules/inventory_intent.py b/plugins/modules/inventory_intent.py index 2430603277..250f3219a1 100644 --- a/plugins/modules/inventory_intent.py +++ b/plugins/modules/inventory_intent.py @@ -5,6 +5,15 @@ # 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 +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, +) +from ansible.module_utils.basic import AnsibleModule +from io import BytesIO, StringIO +from datetime import datetime +import time +import csv __metaclass__ = type __author__ = ("Madhan Sankaranarayanan, Abhishek Maheshwari") @@ -722,15 +731,6 @@ HAS_PYZIPPER = False pyzipper = None -import csv -import time -from datetime import datetime -from io import BytesIO, StringIO -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, -) # Defer this feature as API issue is there once it's fixed we will addresses it in upcoming release iac2.0 support_for_provisioning_wireless = False @@ -837,14 +837,16 @@ def validate_input(self): ) if invalid_params: - self.msg = "Invalid parameters in playbook: {0}".format(invalid_params) + self.msg = "Invalid parameters in playbook: {0}".format( + invalid_params) self.log(self.msg, "ERROR") self.status = "failed" self.result['response'] = self.msg return self self.validated_config = valid_temp - self.msg = "Successfully validated playbook configuration parameters using 'validate_input': {0}".format(str(valid_temp)) + self.msg = "Successfully validated playbook configuration parameters using 'validate_input': {0}".format( + str(valid_temp)) self.log(self.msg, "INFO") self.status = "success" @@ -872,19 +874,22 @@ def get_device_ips_from_config_priority(self): # If device IPs are not available, check hostnames device_hostnames = self.config[0].get("hostnames") if device_hostnames: - device_ip_dict = self.get_device_ips_from_hostnames(device_hostnames) + device_ip_dict = self.get_device_ips_from_hostnames( + device_hostnames) return self.get_list_from_dict_values(device_ip_dict) # If hostnames are not available, check serial numbers device_serial_numbers = self.config[0].get("serial_numbers") if device_serial_numbers: - device_ip_dict = self.get_device_ips_from_serial_numbers(device_serial_numbers) + device_ip_dict = self.get_device_ips_from_serial_numbers( + device_serial_numbers) return self.get_list_from_dict_values(device_ip_dict) # If serial numbers are not available, check MAC addresses device_mac_addresses = self.config[0].get("mac_addresses") if device_mac_addresses: - device_ip_dict = self.get_device_ips_from_mac_addresses(device_mac_addresses) + device_ip_dict = self.get_device_ips_from_mac_addresses( + device_mac_addresses) return self.get_list_from_dict_values(device_ip_dict) # If no information is available, return an empty list @@ -930,20 +935,24 @@ def get_existing_devices_in_ccc(self): offset = offset + 1 response = response.get("response") if not response: - self.log("There are no device details received from 'get_device_list' API.", "INFO") + self.log( + "There are no device details received from 'get_device_list' API.", "INFO") break - self.log("Received API response from 'get_device_list': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_device_list': {0}".format( + str(response)), "DEBUG") for ip in response: device_ip = ip["managementIpAddress"] existing_devices_in_ccc.add(device_ip) except Exception as e: self.status = "failed" - self.msg = "Error while fetching device details from Cisco Catalyst Center: {0}".format(str(e)) + self.msg = "Error while fetching device details from Cisco Catalyst Center: {0}".format( + str(e)) self.log(self.msg, "CRITICAL") self.check_return_status() - self.log("Devices present in Cisco Catalyst Center: {0}".format(str(existing_devices_in_ccc)), "DEBUG") + self.log("Devices present in Cisco Catalyst Center: {0}".format( + str(existing_devices_in_ccc)), "DEBUG") existing_devices_in_ccc = list(existing_devices_in_ccc) return existing_devices_in_ccc @@ -969,13 +978,15 @@ def is_udf_exist(self, field_name): params={"name": field_name}, ) - self.log("Received API response from 'get_all_user_defined_fields': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_all_user_defined_fields': {0}".format( + str(response)), "DEBUG") udf = response.get("response") if (len(udf) == 1): return True - message = "Global User Defined Field with name '{0}' doesnot exist in Cisco Catalyst Center".format(field_name) + message = "Global User Defined Field with name '{0}' doesnot exist in Cisco Catalyst Center".format( + field_name) self.log(message, "INFO") return False @@ -999,14 +1010,17 @@ def create_user_defined_field(self, udf): op_modifies=True, params=udf, ) - self.log("Received API response from 'create_user_defined_field': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'create_user_defined_field': {0}".format( + str(response)), "DEBUG") response = response.get("response") field_name = udf.get('name') - self.log("Global User Defined Field with name '{0}' created successfully".format(field_name), "INFO") + self.log("Global User Defined Field with name '{0}' created successfully".format( + field_name), "INFO") self.status = "success" except Exception as e: - error_message = "Error while creating Global UDF(User Defined Field) in Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error while creating Global UDF(User Defined Field) in Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "ERROR") return self @@ -1043,14 +1057,16 @@ def add_field_to_devices(self, device_ids, udf): op_modifies=True, params=udf_param_dict, ) - self.log("Received API response from 'add_user_defined_field_to_device': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'add_user_defined_field_to_device': {0}".format( + str(response)), "DEBUG") response = response.get("response") self.status = "success" self.result['changed'] = True except Exception as e: self.status = "failed" - error_message = "Error while adding Global UDF to device in Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error while adding Global UDF to device in Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "ERROR") self.result['changed'] = False @@ -1076,7 +1092,8 @@ def trigger_export_api(self, payload_params): op_modifies=True, params=payload_params, ) - self.log("Received API response from 'export_device_list': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'export_device_list': {0}".format( + str(response)), "DEBUG") response = response.get("response") task_id = response.get("taskId") @@ -1084,13 +1101,15 @@ def trigger_export_api(self, payload_params): execution_details = self.get_task_details(task_id) if execution_details.get("additionalStatusURL"): - file_id = execution_details.get("additionalStatusURL").split("/")[-1] + file_id = execution_details.get( + "additionalStatusURL").split("/")[-1] break elif execution_details.get("isError"): self.status = "failed" failure_reason = execution_details.get("failureReason") if failure_reason: - self.msg = "Could not get the File ID because of {0} so can't export device details in csv file".format(failure_reason) + self.msg = "Could not get the File ID because of {0} so can't export device details in csv file".format( + failure_reason) else: self.msg = "Could not get the File ID so can't export device details in csv file" self.log(self.msg, "ERROR") @@ -1105,7 +1124,8 @@ def trigger_export_api(self, payload_params): op_modifies=True, params={"file_id": file_id}, ) - self.log("Received API response from 'download_a_file_by_fileid': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'download_a_file_by_fileid': {0}".format( + str(response)), "DEBUG") return response @@ -1142,10 +1162,12 @@ def decrypt_and_read_csv(self, response, password): try: encryption_method = encryption_dict.get(snmp_protocol) except Exception as e: - self.log("Given SNMP protcol '{0}' not present".format(snmp_protocol), "WARNING") + self.log("Given SNMP protcol '{0}' not present".format( + snmp_protocol), "WARNING") if not encryption_method: - self.msg = "Invalid SNMP protocol '{0}' specified for encryption.".format(snmp_protocol) + self.msg = "Invalid SNMP protocol '{0}' specified for encryption.".format( + snmp_protocol) self.log(self.msg, "ERROR") self.status = "failed" self.result['response'] = self.msg @@ -1157,14 +1179,16 @@ def decrypt_and_read_csv(self, response, password): file_name = zip_ref.namelist()[0] # Extract the content of the file with the provided password - file_content_binary = zip_ref.read(file_name, pwd=password.encode('utf-8')) + file_content_binary = zip_ref.read( + file_name, pwd=password.encode('utf-8')) # Now 'file_content_binary' contains the binary content of the decrypted file # Since the content is text, so we can decode it file_content_text = file_content_binary.decode('utf-8') # Now 'file_content_text' contains the text content of the decrypted file - self.log("Text content of decrypted file: {0}".format(file_content_text), "DEBUG") + self.log("Text content of decrypted file: {0}".format( + file_content_text), "DEBUG") # Parse the CSV-like string into a list of dictionaries csv_reader = csv.DictReader(StringIO(file_content_text)) @@ -1214,7 +1238,8 @@ def export_device_details(self): self.status = "failed" detailed_msg = """Invalid password. Min password length is 8 and it should contain atleast one lower case letter, one uppercase letter, one digit and one special characters from -=\\;,./~!@#$%^&*()_+{}[]|:?""" - formatted_msg = ' '.join(line.strip() for line in detailed_msg.splitlines()) + formatted_msg = ' '.join(line.strip() + for line in detailed_msg.splitlines()) self.msg = formatted_msg self.log(formatted_msg, "INFO") self.result['response'] = self.msg @@ -1222,7 +1247,8 @@ def export_device_details(self): # Export the device data in a batch of 500 devices at a time start = 0 - device_batch_size = self.config[0].get("export_device_details_limit", 500) + device_batch_size = self.config[0].get( + "export_device_details_limit", 500) device_data = [] first_run = True @@ -1241,18 +1267,21 @@ def export_device_details(self): if payload_params["operationEnum"] == "0": temp_file_name = response.filename if first_run: - output_file_name = temp_file_name.split(".")[0] + ".csv" + output_file_name = temp_file_name.split(".")[ + 0] + ".csv" csv_reader = self.decrypt_and_read_csv(response, password) self.check_return_status() else: decoded_resp = response.data.decode(encoding='utf-8') - self.log("Decoded response of Export Device Credential file: {0}".format(str(decoded_resp)), "DEBUG") + self.log("Decoded response of Export Device Credential file: {0}".format( + str(decoded_resp)), "DEBUG") # Parse the CSV-like string into a list of dictionaries csv_reader = csv.DictReader(StringIO(decoded_resp)) current_date = datetime.now() formatted_date = current_date.strftime("%m-%d-%Y") if first_run: - output_file_name = "devices-" + str(formatted_date) + ".csv" + output_file_name = "devices-" + \ + str(formatted_date) + ".csv" for row in csv_reader: device_data.append(row) @@ -1266,14 +1295,16 @@ def export_device_details(self): csv_writer.writeheader() csv_writer.writerows(device_data) - self.msg = "Device Details Exported Successfully to the CSV file: {0}".format(output_file_name) + self.msg = "Device Details Exported Successfully to the CSV file: {0}".format( + output_file_name) self.log(self.msg, "INFO") self.status = "success" self.result['changed'] = True self.result['response'] = self.msg except Exception as e: - self.msg = "Error while exporting device details into CSV file for device(s): '{0}'".format(str(device_ips)) + self.msg = "Error while exporting device details into CSV file for device(s): '{0}'".format( + str(device_ips)) self.log(self.msg, "ERROR") self.status = "failed" @@ -1306,7 +1337,8 @@ def get_ap_devices(self, device_ips): if response and response[0].get('family', '') == "Unified AP": ap_device_list.append(device_ip) except Exception as e: - error_message = "Error while getting the response of device from Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error while getting the response of device from Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "CRITICAL") raise Exception(error_message) @@ -1335,15 +1367,18 @@ def resync_devices(self): input_device_ips.remove(device_ip) ap_devices = self.get_ap_devices(input_device_ips) - self.log("AP Devices from the playbook input are: {0}".format(str(ap_devices)), "INFO") + self.log("AP Devices from the playbook input are: {0}".format( + str(ap_devices)), "INFO") if ap_devices: for ap_ip in ap_devices: input_device_ips.remove(ap_ip) - self.log("Following devices {0} are AP, so can't perform resync operation.".format(str(ap_devices)), "WARNING") + self.log("Following devices {0} are AP, so can't perform resync operation.".format( + str(ap_devices)), "WARNING") if not input_device_ips: - self.msg = "Cannot perform the Resync operation as the device(s) with IP(s) {0} are not present in Cisco Catalyst Center".format(str(device_ips)) + self.msg = "Cannot perform the Resync operation as the device(s) with IP(s) {0} are not present in Cisco Catalyst Center".format( + str(device_ips)) self.status = "success" self.result['changed'] = False self.result['response'] = self.msg @@ -1355,30 +1390,35 @@ def resync_devices(self): # Resync the device in a batch of 200 devices at a time in inventory by default start = 0 resync_failed_for_all_device = False - resync_device_count = self.config[0].get("resync_device_count", 200) + resync_device_count = self.config[0].get( + "resync_device_count", 200) resync_successful_devices, resync_failed_devices = [], [] force_sync = self.config[0].get("force_sync", False) resync_task_dict = {} while start < len(device_ids): device_ids_list = device_ids[start:start + resync_device_count] - device_ips_list = input_device_ips[start:start + resync_device_count] + device_ips_list = input_device_ips[start:start + + resync_device_count] resync_param_dict = { 'payload': device_ids_list, 'force_sync': force_sync } - self.log("Request payload for reysnc Device having the device ids: {0}".format(device_ids_list), "INFO") + self.log("Request payload for reysnc Device having the device ids: {0}".format( + device_ids_list), "INFO") response = self.dnac._exec( family="devices", function='sync_devices_using_forcesync', op_modifies=True, params=resync_param_dict, ) - self.log("Received API response from 'sync_devices_using_forcesync': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'sync_devices_using_forcesync': {0}".format( + str(response)), "DEBUG") if not response or not isinstance(response, dict): self.status = "failed" - self.msg = "Unable to resync the device(s) {0} in the inventory as response is empty.".format(device_ips_list) + self.msg = "Unable to resync the device(s) {0} in the inventory as response is empty.".format( + device_ips_list) self.log(self.msg, "ERROR") self.result['response'] = self.msg return self @@ -1416,7 +1456,8 @@ def resync_devices(self): ).format(resync_successful_devices, resync_failed_devices) elif resync_failed_devices: resync_failed_for_all_device = True - self.msg = "Device resynced get failed for all given device(s) '{0}'.".format(resync_failed_devices) + self.msg = "Device resynced get failed for all given device(s) '{0}'.".format( + resync_failed_devices) else: self.msg = ( "Device(s) '{0}' have been successfully resynced in the inventory in Cisco Catalyst Center. " @@ -1432,7 +1473,8 @@ def resync_devices(self): self.result["response"] = self.msg except Exception as e: self.status = "failed" - error_message = "Error while resyncing device in Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error while resyncing device in Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "ERROR") return self @@ -1455,7 +1497,8 @@ def reboot_access_points(self): if input_device_ips: ap_devices = self.get_ap_devices(input_device_ips) - self.log("AP Devices from the playbook input are: {0}".format(str(ap_devices)), "INFO") + self.log("AP Devices from the playbook input are: {0}".format( + str(ap_devices)), "INFO") for device_ip in input_device_ips: if device_ip not in ap_devices: input_device_ips.remove(device_ip) @@ -1517,14 +1560,16 @@ def reboot_access_points(self): self.status = "success" self.result['changed'] = True self.result['response'] = execution_details - self.msg = "AP Device(s) {0} successfully rebooted!".format(str(input_device_ips)) + self.msg = "AP Device(s) {0} successfully rebooted!".format( + str(input_device_ips)) self.log(self.msg, "INFO") break elif execution_details.get("isError"): self.status = "failed" failure_reason = execution_details.get("failureReason") if failure_reason: - self.msg = "AP Device Rebooting get failed because of {0}".format(failure_reason) + self.msg = "AP Device Rebooting get failed because of {0}".format( + failure_reason) else: self.msg = "AP Device Rebooting get failed" self.log(self.msg, "ERROR") @@ -1550,7 +1595,8 @@ def handle_successful_provisioning(self, device_ip, execution_details, device_ty self.status = "success" self.result['changed'] = True self.result['response'] = execution_details - self.log("{0} Device {1} provisioned successfully!!".format(device_type, device_ip), "INFO") + self.log("{0} Device {1} provisioned successfully!!".format( + device_type, device_ip), "INFO") def handle_failed_provisioning(self, device_ip, execution_details, device_type): """ @@ -1567,8 +1613,10 @@ def handle_failed_provisioning(self, device_ip, execution_details, device_type): """ self.status = "failed" - failure_reason = execution_details.get("failureReason", "Unknown failure reason") - self.msg = "{0} Device Provisioning failed for {1} because of {2}".format(device_type, device_ip, failure_reason) + failure_reason = execution_details.get( + "failureReason", "Unknown failure reason") + self.msg = "{0} Device Provisioning failed for {1} because of {2}".format( + device_type, device_ip, failure_reason) self.log(self.msg, "WARNING") self.result['response'] = self.msg @@ -1586,7 +1634,8 @@ def handle_provisioning_exception(self, device_ip, exception, device_type): This method logs an error message indicating an exception occurred during the provisioning process for a device. """ - error_message = "Error while Provisioning the {0} device {1} in Cisco Catalyst Center: {2}".format(device_type, device_ip, str(exception)) + error_message = "Error while Provisioning the {0} device {1} in Cisco Catalyst Center: {2}".format( + device_type, device_ip, str(exception)) self.log(error_message, "ERROR") def handle_all_already_provisioned(self, device_ips, device_type): @@ -1602,7 +1651,8 @@ def handle_all_already_provisioned(self, device_ips, device_type): """ self.status = "success" - self.msg = "All the {0} Devices '{1}' given in the playbook are already Provisioned".format(device_type, str(device_ips)) + self.msg = "All the {0} Devices '{1}' given in the playbook are already Provisioned".format( + device_type, str(device_ips)) self.log(self.msg, "INFO") self.result['response'] = self.msg self.result['changed'] = False @@ -1621,7 +1671,8 @@ def handle_all_provisioned(self, device_type): self.status = "success" self.result['changed'] = True - self.log("All {0} Devices provisioned successfully!!".format(device_type), "INFO") + self.log("All {0} Devices provisioned successfully!!".format( + device_type), "INFO") def handle_all_failed_provision(self, device_type): """ @@ -1637,7 +1688,8 @@ def handle_all_failed_provision(self, device_type): """ self.status = "failed" - self.msg = "{0} Device Provisioning failed for all devices".format(device_type) + self.msg = "{0} Device Provisioning failed for all devices".format( + device_type) self.log(self.msg, "INFO") self.result['response'] = self.msg @@ -1657,7 +1709,8 @@ def handle_partially_provisioned(self, provision_count, device_type): self.status = "success" self.result['changed'] = True - self.log("{0} Devices provisioned successfully partially for {1} devices".format(device_type, provision_count), "INFO") + self.log("{0} Devices provisioned successfully partially for {1} devices".format( + device_type, provision_count), "INFO") def provisioned_wired_device(self): """ @@ -1705,19 +1758,22 @@ def provisioned_wired_device(self): self.status = "success" already_provision_count += 1 self.result['changed'] = False - self.msg = "Device '{0}' is already provisioned in the Cisco Catalyst Center".format(device_ip) + self.msg = "Device '{0}' is already provisioned in the Cisco Catalyst Center".format( + device_ip) self.log(self.msg, "INFO") continue if device_prov_status == 3: self.status = "failed" - error_msg = "Cannot do Provisioning for device {0}.".format(device_ip) + error_msg = "Cannot do Provisioning for device {0}.".format( + device_ip) self.log(error_msg, "ERROR") continue # Check till device comes into managed state while resync_retry_count: response = self.get_device_response(device_ip) - self.log("Device is in {0} state waiting for Managed State.".format(response['managementState']), "DEBUG") + self.log("Device is in {0} state waiting for Managed State.".format( + response['managementState']), "DEBUG") if ( response.get('managementState') == "Managed" @@ -1756,7 +1812,8 @@ def provisioned_wired_device(self): if response.get("status") == "failed": description = response.get("description") - error_msg = "Cannot do Provisioning for device {0} beacuse of {1}".format(device_ip, description) + error_msg = "Cannot do Provisioning for device {0} beacuse of {1}".format( + device_ip, description) self.log(error_msg, "ERROR") continue @@ -1767,11 +1824,13 @@ def provisioned_wired_device(self): progress = execution_details.get("progress") if 'TASK_PROVISION' in progress: - self.handle_successful_provisioning(device_ip, execution_details, device_type) + self.handle_successful_provisioning( + device_ip, execution_details, device_type) provision_count += 1 break elif execution_details.get("isError"): - self.handle_failed_provisioning(device_ip, execution_details, device_type) + self.handle_failed_provisioning( + device_ip, execution_details, device_type) break except Exception as e: @@ -1857,7 +1916,8 @@ def get_wireless_param(self, prov_dict): wireless_param[0]["deviceName"] = response.get("hostname") self.wireless_param = wireless_param self.status = "success" - self.log("Successfully collected all the parameters required for Wireless Provisioning", "DEBUG") + self.log( + "Successfully collected all the parameters required for Wireless Provisioning", "DEBUG") except Exception as e: self.msg = """An exception occured while fetching the details for wireless provisioning of @@ -1893,7 +1953,8 @@ def get_site_type(self, site_name): self.log(self.msg, "INFO") return site_type - self.log("Received API response from 'get_site': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_site': {0}".format( + str(response)), "DEBUG") site = response.get("response") site_additional_info = site[0].get("additionalInfo") @@ -1902,7 +1963,8 @@ def get_site_type(self, site_name): site_type = item.get("attributes").get("type") except Exception as e: - self.msg = "Error while fetching the site '{0}' and the specified site was not found in Cisco Catalyst Center.".format(site_name) + self.msg = "Error while fetching the site '{0}' and the specified site was not found in Cisco Catalyst Center.".format( + site_name) self.module.fail_json(msg=self.msg, response=[self.msg]) return site_type @@ -1935,13 +1997,15 @@ def provisioned_wireless_devices(self): provisioning_params = self.wireless_param resync_retry_count = prov_dict.get("resync_retry_count", 200) # This resync retry interval will be in seconds which will check device status at given interval - resync_retry_interval = prov_dict.get("resync_retry_interval", 2) + resync_retry_interval = prov_dict.get( + "resync_retry_interval", 2) managed_flag = True # Check till device comes into managed state while resync_retry_count: response = self.get_device_response(device_ip) - self.log("Device is in {0} state waiting for Managed State.".format(response['managementState']), "DEBUG") + self.log("Device is in {0} state waiting for Managed State.".format( + response['managementState']), "DEBUG") if ( response.get('managementState') == "Managed" @@ -1980,7 +2044,8 @@ def provisioned_wireless_devices(self): if response.get("status") == "failed": description = response.get("description") - error_msg = "Cannot do Provisioning for Wireless device {0} beacuse of {1}".format(device_ip, description) + error_msg = "Cannot do Provisioning for Wireless device {0} beacuse of {1}".format( + device_ip, description) self.log(error_msg, "ERROR") continue @@ -1990,11 +2055,13 @@ def provisioned_wireless_devices(self): execution_details = self.get_task_details(task_id) progress = execution_details.get("progress") if 'TASK_PROVISION' in progress: - self.handle_successful_provisioning(device_ip, execution_details, device_type) + self.handle_successful_provisioning( + device_ip, execution_details, device_type) provision_count += 1 break elif execution_details.get("isError"): - self.handle_failed_provisioning(device_ip, execution_details, device_type) + self.handle_failed_provisioning( + device_ip, execution_details, device_type) break except Exception as e: @@ -2002,7 +2069,8 @@ def provisioned_wireless_devices(self): # but for others it gets provision successfully or If some devices are already provsioned self.handle_provisioning_exception(device_ip, e, device_type) if "already provisioned" in str(e): - self.msg = "Device '{0}' already provisioned".format(device_ip) + self.msg = "Device '{0}' already provisioned".format( + device_ip) self.log(self.msg, "INFO") already_provision_count += 1 @@ -2040,13 +2108,15 @@ def get_udf_id(self, field_name): op_modifies=True, params={"name": field_name}, ) - self.log("Received API response from 'get_all_user_defined_fields': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_all_user_defined_fields': {0}".format( + str(response)), "DEBUG") udf = response.get("response") if udf: udf_id = udf[0].get("id") except Exception as e: - error_message = "Exception occurred while getting Global User Defined Fields(UDF) ID from Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Exception occurred while getting Global User Defined Fields(UDF) ID from Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "ERROR") return udf_id @@ -2081,12 +2151,14 @@ def mandatory_parameter(self, device_to_add_in_ccc): if mandatory_params_absent: self.status = "failed" - self.msg = "Required parameters {0} for adding devices '{1}' are not present".format(str(mandatory_params_absent), str(device_to_add_in_ccc)) + self.msg = "Required parameters {0} for adding devices '{1}' are not present".format( + str(mandatory_params_absent), str(device_to_add_in_ccc)) self.result['msg'] = self.msg self.log(self.msg, "ERROR") else: self.status = "success" - self.msg = "Required parameters for adding the devices '{0}' to inventory are present.".format(str(device_to_add_in_ccc)) + self.msg = "Required parameters for adding the devices '{0}' to inventory are present.".format( + str(device_to_add_in_ccc)) self.log(self.msg, "INFO") return self @@ -2131,7 +2203,8 @@ def get_have(self, config): if support_for_provisioning_wireless: if self.config[0].get('provision_wireless_device'): - provision_wireless_list = self.config[0].get('provision_wireless_device') + provision_wireless_list = self.config[0].get( + 'provision_wireless_device') for prov_dict in provision_wireless_list: device_ip_address = prov_dict['device_ip'] @@ -2140,7 +2213,8 @@ def get_have(self, config): if device_ip_address not in device_in_dnac and device_ip_address not in device_not_in_dnac: device_not_in_dnac.append(device_ip_address) - self.log("Device(s) {0} exists in Cisco Catalyst Center".format(str(device_in_dnac)), "INFO") + self.log("Device(s) {0} exists in Cisco Catalyst Center".format( + str(device_in_dnac)), "INFO") have["want_device"] = want_device have["device_in_dnac"] = device_in_dnac have["device_not_in_dnac"] = device_not_in_dnac @@ -2230,7 +2304,8 @@ def get_device_ids(self, device_ips): ) if response: - self.log("Received API response from 'get_device_list': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_device_list': {0}".format( + str(response)), "DEBUG") response = response.get("response") if not response: continue @@ -2238,7 +2313,8 @@ def get_device_ids(self, device_ips): device_ids.append(device_id) except Exception as e: - error_message = "Error while fetching device '{0}' from Cisco Catalyst Center: {1}".format(device_ip, str(e)) + error_message = "Error while fetching device '{0}' from Cisco Catalyst Center: {1}".format( + device_ip, str(e)) self.log(error_message, "ERROR") return device_ids @@ -2266,14 +2342,16 @@ def get_device_ips_from_hostnames(self, hostnames): params={"hostname": hostname} ) if response: - self.log("Received API response from 'get_device_list': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_device_list': {0}".format( + str(response)), "DEBUG") response = response.get("response") if response: device_ip = response[0]["managementIpAddress"] if device_ip: device_ips.append(device_ip) except Exception as e: - error_message = "Exception occurred while fetching device from Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Exception occurred while fetching device from Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "ERROR") return device_ips @@ -2301,14 +2379,16 @@ def get_device_ips_from_serial_numbers(self, serial_numbers): params={"serialNumber": serial_number} ) if response: - self.log("Received API response from 'get_device_list': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_device_list': {0}".format( + str(response)), "DEBUG") response = response.get("response") if response: device_ip = response[0]["managementIpAddress"] if device_ip: device_ips.append(device_ip) except Exception as e: - error_message = "Exception occurred while fetching device from Cisco Catalyst Center - {0}".format(str(e)) + error_message = "Exception occurred while fetching device from Cisco Catalyst Center - {0}".format( + str(e)) self.log(error_message, "ERROR") return device_ips @@ -2336,14 +2416,16 @@ def get_device_ips_from_mac_addresses(self, mac_addresses): params={"macAddress": mac_address} ) if response: - self.log("Received API response from 'get_device_list': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_device_list': {0}".format( + str(response)), "DEBUG") response = response.get("response") if response: device_ip = response[0]["managementIpAddress"] if device_ip: device_ips.append(device_ip) except Exception as e: - error_message = "Exception occurred while fetching device from Cisco Catalyst Center - {0}".format(str(e)) + error_message = "Exception occurred while fetching device from Cisco Catalyst Center - {0}".format( + str(e)) self.log(error_message, "ERROR") return device_ips @@ -2374,7 +2456,8 @@ def get_interface_from_id_and_name(self, device_id, interface_name): op_modifies=True, params=interface_detail_params ) - self.log("Received API response from 'get_interface_details': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_interface_details': {0}".format( + str(response)), "DEBUG") response = response.get("response") if response: @@ -2386,7 +2469,8 @@ def get_interface_from_id_and_name(self, device_id, interface_name): except Exception as e: self.status = "failed" - self.msg = "Failed to retrieve interface ID for interface({0}) from Cisco Catalyst Center: {1}".format(interface_name, str(e)) + self.msg = "Failed to retrieve interface ID for interface({0}) from Cisco Catalyst Center: {1}".format( + interface_name, str(e)) self.log(self.msg, "ERROR") return self @@ -2411,16 +2495,19 @@ def get_interface_from_ip(self, device_ip): op_modifies=True, params={"ip_address": device_ip} ) - self.log("Received API response from 'get_interface_by_ip': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_interface_by_ip': {0}".format( + str(response)), "DEBUG") response = response.get("response") if response: interface_id = response[0]["id"] - self.log("Successfully retrieved Interface Id '{0}' for device '{1}'.".format(interface_id, device_ip), "DEBUG") + self.log("Successfully retrieved Interface Id '{0}' for device '{1}'.".format( + interface_id, device_ip), "DEBUG") return interface_id except Exception as e: - error_message = "Error while fetching Interface Id for device '{0}' from Cisco Catalyst Center: {1}".format(device_ip, str(e)) + error_message = "Error while fetching Interface Id for device '{0}' from Cisco Catalyst Center: {1}".format( + device_ip, str(e)) self.log(error_message, "ERROR") raise Exception(error_message) @@ -2447,7 +2534,8 @@ def get_device_response(self, device_ip): response = response.get('response')[0] except Exception as e: - error_message = "Error while getting the response of device from Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error while getting the response of device from Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "ERROR") raise Exception(error_message) @@ -2503,11 +2591,13 @@ def check_interface_details(self, device_ip, interface_name): op_modifies=True, params=interface_detail_params ) - self.log("Received API response from 'get_interface_details': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_interface_details': {0}".format( + str(response)), "DEBUG") response = response.get("response") if not response: - self.log("No response received from the API 'get_interface_details'.", "DEBUG") + self.log( + "No response received from the API 'get_interface_details'.", "DEBUG") return False response_params = { @@ -2517,7 +2607,8 @@ def check_interface_details(self, device_ip, interface_name): 'vlanId': int(response.get('vlanId')) } - interface_playbook_params = self.config[0].get('update_interface_details') + interface_playbook_params = self.config[0].get( + 'update_interface_details') playbook_params = { 'description': interface_playbook_params.get('description', ''), 'adminStatus': interface_playbook_params.get('admin_status'), @@ -2550,9 +2641,11 @@ def check_credential_update(self): device_uuids = self.get_device_ids(device_ips) password = "Testing@123" # Split the payload into 500 devices(by default) only to match the device credentials - device_batch_size = self.config[0].get("export_device_details_limit", 500) + device_batch_size = self.config[0].get( + "export_device_details_limit", 500) device_ids_list = device_uuids[0:device_batch_size] - payload_params = {"deviceUuids": device_ids_list, "password": password, "operationEnum": "0"} + payload_params = {"deviceUuids": device_ids_list, + "password": password, "operationEnum": "0"} response = self.trigger_export_api(payload_params) self.check_return_status() csv_reader = self.decrypt_and_read_csv(response, password) @@ -2606,7 +2699,8 @@ def get_provision_wired_device(self, device_ip): if response.get("status") == "success" and "Wired Provisioned device detail retrieved successfully." in response.get("description"): flag = 2 - self.log("Wired device '{0}' already provisioned in the Cisco Catalyst Center.".format(device_ip), "INFO") + self.log("Wired device '{0}' already provisioned in the Cisco Catalyst Center.".format( + device_ip), "INFO") except Exception as e: if "not provisioned to any site" in str(e): @@ -2647,7 +2741,8 @@ def clear_mac_address(self, interface_id, deploy_mode, interface_name): op_modifies=True, params=clear_mac_address_payload, ) - self.log("Received API response from 'clear_mac_address_table': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'clear_mac_address_table': {0}".format( + str(response)), "DEBUG") if not (response and isinstance(response, dict)): self.status = "failed" @@ -2666,9 +2761,11 @@ def clear_mac_address(self, interface_id, deploy_mode, interface_name): self.status = "failed" failure_reason = execution_details.get("failureReason") if failure_reason: - self.msg = "Failed to clear the Mac address table for the interface '{0}' due to {1}".format(interface_name, failure_reason) + self.msg = "Failed to clear the Mac address table for the interface '{0}' due to {1}".format( + interface_name, failure_reason) else: - self.msg = "Failed to clear the Mac address table for the interface '{0}'".format(interface_name) + self.msg = "Failed to clear the Mac address table for the interface '{0}'".format( + interface_name) self.log(self.msg, "ERROR") self.result['response'] = self.msg break @@ -2676,7 +2773,8 @@ def clear_mac_address(self, interface_id, deploy_mode, interface_name): self.status = "success" self.result['changed'] = True self.result['response'] = execution_details - self.msg = "Successfully executed the task of clearing the Mac address table for interface '{0}'".format(interface_name) + self.msg = "Successfully executed the task of clearing the Mac address table for interface '{0}'".format( + interface_name) self.log(self.msg, "INFO") break @@ -2712,7 +2810,8 @@ def update_interface_detail_of_device(self, device_to_update): interface_names_list = interface_params.get('interface_name') for interface_name in interface_names_list: device_id = self.get_device_ids([device_ip]) - interface_details = self.get_interface_from_id_and_name(device_id[0], interface_name) + interface_details = self.get_interface_from_id_and_name( + device_id[0], interface_name) # Check if interface_details is None or does not contain the 'id' key. if interface_details is None or not interface_details.get('id'): self.status = "failed" @@ -2727,8 +2826,10 @@ def update_interface_detail_of_device(self, device_to_update): # Now we call update interface details api with required parameter try: - interface_params = self.config[0].get('update_interface_details') - clear_mac_address_table = interface_params.get("clear_mac_address_table", False) + interface_params = self.config[0].get( + 'update_interface_details') + clear_mac_address_table = interface_params.get( + "clear_mac_address_table", False) if clear_mac_address_table: response = self.get_device_response(device_ip) @@ -2739,8 +2840,10 @@ def update_interface_detail_of_device(self, device_to_update): response_list.append(self.msg) self.result['changed'] = False else: - deploy_mode = interface_params.get('deployment_mode', 'Deploy') - self.clear_mac_address(interface_id, deploy_mode, interface_name).check_return_status() + deploy_mode = interface_params.get( + 'deployment_mode', 'Deploy') + self.clear_mac_address( + interface_id, deploy_mode, interface_name).check_return_status() temp_params = { 'description': interface_params.get('description', ''), @@ -2783,7 +2886,8 @@ def update_interface_detail_of_device(self, device_to_update): op_modifies=True, params=update_interface_params, ) - self.log("Received API response from 'update_interface_details': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'update_interface_details': {0}".format( + str(response)), "DEBUG") if response and isinstance(response, dict): response = response.get('response') @@ -2802,15 +2906,18 @@ def update_interface_detail_of_device(self, device_to_update): if 'SUCCESS' in execution_details.get("progress"): self.status = "success" is_update_occurred = True - self.msg = "Successfully updated the Interface Details for device '{0}'.".format(device_ip) + self.msg = "Successfully updated the Interface Details for device '{0}'.".format( + device_ip) response_list.append(self.msg) self.log(self.msg, "INFO") break elif execution_details.get("isError"): self.status = "failed" - failure_reason = execution_details.get("failureReason") + failure_reason = execution_details.get( + "failureReason") if failure_reason: - self.msg = "Interface Updation get failed because of {0}".format(failure_reason) + self.msg = "Interface Updation get failed because of {0}".format( + failure_reason) else: self.msg = "Interface Updation get failed" self.log(self.msg, "ERROR") @@ -2818,7 +2925,8 @@ def update_interface_detail_of_device(self, device_to_update): break except Exception as e: - error_message = "Error while updating interface details in Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error while updating interface details in Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "INFO") self.status = "success" self.result['changed'] = False @@ -2856,9 +2964,11 @@ def check_managementip_execution_response(self, response, device_ip, new_mgmt_ip self.status = "failed" failure_reason = execution_details.get("failureReason") if failure_reason: - self.msg = "Device new management IP updation for device '{0}' get failed due to {1}".format(device_ip, failure_reason) + self.msg = "Device new management IP updation for device '{0}' get failed due to {1}".format( + device_ip, failure_reason) else: - self.msg = "Device new management IP updation for device '{0}' get failed".format(device_ip) + self.msg = "Device new management IP updation for device '{0}' get failed".format( + device_ip) self.log(self.msg, "ERROR") break elif execution_details.get("endTime"): @@ -2897,15 +3007,18 @@ def check_device_update_execution_response(self, response, device_ip): self.status = "failed" failure_reason = execution_details.get("failureReason") if failure_reason: - self.msg = "Device Updation for device '{0}' get failed due to {1}".format(device_ip, failure_reason) + self.msg = "Device Updation for device '{0}' get failed due to {1}".format( + device_ip, failure_reason) else: - self.msg = "Device Updation for device '{0}' get failed".format(device_ip) + self.msg = "Device Updation for device '{0}' get failed".format( + device_ip) self.log(self.msg, "ERROR") self.result['response'] = self.msg self.check_return_status() break elif execution_details.get("endTime"): - self.log("Device '{0}' present in Cisco Catalyst Center and have been updated successfully.".format(device_ip), "INFO") + self.log("Device '{0}' present in Cisco Catalyst Center and have been updated successfully.".format( + device_ip), "INFO") break return self @@ -2934,13 +3047,15 @@ def is_device_exist_in_ccc(self, device_ip): ) response = response.get('response') if not response: - self.log("Device with given IP '{0}' is not present in Cisco Catalyst Center".format(device_ip), "INFO") + self.log("Device with given IP '{0}' is not present in Cisco Catalyst Center".format( + device_ip), "INFO") return False return True except Exception as e: - error_message = "Error while getting the response of device '{0}' from Cisco Catalyst Center: {1}".format(device_ip, str(e)) + error_message = "Error while getting the response of device '{0}' from Cisco Catalyst Center: {1}".format( + device_ip, str(e)) self.log(error_message, "ERROR") raise Exception(error_message) @@ -3038,7 +3153,8 @@ def get_diff_merged(self, config): return self if self.config[0].get('update_mgmt_ipaddresslist'): - device_ip = self.config[0].get('update_mgmt_ipaddresslist')[0].get('existMgmtIpAddress') + device_ip = self.config[0].get('update_mgmt_ipaddresslist')[ + 0].get('existMgmtIpAddress') is_device_exists = self.is_device_exist_in_ccc(device_ip) if not is_device_exists: @@ -3063,7 +3179,8 @@ def get_diff_merged(self, config): if self.config[0].get('role'): devices_to_update_role = self.get_device_ips_from_config_priority() - device_exist = self.is_device_exist_for_update(devices_to_update_role) + device_exist = self.is_device_exist_for_update( + devices_to_update_role) if not device_exist: self.msg = """Unable to update device role because the device(s) listed: {0} are not present in the Cisco @@ -3087,7 +3204,8 @@ def get_diff_merged(self, config): return self if not config['ip_address_list']: - self.msg = "Devices '{0}' already present in Cisco Catalyst Center".format(self.have['devices_in_playbook']) + self.msg = "Devices '{0}' already present in Cisco Catalyst Center".format( + self.have['devices_in_playbook']) self.log(self.msg, "INFO") self.result['changed'] = False self.result['response'] = self.msg @@ -3101,7 +3219,8 @@ def get_diff_merged(self, config): device_params['ipAddress'] = config['ip_address_list'] if device_params['snmpVersion'] == "v2": - params_to_remove = ["snmpAuthPassphrase", "snmpAuthProtocol", "snmpMode", "snmpPrivPassphrase", "snmpPrivProtocol", "snmpUserName"] + params_to_remove = ["snmpAuthPassphrase", "snmpAuthProtocol", + "snmpMode", "snmpPrivPassphrase", "snmpPrivProtocol", "snmpUserName"] for param in params_to_remove: device_params.pop(param, None) @@ -3136,7 +3255,8 @@ def get_diff_merged(self, config): device_params.pop('snmpPrivProtocol', None) device_to_add_in_ccc = device_params['ipAddress'] - self.mandatory_parameter(device_to_add_in_ccc).check_return_status() + self.mandatory_parameter( + device_to_add_in_ccc).check_return_status() try: response = self.dnac._exec( family="devices", @@ -3144,7 +3264,8 @@ def get_diff_merged(self, config): op_modifies=True, params=device_params, ) - self.log("Received API response from 'add_device': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'add_device': {0}".format( + str(response)), "DEBUG") if response and isinstance(response, dict): task_id = response.get('response').get('taskId') @@ -3158,19 +3279,23 @@ def get_diff_merged(self, config): if len(devices_to_add) > 0: self.result['changed'] = True - self.msg = "Device(s) '{0}' added to Cisco Catalyst Center".format(str(devices_to_add)) + self.msg = "Device(s) '{0}' added to Cisco Catalyst Center".format( + str(devices_to_add)) self.log(self.msg, "INFO") self.result['msg'] = self.msg break - self.msg = "Device(s) '{0}' already present in Cisco Catalyst Center".format(str(self.config[0].get("ip_address_list"))) + self.msg = "Device(s) '{0}' already present in Cisco Catalyst Center".format( + str(self.config[0].get("ip_address_list"))) self.log(self.msg, "INFO") self.result['msg'] = self.msg break elif execution_details.get("isError"): self.status = "failed" - failure_reason = execution_details.get("failureReason") + failure_reason = execution_details.get( + "failureReason") if failure_reason: - self.msg = "Device addition get failed because of {0}".format(failure_reason) + self.msg = "Device addition get failed because of {0}".format( + failure_reason) else: self.msg = "Device addition get failed" self.log(self.msg, "ERROR") @@ -3178,7 +3303,8 @@ def get_diff_merged(self, config): return self except Exception as e: - error_message = "Error while adding device in Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error while adding device in Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "ERROR") raise Exception(error_message) @@ -3204,7 +3330,8 @@ def get_diff_merged(self, config): self.status = "success" self.result['changed'] = False role_update_count += 1 - log_msg = "The device role '{0}' is already set in Cisco Catalyst Center, no update is needed.".format(device_role) + log_msg = "The device role '{0}' is already set in Cisco Catalyst Center, no update is needed.".format( + device_role) self.log(log_msg, "INFO") continue @@ -3221,7 +3348,8 @@ def get_diff_merged(self, config): op_modifies=True, params=device_role_params, ) - self.log("Received API response from 'update_device_role': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'update_device_role': {0}".format( + str(response)), "DEBUG") if response and isinstance(response, dict): task_id = response.get('response').get('taskId') @@ -3232,14 +3360,17 @@ def get_diff_merged(self, config): if 'successfully' in progress or 'succesfully' in progress: self.status = "success" - self.log("Device '{0}' role updated successfully to '{1}'".format(device_ip, device_role), "INFO") + self.log("Device '{0}' role updated successfully to '{1}'".format( + device_ip, device_role), "INFO") role_updated_list.append(device_ip) break elif execution_details.get("isError"): self.status = "failed" - failure_reason = execution_details.get("failureReason") + failure_reason = execution_details.get( + "failureReason") if failure_reason: - self.msg = "Device role updation get failed because of {0}".format(failure_reason) + self.msg = "Device role updation get failed because of {0}".format( + failure_reason) else: self.msg = "Device role updation get failed" self.log(self.msg, "ERROR") @@ -3247,7 +3378,8 @@ def get_diff_merged(self, config): break except Exception as e: - error_message = "Error while updating device role '{0}' in Cisco Catalyst Center: {1}".format(device_role, str(e)) + error_message = "Error while updating device role '{0}' in Cisco Catalyst Center: {1}".format( + device_role, str(e)) self.log(error_message, "ERROR") if role_update_count == len(devices_to_update_role): @@ -3261,7 +3393,8 @@ def get_diff_merged(self, config): if role_updated_list: self.status = "success" self.result['changed'] = True - self.msg = "Device(s) '{0}' role updated successfully to '{1}'".format(str(role_updated_list), device_role) + self.msg = "Device(s) '{0}' role updated successfully to '{1}'".format( + str(role_updated_list), device_role) self.result['response'] = self.msg self.log(self.msg, "INFO") @@ -3270,21 +3403,25 @@ def get_diff_merged(self, config): # Update Device details and credentails device_uuids = self.get_device_ids(device_to_update) password = "Testing@123" - export_payload = {"deviceUuids": device_uuids, "password": password, "operationEnum": "0"} + export_payload = {"deviceUuids": device_uuids, + "password": password, "operationEnum": "0"} export_response = self.trigger_export_api(export_payload) self.check_return_status() csv_reader = self.decrypt_and_read_csv(export_response, password) self.check_return_status() device_details = {} start = 0 - device_batch_size = self.config[0].get("export_device_details_limit", 500) + device_batch_size = self.config[0].get( + "export_device_details_limit", 500) while start < len(device_uuids): device_ids_list = device_uuids[start:start + device_batch_size] - export_payload = {"deviceUuids": device_ids_list, "password": password, "operationEnum": "0"} + export_payload = {"deviceUuids": device_ids_list, + "password": password, "operationEnum": "0"} export_response = self.trigger_export_api(export_payload) self.check_return_status() - csv_reader = self.decrypt_and_read_csv(export_response, password) + csv_reader = self.decrypt_and_read_csv( + export_response, password) self.check_return_status() for row in csv_reader: @@ -3339,7 +3476,8 @@ def get_diff_merged(self, config): 'snmp_username': 'snmpUserName', 'netconf_port': 'netconfPort' } - device_update_key_list = ["username", "password", "enable_password", "snmp_username", "netconf_port"] + device_update_key_list = [ + "username", "password", "enable_password", "snmp_username", "netconf_port"] for key in device_update_key_list: mapped_key = device_key_mapping[key] @@ -3385,21 +3523,27 @@ def get_diff_merged(self, config): playbook_params['snmpVersion'] = "v2" if playbook_params['snmpVersion'] == 'v2': - params_to_remove = ["snmpAuthPassphrase", "snmpAuthProtocol", "snmpMode", "snmpPrivPassphrase", "snmpPrivProtocol", "snmpUserName"] + params_to_remove = ["snmpAuthPassphrase", "snmpAuthProtocol", + "snmpMode", "snmpPrivPassphrase", "snmpPrivProtocol", "snmpUserName"] for param in params_to_remove: playbook_params.pop(param, None) if not playbook_params['snmpROCommunity']: - playbook_params['snmpROCommunity'] = device_data.get('snmp_community', None) + playbook_params['snmpROCommunity'] = device_data.get( + 'snmp_community', None) if not playbook_params['snmpRWCommunity']: - playbook_params['snmpRWCommunity'] = device_data.get('snmp_write_community', None) + playbook_params['snmpRWCommunity'] = device_data.get( + 'snmp_write_community', None) if not playbook_params['httpUserName']: - playbook_params['httpUserName'] = device_data.get('http_config_username', None) + playbook_params['httpUserName'] = device_data.get( + 'http_config_username', None) if not playbook_params['httpPassword']: - playbook_params['httpPassword'] = device_data.get('http_config_password', None) + playbook_params['httpPassword'] = device_data.get( + 'http_config_password', None) if not playbook_params['httpPort']: - playbook_params['httpPort'] = device_data.get('http_port', None) + playbook_params['httpPort'] = device_data.get( + 'http_port', None) for key, value in playbook_params.items(): if value == " ": @@ -3410,54 +3554,64 @@ def get_diff_merged(self, config): new_mgmt_ipaddress = playbook_params['updateMgmtIPaddressList'][0]['newMgmtIpAddress'] if new_mgmt_ipaddress in self.have['device_in_dnac']: self.status = "failed" - self.msg = "Device with IP address '{0}' already exists in inventory".format(new_mgmt_ipaddress) + self.msg = "Device with IP address '{0}' already exists in inventory".format( + new_mgmt_ipaddress) self.log(self.msg, "ERROR") self.result['response'] = self.msg else: - self.log("Playbook parameter for updating device new management ip address: {0}".format(str(playbook_params)), "DEBUG") + self.log("Playbook parameter for updating device new management ip address: {0}".format( + str(playbook_params)), "DEBUG") response = self.dnac._exec( family="devices", function='sync_devices', op_modifies=True, params=playbook_params, ) - self.log("Received API response from 'sync_devices': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'sync_devices': {0}".format( + str(response)), "DEBUG") if response and isinstance(response, dict): - self.check_managementip_execution_response(response, device_ip, new_mgmt_ipaddress) + self.check_managementip_execution_response( + response, device_ip, new_mgmt_ipaddress) self.check_return_status() else: - self.log("Playbook parameter for updating devices: {0}".format(str(playbook_params)), "DEBUG") + self.log("Playbook parameter for updating devices: {0}".format( + str(playbook_params)), "DEBUG") response = self.dnac._exec( family="devices", function='sync_devices', op_modifies=True, params=playbook_params, ) - self.log("Received API response from 'sync_devices': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'sync_devices': {0}".format( + str(response)), "DEBUG") if response and isinstance(response, dict): - self.check_device_update_execution_response(response, device_ip) + self.check_device_update_execution_response( + response, device_ip) update_device_ips.append(device_ip) self.check_return_status() except Exception as e: - error_message = "Error while updating device in Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error while updating device in Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "ERROR") raise Exception(error_message) if update_device_ips: self.status = "success" self.result['changed'] = True - self.msg = "Device(s) '{0}' present in Cisco Catalyst Center and have been updated successfully.".format(str(update_device_ips)) + self.msg = "Device(s) '{0}' present in Cisco Catalyst Center and have been updated successfully.".format( + str(update_device_ips)) self.result['response'] = self.msg self.log(self.msg, "INFO") # Update list of interface details on specific or list of devices. if self.config[0].get('update_interface_details'): device_to_update = self.get_device_ips_from_config_priority() - self.update_interface_detail_of_device(device_to_update).check_return_status() + self.update_interface_detail_of_device( + device_to_update).check_return_status() # If User defined field(UDF) not present then create it and add multiple udf to specific or list of devices if self.config[0].get('add_user_defined_field'): @@ -3478,7 +3632,8 @@ def get_diff_merged(self, config): if not udf_exist: # Create the Global UDF - self.log("Global User Defined Field '{0}' does not present in Cisco Catalyst Center, we need to create it".format(field_name), "DEBUG") + self.log("Global User Defined Field '{0}' does not present in Cisco Catalyst Center, we need to create it".format( + field_name), "DEBUG") self.create_user_defined_field(udf).check_return_status() # Get device Id based on config priority @@ -3494,10 +3649,12 @@ def get_diff_merged(self, config): return self # Now add code for adding Global UDF to device with Id - self.add_field_to_devices(device_ids, udf).check_return_status() + self.add_field_to_devices( + device_ids, udf).check_return_status() self.result['changed'] = True - self.msg = "Global User Defined Field(UDF) named '{0}' has been successfully added to the device.".format(field_name) + self.msg = "Global User Defined Field(UDF) named '{0}' has been successfully added to the device.".format( + field_name) self.log(self.msg, "INFO") # Once Wired device get added we will assign device to site and Provisioned it @@ -3546,7 +3703,8 @@ def get_diff_deleted(self, config): if udf_id is None: self.status = "success" - self.msg = "Global UDF '{0}' is not present in Cisco Catalyst Center".format(field_name) + self.msg = "Global UDF '{0}' is not present in Cisco Catalyst Center".format( + field_name) self.log(self.msg, "INFO") self.result['changed'] = False self.result['msg'] = self.msg @@ -3561,7 +3719,8 @@ def get_diff_deleted(self, config): params={"id": udf_id}, ) if response and isinstance(response, dict): - self.log("Received API response from 'delete_user_defined_field': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'delete_user_defined_field': {0}".format( + str(response)), "DEBUG") task_id = response.get('response').get('taskId') while True: @@ -3569,16 +3728,19 @@ def get_diff_deleted(self, config): if 'success' in execution_details.get("progress"): self.status = "success" - self.msg = "Global UDF '{0}' deleted successfully from Cisco Catalyst Center".format(field_name) + self.msg = "Global UDF '{0}' deleted successfully from Cisco Catalyst Center".format( + field_name) self.log(self.msg, "INFO") self.result['changed'] = True self.result['response'] = execution_details break elif execution_details.get("isError"): self.status = "failed" - failure_reason = execution_details.get("failureReason") + failure_reason = execution_details.get( + "failureReason") if failure_reason: - self.msg = "Failed to delete Global User Defined Field(UDF) due to: {0}".format(failure_reason) + self.msg = "Failed to delete Global User Defined Field(UDF) due to: {0}".format( + failure_reason) else: self.msg = "Global UDF deletion get failed." self.log(self.msg, "ERROR") @@ -3586,7 +3748,8 @@ def get_diff_deleted(self, config): break except Exception as e: - error_message = "Error while deleting Global UDF from Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error while deleting Global UDF from Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "ERROR") raise Exception(error_message) @@ -3596,7 +3759,8 @@ def get_diff_deleted(self, config): if device_ip not in self.have.get("device_in_dnac"): self.status = "success" self.result['changed'] = False - self.msg = "Device '{0}' is not present in Cisco Catalyst Center so can't perform delete operation".format(device_ip) + self.msg = "Device '{0}' is not present in Cisco Catalyst Center so can't perform delete operation".format( + device_ip) self.result['msg'].append(self.msg) self.result['response'] = self.msg self.log(self.msg, "INFO") @@ -3623,7 +3787,8 @@ def get_diff_deleted(self, config): executionid = response.get("executionId") while True: - execution_details = self.get_execution_details(executionid) + execution_details = self.get_execution_details( + executionid) if execution_details.get("status") == "SUCCESS": self.result['changed'] = True self.msg = execution_details.get("bapiName") @@ -3656,18 +3821,22 @@ def get_diff_deleted(self, config): if 'success' in execution_details.get("progress"): self.status = "success" - self.msg = "Device '{0}' was successfully deleted from Cisco Catalyst Center".format(device_ip) + self.msg = "Device '{0}' was successfully deleted from Cisco Catalyst Center".format( + device_ip) self.log(self.msg, "INFO") self.result['changed'] = True self.result['response'] = execution_details break elif execution_details.get("isError"): self.status = "failed" - failure_reason = execution_details.get("failureReason") + failure_reason = execution_details.get( + "failureReason") if failure_reason: - self.msg = "Device '{0}' deletion get failed due to: {1}".format(device_ip, failure_reason) + self.msg = "Device '{0}' deletion get failed due to: {1}".format( + device_ip, failure_reason) else: - self.msg = "Device '{0}' deletion get failed.".format(device_ip) + self.msg = "Device '{0}' deletion get failed.".format( + device_ip) self.log(self.msg, "ERROR") self.result['response'] = self.msg break @@ -3717,7 +3886,8 @@ def verify_diff_merged(self, config): if self.config[0].get('update_interface_details'): interface_update_flag = True - interface_names_list = self.config[0].get('update_interface_details').get('interface_name') + interface_names_list = self.config[0].get( + 'update_interface_details').get('interface_name') for device_ip in device_ips: for interface_name in interface_names_list: @@ -3727,7 +3897,8 @@ def verify_diff_merged(self, config): if interface_update_flag: self.status = "success" - msg = "Interface details updated and verified successfully for devices {0}.".format(device_ips) + msg = "Interface details updated and verified successfully for devices {0}.".format( + device_ips) self.log(msg, "INFO") else: self.log("""Playbook's input does not match with Cisco Catalyst Center, indicating that the update @@ -3741,7 +3912,8 @@ def verify_diff_merged(self, config): msg = "Device credentials and details updated and verified successfully in Cisco Catalyst Center." self.log(msg, "INFO") else: - self.log("Playbook parameter does not match with Cisco Catalyst Center, meaning device updation task not executed properly.", "INFO") + self.log( + "Playbook parameter does not match with Cisco Catalyst Center, meaning device updation task not executed properly.", "INFO") elif device_type != "NETWORK_DEVICE": self.log("""Unable to compare the parameter for device type '{0}' in the playbook with the one in Cisco Catalyst Center.""" .format(device_type), "WARNING") @@ -3754,7 +3926,8 @@ def verify_diff_merged(self, config): if udf_exist: self.status = "success" - msg = "Global UDF {0} created and verified successfully".format(field_name) + msg = "Global UDF {0} created and verified successfully".format( + field_name) self.log(msg, "INFO") else: self.log("""Mismatch between playbook parameter and Cisco Catalyst Center detected, indicating that @@ -3791,7 +3964,8 @@ def verify_diff_merged(self, config): if provision_wired_flag: self.status = "success" - msg = "Wired devices {0} get provisioned and verified successfully.".format(provision_device_list) + msg = "Wired devices {0} get provisioned and verified successfully.".format( + provision_device_list) self.log(msg, "INFO") else: self.log("""Mismatch between playbook's input and Cisco Catalyst Center detected, indicating that @@ -3840,7 +4014,8 @@ def verify_diff_deleted(self, config): if device_delete_flag: self.status = "success" - self.msg = "Requested device(s) '{0}' deleted from Cisco Catalyst Center and the deletion has been verified.".format(str(input_devices)) + self.msg = "Requested device(s) '{0}' deleted from Cisco Catalyst Center and the deletion has been verified.".format( + str(input_devices)) self.log(self.msg, "INFO") else: self.log("""Mismatch between playbook parameter device({0}) and Cisco Catalyst Center detected, indicating that @@ -3892,7 +4067,8 @@ def main(): dnac_device.get_have(config).check_return_status() dnac_device.get_diff_state_apply[state](config).check_return_status() if config_verify: - dnac_device.verify_diff_state_apply[state](config).check_return_status() + dnac_device.verify_diff_state_apply[state]( + config).check_return_status() module.exit_json(**dnac_device.result) diff --git a/plugins/modules/inventory_workflow_manager.py b/plugins/modules/inventory_workflow_manager.py index 3a49eac709..0e68747eef 100644 --- a/plugins/modules/inventory_workflow_manager.py +++ b/plugins/modules/inventory_workflow_manager.py @@ -5,9 +5,19 @@ # 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 +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, +) +from ansible.module_utils.basic import AnsibleModule +from io import BytesIO, StringIO +from datetime import datetime +import time +import csv __metaclass__ = type -__author__ = ("Madhan Sankaranarayanan, Abhishek Maheshwari, Syed Khadeer Ahmed, Ajith Andrew J") +__author__ = ( + "Madhan Sankaranarayanan, Abhishek Maheshwari, Syed Khadeer Ahmed, Ajith Andrew J") DOCUMENTATION = r""" --- @@ -723,15 +733,6 @@ HAS_PYZIPPER = False pyzipper = None -import csv -import time -from datetime import datetime -from io import BytesIO, StringIO -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, -) # Defer this feature as API issue is there once it's fixed we will addresses it in upcoming release iac2.0 support_for_provisioning_wireless = False @@ -844,14 +845,16 @@ def validate_input(self): ) if invalid_params: - self.msg = "Invalid parameters in playbook: {0}".format(invalid_params) + self.msg = "Invalid parameters in playbook: {0}".format( + invalid_params) self.log(self.msg, "ERROR") self.status = "failed" self.result['response'] = self.msg return self self.validated_config = valid_temp - self.msg = "Successfully validated playbook configuration parameters using 'validate_input': {0}".format(str(valid_temp)) + self.msg = "Successfully validated playbook configuration parameters using 'validate_input': {0}".format( + str(valid_temp)) self.log(self.msg, "INFO") self.status = "success" @@ -879,19 +882,22 @@ def get_device_ips_from_config_priority(self): # If device IPs are not available, check hostnames device_hostnames = self.config[0].get("hostname_list") if device_hostnames: - device_ip_dict = self.get_device_ips_from_hostnames(device_hostnames) + device_ip_dict = self.get_device_ips_from_hostnames( + device_hostnames) return self.get_list_from_dict_values(device_ip_dict) # If hostnames are not available, check serial numbers device_serial_numbers = self.config[0].get("serial_number_list") if device_serial_numbers: - device_ip_dict = self.get_device_ips_from_serial_numbers(device_serial_numbers) + device_ip_dict = self.get_device_ips_from_serial_numbers( + device_serial_numbers) return self.get_list_from_dict_values(device_ip_dict) # If serial numbers are not available, check MAC addresses device_mac_addresses = self.config[0].get("mac_address_list") if device_mac_addresses: - device_ip_dict = self.get_device_ips_from_mac_addresses(device_mac_addresses) + device_ip_dict = self.get_device_ips_from_mac_addresses( + device_mac_addresses) return self.get_list_from_dict_values(device_ip_dict) # If no information is available, return an empty list @@ -935,10 +941,12 @@ def get_existing_devices_in_ccc(self): function='get_device_list', ) offset = offset + 1 - self.log("Received API response from 'get_device_list': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_device_list': {0}".format( + str(response)), "DEBUG") response = response.get("response") if not response: - self.log("There are no device details received from 'get_device_list' API.", "INFO") + self.log( + "There are no device details received from 'get_device_list' API.", "INFO") break for ip in response: device_ip = ip["managementIpAddress"] @@ -946,12 +954,14 @@ def get_existing_devices_in_ccc(self): except Exception as e: self.status = "failed" - self.msg = "Error while fetching device details from Cisco Catalyst Center: {0}".format(str(e)) + self.msg = "Error while fetching device details from Cisco Catalyst Center: {0}".format( + str(e)) self.log(self.msg, "CRITICAL") self.result['response'] = self.msg self.check_return_status() - self.log("Devices present in Cisco Catalyst Center: {0}".format(str(existing_devices_in_ccc)), "DEBUG") + self.log("Devices present in Cisco Catalyst Center: {0}".format( + str(existing_devices_in_ccc)), "DEBUG") existing_devices_in_ccc = list(existing_devices_in_ccc) return existing_devices_in_ccc @@ -977,13 +987,15 @@ def is_udf_exist(self, field_name): params={"name": field_name}, ) - self.log("Received API response from 'get_all_user_defined_fields': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_all_user_defined_fields': {0}".format( + str(response)), "DEBUG") udf = response.get("response") if (len(udf) == 1): return True - message = "Global User Defined Field with name '{0}' doesnot exist in Cisco Catalyst Center".format(field_name) + message = "Global User Defined Field with name '{0}' doesnot exist in Cisco Catalyst Center".format( + field_name) self.log(message, "INFO") return False @@ -1007,14 +1019,17 @@ def create_user_defined_field(self, udf): op_modifies=True, params=udf, ) - self.log("Received API response from 'create_user_defined_field': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'create_user_defined_field': {0}".format( + str(response)), "DEBUG") response = response.get("response") field_name = udf.get('name') - self.log("Global User Defined Field with name '{0}' created successfully".format(field_name), "INFO") + self.log("Global User Defined Field with name '{0}' created successfully".format( + field_name), "INFO") self.status = "success" except Exception as e: - error_message = "Error while creating Global UDF(User Defined Field) in Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error while creating Global UDF(User Defined Field) in Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "ERROR") return self @@ -1050,14 +1065,16 @@ def add_field_to_devices(self, device_ids, udf): op_modifies=True, params=udf_param_dict, ) - self.log("Received API response from 'add_user_defined_field_to_device': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'add_user_defined_field_to_device': {0}".format( + str(response)), "DEBUG") response = response.get("response") self.status = "success" self.result['changed'] = True except Exception as e: self.status = "failed" - error_message = "Error while adding Global UDF to device in Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error while adding Global UDF to device in Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "ERROR") self.result['changed'] = False @@ -1083,7 +1100,8 @@ def trigger_export_api(self, payload_params): op_modifies=True, params=payload_params, ) - self.log("Received API response from 'export_device_list': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'export_device_list': {0}".format( + str(response)), "DEBUG") response = response.get("response") task_id = response.get("taskId") @@ -1091,13 +1109,15 @@ def trigger_export_api(self, payload_params): execution_details = self.get_task_details(task_id) if execution_details.get("additionalStatusURL"): - file_id = execution_details.get("additionalStatusURL").split("/")[-1] + file_id = execution_details.get( + "additionalStatusURL").split("/")[-1] break elif execution_details.get("isError"): self.status = "failed" failure_reason = execution_details.get("failureReason") if failure_reason: - self.msg = "Could not get the File ID because of {0} so can't export device details in csv file".format(failure_reason) + self.msg = "Could not get the File ID because of {0} so can't export device details in csv file".format( + failure_reason) else: self.msg = "Could not get the File ID so can't export device details in csv file" self.log(self.msg, "ERROR") @@ -1112,7 +1132,8 @@ def trigger_export_api(self, payload_params): op_modifies=True, params={"file_id": file_id}, ) - self.log("Received API response from 'download_a_file_by_fileid': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'download_a_file_by_fileid': {0}".format( + str(response)), "DEBUG") return response @@ -1149,10 +1170,12 @@ def decrypt_and_read_csv(self, response, password): try: encryption_method = encryption_dict.get(snmp_protocol) except Exception as e: - self.log("Given SNMP protcol '{0}' not present".format(snmp_protocol), "WARNING") + self.log("Given SNMP protcol '{0}' not present".format( + snmp_protocol), "WARNING") if not encryption_method: - self.msg = "Invalid SNMP protocol '{0}' specified for encryption.".format(snmp_protocol) + self.msg = "Invalid SNMP protocol '{0}' specified for encryption.".format( + snmp_protocol) self.log(self.msg, "ERROR") self.status = "failed" self.result['response'] = self.msg @@ -1164,14 +1187,16 @@ def decrypt_and_read_csv(self, response, password): file_name = zip_ref.namelist()[0] # Extract the content of the file with the provided password - file_content_binary = zip_ref.read(file_name, pwd=password.encode('utf-8')) + file_content_binary = zip_ref.read( + file_name, pwd=password.encode('utf-8')) # Now 'file_content_binary' contains the binary content of the decrypted file # Since the content is text, so we can decode it file_content_text = file_content_binary.decode('utf-8') # Now 'file_content_text' contains the text content of the decrypted file - self.log("Text content of decrypted file: {0}".format(file_content_text), "DEBUG") + self.log("Text content of decrypted file: {0}".format( + file_content_text), "DEBUG") # Parse the CSV-like string into a list of dictionaries csv_reader = csv.DictReader(StringIO(file_content_text)) @@ -1220,7 +1245,8 @@ def export_device_details(self): self.status = "failed" detailed_msg = """Invalid password. Min password length is 8 and it should contain atleast one lower case letter, one uppercase letter, one digit and one special characters from -=\\;,./~!@#$%^&*()_+{}[]|:?""" - formatted_msg = ' '.join(line.strip() for line in detailed_msg.splitlines()) + formatted_msg = ' '.join(line.strip() + for line in detailed_msg.splitlines()) self.msg = formatted_msg self.log(formatted_msg, "INFO") self.result['response'] = self.msg @@ -1228,7 +1254,8 @@ def export_device_details(self): # Export the device data in a batch of 500 devices at a time by default start = 0 - device_batch_size = self.config[0].get("export_device_details_limit", 500) + device_batch_size = self.config[0].get( + "export_device_details_limit", 500) device_data = [] first_run = True @@ -1247,19 +1274,22 @@ def export_device_details(self): if payload_params["operationEnum"] == "0": temp_file_name = response.filename if first_run: - output_file_name = temp_file_name.split(".")[0] + ".csv" + output_file_name = temp_file_name.split(".")[ + 0] + ".csv" csv_reader = self.decrypt_and_read_csv(response, password) self.check_return_status() else: decoded_resp = response.data.decode(encoding='utf-8') - self.log("Decoded response of Export Device Credential file: {0}".format(str(decoded_resp)), "DEBUG") + self.log("Decoded response of Export Device Credential file: {0}".format( + str(decoded_resp)), "DEBUG") # Parse the CSV-like string into a list of dictionaries csv_reader = csv.DictReader(StringIO(decoded_resp)) current_date = datetime.now() formatted_date = current_date.strftime("%m-%d-%Y") if first_run: - output_file_name = "devices-" + str(formatted_date) + ".csv" + output_file_name = "devices-" + \ + str(formatted_date) + ".csv" for row in csv_reader: device_data.append(row) @@ -1273,7 +1303,8 @@ def export_device_details(self): csv_writer.writeheader() csv_writer.writerows(device_data) - self.msg = "Device Details Exported Successfully to the CSV file: {0}".format(output_file_name) + self.msg = "Device Details Exported Successfully to the CSV file: {0}".format( + output_file_name) self.output_file_name.append(output_file_name) self.log(self.msg, "INFO") self.status = "success" @@ -1281,7 +1312,8 @@ def export_device_details(self): self.result['response'] = self.msg except Exception as e: - self.msg = "Error while exporting device details into CSV file for device(s): '{0}'".format(str(device_ips)) + self.msg = "Error while exporting device details into CSV file for device(s): '{0}'".format( + str(device_ips)) self.log(self.msg, "ERROR") self.status = "failed" @@ -1309,13 +1341,15 @@ def get_ap_devices(self, device_ips): op_modifies=True, params={"managementIpAddress": device_ip} ) - self.log("Received API response from 'get_device_list': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_device_list': {0}".format( + str(response)), "DEBUG") response = response.get('response', []) if response and response[0].get('family', '') == "Unified AP": ap_device_list.append(device_ip) except Exception as e: - error_message = "Error while getting the response of device from Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error while getting the response of device from Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "CRITICAL") raise Exception(error_message) @@ -1344,15 +1378,18 @@ def resync_devices(self): input_device_ips.remove(device_ip) ap_devices = self.get_ap_devices(input_device_ips) - self.log("AP Devices from the playbook input are: {0}".format(str(ap_devices)), "INFO") + self.log("AP Devices from the playbook input are: {0}".format( + str(ap_devices)), "INFO") if ap_devices: for ap_ip in ap_devices: input_device_ips.remove(ap_ip) - self.log("Following devices {0} are AP, so can't perform resync operation.".format(str(ap_devices)), "WARNING") + self.log("Following devices {0} are AP, so can't perform resync operation.".format( + str(ap_devices)), "WARNING") if not input_device_ips: - self.msg = "Cannot perform the Resync operation as the device(s) with IP(s) {0} are not present in Cisco Catalyst Center".format(str(device_ips)) + self.msg = "Cannot perform the Resync operation as the device(s) with IP(s) {0} are not present in Cisco Catalyst Center".format( + str(device_ips)) self.status = "success" self.result['changed'] = False self.result['response'] = self.msg @@ -1365,30 +1402,35 @@ def resync_devices(self): # Resync the device in a batch of 200 devices at a time in inventory by default start = 0 resync_failed_for_all_device = False - resync_device_count = self.config[0].get("resync_device_count", 200) + resync_device_count = self.config[0].get( + "resync_device_count", 200) resync_successful_devices, resync_failed_devices = [], [] force_sync = self.config[0].get("force_sync", False) resync_task_dict = {} while start < len(device_ids): device_ids_list = device_ids[start:start + resync_device_count] - device_ips_list = input_device_ips[start:start + resync_device_count] + device_ips_list = input_device_ips[start:start + + resync_device_count] resync_param_dict = { 'payload': device_ids_list, 'force_sync': force_sync } - self.log("Request payload for reysnc Device having the device ids: {0}".format(device_ids_list), "INFO") + self.log("Request payload for reysnc Device having the device ids: {0}".format( + device_ids_list), "INFO") response = self.dnac._exec( family="devices", function='sync_devices_using_forcesync', op_modifies=True, params=resync_param_dict, ) - self.log("Received API response from 'sync_devices_using_forcesync': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'sync_devices_using_forcesync': {0}".format( + str(response)), "DEBUG") if not response or not isinstance(response, dict): self.status = "failed" - self.msg = "Unable to resync the device(s) {0} in the inventory as response is empty.".format(device_ips_list) + self.msg = "Unable to resync the device(s) {0} in the inventory as response is empty.".format( + device_ips_list) self.log(self.msg, "ERROR") self.result['response'] = self.msg return self @@ -1426,7 +1468,8 @@ def resync_devices(self): ).format(resync_successful_devices, resync_failed_devices) elif resync_failed_devices: resync_failed_for_all_device = True - self.msg = "Device resynced get failed for all given device(s) '{0}'.".format(resync_failed_devices) + self.msg = "Device resynced get failed for all given device(s) '{0}'.".format( + resync_failed_devices) else: self.msg = ( "Device(s) '{0}' have been successfully resynced in the inventory in Cisco Catalyst Center. " @@ -1443,7 +1486,8 @@ def resync_devices(self): except Exception as e: self.status = "failed" - error_message = "Error while resyncing device in Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error while resyncing device in Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "ERROR") return self @@ -1466,7 +1510,8 @@ def reboot_access_points(self): if input_device_ips: ap_devices = self.get_ap_devices(input_device_ips) - self.log("AP Devices from the playbook input are: {0}".format(str(ap_devices)), "INFO") + self.log("AP Devices from the playbook input are: {0}".format( + str(ap_devices)), "INFO") for device_ip in input_device_ips: if device_ip not in ap_devices: input_device_ips.remove(device_ip) @@ -1488,7 +1533,8 @@ def reboot_access_points(self): op_modifies=True, params={"managementIpAddress": device_ip} ) - self.log("Received API response from 'get_device_list': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_device_list': {0}".format( + str(response)), "DEBUG") response = response.get('response') if not response: continue @@ -1517,7 +1563,8 @@ def reboot_access_points(self): op_modifies=True, params=reboot_params, ) - self.log("Received API response from 'reboot_access_points': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'reboot_access_points': {0}".format( + str(response)), "DEBUG") if response and isinstance(response, dict): task_id = response.get('response').get('taskId') @@ -1529,14 +1576,16 @@ def reboot_access_points(self): self.status = "success" self.result['changed'] = True self.result['response'] = execution_details - self.msg = "AP Device(s) {0} successfully rebooted!".format(str(input_device_ips)) + self.msg = "AP Device(s) {0} successfully rebooted!".format( + str(input_device_ips)) self.log(self.msg, "INFO") break elif execution_details.get("isError"): self.status = "failed" failure_reason = execution_details.get("failureReason") if failure_reason: - self.msg = "AP Device Rebooting get failed because of {0}".format(failure_reason) + self.msg = "AP Device Rebooting get failed because of {0}".format( + failure_reason) else: self.msg = "AP Device Rebooting get failed" self.log(self.msg, "ERROR") @@ -1561,10 +1610,12 @@ def handle_successful_provisioning(self, device_ip, execution_details, device_ty self.status = "success" self.result['changed'] = True - self.log("{0} Device {1} provisioned successfully!!".format(device_type, device_ip), "INFO") + self.log("{0} Device {1} provisioned successfully!!".format( + device_type, device_ip), "INFO") self.provisioned_device.append(device_ip) devices = self.provisioned_device - self.msg = "{0} Device(s) {1} provisioned successfully!!".format(device_type, devices) + self.msg = "{0} Device(s) {1} provisioned successfully!!".format( + device_type, devices) self.result['response'] = self.msg def handle_failed_provisioning(self, device_ip, execution_details, device_type): @@ -1582,8 +1633,10 @@ def handle_failed_provisioning(self, device_ip, execution_details, device_type): """ self.status = "failed" - failure_reason = execution_details.get("failureReason", "Unknown failure reason") - self.msg = "{0} Device Provisioning failed for {1} because of {2}".format(device_type, device_ip, failure_reason) + failure_reason = execution_details.get( + "failureReason", "Unknown failure reason") + self.msg = "{0} Device Provisioning failed for {1} because of {2}".format( + device_type, device_ip, failure_reason) self.log(self.msg, "WARNING") self.result['response'] = self.msg @@ -1601,7 +1654,8 @@ def handle_provisioning_exception(self, device_ip, exception, device_type): This method logs an error message indicating an exception occurred during the provisioning process for a device. """ - error_message = "Error while Provisioning the {0} device {1} in Cisco Catalyst Center: {2}".format(device_type, device_ip, str(exception)) + error_message = "Error while Provisioning the {0} device {1} in Cisco Catalyst Center: {2}".format( + device_type, device_ip, str(exception)) self.log(error_message, "ERROR") def handle_all_already_provisioned(self, device_ips, device_type): @@ -1617,7 +1671,8 @@ def handle_all_already_provisioned(self, device_ips, device_type): """ self.status = "success" - self.msg = "All the {0} Devices '{1}' given in the playbook are already Provisioned".format(device_type, str(device_ips)) + self.msg = "All the {0} Devices '{1}' given in the playbook are already Provisioned".format( + device_type, str(device_ips)) self.log(self.msg, "INFO") self.result['response'] = self.msg self.result['changed'] = False @@ -1636,7 +1691,8 @@ def handle_all_provisioned(self, device_type): self.status = "success" self.result['changed'] = True - self.msg = ("All {0} Devices provisioned successfully!!".format(device_type), "INFO") + self.msg = ("All {0} Devices provisioned successfully!!".format( + device_type), "INFO") self.log(self.msg, "INFO") self.result['response'] = self.msg @@ -1654,7 +1710,8 @@ def handle_all_failed_provision(self, device_type): """ self.status = "failed" - self.msg = "{0} Device Provisioning failed for all devices".format(device_type) + self.msg = "{0} Device Provisioning failed for all devices".format( + device_type) self.log(self.msg, "INFO") self.result['response'] = self.msg @@ -1674,7 +1731,8 @@ def handle_partially_provisioned(self, provision_count, device_type): self.status = "success" self.result['changed'] = True - self.log("{0} Devices provisioned successfully partially for {1} devices".format(device_type, provision_count), "INFO") + self.log("{0} Devices provisioned successfully partially for {1} devices".format( + device_type, provision_count), "INFO") def provisioned_wired_device(self): """ @@ -1715,23 +1773,28 @@ def provisioned_wired_device(self): continue elif device_status == 3: # Error in provisioning self.status = "failed" - error_msg = "Cannot do Provisioning for device {0}.".format(device_ip) + error_msg = "Cannot do Provisioning for device {0}.".format( + device_ip) self.log(error_msg, "ERROR") continue # Check if device reaches managed state - managed_flag = self.wait_for_device_managed_state(device_ip, resync_retry_count, resync_retry_interval) + managed_flag = self.wait_for_device_managed_state( + device_ip, resync_retry_count, resync_retry_interval) if not managed_flag: - self.log("Device {0} is not transitioning to the managed state, so provisioning operation cannot be performed.".format(device_ip), "WARNING") + self.log("Device {0} is not transitioning to the managed state, so provisioning operation cannot be performed.".format( + device_ip), "WARNING") continue if self.get_ccc_version_as_integer() <= self.get_ccc_version_as_int_from_str("2.3.5.3"): - self.provision_wired_device_v1(device_ip, site_name_hierarchy, device_type) + self.provision_wired_device_v1( + device_ip, site_name_hierarchy, device_type) else: self.provision_wired_device_v2(device_ip, site_name_hierarchy) # Handle final provisioning results - self.handle_final_provisioning_result(total_devices, self.provision_count, self.already_provisioned_count, device_ip_list, device_type) + self.handle_final_provisioning_result( + total_devices, self.provision_count, self.already_provisioned_count, device_ip_list, device_type) return self def log_device_already_provisioned(self, device_ip): @@ -1750,7 +1813,8 @@ def log_device_already_provisioned(self, device_ip): self.status = "success" self.already_provisioned_count += 1 self.result['changed'] = False - self.msg = "Device '{0}' is already provisioned in the Cisco Catalyst Center.".format(device_ip) + self.msg = "Device '{0}' is already provisioned in the Cisco Catalyst Center.".format( + device_ip) self.device_already_provisioned.append(device_ip) self.log(self.msg, "INFO") @@ -1773,22 +1837,26 @@ def wait_for_device_managed_state(self, device_ip, retry_count, retry_interval): while retry_count > 0: response = self.get_device_response(device_ip) - self.log("Device is in {0} state, waiting for Managed State.".format(response.get('managementState')), "DEBUG") + self.log("Device is in {0} state, waiting for Managed State.".format( + response.get('managementState')), "DEBUG") if response.get('managementState') == "Managed" and response.get('collectionStatus') == "Managed": - msg = "Device '{0}' reached Managed state with {1} retries left.".format(device_ip, retry_count) + msg = "Device '{0}' reached Managed state with {1} retries left.".format( + device_ip, retry_count) self.log(msg, "INFO") return True elif response.get('collectionStatus') in ["Partial Collection Failure", "Could Not Synchronize"]: - msg = "Device '{0}' reached '{1}' state. Retries left: {2}.".format(device_ip, response.get('collectionStatus'), retry_count) + msg = "Device '{0}' reached '{1}' state. Retries left: {2}.".format( + device_ip, response.get('collectionStatus'), retry_count) self.log(msg, "INFO") return False time.sleep(retry_interval) retry_count -= 1 - self.log("Device '{0}' did not transition to the Managed state within the retry limit.".format(device_ip), "WARNING") + self.log("Device '{0}' did not transition to the Managed state within the retry limit.".format( + device_ip), "WARNING") return False def provision_wired_device_v1(self, device_ip, site_name_hierarchy, device_type): @@ -1804,13 +1872,17 @@ def provision_wired_device_v1(self, device_ip, site_name_hierarchy, device_type) It handles the necessary configurations and returns a success status. """ - provision_params = {'deviceManagementIpAddress': device_ip, 'siteNameHierarchy': site_name_hierarchy} + provision_params = {'deviceManagementIpAddress': device_ip, + 'siteNameHierarchy': site_name_hierarchy} try: - response = self.dnac._exec(family="sda", function='provision_wired_device', op_modifies=True, params=provision_params) - self.log("Received API response from 'provision_wired_device': {0}".format(response), "DEBUG") + response = self.dnac._exec( + family="sda", function='provision_wired_device', op_modifies=True, params=provision_params) + self.log("Received API response from 'provision_wired_device': {0}".format( + response), "DEBUG") if response: - self.check_execution_response_status(response, "provision_wired_device").check_return_status() + self.check_execution_response_status( + response, "provision_wired_device").check_return_status() self.provision_count += 1 self.provisioned_device.append(device_ip) @@ -1834,12 +1906,16 @@ def provision_wired_device_v2(self, device_ip, site_name_hierarchy): device_id = device_ids[0] assign_params = {'deviceIds': [device_id], 'siteId': site_id} - provision_params = [{"siteId": site_id, "networkDeviceId": device_id}] - is_device_provisioned = self.is_device_provisioned(device_id, device_ip) - is_device_assigned_to_site = self.is_device_assigned_to_site(device_id) + provision_params = [ + {"siteId": site_id, "networkDeviceId": device_id}] + is_device_provisioned = self.is_device_provisioned( + device_id, device_ip) + is_device_assigned_to_site = self.is_device_assigned_to_site( + device_id) if not is_device_assigned_to_site: - self.assign_device_to_site(device_ids, site_name_hierarchy, site_id) + self.assign_device_to_site( + device_ids, site_name_hierarchy, site_id) if not is_device_provisioned: self.provision_device(provision_params, device_ip) @@ -1863,22 +1939,25 @@ def is_device_assigned_to_site(self, uuid): """ - self.log("Checking site assignment for device with UUID: {0}".format(uuid), "INFO") + self.log( + "Checking site assignment for device with UUID: {0}".format(uuid), "INFO") try: site_response = self.dnac_apply['exec']( family="devices", function='get_device_detail', - params={"search_by": uuid , + params={"search_by": uuid, "identifier": "uuid"}, op_modifies=True ) - self.log("Response collected from the API 'get_device_detail' {0}".format(site_response)) + self.log("Response collected from the API 'get_device_detail' {0}".format( + site_response)) site_response = site_response.get("response") if site_response.get("location"): return True return False except Exception as e: - msg = "Failed to find device with UUID {0} due to: {1}".format(uuid, e) + msg = "Failed to find device with UUID {0} due to: {1}".format( + uuid, e) self.log(msg, "CRITICAL") self.module.fail_json(msg=msg) @@ -1902,13 +1981,15 @@ def is_device_provisioned(self, device_id, device_ip): function='get_provisioned_wired_device', params={"device_management_ip_address": device_ip}, ) - self.log("Received API response from 'get_provisioned_wired_device': {0}".format(str(prov_response)), "DEBUG") + self.log("Received API response from 'get_provisioned_wired_device': {0}".format( + str(prov_response)), "DEBUG") if prov_response: return True except Exception as e: - self.log("Exception occurred during 'get_provisioned_wired_device': {0}".format(str(e)), "ERROR") + self.log("Exception occurred during 'get_provisioned_wired_device': {0}".format( + str(e)), "ERROR") return False else: try: @@ -1920,14 +2001,16 @@ def is_device_provisioned(self, device_id, device_ip): } ) is_provisioned = api_response.get('response') - self.log("API response from 'get_provisioned_devices': {}".format(is_provisioned), "DEBUG") + self.log("API response from 'get_provisioned_devices': {}".format( + is_provisioned), "DEBUG") if is_provisioned: return True return False except Exception as e: - self.log("Exception occurred during 'get_provisioned_devices': {0}".format(str(e)), "ERROR") + self.log("Exception occurred during 'get_provisioned_devices': {0}".format( + str(e)), "ERROR") def provision_device(self, provision_params, device_ip): """ @@ -1944,16 +2027,21 @@ def provision_device(self, provision_params, device_ip): """ try: - response = self.dnac._exec(family="sda", function='provision_devices', op_modifies=True, params={"payload": provision_params}) - self.log("Received API response from 'provision_devices': {0}".format(str(response)), "DEBUG") - self.check_tasks_response_status(response, api_name='provision_device') + response = self.dnac._exec(family="sda", function='provision_devices', op_modifies=True, params={ + "payload": provision_params}) + self.log("Received API response from 'provision_devices': {0}".format( + str(response)), "DEBUG") + self.check_tasks_response_status( + response, api_name='provision_device') if self.status not in ["failed", "exited"]: - self.log("Wired Device '{0}' provisioning completed successfully.".format(device_ip), "INFO") + self.log("Wired Device '{0}' provisioning completed successfully.".format( + device_ip), "INFO") self.provision_count += 1 except Exception as e: - self.log("Exception occurred during provisioning: {0}".format(str(e)), "ERROR") + self.log("Exception occurred during provisioning: {0}".format( + str(e)), "ERROR") return self @@ -2036,12 +2124,14 @@ def get_wireless_param(self, prov_dict): function='get_network_device_by_ip', params={"ip_address": device_ip_address} ) - self.log("Received API response from 'get_network_device_by_ip': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_network_device_by_ip': {0}".format( + str(response)), "DEBUG") response = response.get("response") wireless_param[0]["deviceName"] = response.get("hostname") self.wireless_param = wireless_param self.status = "success" - self.log("Successfully collected all the parameters required for Wireless Provisioning", "DEBUG") + self.log( + "Successfully collected all the parameters required for Wireless Provisioning", "DEBUG") except Exception as e: self.msg = """An exception occured while fetching the details for wireless provisioning of @@ -2078,13 +2168,15 @@ def provisioned_wireless_devices(self): provisioning_params = self.wireless_param resync_retry_count = prov_dict.get("resync_retry_count", 200) # This resync retry interval will be in seconds which will check device status at given interval - resync_retry_interval = prov_dict.get("resync_retry_interval", 2) + resync_retry_interval = prov_dict.get( + "resync_retry_interval", 2) managed_flag = True # Check till device comes into managed state while resync_retry_count: response = self.get_device_response(device_ip) - self.log("Device is in {0} state waiting for Managed State.".format(response.get('managementState')), "DEBUG") + self.log("Device is in {0} state waiting for Managed State.".format( + response.get('managementState')), "DEBUG") if ( response.get('managementState') == "Managed" @@ -2120,10 +2212,12 @@ def provisioned_wireless_devices(self): op_modifies=True, params=provisioning_params, ) - self.log("Received API response from 'provision': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'provision': {0}".format( + str(response)), "DEBUG") if response.get("status") == "failed": description = response.get("description") - error_msg = "Cannot do Provisioning for Wireless device {0} beacuse of {1}".format(device_ip, description) + error_msg = "Cannot do Provisioning for Wireless device {0} beacuse of {1}".format( + device_ip, description) self.log(error_msg, "ERROR") continue @@ -2134,11 +2228,13 @@ def provisioned_wireless_devices(self): progress = execution_details.get("progress") if 'TASK_PROVISION' in progress: - self.handle_successful_provisioning(device_ip, execution_details, device_type) + self.handle_successful_provisioning( + device_ip, execution_details, device_type) provision_count += 1 break elif execution_details.get("isError"): - self.handle_failed_provisioning(device_ip, execution_details, device_type) + self.handle_failed_provisioning( + device_ip, execution_details, device_type) break except Exception as e: @@ -2146,7 +2242,8 @@ def provisioned_wireless_devices(self): # but for others it gets provision successfully or If some devices are already provsioned self.handle_provisioning_exception(device_ip, e, device_type) if "already provisioned" in str(e): - self.msg = "Device '{0}' already provisioned".format(device_ip) + self.msg = "Device '{0}' already provisioned".format( + device_ip) self.log(self.msg, "INFO") already_provision_count += 1 @@ -2184,13 +2281,15 @@ def get_udf_id(self, field_name): op_modifies=True, params={"name": field_name}, ) - self.log("Received API response from 'get_all_user_defined_fields': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_all_user_defined_fields': {0}".format( + str(response)), "DEBUG") udf = response.get("response") if udf: udf_id = udf[0].get("id") except Exception as e: - error_message = "Exception occurred while getting Global User Defined Fields(UDF) ID from Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Exception occurred while getting Global User Defined Fields(UDF) ID from Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "ERROR") return udf_id @@ -2225,12 +2324,14 @@ def mandatory_parameter(self, device_to_add_in_ccc): if mandatory_params_absent: self.status = "failed" - self.msg = "Required parameters {0} for adding devices '{1}' are not present".format(str(mandatory_params_absent), str(device_to_add_in_ccc)) + self.msg = "Required parameters {0} for adding devices '{1}' are not present".format( + str(mandatory_params_absent), str(device_to_add_in_ccc)) self.log(self.msg, "ERROR") self.result['response'] = self.msg else: self.status = "success" - self.msg = "Required parameters for adding the devices '{0}' to inventory are present.".format(str(device_to_add_in_ccc)) + self.msg = "Required parameters for adding the devices '{0}' to inventory are present.".format( + str(device_to_add_in_ccc)) self.log(self.msg, "INFO") return self @@ -2278,7 +2379,8 @@ def get_have(self, config): if missing_params: self.status = "failed" - self.msg = "Missing parameters: '{0}'. Site and Device IP are required for Provisioning of Wired Devices.".format(", ".join(missing_params)) + self.msg = "Missing parameters: '{0}'. Site and Device IP are required for Provisioning of Wired Devices.".format( + ", ".join(missing_params)) self.log(self.msg, "ERROR") self.result['response'] = self.msg return self @@ -2291,7 +2393,8 @@ def get_have(self, config): if support_for_provisioning_wireless: if self.config[0].get('provision_wireless_device'): - provision_wireless_list = self.config[0].get('provision_wireless_device') + provision_wireless_list = self.config[0].get( + 'provision_wireless_device') for prov_dict in provision_wireless_list: device_ip_address = prov_dict['device_ip'] @@ -2300,7 +2403,8 @@ def get_have(self, config): if device_ip_address not in device_in_ccc and device_ip_address not in device_not_in_ccc: device_not_in_ccc.append(device_ip_address) - self.log("Device(s) {0} exists in Cisco Catalyst Center".format(str(device_in_ccc)), "INFO") + self.log("Device(s) {0} exists in Cisco Catalyst Center".format( + str(device_in_ccc)), "INFO") have["want_device"] = want_device have["device_in_ccc"] = device_in_ccc have["device_not_in_ccc"] = device_not_in_ccc @@ -2389,7 +2493,8 @@ def get_device_ids(self, device_ips): params={"managementIpAddress": device_ip} ) - self.log("Received API response from 'get_device_list': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_device_list': {0}".format( + str(response)), "DEBUG") if response: response = response.get("response") if not response: @@ -2398,7 +2503,8 @@ def get_device_ids(self, device_ips): device_ids.append(device_id) except Exception as e: - error_message = "Error while fetching device '{0}' from Cisco Catalyst Center: {1}".format(device_ip, str(e)) + error_message = "Error while fetching device '{0}' from Cisco Catalyst Center: {1}".format( + device_ip, str(e)) self.log(error_message, "ERROR") return device_ids @@ -2429,7 +2535,8 @@ def get_interface_from_id_and_name(self, device_id, interface_name): op_modifies=True, params=interface_detail_params ) - self.log("Received API response from 'get_interface_details': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_interface_details': {0}".format( + str(response)), "DEBUG") response = response.get("response") if response: @@ -2441,7 +2548,8 @@ def get_interface_from_id_and_name(self, device_id, interface_name): except Exception as e: self.status = "failed" - self.msg = "Failed to retrieve interface ID for interface({0}) from Cisco Catalyst Center: {1}".format(interface_name, str(e)) + self.msg = "Failed to retrieve interface ID for interface({0}) from Cisco Catalyst Center: {1}".format( + interface_name, str(e)) self.result['response'] = self.msg self.log(self.msg, "ERROR") self.check_return_status() @@ -2467,16 +2575,19 @@ def get_interface_from_ip(self, device_ip): op_modifies=True, params={"ip_address": device_ip} ) - self.log("Received API response from 'get_interface_by_ip': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_interface_by_ip': {0}".format( + str(response)), "DEBUG") response = response.get("response") if response: interface_id = response[0]["id"] - self.log("Successfully retrieved Interface Id '{0}' for device '{1}'.".format(interface_id, device_ip), "DEBUG") + self.log("Successfully retrieved Interface Id '{0}' for device '{1}'.".format( + interface_id, device_ip), "DEBUG") return interface_id except Exception as e: - error_message = "Error while fetching Interface Id for device '{0}' from Cisco Catalyst Center: {1}".format(device_ip, str(e)) + error_message = "Error while fetching Interface Id for device '{0}' from Cisco Catalyst Center: {1}".format( + device_ip, str(e)) self.log(error_message, "ERROR") raise Exception(error_message) @@ -2500,11 +2611,13 @@ def get_device_response(self, device_ip): op_modifies=True, params={"managementIpAddress": device_ip} ) - self.log("Received API response from 'get_device_list': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_device_list': {0}".format( + str(response)), "DEBUG") response = response.get('response')[0] except Exception as e: - error_message = "Error while getting the response of device from Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error while getting the response of device from Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "ERROR") raise Exception(error_message) @@ -2560,11 +2673,13 @@ def check_interface_details(self, device_ip, interface_name): op_modifies=True, params=interface_detail_params ) - self.log("Received API response from 'get_interface_details': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_interface_details': {0}".format( + str(response)), "DEBUG") response = response.get("response") if not response: - self.log("No response received from the API 'get_interface_details'.", "DEBUG") + self.log( + "No response received from the API 'get_interface_details'.", "DEBUG") return False response_params = { @@ -2574,7 +2689,8 @@ def check_interface_details(self, device_ip, interface_name): 'vlanId': int(response.get('vlanId')) } - interface_playbook_params = self.config[0].get('update_interface_details') + interface_playbook_params = self.config[0].get( + 'update_interface_details') playbook_params = { 'description': interface_playbook_params.get('description', ''), 'adminStatus': interface_playbook_params.get('admin_status'), @@ -2607,9 +2723,11 @@ def check_credential_update(self): device_uuids = self.get_device_ids(device_ips) password = "Testing@123" # Split the payload into 500 devices(by default) only to match the device credentials - device_batch_size = self.config[0].get("export_device_details_limit", 500) + device_batch_size = self.config[0].get( + "export_device_details_limit", 500) device_ids_list = device_uuids[0:device_batch_size] - payload_params = {"deviceUuids": device_ids_list, "password": password, "operationEnum": "0"} + payload_params = {"deviceUuids": device_ids_list, + "password": password, "operationEnum": "0"} response = self.trigger_export_api(payload_params) self.check_return_status() csv_reader = self.decrypt_and_read_csv(response, password) @@ -2661,27 +2779,33 @@ def get_provision_wired_device(self, device_ip): op_modifies=True, params={"device_management_ip_address": device_ip} ) - self.log("Received API response from 'get_provisioned_wired_devices': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_provisioned_wired_devices': {0}".format( + str(response)), "DEBUG") if response.get("status") == "success" and "retrieved successfully" in response.get("description"): flag = 2 - self.log("Wired device '{0}' already provisioned in the Cisco Catalyst Center.".format(device_ip), "INFO") + self.log("Wired device '{0}' already provisioned in the Cisco Catalyst Center.".format( + device_ip), "INFO") else: device_ids = self.get_device_ids([device_ip]) device_id = device_ids[0] if not device_ids: - self.log("No device ID found for IP {0}".format(device_ip), "ERROR") - self.log("Device ID for IP {0}: {1}".format(device_ip, device_id), "DEBUG") + self.log("No device ID found for IP {0}".format( + device_ip), "ERROR") + self.log("Device ID for IP {0}: {1}".format( + device_ip, device_id), "DEBUG") response = self.dnac._exec( family="sda", function='get_provisioned_devices', op_modifies=True, params={"networkDeviceId": device_id} ) - self.log("Received API response from 'get_provision_devices': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_provision_devices': {0}".format( + str(response)), "DEBUG") response = response.get("response") if response: flag = 2 - self.log("Wired device '{0}' already provisioned in the Cisco Catalyst Center.".format(device_ip), "INFO") + self.log("Wired device '{0}' already provisioned in the Cisco Catalyst Center.".format( + device_ip), "INFO") except Exception as e: if "not provisioned to any site" in str(e): flag = 1 @@ -2721,7 +2845,8 @@ def clear_mac_address(self, interface_id, deploy_mode, interface_name): op_modifies=True, params=clear_mac_address_payload, ) - self.log("Received API response from 'clear_mac_address_table': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'clear_mac_address_table': {0}".format( + str(response)), "DEBUG") if not (response and isinstance(response, dict)): self.status = "failed" @@ -2740,9 +2865,11 @@ def clear_mac_address(self, interface_id, deploy_mode, interface_name): self.status = "failed" failure_reason = execution_details.get("failureReason") if failure_reason: - self.msg = "Failed to clear the Mac address table for the interface '{0}' due to {1}".format(interface_name, failure_reason) + self.msg = "Failed to clear the Mac address table for the interface '{0}' due to {1}".format( + interface_name, failure_reason) else: - self.msg = "Failed to clear the Mac address table for the interface '{0}'".format(interface_name) + self.msg = "Failed to clear the Mac address table for the interface '{0}'".format( + interface_name) self.log(self.msg, "ERROR") self.result['response'] = self.msg break @@ -2750,7 +2877,8 @@ def clear_mac_address(self, interface_id, deploy_mode, interface_name): self.status = "success" self.result['changed'] = True self.result['response'] = execution_details - self.msg = "Successfully executed the task of clearing the Mac address table for interface '{0}'".format(interface_name) + self.msg = "Successfully executed the task of clearing the Mac address table for interface '{0}'".format( + interface_name) self.log(self.msg, "INFO") break @@ -2785,7 +2913,8 @@ def update_interface_detail_of_device(self, device_to_update): interface_names_list = interface_params.get('interface_name') for interface_name in interface_names_list: device_id = self.get_device_ids([device_ip]) - interface_details = self.get_interface_from_id_and_name(device_id[0], interface_name) + interface_details = self.get_interface_from_id_and_name( + device_id[0], interface_name) # Check if interface_details is None or does not contain the 'id' key. if interface_details is None or not interface_details.get('id'): self.status = "failed" @@ -2800,8 +2929,10 @@ def update_interface_detail_of_device(self, device_to_update): # Now we call update interface details api with required parameter try: - interface_params = self.config[0].get('update_interface_details') - clear_mac_address_table = interface_params.get("clear_mac_address_table", False) + interface_params = self.config[0].get( + 'update_interface_details') + clear_mac_address_table = interface_params.get( + "clear_mac_address_table", False) if clear_mac_address_table: response = self.get_device_response(device_ip) @@ -2811,8 +2942,10 @@ def update_interface_detail_of_device(self, device_to_update): self.log(self.msg, "WARNING") else: - deploy_mode = interface_params.get('deployment_mode', 'Deploy') - self.clear_mac_address(interface_id, deploy_mode, interface_name).check_return_status() + deploy_mode = interface_params.get( + 'deployment_mode', 'Deploy') + self.clear_mac_address( + interface_id, deploy_mode, interface_name).check_return_status() temp_params = { 'description': interface_params.get('description', ''), @@ -2855,7 +2988,8 @@ def update_interface_detail_of_device(self, device_to_update): op_modifies=True, params=update_interface_params, ) - self.log("Received API response from 'update_interface_details': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'update_interface_details': {0}".format( + str(response)), "DEBUG") if response and isinstance(response, dict): response = response.get('response') @@ -2874,15 +3008,18 @@ def update_interface_detail_of_device(self, device_to_update): if 'SUCCESS' in execution_details.get("progress"): self.status = "success" is_update_occurred = True - self.msg = "Successfully updated the Interface Details for device '{0}'.".format(device_ip) + self.msg = "Successfully updated the Interface Details for device '{0}'.".format( + device_ip) self.response_list.append(self.msg) self.log(self.msg, "INFO") break elif execution_details.get("isError"): self.status = "failed" - failure_reason = execution_details.get("failureReason") + failure_reason = execution_details.get( + "failureReason") if failure_reason: - self.msg = "Interface Updation get failed because of {0}".format(failure_reason) + self.msg = "Interface Updation get failed because of {0}".format( + failure_reason) else: self.msg = "Interface Updation get failed" self.log(self.msg, "ERROR") @@ -2890,7 +3027,8 @@ def update_interface_detail_of_device(self, device_to_update): break except Exception as e: - error_message = "Error while updating interface details in Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error while updating interface details in Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "INFO") self.status = "success" self.result['changed'] = False @@ -2927,9 +3065,11 @@ def check_managementip_execution_response(self, response, device_ip, new_mgmt_ip self.status = "failed" failure_reason = execution_details.get("failureReason") if failure_reason: - self.msg = "Device new management IP updation for device '{0}' get failed due to {1}".format(device_ip, failure_reason) + self.msg = "Device new management IP updation for device '{0}' get failed due to {1}".format( + device_ip, failure_reason) else: - self.msg = "Device new management IP updation for device '{0}' get failed".format(device_ip) + self.msg = "Device new management IP updation for device '{0}' get failed".format( + device_ip) self.log(self.msg, "ERROR") break elif execution_details.get("endTime"): @@ -2970,15 +3110,18 @@ def check_device_update_execution_response(self, response, device_ip): self.status = "failed" failure_reason = execution_details.get("failureReason") if failure_reason: - self.msg = "Device Updation for device '{0}' get failed due to {1}".format(device_ip, failure_reason) + self.msg = "Device Updation for device '{0}' get failed due to {1}".format( + device_ip, failure_reason) else: - self.msg = "Device Updation for device '{0}' get failed".format(device_ip) + self.msg = "Device Updation for device '{0}' get failed".format( + device_ip) self.log(self.msg, "ERROR") self.result['response'] = self.msg self.check_return_status() break elif execution_details.get("endTime"): - self.log("Device '{0}' present in Cisco Catalyst Center and have been updated successfully.".format(device_ip), "INFO") + self.log("Device '{0}' present in Cisco Catalyst Center and have been updated successfully.".format( + device_ip), "INFO") break return device_ip @@ -3005,16 +3148,19 @@ def is_device_exist_in_ccc(self, device_ip): op_modifies=True, params={"managementIpAddress": device_ip} ) - self.log("Received API response from 'get_device_list': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_device_list': {0}".format( + str(response)), "DEBUG") response = response.get('response') if not response: - self.log("Device with given IP '{0}' is not present in Cisco Catalyst Center".format(device_ip), "INFO") + self.log("Device with given IP '{0}' is not present in Cisco Catalyst Center".format( + device_ip), "INFO") return False return True except Exception as e: - error_message = "Error while getting the response of device '{0}' from Cisco Catalyst Center: {1}".format(device_ip, str(e)) + error_message = "Error while getting the response of device '{0}' from Cisco Catalyst Center: {1}".format( + device_ip, str(e)) self.log(error_message, "ERROR") raise Exception(error_message) @@ -3102,7 +3248,7 @@ def get_diff_merged(self, config): for prov_dict in provision_wired_list: device_ip = prov_dict['device_ip'] site_name = prov_dict['site_name'] - site_exist , site_id = self.get_site_id(site_name) + site_exist, site_id = self.get_site_id(site_name) if not site_exist: self.status = "failed" self.msg = ("Unable to Provision Wired Device(s) because the site(s) listed: '{0}' are not present in the" @@ -3121,7 +3267,8 @@ def get_diff_merged(self, config): return self if self.config[0].get('update_mgmt_ipaddresslist'): - device_ip = self.config[0].get('update_mgmt_ipaddresslist')[0].get('existMgmtIpAddress') + device_ip = self.config[0].get('update_mgmt_ipaddresslist')[ + 0].get('existMgmtIpAddress') is_device_exists = self.is_device_exist_in_ccc(device_ip) if not is_device_exists: @@ -3145,7 +3292,8 @@ def get_diff_merged(self, config): if self.config[0].get('role'): devices_to_update_role = self.get_device_ips_from_config_priority() - device_exist = self.is_device_exist_for_update(devices_to_update_role) + device_exist = self.is_device_exist_for_update( + devices_to_update_role) if not device_exist: self.msg = """Unable to update device role because the device(s) listed: {0} are not present in the Cisco @@ -3180,7 +3328,8 @@ def get_diff_merged(self, config): return self if not config['ip_address_list']: - self.msg = "Devices '{0}' already present in Cisco Catalyst Center".format(self.have['devices_in_playbook']) + self.msg = "Devices '{0}' already present in Cisco Catalyst Center".format( + self.have['devices_in_playbook']) self.log(self.msg, "INFO") self.result['changed'] = False self.result['response'] = self.msg @@ -3194,7 +3343,8 @@ def get_diff_merged(self, config): device_params['ipAddress'] = config['ip_address_list'] if device_params['snmpVersion'] == "v2": - params_to_remove = ["snmpAuthPassphrase", "snmpAuthProtocol", "snmpMode", "snmpPrivPassphrase", "snmpPrivProtocol", "snmpUserName"] + params_to_remove = ["snmpAuthPassphrase", "snmpAuthProtocol", + "snmpMode", "snmpPrivPassphrase", "snmpPrivProtocol", "snmpUserName"] for param in params_to_remove: device_params.pop(param, None) @@ -3229,7 +3379,8 @@ def get_diff_merged(self, config): device_params.pop('snmpPrivProtocol', None) device_to_add_in_ccc = device_params['ipAddress'] - self.mandatory_parameter(device_to_add_in_ccc).check_return_status() + self.mandatory_parameter( + device_to_add_in_ccc).check_return_status() try: response = self.dnac._exec( family="devices", @@ -3237,7 +3388,8 @@ def get_diff_merged(self, config): op_modifies=True, params=device_params, ) - self.log("Received API response from 'add_device': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'add_device': {0}".format( + str(response)), "DEBUG") if response and isinstance(response, dict): task_id = response.get('response').get('taskId') @@ -3252,28 +3404,34 @@ def get_diff_merged(self, config): if len(devices_to_add) > 0: self.device_list.append(devices_to_add) self.result['changed'] = True - self.msg = "Device(s) '{0}' added to Cisco Catalyst Center".format(str(devices_to_add)) + self.msg = "Device(s) '{0}' added to Cisco Catalyst Center".format( + str(devices_to_add)) self.log(self.msg, "INFO") self.result['msg'] = self.msg self.result['response'] = self.msg break - self.msg = "Device(s) '{0}' already present in Cisco Catalyst Center".format(str(self.config[0].get("ip_address_list"))) + self.msg = "Device(s) '{0}' already present in Cisco Catalyst Center".format( + str(self.config[0].get("ip_address_list"))) self.log(self.msg, "INFO") self.result['msg'] = self.msg break elif execution_details.get("isError"): self.status = "failed" - failure_reason = execution_details.get("failureReason") + failure_reason = execution_details.get( + "failureReason") if failure_reason: - self.msg = "Device addition for the device(s) '{0}' get failed because of {1}.".format(device_to_add_in_ccc, failure_reason) + self.msg = "Device addition for the device(s) '{0}' get failed because of {1}.".format( + device_to_add_in_ccc, failure_reason) else: - self.msg = "Device addition get failed for the device(s): '{0}'.".format(device_to_add_in_ccc) + self.msg = "Device addition get failed for the device(s): '{0}'.".format( + device_to_add_in_ccc) self.log(self.msg, "ERROR") self.result['response'] = self.msg break except Exception as e: - error_message = "Error while adding device in Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error while adding device in Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "ERROR") raise Exception(error_message) @@ -3293,14 +3451,16 @@ def get_diff_merged(self, config): op_modifies=True, params={"managementIpAddress": device_ip} ) - self.log("Received API response from 'get_device_list': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_device_list': {0}".format( + str(response)), "DEBUG") response = response.get('response')[0] if response.get('role') == device_role: self.status = "success" self.result['changed'] = False role_update_count += 1 - log_msg = "The device role '{0}' is already set in Cisco Catalyst Center, no update is needed.".format(device_role) + log_msg = "The device role '{0}' is already set in Cisco Catalyst Center, no update is needed.".format( + device_role) self.log(log_msg, "INFO") continue @@ -3317,7 +3477,8 @@ def get_diff_merged(self, config): op_modifies=True, params=device_role_params, ) - self.log("Received API response from 'update_device_role': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'update_device_role': {0}".format( + str(response)), "DEBUG") if response and isinstance(response, dict): task_id = response.get('response').get('taskId') @@ -3328,14 +3489,17 @@ def get_diff_merged(self, config): if 'successfully' in progress or 'succesfully' in progress: self.status = "success" - self.log("Device '{0}' role updated successfully to '{1}'".format(device_ip, device_role), "INFO") + self.log("Device '{0}' role updated successfully to '{1}'".format( + device_ip, device_role), "INFO") self.role_updated_list.append(device_ip) break elif execution_details.get("isError"): self.status = "failed" - failure_reason = execution_details.get("failureReason") + failure_reason = execution_details.get( + "failureReason") if failure_reason: - self.msg = "Device role updation get failed because of {0}".format(failure_reason) + self.msg = "Device role updation get failed because of {0}".format( + failure_reason) else: self.msg = "Device role updation get failed" self.log(self.msg, "ERROR") @@ -3343,7 +3507,8 @@ def get_diff_merged(self, config): break except Exception as e: - error_message = "Error while updating device role '{0}' in Cisco Catalyst Center: {1}".format(device_role, str(e)) + error_message = "Error while updating device role '{0}' in Cisco Catalyst Center: {1}".format( + device_role, str(e)) self.log(error_message, "ERROR") if role_update_count == len(devices_to_update_role): @@ -3357,7 +3522,8 @@ def get_diff_merged(self, config): if self.role_updated_list: self.status = "success" self.result['changed'] = True - self.msg = "Device(s) '{0}' role updated successfully to '{1}'".format(self.role_updated_list, device_role) + self.msg = "Device(s) '{0}' role updated successfully to '{1}'".format( + self.role_updated_list, device_role) self.result['msg'] = self.msg self.result["response"] = self.msg self.log(self.msg, "INFO") @@ -3370,15 +3536,18 @@ def get_diff_merged(self, config): device_uuids = self.get_device_ids(device_to_update) password = "Testing@123" start = 0 - device_batch_size = self.config[0].get("export_device_details_limit", 500) + device_batch_size = self.config[0].get( + "export_device_details_limit", 500) device_details = {} while start < len(device_uuids): device_ids_list = device_uuids[start:start + device_batch_size] - export_payload = {"deviceUuids": device_ids_list, "password": password, "operationEnum": "0"} + export_payload = {"deviceUuids": device_ids_list, + "password": password, "operationEnum": "0"} export_response = self.trigger_export_api(export_payload) self.check_return_status() - csv_reader = self.decrypt_and_read_csv(export_response, password) + csv_reader = self.decrypt_and_read_csv( + export_response, password) self.check_return_status() for row in csv_reader: @@ -3433,7 +3602,8 @@ def get_diff_merged(self, config): 'snmp_username': 'snmpUserName', 'netconf_port': 'netconfPort' } - device_update_key_list = ["username", "password", "enable_password", "snmp_username", "netconf_port"] + device_update_key_list = [ + "username", "password", "enable_password", "snmp_username", "netconf_port"] for key in device_update_key_list: mapped_key = device_key_mapping[key] @@ -3479,21 +3649,27 @@ def get_diff_merged(self, config): playbook_params['snmpVersion'] = "v2" if playbook_params['snmpVersion'] == 'v2': - params_to_remove = ["snmpAuthPassphrase", "snmpAuthProtocol", "snmpMode", "snmpPrivPassphrase", "snmpPrivProtocol", "snmpUserName"] + params_to_remove = ["snmpAuthPassphrase", "snmpAuthProtocol", + "snmpMode", "snmpPrivPassphrase", "snmpPrivProtocol", "snmpUserName"] for param in params_to_remove: playbook_params.pop(param, None) if not playbook_params['snmpROCommunity']: - playbook_params['snmpROCommunity'] = device_data.get('snmp_community', None) + playbook_params['snmpROCommunity'] = device_data.get( + 'snmp_community', None) if not playbook_params['snmpRWCommunity']: - playbook_params['snmpRWCommunity'] = device_data.get('snmp_write_community', None) + playbook_params['snmpRWCommunity'] = device_data.get( + 'snmp_write_community', None) if not playbook_params['httpUserName']: - playbook_params['httpUserName'] = device_data.get('http_config_username', None) + playbook_params['httpUserName'] = device_data.get( + 'http_config_username', None) if not playbook_params['httpPassword']: - playbook_params['httpPassword'] = device_data.get('http_config_password', None) + playbook_params['httpPassword'] = device_data.get( + 'http_config_password', None) if not playbook_params['httpPort']: - playbook_params['httpPort'] = device_data.get('http_port', None) + playbook_params['httpPort'] = device_data.get( + 'http_port', None) for key, value in playbook_params.items(): if value == " ": @@ -3504,53 +3680,63 @@ def get_diff_merged(self, config): new_mgmt_ipaddress = playbook_params['updateMgmtIPaddressList'][0]['newMgmtIpAddress'] if new_mgmt_ipaddress in self.have['device_in_ccc']: self.status = "failed" - self.msg = "Device with IP address '{0}' already exists in inventory".format(new_mgmt_ipaddress) + self.msg = "Device with IP address '{0}' already exists in inventory".format( + new_mgmt_ipaddress) self.log(self.msg, "ERROR") self.result['response'] = self.msg else: - self.log("Playbook parameter for updating device new management ip address: {0}".format(str(playbook_params)), "DEBUG") + self.log("Playbook parameter for updating device new management ip address: {0}".format( + str(playbook_params)), "DEBUG") response = self.dnac._exec( family="devices", function='sync_devices', op_modifies=True, params=playbook_params, ) - self.log("Received API response from 'sync_devices': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'sync_devices': {0}".format( + str(response)), "DEBUG") if response and isinstance(response, dict): - self.check_managementip_execution_response(response, device_ip, new_mgmt_ipaddress) + self.check_managementip_execution_response( + response, device_ip, new_mgmt_ipaddress) self.check_return_status() else: - self.log("Playbook parameter for updating devices: {0}".format(str(playbook_params)), "DEBUG") + self.log("Playbook parameter for updating devices: {0}".format( + str(playbook_params)), "DEBUG") response = self.dnac._exec( family="devices", function='sync_devices', op_modifies=True, params=playbook_params, ) - self.log("Received API response from 'sync_devices': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'sync_devices': {0}".format( + str(response)), "DEBUG") if response and isinstance(response, dict): - self.check_device_update_execution_response(response, device_ip) + self.check_device_update_execution_response( + response, device_ip) update_device_ips.append(device_ip) self.check_return_status() except Exception as e: - error_message = "Error while updating device in Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error while updating device in Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "ERROR") raise Exception(error_message) if update_device_ips: self.status = "success" self.result['changed'] = True - self.msg = "Device(s) '{0}' present in Cisco Catalyst Center and have been updated successfully.".format(str(update_device_ips)) + self.msg = "Device(s) '{0}' present in Cisco Catalyst Center and have been updated successfully.".format( + str(update_device_ips)) self.result['response'] = self.msg self.log(self.msg, "INFO") if self.config[0].get('update_interface_details'): device_to_update = self.get_device_ips_from_config_priority() - self.update_interface_detail_of_device(device_to_update).check_return_status() + self.update_interface_detail_of_device( + device_to_update).check_return_status() # If User defined field(UDF) not present then create it and add multiple udf to specific or list of devices self.log("self.config") @@ -3574,7 +3760,8 @@ def get_diff_merged(self, config): self.log(udf_exist) if not udf_exist: # Create the Global UDF - self.log("Global User Defined Field '{0}' does not present in Cisco Catalyst Center, we need to create it".format(field_name), "DEBUG") + self.log("Global User Defined Field '{0}' does not present in Cisco Catalyst Center, we need to create it".format( + field_name), "DEBUG") self.create_user_defined_field(udf).check_return_status() # Get device Id based on config priority @@ -3591,10 +3778,12 @@ def get_diff_merged(self, config): return self # Now add code for adding Global UDF to device with Id - self.add_field_to_devices(device_ids, udf).check_return_status() + self.add_field_to_devices( + device_ids, udf).check_return_status() self.result['changed'] = True - self.msg = "Global User Defined Field(UDF) named '{0}' has been successfully added to the device.".format(field_name) + self.msg = "Global User Defined Field(UDF) named '{0}' has been successfully added to the device.".format( + field_name) self.udf_added.append(field_name) self.log(self.msg, "INFO") @@ -3645,7 +3834,8 @@ def get_diff_deleted(self, config): if device_ip not in self.have.get("device_in_ccc"): self.status = "success" self.result['changed'] = False - self.msg = "Device '{0}' is not present in Cisco Catalyst Center so can't perform delete operation".format(device_ip) + self.msg = "Device '{0}' is not present in Cisco Catalyst Center so can't perform delete operation".format( + device_ip) self.no_device_to_delete.append(device_ip) self.result['msg'].append(self.msg) self.result['response'] = self.msg @@ -3653,7 +3843,8 @@ def get_diff_deleted(self, config): continue device_ids = self.get_device_ids([device_ip]) device_id = device_ids[0] - is_device_provisioned = self.is_device_provisioned(device_id, device_ip) + is_device_provisioned = self.is_device_provisioned( + device_id, device_ip) if not is_device_provisioned: self.handle_device_deletion(device_ip) continue @@ -3685,7 +3876,8 @@ def delete_user_defined_fields(self): if udf_id is None: self.status = "success" - self.msg = "Global UDF '{0}' is not present in Cisco Catalyst Center".format(field_name) + self.msg = "Global UDF '{0}' is not present in Cisco Catalyst Center".format( + field_name) self.log(self.msg, "INFO") self.result['changed'] = False self.result['msg'] = self.msg @@ -3699,7 +3891,8 @@ def delete_user_defined_fields(self): op_modifies=True, params={"id": udf_id}, ) - self.log("Received API response from 'delete_user_defined_field': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'delete_user_defined_field': {0}".format( + str(response)), "DEBUG") # Check for task ID in the response and monitor its progress if response and isinstance(response, dict): @@ -3711,7 +3904,8 @@ def delete_user_defined_fields(self): # If the task is successful, update status and log the result if 'success' in execution_details.get("progress"): self.status = "success" - self.msg = "Global UDF '{0}' deleted successfully from Cisco Catalyst Center".format(field_name) + self.msg = "Global UDF '{0}' deleted successfully from Cisco Catalyst Center".format( + field_name) self.udf_deleted.append(field_name) self.log(self.msg, "INFO") self.result['changed'] = True @@ -3720,17 +3914,21 @@ def delete_user_defined_fields(self): # If there's an error, log and handle it elif execution_details.get("isError"): self.status = "failed" - failure_reason = execution_details.get("failureReason") + failure_reason = execution_details.get( + "failureReason") if failure_reason: - self.msg = "Failed to delete Global User Defined Field (UDF) '{0}' due to: {1}".format(field_name, failure_reason) + self.msg = "Failed to delete Global User Defined Field (UDF) '{0}' due to: {1}".format( + field_name, failure_reason) else: - self.msg = "Global UDF '{0}' deletion failed.".format(field_name) + self.msg = "Global UDF '{0}' deletion failed.".format( + field_name) self.log(self.msg, "ERROR") self.result['response'] = self.msg break except Exception as e: - error_message = "Error while deleting Global UDF '{0}' from Cisco Catalyst Center: {1}".format(field_name, str(e)) + error_message = "Error while deleting Global UDF '{0}' from Cisco Catalyst Center: {1}".format( + field_name, str(e)) self.log(error_message, "ERROR") raise Exception(error_message) @@ -3757,7 +3955,8 @@ def delete_provisioned_device_v1(self, device_ip): op_modifies=True, params=provision_params, ) - self.log("Received API response from 'get_provisioned_wired_device': {0}".format(str(prov_response)), "DEBUG") + self.log("Received API response from 'get_provisioned_wired_device': {0}".format( + str(prov_response)), "DEBUG") if prov_response.get("status") == "success": response = self.dnac._exec( @@ -3768,9 +3967,11 @@ def delete_provisioned_device_v1(self, device_ip): ) if response: response = {"response": response} - self.log("Received API response from 'delete_provisioned_wired_device': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'delete_provisioned_wired_device': {0}".format( + str(response)), "DEBUG") validation_string = "deleted successfully" - self.check_task_response_status(response, validation_string, 'delete_provisioned_wired_device') + self.check_task_response_status( + response, validation_string, 'delete_provisioned_wired_device') self.provisioned_device_deleted.append(device_ip) def delete_provisioned_device_v2(self, device_ip): @@ -3795,7 +3996,8 @@ def delete_provisioned_device_v2(self, device_ip): op_modifies=True, params={"networkDeviceId": device_id} ) - self.log("Received API response from 'get_provisioned_devices': {0}".format(str(prov_response)), "DEBUG") + self.log("Received API response from 'get_provisioned_devices': {0}".format( + str(prov_response)), "DEBUG") if prov_response.get("response"): response = self.dnac._exec( @@ -3804,8 +4006,10 @@ def delete_provisioned_device_v2(self, device_ip): op_modifies=True, params={'networkDeviceId': device_id}, ) - self.log("Received API response from 'delete_provisioned_devices': {0}".format(str(response)), "DEBUG") - self.check_tasks_response_status(response, api_name='delete_provisioned_devices') + self.log("Received API response from 'delete_provisioned_devices': {0}".format( + str(response)), "DEBUG") + self.check_tasks_response_status( + response, api_name='delete_provisioned_devices') if self.status not in ["failed", "exited"]: self.provisioned_device_deleted.append(device_ip) @@ -3837,14 +4041,17 @@ def handle_device_deletion(self, device_ip): params=delete_params, ) - self.log("Received API response from 'deleted_device_by_id': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'deleted_device_by_id': {0}".format( + str(response)), "DEBUG") if self.get_ccc_version_as_integer() <= self.get_ccc_version_as_int_from_str("2.3.5.3"): validation_string = "network device deleted successfully" - self.check_task_response_status(response, validation_string, 'deleted_device_by_id') + self.check_task_response_status( + response, validation_string, 'deleted_device_by_id') self.deleted_devices.append(device_ip) else: - self.check_tasks_response_status(response, api_name='deleted_device_by_id') + self.check_tasks_response_status( + response, api_name='deleted_device_by_id') if self.status not in ["failed", "exited"]: self.deleted_devices.append(device_ip) @@ -3889,7 +4096,8 @@ def verify_diff_merged(self, config): if self.config[0].get('update_interface_details'): interface_update_flag = True - interface_names_list = self.config[0].get('update_interface_details').get('interface_name') + interface_names_list = self.config[0].get( + 'update_interface_details').get('interface_name') for device_ip in device_ips: for interface_name in interface_names_list: @@ -3899,7 +4107,8 @@ def verify_diff_merged(self, config): if interface_update_flag: self.status = "success" - msg = "Interface details updated and verified successfully for devices {0}.".format(device_ips) + msg = "Interface details updated and verified successfully for devices {0}.".format( + device_ips) self.log(msg, "INFO") else: self.log("""Playbook's input does not match with Cisco Catalyst Center, indicating that the update @@ -3913,7 +4122,8 @@ def verify_diff_merged(self, config): msg = "Device credentials and details updated and verified successfully in Cisco Catalyst Center." self.log(msg, "INFO") else: - self.log("Playbook parameter does not match with Cisco Catalyst Center, meaning device updation task not executed properly.", "INFO") + self.log( + "Playbook parameter does not match with Cisco Catalyst Center, meaning device updation task not executed properly.", "INFO") elif device_type != "NETWORK_DEVICE": self.log("""Unable to compare the parameter for device type '{0}' in the playbook with the one in Cisco Catalyst Center.""" .format(device_type), "WARNING") @@ -3926,7 +4136,8 @@ def verify_diff_merged(self, config): if udf_exist: self.status = "success" - msg = "Global UDF {0} created and verified successfully".format(field_name) + msg = "Global UDF {0} created and verified successfully".format( + field_name) self.log(msg, "INFO") else: self.log("""Mismatch between playbook parameter and Cisco Catalyst Center detected, indicating that @@ -3963,7 +4174,8 @@ def verify_diff_merged(self, config): if provision_wired_flag: self.status = "success" - msg = "Wired devices {0} get provisioned and verified successfully.".format(provision_device_list) + msg = "Wired devices {0} get provisioned and verified successfully.".format( + provision_device_list) self.log(msg, "INFO") else: self.log("""Mismatch between playbook's input and Cisco Catalyst Center detected, indicating that @@ -4012,7 +4224,8 @@ def verify_diff_deleted(self, config): if device_delete_flag: self.status = "success" - self.msg = "Requested device(s) '{0}' deleted from Cisco Catalyst Center and the deletion has been verified.".format(str(input_devices)) + self.msg = "Requested device(s) '{0}' deleted from Cisco Catalyst Center and the deletion has been verified.".format( + str(input_devices)) self.log(self.msg, "INFO") else: self.log("""Mismatch between playbook parameter device({0}) and Cisco Catalyst Center detected, indicating that @@ -4039,11 +4252,13 @@ def update_inventory_profile_messages(self): result_msg_list_changed = [] if self.provisioned_device: - provisioned_device = "device(s) '{0}' provisioned successfully in Cisco Catalyst Center.".format("', '".join(self.provisioned_device)) + provisioned_device = "device(s) '{0}' provisioned successfully in Cisco Catalyst Center.".format( + "', '".join(self.provisioned_device)) result_msg_list_changed.append(provisioned_device) if self.device_already_provisioned: - device_already_provisioned = "device(s) '{0}' already provisioned in Cisco Catalyst Center.".format("', '".join(self.device_already_provisioned)) + device_already_provisioned = "device(s) '{0}' already provisioned in Cisco Catalyst Center.".format( + "', '".join(self.device_already_provisioned)) result_msg_list_not_changed.append(device_already_provisioned) if self.device_list: @@ -4051,7 +4266,8 @@ def update_inventory_profile_messages(self): for sublist in self.device_list: for ip in sublist: flat_devices.append(ip) - device_lists_message = "device(s) '{0}' added successfully in Cisco Catalyst Center.".format("', '".join(flat_devices)) + device_lists_message = "device(s) '{0}' added successfully in Cisco Catalyst Center.".format( + "', '".join(flat_devices)) result_msg_list_changed.append(device_lists_message) if self.devices_already_present: @@ -4060,7 +4276,8 @@ def update_inventory_profile_messages(self): for sublist in self.devices_already_present: for ip in sublist: flat_devices.append(ip) - devices_already_present = "device(s) '{0}' already present in Cisco Catalyst Center.".format("', '".join(flat_devices)) + devices_already_present = "device(s) '{0}' already present in Cisco Catalyst Center.".format( + "', '".join(flat_devices)) result_msg_list_not_changed.append(devices_already_present) if self.provisioned_device_deleted: @@ -4069,7 +4286,8 @@ def update_inventory_profile_messages(self): result_msg_list_changed.append(provisioned_device_deleted) if self.deleted_devices: - deleted_devices = "device(s) '{0}' successfully deleted in Cisco Catalyst Center".format("', '".join(self.deleted_devices)) + deleted_devices = "device(s) '{0}' successfully deleted in Cisco Catalyst Center".format( + "', '".join(self.deleted_devices)) result_msg_list_changed.append(deleted_devices) if self.no_device_to_delete: @@ -4078,19 +4296,23 @@ def update_inventory_profile_messages(self): result_msg_list_not_changed.append(deleted_devices) if self.response_list: - response_list_for_update = "{0}".format(", ".join(self.response_list)) + response_list_for_update = "{0}".format( + ", ".join(self.response_list)) result_msg_list_changed.append(response_list_for_update) if self.role_updated_list: - role_updated_list = "Device(s) '{0}' role updated successfully to '{1}'".format(self.role_updated_list, self.device_role_name) + role_updated_list = "Device(s) '{0}' role updated successfully to '{1}'".format( + self.role_updated_list, self.device_role_name) result_msg_list_changed.append(role_updated_list) if self.udf_added: - udf_added = "Global User Defined Field(UDF) named '{0}' has been successfully added to the device.".format("', '".join(self.udf_added)) + udf_added = "Global User Defined Field(UDF) named '{0}' has been successfully added to the device.".format( + "', '".join(self.udf_added)) result_msg_list_changed.append(udf_added) if self.udf_deleted: - udf_deleted = "Global User Defined Field(UDF) named '{0}' has been successfully deleted to the device.".format("', '".join(self.udf_deleted)) + udf_deleted = "Global User Defined Field(UDF) named '{0}' has been successfully deleted to the device.".format( + "', '".join(self.udf_deleted)) result_msg_list_changed.append(udf_deleted) if self.updated_ip: @@ -4101,12 +4323,14 @@ def update_inventory_profile_messages(self): result_msg_list_changed.append(updated_ip_msg) if self.output_file_name: - output_file_name = "Device Details Exported Successfully to the CSV file: {0}".format("', '".join(self.output_file_name)) + output_file_name = "Device Details Exported Successfully to the CSV file: {0}".format( + "', '".join(self.output_file_name)) result_msg_list_changed.append(output_file_name) if result_msg_list_not_changed and result_msg_list_changed: self.result["changed"] = True - self.msg = "{0}, {1}".format(" ".join(result_msg_list_not_changed), " ".join(result_msg_list_changed)) + self.msg = "{0}, {1}".format( + " ".join(result_msg_list_not_changed), " ".join(result_msg_list_changed)) elif result_msg_list_not_changed: self.msg = " ".join(result_msg_list_not_changed) elif result_msg_list_changed: @@ -4166,7 +4390,8 @@ def main(): ccc_device.get_have(config).check_return_status() ccc_device.get_diff_state_apply[state](config).check_return_status() if config_verify: - ccc_device.verify_diff_state_apply[state](config).check_return_status() + ccc_device.verify_diff_state_apply[state]( + config).check_return_status() ccc_device.update_inventory_profile_messages().check_return_status() diff --git a/plugins/modules/ise_radius_integration_workflow_manager.py b/plugins/modules/ise_radius_integration_workflow_manager.py index 509a83f5e8..14a0f033ae 100644 --- a/plugins/modules/ise_radius_integration_workflow_manager.py +++ b/plugins/modules/ise_radius_integration_workflow_manager.py @@ -5,6 +5,15 @@ """Ansible module to operate the Authentication and Policy Servers in Cisco Catalyst Center.""" from __future__ import absolute_import, division, print_function +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + get_dict_result, + dnac_compare_equality, +) +from ansible.module_utils.basic import AnsibleModule +import time +import copy __metaclass__ = type __author__ = ["Muthu Rakesh, Madhan Sankaranarayanan"] @@ -411,16 +420,6 @@ } """ -import copy -import time -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - get_dict_result, - dnac_compare_equality, -) - class IseRadiusIntegration(DnacBase): """Class containing member attributes for ise_radius_integration_workflow_manager module""" @@ -496,14 +495,17 @@ def validate_input(self): } # Validate playbook params against the specification (temp_spec) - valid_temp, invalid_params = validate_list_of_dicts(self.config, temp_spec) + valid_temp, invalid_params = validate_list_of_dicts( + self.config, temp_spec) if invalid_params: - self.msg = "Invalid parameters in playbook: {0}".format("\n".join(invalid_params)) + self.msg = "Invalid parameters in playbook: {0}".format( + "\n".join(invalid_params)) self.status = "failed" return self self.validated_config = valid_temp - self.log("Successfully validated playbook config params: {0}".format(valid_temp), "INFO") + self.log("Successfully validated playbook config params: {0}".format( + valid_temp), "INFO") self.msg = "Successfully validated input from the playbook" self.status = "success" return self @@ -589,7 +591,8 @@ def get_auth_server_params(self, auth_server_info): self.log("Authentication and Policy Server data is empty", "INFO") return None - self.log("Authentication and Policy Server Details: {0}".format(auth_server_info), "DEBUG") + self.log("Authentication and Policy Server Details: {0}".format( + auth_server_info), "DEBUG") auth_server = { "authenticationPort": auth_server_info.get("authenticationPort"), "accountingPort": auth_server_info.get("accountingPort"), @@ -654,20 +657,24 @@ def auth_server_exists(self, ipAddress): return AuthServer all_auth_server_details = response.get("response") - auth_server_details = get_dict_result(all_auth_server_details, "ipAddress", ipAddress) + auth_server_details = get_dict_result( + all_auth_server_details, "ipAddress", ipAddress) self.log("Authentication and Policy Server Ip Address: {0}" .format(ipAddress), "DEBUG") self.log("Authentication and Policy Server details: {0}" .format(auth_server_details), "DEBUG") if not auth_server_details: - self.log("Authentication and Policy Server {0} does not exist".format(ipAddress), "INFO") + self.log("Authentication and Policy Server {0} does not exist".format( + ipAddress), "INFO") return AuthServer AuthServer.update({"exists": True}) AuthServer.update({"id": auth_server_details.get("instanceUuid")}) - AuthServer["details"] = self.get_auth_server_params(auth_server_details) + AuthServer["details"] = self.get_auth_server_params( + auth_server_details) - self.log("Formatted Authenticaion and Policy Server details: {0}".format(AuthServer), "DEBUG") + self.log("Formatted Authenticaion and Policy Server details: {0}".format( + AuthServer), "DEBUG") return AuthServer def get_have_authentication_policy_server(self, authentication_policy_server): @@ -707,7 +714,8 @@ def get_have_authentication_policy_server(self, authentication_policy_server): .format(ip_address, auth_server.get("id")), "DEBUG") all_auth_server_details.append(auth_server) - self.have.update({"authenticationPolicyServer": all_auth_server_details}) + self.have.update( + {"authenticationPolicyServer": all_auth_server_details}) self.msg = "Collecting the Authentication and Policy Server " + \ "details from the Cisco Catalyst Center." self.status = "success" @@ -726,13 +734,15 @@ def get_have(self, config): Authentication and Policy Server information. """ - authentication_policy_server = config.get("authentication_policy_server") + authentication_policy_server = config.get( + "authentication_policy_server") if authentication_policy_server is None: self.msg = "The 'authentication_policy_server' is missing in the playbook configuration." self.status = "failed" return self - self.get_have_authentication_policy_server(authentication_policy_server).check_return_status() + self.get_have_authentication_policy_server( + authentication_policy_server).check_return_status() self.log("Current State (have): {0}".format(self.have), "INFO") self.msg = "Successfully retrieved the details from the Cisco Catalyst Center" self.status = "success" @@ -757,7 +767,8 @@ def get_primary_ise_fqdn(self, cisco_ise_dtos, ip_address): "Input parameters - cisco_ise_dtos: {cisco_ise_dtos}, ip_address: {ip_address}" .format(cisco_ise_dtos=cisco_ise_dtos, ip_address=ip_address) ) - primary_node_ise_details = get_dict_result(cisco_ise_dtos, "role", "PRIMARY") + primary_node_ise_details = get_dict_result( + cisco_ise_dtos, "role", "PRIMARY") if not primary_node_ise_details: self.msg = ( "There are no details of the 'PRIMARY' role node in the multi-node ISE environment {ip_address}." @@ -802,13 +813,16 @@ def get_want_authentication_policy_server(self, auth_policy_server): auth_server_index = 0 for item in auth_policy_server: auth_server = {} - auth_server_exists = self.have.get("authenticationPolicyServer")[auth_server_index].get("exists") - auth_server_details = self.have.get("authenticationPolicyServer")[auth_server_index].get("details") + auth_server_exists = self.have.get("authenticationPolicyServer")[ + auth_server_index].get("exists") + auth_server_details = self.have.get("authenticationPolicyServer")[ + auth_server_index].get("details") trusted_server = False if not auth_server_exists: server_type = item.get("server_type") if server_type not in ["ISE", "AAA", None]: - self.msg = "The 'server_type' should be either 'ISE' or 'AAA' but {0} was provided.".format(server_type) + self.msg = "The 'server_type' should be either 'ISE' or 'AAA' but {0} was provided.".format( + server_type) self.status = "failed" return self @@ -817,11 +831,13 @@ def get_want_authentication_policy_server(self, auth_policy_server): else: auth_server.update({"isIseEnabled": False}) else: - auth_server.update({"isIseEnabled": auth_server_details.get("isIseEnabled")}) + auth_server.update( + {"isIseEnabled": auth_server_details.get("isIseEnabled")}) auth_server.update({"ipAddress": item.get("server_ip_address")}) - auth_server_exists = self.have.get("authenticationPolicyServer")[auth_server_index].get("exists") + auth_server_exists = self.have.get("authenticationPolicyServer")[ + auth_server_index].get("exists") if not auth_server_exists: shared_secret = item.get("shared_secret") @@ -860,7 +876,8 @@ def get_want_authentication_policy_server(self, auth_policy_server): if not auth_server_exists: auth_server.update({"protocol": "RADIUS"}) else: - auth_server.update({"protocol": auth_server_details.get("protocol")}) + auth_server.update( + {"protocol": auth_server_details.get("protocol")}) auth_server.update({"port": 49}) @@ -868,7 +885,8 @@ def get_want_authentication_policy_server(self, auth_policy_server): encryption_scheme = item.get("encryption_scheme") if encryption_scheme not in ["KEYWRAP", "RADSEC", None]: self.msg = "The 'encryption_scheme' should be in ['KEYWRAP', 'RADSEC']. " + \ - "It should not be {0}.".format(encryption_scheme) + "It should not be {0}.".format( + encryption_scheme) self.status = "failed" return self @@ -923,7 +941,8 @@ def get_want_authentication_policy_server(self, auth_policy_server): auth_server.update({"authenticationPort": authentication_port}) else: - auth_server.update({"authenticationPort": auth_server_details.get("authenticationPort")}) + auth_server.update( + {"authenticationPort": auth_server_details.get("authenticationPort")}) if not auth_server_exists: accounting_port = item.get("accounting_port") @@ -942,14 +961,16 @@ def get_want_authentication_policy_server(self, auth_policy_server): auth_server.update({"accountingPort": accounting_port}) else: - auth_server.update({"accountingPort": auth_server_details.get("accountingPort")}) + auth_server.update( + {"accountingPort": auth_server_details.get("accountingPort")}) retries = item.get("retries") if not retries: if not auth_server_exists: auth_server.update({"retries": "3"}) else: - auth_server.update({"retries": auth_server_details.get("retries")}) + auth_server.update( + {"retries": auth_server_details.get("retries")}) else: try: retries_int = int(retries) @@ -968,7 +989,8 @@ def get_want_authentication_policy_server(self, auth_policy_server): if not auth_server_exists: default_timeout = "4" else: - default_timeout = str(auth_server_details.get("timeoutSeconds")) + default_timeout = str( + auth_server_details.get("timeoutSeconds")) # If 'timeout' is not provided, use 'default_timeout' if timeout is None: @@ -1015,7 +1037,8 @@ def get_want_authentication_policy_server(self, auth_policy_server): self.status = "failed" return self - user_name = auth_server_details.get("ciscoIseDtos")[0].get("userName") + user_name = auth_server_details.get( + "ciscoIseDtos")[0].get("userName") auth_server.get("ciscoIseDtos")[position_ise_creds].update({ "userName": user_name @@ -1048,7 +1071,8 @@ def get_want_authentication_policy_server(self, auth_policy_server): fqdn = ise_credential.get("fqdn") if not fqdn: - self.log("FQDN is missing in the provided ISE credentials, proceeding to fetch it...", "DEBUG") + self.log( + "FQDN is missing in the provided ISE credentials, proceeding to fetch it...", "DEBUG") if not auth_server_exists: self.msg = "The required parameter 'fqdn' is missing when 'server_type' is 'ISE'." self.log(str(self.msg), "ERROR") @@ -1065,7 +1089,8 @@ def get_want_authentication_policy_server(self, auth_policy_server): function='get_authentication_and_policy_servers', params={"is_ise_enabled": True} ) - self.log("Successfully retrieved authentication server response; processing Cisco ISE details.", "DEBUG") + self.log( + "Successfully retrieved authentication server response; processing Cisco ISE details.", "DEBUG") response = response.get("response") if response is None: self.msg = ( @@ -1078,22 +1103,28 @@ def get_want_authentication_policy_server(self, auth_policy_server): cisco_ise_dtos = response[0].get("ciscoIseDtos") if not cisco_ise_dtos: - self.msg = "No Cisco ISE details available for IP '{0}'.".format(ip_address) + self.msg = "No Cisco ISE details available for IP '{0}'.".format( + ip_address) self.status = "failed" self.log(str(self.msg), "ERROR") return self - self.log("Cisco ISE details found; retrieving FQDN of primary node...", "DEBUG") - fqdn = self.get_primary_ise_fqdn(cisco_ise_dtos, ip_address) - self.log("Updating authentication server details with FQDN...", "DEBUG") + self.log( + "Cisco ISE details found; retrieving FQDN of primary node...", "DEBUG") + fqdn = self.get_primary_ise_fqdn( + cisco_ise_dtos, ip_address) + self.log( + "Updating authentication server details with FQDN...", "DEBUG") self.log( "Retrieved FQDN for primary ISE node with IP '{ip}': {fqdn}" .format(ip=ip_address, fqdn=fqdn), "INFO" ) - auth_server.get("ciscoIseDtos")[position_ise_creds].update({"fqdn": fqdn}) - self.log("Authentication server details successfully updated with FQDN.", "INFO") + auth_server.get("ciscoIseDtos")[ + position_ise_creds].update({"fqdn": fqdn}) + self.log( + "Authentication server details successfully updated with FQDN.", "INFO") if not auth_server_exists: auth_server.get("ciscoIseDtos")[position_ise_creds].update({ @@ -1121,7 +1152,8 @@ def get_want_authentication_policy_server(self, auth_policy_server): pxgrid_enabled = item.get("pxgrid_enabled") if pxgrid_enabled is None: if auth_server_exists: - pxgrid_enabled = auth_server_details.get("pxgridEnabled") + pxgrid_enabled = auth_server_details.get( + "pxgridEnabled") else: pxgrid_enabled = True @@ -1130,11 +1162,13 @@ def get_want_authentication_policy_server(self, auth_policy_server): use_dnac_cert_for_pxgrid = item.get("use_dnac_cert_for_pxgrid") if use_dnac_cert_for_pxgrid is None: if auth_server_exists: - use_dnac_cert_for_pxgrid = auth_server_details.get("useDnacCertForPxgrid") + use_dnac_cert_for_pxgrid = auth_server_details.get( + "useDnacCertForPxgrid") else: use_dnac_cert_for_pxgrid = False - auth_server.update({"useDnacCertForPxgrid": use_dnac_cert_for_pxgrid}) + auth_server.update( + {"useDnacCertForPxgrid": use_dnac_cert_for_pxgrid}) external_cisco_ise_ip_addr_dtos = item \ .get("external_cisco_ise_ip_addr_dtos") @@ -1145,7 +1179,8 @@ def get_want_authentication_policy_server(self, auth_policy_server): external_cisco_ise_ip_addresses = external_cisco_ise \ .get("external_cisco_ise_ip_addresses") if external_cisco_ise_ip_addresses: - auth_server.get("externalCiscoIseIpAddrDtos").append({}) + auth_server.get( + "externalCiscoIseIpAddrDtos").append({}) auth_server.get("externalCiscoIseIpAddrDtos")[position_ise_addresses] \ .update({"externalCiscoIseIpAddresses": []}) position_ise_address = 0 @@ -1171,12 +1206,14 @@ def get_want_authentication_policy_server(self, auth_policy_server): self.want.update({"trusted_server": trusted_server}) - ise_integration_wait_time = item.get("ise_integration_wait_time") + ise_integration_wait_time = item.get( + "ise_integration_wait_time") if ise_integration_wait_time is None: ise_integration_wait_time = 20 else: try: - ise_integration_wait_time_int = int(ise_integration_wait_time) + ise_integration_wait_time_int = int( + ise_integration_wait_time) if ise_integration_wait_time_int < 1 or ise_integration_wait_time_int > 120: self.msg = "The 'ise_integration_wait_time' should be from 1 to 120 seconds." self.status = "failed" @@ -1187,14 +1224,16 @@ def get_want_authentication_policy_server(self, auth_policy_server): self.status = "failed" return self - self.want.update({"ise_integration_wait_time": ise_integration_wait_time}) + self.want.update( + {"ise_integration_wait_time": ise_integration_wait_time}) self.log("Authentication and Policy Server playbook details: {0}" .format(auth_server), "DEBUG") all_auth_server_details.append(auth_server) auth_server_index += 1 - self.want.update({"authenticationPolicyServer": all_auth_server_details}) + self.want.update( + {"authenticationPolicyServer": all_auth_server_details}) self.msg = "Collecting the Authentication and Policy Server details from the playbook" self.status = "success" return self @@ -1212,7 +1251,8 @@ def get_want(self, config): if config.get("authentication_policy_server"): auth_policy_server = config.get("authentication_policy_server") - self.get_want_authentication_policy_server(auth_policy_server).check_return_status() + self.get_want_authentication_policy_server( + auth_policy_server).check_return_status() self.log("Desired State (want): {0}".format(self.want), "INFO") self.msg = "Successfully retrieved details from the playbook" @@ -1248,7 +1288,8 @@ def check_ise_server_integration_status(self, ip_address): overall_status = cisco_ise_status.get("overallStatus") statuses = ["WAITING_USER_INPUT", "COMPLETE"] if overall_status in statuses: - self.log("The status of the Cisco ISE server is '{status}'".format(status=overall_status)) + self.log("The status of the Cisco ISE server is '{status}'".format( + status=overall_status)) break if (time.time() - start_time) >= 10: @@ -1337,12 +1378,14 @@ def check_auth_server_response_status(self, response, validation_string_set, api end_time = time.time() if (end_time - start_time) >= self.max_timeout: self.msg = "Max timeout of {0} sec has reached for the execution id '{1}'.".format(self.max_timeout, task_id) + \ - "Exiting the loop due to unexpected API '{0}' status.".format(api_name) + "Exiting the loop due to unexpected API '{0}' status.".format( + api_name) self.status = "failed" break task_details = self.get_task_details(task_id) - self.log('Getting task details from task ID {0}: {1}'.format(task_id, task_details), "DEBUG") + self.log('Getting task details from task ID {0}: {1}'.format( + task_id, task_details), "DEBUG") if task_details.get("isError") is True: failure_reason = task_details.get("failureReason") if failure_reason: @@ -1360,13 +1403,16 @@ def check_auth_server_response_status(self, response, validation_string_set, api break if self.result['changed'] is True: - self.log("The task with task id '{0}' is successfully executed".format(task_id), "DEBUG") + self.log("The task with task id '{0}' is successfully executed".format( + task_id), "DEBUG") break # sleep time after checking the status of the response from the API - self.log("The time interval before checking the next response, sleep for {0}".format(sleep_time)) + self.log("The time interval before checking the next response, sleep for {0}".format( + sleep_time)) time.sleep(sleep_time) - self.log("Progress set to {0} for taskid: {1}".format(task_details.get('progress'), task_id), "DEBUG") + self.log("Progress set to {0} for taskid: {1}".format( + task_details.get('progress'), task_id), "DEBUG") return self @@ -1405,7 +1451,8 @@ def check_ise_server_updation_status(self, have_auth_details, want_auth_details) if state != "ACTIVE": self.log( "Cisco ISE server '{ip_address}' is not in 'ACTIVE' state (current state: '{state}'). " - "Update required.".format(ip_address=ip_address, state=state), "DEBUG" + "Update required.".format( + ip_address=ip_address, state=state), "DEBUG" ) return True @@ -1450,7 +1497,8 @@ def format_payload_for_update(self, have_auth_server, want_auth_server): self.status = "failed" return self - self.log("Successfully formatted the parameter of the payload for updating the authentication and policy server.") + self.log( + "Successfully formatted the parameter of the payload for updating the authentication and policy server.") self.msg = "Successfully formatted the parameter of the payload for updating the authentication and policy server." self.status = "success" return self @@ -1467,7 +1515,8 @@ def update_auth_policy_server(self, authentication_policy_server): None """ - result_auth_server = self.result.get("response")[0].get("authenticationPolicyServer") + result_auth_server = self.result.get( + "response")[0].get("authenticationPolicyServer") auth_server_index = -1 for item in authentication_policy_server: auth_server_index += 1 @@ -1475,9 +1524,11 @@ def update_auth_policy_server(self, authentication_policy_server): result_auth_server.get("response").update({ip_address: {}}) # Check Authentication and Policy Server exist, if not create and return - is_ise_server = self.want.get("authenticationPolicyServer")[auth_server_index].get("isIseEnabled") + is_ise_server = self.want.get("authenticationPolicyServer")[ + auth_server_index].get("isIseEnabled") if not self.have.get("authenticationPolicyServer")[auth_server_index].get("exists"): - auth_server_params = self.want.get("authenticationPolicyServer")[auth_server_index] + auth_server_params = self.want.get("authenticationPolicyServer")[ + auth_server_index] self.log("Desired State for Authentication and Policy Server for the IP '{0}' (want): {1}" .format(ip_address, auth_server_params), "DEBUG") function_name = "add_authentication_and_policy_server_access_configuration" @@ -1487,11 +1538,14 @@ def update_auth_policy_server(self, authentication_policy_server): params=auth_server_params, ) if self.get_ccc_version_as_integer() >= self.get_ccc_version_as_int_from_str("2.3.7.9"): - validation_string_set = ("successfully created aaa settings", "operation successful") + validation_string_set = ( + "successfully created aaa settings", "operation successful") else: - validation_string_set = ("successfully created aaa settings", "operation sucessful") + validation_string_set = ( + "successfully created aaa settings", "operation sucessful") - self.check_auth_server_response_status(response, validation_string_set, function_name) + self.check_auth_server_response_status( + response, validation_string_set, function_name) if self.status == "failed": self.log(self.msg, "ERROR") return @@ -1499,8 +1553,10 @@ def update_auth_policy_server(self, authentication_policy_server): if is_ise_server: trusted_server = self.want.get("trusted_server") self.check_ise_server_integration_status(ip_address) - self.accept_cisco_ise_server_certificate(ip_address, trusted_server) - ise_integration_wait_time = self.want.get("ise_integration_wait_time") + self.accept_cisco_ise_server_certificate( + ip_address, trusted_server) + ise_integration_wait_time = self.want.get( + "ise_integration_wait_time") time.sleep(ise_integration_wait_time) response = self.dnac._exec( family="system_settings", @@ -1514,7 +1570,8 @@ def update_auth_policy_server(self, authentication_policy_server): self.status = "failed" return - ise_server_details = get_dict_result(response, "ipAddress", ip_address) + ise_server_details = get_dict_result( + response, "ipAddress", ip_address) ise_state_set = {"FAILED", "INPROGRESS"} state = ise_server_details.get("state") if state in ise_state_set: @@ -1547,24 +1604,31 @@ def update_auth_policy_server(self, authentication_policy_server): # Authentication and Policy Server exists, check update is required # Edit API not working, remove this - have_auth_server_details = self.have.get("authenticationPolicyServer")[auth_server_index].get("details") - want_auth_server_details = self.want.get("authenticationPolicyServer")[auth_server_index] + have_auth_server_details = self.have.get("authenticationPolicyServer")[ + auth_server_index].get("details") + want_auth_server_details = self.want.get( + "authenticationPolicyServer")[auth_server_index] self.log( "Formatting payload for update between current and desired authentication server details.", "DEBUG" ) - self.format_payload_for_update(have_auth_server_details, want_auth_server_details).check_return_status() + self.format_payload_for_update( + have_auth_server_details, want_auth_server_details).check_return_status() - is_ise_server_enabled = have_auth_server_details.get("isIseEnabled") + is_ise_server_enabled = have_auth_server_details.get( + "isIseEnabled") ise_server_requires_update = False if is_ise_server_enabled: - self.log("Cisco ISE server is enabled; checking if an update is required.") + self.log( + "Cisco ISE server is enabled; checking if an update is required.") ise_server_requires_update = self.check_ise_server_updation_status(have_auth_server_details, want_auth_server_details) if ise_server_requires_update: - self.log("Cisco ISE server requires an update based on configuration changes.", "DEBUG") + self.log( + "Cisco ISE server requires an update based on configuration changes.", "DEBUG") else: - self.log("Cisco ISE server does not require any updates.", "DEBUG") + self.log( + "Cisco ISE server does not require any updates.", "DEBUG") if not (ise_server_requires_update or self.requires_update(have_auth_server_details, want_auth_server_details, @@ -1587,7 +1651,8 @@ def update_auth_policy_server(self, authentication_policy_server): # Authenticaiton and Policy Server Exists auth_server_params = copy.deepcopy(want_auth_server_details) - auth_server_params.update({"id": self.have.get("authenticationPolicyServer")[auth_server_index].get("id")}) + auth_server_params.update({"id": self.have.get( + "authenticationPolicyServer")[auth_server_index].get("id")}) self.log("Desired State for Authentication and Policy Server (want): {0}" .format(auth_server_params), "DEBUG") self.log("Current State for Authentication and Policy Server (have): {0}" @@ -1599,11 +1664,14 @@ def update_auth_policy_server(self, authentication_policy_server): params=auth_server_params, ) if self.get_ccc_version_as_integer() >= self.get_ccc_version_as_int_from_str("2.3.7.9"): - validation_string_set = ("successfully updated aaa settings", "operation successful") + validation_string_set = ( + "successfully updated aaa settings", "operation successful") else: - validation_string_set = ("successfully updated aaa settings", "operation sucessful") + validation_string_set = ( + "successfully updated aaa settings", "operation sucessful") - self.check_auth_server_response_status(response, validation_string_set, function_name) + self.check_auth_server_response_status( + response, validation_string_set, function_name) if self.status == "failed": self.log(self.msg, "ERROR") return @@ -1614,8 +1682,10 @@ def update_auth_policy_server(self, authentication_policy_server): state = have_auth_server_details.get("state") if state != "ACTIVE": self.check_ise_server_integration_status(ip_address) - self.accept_cisco_ise_server_certificate(ip_address, trusted_server) - ise_integration_wait_time = self.want.get("ise_integration_wait_time") + self.accept_cisco_ise_server_certificate( + ip_address, trusted_server) + ise_integration_wait_time = self.want.get( + "ise_integration_wait_time") time.sleep(ise_integration_wait_time) ise_details = self.dnac._exec( @@ -1660,7 +1730,8 @@ def update_auth_policy_server(self, authentication_policy_server): result_auth_server.get("response").get(ip_address) \ .update({"Id": self.have.get("authenticationPolicyServer")[auth_server_index].get("id")}) result_auth_server.get("msg").update({ - ip_address: "Authentication and Policy Server Updated Successfully.{0}".format(trusted_server_msg) + ip_address: "Authentication and Policy Server Updated Successfully.{0}".format( + trusted_server_msg) }) return @@ -1678,7 +1749,8 @@ def get_diff_merged(self, config): self """ - authentication_policy_server = config.get("authentication_policy_server") + authentication_policy_server = config.get( + "authentication_policy_server") if authentication_policy_server is not None: self.update_auth_policy_server(authentication_policy_server) @@ -1695,11 +1767,13 @@ def delete_auth_policy_server(self, authentication_policy_server): self """ - result_auth_server = self.result.get("response")[0].get("authenticationPolicyServer") + result_auth_server = self.result.get( + "response")[0].get("authenticationPolicyServer") auth_server_index = 0 for item in authentication_policy_server: ipAddress = item.get("server_ip_address") - auth_server_exists = self.have.get("authenticationPolicyServer")[auth_server_index].get("exists") + auth_server_exists = self.have.get("authenticationPolicyServer")[ + auth_server_index].get("exists") if not auth_server_exists: result_auth_server.get("msg").update({ ipAddress: "Authentication and Policy Server not found." @@ -1712,7 +1786,8 @@ def delete_auth_policy_server(self, authentication_policy_server): response = self.dnac._exec( family="system_settings", function="delete_authentication_and_policy_server_access_configuration", - params={"id": self.have.get("authenticationPolicyServer")[auth_server_index].get("id")}, + params={"id": self.have.get("authenticationPolicyServer")[ + auth_server_index].get("id")}, ) self.log("Received API response for 'delete_authentication_and_" @@ -1720,16 +1795,19 @@ def delete_auth_policy_server(self, authentication_policy_server): # Check the task status validation_string = "successfully deleted aaa settings" - self.check_task_response_status(response, validation_string, "delete_authentication_and_policy_server_access_configuration").check_return_status() + self.check_task_response_status( + response, validation_string, "delete_authentication_and_policy_server_access_configuration").check_return_status() taskid = response.get("response").get("taskId") # Update result information result_auth_server.get("response").update({ipAddress: {}}) - result_auth_server.get("response").get(ipAddress).update({"Task Id": taskid}) + result_auth_server.get("response").get( + ipAddress).update({"Task Id": taskid}) result_auth_server.get("msg").update({ ipAddress: "Authentication and Policy Server deleted successfully." }) - self.log("Authentication and Policy Server - {0} deleted successfully.".format(ipAddress)) + self.log( + "Authentication and Policy Server - {0} deleted successfully.".format(ipAddress)) auth_server_index += 1 self.msg = "Authentication and Policy Server(s) deleted successfully." @@ -1747,9 +1825,11 @@ def get_diff_deleted(self, config): self """ - authentication_policy_server = config.get("authentication_policy_server") + authentication_policy_server = config.get( + "authentication_policy_server") if authentication_policy_server is not None: - self.delete_auth_policy_server(authentication_policy_server).check_return_status() + self.delete_auth_policy_server( + authentication_policy_server).check_return_status() return self @@ -1792,7 +1872,8 @@ def verify_diff_merged(self, config): auth_server_index += 1 - self.log("Successfully validated Authentication and Policy Server(s).", "INFO") + self.log( + "Successfully validated Authentication and Policy Server(s).", "INFO") self.result.get("response")[0].get("authenticationPolicyServer").update({ "Validation": "Success" }) @@ -1817,13 +1898,15 @@ def verify_diff_deleted(self, config): self.get_have(config) self.log("Current State (have): {0}".format(self.have), "INFO") auth_server_index = 0 - authentication_policy_server = config.get("authentication_policy_server") + authentication_policy_server = config.get( + "authentication_policy_server") for item in authentication_policy_server: ip_address = item.get("server_ip_address") self.log("Authentication and Policy Server deleted from the Cisco Catalyst Center: {0}" .format(ip_address), "INFO") if item is not None: - auth_server_exists = self.have.get("authenticationPolicyServer")[auth_server_index].get("exists") + auth_server_exists = self.have.get("authenticationPolicyServer")[ + auth_server_index].get("exists") if auth_server_exists: self.msg = ("Authentication and Policy Server with IP '{0}' " "config is not applied to the Cisco Catalyst Center.".format(ip_address)) @@ -1884,7 +1967,8 @@ def main(): } # Create an AnsibleModule object with argument specifications - module = AnsibleModule(argument_spec=element_spec, supports_check_mode=False) + module = AnsibleModule(argument_spec=element_spec, + supports_check_mode=False) ccc_ise_radius = IseRadiusIntegration(module) if ccc_ise_radius.compare_dnac_versions(ccc_ise_radius.get_ccc_version(), "2.3.5.3") < 0: ccc_ise_radius.msg = ( @@ -1910,9 +1994,11 @@ def main(): ccc_ise_radius.get_have(config).check_return_status() if state != "deleted": ccc_ise_radius.get_want(config).check_return_status() - ccc_ise_radius.get_diff_state_apply[state](config).check_return_status() + ccc_ise_radius.get_diff_state_apply[state]( + config).check_return_status() if config_verify: - ccc_ise_radius.verify_diff_state_apply[state](config).check_return_status() + ccc_ise_radius.verify_diff_state_apply[state]( + config).check_return_status() module.exit_json(**ccc_ise_radius.result) diff --git a/plugins/modules/lan_automation_workflow_manager.py b/plugins/modules/lan_automation_workflow_manager.py index 05d6df3e41..5f4bfa0227 100644 --- a/plugins/modules/lan_automation_workflow_manager.py +++ b/plugins/modules/lan_automation_workflow_manager.py @@ -5,6 +5,12 @@ # 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) +import time +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts +) +from ansible.module_utils.basic import AnsibleModule __metaclass__ = type __author__ = ("Luna Aliaj, Madhan Sankaranarayanan") @@ -518,13 +524,6 @@ } """ -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts -) -import time - class LanAutomation(DnacBase): """ Class containing member attributes for lan automation workflow manager module """ @@ -803,7 +802,8 @@ def get_have(self, config): active_lan_automation = False lan_automation_session_ids = [] - (active_lan_automation, lan_automation_session_ids) = self.active_lan_automation_sessions() + (active_lan_automation, + lan_automation_session_ids) = self.active_lan_automation_sessions() self.log("Current active LAN Automation sessions (have): {} and their ids are: {}".format( str(active_lan_automation), @@ -815,12 +815,14 @@ def get_have(self, config): have["activeSessionIds"] = lan_automation_session_ids lan_automation_sessions = self.get_lan_automation_status() - session_to_ip_map = self.map_active_sessions_to_primary_ip(lan_automation_sessions, lan_automation_session_ids) + session_to_ip_map = self.map_active_sessions_to_primary_ip( + lan_automation_sessions, lan_automation_session_ids) if session_to_ip_map: have['session_to_ip_map'] = session_to_ip_map - self.log("Mapped active session IDs to primary IPs: {}".format(str(session_to_ip_map)), "INFO") + self.log("Mapped active session IDs to primary IPs: {}".format( + str(session_to_ip_map)), "INFO") self.have = have self.log("Current State (self.have): {}".format(str(self.have)), "INFO") @@ -855,7 +857,8 @@ def map_active_sessions_to_primary_ip(self, lan_automation_sessions, lan_automat session_id_to_primary_ip[session_id] = primary_ip - self.log("Mapped active session IDs to primary IPs: {}".format(session_id_to_primary_ip), "INFO") + self.log("Mapped active session IDs to primary IPs: {}".format( + session_id_to_primary_ip), "INFO") return session_id_to_primary_ip @@ -879,17 +882,21 @@ def active_lan_automation_sessions(self): ) except Exception as e: - self.log("Error occurred while retrieving active LAN automation sessions", "WARNING") + self.log( + "Error occurred while retrieving active LAN automation sessions", "WARNING") active_sessions = 0 active_session_ids = [] if response and response.get("response"): - active_sessions = int(response["response"].get("activeSessions", 0)) - active_session_ids = response["response"].get("activeSessionIds", []) + active_sessions = int( + response["response"].get("activeSessions", 0)) + active_session_ids = response["response"].get( + "activeSessionIds", []) if active_sessions > 0: - self.log("Active LAN automation sessions: {}".format(str(active_sessions)), "INFO") + self.log("Active LAN automation sessions: {}".format( + str(active_sessions)), "INFO") else: self.log("No active LAN automation sessions found.", "INFO") else: @@ -919,13 +926,15 @@ def get_lan_automation_status(self): ) except Exception as e: - self.log("Error occurred while retrieving LAN automation status", "WARNING") + self.log( + "Error occurred while retrieving LAN automation status", "WARNING") return [] if response and response.get("response"): sessions = response["response"] if sessions: - self.log("Retrieved {} LAN automation session(s).".format(str(len(sessions))), "INFO") + self.log("Retrieved {} LAN automation session(s).".format( + str(len(sessions))), "INFO") else: self.log("No LAN automation sessions found.", "INFO") else: @@ -965,7 +974,8 @@ def get_ip_details(self, management_ip_address, device_type): ) if response: - self.log("Received IP address details for {0}: {1}".format(device_type, management_ip_address), "DEBUG") + self.log("Received IP address details for {0}: {1}".format( + device_type, management_ip_address), "DEBUG") ip = response.get("response") if ip and len(ip) > 0: ip_exists = True @@ -1002,15 +1012,18 @@ def get_hostname_details(self, management_ip_address): return None if response: - self.log("Received device details for IP address {0}.".format(management_ip_address), "DEBUG") + self.log("Received device details for IP address {0}.".format( + management_ip_address), "DEBUG") device_details = response.get("response", []) if len(device_details) > 0: hostname = device_details[0].get("hostname") if hostname: - self.log("Hostname for IP {0} is {1}.".format(management_ip_address, hostname), "INFO") + self.log("Hostname for IP {0} is {1}.".format( + management_ip_address, hostname), "INFO") else: - self.log("No device found with IP address {0}.".format(management_ip_address), "WARNING") + self.log("No device found with IP address {0}.".format( + management_ip_address), "WARNING") return hostname @@ -1035,17 +1048,20 @@ def get_site_details(self, site_name_hierarchy): op_modifies=True ) except Exception: - self.log("Exception occurred as site '{0}' was not found".format(site_name_hierarchy), "CRITICAL") + self.log("Exception occurred as site '{0}' was not found".format( + site_name_hierarchy), "CRITICAL") self.module.fail_json( msg="Site {0} does not exist. Please provide a valid discovered device site name!".format( site_name_hierarchy), response=[]) if response: - self.log("Received site details for '{0}': {1}".format(site_name_hierarchy, str(response)), "DEBUG") + self.log("Received site details for '{0}': {1}".format( + site_name_hierarchy, str(response)), "DEBUG") site = response.get("response") if len(site) == 1: site_exists = True - self.log("Site Name: {0} exists in the Cisco Catalyst Center".format(site_name_hierarchy), "INFO") + self.log("Site Name: {0} exists in the Cisco Catalyst Center".format( + site_name_hierarchy), "INFO") return site_exists @@ -1077,7 +1093,8 @@ def get_want(self, config): state = self.params.get("state") if state == "merged": - want["lan_automation"], lan_auto_missing_params = self.extract_lan_automation(config) + want["lan_automation"], lan_auto_missing_params = self.extract_lan_automation( + config) missing_params.extend(lan_auto_missing_params) want[ @@ -1086,11 +1103,13 @@ def get_want(self, config): missing_params.extend(lan_auto_device_missing_params) elif state == "deleted": - want["lan_automation"], lan_auto_missing_params = self.extract_lan_automation(config) + want["lan_automation"], lan_auto_missing_params = self.extract_lan_automation( + config) missing_params.extend(lan_auto_missing_params) if missing_params: - missing_msg = "The following required parameters are missing or invalid: " + ", ".join(missing_params) + missing_msg = "The following required parameters are missing or invalid: " + \ + ", ".join(missing_params) self.log(missing_msg, "ERROR") self.module.fail_json(msg=missing_msg, response=[]) @@ -1153,7 +1172,8 @@ def update_dict_keys_to_camel_case(self, input_data): else: updated_key = self.snake_to_camel(key) - updated_dict[updated_key] = self.update_dict_keys_to_camel_case(value) + updated_dict[updated_key] = self.update_dict_keys_to_camel_case( + value) return updated_dict elif isinstance(input_data, list): @@ -1183,7 +1203,8 @@ def extract_lan_automation(self, config): missing_params = [] if not isinstance(lan_automation, dict): - self.log("lan_automation is not a dict, but a {}".format(type(lan_automation))) + self.log("lan_automation is not a dict, but a {}".format( + type(lan_automation))) return None, missing_params state = self.params.get("state") @@ -1195,38 +1216,51 @@ def extract_lan_automation(self, config): "lan_automation -> primary_device_management_ip_address", missing_params ) - self.log("Validated primary_device_management_ip_address for deletion", "INFO") + self.log( + "Validated primary_device_management_ip_address for deletion", "INFO") return lan_automation, missing_params if state == "merged": - discovered_site_name = lan_automation.get("discovered_device_site_name_hierarchy") + discovered_site_name = lan_automation.get( + "discovered_device_site_name_hierarchy") if not discovered_site_name: - missing_params.append("lan_automation -> discovered_device_site_name_hierarchy") - self.log("Missing parameter: lan_automation -> discovered_device_site_name_hierarchy", "ERROR") + missing_params.append( + "lan_automation -> discovered_device_site_name_hierarchy") + self.log( + "Missing parameter: lan_automation -> discovered_device_site_name_hierarchy", "ERROR") else: - self.log("Validating discovered site name: {}".format(discovered_site_name), "INFO") + self.log("Validating discovered site name: {}".format( + discovered_site_name), "INFO") if not self.get_site_details(discovered_site_name): self.fail_with_error( - "Invalid site \"{}\". Please provide a valid site!".format(discovered_site_name) + "Invalid site \"{}\". Please provide a valid site!".format( + discovered_site_name) ) else: - self.log("Discovered site name '{}' exists and is valid.".format(discovered_site_name), "DEBUG") + self.log("Discovered site name '{}' exists and is valid.".format( + discovered_site_name), "DEBUG") - primary_device_ip = lan_automation.get("primary_device_management_ip_address") - self.log("Validating primary device management IP address: {}".format(primary_device_ip), "INFO") + primary_device_ip = lan_automation.get( + "primary_device_management_ip_address") + self.log("Validating primary device management IP address: {}".format( + primary_device_ip), "INFO") self.validate_ipv4_ip(primary_device_ip, "lan_automation -> primary_device_management_ip_address", missing_params) if not self.get_ip_details(primary_device_ip, "lan_automation -> primary_device_management_ip_address"): self.module.fail_json( msg="IP address: {} does not exist in Catalyst Center. Please provide a valid IP address for " - "'lan_automation -> primary_device_management_ip_address'!".format(primary_device_ip), + "'lan_automation -> primary_device_management_ip_address'!".format( + primary_device_ip), response=[] ) - self.log("Primary device management IP address '{}' is valid.".format(primary_device_ip), "DEBUG") + self.log("Primary device management IP address '{}' is valid.".format( + primary_device_ip), "DEBUG") - peer_device_ip = lan_automation.get("peer_device_management_ip_address") + peer_device_ip = lan_automation.get( + "peer_device_management_ip_address") if peer_device_ip: - self.log("Validating peer device management IP address: {}".format(peer_device_ip), "INFO") + self.log("Validating peer device management IP address: {}".format( + peer_device_ip), "INFO") self.validate_ipv4_ip(peer_device_ip, "lan_automation -> peer_device_management_ip_address", missing_params) if not self.get_ip_details(peer_device_ip, "lan_automation -> peer_device_management_ip_address"): @@ -1234,43 +1268,56 @@ def extract_lan_automation(self, config): msg="IP address: {} does not exist in Catalyst Center. Please provide a valid IP address for " "'lan_automation -> peer_device_management_ip_address'!".format(peer_device_ip), response=[] ) - self.log("Peer device management IP address '{}' is valid.".format(peer_device_ip), "DEBUG") + self.log("Peer device management IP address '{}' is valid.".format( + peer_device_ip), "DEBUG") else: - self.log("Peer device IP not provided. Skipping peer device checks.", "INFO") + self.log( + "Peer device IP not provided. Skipping peer device checks.", "INFO") - primary_device_interfaces = lan_automation.get("primary_device_interface_names") + primary_device_interfaces = lan_automation.get( + "primary_device_interface_names") if not primary_device_interfaces: - missing_params.append("lan_automation -> primary_device_interface_names") - self.log("Missing parameter: lan_automation -> primary_device_interface_names", "ERROR") + missing_params.append( + "lan_automation -> primary_device_interface_names") + self.log( + "Missing parameter: lan_automation -> primary_device_interface_names", "ERROR") else: - self.log("Primary device interface names provided: {}".format(primary_device_interfaces), "DEBUG") + self.log("Primary device interface names provided: {}".format( + primary_device_interfaces), "DEBUG") - self.validate_ip_pools(lan_automation.get("ip_pools"), missing_params) + self.validate_ip_pools( + lan_automation.get("ip_pools"), missing_params) self.log("Validating discovery devices.", "INFO") - self.validate_discovery_devices(lan_automation.get("discovery_devices"), missing_params) + self.validate_discovery_devices( + lan_automation.get("discovery_devices"), missing_params) self.log("Completed validation of lan_automation parameters.", "INFO") - self.log("Validate launch_and_wait, pnp_authorization and if not provided set default to False.", "INFO") + self.log( + "Validate launch_and_wait, pnp_authorization and if not provided set default to False.", "INFO") launch_and_wait = lan_automation.get("launch_and_wait") if not isinstance(launch_and_wait, bool): self.log( - "Invalid value for 'launch_and_wait': {}. Defaulting to 'false'.".format(launch_and_wait), + "Invalid value for 'launch_and_wait': {}. Defaulting to 'false'.".format( + launch_and_wait), "WARNING" ) launch_and_wait = False # Default to False lan_automation["launch_and_wait"] = launch_and_wait - self.log("'launch_and_wait' set to: {}".format(launch_and_wait), "INFO") + self.log("'launch_and_wait' set to: {}".format( + launch_and_wait), "INFO") pnp_authorization = lan_automation.get("pnp_authorization") if not isinstance(pnp_authorization, bool): self.log( - "Invalid value for 'pnp_authorization': {}. Defaulting to 'false'.".format(pnp_authorization), + "Invalid value for 'pnp_authorization': {}. Defaulting to 'false'.".format( + pnp_authorization), "WARNING" ) pnp_authorization = False lan_automation["pnp_authorization"] = pnp_authorization - self.log("'pnp_authorization' set to: {}".format(pnp_authorization), "INFO") + self.log("'pnp_authorization' set to: {}".format( + pnp_authorization), "INFO") return lan_automation, missing_params @@ -1294,26 +1341,32 @@ def extract_lan_automated_device_update(self, config): update_device = config.get("lan_automated_device_update") if not isinstance(update_device, dict): - self.log("lan_automated_device_update is not a dict, but a {}".format(type(update_device)), "ERROR") + self.log("lan_automated_device_update is not a dict, but a {}".format( + type(update_device)), "ERROR") return None, missing_params loopback_devices = update_device.get("loopback_update_device_list") - self.log("Starting validation of loopback update devices: {}".format(loopback_devices), "DEBUG") + self.log("Starting validation of loopback update devices: {}".format( + loopback_devices), "DEBUG") self.validate_device_list(loopback_devices, missing_params) hostname_devices = update_device.get("hostname_update_devices") - self.log("Starting validation of hostname update devices: {}".format(hostname_devices), "DEBUG") + self.log("Starting validation of hostname update devices: {}".format( + hostname_devices), "DEBUG") self.validate_hostname_update_devices(hostname_devices, missing_params) link_add = update_device.get("link_add") - self.log("Starting validation of link_add configurations: {}".format(link_add), "DEBUG") + self.log("Starting validation of link_add configurations: {}".format( + link_add), "DEBUG") self.validate_link_update(link_add, "link_add", missing_params) link_delete = update_device.get("link_delete") - self.log("Starting validation of link_delete configurations: {}".format(link_delete), "DEBUG") + self.log("Starting validation of link_delete configurations: {}".format( + link_delete), "DEBUG") self.validate_link_update(link_delete, "link_delete", missing_params) - self.log("Completed validation of lan_automated_device_update parameters.", "DEBUG") + self.log( + "Completed validation of lan_automated_device_update parameters.", "DEBUG") return update_device, missing_params def validate_ip_pools(self, ip_pools, missing_params): @@ -1334,7 +1387,8 @@ def validate_ip_pools(self, ip_pools, missing_params): """ if not ip_pools: - self.log("IP pools list is empty. Adding 'lan_automation -> ip_pools' to missing parameters.", "ERROR") + self.log( + "IP pools list is empty. Adding 'lan_automation -> ip_pools' to missing parameters.", "ERROR") missing_params.append("lan_automation -> ip_pools") return @@ -1342,13 +1396,17 @@ def validate_ip_pools(self, ip_pools, missing_params): for index, pool in enumerate(ip_pools): if not pool.get("ip_pool_name"): - self.log("IP pool at index {} is missing 'ip_pool_name'.".format(index), "ERROR") - missing_params.append("lan_automation -> ip_pools[{}] -> ip_pool_name".format(index)) + self.log("IP pool at index {} is missing 'ip_pool_name'.".format( + index), "ERROR") + missing_params.append( + "lan_automation -> ip_pools[{}] -> ip_pool_name".format(index)) ip_pool_role = pool.get("ip_pool_role") if not ip_pool_role: - self.log("IP pool at index {} is missing 'ip_pool_role'.".format(index), "ERROR") - missing_params.append("lan_automation -> ip_pools[{}] -> ip_pool_role".format(index)) + self.log("IP pool at index {} is missing 'ip_pool_role'.".format( + index), "ERROR") + missing_params.append( + "lan_automation -> ip_pools[{}] -> ip_pool_role".format(index)) continue ip_pool_role = ip_pool_role.upper() @@ -1361,7 +1419,8 @@ def validate_ip_pools(self, ip_pools, missing_params): ) continue - self.log("IP pool role '{}' at index {} validated and set.".format(ip_pool_role, index), "INFO") + self.log("IP pool role '{}' at index {} validated and set.".format( + ip_pool_role, index), "INFO") pool["ip_pool_role"] = ip_pool_role return @@ -1381,19 +1440,23 @@ def validate_discovery_devices(self, discovery_devices, missing_params): invalid, it raises an error and halts execution. """ if discovery_devices is None: - self.log("No discovery devices found. Skipping validation for 'discovery_devices'.", "INFO") + self.log( + "No discovery devices found. Skipping validation for 'discovery_devices'.", "INFO") return for j, device in enumerate(discovery_devices): if device is None: - self.log("Invalid device entry at index {}. Device cannot be 'None'.".format(j), "ERROR") + self.log( + "Invalid device entry at index {}. Device cannot be 'None'.".format(j), "ERROR") self.fail_with_error( "'discovery_devices[{}]' cannot be 'None'. Provide a valid device entry.".format(j)) return - self.log("Validating device at index {}: {}".format(j, device), "DEBUG") + self.log("Validating device at index {}: {}".format( + j, device), "DEBUG") if not device.get("device_serial_number"): - self.log("Discovery device at index {} is missing 'device_serial_number'.".format(j), "ERROR") + self.log("Discovery device at index {} is missing 'device_serial_number'.".format( + j), "ERROR") missing_params.append( "lan_automation -> discovery_devices[{}] -> device_serial_number (required if " "discovery_devices is provided)".format(j)) @@ -1428,23 +1491,28 @@ def validate_device_list(self, device_list, missing_params): - Missing or invalid parameters are appended to the 'missing_params' list. """ if not device_list: - self.log("No devices to validate in device_list. Skipping validation.", "ERROR") + self.log( + "No devices to validate in device_list. Skipping validation.", "ERROR") return - self.log("Starting validation of devices in device list: {}".format(device_list), "DEBUG") + self.log("Starting validation of devices in device list: {}".format( + device_list), "DEBUG") for j, device in enumerate(device_list): if not isinstance(device, dict): - self.log("Expected a dictionary at index {}, but got: {}".format(j, type(device)), "ERROR") + self.log("Expected a dictionary at index {}, but got: {}".format( + j, type(device)), "ERROR") self.fail_with_error( "Invalid data type for loopback_update_device_list at index {}: expected a dictionary, got {}" .format(j, type(device)) ) management_ip = device.get("device_management_ip_address") if not management_ip: - self.log("Device at index {} missing 'device_management_ip_address'.".format(j), "ERROR") + self.log( + "Device at index {} missing 'device_management_ip_address'.".format(j), "ERROR") missing_params.append( - "loopback_update_device_list[{}] -> device_management_ip_address".format(j) + "loopback_update_device_list[{}] -> device_management_ip_address".format( + j) ) else: self.validate_ipv4_ip( @@ -1459,7 +1527,8 @@ def validate_device_list(self, device_list, missing_params): loopback_ip = device.get("new_loopback0_ip_address") if not loopback_ip: - self.log("Device at index {} missing 'new_loopback0_ip_address'.".format(j), "ERROR") + self.log( + "Device at index {} missing 'new_loopback0_ip_address'.".format(j), "ERROR") missing_params.append( "lan_automated_device_update -> loopback_update_device_list[{}] -> new_loopback0_ip_address" .format(j) @@ -1488,13 +1557,16 @@ def validate_hostname_update_devices(self, hostname_update_devices, missing_para - Missing parameters are added to the 'missing_params' list. """ if not hostname_update_devices: - self.log("No hostname update devices to validate. Skipping validation.", "INFO") + self.log( + "No hostname update devices to validate. Skipping validation.", "INFO") return - self.log("Starting validation of hostname update devices: {}".format(hostname_update_devices), "INFO") + self.log("Starting validation of hostname update devices: {}".format( + hostname_update_devices), "INFO") for j, device in enumerate(hostname_update_devices): if not isinstance(device, dict): - self.log("Expected a dictionary at index {}, but got: {}".format(j, type(device)), "ERROR") + self.log("Expected a dictionary at index {}, but got: {}".format( + j, type(device)), "ERROR") self.fail_with_error( "Invalid data type for hostname_update_devices at index {}: expected a dictionary, got {}" .format(j, type(device)) @@ -1509,15 +1581,18 @@ def validate_hostname_update_devices(self, hostname_update_devices, missing_para "ERROR") self.module.fail_json( msg="IP address: {} does not exist in Catalyst Center. Please provide a valid IP address for " - "'hostname_update_devices -> device_management_ip_address'.".format(management_ip), + "'hostname_update_devices -> device_management_ip_address'.".format( + management_ip), response=[] ) new_host_name = device.get("new_host_name") if not new_host_name: - self.log("Device at index {} is missing 'new_host_name'.".format(j), "ERROR") + self.log( + "Device at index {} is missing 'new_host_name'.".format(j), "ERROR") missing_params.append( - "lan_automated_device_update -> hostname_update_devices[{}] -> new_host_name".format(j) + "lan_automated_device_update -> hostname_update_devices[{}] -> new_host_name".format( + j) ) else: self.log("Device at index {} has management IP '{}' and new hostname '{}'.".format(j, management_ip, @@ -1540,39 +1615,51 @@ def validate_link_update(self, link_update_dict, link_name, missing_params): - In the case of 'link_add', the 'ip_pool_name' must also be provided. """ if not link_update_dict: - self.log("{0} dictionary is empty. Skipping validation.".format(link_name), "INFO") + self.log("{0} dictionary is empty. Skipping validation.".format( + link_name), "INFO") return if not isinstance(link_update_dict, dict): self.fail_with_error( - "Expected a dict for {0}, but got {1}".format(link_name, type(link_update_dict).__name__) + "Expected a dict for {0}, but got {1}".format( + link_name, type(link_update_dict).__name__) ) return - self.log("Starting validation for {0}: {1}".format(link_name, link_update_dict), "INFO") + self.log("Starting validation for {0}: {1}".format( + link_name, link_update_dict), "INFO") source_ip = link_update_dict.get("source_device_management_ip_address") - self.validate_ipv4_ip(source_ip, "{0} -> source_device_management_ip_address".format(link_name), missing_params) + self.validate_ipv4_ip( + source_ip, "{0} -> source_device_management_ip_address".format(link_name), missing_params) - source_interface_name = link_update_dict.get("source_device_interface_name") + source_interface_name = link_update_dict.get( + "source_device_interface_name") if not source_interface_name: - self.log("{0} is missing 'source_device_interface_name'.".format(link_name), "ERROR") + self.log("{0} is missing 'source_device_interface_name'.".format( + link_name), "ERROR") missing_params.append( - "lan_automated_device_update -> {0} -> source_device_interface_name".format(link_name) + "lan_automated_device_update -> {0} -> source_device_interface_name".format( + link_name) ) # Validate Destination Device Management IP Address - destination_ip = link_update_dict.get("destination_device_management_ip_address") + destination_ip = link_update_dict.get( + "destination_device_management_ip_address") self.validate_ipv4_ip(destination_ip, "{0} -> destination_device_management_ip_address".format(link_name), missing_params) if not link_update_dict.get("destination_device_interface_name"): - self.log("{0} is missing 'destination_device_interface_name'.".format(link_name), "ERROR") + self.log("{0} is missing 'destination_device_interface_name'.".format( + link_name), "ERROR") missing_params.append( - "lan_automated_device_update -> {0} -> destination_device_interface_name".format(link_name) + "lan_automated_device_update -> {0} -> destination_device_interface_name".format( + link_name) ) if link_name == "link_add" and not link_update_dict.get("ip_pool_name"): - self.log("{0} requires 'ip_pool_name', but it is missing.".format(link_name), "ERROR") + self.log("{0} requires 'ip_pool_name', but it is missing.".format( + link_name), "ERROR") missing_params.append( - "lan_automated_device_update -> {0} -> ip_pool_name (missing)".format(link_name) + "lan_automated_device_update -> {0} -> ip_pool_name (missing)".format( + link_name) ) def validate_ipv4_ip(self, ip_address, field_name, missing_params=None): @@ -1617,7 +1704,8 @@ def get_device_id(self, device_ip): op_modifies=False ) except Exception as e: - self.log("Error fetching device ID for {0}: {1}".format(device_ip, str(e)), "ERROR") + self.log("Error fetching device ID for {0}: {1}".format( + device_ip, str(e)), "ERROR") return None if not response or "response" not in response: @@ -1627,7 +1715,8 @@ def get_device_id(self, device_ip): device_list = response.get("response", []) if device_list and len(device_list) > 0: device_id = device_list[0].get("id") - self.log("Device ID for {0} is {1}".format(device_ip, device_id), "INFO") + self.log("Device ID for {0} is {1}".format( + device_ip, device_id), "INFO") return device_id else: self.log("No device ID found for {0}".format(device_ip), "INFO") @@ -1652,7 +1741,8 @@ def check_link_details(self, source_device_ip, interface_name): device_id = self.get_device_id(source_device_ip) if device_id is None: - self.log("Device ID not found for {0}.".format(source_device_ip), "WARNING") + self.log("Device ID not found for {0}.".format( + source_device_ip), "WARNING") return False try: @@ -1668,7 +1758,8 @@ def check_link_details(self, source_device_ip, interface_name): return False if not response or "response" not in response: - self.log("No response received for {0} on {1}".format(source_device_ip, interface_name), "INFO") + self.log("No response received for {0} on {1}".format( + source_device_ip, interface_name), "INFO") return False self.log("Received response from 'get_interface_details'{}".format(response)) @@ -1683,10 +1774,12 @@ def check_link_details(self, source_device_ip, interface_name): self.log("Address List: {0}".format(address_list), "DEBUG") if ipv4_address and isis_support != "false" and address_list: - self.log("Valid link details for {0} on {1}".format(source_device_ip, interface_name), "INFO") + self.log("Valid link details for {0} on {1}".format( + source_device_ip, interface_name), "INFO") return True else: - self.log("Invalid link details for {0} on {1}".format(source_device_ip, interface_name), "INFO") + self.log("Invalid link details for {0} on {1}".format( + source_device_ip, interface_name), "INFO") return False def fail_with_error(self, error_message): @@ -1784,7 +1877,8 @@ def update_lan_auto_messages(self): self.result["changed"] = True self.msg = "\n".join(result_msg_list) - self.set_operation_result("success", self.result["changed"], self.msg, "INFO") + self.set_operation_result( + "success", self.result["changed"], self.msg, "INFO") return self @@ -1818,13 +1912,16 @@ def verify_diff_merged(self, config): """ lan_automation = self.want.get("lan_automation", {}) if lan_automation: - seed_ip_address = lan_automation.get("primaryDeviceManagmentIPAddress") + seed_ip_address = lan_automation.get( + "primaryDeviceManagmentIPAddress") launch_and_wait = lan_automation.get("launchAndWait", False) - self.log("Verifying LAN automation session for seed IP: {}".format(seed_ip_address), "DEBUG") + self.log("Verifying LAN automation session for seed IP: {}".format( + seed_ip_address), "DEBUG") if seed_ip_address and not launch_and_wait: self.get_have(config) - self.log("Current State (have): {0}".format(str(self.have)), "INFO") + self.log("Current State (have): {0}".format( + str(self.have)), "INFO") session_to_ip_mapping = self.have.get("session_to_ip_map", {}) session_id = None @@ -1846,8 +1943,10 @@ def verify_diff_merged(self, config): lan_devices = self.want.get("lan_automated_device_update", {}) if lan_devices: - self.process_loopback_updates(lan_devices.get("loopbackUpdateDeviceList", [])) - self.process_hostname_updates(lan_devices.get("hostnameUpdateDevices", [])) + self.process_loopback_updates( + lan_devices.get("loopbackUpdateDeviceList", [])) + self.process_hostname_updates( + lan_devices.get("hostnameUpdateDevices", [])) self.process_link_addition(lan_devices.get("linkAdd", {})) self.process_link_deletion(lan_devices.get("linkDelete", {})) @@ -1868,16 +1967,19 @@ def process_loopback_updates(self, loopback_updates): and logs the outcome of each verification. """ if not loopback_updates: - self.log("No loopback update data provided. Skipping loopback update processing.", "INFO") + self.log( + "No loopback update data provided. Skipping loopback update processing.", "INFO") return self.log("Processing loopback updates.", "INFO") for loopback in loopback_updates: new_ip = loopback.get("newLoopback0IPAddress") if self.get_ip_details(new_ip, "new loopback IP update"): - self.log("Verified loopback IP address {0} was updated on Catalyst Center.".format(new_ip), "INFO") + self.log("Verified loopback IP address {0} was updated on Catalyst Center.".format( + new_ip), "INFO") else: - self.log("Loopback IP address {0} was not updated on Catalyst Center.".format(new_ip), "WARNING") + self.log("Loopback IP address {0} was not updated on Catalyst Center.".format( + new_ip), "WARNING") def process_hostname_updates(self, hostname_updates): """ @@ -1894,7 +1996,8 @@ def process_hostname_updates(self, hostname_updates): whether the update was successful or if it was already up to date. """ if not hostname_updates: - self.log("No hostname updates data provided. Skipping hostname updates processing.", "INFO") + self.log( + "No hostname updates data provided. Skipping hostname updates processing.", "INFO") return self.log("Processing hostname updates.", "INFO") @@ -1926,15 +2029,18 @@ def process_link_addition(self, link_add): logs the result of the link addition attempt. """ if not link_add: - self.log("No link addition data provided. Skipping link addition processing.", "INFO") + self.log( + "No link addition data provided. Skipping link addition processing.", "INFO") return self.log("Processing link addition.", "INFO") source_ip_address = link_add.get("sourceDeviceManagementIPAddress") source_interface_name = link_add.get("sourceDeviceInterfaceName") - destination_ip_address = link_add.get("destinationDeviceManagementIPAddress") - destination_interface_name = link_add.get("destinationDeviceInterfaceName") + destination_ip_address = link_add.get( + "destinationDeviceManagementIPAddress") + destination_interface_name = link_add.get( + "destinationDeviceInterfaceName") if self.check_link_details(source_ip_address, source_interface_name) and \ self.check_link_details(destination_ip_address, destination_interface_name): @@ -1961,15 +2067,18 @@ def process_link_deletion(self, link_delete): still exists in the system. It logs the outcome of the link deletion attempt. """ if not link_delete: - self.log("No link deletion data provided. Skipping link deletion processing.", "INFO") + self.log( + "No link deletion data provided. Skipping link deletion processing.", "INFO") return self.log("Processing link deletion.", "INFO") source_ip_address = link_delete.get("sourceDeviceManagementIPAddress") source_interface_name = link_delete.get("sourceDeviceInterfaceName") - destination_ip_address = link_delete.get("destinationDeviceManagementIPAddress") - destination_interface_name = link_delete.get("destinationDeviceInterfaceName") + destination_ip_address = link_delete.get( + "destinationDeviceManagementIPAddress") + destination_interface_name = link_delete.get( + "destinationDeviceInterfaceName") if not self.check_link_details(source_ip_address, source_interface_name) and \ not self.check_link_details(destination_ip_address, destination_interface_name): @@ -2019,12 +2128,16 @@ def get_diff_merged(self): if lan_automation: launch_and_wait = lan_automation.get("launchAndWait", False) - self.log("Launch and wait setting: {}".format(launch_and_wait), "DEBUG") + self.log("Launch and wait setting: {}".format( + launch_and_wait), "DEBUG") session_to_ip_mapping = self.have.get("session_to_ip_map", {}) - seed_ip_address = lan_automation.get("primaryDeviceManagmentIPAddress") - self.log("Current session to IP mapping: {}".format(session_to_ip_mapping), "DEBUG") - self.log("Seed IP address being checked: {}".format(seed_ip_address), "DEBUG") + seed_ip_address = lan_automation.get( + "primaryDeviceManagmentIPAddress") + self.log("Current session to IP mapping: {}".format( + session_to_ip_mapping), "DEBUG") + self.log("Seed IP address being checked: {}".format( + seed_ip_address), "DEBUG") if session_to_ip_mapping and seed_ip_address in session_to_ip_mapping.values(): self.no_lan_auto_start.append(seed_ip_address) @@ -2035,19 +2148,23 @@ def get_diff_merged(self): return self action_func, status_func = action_plan["start_lan_automation"] - self.log("Performing '{}' operation...".format(action_func.__name__), "DEBUG") + self.log("Performing '{}' operation...".format( + action_func.__name__), "DEBUG") result_task_id = action_func(lan_automation) - self.log("Result task ID from '{}': {}".format(action_func.__name__, result_task_id), "DEBUG") + self.log("Result task ID from '{}': {}".format( + action_func.__name__, result_task_id), "DEBUG") self.log("Result task ID is: {}".format(result_task_id)) if not result_task_id: self.msg = "An error occurred while retrieving the task_id of the '{}' operation.".format( action_func.__name__) - self.set_operation_result("failed", False, self.msg, "CRITICAL") + self.set_operation_result( + "failed", False, self.msg, "CRITICAL") self.log(self.msg, "ERROR") - self.log("Checking status for task ID: {}".format(result_task_id), "DEBUG") + self.log("Checking status for task ID: {}".format( + result_task_id), "DEBUG") status_func(result_task_id).check_return_status() self.log("LAN Automation session completed successfully.", "DEBUG") @@ -2055,24 +2172,29 @@ def get_diff_merged(self): if lan_automation and not launch_and_wait: self.msg = "Error: You need to first run LAN automation and wait for it to complete before running " \ "'update_lan_automated_devices'. " - self.set_operation_result("failed", False, self.msg, "CRITICAL") + self.set_operation_result( + "failed", False, self.msg, "CRITICAL") self.log(self.msg, "ERROR") self.module.fail_json(msg=self.msg, response=[]) filtered_updates = self.filter_updates(update_device) - self.log("Filtered updates for devices: {}".format(filtered_updates), "DEBUG") + self.log("Filtered updates for devices: {}".format( + filtered_updates), "DEBUG") if filtered_updates: action_func, status_func = action_plan["update_lan_automated_devices"] - self.log("Performing '{}' operation with filtered updates.".format(action_func.__name__), "DEBUG") + self.log("Performing '{}' operation with filtered updates.".format( + action_func.__name__), "DEBUG") result_task_ids = action_func(filtered_updates) if not result_task_ids: self.msg = "An error occurred while retrieving task_ids for '{}' operation.".format( action_func.__name__) - self.set_operation_result("failed", False, self.msg, "CRITICAL") + self.set_operation_result( + "failed", False, self.msg, "CRITICAL") else: - self.log("Changes Merged: Task IDs: {}".format(result_task_ids)) + self.log("Changes Merged: Task IDs: {}".format( + result_task_ids)) status_func(result_task_ids).check_return_status() self.log("Device updates completed successfully.", "INFO") else: @@ -2107,10 +2229,12 @@ def filter_updates(self, update_device): filtered_updates = {} for update_key, update_type in update_types.items(): - updates = update_device.get(update_key, {} if update_key in ["linkAdd", "linkDelete"] else []) + updates = update_device.get(update_key, {} if update_key in [ + "linkAdd", "linkDelete"] else []) if updates: - self.log("Filtering updates for {}: {}".format(update_key, updates), "DEBUG") + self.log("Filtering updates for {}: {}".format( + update_key, updates), "DEBUG") if update_type == "loopback_update": filtered_updates[update_key] = [] @@ -2124,31 +2248,41 @@ def filter_updates(self, update_device): .format(device, current_ip, new_ip), "INFO") else: self.no_loopback_updated.append(device) - self.log("No update needed for loopback IP on device: {}".format(device), "INFO") + self.log("No update needed for loopback IP on device: {}".format( + device), "INFO") if not filtered_updates[update_key]: - self.log("No loopback updates needed after filtering.", "INFO") + self.log( + "No loopback updates needed after filtering.", "INFO") elif update_type == "hostname_update": filtered_updates[update_key] = [] for device in updates: - current_hostname = self.get_hostname_details(device.get("deviceManagementIPAddress")) + current_hostname = self.get_hostname_details( + device.get("deviceManagementIPAddress")) if current_hostname != device.get("newHostName"): self.log("Hostname needs update for device: {}. Current: {}, New: {}".format( device, current_hostname, device.get("newHostName")), "INFO") filtered_updates[update_key].append(device) else: self.no_hostname_updated.append(device) - self.log("No update needed for hostname on device: {}".format(device), "INFO") + self.log("No update needed for hostname on device: {}".format( + device), "INFO") if not filtered_updates[update_key]: - self.log("No hostname updates needed after filtering.", "INFO") + self.log( + "No hostname updates needed after filtering.", "INFO") elif update_type == "link_add": - self.log("Link add updates ready for processing: {}".format(updates), "DEBUG") - - source_ip_address = updates.get("sourceDeviceManagementIPAddress") - source_interface_name = updates.get("sourceDeviceInterfaceName") - destination_ip_address = updates.get("destinationDeviceManagementIPAddress") - destination_interface_name = updates.get("destinationDeviceInterfaceName") + self.log("Link add updates ready for processing: {}".format( + updates), "DEBUG") + + source_ip_address = updates.get( + "sourceDeviceManagementIPAddress") + source_interface_name = updates.get( + "sourceDeviceInterfaceName") + destination_ip_address = updates.get( + "destinationDeviceManagementIPAddress") + destination_interface_name = updates.get( + "destinationDeviceInterfaceName") if self.check_link_details(source_ip_address, source_interface_name) and \ self.check_link_details(destination_ip_address, destination_interface_name): @@ -2162,7 +2296,8 @@ def filter_updates(self, update_device): filtered_updates[update_key] = updates if not filtered_updates[update_key]: - self.log("No link add updates needed after filtering.", "INFO") + self.log( + "No link add updates needed after filtering.", "INFO") elif update_type == "link_delete": if not self.check_link_details( @@ -2173,13 +2308,16 @@ def filter_updates(self, update_device): updates.get("destinationDeviceInterfaceName") ): filtered_updates[update_key] = updates - self.log("Link delete updates ready for processing: {}".format(updates), "DEBUG") + self.log("Link delete updates ready for processing: {}".format( + updates), "DEBUG") else: self.no_link_deleted.append(updates) - self.log("No link delete needed for updates: {}".format(updates), "INFO") + self.log("No link delete needed for updates: {}".format( + updates), "INFO") if not filtered_updates.get(update_key): - self.log("No link delete updates needed after filtering.", "INFO") + self.log( + "No link delete updates needed after filtering.", "INFO") self.log("Filtered updates: {}".format(filtered_updates), "DEBUG") @@ -2216,17 +2354,21 @@ def update_lan_auto_devices(self, filtered_updates): updates = filtered_updates.get(update_key, []) if updates: - self.log("Processing updates for {}: {}".format(update_key, updates), "DEBUG") + self.log("Processing updates for {}: {}".format( + update_key, updates), "DEBUG") task_id = self.call_lan_auto_update_api(update_type, updates) if task_id: task_ids[update_type] = task_id - self.log("Successfully initiated {} update. Task ID: {}".format(update_type, task_id), "INFO") + self.log("Successfully initiated {} update. Task ID: {}".format( + update_type, task_id), "INFO") else: - self.log("Failed to get task ID for {} update: {}".format(update_type, updates), "ERROR") + self.log("Failed to get task ID for {} update: {}".format( + update_type, updates), "ERROR") else: - self.log("No updates found for {}, skipping.".format(update_key), "INFO") + self.log("No updates found for {}, skipping.".format( + update_key), "INFO") self.log("Generated task_ids: {}".format(task_ids)) @@ -2248,7 +2390,8 @@ def get_lan_auto_task_status(self, task_id): """ lan_automation = self.want.get("lan_automation", {}) - launch_and_wait = lan_automation.get("launchAndWait", False) # Default is False + launch_and_wait = lan_automation.get( + "launchAndWait", False) # Default is False pnp_authorization = lan_automation.get("pnpAuthorization", False) device_serials = ([serial.upper() for serial in lan_automation.get("deviceSerialNumberAuthorization", [])] or [device.get("deviceSerialNumber", "").upper() for device in @@ -2264,19 +2407,23 @@ def get_lan_auto_task_status(self, task_id): pending_authorization = True task_id = task_id.get("response", {}).get("taskId") - self.log("Starting to monitor LAN automation task with task ID: {}".format(task_id), "DEBUG") + self.log("Starting to monitor LAN automation task with task ID: {}".format( + task_id), "DEBUG") if not launch_and_wait: task_details = self.get_task_details(task_id) if not task_details: - self.msg = "Error retrieving task status for starting LAN Automation with task_id '{}'.".format(task_id) + self.msg = "Error retrieving task status for starting LAN Automation with task_id '{}'.".format( + task_id) self.set_operation_result("failed", False, self.msg, "ERROR") return self - self.log("Task details for task ID {}: {}".format(task_id, task_details), "DEBUG") + self.log("Task details for task ID {}: {}".format( + task_id, task_details), "DEBUG") if task_details.get("isError") is True: - error_msg = task_details.get("failureReason") or task_details.get("progress") + error_msg = task_details.get( + "failureReason") or task_details.get("progress") self.msg = "Error encountered: {}".format(error_msg) self.log(self.msg, "ERROR") self.status = "failed" @@ -2291,29 +2438,35 @@ def get_lan_auto_task_status(self, task_id): ) self.log(self.msg, "INFO") self.set_operation_result("success", True, self.msg, "INFO") - self.started_lan_automation.append(lan_automation.get("primaryDeviceManagmentIPAddress")) + self.started_lan_automation.append( + lan_automation.get("primaryDeviceManagmentIPAddress")) else: self.msg = "LAN automation session has started successfully. Please check Catalyst Center UI " \ "to track progress." self.log(self.msg, "INFO") self.set_operation_result("success", True, self.msg, "INFO") - self.started_lan_automation.append(lan_automation.get("primaryDeviceManagmentIPAddress")) + self.started_lan_automation.append( + lan_automation.get("primaryDeviceManagmentIPAddress")) return self - self.log("Entering polling loop for LAN automation task completion...", "DEBUG") + self.log( + "Entering polling loop for LAN automation task completion...", "DEBUG") while True: task_details = self.get_task_details(task_id) if not task_details: - self.msg = "Error retrieving task status for starting LAN Automation with task_id '{}'.".format(task_id) + self.msg = "Error retrieving task status for starting LAN Automation with task_id '{}'.".format( + task_id) self.set_operation_result("failed", False, self.msg, "ERROR") break - self.log("Current task details for task ID {}: {}".format(task_id, task_details), "DEBUG") + self.log("Current task details for task ID {}: {}".format( + task_id, task_details), "DEBUG") if task_details.get("isError") is True: - error_msg = task_details.get("failureReason") or task_details.get("progress") + error_msg = task_details.get( + "failureReason") or task_details.get("progress") self.msg = "Error encountered: {}".format(error_msg) self.status = "failed" self.log(self.msg, "ERROR") @@ -2321,14 +2474,17 @@ def get_lan_auto_task_status(self, task_id): break if "complete" in task_details.get("progress", "").lower(): - self.msg = "LAN automation has completed successfully: {}".format(task_details.get('progress')) + self.msg = "LAN automation has completed successfully: {}".format( + task_details.get('progress')) self.log(self.msg, "INFO") - self.completed_lan_automation.append(lan_automation.get("primaryDeviceManagmentIPAddress")) + self.completed_lan_automation.append( + lan_automation.get("primaryDeviceManagmentIPAddress")) self.status = "success" self.set_operation_result("success", True, self.msg, "INFO") break - self.log("Current progress for task ID {}: {}".format(task_id, task_details.get('progress')), "DEBUG") + self.log("Current progress for task ID {}: {}".format( + task_id, task_details.get('progress')), "DEBUG") elapsed_time = time.time() - start_time if int(elapsed_time) % 300 == 0: logs = self.collect_logs() @@ -2339,10 +2495,13 @@ def get_lan_auto_task_status(self, task_id): if pnp_authorization and pending_authorization: if remaining_auth_devices: self.log( - "Authorizing devices in PnP with serial numbers provided: {}".format(remaining_auth_devices), + "Authorizing devices in PnP with serial numbers provided: {}".format( + remaining_auth_devices), "DEBUG") - authorized_devices = self.authorize_devices(remaining_auth_devices) - self.log("Authorized devices: {}".format(', '.join(authorized_devices)), "INFO") + authorized_devices = self.authorize_devices( + remaining_auth_devices) + self.log("Authorized devices: {}".format( + ', '.join(authorized_devices)), "INFO") remaining_auth_devices = [device for device in remaining_auth_devices if device not in authorized_devices] @@ -2360,21 +2519,25 @@ def get_lan_auto_task_status(self, task_id): "INFO") else: pending_authorization = False - self.log("All devices have been successfully authorized.", "INFO") + self.log( + "All devices have been successfully authorized.", "INFO") else: pending_authorization = False self.msg = ("PnP authorization is set to True, but no devices were given for authorization or " "discovery. Please authorize devices manually in the PnP page in Catalyst Center.") - self.set_operation_result("failed", False, self.msg, "ERROR") + self.set_operation_result( + "failed", False, self.msg, "ERROR") - self.log("Waiting for 30 seconds before the next status check...", "DEBUG") + self.log( + "Waiting for 30 seconds before the next status check...", "DEBUG") time.sleep(self.params.get("dnac_task_poll_interval", 30)) if self.status != "success": elapsed_time = time.time() - start_time self.msg = ( "LAN automation did not complete within the expected time {:.2f} seconds. " - "Consider stopping the LAN Automation by running the playbook in Deleted state.".format(elapsed_time) + "Consider stopping the LAN Automation by running the playbook in Deleted state.".format( + elapsed_time) ) self.log(self.msg, "ERROR") self.set_operation_result("failed", True, self.msg, "INFO") @@ -2412,7 +2575,8 @@ def call_lan_auto_update_api(self, update_type, payload): feature = feature_map.get(update_type) payload_key = payload_map.get(update_type) - self.log("Preparing to call LAN automation API for update type '{}': {}".format(update_type, payload), "DEBUG") + self.log("Preparing to call LAN automation API for update type '{}': {}".format( + update_type, payload), "DEBUG") try: params = { @@ -2428,18 +2592,22 @@ def call_lan_auto_update_api(self, update_type, payload): op_modifies=True, ) - self.log("Response received for {} API call: {}".format(update_type, response), "DEBUG") + self.log("Response received for {} API call: {}".format( + update_type, response), "DEBUG") if response: task_id = response["response"].get("taskId") - self.log("Task ID for {} update is {}".format(update_type, task_id), "DEBUG") + self.log("Task ID for {} update is {}".format( + update_type, task_id), "DEBUG") return task_id else: - self.log("No response received from {} API call".format(update_type), "ERROR") + self.log("No response received from {} API call".format( + update_type), "ERROR") return None except Exception as e: - self.log("Error occurred during {} update: {}".format(update_type, str(e)), "CRITICAL") + self.log("Error occurred during {} update: {}".format( + update_type, str(e)), "CRITICAL") self.set_operation_result("failed", False, "Error occurred during {} update: {}".format(update_type, str(e)), "CRITICAL") return None @@ -2462,31 +2630,39 @@ def get_update_lan_task_status(self, task_ids): for update_type, task_id in task_ids.items(): if task_id is not None: - self.log("Monitoring task ID: {} for update type: {}".format(task_id, update_type), "INFO") + self.log("Monitoring task ID: {} for update type: {}".format( + task_id, update_type), "INFO") while True: task_details = self.get_task_details(task_id) if not task_details: - self.msg = "Error retrieving task status for task_id '{}'.".format(task_id) + self.msg = "Error retrieving task status for task_id '{}'.".format( + task_id) self.log(self.msg, "ERROR") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() break - self.log("Task details for task ID {}: {}".format(task_id, task_details), "DEBUG") + self.log("Task details for task ID {}: {}".format( + task_id, task_details), "DEBUG") if task_details.get("isError") is True: - error_msg = task_details.get("failureReason") or task_details.get("progress") + error_msg = task_details.get( + "failureReason") or task_details.get("progress") self.msg = "Error encountered for update type {} with Task ID: '{}': {} Check the logs " \ - "for more details.".format(update_type, task_id, error_msg) + "for more details.".format( + update_type, task_id, error_msg) self.log(self.msg, "ERROR") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() break if ("deleted" in task_details.get("progress", "").lower() or "config push success" in task_details.get("progress", "").lower() or "update performed successfully" in task_details.get("progress", "").lower()): - self.msg = "Update {} for task ID '{}' completed successfully".format(update_type, task_id) + self.msg = "Update {} for task ID '{}' completed successfully".format( + update_type, task_id) self.log(self.msg, "INFO") if update_type == "loopback_update": @@ -2525,7 +2701,8 @@ def collect_logs(self): ) if response: response_data = response.get("response", []) - self.log("Received API response from 'lan_automation_log': {}".format(str(response)), "DEBUG") + self.log("Received API response from 'lan_automation_log': {}".format( + str(response)), "DEBUG") if response_data: return response_data[0] @@ -2547,7 +2724,8 @@ def authorize_devices(self, device_serials): returns a list of successfully authorized devices or an empty list if some devices were not found. """ - self.log("Retrieving device IDs for serial numbers: {}".format(device_serials), "DEBUG") + self.log("Retrieving device IDs for serial numbers: {}".format( + device_serials), "DEBUG") device_list_response = self.get_device_list(device_serials) if not device_list_response: @@ -2567,7 +2745,8 @@ def authorize_devices(self, device_serials): device_id = device.get("id") state = device_info.get("state") - self.log("Checking device: Serial Number: {}, State: {}".format(serial_number, state), "DEBUG") + self.log("Checking device: Serial Number: {}, State: {}".format( + serial_number, state), "DEBUG") if serial_number in device_serials: if state == "Pending Authorization": @@ -2581,32 +2760,41 @@ def authorize_devices(self, device_serials): self.log("Serial number {} is not in the provided device_serials list".format(serial_number), "INFO") - self.log("Serial to ID mapping for devices in 'Pending Authorization': {}".format(serial_to_id_map), "DEBUG") - self.log("Device IDs list for devices in 'Pending Authorization': {}".format(device_ids), "DEBUG") + self.log("Serial to ID mapping for devices in 'Pending Authorization': {}".format( + serial_to_id_map), "DEBUG") + self.log("Device IDs list for devices in 'Pending Authorization': {}".format( + device_ids), "DEBUG") - missing_serials = [serial for serial in device_serials if serial not in serial_to_id_map] + missing_serials = [ + serial for serial in device_serials if serial not in serial_to_id_map] self.log( "This is missing serials for devices not found in PnP and/or are not in 'Pending Authorization': {}".format( missing_serials)) if missing_serials: self.log( - "The following device serial numbers were not found in PnP onboarding page: {}".format(missing_serials), + "The following device serial numbers were not found in PnP onboarding page: {}".format( + missing_serials), "WARNING") if not device_ids: - self.log("No matching device IDs found for the provided serial numbers {}.".format(device_serials), "ERROR") + self.log("No matching device IDs found for the provided serial numbers {}.".format( + device_serials), "ERROR") return [] - self.log("Attempting to authorize devices with IDs: {}".format(device_ids), "DEBUG") - authorized_devices = self.authorize_pnp_devices(device_ids, serial_to_id_map) + self.log("Attempting to authorize devices with IDs: {}".format( + device_ids), "DEBUG") + authorized_devices = self.authorize_pnp_devices( + device_ids, serial_to_id_map) if not authorized_devices: self.log("Authorization failed for one or more devices", "ERROR") return [] - authorized_serials = [serial for serial, id in serial_to_id_map.items() if id in authorized_devices] + authorized_serials = [ + serial for serial, id in serial_to_id_map.items() if id in authorized_devices] - self.log("The following devices were successfully authorized: {}".format(', '.join(authorized_serials)), "INFO") + self.log("The following devices were successfully authorized: {}".format( + ', '.join(authorized_serials)), "INFO") return authorized_serials def authorize_pnp_devices(self, device_ids, serial_to_id_map): @@ -2636,17 +2824,20 @@ def authorize_pnp_devices(self, device_ids, serial_to_id_map): params=payload ) except Exception as e: - self.log("Error occurred while authorizing devices: {}".format(str(e)), "ERROR") + self.log("Error occurred while authorizing devices: {}".format( + str(e)), "ERROR") return None if response: status_code = response.get("statusCode") if status_code is not None: if status_code == 200: - self.log("Authorization API call was successful as following: {}".format(response), "INFO") + self.log("Authorization API call was successful as following: {}".format( + response), "INFO") return device_ids else: - self.log("Authorization API call failed with status code: {}".format(status_code), "ERROR") + self.log("Authorization API call failed with status code: {}".format( + status_code), "ERROR") return [] else: self.log("No response received from the authorize_device API.", "ERROR") @@ -2668,7 +2859,8 @@ def get_device_list(self, device_serial_numbers): an empty list. """ - self.log("Initiating API call for device list: {}".format(device_serial_numbers)) + self.log("Initiating API call for device list: {}".format( + device_serial_numbers)) try: response = self.dnac._exec( family="device_onboarding_pnp", @@ -2686,7 +2878,8 @@ def get_device_list(self, device_serial_numbers): if isinstance(response, list) and response: return response - self.log("Received empty or invalid response: {}".format(response), "WARNING") + self.log("Received empty or invalid response: {}".format( + response), "WARNING") return [] def start_lan_auto(self, lan_automation_params): @@ -2705,9 +2898,12 @@ def start_lan_auto(self, lan_automation_params): result to failed, and returns an empty dictionary. """ session_to_ip_mapping = self.have.get("session_to_ip_map", {}) - seed_ip_address = lan_automation_params.get("primaryDeviceManagmentIPAddress") - self.log("Current session to IP mapping: {}".format(session_to_ip_mapping), "DEBUG") - self.log("Seed IP address being checked: {}".format(seed_ip_address), "DEBUG") + seed_ip_address = lan_automation_params.get( + "primaryDeviceManagmentIPAddress") + self.log("Current session to IP mapping: {}".format( + session_to_ip_mapping), "DEBUG") + self.log("Seed IP address being checked: {}".format( + seed_ip_address), "DEBUG") if session_to_ip_mapping and seed_ip_address in session_to_ip_mapping.values(): self.no_lan_auto_start.append(seed_ip_address) @@ -2731,15 +2927,18 @@ def start_lan_auto(self, lan_automation_params): } if lan_auto_params: - self.log("Starting LAN automation with the following parameters: {}".format(lan_auto_params), "DEBUG") + self.log("Starting LAN automation with the following parameters: {}".format( + lan_auto_params), "DEBUG") else: self.log("No valid parameters found for LAN automation.", "WARNING") - self.log("Starting LAN automation with parameters: {}".format(lan_auto_params), "DEBUG") + self.log("Starting LAN automation with parameters: {}".format( + lan_auto_params), "DEBUG") lan_auto_params_list = [] lan_auto_params_list.append(lan_auto_params) - self.log("Sending request to start LAN Automation with payload: {}".format(lan_auto_params_list), "DEBUG") + self.log("Sending request to start LAN Automation with payload: {}".format( + lan_auto_params_list), "DEBUG") try: response = self.dnac_apply["exec"]( family="lan_automation", @@ -2748,12 +2947,14 @@ def start_lan_auto(self, lan_automation_params): op_modifies=True, ) - self.log("Response received for starting LAN Automation API call: {}".format(response), "DEBUG") + self.log("Response received for starting LAN Automation API call: {}".format( + response), "DEBUG") if response: self.result.update(dict(response=response["response"])) task_id = response["response"].get("taskId") - self.log("Task ID for starting LAN Automation session is {}".format(task_id), "DEBUG") + self.log("Task ID for starting LAN Automation session is {}".format( + task_id), "DEBUG") if task_id: self.result['task_id'] = task_id @@ -2764,7 +2965,8 @@ def start_lan_auto(self, lan_automation_params): self.set_operation_result("failed", False, self.msg, "ERROR") self.check_return_status() except Exception as e: - self.msg = "An error occurred while trying to start LAN Automation session. Error: {}".format(str(e)) + self.msg = "An error occurred while trying to start LAN Automation session. Error: {}".format( + str(e)) self.log(self.msg, "CRITICAL") self.set_operation_result("failed", False, self.msg, "CRITICAL") self.check_return_status() @@ -2787,13 +2989,17 @@ def get_diff_deleted(self): It logs the outcome, indicating success or failure, and updates the internal state based on the API response. """ if not self.want.get("lan_automation"): - self.log("LAN automation configuration not found in 'want'. Exiting the method.", "INFO") + self.log( + "LAN automation configuration not found in 'want'. Exiting the method.", "INFO") return self session_to_ip_mapping = self.have.get("session_to_ip_map", {}) - seed_ip_address = self.want.get("lan_automation").get("primaryDeviceManagmentIPAddress") - self.log("Current session to IP mapping: {}".format(session_to_ip_mapping), "DEBUG") - self.log("Seed IP address for stopping LAN automation: {}".format(seed_ip_address), "DEBUG") + seed_ip_address = self.want.get("lan_automation").get( + "primaryDeviceManagmentIPAddress") + self.log("Current session to IP mapping: {}".format( + session_to_ip_mapping), "DEBUG") + self.log("Seed IP address for stopping LAN automation: {}".format( + seed_ip_address), "DEBUG") if not session_to_ip_mapping: self.msg = "No LAN automation session is currently running. Please use state merged to start a " \ @@ -2806,7 +3012,8 @@ def get_diff_deleted(self): (sid for sid, ip_address in session_to_ip_mapping.items() if ip_address == seed_ip_address), None) if not session_id: - self.msg = "No active LAN automation session found for seed IP address: {0}.".format(seed_ip_address) + self.msg = "No active LAN automation session found for seed IP address: {0}.".format( + seed_ip_address) self.log(self.msg) self.set_operation_result("failed", False, self.msg, "INFO") return self @@ -2817,7 +3024,8 @@ def get_diff_deleted(self): "INFO") try: - self.log("Attempting to stop LAN automation session with ID: {}".format(session_id), "DEBUG") + self.log("Attempting to stop LAN automation session with ID: {}".format( + session_id), "DEBUG") response = self.dnac_apply["exec"]( family="lan_automation", function="lan_automation_stop", @@ -2825,7 +3033,8 @@ def get_diff_deleted(self): op_modifies=True ) - self.log("Response from 'lan_automation_stop' API: {0}".format(response), "DEBUG") + self.log("Response from 'lan_automation_stop' API: {0}".format( + response), "DEBUG") response_data = response.get("response", {}) error_code = response_data.get("errorCode") @@ -2835,15 +3044,18 @@ def get_diff_deleted(self): if error_code: self.msg = "Error stopping LAN automation session: {0}. Details: {1} (Error Code: {2}) ".format( message, detail, error_code) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() else: self.check_stop_session(seed_ip_address, session_id) - self.msg = "Successfully stopped LAN automation session with session ID: {0}.".format(session_id) + self.msg = "Successfully stopped LAN automation session with session ID: {0}.".format( + session_id) self.stopped_lan_automation.append(seed_ip_address) self.set_operation_result("success", True, self.msg, "INFO") except Exception as e: - self.msg = "An error occurred while stopping the LAN automation session: {0}".format(str(e)) + self.msg = "An error occurred while stopping the LAN automation session: {0}".format( + str(e)) self.log(self.msg, "CRITICAL") self.set_operation_result("failed", False, self.msg, "CRITICAL") @@ -2871,16 +3083,19 @@ def check_stop_session(self, seed_ip_address, session_id, max_wait_time=1800): while time.time() < end_time: self.get_have(self.want) - self.log("Current State (have): {0}".format(str(self.have)), "INFO") + self.log("Current State (have): {0}".format( + str(self.have)), "INFO") active_session_ids = self.have.get("activeSessionIds", []) - self.log("Active session IDs: {0}".format(active_session_ids), "DEBUG") + self.log("Active session IDs: {0}".format( + active_session_ids), "DEBUG") if session_id not in active_session_ids: self.status = "success" self.msg = "The LAN automation session for seed IP '{0}' has been successfully stopped.".format( seed_ip_address) - self.set_operation_result("success", True, self.msg, "INFO").check_return_status() + self.set_operation_result( + "success", True, self.msg, "INFO").check_return_status() return self self.log("LAN automation session for seed IP '{0}' is still running. Checking again in " @@ -2891,7 +3106,8 @@ def check_stop_session(self, seed_ip_address, session_id, max_wait_time=1800): self.status = "failed" self.msg = ( "Timeout reached (~30 minutes). Unable to verify that the LAN automation session for seed IP '{0}' " - "has been completely stopped. Please monitor through the Cisco Catalyst Center UI.".format(seed_ip_address) + "has been completely stopped. Please monitor through the Cisco Catalyst Center UI.".format( + seed_ip_address) ) self.set_operation_result("failed", False, self.msg, "CRITICAL") return self @@ -2910,17 +3126,21 @@ def verify_diff_deleted(self, config): specified seed IP. """ if not self.want.get("lan_automated_device_update"): - self.log("LAN automated device update is not requested. Exiting verification.", "DEBUG") + self.log( + "LAN automated device update is not requested. Exiting verification.", "DEBUG") return self - seed_ip_address = self.want.get("lan_automation").get("primaryDeviceManagmentIPAddress") - self.log("Verifying active LAN automation session for seed IP: {}".format(seed_ip_address), "DEBUG") + seed_ip_address = self.want.get("lan_automation").get( + "primaryDeviceManagmentIPAddress") + self.log("Verifying active LAN automation session for seed IP: {}".format( + seed_ip_address), "DEBUG") self.get_have(config) self.log("Current State (have): {0}".format(str(self.have)), "INFO") session_to_ip_mapping = self.have.get("session_to_ip_map", {}) - self.log("Session to IP mapping: {}".format(session_to_ip_mapping), "DEBUG") + self.log("Session to IP mapping: {}".format( + session_to_ip_mapping), "DEBUG") session_id = None for sid, ip in session_to_ip_mapping.items(): @@ -2929,7 +3149,8 @@ def verify_diff_deleted(self, config): break if not session_id: - self.msg = "No active LAN automation session found for seed IP '{}'.".format(seed_ip_address) + self.msg = "No active LAN automation session found for seed IP '{}'.".format( + seed_ip_address) self.log(self.msg) else: self.msg = "Active LAN automation session found for seed IP '{}', session ID: {}."\ @@ -2995,7 +3216,8 @@ def main(): ccc_lan_automation.get_want(config).check_return_status() ccc_lan_automation.get_diff_state_apply[state]().check_return_status() if config_verify: - ccc_lan_automation.verify_diff_state_apply[state](config).check_return_status() + ccc_lan_automation.verify_diff_state_apply[state]( + config).check_return_status() ccc_lan_automation.update_lan_auto_messages().check_return_status() diff --git a/plugins/modules/network_compliance_workflow_manager.py b/plugins/modules/network_compliance_workflow_manager.py index dc1851a65d..540980c3a1 100644 --- a/plugins/modules/network_compliance_workflow_manager.py +++ b/plugins/modules/network_compliance_workflow_manager.py @@ -5,6 +5,11 @@ """Ansible module to perform Network Compliance Operations on devices in Cisco Catalyst Center.""" from __future__ import absolute_import, division, print_function +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts +) +from ansible.module_utils.basic import AnsibleModule __metaclass__ = type __author__ = ("Rugvedi Kapse, Madhan Sankaranarayanan, Sonali Deepthi Kesali") @@ -349,12 +354,6 @@ } """ -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts -) - class NetworkCompliance(DnacBase): """Class containing member attributes for network_compliance_workflow_manager module""" @@ -411,14 +410,16 @@ def validate_input(self): ) if invalid_params: - self.msg = "Invalid parameters in playbook: {0}".format(invalid_params) + self.msg = "Invalid parameters in playbook: {0}".format( + invalid_params) self.log(self.msg, "ERROR") self.status = "failed" return self self.validated_config = valid_temp - self.msg = "Successfully validated playbook configuration parameters using 'validated_input': {0}".format(str(valid_temp)) + self.msg = "Successfully validated playbook configuration parameters using 'validated_input': {0}".format( + str(valid_temp)) self.log(self.msg, "INFO") self.status = "success" @@ -434,7 +435,8 @@ def validate_ip4_address_list(self, ip_address_list): If any address is found to be invalid, it logs an error message and fails. After validating all IP addresses, it logs a success message. """ - self.log("Validating the IP addresses in the ip_address_list: {0}".format(ip_address_list), "DEBUG") + self.log("Validating the IP addresses in the ip_address_list: {0}".format( + ip_address_list), "DEBUG") for ip in ip_address_list: if not self.is_valid_ipv4(ip): @@ -443,7 +445,8 @@ def validate_ip4_address_list(self, ip_address_list): self.module.fail_json(self.msg) ip_address_list_str = ", ".join(ip_address_list) - self.log("Successfully validated the IP address(es): {0}".format(ip_address_list_str), "DEBUG") + self.log("Successfully validated the IP address(es): {0}".format( + ip_address_list_str), "DEBUG") def validate_iplist_and_site_name(self, ip_address_list, site_name): """ @@ -457,7 +460,8 @@ def validate_iplist_and_site_name(self, ip_address_list, site_name): Raises: SystemExit: If neither `ip_address_list` nor `site_name` is provided, the function logs an error message and exits the process. """ - self.log("Validating 'ip_address_list': '{0}' or 'site_name': '{1}'".format(ip_address_list, site_name), "DEBUG") + self.log("Validating 'ip_address_list': '{0}' or 'site_name': '{1}'".format( + ip_address_list, site_name), "DEBUG") # Check if IP address list or hostname is provided if not any([ip_address_list, site_name]): @@ -469,7 +473,8 @@ def validate_iplist_and_site_name(self, ip_address_list, site_name): if ip_address_list: self.validate_ip4_address_list(ip_address_list) - self.log("Validation successful: Provided IP address list or Site name is valid") + self.log( + "Validation successful: Provided IP address list or Site name is valid") def validate_compliance_operation(self, run_compliance, run_compliance_categories, sync_device_config): """ @@ -506,15 +511,19 @@ def validate_run_compliance_categories(self, run_compliance_categories): Raises: Exception: If invalid categories are provided, raises an exception with a message. """ - self.log("Validating the provided run compliance categories: {0}".format(run_compliance_categories), "DEBUG") + self.log("Validating the provided run compliance categories: {0}".format( + run_compliance_categories), "DEBUG") - valid_categories = ["INTENT", "RUNNING_CONFIG", "IMAGE", "PSIRT", "EOX", "NETWORK_SETTINGS"] + valid_categories = ["INTENT", "RUNNING_CONFIG", + "IMAGE", "PSIRT", "EOX", "NETWORK_SETTINGS"] if not all(category.upper() in valid_categories for category in run_compliance_categories): valid_categories_str = ", ".join(valid_categories) - self.msg = "Invalid category provided. Valid categories are {0}.".format(valid_categories_str) + self.msg = "Invalid category provided. Valid categories are {0}.".format( + valid_categories_str) self.fail_and_exit(self.msg) - self.log("Validation successful: valid run compliance categorites provided: {0}".format(run_compliance_categories), "DEBUG") + self.log("Validation successful: valid run compliance categorites provided: {0}".format( + run_compliance_categories), "DEBUG") def validate_params(self, config): """ @@ -528,7 +537,8 @@ def validate_params(self, config): Raises: Exception: If any validation fails, raises an exception with a message. """ - self.log("Validating the provided configuration: {0}".format(config), "INFO") + self.log("Validating the provided configuration: {0}".format( + config), "INFO") ip_address_list = config.get("ip_address_list") site_name = config.get("site_name") run_compliance = config.get("run_compliance") @@ -546,13 +556,15 @@ def validate_params(self, config): self.validate_iplist_and_site_name(ip_address_list, site_name) # Validate if a network compliance operation is present - self.validate_compliance_operation(run_compliance, run_compliance_categories, sync_device_config) + self.validate_compliance_operation( + run_compliance, run_compliance_categories, sync_device_config) # Validate the categories if provided if run_compliance_categories: self.validate_run_compliance_categories(run_compliance_categories) - self.log("Validation completed for configuration: {0}".format(config), "INFO") + self.log("Validation completed for configuration: {0}".format( + config), "INFO") def get_run_compliance_params(self, mgmt_ip_to_instance_id_map, run_compliance, run_compliance_categories): """ @@ -577,8 +589,10 @@ def get_run_compliance_params(self, mgmt_ip_to_instance_id_map, run_compliance, # Create run_compliance_params if run_compliance: - run_compliance_params["deviceUuids"] = list(mgmt_ip_to_instance_id_map.values()) - run_compliance_params["triggerFull"] = not bool(run_compliance_categories) + run_compliance_params["deviceUuids"] = list( + mgmt_ip_to_instance_id_map.values()) + run_compliance_params["triggerFull"] = not bool( + run_compliance_categories) if run_compliance_categories: run_compliance_params["categories"] = run_compliance_categories @@ -586,10 +600,12 @@ def get_run_compliance_params(self, mgmt_ip_to_instance_id_map, run_compliance, if run_compliance_params: device_in_progress = set() - response = self.get_compliance_report(run_compliance_params, mgmt_ip_to_instance_id_map) + response = self.get_compliance_report( + run_compliance_params, mgmt_ip_to_instance_id_map) if not response: - ip_address_list_str = ", ".join(list(mgmt_ip_to_instance_id_map.keys())) + ip_address_list_str = ", ".join( + list(mgmt_ip_to_instance_id_map.keys())) self.msg = ( "Error occurred when retrieving Compliance Report to identify if there are " "devices with 'IN_PROGRESS' status. This is required on device(s): {0}" @@ -601,7 +617,8 @@ def get_run_compliance_params(self, mgmt_ip_to_instance_id_map, run_compliance, for device_ip, compliance_details_list in response.items(): for compliance_type in compliance_details_list: if compliance_type.get("status") == "IN_PROGRESS": - device_in_progress.add(compliance_type.get("deviceUuid")) + device_in_progress.add( + compliance_type.get("deviceUuid")) self.log( "Number of devices with Compliance Status 'IN_PROGRESS': {0}. Device UUIDs: {1}".format( @@ -609,11 +626,14 @@ def get_run_compliance_params(self, mgmt_ip_to_instance_id_map, run_compliance, ) if device_in_progress: # Update run_compliance_params to exclude devices with 'IN_PROGRESS' status - run_compliance_params["deviceUuids"] = [device_id for device_id in mgmt_ip_to_instance_id_map.values() if device_id not in device_in_progress] - msg = "Excluding 'IN_PROGRESS' devices from compliance check. Updated run_compliance_params: {0}".format(run_compliance_params) + run_compliance_params["deviceUuids"] = [ + device_id for device_id in mgmt_ip_to_instance_id_map.values() if device_id not in device_in_progress] + msg = "Excluding 'IN_PROGRESS' devices from compliance check. Updated run_compliance_params: {0}".format( + run_compliance_params) self.log(msg, "DEBUG") - self.log("run_compliance_params: {0}".format(run_compliance_params), "DEBUG") + self.log("run_compliance_params: {0}".format( + run_compliance_params), "DEBUG") return run_compliance_params def get_sync_device_config_params(self, mgmt_ip_to_instance_id_map, categorized_devices): @@ -642,23 +662,30 @@ def get_sync_device_config_params(self, mgmt_ip_to_instance_id_map, categorized_ compliant_device_ips = categorized_devices.get("COMPLIANT", {}).keys() excluded_device_ips = set(other_device_ips) | set(compliant_device_ips) - self.log("Identified other device IPs: {0}".format(", ".join(other_device_ips)), "DEBUG") - self.log("Identified compliant device IPs: {0}".format(", ".join(compliant_device_ips)), "DEBUG") - self.log("Identified excluded device IPs: {0}".format(", ".join(excluded_device_ips)), "DEBUG") + self.log("Identified other device IPs: {0}".format( + ", ".join(other_device_ips)), "DEBUG") + self.log("Identified compliant device IPs: {0}".format( + ", ".join(compliant_device_ips)), "DEBUG") + self.log("Identified excluded device IPs: {0}".format( + ", ".join(excluded_device_ips)), "DEBUG") if excluded_device_ips: self.skipped_sync_device_configs_list.extend(excluded_device_ips) - excluded_device_uuids = [mgmt_ip_to_instance_id_map[ip] for ip in excluded_device_ips if ip in mgmt_ip_to_instance_id_map] + excluded_device_uuids = [mgmt_ip_to_instance_id_map[ip] + for ip in excluded_device_ips if ip in mgmt_ip_to_instance_id_map] sync_device_config_params["deviceId"] = [ device_id for device_id in mgmt_ip_to_instance_id_map.values() if device_id not in excluded_device_uuids ] excluded_device_ips_str = ", ".join(excluded_device_ips) - msg = "Skipping these devices because their compliance status is not 'NON_COMPLIANT': {0}".format(excluded_device_ips_str) + msg = "Skipping these devices because their compliance status is not 'NON_COMPLIANT': {0}".format( + excluded_device_ips_str) self.log(msg, "WARNING") - self.log("Updated 'sync_device_config_params' parameters: {0}".format(sync_device_config_params), "DEBUG") + self.log("Updated 'sync_device_config_params' parameters: {0}".format( + sync_device_config_params), "DEBUG") - self.log("Final sync_device_config_params: {0}".format(sync_device_config_params), "DEBUG") + self.log("Final sync_device_config_params: {0}".format( + sync_device_config_params), "DEBUG") return sync_device_config_params def get_device_list_params(self, ip_address_list): @@ -673,12 +700,14 @@ def get_device_list_params(self, ip_address_list): names required by Cisco Catalyst Center. It returns a dictionary of these mapped parameters which can be used to query devices based on the provided filters. """ - self.log("Entering get_device_list_params method with ip_address_list: {0}".format(ip_address_list), "DEBUG") + self.log("Entering get_device_list_params method with ip_address_list: {0}".format( + ip_address_list), "DEBUG") # Initialize an empty dictionary to store the mapped parameters get_device_list_params = {"management_ip_address": ip_address_list} - self.log("Generated get_device_list_params: {0}".format(get_device_list_params), "DEBUG") + self.log("Generated get_device_list_params: {0}".format( + get_device_list_params), "DEBUG") return get_device_list_params def get_device_ids_from_ip(self, get_device_list_params): @@ -693,7 +722,8 @@ def get_device_ids_from_ip(self, get_device_list_params): mapped to their instance IDs. Logs detailed information about the number of devices processed, skipped, and the final list of devices available for configuration backup. """ - self.log("Entering 'get_device_ids_from_ip' method with parameters: {0}".format(get_device_list_params), "DEBUG") + self.log("Entering 'get_device_ids_from_ip' method with parameters: {0}".format( + get_device_list_params), "DEBUG") mgmt_ip_to_instance_id_map = {} processed_device_count = 0 @@ -716,17 +746,20 @@ def get_device_ids_from_ip(self, get_device_list_params): op_modifies=False, params=get_device_list_params ) - self.log("Response received post 'get_device_list' API call with offset {0}: {1}".format(offset, str(response)), "DEBUG") + self.log("Response received post 'get_device_list' API call with offset {0}: {1}".format( + offset, str(response)), "DEBUG") # Check if a valid response is received if not response.get("response"): - self.log("Exiting the loop because no devices were returned after increasing the offset. Current offset: {0}".format(offset)) + self.log( + "Exiting the loop because no devices were returned after increasing the offset. Current offset: {0}".format(offset)) break # Exit loop if no devices are returned # Iterate over the devices in the response for device_info in response.get("response", []): processed_device_count += 1 - device_ip = device_info.get("managementIpAddress", "Unknown IP") + device_ip = device_info.get( + "managementIpAddress", "Unknown IP") reachability_status = device_info.get("reachabilityStatus") collection_status = device_info.get("collectionStatus") device_family = device_info.get("family") @@ -744,12 +777,14 @@ def get_device_ids_from_ip(self, get_device_list_params): # Check if the device is reachable and managed if reachability_status == "Reachable" and collection_status == "Managed": # Skip Unified AP devices - if device_family != "Unified AP" : + if device_family != "Unified AP": mgmt_ip_to_instance_id_map[device_ip] = device_id else: skipped_device_count += 1 - self.skipped_run_compliance_devices_list.append(device_ip) - self.skipped_sync_device_configs_list.append(device_ip) + self.skipped_run_compliance_devices_list.append( + device_ip) + self.skipped_sync_device_configs_list.append( + device_ip) msg = ( "Skipping device {0} as its family is: {1}.".format( device_ip, device_family @@ -758,7 +793,8 @@ def get_device_ids_from_ip(self, get_device_list_params): self.log(msg, "INFO") else: - self.skipped_run_compliance_devices_list.append(device_ip) + self.skipped_run_compliance_devices_list.append( + device_ip) self.skipped_sync_device_configs_list.append(device_ip) skipped_device_count += 1 msg = ( @@ -778,17 +814,22 @@ def get_device_ids_from_ip(self, get_device_list_params): self.skipped_sync_device_configs_list.append(ip) # Log the total number of devices processed and skipped - self.log("Total number of devices received: {0}".format(processed_device_count), "INFO") - self.log("Number of devices that are Unreachable or APs: {0}".format(skipped_device_count), "INFO") - self.log("Config Backup Operation can be performed on the following filtered devices: {0}".format(len(mgmt_ip_to_instance_id_map)), "INFO") + self.log("Total number of devices received: {0}".format( + processed_device_count), "INFO") + self.log("Number of devices that are Unreachable or APs: {0}".format( + skipped_device_count), "INFO") + self.log("Config Backup Operation can be performed on the following filtered devices: {0}".format( + len(mgmt_ip_to_instance_id_map)), "INFO") except Exception as e: # Log an error message if any exception occurs during the process - self.log("Error fetching device IDs from Cisco Catalyst Center. Error details: {0}".format(str(e)), "ERROR") + self.log("Error fetching device IDs from Cisco Catalyst Center. Error details: {0}".format( + str(e)), "ERROR") # Log an error if no reachable devices are found if not mgmt_ip_to_instance_id_map: - self.log("No reachable devices found among the provided parameters: {0}".format(mgmt_ip_to_instance_id_map), "ERROR") + self.log("No reachable devices found among the provided parameters: {0}".format( + mgmt_ip_to_instance_id_map), "ERROR") return mgmt_ip_to_instance_id_map @@ -812,16 +853,23 @@ def get_device_id_list(self, ip_address_list, site_name): mgmt_ip_to_instance_id_map = {} if ip_address_list: - self.log("Retrieving device IDs for IP addresses: {0}".format(", ".join(ip_address_list)), "DEBUG") - get_device_list_params = self.get_device_list_params(ip_address_list) - iplist_mgmt_ip_to_instance_id_map = self.get_device_ids_from_ip(get_device_list_params) - mgmt_ip_to_instance_id_map.update(iplist_mgmt_ip_to_instance_id_map) + self.log("Retrieving device IDs for IP addresses: {0}".format( + ", ".join(ip_address_list)), "DEBUG") + get_device_list_params = self.get_device_list_params( + ip_address_list) + iplist_mgmt_ip_to_instance_id_map = self.get_device_ids_from_ip( + get_device_list_params) + mgmt_ip_to_instance_id_map.update( + iplist_mgmt_ip_to_instance_id_map) # Check if both site name and IP address list are provided if site_name: - self.log("Retrieving device IDs for site: {0}".format(site_name), "DEBUG") - site_mgmt_ip_to_instance_id_map, skipped_devices_list = self.get_reachable_devices_from_site(site_name) - self.skipped_run_compliance_devices_list.extend(skipped_devices_list) + self.log("Retrieving device IDs for site: {0}".format( + site_name), "DEBUG") + site_mgmt_ip_to_instance_id_map, skipped_devices_list = self.get_reachable_devices_from_site( + site_name) + self.skipped_run_compliance_devices_list.extend( + skipped_devices_list) self.skipped_sync_device_configs_list.extend(skipped_devices_list) mgmt_ip_to_instance_id_map.update(site_mgmt_ip_to_instance_id_map) @@ -862,7 +910,8 @@ def is_sync_required(self, response, mgmt_ip_to_instance_id_map): task_name, list(mgmt_ip_to_instance_id_map.keys()), response), "INFO") # Categorize the devices based on status - "COMPLIANT", "NON_COMPLIANT", "OTHER"(status other than COMPLIANT and NON_COMPLIANT) - categorized_devices = {"COMPLIANT": {}, "NON_COMPLIANT": {}, "OTHER": {}} + categorized_devices = {"COMPLIANT": {}, + "NON_COMPLIANT": {}, "OTHER": {}} for ip_address, compliance_type in response.items(): status = compliance_type[0]["status"] if status == "NON_COMPLIANT": @@ -872,11 +921,13 @@ def is_sync_required(self, response, mgmt_ip_to_instance_id_map): else: categorized_devices["OTHER"][ip_address] = compliance_type - self.log("Device(s) Categorized based on Compliance status: {0}".format(categorized_devices), "INFO") + self.log("Device(s) Categorized based on Compliance status: {0}".format( + categorized_devices), "INFO") # Validate if all devices are "COMPLIANT" - then sync not required if len(categorized_devices["COMPLIANT"]) + len(categorized_devices["OTHER"]) == len(mgmt_ip_to_instance_id_map): - compliant_device_ips_str = ", ".join(list(mgmt_ip_to_instance_id_map.keys())) + compliant_device_ips_str = ", ".join( + list(mgmt_ip_to_instance_id_map.keys())) msg = ( "Device(s) with IP address(es): {0} are already compliant with the RUNNING_CONFIG compliance type. " "Therefore, the task '{1}' is not required." @@ -898,10 +949,13 @@ def get_compliance_details_of_device(self, compliance_details_of_device_params, dict or None: The response from the compliance details API call if successful, None if an error occurs or no response is received. """ - self.log("Attempting to retrieve Compliance details for device: '{0}'".format(device_ip), "INFO") - response = self.execute_get_request("compliance", "compliance_details_of_device", compliance_details_of_device_params) + self.log("Attempting to retrieve Compliance details for device: '{0}'".format( + device_ip), "INFO") + response = self.execute_get_request( + "compliance", "compliance_details_of_device", compliance_details_of_device_params) if response: - self.log("Sucessfully retrieved Compliance details for device: '{0}'".format(device_ip), "INFO") + self.log("Sucessfully retrieved Compliance details for device: '{0}'".format( + device_ip), "INFO") return response.get("response") else: self.log( @@ -942,7 +996,8 @@ def get_compliance_report(self, run_compliance_params, mgmt_ip_to_instance_id_ma break if device_ip is None: - self.log("Device UUID: {0} not found in mgmt_ip_to_instance_id_map: {1}".format(device_uuid, mgmt_ip_to_instance_id_map), "DEBUG") + self.log("Device UUID: {0} not found in mgmt_ip_to_instance_id_map: {1}".format( + device_uuid, mgmt_ip_to_instance_id_map), "DEBUG") continue # Add the device IP to the device list @@ -959,7 +1014,8 @@ def get_compliance_report(self, run_compliance_params, mgmt_ip_to_instance_id_ma compliance_details_of_device_params["device_uuid"] = device_uuid compliance_details_of_device_params["diff_list"] = True - response = self.get_compliance_details_of_device(compliance_details_of_device_params, device_ip) + response = self.get_compliance_details_of_device( + compliance_details_of_device_params, device_ip) if response: final_response[device_ip].extend(response) @@ -967,14 +1023,16 @@ def get_compliance_report(self, run_compliance_params, mgmt_ip_to_instance_id_ma # Fetch compliance details for the device without specific category compliance_details_of_device_params["device_uuid"] = device_uuid compliance_details_of_device_params["diff_list"] = True - response = self.get_compliance_details_of_device(compliance_details_of_device_params, device_ip) + response = self.get_compliance_details_of_device( + compliance_details_of_device_params, device_ip) if response: final_response[device_ip].extend(response) # If no compliance details were found, update the result with an error message if not final_response: device_list_str = ", ".join(device_list) - self.msg = "No Compliance Details found for the devices: {0}".format(device_list_str) + self.msg = "No Compliance Details found for the devices: {0}".format( + device_list_str) self.fail_and_exit(self.msg) return final_response @@ -1001,22 +1059,29 @@ def run_compliance(self, run_compliance_params, batch_size): batches_dict = {} if len(device_uuids) > batch_size: - batches = [device_uuids[i:i + batch_size] for i in range(0, len(device_uuids), batch_size)] + batches = [device_uuids[i:i + batch_size] + for i in range(0, len(device_uuids), batch_size)] else: batches = [device_uuids] - self.log("Created {0} batch(es) for run compliance operation: {1}".format(len(batches), batches), "DEBUG") + self.log("Created {0} batch(es) for run compliance operation: {1}".format( + len(batches), batches), "DEBUG") for idx, batch in enumerate(batches): - self.log("Executing 'run_compliance' operation on batch: {0} - {1}".format(idx, batch), "DEBUG") + self.log( + "Executing 'run_compliance' operation on batch: {0} - {1}".format(idx, batch), "DEBUG") batch_params = run_compliance_params.copy() batch_params["deviceUuids"] = batch - self.log("Batch {0} Parameters: {1}".format(idx, batch_params), "DEBUG") + self.log("Batch {0} Parameters: {1}".format( + idx, batch_params), "DEBUG") - task_id = self.get_taskid_post_api_call("compliance", "run_compliance", batch_params) + task_id = self.get_taskid_post_api_call( + "compliance", "run_compliance", batch_params) if task_id: - batches_dict[idx] = {"task_id": task_id, "batch_params": batch_params} + batches_dict[idx] = {"task_id": task_id, + "batch_params": batch_params} else: - self.log("No response received from the 'run_compliance' API call for batch: {0}.".format(batch_params), "ERROR") + self.log("No response received from the 'run_compliance' API call for batch: {0}.".format( + batch_params), "ERROR") return batches_dict @@ -1046,7 +1111,8 @@ def handle_error(self, task_name, mgmt_ip_to_instance_id_map, failure_reason=Non self (object): An instance of the class used for interacting with Cisco Catalyst Center. """ # If failure reason is provided, include it in the error message - ip_address_list_str = ", ".join(list(mgmt_ip_to_instance_id_map.keys())) + ip_address_list_str = ", ".join( + list(mgmt_ip_to_instance_id_map.keys())) if failure_reason: self.msg = "An error occurred while performing {0} on device(s): {1}. The operation failed due to the following reason: {2}".format( task_name, ip_address_list_str, failure_reason) @@ -1091,12 +1157,15 @@ def get_batches_result(self, batches_dict): .format(task_name, task_id, idx, len(device_ids), device_ids) ) progress_validation = "report has been generated successfully" - self.get_task_status_from_task_by_id(task_id, task_name, failure_msg, success_msg, progress_validation=progress_validation) + self.get_task_status_from_task_by_id( + task_id, task_name, failure_msg, success_msg, progress_validation=progress_validation) else: - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) task_status = self.status - self.log("The task status of batch: {0} with task id: {1} is {2}".format(idx, task_id, task_status), "INFO") + self.log("The task status of batch: {0} with task id: {1} is {2}".format( + idx, task_id, task_status), "INFO") # Store the result for the current batch batch_result = { @@ -1109,7 +1178,8 @@ def get_batches_result(self, batches_dict): # Append the current batch result to the batches_result list batches_result.append(batch_result) - self.log("Collective result of all batches: {0}".format(batches_result), "DEBUG") + self.log("Collective result of all batches: {0}".format( + batches_result), "DEBUG") return batches_result def validate_batch_result(self, batches_result, retried_batches=None): @@ -1150,14 +1220,16 @@ def validate_batch_result(self, batches_result, retried_batches=None): ) continue - self.log("Re-running compliance check for batch {0} with batch_result: {1} ".format(batch, batches_result), "WARNING") + self.log("Re-running compliance check for batch {0} with batch_result: {1} ".format( + batch, batches_result), "WARNING") # Re-run the compliance check for the failed batch with batch size of 1 retried_batches.add(device_ids) batches_dict = self.run_compliance(batch_params, batch_size=1) batches_result = self.get_batches_result(batches_dict) # Recursively validate the batch results and append the successful device IDs - successful_devices.extend(self.validate_batch_result(batches_result, retried_batches=retried_batches)) + successful_devices.extend(self.validate_batch_result( + batches_result, retried_batches=retried_batches)) msg = ("The results of all batches have been validated, and the compliance checks " "were successfully executed on following devices: {0}".format(successful_devices)) self.log(msg, "DEBUG") @@ -1182,7 +1254,8 @@ def get_compliance_task_status(self, batches_dict, mgmt_ip_to_instance_id_map): batches_result = self.get_batches_result(batches_dict) successful_devices = self.validate_batch_result(batches_result) successful_devices_str = ", ".join(successful_devices) - self.log("{0} successful on device(s): {1}".format(task_name, successful_devices_str), "DEBUG") + self.log("{0} successful on device(s): {1}".format( + task_name, successful_devices_str), "DEBUG") # Reverse the mgmt_ip_to_instance_id_map to map device IDs to IPs id_to_ip_map = {v: k for k, v in mgmt_ip_to_instance_id_map.items()} @@ -1193,25 +1266,33 @@ def get_compliance_task_status(self, batches_dict, mgmt_ip_to_instance_id_map): for batch in batches_dict.values() for device_id in batch["batch_params"]["deviceUuids"] ] - unsuccessful_devices = list(set(all_device_ids) - set(successful_devices)) - unsuccessful_ips = [id_to_ip_map[device_id] for device_id in unsuccessful_devices if device_id in id_to_ip_map] + unsuccessful_devices = list( + set(all_device_ids) - set(successful_devices)) + unsuccessful_ips = [id_to_ip_map[device_id] + for device_id in unsuccessful_devices if device_id in id_to_ip_map] final_msg = {} if successful_devices: - successful_ips = [id_to_ip_map[device_id] for device_id in successful_devices if device_id in id_to_ip_map] - self.log("{0} Succeeded for following device(s): {1}".format(task_name, successful_ips), "INFO") + successful_ips = [id_to_ip_map[device_id] + for device_id in successful_devices if device_id in id_to_ip_map] + self.log("{0} Succeeded for following device(s): {1}".format( + task_name, successful_ips), "INFO") final_msg["{0} Succeeded for following device(s)".format(task_name)] = { "success_count": len(successful_ips), "success_devices": successful_ips } - successful_devices_params = self.want.get("run_compliance_params").copy() + successful_devices_params = self.want.get( + "run_compliance_params").copy() successful_devices_params["deviceUuids"] = successful_devices - compliance_report = self.get_compliance_report(successful_devices_params, mgmt_ip_to_instance_id_map) - self.log("Compliance Report for device on which compliance operation was successful: {0}".format(compliance_report), "INFO") + compliance_report = self.get_compliance_report( + successful_devices_params, mgmt_ip_to_instance_id_map) + self.log("Compliance Report for device on which compliance operation was successful: {0}".format( + compliance_report), "INFO") if unsuccessful_ips: - self.log("{0} Failed for following device(s): {1}".format(task_name, unsuccessful_ips), "ERROR") + self.log("{0} Failed for following device(s): {1}".format( + task_name, unsuccessful_ips), "ERROR") final_msg["{0} Failed for following device(s)".format(task_name)] = { "failed_count": len(unsuccessful_ips), "failed_devices": unsuccessful_ips @@ -1221,9 +1302,11 @@ def get_compliance_task_status(self, batches_dict, mgmt_ip_to_instance_id_map): # Determine the final operation result if successful_devices and unsuccessful_devices: - self.set_operation_result("failed", True, self.msg, "ERROR", compliance_report) + self.set_operation_result( + "failed", True, self.msg, "ERROR", compliance_report) elif successful_devices: - self.set_operation_result("success", True, self.msg, "INFO", compliance_report) + self.set_operation_result( + "success", True, self.msg, "INFO", compliance_report) elif unsuccessful_devices: self.set_operation_result("failed", True, self.msg, "ERROR") else: @@ -1252,17 +1335,22 @@ def get_sync_config_task_status(self, task_id, mgmt_ip_to_instance_id_map): # Retrieve the parameters for sync device config sync_device_config_params = self.want.get("sync_device_config_params") - self.log("Sync device config parameters: {0}".format(sync_device_config_params), "DEBUG") + self.log("Sync device config parameters: {0}".format( + sync_device_config_params), "DEBUG") # Extract the list of device IDs from sync_device_config_params device_ids = sync_device_config_params.get("deviceId") - self.log("Device IDs for synchronization: {0}".format(device_ids), "DEBUG") + self.log("Device IDs for synchronization: {0}".format( + device_ids), "DEBUG") # Create device_ip_list by mapping the device IDs back to their corresponding IP addresses - device_ip_list = [ip for ip, device_id in mgmt_ip_to_instance_id_map.items() if device_id in device_ids] - self.log("Device IPs to synchronize: {0}".format(device_ip_list), "DEBUG") + device_ip_list = [ip for ip, device_id in mgmt_ip_to_instance_id_map.items( + ) if device_id in device_ids] + self.log("Device IPs to synchronize: {0}".format( + device_ip_list), "DEBUG") - msg["{0} Succeeded for following device(s)".format(task_name)] = {"success_count": len(device_ip_list), "success_devices": device_ip_list} + msg["{0} Succeeded for following device(s)".format(task_name)] = { + "success_count": len(device_ip_list), "success_devices": device_ip_list} # Retrieve and return the task status using the provided task ID return self.get_task_status_from_tasks_by_id(task_id, task_name, msg) @@ -1297,7 +1385,8 @@ def verify_sync_device_config(self): """ # Get compliance details before running sync_device_config compliance_details_before = self.want.get("compliance_details") - self.log("Compliance details before running sync_device_config: {0}".format(compliance_details_before), "INFO") + self.log("Compliance details before running sync_device_config: {0}".format( + compliance_details_before), "INFO") # Get compliance details after running sync_device_config compliance_details_after = self.get_compliance_report( @@ -1308,10 +1397,12 @@ def verify_sync_device_config(self): self.msg = "Error occurred when Retrieving Compliance Details after for verifying configuration." self.fail_and_exit(self.msg) - self.log("Compliance details after running sync_device_config: {0}.".format(compliance_details_after), "INFO") + self.log("Compliance details after running sync_device_config: {0}.".format( + compliance_details_after), "INFO") # Get the device IDs to check - sync_device_ids = self.want.get("sync_device_config_params").get("deviceId", []) + sync_device_ids = self.want.get( + "sync_device_config_params").get("deviceId", []) if not sync_device_ids: self.log( "No device IDs found in sync_device_config_params, Sync Device Configuration " @@ -1328,35 +1419,45 @@ def verify_sync_device_config(self): self.log("Device IDs to check: {0}".format(sync_device_ids), "DEBUG") for device_id in sync_device_ids: # Find the corresponding IP address from the mgmt_ip_to_instance_id_map - ip_address = next((ip for ip, id in self.want.get("mgmt_ip_to_instance_id_map").items() if id == device_id), None) - self.log("Found IP address for device ID {0}: {1}".format(device_id, ip_address), "DEBUG") + ip_address = next((ip for ip, id in self.want.get( + "mgmt_ip_to_instance_id_map").items() if id == device_id), None) + self.log("Found IP address for device ID {0}: {1}".format( + device_id, ip_address), "DEBUG") if ip_address: - self.log("Checking compliance status for device ID: {0}".format(device_id), "DEBUG") + self.log("Checking compliance status for device ID: {0}".format( + device_id), "DEBUG") # Get the status before - compliance_before = compliance_details_before.get(ip_address, []) + compliance_before = compliance_details_before.get( + ip_address, []) if compliance_before: all_statuses_before.append(compliance_before[0]["status"]) else: - self.log("No compliance details found for device IP: {0} before synchronization.".format(ip_address), "DEBUG") + self.log("No compliance details found for device IP: {0} before synchronization.".format( + ip_address), "DEBUG") # Get the status after compliance_after = compliance_details_after.get(ip_address, []) if compliance_after: all_statuses_after.append(compliance_after[0]["status"]) else: - self.log("No compliance details found for device IP: {0} after synchronization.".format(ip_address), "DEBUG") + self.log("No compliance details found for device IP: {0} after synchronization.".format( + ip_address), "DEBUG") - self.log("Compliance statuses before synchronization: {0}".format(all_statuses_before), "DEBUG") - self.log("Compliance statuses after synchronization: {0}".format(all_statuses_after), "DEBUG") + self.log("Compliance statuses before synchronization: {0}".format( + all_statuses_before), "DEBUG") + self.log("Compliance statuses after synchronization: {0}".format( + all_statuses_after), "DEBUG") else: - self.log("No IP address found for device ID: {0}".format(device_id), "DEBUG") + self.log("No IP address found for device ID: {0}".format( + device_id), "DEBUG") # Check if all statuses changed from "NON_COMPLIANT" to "COMPLIANT" if ( all(all_status == "NON_COMPLIANT" for all_status in all_statuses_before) and all(all_status == "COMPLIANT" for all_status in all_statuses_after) ): - self.log("Verified the success of the Sync Device Configuration operation.") + self.log( + "Verified the success of the Sync Device Configuration operation.") else: self.log( "Sync Device Configuration operation may have been unsuccessful " @@ -1384,11 +1485,13 @@ def get_want(self, config): # Store input parameters ip_address_list = config.get("ip_address_list") - self.log("Original IP address list: {0}".format(ip_address_list), "DEBUG") + self.log("Original IP address list: {0}".format( + ip_address_list), "DEBUG") # Remove Duplicates from list if ip_address_list: ip_address_list = list(set(ip_address_list)) - self.log("Deduplicated IP address list: {0}".format(ip_address_list), "DEBUG") + self.log("Deduplicated IP address list: {0}".format( + ip_address_list), "DEBUG") site_name = config.get("site_name") run_compliance = config.get("run_compliance") @@ -1399,11 +1502,14 @@ def get_want(self, config): self.validate_params(config) # Retrieve device ID list - mgmt_ip_to_instance_id_map = self.get_device_id_list(ip_address_list, site_name) - self.log("Management IP to Instance ID Map: {0}".format(mgmt_ip_to_instance_id_map), "DEBUG") + mgmt_ip_to_instance_id_map = self.get_device_id_list( + ip_address_list, site_name) + self.log("Management IP to Instance ID Map: {0}".format( + mgmt_ip_to_instance_id_map), "DEBUG") # Run Compliance Paramters - run_compliance_params = self.get_run_compliance_params(mgmt_ip_to_instance_id_map, run_compliance, run_compliance_categories) + run_compliance_params = self.get_run_compliance_params( + mgmt_ip_to_instance_id_map, run_compliance, run_compliance_categories) # Sync Device Configuration Parameters if sync_device_config: @@ -1413,23 +1519,32 @@ def get_want(self, config): "deviceUuids": list(mgmt_ip_to_instance_id_map.values()), "categories": ["RUNNING_CONFIG"] } - self.log("Retrieving compliance report with parameters: {0}".format(compliance_detail_params_sync), "DEBUG") - response = self.get_compliance_report(compliance_detail_params_sync, mgmt_ip_to_instance_id_map) - self.log("Response from get_compliance_report: {0}".format(response), "DEBUG") + self.log("Retrieving compliance report with parameters: {0}".format( + compliance_detail_params_sync), "DEBUG") + response = self.get_compliance_report( + compliance_detail_params_sync, mgmt_ip_to_instance_id_map) + self.log("Response from get_compliance_report: {0}".format( + response), "DEBUG") if not response: - ip_address_list_str = ", ".join(list(mgmt_ip_to_instance_id_map.keys())) + ip_address_list_str = ", ".join( + list(mgmt_ip_to_instance_id_map.keys())) self.msg = "Error occurred when retrieving Compliance Report to identify if Sync Device Config Operation " - self.msg += "is required on device(s): {0}".format(ip_address_list_str) + self.msg += "is required on device(s): {0}".format( + ip_address_list_str) self.fail_and_exit(self.msg) compliance_details = response - sync_required, self.msg, categorized_devices = self.is_sync_required(response, mgmt_ip_to_instance_id_map) - self.log("Is Sync Requied: {0} -- Message: {1}".format(sync_required, self.msg), "DEBUG") + sync_required, self.msg, categorized_devices = self.is_sync_required( + response, mgmt_ip_to_instance_id_map) + self.log( + "Is Sync Requied: {0} -- Message: {1}".format(sync_required, self.msg), "DEBUG") if sync_required: - sync_device_config_params = self.get_sync_device_config_params(mgmt_ip_to_instance_id_map, categorized_devices) + sync_device_config_params = self.get_sync_device_config_params( + mgmt_ip_to_instance_id_map, categorized_devices) self.log( "Sync Device Configuration operation is required for provided parameters in the Cisco Catalyst Center." - "therefore setting 'sync_device_config_params' - {0}.".format(sync_device_config_params), + "therefore setting 'sync_device_config_params' - {0}.".format( + sync_device_config_params), "DEBUG" ) else: @@ -1438,13 +1553,15 @@ def get_want(self, config): "therefore not setting the 'sync_device_config_params'", "INFO" ) - self.skipped_sync_device_configs_list.extend(list(mgmt_ip_to_instance_id_map.keys())) + self.skipped_sync_device_configs_list.extend( + list(mgmt_ip_to_instance_id_map.keys())) else: self.msg = ( "The specified Cisco Catalyst Center version: '{0}' does not support the Sync Device Config operation. " "Supported version start '2.3.7.6' onwards. Version '2.3.5.3' introduces APIs for " "performing Compliance Checks. Version '2.3.7.6' expands support to include APIs " - "for Compliance Checks and Sync Device Config operations.".format(self.get_ccc_version()) + "for Compliance Checks and Sync Device Config operations.".format( + self.get_ccc_version()) ) self.fail_and_exit(self.msg) @@ -1497,34 +1614,44 @@ def get_diff_merged(self, config): req_action_param = self.want.get(action_param) # Execute the action and check its status if req_action_param: - self.log("Executing action function: {0} with params: {1}".format(action_func.__name__, req_action_param), "INFO") + self.log("Executing action function: {0} with params: {1}".format( + action_func.__name__, req_action_param), "INFO") if action_param == "run_compliance_params": batch_size = self.want.get("run_compliance_batch_size") - result_task_id = action_func(self.want.get(action_param), batch_size=batch_size) + result_task_id = action_func(self.want.get( + action_param), batch_size=batch_size) else: result_task_id = action_func(self.want.get(action_param)) if not result_task_id: - self.msg = "An error occurred while retrieving the task_id of the {0} operation.".format(action_func.__name__) - self.set_operation_result("failed", False, self.msg, "CRITICAL") + self.msg = "An error occurred while retrieving the task_id of the {0} operation.".format( + action_func.__name__) + self.set_operation_result( + "failed", False, self.msg, "CRITICAL") else: - self.log("Task Id: {0} returned from the action function: {1}".format(result_task_id, action_func.__name__), "DEBUG") - status_func(result_task_id, self.want.get("mgmt_ip_to_instance_id_map")).check_return_status() + self.log("Task Id: {0} returned from the action function: {1}".format( + result_task_id, action_func.__name__), "DEBUG") + status_func(result_task_id, self.want.get( + "mgmt_ip_to_instance_id_map")).check_return_status() result = self.msg result_details.update(result) if config.get("sync_device_config"): - skipped_sync_device_configs_list = set(self.skipped_sync_device_configs_list) + skipped_sync_device_configs_list = set( + self.skipped_sync_device_configs_list) if skipped_sync_device_configs_list: - self.log("Sync Device Configuration skipped for devices: {0}".format(skipped_sync_device_configs_list), "DEBUG") + self.log("Sync Device Configuration skipped for devices: {0}".format( + skipped_sync_device_configs_list), "DEBUG") result_details["Sync Device Configuration operation Skipped for following device(s)"] = { "skipped_count": len(skipped_sync_device_configs_list), "skipped_devices": skipped_sync_device_configs_list } - skipped_run_compliance_devices_list = set(self.skipped_run_compliance_devices_list) + skipped_run_compliance_devices_list = set( + self.skipped_run_compliance_devices_list) if skipped_run_compliance_devices_list: - self.log("Run Compliance Check skipped for devices: {0}".format(skipped_run_compliance_devices_list), "DEBUG") + self.log("Run Compliance Check skipped for devices: {0}".format( + skipped_run_compliance_devices_list), "DEBUG") result_details["Run Compliance Check Skipped for following device(s)"] = { "skipped_count": len(skipped_run_compliance_devices_list), "skipped_devices": skipped_run_compliance_devices_list @@ -1532,8 +1659,10 @@ def get_diff_merged(self, config): final_status, is_changed = self.process_final_result(final_status_list) self.msg = result_details - self.log("Completed 'get_diff_merged' operation with final status: {0}, is_changed: {1}".format(final_status, is_changed), "INFO") - self.set_operation_result(final_status, is_changed, self.msg, "INFO", self.result.get("data")) + self.log("Completed 'get_diff_merged' operation with final status: {0}, is_changed: {1}".format( + final_status, is_changed), "INFO") + self.set_operation_result( + final_status, is_changed, self.msg, "INFO", self.result.get("data")) return self def verify_diff_merged(self, config): @@ -1555,12 +1684,15 @@ def verify_diff_merged(self, config): run_compliance_params = self.want.get("run_compliance_params") if sync_device_config_params: - self.log("Starting verification of Sync Device Configuration operation.", "INFO") + self.log( + "Starting verification of Sync Device Configuration operation.", "INFO") self.verify_sync_device_config() - self.log("Completed verification of Sync Device Configuration operation.", "INFO") + self.log( + "Completed verification of Sync Device Configuration operation.", "INFO") if run_compliance_params: - self.log("Verification of configuration is not required for Run Compliance operation!", "INFO") + self.log( + "Verification of configuration is not required for Run Compliance operation!", "INFO") self.log("Completed 'verify_diff_merged' operation.", "INFO") return self @@ -1616,9 +1748,11 @@ def main(): # Iterate over the validated configuration parameters for config in ccc_network_compliance.validated_config: ccc_network_compliance.get_want(config).check_return_status() - ccc_network_compliance.get_diff_state_apply[state](config).check_return_status() + ccc_network_compliance.get_diff_state_apply[state]( + config).check_return_status() if config_verify: - ccc_network_compliance.verify_diff_state_apply[state](config).check_return_status() + ccc_network_compliance.verify_diff_state_apply[state]( + config).check_return_status() # Exit with the result obtained from the NetworkCompliance object module.exit_json(**ccc_network_compliance.result) diff --git a/plugins/modules/network_settings_intent.py b/plugins/modules/network_settings_intent.py index a86d342cfd..7669683940 100644 --- a/plugins/modules/network_settings_intent.py +++ b/plugins/modules/network_settings_intent.py @@ -5,6 +5,14 @@ """Ansible module to perform operations on global pool, reserve pool and network in DNAC.""" from __future__ import absolute_import, division, print_function +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + get_dict_result, + dnac_compare_equality, +) +from ansible.module_utils.basic import AnsibleModule +import copy __metaclass__ = type __author__ = ['Muthu Rakesh, Madhan Sankaranarayanan'] @@ -448,15 +456,6 @@ } """ -import copy -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - get_dict_result, - dnac_compare_equality, -) - class NetworkSettings(DnacBase): """Class containing member attributes for network intent module""" @@ -598,14 +597,17 @@ def validate_input(self): # Validate playbook params against the specification (temp_spec) self.config = self.camel_to_snake_case(self.config) - valid_temp, invalid_params = validate_list_of_dicts(self.config, temp_spec) + valid_temp, invalid_params = validate_list_of_dicts( + self.config, temp_spec) if invalid_params: - self.msg = "Invalid parameters in playbook: {0}".format("\n".join(invalid_params)) + self.msg = "Invalid parameters in playbook: {0}".format( + "\n".join(invalid_params)) self.status = "failed" return self self.validated_config = valid_temp - self.log("Successfully validated playbook config params: {0}".format(valid_temp), "INFO") + self.log("Successfully validated playbook config params: {0}".format( + valid_temp), "INFO") self.msg = "Successfully validated input from the playbook" self.status = "success" return self @@ -708,14 +710,16 @@ def get_site_id(self, site_name): op_modifies=True, params={"name": site_name}, ) - self.log("Received API response from 'get_site': {0}".format(response), "DEBUG") + self.log("Received API response from 'get_site': {0}".format( + response), "DEBUG") if not response: self.log("Failed to retrieve the site ID for the site name: {0}" .format(site_name), "ERROR") return None _id = response.get("response")[0].get("id") - self.log("Site ID for site name '{0}': {1}".format(site_name, _id), "DEBUG") + self.log("Site ID for site name '{0}': {1}".format( + site_name, _id), "DEBUG") except Exception as msg: self.log("Exception occurred while retrieving site_id from the site_name: {0}" .format(msg), "CRITICAL") @@ -751,14 +755,16 @@ def get_global_pool_params(self, pool_info): }] } } - self.log("Formated global pool details: {0}".format(global_pool), "DEBUG") + self.log("Formated global pool details: {0}".format( + global_pool), "DEBUG") global_ippool = global_pool.get("settings").get("ippool")[0] if pool_info.get("ipv6") is False: global_ippool.update({"IpAddressSpace": "IPv4"}) else: global_ippool.update({"IpAddressSpace": "IPv6"}) - self.log("ip_address_space: {0}".format(global_ippool.get("IpAddressSpace")), "DEBUG") + self.log("ip_address_space: {0}".format( + global_ippool.get("IpAddressSpace")), "DEBUG") if not pool_info["gateways"]: global_ippool.update({"gateway": ""}) else: @@ -790,7 +796,8 @@ def get_reserve_pool_params(self, pool_info): "ipv6AddressSpace": "False" }) if pool_info.get("ipPools")[0].get("gateways") != []: - reserve_pool.update({"ipv4GateWay": pool_info.get("ipPools")[0].get("gateways")[0]}) + reserve_pool.update( + {"ipv4GateWay": pool_info.get("ipPools")[0].get("gateways")[0]}) else: reserve_pool.update({"ipv4GateWay": ""}) reserve_pool.update({"ipv6AddressSpace": "False"}) @@ -837,7 +844,8 @@ def get_reserve_pool_params(self, pool_info): else: reserve_pool.update({"ipv6GateWay": ""}) reserve_pool.update({"slaacSupport": True}) - self.log("Formatted reserve pool details: {0}".format(reserve_pool), "DEBUG") + self.log("Formatted reserve pool details: {0}".format( + reserve_pool), "DEBUG") return reserve_pool def get_network_params(self, site_id): @@ -860,7 +868,8 @@ def get_network_params(self, site_id): op_modifies=True, params={"site_id": site_id} ) - self.log("Received API response from 'get_network_v2': {0}".format(response), "DEBUG") + self.log("Received API response from 'get_network_v2': {0}".format( + response), "DEBUG") if not isinstance(response, dict): self.log("Failed to retrieve the network details - " "Response is not a dictionary", "ERROR") @@ -868,23 +877,35 @@ def get_network_params(self, site_id): # Extract various network-related details from the response all_network_details = response.get("response") - dhcp_details = get_dict_result(all_network_details, "key", "dhcp.server") + dhcp_details = get_dict_result( + all_network_details, "key", "dhcp.server") dns_details = get_dict_result(all_network_details, "key", "dns.server") - snmp_details = get_dict_result(all_network_details, "key", "snmp.trap.receiver") - syslog_details = get_dict_result(all_network_details, "key", "syslog.server") - netflow_details = get_dict_result(all_network_details, "key", "netflow.collector") - ntpserver_details = get_dict_result(all_network_details, "key", "ntp.server") - timezone_details = get_dict_result(all_network_details, "key", "timezone.site") - messageoftheday_details = get_dict_result(all_network_details, "key", "device.banner") - network_aaa = get_dict_result(all_network_details, "key", "aaa.network.server.1") - network_aaa2 = get_dict_result(all_network_details, "key", "aaa.network.server.2") - network_aaa_pan = get_dict_result(all_network_details, "key", "aaa.server.pan.network") - clientAndEndpoint_aaa = get_dict_result(all_network_details, "key", "aaa.endpoint.server.1") + snmp_details = get_dict_result( + all_network_details, "key", "snmp.trap.receiver") + syslog_details = get_dict_result( + all_network_details, "key", "syslog.server") + netflow_details = get_dict_result( + all_network_details, "key", "netflow.collector") + ntpserver_details = get_dict_result( + all_network_details, "key", "ntp.server") + timezone_details = get_dict_result( + all_network_details, "key", "timezone.site") + messageoftheday_details = get_dict_result( + all_network_details, "key", "device.banner") + network_aaa = get_dict_result( + all_network_details, "key", "aaa.network.server.1") + network_aaa2 = get_dict_result( + all_network_details, "key", "aaa.network.server.2") + network_aaa_pan = get_dict_result( + all_network_details, "key", "aaa.server.pan.network") + clientAndEndpoint_aaa = get_dict_result( + all_network_details, "key", "aaa.endpoint.server.1") clientAndEndpoint_aaa2 = get_dict_result(all_network_details, "key", "aaa.endpoint.server.2") clientAndEndpoint_aaa_pan = \ - get_dict_result(all_network_details, "key", "aaa.server.pan.endpoint") + get_dict_result(all_network_details, "key", + "aaa.server.pan.endpoint") # Prepare the network details for Cisco DNA Center configuration network_details = { @@ -920,7 +941,8 @@ def get_network_params(self, site_id): }) if ntpserver_details and ntpserver_details.get("value") != []: - network_settings.update({"ntpServer": ntpserver_details.get("value")}) + network_settings.update( + {"ntpServer": ntpserver_details.get("value")}) else: network_settings.update({"ntpServer": [""]}) @@ -985,7 +1007,8 @@ def get_network_params(self, site_id): } }) - self.log("Formatted playbook network details: {0}".format(network_details), "DEBUG") + self.log("Formatted playbook network details: {0}".format( + network_details), "DEBUG") return network_details def global_pool_exists(self, name): @@ -1017,17 +1040,21 @@ def global_pool_exists(self, name): return global_pool all_global_pool_details = response.get("response") - global_pool_details = get_dict_result(all_global_pool_details, "ipPoolName", name) + global_pool_details = get_dict_result( + all_global_pool_details, "ipPoolName", name) self.log("Global ip pool name: {0}".format(name), "DEBUG") - self.log("Global pool details: {0}".format(global_pool_details), "DEBUG") + self.log("Global pool details: {0}".format( + global_pool_details), "DEBUG") if not global_pool_details: self.log("Global pool {0} does not exist".format(name), "INFO") return global_pool global_pool.update({"exists": True}) global_pool.update({"id": global_pool_details.get("id")}) - global_pool["details"] = self.get_global_pool_params(global_pool_details) + global_pool["details"] = self.get_global_pool_params( + global_pool_details) - self.log("Formatted global pool details: {0}".format(global_pool), "DEBUG") + self.log("Formatted global pool details: {0}".format( + global_pool), "DEBUG") return global_pool def reserve_pool_exists(self, name, site_name): @@ -1053,10 +1080,12 @@ def reserve_pool_exists(self, name, site_name): "success": True } site_id = self.get_site_id(site_name) - self.log("Site ID for the site name {0}: {1}".format(site_name, site_id), "DEBUG") + self.log("Site ID for the site name {0}: {1}".format( + site_name, site_id), "DEBUG") if not site_id: reserve_pool.update({"success": False}) - self.msg = "Failed to get the site id from the site name {0}".format(site_name) + self.msg = "Failed to get the site id from the site name {0}".format( + site_name) self.status = "failed" return reserve_pool @@ -1073,7 +1102,8 @@ def reserve_pool_exists(self, name, site_name): return reserve_pool all_reserve_pool_details = response.get("response") - reserve_pool_details = get_dict_result(all_reserve_pool_details, "groupName", name) + reserve_pool_details = get_dict_result( + all_reserve_pool_details, "groupName", name) if not reserve_pool_details: self.log("Reserved pool {0} does not exist in the site {1}" .format(name, site_name), "DEBUG") @@ -1081,10 +1111,13 @@ def reserve_pool_exists(self, name, site_name): reserve_pool.update({"exists": True}) reserve_pool.update({"id": reserve_pool_details.get("id")}) - reserve_pool.update({"details": self.get_reserve_pool_params(reserve_pool_details)}) + reserve_pool.update( + {"details": self.get_reserve_pool_params(reserve_pool_details)}) - self.log("Reserved pool details: {0}".format(reserve_pool.get("details")), "DEBUG") - self.log("Reserved pool id: {0}".format(reserve_pool.get("id")), "DEBUG") + self.log("Reserved pool details: {0}".format( + reserve_pool.get("details")), "DEBUG") + self.log("Reserved pool id: {0}".format( + reserve_pool.get("id")), "DEBUG") return reserve_pool def get_have_global_pool(self, config): @@ -1105,7 +1138,8 @@ def get_have_global_pool(self, config): "details": None, "id": None } - global_pool_settings = config.get("global_pool_details").get("settings") + global_pool_settings = config.get( + "global_pool_details").get("settings") if global_pool_settings is None: self.msg = "settings in global_pool_details is missing in the playbook" self.status = "failed" @@ -1132,12 +1166,15 @@ def get_have_global_pool(self, config): prev_name is not None: global_pool = self.global_pool_exists(prev_name) if global_pool.get("exists") is False: - self.msg = "Prev name {0} doesn't exist in global_pool_details".format(prev_name) + self.msg = "Prev name {0} doesn't exist in global_pool_details".format( + prev_name) self.status = "failed" return self - self.log("Global pool exists: {0}".format(global_pool.get("exists")), "DEBUG") - self.log("Current Site: {0}".format(global_pool.get("details")), "DEBUG") + self.log("Global pool exists: {0}".format( + global_pool.get("exists")), "DEBUG") + self.log("Current Site: {0}".format( + global_pool.get("details")), "DEBUG") self.have.update({"globalPool": global_pool}) self.msg = "Collecting the global pool details from the Cisco DNA Center" self.status = "success" @@ -1193,12 +1230,15 @@ def get_have_reserve_pool(self, config): # If the previous name doesn't exist in Cisco DNA Center, return with error if reserve_pool.get("exists") is False: - self.msg = "Prev name {0} doesn't exist in reserve_pool_details".format(prev_name) + self.msg = "Prev name {0} doesn't exist in reserve_pool_details".format( + prev_name) self.status = "failed" return self - self.log("Reserved pool exists: {0}".format(reserve_pool.get("exists")), "DEBUG") - self.log("Reserved pool: {0}".format(reserve_pool.get("details")), "DEBUG") + self.log("Reserved pool exists: {0}".format( + reserve_pool.get("exists")), "DEBUG") + self.log("Reserved pool: {0}".format( + reserve_pool.get("details")), "DEBUG") # If reserve pool exist, convert ipv6AddressSpace to the required format (boolean) if reserve_pool.get("exists"): @@ -1240,7 +1280,8 @@ def get_have_network(self, config): network["site_id"] = site_id network["net_details"] = self.get_network_params(site_id) - self.log("Network details from the Catalyst Center: {0}".format(network), "DEBUG") + self.log("Network details from the Catalyst Center: {0}".format( + network), "DEBUG") self.have.update({"network": network}) self.msg = "Collecting the network details from the Cisco DNA Center" self.status = "success" @@ -1319,7 +1360,8 @@ def get_want_global_pool(self, global_ippool): want_ippool.update({"type": "Generic"}) else: want_ippool.update({"type": global_ippool_type}) - self.log("'type' is deprecated and use 'pool_type'", "WARNING") + self.log( + "'type' is deprecated and use 'pool_type'", "WARNING") else: have_ippool = self.have.get("globalPool").get("details") \ @@ -1338,7 +1380,8 @@ def get_want_global_pool(self, global_ippool): if want_ippool.get(key) is None and have_ippool.get(key) is not None: want_ippool[key] = have_ippool[key] - self.log("Global pool playbook details: {0}".format(want_global), "DEBUG") + self.log("Global pool playbook details: {0}".format( + want_global), "DEBUG") self.want.update({"wantGlobal": want_global}) self.msg = "Collecting the global pool details from the playbook" self.status = "success" @@ -1402,7 +1445,8 @@ def get_want_reserve_pool(self, reserve_pool): self.status = "failed" return self - self.log("Reserved IP pool playbook details: {0}".format(want_reserve), "DEBUG") + self.log("Reserved IP pool playbook details: {0}".format( + want_reserve), "DEBUG") # If there are no existing Reserved Pool details, validate and set defaults if not self.have.get("reservePool").get("details"): @@ -1422,7 +1466,8 @@ def get_want_reserve_pool(self, reserve_pool): want_reserve.update({"type": "Generic"}) else: want_reserve.update({"type": reserve_pool_type}) - self.log("'type' is deprecated and use 'pool_type'", "WARNING") + self.log( + "'type' is deprecated and use 'pool_type'", "WARNING") if want_reserve.get("ipv4GateWay") is None: want_reserve.update({"ipv4GateWay": ""}) if want_reserve.get("ipv4DhcpServers") is None: @@ -1641,7 +1686,8 @@ def get_want_network(self, network_management_details): else: del want_network_settings["network_aaa"] - clientAndEndpoint_aaa = network_management_details.get("client_and_endpoint_aaa") + clientAndEndpoint_aaa = network_management_details.get( + "client_and_endpoint_aaa") if clientAndEndpoint_aaa: if clientAndEndpoint_aaa.get("ip_address"): want_network_settings.get("clientAndEndpoint_aaa").update({ @@ -1711,7 +1757,8 @@ def get_want(self, config): """ if config.get("global_pool_details"): - global_ippool = config.get("global_pool_details").get("settings").get("ip_pool")[0] + global_ippool = config.get("global_pool_details").get( + "settings").get("ip_pool")[0] self.get_want_global_pool(global_ippool).check_return_status() if config.get("reserve_pool_details"): @@ -1721,7 +1768,8 @@ def get_want(self, config): if config.get("network_management_details"): network_management_details = config.get("network_management_details") \ .get("settings") - self.get_want_network(network_management_details).check_return_status() + self.get_want_network( + network_management_details).check_return_status() self.log("Desired State (want): {0}".format(self.want), "INFO") self.msg = "Successfully retrieved details from the playbook" @@ -1747,27 +1795,33 @@ def update_global_pool(self, config): # Check pool exist, if not create and return if not self.have.get("globalPool").get("exists"): pool_params = self.want.get("wantGlobal") - self.log("Desired State for global pool (want): {0}".format(pool_params), "DEBUG") + self.log("Desired State for global pool (want): {0}".format( + pool_params), "DEBUG") response = self.dnac._exec( family="network_settings", function="create_global_pool", op_modifies=True, params=pool_params, ) - self.check_execution_response_status(response).check_return_status() - self.log("Successfully created global pool '{0}'.".format(name), "INFO") + self.check_execution_response_status( + response).check_return_status() + self.log( + "Successfully created global pool '{0}'.".format(name), "INFO") result_global_pool.get("response").get(name) \ .update({"globalPool Details": self.want.get("wantGlobal")}) - result_global_pool.get("msg").update({name: "Global Pool Created Successfully"}) + result_global_pool.get("msg").update( + {name: "Global Pool Created Successfully"}) return # Pool exists, check update is required if not self.requires_update(self.have.get("globalPool").get("details"), self.want.get("wantGlobal"), self.global_pool_obj_params): - self.log("Global pool '{0}' doesn't require an update".format(name), "INFO") + self.log( + "Global pool '{0}' doesn't require an update".format(name), "INFO") result_global_pool.get("response").get(name).update({ "Cisco DNA Center params": - self.have.get("globalPool").get("details").get("settings").get("ippool")[0] + self.have.get("globalPool").get( + "details").get("settings").get("ippool")[0] }) result_global_pool.get("response").get(name).update({ "Id": self.have.get("globalPool").get("id") @@ -1781,19 +1835,23 @@ def update_global_pool(self, config): # Pool Exists pool_params = copy.deepcopy(self.want.get("wantGlobal")) pool_params_ippool = pool_params.get("settings").get("ippool")[0] - pool_params_ippool.update({"id": self.have.get("globalPool").get("id")}) - self.log("Desired State for global pool (want): {0}".format(pool_params), "DEBUG") + pool_params_ippool.update( + {"id": self.have.get("globalPool").get("id")}) + self.log("Desired State for global pool (want): {0}".format( + pool_params), "DEBUG") keys_to_remove = ["IpAddressSpace", "ipPoolCidr", "type"] for key in keys_to_remove: del pool_params["settings"]["ippool"][0][key] - have_ippool = self.have.get("globalPool").get("details").get("settings").get("ippool")[0] + have_ippool = self.have.get("globalPool").get( + "details").get("settings").get("ippool")[0] keys_to_update = ["dhcpServerIps", "dnsServerIps", "gateway"] for key in keys_to_update: if pool_params_ippool.get(key) is None: pool_params_ippool[key] = have_ippool.get(key) - self.log("Desired global pool details (want): {0}".format(pool_params), "DEBUG") + self.log("Desired global pool details (want): {0}".format( + pool_params), "DEBUG") response = self.dnac._exec( family="network_settings", function="update_global_pool", @@ -1805,7 +1863,8 @@ def update_global_pool(self, config): self.log("Global pool '{0}' updated successfully".format(name), "INFO") result_global_pool.get("response").get(name) \ .update({"Id": self.have.get("globalPool").get("details").get("id")}) - result_global_pool.get("msg").update({name: "Global Pool Updated Successfully"}) + result_global_pool.get("msg").update( + {name: "Global Pool Updated Successfully"}) return def update_reserve_pool(self, config): @@ -1837,15 +1896,18 @@ def update_reserve_pool(self, config): site_id = self.get_site_id(site_name) reserve_params.update({"site_id": site_id}) if not self.have.get("reservePool").get("exists"): - self.log("Desired reserved pool details (want): {0}".format(reserve_params), "DEBUG") + self.log("Desired reserved pool details (want): {0}".format( + reserve_params), "DEBUG") response = self.dnac._exec( family="network_settings", function="reserve_ip_subpool", op_modifies=True, params=reserve_params, ) - self.check_execution_response_status(response).check_return_status() - self.log("Successfully created IP subpool reservation '{0}'.".format(name), "INFO") + self.check_execution_response_status( + response).check_return_status() + self.log( + "Successfully created IP subpool reservation '{0}'.".format(name), "INFO") result_reserve_pool.get("response").get(name) \ .update({"reservePool Details": self.want.get("wantReserve")}) result_reserve_pool.get("msg") \ @@ -1855,7 +1917,8 @@ def update_reserve_pool(self, config): # Check update is required if not self.requires_update(self.have.get("reservePool").get("details"), self.want.get("wantReserve"), self.reserve_pool_obj_params): - self.log("Reserved ip subpool '{0}' doesn't require an update".format(name), "INFO") + self.log( + "Reserved ip subpool '{0}' doesn't require an update".format(name), "INFO") result_reserve_pool.get("response").get(name) \ .update({"Cisco DNA Center params": self.have.get("reservePool").get("details")}) result_reserve_pool.get("response").get(name) \ @@ -1864,7 +1927,8 @@ def update_reserve_pool(self, config): .update({name: "Reserve ip subpool doesn't require an update"}) return - self.log("Reserved ip pool '{0}' requires an update".format(name), "DEBUG") + self.log( + "Reserved ip pool '{0}' requires an update".format(name), "DEBUG") # Pool Exists self.log("Current reserved ip pool '{0}' details in Catalyst Center: {1}" .format(name, self.have.get("reservePool")), "DEBUG") @@ -1878,7 +1942,8 @@ def update_reserve_pool(self, config): params=reserve_params, ) self.check_execution_response_status(response).check_return_status() - self.log("Reserved ip subpool '{0}' updated successfully.".format(name), "INFO") + self.log( + "Reserved ip subpool '{0}' updated successfully.".format(name), "INFO") result_reserve_pool['msg'] = "Reserved Ip Subpool Updated Successfully" result_reserve_pool.get("response").get(name) \ .update({"Reservation details": self.have.get("reservePool").get("details")}) @@ -1904,18 +1969,22 @@ def update_network(self, config): if not self.requires_update(self.have.get("network").get("net_details"), self.want.get("wantNetwork"), self.network_obj_params): - self.log("Network in site '{0}' doesn't require an update.".format(site_name), "INFO") + self.log("Network in site '{0}' doesn't require an update.".format( + site_name), "INFO") result_network.get("response").get(site_name).update({ "Cisco DNA Center params": self.have.get("network") .get("net_details").get("settings") }) - result_network.get("msg").update({site_name: "Network doesn't require an update"}) + result_network.get("msg").update( + {site_name: "Network doesn't require an update"}) return - self.log("Network in site '{0}' requires update.".format(site_name), "INFO") + self.log("Network in site '{0}' requires update.".format( + site_name), "INFO") self.log("Current State of network in Catalyst Center: {0}" .format(self.have.get("network")), "DEBUG") - self.log("Desired State of network: {0}".format(self.want.get("wantNetwork")), "DEBUG") + self.log("Desired State of network: {0}".format( + self.want.get("wantNetwork")), "DEBUG") net_params = copy.deepcopy(self.want.get("wantNetwork")) net_params.update({"site_id": self.have.get("network").get("site_id")}) @@ -1925,9 +1994,11 @@ def update_network(self, config): op_modifies=True, params=net_params, ) - self.log("Received API response of 'update_network_v2': {0}".format(response), "DEBUG") + self.log("Received API response of 'update_network_v2': {0}".format( + response), "DEBUG") validation_string = "desired common settings operation successful" - self.check_task_response_status(response, validation_string).check_return_status() + self.check_task_response_status( + response, validation_string).check_return_status() self.log("Network has been changed successfully", "INFO") result_network.get("msg") \ .update({site_name: "Network Updated successfully"}) @@ -1974,7 +2045,8 @@ def delete_reserve_pool(self, name): result_reserve_pool = self.result.get("response")[1].get("reservePool") if not reserve_pool_exists: - result_reserve_pool.get("response").update({name: "Reserve Pool not found"}) + result_reserve_pool.get("response").update( + {name: "Reserve Pool not found"}) self.msg = "Reserved Ip Subpool Not Found" self.status = "success" return self @@ -2015,7 +2087,8 @@ def delete_global_pool(self, name): global_pool_exists = self.have.get("globalPool").get("exists") result_global_pool = self.result.get("response")[0].get("globalPool") if not global_pool_exists: - result_global_pool.get("response").update({name: "Global Pool not found"}) + result_global_pool.get("response").update( + {name: "Global Pool not found"}) self.msg = "Global pool Not Found" self.status = "success" return self @@ -2034,8 +2107,10 @@ def delete_global_pool(self, name): # Update result information result_global_pool = self.result.get("response")[0].get("globalPool") result_global_pool.get("response").update({name: {}}) - result_global_pool.get("response").get(name).update({"Execution Id": executionid}) - result_global_pool.get("msg").update({name: "Pool deleted successfully"}) + result_global_pool.get("response").get( + name).update({"Execution Id": executionid}) + result_global_pool.get("msg").update( + {name: "Pool deleted successfully"}) self.msg = "Global pool - {0} deleted successfully".format(name) self.status = "success" return self @@ -2091,7 +2166,8 @@ def verify_diff_merged(self, config): self.log("Successfully validated global pool '{0}'.".format(self.want .get("wantGlobal").get("settings").get("ippool")[0].get("ipPoolName")), "INFO") - self.result.get("response")[0].get("globalPool").update({"Validation": "Success"}) + self.result.get("response")[0].get( + "globalPool").update({"Validation": "Success"}) if config.get("reserve_pool_details") is not None: if self.requires_update(self.have.get("reservePool").get("details"), @@ -2106,7 +2182,8 @@ def verify_diff_merged(self, config): self.log("Successfully validated the reserved pool '{0}'." .format(self.want.get("wantReserve").get("name")), "INFO") - self.result.get("response")[1].get("reservePool").update({"Validation": "Success"}) + self.result.get("response")[1].get( + "reservePool").update({"Validation": "Success"}) if config.get("network_management_details") is not None: if self.requires_update(self.have.get("network").get("net_details"), @@ -2117,7 +2194,8 @@ def verify_diff_merged(self, config): self.log("Successfully validated the network functions '{0}'." .format(config.get("network_management_details").get("site_name")), "INFO") - self.result.get("response")[2].get("network").update({"Validation": "Success"}) + self.result.get("response")[2].get( + "network").update({"Validation": "Success"}) self.msg = "Successfully validated the Global Pool, Reserve Pool \ and the Network Functions." @@ -2150,7 +2228,8 @@ def verify_diff_deleted(self, config): self.log("Successfully validated absence of Global Pool '{0}'." .format(config.get("global_pool_details") .get("settings").get("ip_pool")[0].get("name")), "INFO") - self.result.get("response")[0].get("globalPool").update({"Validation": "Success"}) + self.result.get("response")[0].get( + "globalPool").update({"Validation": "Success"}) if config.get("reserve_pool_details") is not None: reserve_pool_exists = self.have.get("reservePool").get("exists") @@ -2161,7 +2240,8 @@ def verify_diff_deleted(self, config): self.log("Successfully validated the absence of Reserve Pool '{0}'." .format(config.get("reserve_pool_details").get("name")), "INFO") - self.result.get("response")[1].get("reservePool").update({"Validation": "Success"}) + self.result.get("response")[1].get( + "reservePool").update({"Validation": "Success"}) self.msg = "Successfully validated the absence of Global Pool/Reserve Pool" self.status = "success" @@ -2208,7 +2288,8 @@ def main(): } # Create an AnsibleModule object with argument specifications - module = AnsibleModule(argument_spec=element_spec, supports_check_mode=False) + module = AnsibleModule(argument_spec=element_spec, + supports_check_mode=False) dnac_network = NetworkSettings(module) state = dnac_network.params.get("state") config_verify = dnac_network.params.get("config_verify") @@ -2226,7 +2307,8 @@ def main(): dnac_network.get_want(config).check_return_status() dnac_network.get_diff_state_apply[state](config).check_return_status() if config_verify: - dnac_network.verify_diff_state_apply[state](config).check_return_status() + dnac_network.verify_diff_state_apply[state]( + config).check_return_status() module.exit_json(**dnac_network.result) diff --git a/plugins/modules/network_settings_workflow_manager.py b/plugins/modules/network_settings_workflow_manager.py index b4bb355bbd..0b989d69fc 100644 --- a/plugins/modules/network_settings_workflow_manager.py +++ b/plugins/modules/network_settings_workflow_manager.py @@ -5,6 +5,16 @@ """Ansible module to perform operations on global pool, reserve pool and network in Cisco Catalyst Center.""" from __future__ import absolute_import, division, print_function +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + get_dict_result, + dnac_compare_equality, +) +from ansible.module_utils.basic import AnsibleModule +import time +import re +import copy __metaclass__ = type __author__ = ['Muthu Rakesh, Madhan Sankaranarayanan, Megha Kandari'] @@ -668,17 +678,6 @@ } """ -import copy -import re -import time -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - get_dict_result, - dnac_compare_equality, -) - class NetworkSettings(DnacBase): """Class containing member attributes for network_settings_workflow_manager module""" @@ -823,34 +822,41 @@ def validate_input(self): invalid_params_type = [] for config_item in self.config: - ip_pool = config_item.get("global_pool_details", {}).get("settings", {}).get("ip_pool", []) + ip_pool = config_item.get("global_pool_details", {}).get( + "settings", {}).get("ip_pool", []) for pool in ip_pool: # Check for 'dhcp_server_ips' dhcp_server_ips = pool.get("dhcp_server_ips") if dhcp_server_ips is not None and not isinstance(dhcp_server_ips, list): - invalid_params_type.append("'dhcp_server_ips' should be a list.") + invalid_params_type.append( + "'dhcp_server_ips' should be a list.") # Check for 'dns_server_ips' dns_server_ips = pool.get("dns_server_ips") if dns_server_ips is not None and not isinstance(dns_server_ips, list): - invalid_params_type.append("'dns_server_ips' should be a list.") + invalid_params_type.append( + "'dns_server_ips' should be a list.") if invalid_params_type: - self.msg = "Invalid required parameter(s): {0}".format(', '.join(invalid_params_type)) + self.msg = "Invalid required parameter(s): {0}".format( + ', '.join(invalid_params_type)) self.result['response'] = self.msg self.status = "failed" return self # Validate playbook params against the specification (temp_spec) - valid_temp, invalid_params = validate_list_of_dicts(self.config, temp_spec) + valid_temp, invalid_params = validate_list_of_dicts( + self.config, temp_spec) if invalid_params: - self.msg = "Invalid parameters in playbook: {0}".format("\n".join(invalid_params)) + self.msg = "Invalid parameters in playbook: {0}".format( + "\n".join(invalid_params)) self.status = "failed" return self self.validated_config = valid_temp - self.log("Successfully validated playbook config params: {0}".format(valid_temp), "INFO") + self.log("Successfully validated playbook config params: {0}".format( + valid_temp), "INFO") self.msg = "Successfully validated input from the playbook" self.status = "success" return self @@ -959,14 +965,16 @@ def get_global_pool_params(self, pool_info): "ipPoolName": pool_info.get("ipPoolName"), "type": pool_info.get("ipPoolType").capitalize() } - self.log("Formated global pool details: {0}".format(global_pool), "DEBUG") + self.log("Formated global pool details: {0}".format( + global_pool), "DEBUG") # global_ippool = global_pool.get("settings").get("ippool")[0] if pool_info.get("ipv6") is False: global_pool.update({"IpAddressSpace": "IPv4"}) else: global_pool.update({"IpAddressSpace": "IPv6"}) - self.log("ip_address_space: {0}".format(global_pool.get("IpAddressSpace")), "DEBUG") + self.log("ip_address_space: {0}".format( + global_pool.get("IpAddressSpace")), "DEBUG") if not pool_info["gateways"]: global_pool.update({"gateway": ""}) else: @@ -1003,7 +1011,8 @@ def get_reserve_pool_params(self, pool_info): "ipv6AddressSpace": "False" }) if pool_info_ippools[0].get("gateways") != []: - reserve_pool.update({"ipv4GateWay": pool_info_ippools[0].get("gateways")[0]}) + reserve_pool.update( + {"ipv4GateWay": pool_info_ippools[0].get("gateways")[0]}) else: reserve_pool.update({"ipv4GateWay": ""}) reserve_pool.update({"ipv6AddressSpace": "False"}) @@ -1040,13 +1049,15 @@ def get_reserve_pool_params(self, pool_info): reserve_pool.update({"ipv6GateWay": ""}) ippools_info = pool_info_ippools[ipv6_index].get("context") - slaac_support_info = get_dict_result(ippools_info, "contextKey", "slaacSupport") + slaac_support_info = get_dict_result( + ippools_info, "contextKey", "slaacSupport") if slaac_support_info is None or slaac_support_info.get("contextValue") == "false": reserve_pool.update({"slaacSupport": False}) else: reserve_pool.update({"slaacSupport": True}) - self.log("Formatted reserve pool details: {0}".format(reserve_pool), "DEBUG") + self.log("Formatted reserve pool details: {0}".format( + reserve_pool), "DEBUG") return reserve_pool def get_dhcp_settings_for_site(self, site_name, site_id): @@ -1061,7 +1072,8 @@ def get_dhcp_settings_for_site(self, site_name, site_id): Returns: dhcp_details (dict) - DHCP settings details for the specified site. """ - self.log("Attempting to retrieve DHCP settings for site '{0}' (ID: {1})".format(site_name, site_id), "INFO") + self.log("Attempting to retrieve DHCP settings for site '{0}' (ID: {1})".format( + site_name, site_id), "INFO") try: dhcp_response = self.dnac._exec( @@ -1074,13 +1086,16 @@ def get_dhcp_settings_for_site(self, site_name, site_id): dhcp_details = dhcp_response.get("response", {}).get("dhcp") if not dhcp_response: - self.log("No DHCP settings found for site '{0}' (ID: {1})".format(site_name, site_id), "WARNING") + self.log("No DHCP settings found for site '{0}' (ID: {1})".format( + site_name, site_id), "WARNING") return None - self.log("Successfully retrieved DNS settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, dhcp_response), "DEBUG") + self.log("Successfully retrieved DNS settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, dhcp_response), "DEBUG") except Exception as e: self.msg = ( - "Exception occurred while getting DHCP settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, str(e)) + "Exception occurred while getting DHCP settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, str(e)) ) self.log(self.msg, "CRITICAL") self.status = "failed" @@ -1100,7 +1115,8 @@ def get_dns_settings_for_site(self, site_name, site_id): Returns: dns_details (dict): DNS settings details for the specified site. """ - self.log("Attempting to retrieve DNS settings for site '{0}' (ID: {1})".format(site_name, site_id), "INFO") + self.log("Attempting to retrieve DNS settings for site '{0}' (ID: {1})".format( + site_name, site_id), "INFO") try: dns_response = self.dnac._exec( @@ -1113,13 +1129,16 @@ def get_dns_settings_for_site(self, site_name, site_id): dns_details = dns_response.get("response", {}).get("dns") if not dns_details: - self.log("No DNS settings found for site '{0}' (ID: {1})".format(site_name, site_id), "WARNING") + self.log("No DNS settings found for site '{0}' (ID: {1})".format( + site_name, site_id), "WARNING") return None - self.log("Successfully retrieved DNS settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, dns_details), "DEBUG") + self.log("Successfully retrieved DNS settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, dns_details), "DEBUG") except Exception as e: self.msg = ( - "Exception occurred while getting DNS settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, str(e)) + "Exception occurred while getting DNS settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, str(e)) ) self.log(self.msg, "CRITICAL") self.status = "failed" @@ -1139,7 +1158,8 @@ def get_telemetry_settings_for_site(self, site_name, site_id): Returns: telemetry_details (dict): Telemetry settings details for the specified site. """ - self.log("Attempting to retrieve telemetry settings for site ID: {0}".format(site_id), "INFO") + self.log("Attempting to retrieve telemetry settings for site ID: {0}".format( + site_id), "INFO") try: telemetry_response = self.dnac._exec( @@ -1152,13 +1172,16 @@ def get_telemetry_settings_for_site(self, site_name, site_id): telemetry_details = telemetry_response.get("response", {}) if not telemetry_details: - self.log("No telemetry settings found for site '{0}' (ID: {1})".format(site_name, site_id), "WARNING") + self.log("No telemetry settings found for site '{0}' (ID: {1})".format( + site_name, site_id), "WARNING") return None - self.log("Successfully retrieved telemetry settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, telemetry_details), "DEBUG") + self.log("Successfully retrieved telemetry settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, telemetry_details), "DEBUG") except Exception as e: self.msg = ( - "Exception occurred while getting telemetry settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, str(e)) + "Exception occurred while getting telemetry settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, str(e)) ) self.log(self.msg, "CRITICAL") self.status = "failed" @@ -1178,7 +1201,8 @@ def get_ntp_settings_for_site(self, site_name, site_id): Returns: ntpserver_details (dict): NTP server settings details for the specified site. """ - self.log("Attempting to retrieve NTP server settings for site '{0}' (ID: {1})".format(site_name, site_id), "INFO") + self.log("Attempting to retrieve NTP server settings for site '{0}' (ID: {1})".format( + site_name, site_id), "INFO") try: ntpserver_response = self.dnac._exec( @@ -1188,16 +1212,20 @@ def get_ntp_settings_for_site(self, site_name, site_id): params={"id": site_id} ) # Extract NTP server details - ntpserver_details = ntpserver_response.get("response", {}).get("ntp") + ntpserver_details = ntpserver_response.get( + "response", {}).get("ntp") if not ntpserver_details: - self.log("No NTP server settings found for site '{0}' (ID: {1})".format(site_name, site_id), "WARNING") + self.log("No NTP server settings found for site '{0}' (ID: {1})".format( + site_name, site_id), "WARNING") return None - self.log("Successfully retrieved NTP server settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, ntpserver_details), "DEBUG") + self.log("Successfully retrieved NTP server settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, ntpserver_details), "DEBUG") except Exception as e: self.msg = ( - "Exception occurred while getting NTP server settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, str(e)) + "Exception occurred while getting NTP server settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, str(e)) ) self.log(self.msg, "CRITICAL") self.status = "failed" @@ -1217,7 +1245,8 @@ def get_time_zone_settings_for_site(self, site_name, site_id): Returns: timezone_details (dict): Time zone settings details for the specified site. """ - self.log("Attempting to retrieve time zone settings for site '{0}' (ID: {1})".format(site_name, site_id), "INFO") + self.log("Attempting to retrieve time zone settings for site '{0}' (ID: {1})".format( + site_name, site_id), "INFO") try: timezone_response = self.dnac._exec( @@ -1227,16 +1256,20 @@ def get_time_zone_settings_for_site(self, site_name, site_id): params={"id": site_id} ) # Extract time zone details - timezone_details = timezone_response.get("response", {}).get("timeZone") + timezone_details = timezone_response.get( + "response", {}).get("timeZone") if not timezone_details: - self.log("No time zone settings found for site '{0}' (ID: {1})".format(site_name, site_id), "WARNING") + self.log("No time zone settings found for site '{0}' (ID: {1})".format( + site_name, site_id), "WARNING") return None - self.log("Successfully retrieved time zone settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, timezone_details), "DEBUG") + self.log("Successfully retrieved time zone settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, timezone_details), "DEBUG") except Exception as e: self.msg = ( - "Exception occurred while getting time zone settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, str(e)) + "Exception occurred while getting time zone settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, str(e)) ) self.log(self.msg, "CRITICAL") self.status = "failed" @@ -1256,7 +1289,8 @@ def get_banner_settings_for_site(self, site_name, site_id): Returns: messageoftheday_details (dict): Banner (Message of the Day) settings details for the specified site. """ - self.log("Attempting to retrieve banner (Message of the Day) settings for site '{0}' (ID: {1})".format(site_name, site_id), "INFO") + self.log("Attempting to retrieve banner (Message of the Day) settings for site '{0}' (ID: {1})".format( + site_name, site_id), "INFO") try: banner_response = self.dnac._exec( @@ -1266,17 +1300,20 @@ def get_banner_settings_for_site(self, site_name, site_id): params={"id": site_id} ) # Extract banner (Message of the Day) details - messageoftheday_details = banner_response.get("response", {}).get("banner") + messageoftheday_details = banner_response.get( + "response", {}).get("banner") if not messageoftheday_details: - self.log("No banner (Message of the Day) settings found for site '{0}' (ID: {1})".format(site_name, site_id), "WARNING") + self.log("No banner (Message of the Day) settings found for site '{0}' (ID: {1})".format( + site_name, site_id), "WARNING") return None self.log("Successfully retrieved banner (Message of the Day) settings for site '{0}' (ID: {1}): {2}" .format(site_name, site_id, messageoftheday_details), "DEBUG") except Exception as e: self.msg = ( - "Exception occurred while getting banner settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, str(e)) + "Exception occurred while getting banner settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, str(e)) ) self.log(self.msg, "CRITICAL") self.status = "failed" @@ -1297,7 +1334,8 @@ def get_aaa_settings_for_site(self, site_name, site_id): network_aaa (dict): AAA network settings details for the specified site. client_and_endpoint_aaa (dict): AAA client and endpoint settings details for the specified site. """ - self.log("Attempting to retrieve AAA settings for site '{0}' (ID: {1})".format(site_name, site_id), "INFO") + self.log("Attempting to retrieve AAA settings for site '{0}' (ID: {1})".format( + site_name, site_id), "INFO") try: aaa_network_response = self.dnac._exec( @@ -1307,19 +1345,24 @@ def get_aaa_settings_for_site(self, site_name, site_id): params={"id": site_id} ) # Extract AAA network and client/endpoint settings - network_aaa = aaa_network_response.get("response", {}).get("aaaNetwork") - client_and_endpoint_aaa = aaa_network_response.get("response", {}).get("aaaClient") + network_aaa = aaa_network_response.get( + "response", {}).get("aaaNetwork") + client_and_endpoint_aaa = aaa_network_response.get( + "response", {}).get("aaaClient") if not network_aaa or not client_and_endpoint_aaa: - self.log("No AAA settings found for site '{0}' (ID: {1})".format(site_name, site_id), "WARNING") + self.log("No AAA settings found for site '{0}' (ID: {1})".format( + site_name, site_id), "WARNING") return None, None - self.log("Successfully retrieved AAA Network settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, network_aaa), "DEBUG") + self.log("Successfully retrieved AAA Network settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, network_aaa), "DEBUG") self.log("Successfully retrieved AAA Client and Endpoint settings for site '{0}' (ID: {1}): {2}" .format(site_name, site_id, client_and_endpoint_aaa), "DEBUG") except Exception as e: self.msg = ( - "Exception occurred while getting AAA settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, str(e)) + "Exception occurred while getting AAA settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, str(e)) ) self.log(self.msg, "CRITICAL") self.status = "failed" @@ -1354,7 +1397,8 @@ def get_network_params_v1(self, site_name, site_id): Returns: network_details: Processed Network data in a format suitable for configuration, or None on error. """ - self.log("Attempting to retrieve network configuration details for site '{0}' (ID: {1})".format(site_name, site_id), "INFO") + self.log("Attempting to retrieve network configuration details for site '{0}' (ID: {1})".format( + site_name, site_id), "INFO") try: response = self.dnac._exec( @@ -1372,7 +1416,8 @@ def get_network_params_v1(self, site_name, site_id): self.status = "failed" return self - self.log("Received API response from 'get_network_v2' for site '{0}' (ID: {1}): {2}".format(site_name, site_id, response,), "DEBUG") + self.log("Received API response from 'get_network_v2' for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, response,), "DEBUG") if not isinstance(response, dict): self.log("Failed to retrieve the network details - " "Response is not a dictionary", "ERROR") @@ -1380,20 +1425,33 @@ def get_network_params_v1(self, site_name, site_id): # Extract various network-related details from the response all_network_details = response.get("response") - dhcp_details = get_dict_result(all_network_details, "key", "dhcp.server") + dhcp_details = get_dict_result( + all_network_details, "key", "dhcp.server") dns_details = get_dict_result(all_network_details, "key", "dns.server") - snmp_details = get_dict_result(all_network_details, "key", "snmp.trap.receiver") - syslog_details = get_dict_result(all_network_details, "key", "syslog.server") - netflow_details = get_dict_result(all_network_details, "key", "netflow.collector") - ntpserver_details = get_dict_result(all_network_details, "key", "ntp.server") - timezone_details = get_dict_result(all_network_details, "key", "timezone.site") - messageoftheday_details = get_dict_result(all_network_details, "key", "device.banner") - network_aaa = get_dict_result(all_network_details, "key", "aaa.network.server.1") - network_aaa2 = get_dict_result(all_network_details, "key", "aaa.network.server.2") - network_aaa_pan = get_dict_result(all_network_details, "key", "aaa.server.pan.network") - client_and_endpoint_aaa = get_dict_result(all_network_details, "key", "aaa.endpoint.server.1") - client_and_endpoint_aaa2 = get_dict_result(all_network_details, "key", "aaa.endpoint.server.2") - client_and_endpoint_aaa_pan = get_dict_result(all_network_details, "key", "aaa.server.pan.endpoint") + snmp_details = get_dict_result( + all_network_details, "key", "snmp.trap.receiver") + syslog_details = get_dict_result( + all_network_details, "key", "syslog.server") + netflow_details = get_dict_result( + all_network_details, "key", "netflow.collector") + ntpserver_details = get_dict_result( + all_network_details, "key", "ntp.server") + timezone_details = get_dict_result( + all_network_details, "key", "timezone.site") + messageoftheday_details = get_dict_result( + all_network_details, "key", "device.banner") + network_aaa = get_dict_result( + all_network_details, "key", "aaa.network.server.1") + network_aaa2 = get_dict_result( + all_network_details, "key", "aaa.network.server.2") + network_aaa_pan = get_dict_result( + all_network_details, "key", "aaa.server.pan.network") + client_and_endpoint_aaa = get_dict_result( + all_network_details, "key", "aaa.endpoint.server.1") + client_and_endpoint_aaa2 = get_dict_result( + all_network_details, "key", "aaa.endpoint.server.2") + client_and_endpoint_aaa_pan = get_dict_result( + all_network_details, "key", "aaa.server.pan.endpoint") # Prepare the network details for Cisco Catalyst Center configuration network_details = { @@ -1433,7 +1491,8 @@ def get_network_params_v1(self, site_name, site_id): }) if ntpserver_details and ntpserver_details.get("value") != []: - network_settings.update({"ntpServer": ntpserver_details.get("value")}) + network_settings.update( + {"ntpServer": ntpserver_details.get("value")}) else: network_settings.update({"ntpServer": [""]}) @@ -1495,7 +1554,8 @@ def get_network_params_v1(self, site_name, site_id): }) # Handle the second AAA server network_aaa2 if network_aaa2 and network_aaa2.get("value"): - network_settings["network_aaa"].update({"ipAddress": network_aaa2.get("value")[0].get("ipAddress", "")}) + network_settings["network_aaa"].update( + {"ipAddress": network_aaa2.get("value")[0].get("ipAddress", "")}) else: network_settings["network_aaa"].update({"ipAddress": ""}) else: @@ -1538,9 +1598,11 @@ def get_network_params_v1(self, site_name, site_id): }) # Handle the second client AAA server client_and_endpoint_aaa2 if client_and_endpoint_aaa2 and client_and_endpoint_aaa2.get("value"): - network_settings["client_and_endpoint_aaa"].update({"ipAddress": client_and_endpoint_aaa2.get("value")[0].get("ipAddress", "")}) + network_settings["client_and_endpoint_aaa"].update( + {"ipAddress": client_and_endpoint_aaa2.get("value")[0].get("ipAddress", "")}) else: - network_settings["client_and_endpoint_aaa"].update({"ipAddress": ""}) + network_settings["client_and_endpoint_aaa"].update( + {"ipAddress": ""}) else: network_settings.update({ "client_and_endpoint_aaa": { @@ -1568,7 +1630,8 @@ def get_network_params_v1(self, site_name, site_id): if not network_settings_syslog.get("ipAddresses"): network_settings_syslog.update({"ipAddresses": []}) - self.log("Formatted playbook network details: {0}".format(network_details), "DEBUG") + self.log("Formatted playbook network details: {0}".format( + network_details), "DEBUG") return network_details def get_network_params_v2(self, site_name, site_id): @@ -1585,16 +1648,20 @@ def get_network_params_v2(self, site_name, site_id): dhcp_details = self.get_dhcp_settings_for_site(site_name, site_id) dns_details = self.get_dns_settings_for_site(site_name, site_id) - telemetry_details = self.get_telemetry_settings_for_site(site_name, site_id) + telemetry_details = self.get_telemetry_settings_for_site( + site_name, site_id) wired_data_collection = telemetry_details.get("wiredDataCollection") wireless_telemetry = telemetry_details.get("wirelessTelemetry") netflow_details = telemetry_details.get("applicationVisibility") snmp_details = telemetry_details.get("snmpTraps") syslog_details = telemetry_details.get("syslogs") ntpserver_details = self.get_ntp_settings_for_site(site_name, site_id) - timezone_details = self.get_time_zone_settings_for_site(site_name, site_id) - messageoftheday_details = self.get_banner_settings_for_site(site_name, site_id) - network_aaa, client_and_endpoint_aaa = self.get_aaa_settings_for_site(site_name, site_id) + timezone_details = self.get_time_zone_settings_for_site( + site_name, site_id) + messageoftheday_details = self.get_banner_settings_for_site( + site_name, site_id) + network_aaa, client_and_endpoint_aaa = self.get_aaa_settings_for_site( + site_name, site_id) # Prepare the network details for Cisco Catalyst Center configuration if not network_aaa: @@ -1614,7 +1681,7 @@ def get_network_params_v2(self, site_name, site_id): network_details = { "settings": { - "network_aaa" : network_aaa, + "network_aaa": network_aaa, "client_and_endpoint_aaa": client_and_endpoint_aaa, "wired_data_collection": wired_data_collection, "wireless_telemetry": wireless_telemetry @@ -1647,7 +1714,8 @@ def get_network_params_v2(self, site_name, site_id): if 'dnsServer' not in network_settings: network_settings['dnsServer'] = {} if domain_name: - network_settings.get("dnsServer").update({"domainName": dns_details.get("domainName")}) + network_settings.get("dnsServer").update( + {"domainName": dns_details.get("domainName")}) dns_servers = dns_details.get("dnsServers", []) if len(dns_servers) > 0: network_settings.get("dnsServer").update({ @@ -1677,7 +1745,8 @@ def get_network_params_v2(self, site_name, site_id): enable_on_wired_access_devices = netflow_details \ .get("enableOnWiredAccessDevices") - collector_type = netflow_details.get("collector").get("collectorType") + collector_type = netflow_details.get( + "collector").get("collectorType") if collector_type == "TelemetryBrokerOrUDPDirector": network_settings.update({ @@ -1701,11 +1770,13 @@ def get_network_params_v2(self, site_name, site_id): netflow_details = {} if messageoftheday_details is not None: - network_settings.update({"messageOfTheday": messageoftheday_details}) + network_settings.update( + {"messageOfTheday": messageoftheday_details}) else: network_settings.update({"messageOfTheday": ""}) - self.log("Formatted playbook network details: {0}".format(network_details), "DEBUG") + self.log("Formatted playbook network details: {0}".format( + network_details), "DEBUG") return network_details @@ -1755,7 +1826,8 @@ def get_reserved_ip_subpool(self, site_id): .format(site_id), "DEBUG") return self - self.all_reserved_pool_details.get(site_id).extend(reserve_pool_details) + self.all_reserved_pool_details.get( + site_id).extend(reserve_pool_details) value += 25 end_time = time.time() if (end_time - start_time) >= self.max_timeout: @@ -1812,20 +1884,25 @@ def global_pool_exists(self, name): all_global_pool_details = response.get("response") if not all_global_pool_details: - self.log("Global pool '{0}' does not exist".format(name), "INFO") + self.log( + "Global pool '{0}' does not exist".format(name), "INFO") return global_pool - global_pool_details = get_dict_result(all_global_pool_details, "ipPoolName", name) + global_pool_details = get_dict_result( + all_global_pool_details, "ipPoolName", name) if global_pool_details: - self.log("Global pool found with name '{0}': {1}".format(name, global_pool_details), "INFO") + self.log("Global pool found with name '{0}': {1}".format( + name, global_pool_details), "INFO") global_pool.update({"exists": True}) global_pool.update({"id": global_pool_details.get("id")}) - global_pool["details"] = self.get_global_pool_params(global_pool_details) + global_pool["details"] = self.get_global_pool_params( + global_pool_details) break value += 25 - self.log("Formatted global pool details: {0}".format(global_pool), "DEBUG") + self.log("Formatted global pool details: {0}".format( + global_pool), "DEBUG") return global_pool def reserve_pool_exists(self, name, site_name): @@ -1851,10 +1928,12 @@ def reserve_pool_exists(self, name, site_name): "success": True } site_exist, site_id = self.get_site_id(site_name) - self.log("Site ID for the site name {0}: {1}".format(site_name, site_id), "DEBUG") + self.log("Site ID for the site name {0}: {1}".format( + site_name, site_id), "DEBUG") if not site_id: reserve_pool.update({"success": False}) - self.msg = "Failed to get the site id from the site name {0}".format(site_name) + self.msg = "Failed to get the site id from the site name {0}".format( + site_name) self.status = "failed" return reserve_pool @@ -1866,16 +1945,20 @@ def reserve_pool_exists(self, name, site_name): .format(name, site_name), "DEBUG") return reserve_pool - reserve_pool_details = get_dict_result(self.all_reserved_pool_details.get(site_id), "groupName", name) + reserve_pool_details = get_dict_result( + self.all_reserved_pool_details.get(site_id), "groupName", name) if reserve_pool_details: self.log("Reserve pool found with name '{0}' in the site '{1}': {2}" .format(name, site_name, reserve_pool_details), "INFO") reserve_pool.update({"exists": True}) reserve_pool.update({"id": reserve_pool_details.get("id")}) - reserve_pool.update({"details": self.get_reserve_pool_params(reserve_pool_details)}) + reserve_pool.update( + {"details": self.get_reserve_pool_params(reserve_pool_details)}) - self.log("Reserved pool details: {0}".format(reserve_pool.get("details")), "DEBUG") - self.log("Reserved pool id: {0}".format(reserve_pool.get("id")), "DEBUG") + self.log("Reserved pool details: {0}".format( + reserve_pool.get("details")), "DEBUG") + self.log("Reserved pool id: {0}".format( + reserve_pool.get("id")), "DEBUG") return reserve_pool def get_have_global_pool(self, global_pool_details): @@ -1914,7 +1997,8 @@ def get_have_global_pool(self, global_pool_details): name_length = len(name) if name_length > 100: - self.msg = "The length of the '{0}' in global_pool_details should be less or equal to 100. Invalid_config: {1}".format(name, pool_details) + self.msg = "The length of the '{0}' in global_pool_details should be less or equal to 100. Invalid_config: {1}".format( + name, pool_details) self.status = "failed" return self @@ -1932,14 +2016,16 @@ def get_have_global_pool(self, global_pool_details): # If the Global Pool doesn't exist and a previous name is provided # Else try using the previous name global_pool.append(self.global_pool_exists(name)) - self.log("Global pool details of '{0}': {1}".format(name, global_pool[global_pool_index]), "DEBUG") + self.log("Global pool details of '{0}': {1}".format( + name, global_pool[global_pool_index]), "DEBUG") prev_name = pool_details.get("prev_name") if global_pool[global_pool_index].get("exists") is False and \ prev_name is not None: global_pool.pop() global_pool.append(self.global_pool_exists(prev_name)) if global_pool[global_pool_index].get("exists") is False: - self.msg = "Prev name {0} doesn't exist in global_pool_details".format(prev_name) + self.msg = "Prev name {0} doesn't exist in global_pool_details".format( + prev_name) self.status = "failed" return self @@ -2003,7 +2089,8 @@ def get_have_reserve_pool(self, reserve_pool_details): reserve_pool.append(self.reserve_pool_exists(name, site_name)) if not reserve_pool[reserve_pool_index].get("success"): return self.check_return_status() - self.log("Reserved pool details for '{0}': {1}".format(name, reserve_pool[reserve_pool_index]), "DEBUG") + self.log("Reserved pool details for '{0}': {1}".format( + name, reserve_pool[reserve_pool_index]), "DEBUG") # If the Reserved Pool doesn't exist and a previous name is provided # Else try using the previous name @@ -2011,22 +2098,27 @@ def get_have_reserve_pool(self, reserve_pool_details): if reserve_pool[reserve_pool_index].get("exists") is False and \ prev_name is not None: reserve_pool.pop() - reserve_pool.append(self.reserve_pool_exists(prev_name, site_name)) + reserve_pool.append( + self.reserve_pool_exists(prev_name, site_name)) if not reserve_pool[reserve_pool_index].get("success"): return self.check_return_status() # If the previous name doesn't exist in Cisco Catalyst Center, return with error if reserve_pool[reserve_pool_index].get("exists") is False: - self.msg = "Prev name {0} doesn't exist in reserve_pool_details".format(prev_name) + self.msg = "Prev name {0} doesn't exist in reserve_pool_details".format( + prev_name) self.status = "failed" return self - self.log("Reserved pool exists: {0}".format(reserve_pool[reserve_pool_index].get("exists")), "DEBUG") - self.log("Reserved pool: {0}".format(reserve_pool[reserve_pool_index].get("details")), "DEBUG") + self.log("Reserved pool exists: {0}".format( + reserve_pool[reserve_pool_index].get("exists")), "DEBUG") + self.log("Reserved pool: {0}".format( + reserve_pool[reserve_pool_index].get("details")), "DEBUG") # If reserve pool exist, convert ipv6AddressSpace to the required format (boolean) if reserve_pool[reserve_pool_index].get("exists"): - reserve_pool_info = reserve_pool[reserve_pool_index].get("details") + reserve_pool_info = reserve_pool[reserve_pool_index].get( + "details") if reserve_pool_info.get("ipv6AddressSpace") == "False": reserve_pool_info.update({"ipv6AddressSpace": False}) else: @@ -2061,14 +2153,17 @@ def get_have_network(self, network_details): site_exist, site_id = self.get_site_id(site_name) if site_id is None: - self.msg = "The site with the name '{0}' is not available in the Catalyst Center".format(site_name) + self.msg = "The site with the name '{0}' is not available in the Catalyst Center".format( + site_name) self.status = "failed" return self network["site_name"] = site_name network["site_id"] = site_id - network["net_details"] = self.get_network_params(site_name, site_id) - self.log("Network details from the Catalyst Center for site '{0}': {1}".format(site_name, network), "DEBUG") + network["net_details"] = self.get_network_params( + site_name, site_id) + self.log("Network details from the Catalyst Center for site '{0}': {1}".format( + site_name, network), "DEBUG") all_network_management_details.append(network) self.have.update({"network": all_network_management_details}) @@ -2091,11 +2186,13 @@ def get_have(self, config): global_pool_details = config.get("global_pool_details") if global_pool_details is not None: - self.get_have_global_pool(global_pool_details).check_return_status() + self.get_have_global_pool( + global_pool_details).check_return_status() reserve_pool_details = config.get("reserve_pool_details") if reserve_pool_details is not None: - self.get_have_reserve_pool(reserve_pool_details).check_return_status() + self.get_have_reserve_pool( + reserve_pool_details).check_return_status() network_details = config.get("network_management_details") if network_details is not None: @@ -2152,18 +2249,23 @@ def get_global_pool_cidr(self, global_pool_cidr, global_pool_name): all_global_pool_details = response.get("response") if not all_global_pool_details: - self.log("Invalid global_pool_name '{0}' under reserve_pool_details".format(global_pool_name), "ERROR") - self.msg = "No information found for the global pool named '{0}'".format(global_pool_name) + self.log("Invalid global_pool_name '{0}' under reserve_pool_details".format( + global_pool_name), "ERROR") + self.msg = "No information found for the global pool named '{0}'".format( + global_pool_name) self.status = "failed" return self.check_return_status() - global_pool_details = get_dict_result(all_global_pool_details, "ipPoolName", global_pool_name) + global_pool_details = get_dict_result( + all_global_pool_details, "ipPoolName", global_pool_name) if global_pool_details: global_pool_cidr = global_pool_details.get("ipPoolCidr") - self.log("Global pool found with name '{0}': {1}".format(global_pool_name, global_pool_details), "INFO") + self.log("Global pool found with name '{0}': {1}".format( + global_pool_name, global_pool_details), "INFO") break - self.log("Global Pool '{0}' cidr: {1}".format(global_pool_name, global_pool_cidr), "INFO") + self.log("Global Pool '{0}' cidr: {1}".format( + global_pool_name, global_pool_cidr), "INFO") return global_pool_cidr def get_want_global_pool(self, global_ippool): @@ -2225,7 +2327,8 @@ def get_want_global_pool(self, global_ippool): if pool_values.get("type") is None: pool_values.update({"type": "Generic"}) else: - have_ippool = self.have.get("globalPool")[global_pool_index].get("details") + have_ippool = self.have.get("globalPool")[ + global_pool_index].get("details") # Copy existing Global Pool information if the desired configuration is not provided pool_values.update({ @@ -2240,7 +2343,8 @@ def get_want_global_pool(self, global_ippool): want_ippool.append(pool_values) global_pool_index += 1 - self.log("Global pool playbook details: {0}".format(want_global), "DEBUG") + self.log("Global pool playbook details: {0}".format( + want_global), "DEBUG") self.want.update({"wantGlobal": want_global}) self.msg = "Collecting the global pool details from the playbook" self.status = "success" @@ -2313,7 +2417,8 @@ def get_want_reserve_pool(self, reserve_pool): self.status = "failed" return self - self.log("Reserved IP pool playbook details: {0}".format(pool_values), "DEBUG") + self.log("Reserved IP pool playbook details: {0}".format( + pool_values), "DEBUG") # If there are no existing Reserved Pool details, validate and set defaults if not self.have.get("reservePool")[reserve_pool_index].get("details"): @@ -2423,7 +2528,8 @@ def get_want_network(self, network_management_details): else: del want_network_settings["ntpServer"] - have_timezone = self.have.get("network")[network_management_index].get("net_details").get("settings").get("timezone") + have_timezone = self.have.get("network")[network_management_index].get( + "net_details").get("settings").get("timezone") if item.get("timezone") is not None: want_network_settings["timezone"] = \ item.get("timezone") @@ -2497,7 +2603,8 @@ def get_want_network(self, network_management_details): message_of_the_day = item.get("message_of_the_day") if message_of_the_day is not None: - retain_existing_banner = message_of_the_day.get("retain_existing_banner") + retain_existing_banner = message_of_the_day.get( + "retain_existing_banner") if retain_existing_banner is not None: if retain_existing_banner is True: want_network_settings.get("messageOfTheday").update({ @@ -2530,11 +2637,13 @@ def get_want_network(self, network_management_details): return self if server_type not in server_types: - self.msg = "The 'server_type' in the network_aaa should be in {0}".format(server_types) + self.msg = "The 'server_type' in the network_aaa should be in {0}".format( + server_types) self.status = "failed" return self - primary_server_address = network_aaa.get("primary_server_address") + primary_server_address = network_aaa.get( + "primary_server_address") if primary_server_address: want_network_settings.get("network_aaa").update({ "network": primary_server_address @@ -2555,7 +2664,8 @@ def get_want_network(self, network_management_details): self.status = "failed" return self else: - secondary_server_address = network_aaa.get("secondary_server_address") + secondary_server_address = network_aaa.get( + "secondary_server_address") if secondary_server_address: want_network_settings.get("network_aaa").update({ "ipAddress": secondary_server_address @@ -2572,7 +2682,8 @@ def get_want_network(self, network_management_details): }) if protocol not in protocol_types: - self.msg = "The 'protocol' in the network_aaa should be in {0}".format(protocol_types) + self.msg = "The 'protocol' in the network_aaa should be in {0}".format( + protocol_types) self.status = "failed" return self @@ -2604,11 +2715,13 @@ def get_want_network(self, network_management_details): return self if server_type not in server_types: - self.msg = "The 'server_type' in the client_and_endpoint_aaa should be in {0}".format(server_types) + self.msg = "The 'server_type' in the client_and_endpoint_aaa should be in {0}".format( + server_types) self.status = "failed" return self - primary_server_address = client_and_endpoint_aaa.get("primary_server_address") + primary_server_address = client_and_endpoint_aaa.get( + "primary_server_address") if primary_server_address: want_network_settings.get("client_and_endpoint_aaa").update({ "network": primary_server_address @@ -2619,7 +2732,8 @@ def get_want_network(self, network_management_details): return self if server_type == "ISE": - pan_address = client_and_endpoint_aaa.get("pan_address") + pan_address = client_and_endpoint_aaa.get( + "pan_address") if pan_address: want_network_settings.get("client_and_endpoint_aaa").update({ "ipAddress": pan_address @@ -2629,7 +2743,8 @@ def get_want_network(self, network_management_details): self.status = "failed" return self else: - secondary_server_address = client_and_endpoint_aaa.get("secondary_server_address") + secondary_server_address = client_and_endpoint_aaa.get( + "secondary_server_address") if secondary_server_address: want_network_settings.get("client_and_endpoint_aaa").update({ "ipAddress": secondary_server_address @@ -2646,11 +2761,13 @@ def get_want_network(self, network_management_details): }) if protocol not in protocol_types: - self.msg = "The 'protocol' in the client_and_endpoint_aaa should be in {0}".format(protocol_types) + self.msg = "The 'protocol' in the client_and_endpoint_aaa should be in {0}".format( + protocol_types) self.status = "failed" return self - shared_secret = client_and_endpoint_aaa.get("shared_secret") + shared_secret = client_and_endpoint_aaa.get( + "shared_secret") if shared_secret is not None: if len(shared_secret) < 4: self.msg = ( @@ -2666,7 +2783,8 @@ def get_want_network(self, network_management_details): del want_network_settings["client_and_endpoint_aaa"] network_aaa = want_network_settings.get("network_aaa") - client_and_endpoint_aaa = want_network_settings.get("client_and_endpoint_aaa") + client_and_endpoint_aaa = want_network_settings.get( + "client_and_endpoint_aaa") if network_aaa and client_and_endpoint_aaa and \ network_aaa.get("sharedSecret") and \ client_and_endpoint_aaa.get("sharedSecret") and \ @@ -2749,7 +2867,8 @@ def get_want_network(self, network_management_details): netflow_collector = item.get("netflow_collector") if netflow_collector is not None: - netflowcollector = want_network_settings.get("netflowcollector") + netflowcollector = want_network_settings.get( + "netflowcollector") netflowcollector.update({"collector": {}}) if netflow_collector.get("collector_type") is not None and netflow_collector.get("collectorType") != "Builtin": want_network_settings.get("netflowcollector").get("collector").update({ @@ -2827,7 +2946,8 @@ def get_want_network(self, network_management_details): message_of_the_day = item.get("message_of_the_day") if message_of_the_day is not None: - retain_existing_banner = message_of_the_day.get("retain_existing_banner") + retain_existing_banner = message_of_the_day.get( + "retain_existing_banner") if retain_existing_banner is not None: if retain_existing_banner is True: want_network_settings.get("messageOfTheday").update({ @@ -2860,11 +2980,13 @@ def get_want_network(self, network_management_details): return self if server_type not in server_types: - self.msg = "The 'server_type' in the network_aaa should be in {0}".format(server_types) + self.msg = "The 'server_type' in the network_aaa should be in {0}".format( + server_types) self.status = "failed" return self - primary_server_address = network_aaa.get("primary_server_address") + primary_server_address = network_aaa.get( + "primary_server_address") if primary_server_address: want_network_settings.get("network_aaa").update({ "primaryServerIp": primary_server_address @@ -2885,7 +3007,8 @@ def get_want_network(self, network_management_details): self.status = "failed" return self else: - secondary_server_address = network_aaa.get("secondary_server_address") + secondary_server_address = network_aaa.get( + "secondary_server_address") if secondary_server_address: want_network_settings.get("network_aaa").update({ "secondaryServerIp": secondary_server_address @@ -2902,7 +3025,8 @@ def get_want_network(self, network_management_details): }) if protocol not in protocol_types: - self.msg = "The 'protocol' in the network_aaa should be in {0}".format(protocol_types) + self.msg = "The 'protocol' in the network_aaa should be in {0}".format( + protocol_types) self.status = "failed" return self @@ -2934,11 +3058,13 @@ def get_want_network(self, network_management_details): return self if server_type not in server_types: - self.msg = "The 'server_type' in the client_and_endpoint_aaa should be in {0}".format(server_types) + self.msg = "The 'server_type' in the client_and_endpoint_aaa should be in {0}".format( + server_types) self.status = "failed" return self - primary_server_address = client_and_endpoint_aaa.get("primary_server_address") + primary_server_address = client_and_endpoint_aaa.get( + "primary_server_address") if primary_server_address: want_network_settings.get("client_and_endpoint_aaa").update({ "primaryServerIp": primary_server_address @@ -2949,7 +3075,8 @@ def get_want_network(self, network_management_details): return self if server_type == "ISE": - pan_address = client_and_endpoint_aaa.get("pan_address") + pan_address = client_and_endpoint_aaa.get( + "pan_address") if pan_address: want_network_settings.get("client_and_endpoint_aaa").update({ "pan": pan_address @@ -2959,7 +3086,8 @@ def get_want_network(self, network_management_details): self.status = "failed" return self else: - secondary_server_address = client_and_endpoint_aaa.get("secondary_server_address") + secondary_server_address = client_and_endpoint_aaa.get( + "secondary_server_address") if secondary_server_address: want_network_settings.get("client_and_endpoint_aaa").update({ "secondaryServerIp": secondary_server_address @@ -2976,11 +3104,13 @@ def get_want_network(self, network_management_details): }) if protocol not in protocol_types: - self.msg = "The 'protocol' in the client_and_endpoint_aaa should be in {0}".format(protocol_types) + self.msg = "The 'protocol' in the client_and_endpoint_aaa should be in {0}".format( + protocol_types) self.status = "failed" return self - shared_secret = client_and_endpoint_aaa.get("shared_secret") + shared_secret = client_and_endpoint_aaa.get( + "shared_secret") if shared_secret is not None: if len(shared_secret) < 4: self.msg = ( @@ -2996,7 +3126,8 @@ def get_want_network(self, network_management_details): del want_network_settings["client_and_endpoint_aaa"] network_aaa = want_network_settings.get("network_aaa") - client_and_endpoint_aaa = want_network_settings.get("client_and_endpoint_aaa") + client_and_endpoint_aaa = want_network_settings.get( + "client_and_endpoint_aaa") if network_aaa and client_and_endpoint_aaa and \ network_aaa.get("sharedSecret") and \ client_and_endpoint_aaa.get("sharedSecret") and \ @@ -3008,7 +3139,8 @@ def get_want_network(self, network_management_details): all_network_management_details.append(want_network) network_management_index += 1 - self.log("Network playbook details: {0}".format(all_network_management_details), "DEBUG") + self.log("Network playbook details: {0}".format( + all_network_management_details), "DEBUG") self.want.update({"wantNetwork": all_network_management_details}) self.msg = "Collected the network details from the playbook" self.status = "success" @@ -3026,7 +3158,8 @@ def get_want(self, config): """ if config.get("global_pool_details"): - global_ippool = config.get("global_pool_details").get("settings").get("ip_pool") + global_ippool = config.get("global_pool_details").get( + "settings").get("ip_pool") self.get_want_global_pool(global_ippool).check_return_status() if config.get("reserve_pool_details"): @@ -3034,8 +3167,10 @@ def get_want(self, config): self.get_want_reserve_pool(reserve_pool).check_return_status() if config.get("network_management_details"): - network_management_details = config.get("network_management_details") - self.get_want_network(network_management_details).check_return_status() + network_management_details = config.get( + "network_management_details") + self.get_want_network( + network_management_details).check_return_status() self.log("Desired State (want): {0}".format(self.want), "INFO") self.msg = "Successfully retrieved details from the playbook" @@ -3057,8 +3192,10 @@ def update_global_pool(self, global_pool): update_global_pool = [] global_pool_index = 0 result_global_pool = self.result.get("response")[0].get("globalPool") - want_global_pool = self.want.get("wantGlobal").get("settings").get("ippool") - self.log("Global pool playbook details: {0}".format(global_pool), "DEBUG") + want_global_pool = self.want.get( + "wantGlobal").get("settings").get("ippool") + self.log("Global pool playbook details: {0}".format( + global_pool), "DEBUG") for item in self.have.get("globalPool"): result_global_pool.get("msg") \ .update({want_global_pool[global_pool_index].get("ipPoolName"): {}}) @@ -3071,7 +3208,8 @@ def update_global_pool(self, global_pool): # Check create_global_pool; if yes, create the global pool if create_global_pool: - self.log("Global pool(s) details to be created: {0}".format(create_global_pool), "INFO") + self.log("Global pool(s) details to be created: {0}".format( + create_global_pool), "INFO") pool_params = { "settings": { "ippool": copy.deepcopy(create_global_pool) @@ -3093,13 +3231,17 @@ def update_global_pool(self, global_pool): self.status = "failed" return self - self.check_execution_response_status(response, "create_global_pool").check_return_status() + self.check_execution_response_status( + response, "create_global_pool").check_return_status() self.log("Successfully created global pool successfully.", "INFO") for item in pool_params.get("settings").get("ippool"): name = item.get("ipPoolName") - self.log("Global pool '{0}' created successfully.".format(name), "INFO") - result_global_pool.get("response").update({"created": pool_params}) - result_global_pool.get("msg").update({name: "Global Pool Created Successfully"}) + self.log( + "Global pool '{0}' created successfully.".format(name), "INFO") + result_global_pool.get("response").update( + {"created": pool_params}) + result_global_pool.get("msg").update( + {name: "Global Pool Created Successfully"}) if update_global_pool: final_update_global_pool = [] @@ -3109,8 +3251,10 @@ def update_global_pool(self, global_pool): for pool_value in self.have.get("globalPool"): if pool_value.get("exists") and (pool_value.get("details").get("ipPoolName") == name or pool_value.get("prev_name") == name): if not self.requires_update(pool_value.get("details"), item, self.global_pool_obj_params): - self.log("Global pool '{0}' doesn't require an update".format(name), "INFO") - result_global_pool.get("msg").update({name: "Global pool doesn't require an update"}) + self.log( + "Global pool '{0}' doesn't require an update".format(name), "INFO") + result_global_pool.get("msg").update( + {name: "Global pool doesn't require an update"}) elif item not in final_update_global_pool: final_update_global_pool.append(item) @@ -3123,13 +3267,15 @@ def update_global_pool(self, global_pool): "ippool": copy.deepcopy(final_update_global_pool) } } - self.log("Desired State for global pool (want): {0}".format(pool_params), "DEBUG") + self.log("Desired State for global pool (want): {0}".format( + pool_params), "DEBUG") keys_to_remove = ["IpAddressSpace", "ipPoolCidr", "type"] for item in pool_params["settings"]["ippool"]: for key in keys_to_remove: del item[key] - self.log("Desired global pool details (want): {0}".format(pool_params), "DEBUG") + self.log("Desired global pool details (want): {0}".format( + pool_params), "DEBUG") try: response = self.dnac._exec( family="network_settings", @@ -3146,14 +3292,19 @@ def update_global_pool(self, global_pool): self.status = "failed" return self - self.check_execution_response_status(response, "update_global_pool").check_return_status() + self.check_execution_response_status( + response, "update_global_pool").check_return_status() for item in pool_params.get("settings").get("ippool"): name = item.get("ipPoolName") - self.log("Global pool '{0}' Updated successfully.".format(name), "INFO") - result_global_pool.get("response").update({"globalPool Details": pool_params}) - result_global_pool.get("msg").update({name: "Global Pool Updated Successfully"}) - - self.log("Global pool configuration operations completed successfully.", "INFO") + self.log( + "Global pool '{0}' Updated successfully.".format(name), "INFO") + result_global_pool.get("response").update( + {"globalPool Details": pool_params}) + result_global_pool.get("msg").update( + {name: "Global Pool Updated Successfully"}) + + self.log( + "Global pool configuration operations completed successfully.", "INFO") return self def update_reserve_pool(self, reserve_pool): @@ -3173,7 +3324,8 @@ def update_reserve_pool(self, reserve_pool): for item in reserve_pool: reserve_pool_index += 1 name = item.get("name") - result_reserve_pool = self.result.get("response")[1].get("reservePool") + result_reserve_pool = self.result.get( + "response")[1].get("reservePool") self.log("Current reserved pool '{0}' details in Catalyst Center: {1}" .format(name, self.have.get("reservePool")[reserve_pool_index].get("details")), "DEBUG") self.log("Desired reserved pool '{0}' details in Catalyst Center: {1}" @@ -3199,14 +3351,17 @@ def update_reserve_pool(self, reserve_pool): except Exception as msg: self.msg = ( "Exception occurred while reserving the global pool with the name '{name}' " - "in site '{site}: {msg}".format(name=name, site=site_name, msg=msg) + "in site '{site}: {msg}".format( + name=name, site=site_name, msg=msg) ) self.log(str(msg), "ERROR") self.status = "failed" return self - self.check_execution_response_status(response, "reserve_ip_subpool").check_return_status() - self.log("Successfully created IP subpool reservation '{0}'.".format(name), "INFO") + self.check_execution_response_status( + response, "reserve_ip_subpool").check_return_status() + self.log( + "Successfully created IP subpool reservation '{0}'.".format(name), "INFO") result_reserve_pool.get("response") \ .update({name: self.want.get("wantReserve")[reserve_pool_index]}) result_reserve_pool.get("msg") \ @@ -3215,21 +3370,25 @@ def update_reserve_pool(self, reserve_pool): # Check update is required if not self.requires_update(self.have.get("reservePool")[reserve_pool_index].get("details"), - self.want.get("wantReserve")[reserve_pool_index], - self.reserve_pool_obj_params): - self.log("Reserved ip subpool '{0}' doesn't require an update".format(name), "INFO") + self.want.get("wantReserve")[ + reserve_pool_index], + self.reserve_pool_obj_params): + self.log( + "Reserved ip subpool '{0}' doesn't require an update".format(name), "INFO") result_reserve_pool.get("msg") \ .update({name: "Reserved ip subpool doesn't require an update"}) continue - self.log("Reserved ip pool '{0}' requires an update".format(name), "DEBUG") + self.log( + "Reserved ip pool '{0}' requires an update".format(name), "DEBUG") # Pool Exists self.log("Current reserved ip pool '{0}' details in Catalyst Center: {1}" .format(name, self.have.get("reservePool")), "DEBUG") self.log("Desired reserved ip pool '{0}' details: {1}" .format(name, self.want.get("wantReserve")), "DEBUG") - reserve_params.update({"id": self.have.get("reservePool")[reserve_pool_index].get("id")}) + reserve_params.update({"id": self.have.get("reservePool")[ + reserve_pool_index].get("id")}) try: response = self.dnac._exec( family="network_settings", @@ -3246,8 +3405,10 @@ def update_reserve_pool(self, reserve_pool): self.status = "failed" return self - self.check_execution_response_status(response, "update_reserve_ip_subpool").check_return_status() - self.log("Reserved ip subpool '{0}' updated successfully.".format(name), "INFO") + self.check_execution_response_status( + response, "update_reserve_ip_subpool").check_return_status() + self.log( + "Reserved ip subpool '{0}' updated successfully.".format(name), "INFO") result_reserve_pool.get("response") \ .update({name: reserve_params}) result_reserve_pool.get("response").get(name) \ @@ -3270,7 +3431,8 @@ def update_dhcp_settings_for_site(self, site_name, site_id, dhcp_settings): Returns: Response (dict) - The response after updating the DHCP settings. """ - self.log("Attempting to update DHCP settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, dhcp_settings), "INFO") + self.log("Attempting to update DHCP settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, dhcp_settings), "INFO") try: response = self.dnac._exec( @@ -3279,10 +3441,12 @@ def update_dhcp_settings_for_site(self, site_name, site_id, dhcp_settings): op_modifies=True, params={"id": site_id, "dhcp": dhcp_settings}, ) - self.log("DHCP settings updated for for site '{0}' (ID: {1}): {2}".format(site_name, site_id, dhcp_settings), "DEBUG") + self.log("DHCP settings updated for for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, dhcp_settings), "DEBUG") except Exception as e: self.msg = ( - "Exception occurred while updating DHCP settings for site {0}: {1}".format(site_id, str(e)) + "Exception occurred while updating DHCP settings for site {0}: {1}".format( + site_id, str(e)) ) self.log(self.msg, "CRITICAL") self.status = "failed" @@ -3303,7 +3467,8 @@ def update_ntp_settings_for_site(self, site_name, site_id, ntp_settings): Returns: Response (dict): The response after updating the NTP settings. """ - self.log("Attempting to update NTP settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, ntp_settings), "INFO") + self.log("Attempting to update NTP settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, ntp_settings), "INFO") try: response = self.dnac._exec( @@ -3312,10 +3477,12 @@ def update_ntp_settings_for_site(self, site_name, site_id, ntp_settings): op_modifies=True, params={"id": site_id, "ntp": ntp_settings}, ) - self.log("NTP settings updated for site '{0}' (ID: {1}): {2}".format(site_name, site_id, ntp_settings), "DEBUG") + self.log("NTP settings updated for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, ntp_settings), "DEBUG") except Exception as e: self.msg = ( - "Exception occurred while updating NTP settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, str(e)) + "Exception occurred while updating NTP settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, str(e)) ) self.log(self.msg, "CRITICAL") self.status = "failed" @@ -3336,7 +3503,8 @@ def update_time_zone_settings_for_site(self, site_name, site_id, time_zone_setti Returns: Response (dict): The response after updating the time zone settings. """ - self.log("Attempting to update time zone settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, time_zone_settings), "INFO") + self.log("Attempting to update time zone settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, time_zone_settings), "INFO") try: response = self.dnac._exec( @@ -3345,10 +3513,12 @@ def update_time_zone_settings_for_site(self, site_name, site_id, time_zone_setti op_modifies=True, params={"id": site_id, "timeZone": time_zone_settings} ) - self.log("Time zone settings updated for site '{0}' (ID: {1}): {2}".format(site_name, site_id, time_zone_settings), "DEBUG") + self.log("Time zone settings updated for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, time_zone_settings), "DEBUG") except Exception as e: self.msg = ( - "Exception occurred while updating time zone settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, str(e)) + "Exception occurred while updating time zone settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, str(e)) ) self.log(self.msg, "CRITICAL") self.status = "failed" @@ -3369,7 +3539,8 @@ def update_dns_settings_for_site(self, site_name, site_id, dns_settings): Returns: Response (dict): The response after updating the DNS settings. """ - self.log("Attempting to update DNS settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, dns_settings), "INFO") + self.log("Attempting to update DNS settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, dns_settings), "INFO") dns_params = {} if dns_settings.get("domainName"): @@ -3392,10 +3563,12 @@ def update_dns_settings_for_site(self, site_name, site_id, dns_settings): op_modifies=True, params={"id": site_id, "dns": dns_params}, ) - self.log("DNS settings updated for site '{0}' (ID: {1}): {2}".format(site_name, site_id, dns_settings), "DEBUG") + self.log("DNS settings updated for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, dns_settings), "DEBUG") except Exception as e: self.msg = ( - "Exception occurred while updating DNS settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, str(e)) + "Exception occurred while updating DNS settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, str(e)) ) self.log(self.msg, "CRITICAL") self.status = "failed" @@ -3416,7 +3589,8 @@ def update_telemetry_settings_for_site(self, site_name, site_id, telemetry_setti Returns: Response (dict): The response after updating the telemetry settings. """ - self.log("Attempting to update telemetry settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, telemetry_settings), "INFO") + self.log("Attempting to update telemetry settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, telemetry_settings), "INFO") try: response = self.dnac._exec( @@ -3432,10 +3606,12 @@ def update_telemetry_settings_for_site(self, site_name, site_id, telemetry_setti "applicationVisibility": telemetry_settings.get("netflowcollector") } ) - self.log("Telemetry settings updated for site '{0}' (ID: {1}): {2}".format(site_name, site_id, telemetry_settings), "DEBUG") + self.log("Telemetry settings updated for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, telemetry_settings), "DEBUG") except Exception as e: self.msg = ( - "Exception occurred while updating telemetry settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, str(e)) + "Exception occurred while updating telemetry settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, str(e)) ) self.log(self.msg, "CRITICAL") self.status = "failed" @@ -3456,7 +3632,8 @@ def update_banner_settings_for_site(self, site_name, site_id, banner_settings): Returns: Response (dict): The response after updating the banner settings. """ - self.log("Attempting to update banner settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, banner_settings), "INFO") + self.log("Attempting to update banner settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, banner_settings), "INFO") try: response = self.dnac._exec( @@ -3465,10 +3642,12 @@ def update_banner_settings_for_site(self, site_name, site_id, banner_settings): op_modifies=True, params={"id": site_id, "banner": banner_settings}, ) - self.log("Banner settings updated for site '{0}' (ID: {1}): {2}".format(site_name, site_id, banner_settings), "DEBUG") + self.log("Banner settings updated for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, banner_settings), "DEBUG") except Exception as e: self.msg = ( - "Exception occurred while updating banner settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, str(e)) + "Exception occurred while updating banner settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, str(e)) ) self.log(self.msg, "CRITICAL") self.status = "failed" @@ -3490,10 +3669,13 @@ def update_aaa_settings_for_site(self, site_name, site_id, network_aaa, client_a Returns: Response (dict): The response after updating the AAA settings. """ - self.log("Attempting to update AAA settings for site '{0}' (ID: {1})".format(site_name, site_id), "INFO") - self.log({"id": site_id, "aaaNetwork": network_aaa, "aaaClient": client_and_endpoint_aaa}, "DEBUG") + self.log("Attempting to update AAA settings for site '{0}' (ID: {1})".format( + site_name, site_id), "INFO") + self.log({"id": site_id, "aaaNetwork": network_aaa, + "aaaClient": client_and_endpoint_aaa}, "DEBUG") if network_aaa and client_and_endpoint_aaa: - param = {"id": site_id, "aaaNetwork": network_aaa, "aaaClient": client_and_endpoint_aaa} + param = {"id": site_id, "aaaNetwork": network_aaa, + "aaaClient": client_and_endpoint_aaa} elif network_aaa: param = {"id": site_id, "aaaNetwork": network_aaa} else: @@ -3510,7 +3692,8 @@ def update_aaa_settings_for_site(self, site_name, site_id, network_aaa, client_a .format(site_name, site_id, network_aaa, client_and_endpoint_aaa), "DEBUG") except Exception as e: self.msg = ( - "Exception occurred while updating AAA settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, str(e)) + "Exception occurred while updating AAA settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, str(e)) ) self.log(self.msg, "CRITICAL") self.status = "failed" @@ -3534,35 +3717,47 @@ def update_network(self, network_management): site_name = item.get("site_name") result_network = self.result.get("response")[2].get("network") result_network.get("response").update({site_name: {}}) - have_network_details = self.have.get("network")[network_management_index].get("net_details") - want_network_details = self.want.get("wantNetwork")[network_management_index] - network_aaa = want_network_details.get("settings").get("network_aaa") - client_and_endpoint_aaa = want_network_details.get("settings").get("client_and_endpoint_aaa") + have_network_details = self.have.get( + "network")[network_management_index].get("net_details") + want_network_details = self.want.get( + "wantNetwork")[network_management_index] + network_aaa = want_network_details.get( + "settings").get("network_aaa") + client_and_endpoint_aaa = want_network_details.get( + "settings").get("client_and_endpoint_aaa") # Check update is required or not if not ((network_aaa and network_aaa.get("sharedSecret")) or (client_and_endpoint_aaa and client_and_endpoint_aaa.get("sharedSecret")) or self.requires_update(have_network_details, want_network_details, self.network_obj_params)): - self.log("Network in site '{0}' doesn't require an update.".format(site_name), "INFO") + self.log("Network in site '{0}' doesn't require an update.".format( + site_name), "INFO") result_network.get("response").get(site_name).update({ "Cisco Catalyst Center params": self.have.get("network")[network_management_index] .get("net_details").get("settings") }) - result_network.get("msg").update({site_name: "Network doesn't require an update"}) + result_network.get("msg").update( + {site_name: "Network doesn't require an update"}) continue - self.log("Network in site '{0}' requires update.".format(site_name), "INFO") + self.log("Network in site '{0}' requires update.".format( + site_name), "INFO") self.log("Current State of network in Catalyst Center: {0}" .format(self.have.get("network")), "DEBUG") - self.log("Desired State of network: {0}".format(self.want.get("wantNetwork")), "DEBUG") - - net_params = copy.deepcopy(self.want.get("wantNetwork")[network_management_index]) - net_params.update({"site_id": self.have.get("network")[network_management_index].get("site_id")}) - self.log("Network parameters for 'update_network_v2': {0}".format(net_params), "DEBUG") + self.log("Desired State of network: {0}".format( + self.want.get("wantNetwork")), "DEBUG") + + net_params = copy.deepcopy(self.want.get("wantNetwork")[ + network_management_index]) + net_params.update({"site_id": self.have.get("network")[ + network_management_index].get("site_id")}) + self.log("Network parameters for 'update_network_v2': {0}".format( + net_params), "DEBUG") if self.compare_dnac_versions(self.get_ccc_version(), "2.3.5.3") <= 0: if 'client_and_endpoint_aaa' in net_params['settings']: - net_params['settings']['clientAndEndpoint_aaa'] = net_params['settings'].pop('client_and_endpoint_aaa') + net_params['settings']['clientAndEndpoint_aaa'] = net_params['settings'].pop( + 'client_and_endpoint_aaa') try: response = self.dnac._exec( @@ -3571,9 +3766,11 @@ def update_network(self, network_management): op_modifies=True, params=net_params, ) - self.log("Received API response of 'update_network_v2': {0}".format(response), "DEBUG") + self.log("Received API response of 'update_network_v2': {0}".format( + response), "DEBUG") validation_string = "desired common settings operation successful" - self.check_task_response_status(response, validation_string, "update_network_v2").check_return_status() + self.check_task_response_status( + response, validation_string, "update_network_v2").check_return_status() except Exception as msg: self.msg = ( "Exception occurred while updating the network settings of '{site_name}': {msg}" @@ -3584,43 +3781,63 @@ def update_network(self, network_management): return self else: site_id = net_params.get("site_id") - site_name = self.have.get("network")[network_management_index].get("site_name") + site_name = self.have.get( + "network")[network_management_index].get("site_name") if net_params.get("settings").get("dhcpServer"): - dhcp_settings = net_params.get("settings").get("dhcpServer") - response = self.update_dhcp_settings_for_site(site_name, site_id, dhcp_settings) - self.log("Received API response of 'set_dhcp_settings_for_a_site': {0}".format(response), "DEBUG") - self.check_tasks_response_status(response, "set_dhcp_settings_for_a_site").check_return_status() + dhcp_settings = net_params.get( + "settings").get("dhcpServer") + response = self.update_dhcp_settings_for_site( + site_name, site_id, dhcp_settings) + self.log("Received API response of 'set_dhcp_settings_for_a_site': {0}".format( + response), "DEBUG") + self.check_tasks_response_status( + response, "set_dhcp_settings_for_a_site").check_return_status() if net_params.get("settings").get("ntpServer"): ntp_settings = net_params.get("settings").get("ntpServer") - response = self.update_ntp_settings_for_site(site_name, site_id, ntp_settings) - self.log("Received API response of 'set_n_t_p_settings_for_a_site': {0}".format(response), "DEBUG") - self.check_tasks_response_status(response, "set_n_t_p_settings_for_a_site").check_return_status() + response = self.update_ntp_settings_for_site( + site_name, site_id, ntp_settings) + self.log("Received API response of 'set_n_t_p_settings_for_a_site': {0}".format( + response), "DEBUG") + self.check_tasks_response_status( + response, "set_n_t_p_settings_for_a_site").check_return_status() if net_params.get("settings").get("timezone"): - time_zone_settings = net_params.get("settings").get("timezone") - response = self.update_time_zone_settings_for_site(site_name, site_id, time_zone_settings) - self.log("Received API response of 'set_time_zone_for_a_site': {0}".format(response), "DEBUG") - self.check_tasks_response_status(response, "set_time_zone_for_a_site").check_return_status() + time_zone_settings = net_params.get( + "settings").get("timezone") + response = self.update_time_zone_settings_for_site( + site_name, site_id, time_zone_settings) + self.log("Received API response of 'set_time_zone_for_a_site': {0}".format( + response), "DEBUG") + self.check_tasks_response_status( + response, "set_time_zone_for_a_site").check_return_status() if net_params.get("settings").get("dnsServer"): dns_settings = net_params.get("settings").get("dnsServer") - response = self.update_dns_settings_for_site(site_name, site_id, dns_settings) - self.log("Received API response of 'set_d_n_s_settings_for_a_site': {0}".format(response), "DEBUG") - self.check_tasks_response_status(response, "set_d_n_s_settings_for_a_site").check_return_status() + response = self.update_dns_settings_for_site( + site_name, site_id, dns_settings) + self.log("Received API response of 'set_d_n_s_settings_for_a_site': {0}".format( + response), "DEBUG") + self.check_tasks_response_status( + response, "set_d_n_s_settings_for_a_site").check_return_status() if net_params.get("settings").get("messageOfTheday"): - banner_settings = net_params.get("settings").get("messageOfTheday") - response = self.update_banner_settings_for_site(site_name, site_id, banner_settings) - self.log("Received API response of 'set_banner_settings_for_a_site': {0}".format(response), "DEBUG") - self.check_tasks_response_status(response, "set_banner_settings_for_a_site").check_return_status() + banner_settings = net_params.get( + "settings").get("messageOfTheday") + response = self.update_banner_settings_for_site( + site_name, site_id, banner_settings) + self.log("Received API response of 'set_banner_settings_for_a_site': {0}".format( + response), "DEBUG") + self.check_tasks_response_status( + response, "set_banner_settings_for_a_site").check_return_status() if all([ net_params.get("settings", {}).get("snmpServer"), net_params.get("settings", {}).get("syslogServer"), net_params.get("settings", {}).get("netflowcollector"), - net_params.get("settings", {}).get("wired_data_collection"), + net_params.get("settings", {}).get( + "wired_data_collection"), net_params.get("settings", {}).get("wireless_telemetry") ]): telemetry_settings = { @@ -3630,18 +3847,26 @@ def update_network(self, network_management): "wired_data_collection": net_params.get("settings").get("wired_data_collection"), "wireless_telemetry": net_params.get("settings").get("wireless_telemetry") } - response = self.update_telemetry_settings_for_site(site_name, site_id, telemetry_settings) - self.log("Received API response of 'set_telemetry_settings_for_a_site': {0}".format(response), "DEBUG") - self.check_tasks_response_status(response, "set_telemetry_settings_for_a_site").check_return_status() + response = self.update_telemetry_settings_for_site( + site_name, site_id, telemetry_settings) + self.log("Received API response of 'set_telemetry_settings_for_a_site': {0}".format( + response), "DEBUG") + self.check_tasks_response_status( + response, "set_telemetry_settings_for_a_site").check_return_status() if net_params.get("settings").get("network_aaa") or net_params.get("settings").get("client_and_endpoint_aaa"): network_aaa = net_params.get("settings").get("network_aaa") - client_and_endpoint_aaa = net_params.get("settings").get("client_and_endpoint_aaa") - response = self.update_aaa_settings_for_site(site_name, site_id, network_aaa, client_and_endpoint_aaa) - self.log("Received API response of 'set_aaa_settings_for_a_site': {0}".format(response), "DEBUG") - self.check_tasks_response_status(response, "set_aaa_settings_for_a_site").check_return_status() - - self.log("Network under the site '{0}' has been changed successfully".format(site_name), "INFO") + client_and_endpoint_aaa = net_params.get( + "settings").get("client_and_endpoint_aaa") + response = self.update_aaa_settings_for_site( + site_name, site_id, network_aaa, client_and_endpoint_aaa) + self.log("Received API response of 'set_aaa_settings_for_a_site': {0}".format( + response), "DEBUG") + self.check_tasks_response_status( + response, "set_aaa_settings_for_a_site").check_return_status() + + self.log("Network under the site '{0}' has been changed successfully".format( + site_name), "INFO") result_network.get("msg") \ .update({site_name: "Network Updated successfully"}) result_network.get("response").get(site_name) \ @@ -3691,12 +3916,16 @@ def delete_reserve_pool(self, reserve_pool_details): for item in reserve_pool_details: reserve_pool_index += 1 name = item.get("name") - reserve_pool_exists = self.have.get("reservePool")[reserve_pool_index].get("exists") - result_reserve_pool = self.result.get("response")[1].get("reservePool") + reserve_pool_exists = self.have.get( + "reservePool")[reserve_pool_index].get("exists") + result_reserve_pool = self.result.get( + "response")[1].get("reservePool") if not reserve_pool_exists: - result_reserve_pool.get("msg").update({name: "Reserve Pool not found"}) - self.log("Reserved Ip Subpool '{0}' not found".format(name), "INFO") + result_reserve_pool.get("msg").update( + {name: "Reserve Pool not found"}) + self.log( + "Reserved Ip Subpool '{0}' not found".format(name), "INFO") continue self.log("Reserved IP pool scheduled for deletion: {0}" @@ -3719,9 +3948,11 @@ def delete_reserve_pool(self, reserve_pool_details): self.status = "failed" return self - self.check_execution_response_status(response, "release_reserve_ip_subpool").check_return_status() + self.check_execution_response_status( + response, "release_reserve_ip_subpool").check_return_status() executionid = response.get("executionId") - result_reserve_pool = self.result.get("response")[1].get("reservePool") + result_reserve_pool = self.result.get( + "response")[1].get("reservePool") result_reserve_pool.get("response").update({name: {}}) result_reserve_pool.get("response").get(name) \ .update({"Execution Id": executionid}) @@ -3747,10 +3978,12 @@ def delete_global_pool(self, global_pool_details): global_pool_index = 0 for item in self.have.get("globalPool"): global_pool_exists = item.get("exists") - name = global_pool_details.get("settings").get("ip_pool")[global_pool_index].get("name") + name = global_pool_details.get("settings").get( + "ip_pool")[global_pool_index].get("name") global_pool_index += 1 if not global_pool_exists: - result_global_pool.get("msg").update({name: "Global Pool not found"}) + result_global_pool.get("msg").update( + {name: "Global Pool not found"}) self.log("Global pool '{0}' not found".format(name), "INFO") continue @@ -3772,14 +4005,18 @@ def delete_global_pool(self, global_pool_details): return self # Check the execution status - self.check_execution_response_status(response, "delete_global_ip_pool").check_return_status() + self.check_execution_response_status( + response, "delete_global_ip_pool").check_return_status() executionid = response.get("executionId") # Update result information - result_global_pool = self.result.get("response")[0].get("globalPool") + result_global_pool = self.result.get( + "response")[0].get("globalPool") result_global_pool.get("response").update({name: {}}) - result_global_pool.get("response").get(name).update({"Execution Id": executionid}) - result_global_pool.get("msg").update({name: "Global pool deleted successfully"}) + result_global_pool.get("response").get( + name).update({"Execution Id": executionid}) + result_global_pool.get("msg").update( + {name: "Global pool deleted successfully"}) self.msg = "Global pools deleted successfully" self.status = "success" @@ -3798,7 +4035,8 @@ def get_diff_deleted(self, config): reserve_pool_details = config.get("reserve_pool_details") if reserve_pool_details is not None: - self.delete_reserve_pool(reserve_pool_details).check_return_status() + self.delete_reserve_pool( + reserve_pool_details).check_return_status() global_pool_details = config.get("global_pool_details") if global_pool_details is not None: @@ -3830,9 +4068,11 @@ def verify_diff_merged(self, config): self.log("Current State of global pool (have): {0}" .format(self.have.get("globalPool")), "DEBUG") for item in self.want.get("wantGlobal").get("settings").get("ippool"): - global_pool_details = self.have.get("globalPool")[global_pool_index].get("details") + global_pool_details = self.have.get( + "globalPool")[global_pool_index].get("details") if not global_pool_details: - self.msg = "The global pool is not created with the config: {0}".format(item) + self.msg = "The global pool is not created with the config: {0}".format( + item) self.status = "failed" return self @@ -3844,7 +4084,8 @@ def verify_diff_merged(self, config): global_pool_index += 1 self.log("Successfully validated global pool(s).", "INFO") - self.result.get("response")[0].get("globalPool").update({"Validation": "Success"}) + self.result.get("response")[0].get( + "globalPool").update({"Validation": "Success"}) if config.get("reserve_pool_details") is not None: reserve_pool_index = 0 @@ -3853,9 +4094,11 @@ def verify_diff_merged(self, config): self.log("Current State for reserve pool (have): {0}" .format(self.have.get("reservePool")), "DEBUG") for item in self.want.get("wantReserve"): - reserve_pool_details = self.have.get("reservePool")[reserve_pool_index].get("details") + reserve_pool_details = self.have.get( + "reservePool")[reserve_pool_index].get("details") if not reserve_pool_details: - self.msg = "The reserve pool is not created with the config: {0}".format(item) + self.msg = "The reserve pool is not created with the config: {0}".format( + item) self.status = "failed" return self @@ -3867,7 +4110,8 @@ def verify_diff_merged(self, config): reserve_pool_index += 1 self.log("Successfully validated the reserved pool(s)", "INFO") - self.result.get("response")[1].get("reservePool").update({"Validation": "Success"}) + self.result.get("response")[1].get( + "reservePool").update({"Validation": "Success"}) network_management_details = config.get("network_management_details") if network_management_details is not None: @@ -3883,7 +4127,8 @@ def verify_diff_merged(self, config): .format(item.get("site_name")), "INFO") network_management_index += 1 - self.result.get("response")[2].get("network").update({"Validation": "Success"}) + self.result.get("response")[2].get( + "network").update({"Validation": "Success"}) self.msg = "Successfully validated the Global Pool, Reserve Pool and the Network Functions." self.status = "success" @@ -3919,24 +4164,29 @@ def verify_diff_deleted(self, config): self.status = "failed" return self - self.log("Successfully validated absence of Global Pool '{0}'.".format(name), "INFO") + self.log( + "Successfully validated absence of Global Pool '{0}'.".format(name), "INFO") global_pool_index += 1 - self.result.get("response")[0].get("globalPool").update({"Validation": "Success"}) + self.result.get("response")[0].get( + "globalPool").update({"Validation": "Success"}) if config.get("reserve_pool_details") is not None: reserve_pool_index = 0 reserve_pool_details = self.have.get("reservePool") for item in reserve_pool_details: reserve_pool_exists = item.get("exists") - name = config.get("reserve_pool_details")[reserve_pool_index].get("name") + name = config.get("reserve_pool_details")[ + reserve_pool_index].get("name") if reserve_pool_exists: self.msg = "Reserved Pool Config '{0}' is not applied to the Catalyst Center" \ .format(name) self.status = "failed" return self - self.log("Successfully validated the absence of Reserve Pool '{0}'.".format(name), "INFO") - self.result.get("response")[1].get("reservePool").update({"Validation": "Success"}) + self.log("Successfully validated the absence of Reserve Pool '{0}'.".format( + name), "INFO") + self.result.get("response")[1].get( + "reservePool").update({"Validation": "Success"}) self.msg = "Successfully validated the absence of Global Pool/Reserve Pool" self.status = "success" @@ -3983,7 +4233,8 @@ def main(): } # Create an AnsibleModule object with argument specifications - module = AnsibleModule(argument_spec=element_spec, supports_check_mode=False) + module = AnsibleModule(argument_spec=element_spec, + supports_check_mode=False) ccc_network = NetworkSettings(module) state = ccc_network.params.get("state") @@ -4010,7 +4261,8 @@ def main(): ccc_network.get_want(config).check_return_status() ccc_network.get_diff_state_apply[state](config).check_return_status() if config_verify: - ccc_network.verify_diff_state_apply[state](config).check_return_status() + ccc_network.verify_diff_state_apply[state]( + config).check_return_status() module.exit_json(**ccc_network.result) diff --git a/plugins/modules/pnp_intent.py b/plugins/modules/pnp_intent.py index 15d00b0dc0..a157107a48 100644 --- a/plugins/modules/pnp_intent.py +++ b/plugins/modules/pnp_intent.py @@ -4,6 +4,12 @@ # Copyright (c) 2024, Cisco Systems # 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 +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + get_dict_result +) +from ansible.module_utils.basic import AnsibleModule __metaclass__ = type __author__ = ("Abinash Mishra, Madhan Sankaranarayanan, Rishita Chowdhary") @@ -326,12 +332,6 @@ "msg": String } """ -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - get_dict_result -) class PnP(DnacBase): @@ -398,7 +398,8 @@ def validate_input(self): self.status = "failed" return self self.validated_config = valid_pnp - self.msg = "Successfully validated playbook config params: {0}".format(str(valid_pnp)) + self.msg = "Successfully validated playbook config params: {0}".format( + str(valid_pnp)) self.log(str(self.msg), "INFO") self.status = "success" @@ -443,7 +444,8 @@ def get_site_details(self): if len(site) == 1: site_id = site[0].get("id") site_exists = True - self.log("Site Name: {1}, Site ID: {0}".format(site_id, self.want.get("site_name")), "INFO") + self.log("Site Name: {1}, Site ID: {0}".format( + site_id, self.want.get("site_name")), "INFO") return (site_exists, site_id) @@ -483,7 +485,8 @@ def get_site_type(self): for item in site_additional_info: if item["nameSpace"] == "Location": site_type = item.get("attributes").get("type") - self.log("Site type for site name '{1}' : {0}".format(site_type, self.want.get("site_name")), "INFO") + self.log("Site type for site name '{1}' : {0}".format( + site_type, self.want.get("site_name")), "INFO") return site_type @@ -515,7 +518,8 @@ def get_pnp_params(self, params): device_dict["deviceInfo"] = param device_info_list.append(device_dict) - self.log("PnP paramters passed are {0}".format(str(params_list)), "INFO") + self.log("PnP paramters passed are {0}".format( + str(params_list)), "INFO") return device_info_list def get_image_params(self, params): @@ -625,7 +629,8 @@ def get_claim_params(self): claim_params["staticIP"] = self.validated_config[0]['static_ip'] claim_params["subnetMask"] = self.validated_config[0]['subnet_mask'] claim_params["gateway"] = self.validated_config[0]['gateway'] - claim_params["vlanId"] = str(self.validated_config[0].get('vlan_id')) + claim_params["vlanId"] = str( + self.validated_config[0].get('vlan_id')) claim_params["ipInterfaceName"] = self.validated_config[0]['ip_interface_name'] if claim_params["type"] == "AccessPoint": @@ -634,7 +639,8 @@ def get_claim_params(self): self.pnp_cred_failure(msg=msg) claim_params["rfProfile"] = self.validated_config[0]["rf_profile"] - self.log("Parameters used for claiming are {0}".format(str(claim_params)), "INFO") + self.log("Parameters used for claiming are {0}".format( + str(claim_params)), "INFO") return claim_params def get_reset_params(self): @@ -673,7 +679,8 @@ def get_reset_params(self): ] } - self.log("Paramters used for resetting from errored state:{0}".format(str(reset_params)), "INFO") + self.log("Paramters used for resetting from errored state:{0}".format( + str(reset_params)), "INFO") return reset_params def get_have(self): @@ -707,7 +714,8 @@ def get_have(self): number '{0}': {1}".format(self.want.get("serial_number"), str(device_response)), "DEBUG") if not (device_response and (len(device_response) == 1)): - self.log("Device with serial number {0} is not found in the inventory".format(self.want.get("serial_number")), "WARNING") + self.log("Device with serial number {0} is not found in the inventory".format( + self.want.get("serial_number")), "WARNING") self.msg = "Adding the device to database" self.status = "success" self.have = have @@ -727,7 +735,8 @@ def get_have(self): op_modifies=True, ) image_list = image_response.get("response") - self.log("Image details obtained from the API 'get_software_image_details': {0}".format(str(image_response)), "DEBUG") + self.log("Image details obtained from the API 'get_software_image_details': {0}".format( + str(image_response)), "DEBUG") # check if project has templates or not template_list = self.dnac_apply['exec']( @@ -736,7 +745,8 @@ def get_have(self): params={"project_names": self.want.get("project_name")}, op_modifies=True, ) - self.log("List of templates under the project '{0}': {1}".format(self.want.get("project_name"), str(template_list)), "DEBUG") + self.log("List of templates under the project '{0}': {1}".format( + self.want.get("project_name"), str(template_list)), "DEBUG") dev_details_response = self.dnac_apply['exec']( family="device_onboarding_pnp", @@ -744,9 +754,12 @@ def get_have(self): params={"id": device_response[0].get("id")}, op_modifies=True, ) - self.log("Device details retrieved after calling the 'get_device_by_id' API: {0}".format(str(dev_details_response)), "DEBUG") - install_mode = dev_details_response.get("deviceInfo").get("mode") - self.log("Installation mode of the device with the serial no. '{0}':{1}".format(self.want.get("serial_number"), install_mode), "INFO") + self.log("Device details retrieved after calling the 'get_device_by_id' API: {0}".format( + str(dev_details_response)), "DEBUG") + install_mode = dev_details_response.get( + "deviceInfo").get("mode") + self.log("Installation mode of the device with the serial no. '{0}':{1}".format( + self.want.get("serial_number"), install_mode), "INFO") # check if given site exits, if exists store current site info site_exists = False @@ -762,7 +775,8 @@ def get_have(self): if site_exists: have["site_id"] = site_id - self.log("Site Exists: {0}\nSite Name: {1}\nSite ID: {2}".format(site_exists, site_name, site_id), "INFO") + self.log("Site Exists: {0}\nSite Name: {1}\nSite ID: {2}".format( + site_exists, site_name, site_id), "INFO") if self.want.get("pnp_type") == "AccessPoint": if self.get_site_type() != "floor": self.msg = "Please ensure that the site type is specified as 'floor' when claiming an AP."\ @@ -774,7 +788,8 @@ def get_have(self): if len(image_list) == 0: self.msg = "The image '{0}' is either not present or not tagged as 'Golden' in the Cisco Catalyst Center."\ - " Please verify its existence and its tag status.".format(self.validated_config[0].get("image_name")) + " Please verify its existence and its tag status.".format( + self.validated_config[0].get("image_name")) self.log(self.msg, "CRITICAL") self.status = "failed" return self @@ -782,13 +797,15 @@ def get_have(self): if len(image_list) == 1: if install_mode != "INSTALL": self.msg = "The system must be in INSTALL mode to upgrade the image. The current mode is '{0}'."\ - " Please switch to INSTALL mode to proceed.".format(install_mode) + " Please switch to INSTALL mode to proceed.".format( + install_mode) self.log(str(self.msg), "CRITICAL") self.status = "failed" return self have["image_id"] = image_list[0].get("imageUuid") - self.log("Image ID for the image '{0}': {1}".format(self.want.get('image_params').get('image_name'), str(have["image_id"])), "INFO") + self.log("Image ID for the image '{0}': {1}".format(self.want.get( + 'image_params').get('image_name'), str(have["image_id"])), "INFO") template_name = self.want.get("template_name") if template_name: @@ -799,11 +816,14 @@ def get_have(self): self.status = "failed" return self - template_details = get_dict_result(template_list, 'name', template_name) + template_details = get_dict_result( + template_list, 'name', template_name) if template_details: - have["template_id"] = template_details.get("templateId") + have["template_id"] = template_details.get( + "templateId") else: - self.msg = "Template '{0}' is not found.".format(template_name) + self.msg = "Template '{0}' is not found.".format( + template_name) self.log(self.msg, "CRITICAL") self.status = "failed" return self @@ -905,14 +925,16 @@ class instance for further use. multi_device_response = self.dnac_apply['exec']( family="device_onboarding_pnp", function='get_device_list', - params={"serial_number": device["deviceInfo"]["serialNumber"]}, + params={ + "serial_number": device["deviceInfo"]["serialNumber"]}, op_modifies=True, ) self.log("Device details for serial number {0} \ obtained from the API 'get_device_list': {1}".format(device["deviceInfo"]["serialNumber"], str(multi_device_response)), "DEBUG") if (multi_device_response and (len(multi_device_response) == 1)): devices_added.append(device) - self.log("Details of the added device:{0}".format(str(device)), "INFO") + self.log("Details of the added device:{0}".format( + str(device)), "INFO") if (len(self.want.get("pnp_params")) - len(devices_added)) == 0: self.result['response'] = [] self.result['msg'] = "Devices are already added" @@ -930,7 +952,8 @@ class instance for further use. params={"payload": bulk_list}, op_modifies=True, ) - self.log("Response from API 'import_devices_in_bulk' for imported devices: {0}".format(bulk_params), "DEBUG") + self.log("Response from API 'import_devices_in_bulk' for imported devices: {0}".format( + bulk_params), "DEBUG") if len(bulk_params.get("successList")) > 0: self.result['msg'] = "{0} device(s) imported successfully".format( len(bulk_params.get("successList"))) @@ -972,7 +995,8 @@ class instance for further use. ) self.have["deviceInfo"] = dev_add_response.get("deviceInfo") - self.log("Response from API 'add device' for a single device addition: {0}".format(str(dev_add_response)), "DEBUG") + self.log("Response from API 'add device' for a single device addition: {0}".format( + str(dev_add_response)), "DEBUG") if self.have["deviceInfo"]: self.result['msg'] = "Only Device Added Successfully" self.log(self.result['msg'], "INFO") @@ -997,7 +1021,8 @@ class instance for further use. ) self.get_have().check_return_status() self.have["deviceInfo"] = dev_add_response.get("deviceInfo") - self.log("Response from API 'add device' for single device addition: {0}".format(str(dev_add_response)), "DEBUG") + self.log("Response from API 'add device' for single device addition: {0}".format( + str(dev_add_response)), "DEBUG") claim_params = self.get_claim_params() claim_params["deviceId"] = dev_add_response.get("id") claim_response = self.dnac_apply['exec']( @@ -1007,7 +1032,8 @@ class instance for further use. params=claim_params, ) - self.log("Response from API 'claim a device to a site' for a single claiming: {0}".format(str(dev_add_response)), "DEBUG") + self.log("Response from API 'claim a device to a site' for a single claiming: {0}".format( + str(dev_add_response)), "DEBUG") if claim_response.get("response") == "Device Claimed" and self.have["deviceInfo"]: self.result['msg'] = "Device Added and Claimed Successfully" self.log(self.result['msg'], "INFO") @@ -1028,7 +1054,8 @@ class instance for further use. op_modifies=True, params=provisioned_count_params, ) - self.log("Response from 'get device count' API for provisioned devices: {0}".format(str(prov_dev_response)), "DEBUG") + self.log("Response from 'get device count' API for provisioned devices: {0}".format( + str(prov_dev_response)), "DEBUG") plan_dev_response = self.dnac_apply['exec']( family="device_onboarding_pnp", @@ -1036,7 +1063,8 @@ class instance for further use. op_modifies=True, params=planned_count_params, ) - self.log("Response from 'get_device_count' API for devices in planned state: {0}".format(str(plan_dev_response)), "DEBUG") + self.log("Response from 'get_device_count' API for devices in planned state: {0}".format( + str(plan_dev_response)), "DEBUG") dev_details_response = self.dnac_apply['exec']( family="device_onboarding_pnp", @@ -1044,7 +1072,8 @@ class instance for further use. params={"id": self.have["device_id"]}, op_modifies=True, ) - self.log("Response from 'get_device_by_id' API for device details: {0}".format(str(dev_details_response)), "DEBUG") + self.log("Response from 'get_device_by_id' API for device details: {0}".format( + str(dev_details_response)), "DEBUG") is_stack = False if dev_details_response.get("deviceInfo").get("stack"): @@ -1058,10 +1087,12 @@ class instance for further use. self.log(self.result['msg'], "WARNING") return self - update_payload = {"deviceInfo": self.want.get('pnp_params')[0].get("deviceInfo")} + update_payload = {"deviceInfo": self.want.get( + 'pnp_params')[0].get("deviceInfo")} update_payload["deviceInfo"]["stack"] = is_stack - self.log("The request sent for 'update_device' API for device's config update: {0}".format(update_payload), "DEBUG") + self.log("The request sent for 'update_device' API for device's config update: {0}".format( + update_payload), "DEBUG") update_response = self.dnac_apply['exec']( family="device_onboarding_pnp", function="update_device", @@ -1069,7 +1100,8 @@ class instance for further use. "payload": update_payload}, op_modifies=True, ) - self.log("Response from 'update_device' API for device's config update: {0}".format(str(update_response)), "DEBUG") + self.log("Response from 'update_device' API for device's config update: {0}".format( + str(update_response)), "DEBUG") if pnp_state == "Error": reset_paramters = self.get_reset_params() @@ -1079,7 +1111,8 @@ class instance for further use. params={"payload": reset_paramters}, op_modifies=True, ) - self.log("Response from 'update_device' API for errored state resolution: {0}".format(str(reset_response)), "DEBUG") + self.log("Response from 'update_device' API for errored state resolution: {0}".format( + str(reset_response)), "DEBUG") self.result['msg'] = "Device reset done Successfully" self.log(self.result['msg'], "INFO") self.result['response'] = reset_response @@ -1101,7 +1134,8 @@ class instance for further use. return self claim_params = self.get_claim_params() - self.log("Parameters for claiming the device: {0}".format(str(claim_params)), "DEBUG") + self.log("Parameters for claiming the device: {0}".format( + str(claim_params)), "DEBUG") claim_response = self.dnac_apply['exec']( family="device_onboarding_pnp", @@ -1109,7 +1143,8 @@ class instance for further use. op_modifies=True, params=claim_params, ) - self.log("Response from 'claim_a_device_to_a_site' API for claiming: {0}".format(str(claim_response)), "DEBUG") + self.log("Response from 'claim_a_device_to_a_site' API for claiming: {0}".format( + str(claim_response)), "DEBUG") if claim_response.get("response") == "Device Claimed": self.result['msg'] = "Only Device Claimed Successfully" self.log(self.result['msg'], "INFO") @@ -1144,7 +1179,8 @@ def get_diff_deleted(self): params={"serial_number": device["deviceInfo"]["serialNumber"]}, op_modifies=True, ) - self.log("Response from 'get_device_list' API for claiming: {0}".format(str(multi_device_response)), "DEBUG") + self.log("Response from 'get_device_list' API for claiming: {0}".format( + str(multi_device_response)), "DEBUG") if multi_device_response and len(multi_device_response) == 1: device_id = multi_device_response[0].get("id") @@ -1157,7 +1193,8 @@ def get_diff_deleted(self): self.log("Device details for the deleted device with \ serial number '{0}': {1}".format(device["deviceInfo"]["serialNumber"], str(response)), "DEBUG") if response.get("deviceInfo", {}).get("state") == "Deleted": - devices_deleted.append(device["deviceInfo"]["serialNumber"]) + devices_deleted.append( + device["deviceInfo"]["serialNumber"]) self.want.get("pnp_params").remove(device) else: self.result['response'] = response @@ -1168,7 +1205,8 @@ def get_diff_deleted(self): self.result['changed'] = True self.result['response'] = devices_deleted self.result['diff'] = self.want.get("pnp_params") - self.result['msg'] = "{0} Device(s) Deleted Successfully".format(len(devices_deleted)) + self.result['msg'] = "{0} Device(s) Deleted Successfully".format( + len(devices_deleted)) self.log(self.result['msg'], "INFO") else: self.result['msg'] = "Device(s) Not Found" @@ -1303,7 +1341,8 @@ def main(): ccc_pnp.get_have().check_return_status() ccc_pnp.get_diff_state_apply[state]().check_return_status() if config_verify: - ccc_pnp.verify_diff_state_apply[state](config).check_return_status() + ccc_pnp.verify_diff_state_apply[state]( + config).check_return_status() module.exit_json(**ccc_pnp.result) diff --git a/plugins/modules/pnp_workflow_manager.py b/plugins/modules/pnp_workflow_manager.py index 4360d26dcb..a13d8527bf 100644 --- a/plugins/modules/pnp_workflow_manager.py +++ b/plugins/modules/pnp_workflow_manager.py @@ -4,6 +4,12 @@ # Copyright (c) 2024, Cisco Systems # 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 +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + get_dict_result +) +from ansible.module_utils.basic import AnsibleModule __metaclass__ = type __author__ = ("Abinash Mishra, Madhan Sankaranarayanan, Rishita Chowdhary") @@ -326,12 +332,6 @@ "msg": String } """ -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - get_dict_result -) class PnP(DnacBase): @@ -393,12 +393,15 @@ def validate_input(self): ) if invalid_params: - self.msg = "Invalid parameters in playbook: {0}".format("\n".join(invalid_params)) + self.msg = "Invalid parameters in playbook: {0}".format( + "\n".join(invalid_params)) self.log(str(self.msg), "ERROR") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() self.validated_config = valid_pnp - self.msg = "Successfully validated playbook config params: {0}".format(str(valid_pnp)) + self.msg = "Successfully validated playbook config params: {0}".format( + str(valid_pnp)) self.log(str(self.msg), "INFO") self.status = "success" @@ -437,9 +440,11 @@ def get_site_details(self): return (site_exists, site_id) except Exception: - self.msg = "Exception occurred as site '{0}' was not found".format(self.want.get("site_name")) + self.msg = "Exception occurred as site '{0}' was not found".format( + self.want.get("site_name")) self.log(self.msg, "CRITICAL") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() def get_site_type(self): """ @@ -479,9 +484,11 @@ def get_site_type(self): return site_type except Exception: - self.msg = "Exception occurred as site '{0}' was not found".format(self.want.get("site_name")) + self.msg = "Exception occurred as site '{0}' was not found".format( + self.want.get("site_name")) self.log(self.msg, "CRITICAL") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() def get_pnp_params(self, params): """ @@ -511,7 +518,8 @@ def get_pnp_params(self, params): device_dict["deviceInfo"] = param device_info_list.append(device_dict) - self.log("PnP paramters passed are {0}".format(str(params_list)), "INFO") + self.log("PnP paramters passed are {0}".format( + str(params_list)), "INFO") return device_info_list def get_image_params(self, params): @@ -621,7 +629,8 @@ def get_claim_params(self): claim_params["staticIP"] = self.validated_config[0]['static_ip'] claim_params["subnetMask"] = self.validated_config[0]['subnet_mask'] claim_params["gateway"] = self.validated_config[0]['gateway'] - claim_params["vlanId"] = str(self.validated_config[0].get('vlan_id')) + claim_params["vlanId"] = str( + self.validated_config[0].get('vlan_id')) claim_params["ipInterfaceName"] = self.validated_config[0]['ip_interface_name'] if claim_params["type"] == "AccessPoint": @@ -630,7 +639,8 @@ def get_claim_params(self): self.pnp_cred_failure(msg=msg) claim_params["rfProfile"] = self.validated_config[0]["rf_profile"] - self.log("Parameters used for claiming are {0}".format(str(claim_params)), "INFO") + self.log("Parameters used for claiming are {0}".format( + str(claim_params)), "INFO") return claim_params def get_reset_params(self): @@ -669,7 +679,8 @@ def get_reset_params(self): ] } - self.log("Paramters used for resetting from errored state:{0}".format(str(reset_params)), "INFO") + self.log("Paramters used for resetting from errored state:{0}".format( + str(reset_params)), "INFO") return reset_params def get_have(self): @@ -693,12 +704,14 @@ def get_have(self): # Claiming is only allowed for single addition of devices if len(self.want.get('pnp_params')) == 1: # check if given device exists in pnp inventory, store device Id - device_response = self.get_device_list_pnp(self.want.get("serial_number")) + device_response = self.get_device_list_pnp( + self.want.get("serial_number")) self.log("Device details for the device with serial number '{0}': {1}". format(self.want.get("serial_number"), self.pprint(device_response)), "DEBUG") if not device_response: - self.log("Device with serial number {0} is not found in the inventory".format(self.want.get("serial_number")), "WARNING") + self.log("Device with serial number {0} is not found in the inventory".format( + self.want.get("serial_number")), "WARNING") self.msg = "Adding the device to database" self.status = "success" self.have = have @@ -729,11 +742,13 @@ def get_have(self): self.log("List of templates under the project '{0}': {1}" .format(self.want.get("project_name"), self.pprint(template_list)), "DEBUG") - dev_details_response = self.get_device_by_id_pnp(device_response.get("id")) + dev_details_response = self.get_device_by_id_pnp( + device_response.get("id")) self.log("Device details retrieved after calling the 'get_device_by_id' API: {0}" .format(self.pprint(dev_details_response)), "DEBUG") - install_mode = dev_details_response.get("deviceInfo").get("mode") + install_mode = dev_details_response.get( + "deviceInfo").get("mode") self.log("Installation mode of the device with the serial no. '{0}':{1}" .format(self.want.get("serial_number"), install_mode), "INFO") @@ -743,14 +758,16 @@ def get_have(self): not self.want.get('pnp_params')[0].get('deviceInfo'): self.msg = "The site name must be a string" self.log(str(self.msg), "ERROR") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() site_name = self.want.get("site_name") (site_exists, site_id) = self.get_site_details() if site_exists: have["site_id"] = site_id - self.log("Site Exists: {0}\nSite Name: {1}\nSite ID: {2}".format(site_exists, site_name, site_id), "INFO") + self.log("Site Exists: {0}\nSite Name: {1}\nSite ID: {2}".format( + site_exists, site_name, site_id), "INFO") if self.want.get("pnp_type") == "AccessPoint": if self.get_site_type() != "floor": self.msg = "Please ensure that the site type is specified as 'floor' when claiming an AP."\ @@ -762,40 +779,51 @@ def get_have(self): if len(image_list) == 0: self.msg = "The image '{0}' is either not present or not tagged as 'Golden' in the Cisco Catalyst Center."\ - " Please verify its existence and its tag status.".format(self.validated_config[0].get("image_name")) + " Please verify its existence and its tag status.".format( + self.validated_config[0].get("image_name")) self.log(self.msg, "CRITICAL") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() if len(image_list) == 1: if install_mode != "INSTALL": self.msg = "The system must be in INSTALL mode to upgrade the image. The current mode is '{0}'."\ - " Please switch to INSTALL mode to proceed.".format(install_mode) + " Please switch to INSTALL mode to proceed.".format( + install_mode) self.log(str(self.msg), "CRITICAL") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() have["image_id"] = image_list[0].get("imageUuid") - self.log("Image ID for the image '{0}': {1}".format(self.want.get('image_params').get('image_name'), str(have["image_id"])), "INFO") + self.log("Image ID for the image '{0}': {1}".format(self.want.get( + 'image_params').get('image_name'), str(have["image_id"])), "INFO") template_name = self.want.get("template_name") if template_name: if not (template_list and isinstance(template_list, list)): self.msg = "Either project not found or it is Empty." self.log(self.msg, "CRITICAL") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() - template_details = get_dict_result(template_list, 'name', template_name) + template_details = get_dict_result( + template_list, 'name', template_name) if template_details: - have["template_id"] = template_details.get("templateId") + have["template_id"] = template_details.get( + "templateId") else: - self.msg = "Template '{0}' is not found.".format(template_name) + self.msg = "Template '{0}' is not found.".format( + template_name) self.log(self.msg, "CRITICAL") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() else: if not self.want.get('pnp_params')[0].get('deviceInfo'): self.msg = "Either Site Name or Device details must be added." self.log(self.msg, "ERROR") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() self.msg = "Successfully collected all project and template \ parameters from Cisco Catalyst Center for comparison" @@ -878,18 +906,21 @@ class instance for further use. if not isinstance(self.want.get("pnp_params"), list): self.msg = "Device Info must be passed as a list" self.log(self.msg, "ERROR") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() if len(self.want.get("pnp_params")) > 1: devices_added = [] for device in self.want.get("pnp_params"): - multi_device_response = self.get_device_list_pnp(device["deviceInfo"]["serialNumber"]) + multi_device_response = self.get_device_list_pnp( + device["deviceInfo"]["serialNumber"]) self.log("Device details for serial number {0} \ obtained from the API 'get_device_list': {1}".format(device["deviceInfo"]["serialNumber"], str(multi_device_response)), "DEBUG") if (multi_device_response and (len(multi_device_response) == 1)): devices_added.append(device) - self.log("Details of the added device:{0}".format(str(device)), "INFO") + self.log("Details of the added device:{0}".format( + str(device)), "INFO") if (len(self.want.get("pnp_params")) - len(devices_added)) == 0: self.result['response'] = [] self.result['msg'] = "Devices are already added" @@ -907,7 +938,8 @@ class instance for further use. params={"payload": bulk_list}, op_modifies=True, ) - self.log("Response from API 'import_devices_in_bulk' for imported devices: {0}".format(bulk_params), "DEBUG") + self.log("Response from API 'import_devices_in_bulk' for imported devices: {0}".format( + bulk_params), "DEBUG") if len(bulk_params.get("successList")) > 0: self.result['msg'] = "{0} device(s) imported successfully".format( len(bulk_params.get("successList"))) @@ -919,7 +951,8 @@ class instance for further use. self.msg = "Bulk import failed" self.log(self.msg, "CRITICAL") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() provisioned_count_params = { "serial_number": self.want.get("serial_number"), @@ -935,13 +968,16 @@ class instance for further use. if not self.want['pnp_params']: self.msg = "Device needs to be added before claiming. Please add device_info" self.log(self.msg, "ERROR") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() if not self.want["site_name"]: self.log("Adding device to pnp database", "INFO") - dev_add_response = self.add_pnp_device(self.want.get('pnp_params')[0]) + dev_add_response = self.add_pnp_device( + self.want.get('pnp_params')[0]) self.have["deviceInfo"] = dev_add_response.get("deviceInfo") - self.log("Response from API 'add device' for a single device addition: {0}".format(str(dev_add_response)), "DEBUG") + self.log("Response from API 'add device' for a single device addition: {0}".format( + str(dev_add_response)), "DEBUG") if self.have["deviceInfo"]: self.result['msg'] = "Only Device Added Successfully" @@ -952,21 +988,25 @@ class instance for further use. else: self.msg = "Device Addition Failed" self.log(self.result['msg'], "CRITICAL") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() return self else: self.log("Adding device to pnp database") - dev_add_response = self.add_pnp_device(self.want.get('pnp_params')[0]) + dev_add_response = self.add_pnp_device( + self.want.get('pnp_params')[0]) self.get_have().check_return_status() self.have["deviceInfo"] = dev_add_response.get("deviceInfo") - self.log("Response from API 'add device' for single device addition: {0}".format(str(dev_add_response)), "DEBUG") + self.log("Response from API 'add device' for single device addition: {0}".format( + str(dev_add_response)), "DEBUG") claim_params = self.get_claim_params() claim_params["deviceId"] = dev_add_response.get("id") claim_response = self.claim_device_site(claim_params) - self.log("Response from API 'claim a device to a site' for a single claiming: {0}".format(str(claim_response)), "DEBUG") + self.log("Response from API 'claim a device to a site' for a single claiming: {0}".format( + str(claim_response)), "DEBUG") if claim_response.get("response") == "Device Claimed" and self.have["deviceInfo"]: self.result['msg'] = "Device Added and Claimed Successfully" @@ -978,18 +1018,23 @@ class instance for further use. else: self.msg = "Device Claim Failed" self.log(self.result['msg'], "CRITICAL") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() return self prov_dev_response = self.pnp_device_count(provisioned_count_params) - self.log("Response from 'get device count' API for provisioned devices: {0}".format(str(prov_dev_response)), "DEBUG") + self.log("Response from 'get device count' API for provisioned devices: {0}".format( + str(prov_dev_response)), "DEBUG") plan_dev_response = self.pnp_device_count(planned_count_params) - self.log("Response from 'get_device_count' API for devices in planned state: {0}".format(str(plan_dev_response)), "DEBUG") + self.log("Response from 'get_device_count' API for devices in planned state: {0}".format( + str(plan_dev_response)), "DEBUG") - dev_details_response = self.get_device_by_id_pnp(self.have["device_id"]) - self.log("Response from 'get_device_by_id' API for device details: {0}".format(str(dev_details_response)), "DEBUG") + dev_details_response = self.get_device_by_id_pnp( + self.have["device_id"]) + self.log("Response from 'get_device_by_id' API for device details: {0}".format( + str(dev_details_response)), "DEBUG") is_stack = False if dev_details_response.get("deviceInfo").get("stack"): @@ -1003,10 +1048,12 @@ class instance for further use. self.log(self.result['msg'], "WARNING") return self - update_payload = {"deviceInfo": self.want.get('pnp_params')[0].get("deviceInfo")} + update_payload = {"deviceInfo": self.want.get( + 'pnp_params')[0].get("deviceInfo")} update_payload["deviceInfo"]["stack"] = is_stack - self.log("The request sent for 'update_device' API for device's config update: {0}".format(update_payload), "DEBUG") + self.log("The request sent for 'update_device' API for device's config update: {0}".format( + update_payload), "DEBUG") update_response = self.dnac_apply['exec']( family="device_onboarding_pnp", function="update_device", @@ -1014,7 +1061,8 @@ class instance for further use. "payload": update_payload}, op_modifies=True, ) - self.log("Response from 'update_device' API for device's config update: {0}".format(str(update_response)), "DEBUG") + self.log("Response from 'update_device' API for device's config update: {0}".format( + str(update_response)), "DEBUG") if pnp_state == "Error": reset_paramters = self.get_reset_params() @@ -1024,7 +1072,8 @@ class instance for further use. params={"payload": reset_paramters}, op_modifies=True, ) - self.log("Response from 'update_device' API for errored state resolution: {0}".format(str(reset_response)), "DEBUG") + self.log("Response from 'update_device' API for errored state resolution: {0}".format( + str(reset_response)), "DEBUG") self.result['msg'] = "Device reset done Successfully" self.log(self.result['msg'], "INFO") self.result['response'] = reset_response @@ -1046,10 +1095,12 @@ class instance for further use. return self claim_params = self.get_claim_params() - self.log("Parameters for claiming the device: {0}".format(str(claim_params)), "DEBUG") + self.log("Parameters for claiming the device: {0}".format( + str(claim_params)), "DEBUG") claim_response = self.claim_device_site(claim_params) - self.log("Response from 'claim_a_device_to_a_site' API for claiming: {0}".format(str(claim_response)), "DEBUG") + self.log("Response from 'claim_a_device_to_a_site' API for claiming: {0}".format( + str(claim_response)), "DEBUG") if claim_response.get("response") == "Device Claimed": self.result['msg'] = "Only Device Claimed Successfully" @@ -1079,8 +1130,10 @@ def get_diff_deleted(self): devices_deleted = [] devices_to_delete = self.want.get("pnp_params")[:] for device in devices_to_delete: - multi_device_response = self.get_device_list_pnp(device["deviceInfo"]["serialNumber"]) - self.log("Response from 'get_device_list' API for claiming: {0}".format(str(multi_device_response)), "DEBUG") + multi_device_response = self.get_device_list_pnp( + device["deviceInfo"]["serialNumber"]) + self.log("Response from 'get_device_list' API for claiming: {0}".format( + str(multi_device_response)), "DEBUG") if multi_device_response: device_id = multi_device_response.get("id") @@ -1094,7 +1147,8 @@ def get_diff_deleted(self): self.log("Device details for the deleted device with \ serial number '{0}': {1}".format(device["deviceInfo"]["serialNumber"], str(response)), "DEBUG") if response.get("deviceInfo", {}).get("state") == "Deleted": - devices_deleted.append(device["deviceInfo"]["serialNumber"]) + devices_deleted.append( + device["deviceInfo"]["serialNumber"]) self.want.get("pnp_params").remove(device) else: self.result['response'] = response @@ -1105,7 +1159,8 @@ def get_diff_deleted(self): self.result['changed'] = True self.result['response'] = devices_deleted self.result['diff'] = self.want.get("pnp_params") - self.result['msg'] = "{0} Device(s) Deleted Successfully".format(len(devices_deleted)) + self.result['msg'] = "{0} Device(s) Deleted Successfully".format( + len(devices_deleted)) self.log(self.result['msg'], "INFO") else: self.result['msg'] = "Device(s) Not Found" @@ -1132,7 +1187,8 @@ def verify_diff_merged(self, config): self.log("Desired State (want): {0}".format(str(config)), "INFO") # Code to validate Cisco Catalyst Center config for merged state for device in self.want.get("pnp_params"): - device_response = self.get_device_list_pnp(device["deviceInfo"]["serialNumber"]) + device_response = self.get_device_list_pnp( + device["deviceInfo"]["serialNumber"]) if (device_response and (len(device_response) == 1)): msg = ( @@ -1167,7 +1223,8 @@ def verify_diff_deleted(self, config): self.log("Desired State (want): {0}".format(str(config)), "INFO") # Code to validate Cisco Catalyst Center config for deleted state for device in self.want.get("pnp_params"): - device_response = self.get_device_list_pnp(device["deviceInfo"]["serialNumber"]) + device_response = self.get_device_list_pnp( + device["deviceInfo"]["serialNumber"]) if not (device_response and (len(device_response) == 1)): msg = ( @@ -1207,17 +1264,21 @@ def get_device_list_pnp(self, serial_number): if response and isinstance(response, list) and len(response) == 1: self.device_response = response[0] - self.log("Successfully retrieved PNP device details for serial number: {0}".format(serial_number), "INFO") + self.log("Successfully retrieved PNP device details for serial number: {0}".format( + serial_number), "INFO") return self.device_response - msg = "No device found with serial number: {0}".format(serial_number) + msg = "No device found with serial number: {0}".format( + serial_number) self.log(msg, "WARNING") return None except Exception as e: - msg = "An error occurred while retrieving device with serial number {0}: {1}".format(serial_number, str(e)) + msg = "An error occurred while retrieving device with serial number {0}: {1}".format( + serial_number, str(e)) self.log(msg + str(e), "WARNING") - self.set_operation_result("failed", False, msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, msg, "ERROR").check_return_status() def get_device_by_id_pnp(self, device_id): """ @@ -1233,7 +1294,8 @@ def get_device_by_id_pnp(self, device_id): Example: passing device details and getting pnp device details response """ - self.log("Attempting to retrieve PNP device details for device id: {0}".format(device_id), "INFO") + self.log("Attempting to retrieve PNP device details for device id: {0}".format( + device_id), "INFO") try: device_details_response = self.dnac_apply['exec']( family="device_onboarding_pnp", @@ -1243,18 +1305,22 @@ def get_device_by_id_pnp(self, device_id): # Check if the response contains the expected data if device_details_response: self.device_response = device_details_response # Update the instance attribute - self.log("Successfully retrieved PNP device details for device id: {0}".format(device_id), "INFO") + self.log("Successfully retrieved PNP device details for device id: {0}".format( + device_id), "INFO") return self.device_response # If no device found, raise an error msg = "No device found with device id: {0}".format(device_id) self.log(msg, "WARNING") - self.set_operation_result("failed", False, msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, msg, "ERROR").check_return_status() except Exception as e: - msg = "An error occurred while retrieving device with device id {0}: {1}".format(device_id, str(e)) + msg = "An error occurred while retrieving device with device id {0}: {1}".format( + device_id, str(e)) self.log(msg + str(e), "WARNING") - self.set_operation_result("failed", False, msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, msg, "ERROR").check_return_status() def add_pnp_device(self, pnp_params): """ @@ -1270,7 +1336,8 @@ def add_pnp_device(self, pnp_params): Example: passing device details and getting pnp device details response """ - self.log("Attempting to add PNP device with parameters: {0}".format(pnp_params), "INFO") + self.log("Attempting to add PNP device with parameters: {0}".format( + pnp_params), "INFO") try: device_add_response = self.dnac_apply['exec']( family="device_onboarding_pnp", @@ -1280,18 +1347,22 @@ def add_pnp_device(self, pnp_params): ) if device_add_response: self.device_response = device_add_response # Update the instance attribute - self.log("Successfully added PNP device with parameters: {0}".format(pnp_params), "INFO") + self.log("Successfully added PNP device with parameters: {0}".format( + pnp_params), "INFO") return self.device_response # If the response is empty, log a warning - msg = "No response received when trying to add the PNP device with parameters: {0}".format(pnp_params) + msg = "No response received when trying to add the PNP device with parameters: {0}".format( + pnp_params) self.log(msg, "WARNING") self.module.fail_json(msg=msg) except Exception as e: - msg = "Unable to add the PNP device with parameters: {0}. Error: {1}".format(pnp_params, str(e)) + msg = "Unable to add the PNP device with parameters: {0}. Error: {1}".format( + pnp_params, str(e)) self.log(msg + str(e), "WARNING") - self.set_operation_result("failed", False, msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, msg, "ERROR").check_return_status() def pnp_device_count(self, pnp_params): """ @@ -1307,7 +1378,8 @@ def pnp_device_count(self, pnp_params): Example: passing device param and getting pnp device count response """ - self.log("Attempting to get PNP device count with parameters: {0}".format(pnp_params), "INFO") + self.log("Attempting to get PNP device count with parameters: {0}".format( + pnp_params), "INFO") try: prov_dev_response = self.dnac_apply['exec']( family="device_onboarding_pnp", @@ -1315,18 +1387,23 @@ def pnp_device_count(self, pnp_params): params=pnp_params, ) if prov_dev_response: - self.log("Successfully retrieved PNP device count: {0}".format(prov_dev_response), "INFO") + self.log("Successfully retrieved PNP device count: {0}".format( + prov_dev_response), "INFO") return prov_dev_response # If the response is empty, log a warning - msg = "No response received when trying to get the PNP device count for parameters: {0}".format(pnp_params) + msg = "No response received when trying to get the PNP device count for parameters: {0}".format( + pnp_params) self.log(msg, "WARNING") - self.set_operation_result("failed", False, msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, msg, "ERROR").check_return_status() except Exception as e: - msg = "Unable to get the PNP device count for parameters: {0}. Error: {1}".format(pnp_params, str(e)) + msg = "Unable to get the PNP device count for parameters: {0}. Error: {1}".format( + pnp_params, str(e)) self.log(msg + str(e), "WARNING") - self.set_operation_result("failed", False, msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, msg, "ERROR").check_return_status() def claim_device_site(self, claim_params): """ @@ -1342,7 +1419,8 @@ def claim_device_site(self, claim_params): Example: passing device claim param and getting pnp claim response """ - self.log("Attempting to claim device to site with parameters: {0}".format(claim_params), "INFO") + self.log("Attempting to claim device to site with parameters: {0}".format( + claim_params), "INFO") try: claim_response = self.dnac_apply['exec']( family="device_onboarding_pnp", @@ -1351,18 +1429,23 @@ def claim_device_site(self, claim_params): params=claim_params, ) if claim_response: - self.log("Successfully claimed device to site: {0}".format(claim_response), "INFO") + self.log("Successfully claimed device to site: {0}".format( + claim_response), "INFO") return claim_response # If the response is empty, log a warning - msg = "No response received when trying to claim the device to site with parameters: {0}".format(claim_params) + msg = "No response received when trying to claim the device to site with parameters: {0}".format( + claim_params) self.log(msg, "WARNING") - self.set_operation_result("failed", False, msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, msg, "ERROR").check_return_status() except Exception as e: - msg = "Unable to claim the device to site with parameters: {0}. Error: {1}".format(claim_params, str(e)) + msg = "Unable to claim the device to site with parameters: {0}. Error: {1}".format( + claim_params, str(e)) self.log(msg + str(e), "WARNING") - self.set_operation_result("failed", False, msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, msg, "ERROR").check_return_status() def main(): @@ -1408,7 +1491,8 @@ def main(): ccc_pnp.get_have().check_return_status() ccc_pnp.get_diff_state_apply[state]().check_return_status() if config_verify: - ccc_pnp.verify_diff_state_apply[state](config).check_return_status() + ccc_pnp.verify_diff_state_apply[state]( + config).check_return_status() module.exit_json(**ccc_pnp.result) diff --git a/plugins/modules/provision_intent.py b/plugins/modules/provision_intent.py index 1c19ed0c7b..d60dc03085 100644 --- a/plugins/modules/provision_intent.py +++ b/plugins/modules/provision_intent.py @@ -4,6 +4,13 @@ # Copyright (c) 2021, Cisco Systems # 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 +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts +) +from ansible.module_utils.basic import AnsibleModule +import re +import time __metaclass__ = type __author__ = ("Abinash Mishra") @@ -160,13 +167,6 @@ "msg": String } """ -import time -import re -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts -) class Dnacprovision(DnacBase): @@ -174,11 +174,11 @@ class Dnacprovision(DnacBase): """ Class containing member attributes for provision intent module """ + def __init__(self, module): super().__init__(module) def validate_input(self): - """ Validate the fields provided in the playbook. Checks the configuration provided in the playbook against a predefined specification @@ -246,7 +246,8 @@ def get_dev_type(self): dev_response = self.dnac_apply['exec']( family="devices", function='get_network_device_by_ip', - params={"ip_address": self.validated_config[0]["management_ip_address"]}, + params={ + "ip_address": self.validated_config[0]["management_ip_address"]}, op_modifies=True ) @@ -390,7 +391,8 @@ def get_wireless_params(self): ] for ap_loc in wireless_params[0]["managedAPLocations"]: if self.get_site_type(site_name=ap_loc) != "floor": - self.module.fail_json(msg="Managed AP Location must be a floor", response=[]) + self.module.fail_json( + msg="Managed AP Location must be a floor", response=[]) wireless_params[0]["dynamicInterfaces"] = [] for interface in self.validated_config[0].get("dynamic_interfaces"): @@ -406,11 +408,13 @@ def get_wireless_params(self): response = self.dnac_apply['exec']( family="devices", function='get_network_device_by_ip', - params={"management_ip_address": self.validated_config[0]["management_ip_address"]}, + params={ + "management_ip_address": self.validated_config[0]["management_ip_address"]}, op_modifies=True ) - wireless_params[0]["deviceName"] = response.get("response")[0].get("hostname") + wireless_params[0]["deviceName"] = response.get("response")[ + 0].get("hostname") return wireless_params def get_want(self): @@ -577,7 +581,6 @@ def get_diff_deleted(self): def main(): - """ main entry point for module execution """ diff --git a/plugins/modules/provision_workflow_manager.py b/plugins/modules/provision_workflow_manager.py index 5e68d55c8b..f7979a16bd 100644 --- a/plugins/modules/provision_workflow_manager.py +++ b/plugins/modules/provision_workflow_manager.py @@ -4,9 +4,17 @@ # Copyright (c) 2024, Cisco Systems # 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 +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts +) +from ansible.module_utils.basic import AnsibleModule +import re +import time __metaclass__ = type -__author__ = ("Abinash Mishra, Madhan Sankaranarayanan, Syed Khadeer Ahmed, Ajith Andrew J") +__author__ = ( + "Abinash Mishra, Madhan Sankaranarayanan, Syed Khadeer Ahmed, Ajith Andrew J") DOCUMENTATION = r""" --- @@ -338,13 +346,6 @@ "msg": String } """ -import time -import re -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts -) class Provision(DnacBase): @@ -352,11 +353,11 @@ class Provision(DnacBase): """ Class containing member attributes for provision workflow module """ + def __init__(self, module): super().__init__(module) def validate_input(self, state=None): - """ Validate the fields provided in the playbook. Checks the configuration provided in the playbook against a predefined specification @@ -398,7 +399,8 @@ def validate_input(self, state=None): "force_provisioning": {'type': 'bool', 'required': False, "default": False} } if state == "merged": - provision_spec["site_name_hierarchy"] = {'type': 'str', 'required': True} + provision_spec["site_name_hierarchy"] = { + 'type': 'str', 'required': True} missing_params = [] for config_item in self.config: if "site_name_hierarchy" not in config_item or config_item["site_name_hierarchy"] is None: @@ -407,7 +409,8 @@ def validate_input(self, state=None): missing_params.append("management_ip_address") if missing_params: - self.msg = "Missing or invalid required parameter(s): {0}".format(', '.join(missing_params)) + self.msg = "Missing or invalid required parameter(s): {0}".format( + ', '.join(missing_params)) self.status = "failed" return self @@ -422,7 +425,8 @@ def validate_input(self, state=None): return self self.validated_config = valid_provision - self.msg = "Successfully validated playbook configuration parameters using 'validate_input': {0}".format(str(valid_provision)) + self.msg = "Successfully validated playbook configuration parameters using 'validate_input': {0}".format( + str(valid_provision)) self.log(str(self.msg), "INFO") self.status = "success" return self @@ -446,13 +450,15 @@ def get_dev_type(self): dev_response = self.dnac_apply['exec']( family="devices", function='get_network_device_by_ip', - params={"ip_address": self.validated_config["management_ip_address"]} + params={ + "ip_address": self.validated_config["management_ip_address"]} ) except Exception as e: self.log(str(e), "ERROR") self.module.fail_json(msg=str(e)) - self.log("The device response from 'get_network_device_by_ip' API is {0}".format(str(dev_response)), "DEBUG") + self.log("The device response from 'get_network_device_by_ip' API is {0}".format( + str(dev_response)), "DEBUG") dev_dict = dev_response.get("response") device_family = dev_dict["family"] @@ -482,14 +488,17 @@ def get_device_id(self): dev_response = self.dnac_apply['exec']( family="devices", function='get_network_device_by_ip', - params={"ip_address": self.validated_config["management_ip_address"]} + params={ + "ip_address": self.validated_config["management_ip_address"]} ) - self.log("The device response from 'get_network_device_by_ip' API is {0}".format(str(dev_response)), "DEBUG") + self.log("The device response from 'get_network_device_by_ip' API is {0}".format( + str(dev_response)), "DEBUG") dev_dict = dev_response.get("response") device_id = dev_dict.get("id") - self.log("Device ID of the device with IP address {0} is {1}".format(self.validated_config["management_ip_address"], device_id), "INFO") + self.log("Device ID of the device with IP address {0} is {1}".format( + self.validated_config["management_ip_address"], device_id), "INFO") return device_id def get_serial_number(self): @@ -510,18 +519,22 @@ def get_serial_number(self): response = self.dnac_apply['exec']( family="devices", function='get_network_device_by_ip', - params={"ip_address": self.validated_config["management_ip_address"]} + params={ + "ip_address": self.validated_config["management_ip_address"]} ) except Exception as e: - self.log("An error occurred while fetching the serial number: {0}".format(str(e)), "ERROR") + self.log("An error occurred while fetching the serial number: {0}".format( + str(e)), "ERROR") return None if not (response or response.get("response")): - self.log("No response received from 'get_network_device_by_ip' API or it's invalid.", "ERROR") + self.log( + "No response received from 'get_network_device_by_ip' API or it's invalid.", "ERROR") return None - self.log("The device response from 'get_network_device_by_ip' API is {0}".format(str(response)), "DEBUG") + self.log("The device response from 'get_network_device_by_ip' API is {0}".format( + str(response)), "DEBUG") dev_dict = response.get("response") serial_number = dev_dict.get("serialNumber") @@ -529,7 +542,8 @@ def get_serial_number(self): self.log("Serial number not found in the response.", "ERROR") return None - self.log("Serial Number of the device is {0}".format(str(serial_number)), "INFO") + self.log("Serial Number of the device is {0}".format( + str(serial_number)), "INFO") return serial_number @@ -557,9 +571,11 @@ def get_task_status(self, task_id=None): function='get_task_by_id', params=params ) - self.log("Response collected from 'get_task_by_id' API is {0}".format(str(response)), "DEBUG") + self.log("Response collected from 'get_task_by_id' API is {0}".format( + str(response)), "DEBUG") response = response.response - self.log("Task status for the task id {0} is {1}".format(str(task_id), str(response.get("progress"))), "INFO") + self.log("Task status for the task id {0} is {1}".format( + str(task_id), str(response.get("progress"))), "INFO") if response.get('isError') or re.search( 'failed', response.get('progress'), flags=re.IGNORECASE ): @@ -569,7 +585,8 @@ def get_task_status(self, task_id=None): return False if ( - response.get('progress') in ["TASK_PROVISION", "TASK_MODIFY_PUT"] + response.get('progress') in [ + "TASK_PROVISION", "TASK_MODIFY_PUT"] and response.get("isError") is False ) or "deleted successfully" in response.get('progress'): @@ -604,8 +621,10 @@ def get_execution_status_wireless(self, execution_id=None): function="get_business_api_execution_details", params=params ) - self.log("Response collected from 'get_business_api_execution_details' API is {0}".format(str(response)), "DEBUG") - self.log("Execution status for the execution id {0} is {1}".format(str(execution_id), str(response.get("status"))), "INFO") + self.log("Response collected from 'get_business_api_execution_details' API is {0}".format( + str(response)), "DEBUG") + self.log("Execution status for the execution id {0} is {1}".format( + str(execution_id), str(response.get("status"))), "INFO") if response.get('bapiError') or response.get("status") == "FAILURE": if response.get("bapiError") == "Device was already provisioned , please use provision update API to reprovision the device": msg = "Performing reprovisioning of wireless device" @@ -659,7 +678,8 @@ def get_site_type(self, site_name_hierarchy=None): for item in site_additional_info: if item["nameSpace"] == "Location": site_type = item.get("attributes").get("type") - self.log("Site type for site name '{1}' : {0}".format(site_type, site_name_hierarchy), "INFO") + self.log("Site type for site name '{1}' : {0}".format( + site_type, site_name_hierarchy), "INFO") return site_type @@ -676,22 +696,25 @@ def is_device_assigned_to_site(self, uuid): """ - self.log("Checking site assignment for device with UUID: {0}".format(uuid), "INFO") + self.log( + "Checking site assignment for device with UUID: {0}".format(uuid), "INFO") try: site_response = self.dnac_apply['exec']( family="devices", function='get_device_detail', - params={"search_by": uuid , + params={"search_by": uuid, "identifier": "uuid"} ) - self.log("Response collected from the API 'get_device_detail' {0}".format(site_response)) + self.log("Response collected from the API 'get_device_detail' {0}".format( + site_response)) site_response = site_response.get("response") if site_response.get("location"): return True else: return False except Exception as e: - msg = "Failed to find device with UUID {0} due to: {1}".format(uuid, e) + msg = "Failed to find device with UUID {0} due to: {1}".format( + uuid, e) self.log(msg, "CRITICAL") self.module.fail_json(msg=msg) @@ -708,7 +731,8 @@ def get_device_site_by_uuid(self, uuid): None otherwise. """ - self.log("Checking site assignment for device with UUID: {0}".format(uuid), "INFO") + self.log( + "Checking site assignment for device with UUID: {0}".format(uuid), "INFO") try: site_response = self.dnac_apply['exec']( @@ -716,18 +740,21 @@ def get_device_site_by_uuid(self, uuid): function='get_device_detail', params={"search_by": uuid, "identifier": "uuid"} ) - self.log("Response collected from the API 'get_device_detail': {0}".format(site_response)) + self.log("Response collected from the API 'get_device_detail': {0}".format( + site_response)) site_response = site_response.get("response") if site_response and site_response.get("location"): location = site_response.get("location") return location else: - self.log("No site assignment found for device with UUID: {0}".format(uuid), "INFO") + self.log( + "No site assignment found for device with UUID: {0}".format(uuid), "INFO") return None except Exception as e: - msg = "Failed to find device with location for UUID {0} due to: {1}".format(uuid, e) + msg = "Failed to find device with location for UUID {0} due to: {1}".format( + uuid, e) self.log(msg, "CRITICAL") self.module.fail_json(msg=msg) @@ -773,7 +800,8 @@ def get_wired_params(self): "site_id": site_id } - self.log("Parameters collected for the provisioning of wired device:{0}".format(wired_params), "INFO") + self.log("Parameters collected for the provisioning of wired device:{0}".format( + wired_params), "INFO") return wired_params def get_wireless_params(self): @@ -803,11 +831,13 @@ def get_wireless_params(self): ] if self.compare_dnac_versions(self.get_ccc_version(), "2.3.5.3") <= 0: - self.log("Checking for managed AP locations in Catalyst Center version <= 2.3.5.3", "DEBUG") + self.log( + "Checking for managed AP locations in Catalyst Center version <= 2.3.5.3", "DEBUG") ap_locations = wireless_params[0].get("managedAPLocations") if not (ap_locations and isinstance(ap_locations, list)): - self.log("Validating AP locations: {0}".format(ap_locations), "DEBUG") + self.log("Validating AP locations: {0}".format( + ap_locations), "DEBUG") msg = "Missing Managed AP Locations: Please specify the intended location(s) for the wireless device \ within the site hierarchy." self.log(msg, "CRITICAL") @@ -815,10 +845,12 @@ def get_wireless_params(self): for ap_loc in self.validated_config.get("managed_ap_locations"): site_type = self.get_site_type(site_name_hierarchy=ap_loc) - self.log("Checking site type for AP location '{0}', resolved type: '{1}'".format(ap_loc, site_type), "DEBUG") + self.log("Checking site type for AP location '{0}', resolved type: '{1}'".format( + ap_loc, site_type), "DEBUG") if site_type != "floor": self.log("Managed AP Location must be a floor", "CRITICAL") - self.module.fail_json(msg="Managed AP Location must be a floor", response=[]) + self.module.fail_json( + msg="Managed AP Location must be a floor", response=[]) wireless_params[0]["dynamicInterfaces"] = [] if self.validated_config.get("dynamic_interfaces"): @@ -833,10 +865,13 @@ def get_wireless_params(self): } wireless_params[0]["dynamicInterfaces"].append(interface_dict) - wireless_params[0]["skip_ap_provision"] = self.validated_config.get("skip_ap_provision") - primary_ap_location = self.validated_config.get("primary_managed_ap_Locations") or self.validated_config.get("managed_ap_locations") + wireless_params[0]["skip_ap_provision"] = self.validated_config.get( + "skip_ap_provision") + primary_ap_location = self.validated_config.get( + "primary_managed_ap_Locations") or self.validated_config.get("managed_ap_locations") wireless_params[0]["primaryManagedAPLocationsSiteIds"] = primary_ap_location - wireless_params[0]["secondaryManagedAPLocationsSiteIds"] = self.validated_config.get("secondary_managed_ap_locations") + wireless_params[0]["secondaryManagedAPLocationsSiteIds"] = self.validated_config.get( + "secondary_managed_ap_locations") if self.validated_config.get("rolling_ap_upgrade"): rolling_ap_upgrade = self.validated_config["rolling_ap_upgrade"] @@ -845,13 +880,17 @@ def get_wireless_params(self): response = self.dnac_apply['exec']( family="devices", function='get_network_device_by_ip', - params={"ip_address": self.validated_config["management_ip_address"]} + params={ + "ip_address": self.validated_config["management_ip_address"]} ) - self.log("Response collected from 'get_network_device_by_ip' is:{0}".format(str(response)), "DEBUG") - wireless_params[0]["deviceName"] = response.get("response").get("hostname") + self.log("Response collected from 'get_network_device_by_ip' is:{0}".format( + str(response)), "DEBUG") + wireless_params[0]["deviceName"] = response.get( + "response").get("hostname") wireless_params[0]["device_id"] = response.get("response").get("id") - self.log("Parameters collected for the provisioning of wireless device:{0}".format(wireless_params), "INFO") + self.log("Parameters collected for the provisioning of wireless device:{0}".format( + wireless_params), "INFO") return wireless_params def get_want(self, config): @@ -879,7 +918,8 @@ def get_want(self, config): elif self.want["device_type"] == "wireless": self.want["prov_params"] = self.get_wireless_params() else: - self.log("Passed devices are neither wired or wireless devices", "WARNING") + self.log( + "Passed devices are neither wired or wireless devices", "WARNING") self.msg = "Successfully collected all parameters from playbook " + \ "for comparison" @@ -924,18 +964,21 @@ def perform_wireless_reprovision(self): params={"payload": self.want.get("prov_params"), "headers": headers_payload} ) - self.log("Wireless provisioning response collected from 'provision_update' API is: {0}".format(str(response)), "DEBUG") + self.log("Wireless provisioning response collected from 'provision_update' API is: {0}".format( + str(response)), "DEBUG") execution_id = response.get("executionId") self.get_execution_status_wireless(execution_id=execution_id) self.result["changed"] = True - self.result['msg'] = "Wireless device with IP address {0} got re-provisioned successfully".format(self.validated_config["management_ip_address"]) + self.result['msg'] = "Wireless device with IP address {0} got re-provisioned successfully".format( + self.validated_config["management_ip_address"]) self.result['diff'] = self.validated_config self.result['response'] = execution_id self.log(self.result['msg'], "INFO") return self except Exception as e: self.log("Parameters are {0}".format(self.want)) - self.msg = "Error in wireless re-provisioning of {0} due to {1}".format(self.validated_config["management_ip_address"], e) + self.msg = "Error in wireless re-provisioning of {0} due to {1}".format( + self.validated_config["management_ip_address"], e) self.log(self.msg, "ERROR") self.status = "failed" return self @@ -993,10 +1036,13 @@ def get_device_provision_status(self, device_id): """ provision_id = None status = "failed" - device_management_ip = self.validated_config.get("management_ip_address") - self.log("Checking provisioning status for device with management IP '{0}' and ID '{1}'".format(device_management_ip, device_id), "DEBUG") + device_management_ip = self.validated_config.get( + "management_ip_address") + self.log("Checking provisioning status for device with management IP '{0}' and ID '{1}'".format( + device_management_ip, device_id), "DEBUG") if self.compare_dnac_versions(self.get_ccc_version(), "2.3.5.3") <= 0: - self.log("Using 'get_provisioned_wired_device' API for Catalyst Center version <= 2.3.5.3", "DEBUG") + self.log( + "Using 'get_provisioned_wired_device' API for Catalyst Center version <= 2.3.5.3", "DEBUG") try: status_response = self.dnac_apply['exec']( family="sda", @@ -1008,13 +1054,16 @@ def get_device_provision_status(self, device_id): ": {1}".format(device_management_ip, status_response), "DEBUG") status = status_response.get("status") else: - self.log("No status response received for wired device with management IP '{0}'".format(device_management_ip), "DEBUG") + self.log("No status response received for wired device with management IP '{0}'".format( + device_management_ip), "DEBUG") except Exception as e: - self.log("Device '{0}' is not provisioned due to error: {1}".format(device_management_ip, str(e)), "ERROR") + self.log("Device '{0}' is not provisioned due to error: {1}".format( + device_management_ip, str(e)), "ERROR") status = "failed" else: - self.log("Using 'get_provisioned_devices' API for Catalyst Center version > 2.3.5.3", "DEBUG") + self.log( + "Using 'get_provisioned_devices' API for Catalyst Center version > 2.3.5.3", "DEBUG") try: api_response = self.dnac._exec( family="sda", @@ -1024,21 +1073,26 @@ def get_device_provision_status(self, device_id): } ) if api_response: - self.log("API response for device '{0}' from 'get_provisioned_devices': {1}".format(device_management_ip, api_response), "DEBUG") + self.log("API response for device '{0}' from 'get_provisioned_devices': {1}".format( + device_management_ip, api_response), "DEBUG") provisioned_devices = api_response.get('response') - provision_id = provisioned_devices[0].get('id') if provisioned_devices else None + provision_id = provisioned_devices[0].get( + 'id') if provisioned_devices else None if provisioned_devices: status = "success" else: status = "failed" - self.log("Provisioned devices found for '{0}': {1}".format(device_management_ip, bool(provisioned_devices)), "DEBUG") + self.log("Provisioned devices found for '{0}': {1}".format( + device_management_ip, bool(provisioned_devices)), "DEBUG") else: - self.log("No API response received for device '{0}' provisioning check".format(device_management_ip), "DEBUG") + self.log("No API response received for device '{0}' provisioning check".format( + device_management_ip), "DEBUG") except Exception as e: - self.msg = "Error in 'get_provisioned_devices' for device '{0}': {1}".format(device_management_ip, str(e)) + self.msg = "Error in 'get_provisioned_devices' for device '{0}': {1}".format( + device_management_ip, str(e)) self.log(self.msg, "ERROR") self.result['response'] = self.msg @@ -1070,22 +1124,28 @@ def provision_wired_device(self, to_provisioning, to_force_provisioning): device_id = self.get_device_id() self.log("Device ID retrieved: {0}".format(device_id), "DEBUG") - provision_id , status = self.get_device_provision_status(device_id) - self.log("Provision ID and status for device ID '{0}': provision_id='{1}', status='{2}'".format(device_id, provision_id, status), "DEBUG") + provision_id, status = self.get_device_provision_status(device_id) + self.log("Provision ID and status for device ID '{0}': provision_id='{1}', status='{2}'".format( + device_id, provision_id, status), "DEBUG") site_exist, site_id = self.get_site_id(self.site_name) - self.log("Site ID retrieval for site '{0}': site_exist={1}, site_id='{2}'".format(self.site_name, site_exist, site_id), "DEBUG") + self.log("Site ID retrieval for site '{0}': site_exist={1}, site_id='{2}'".format( + self.site_name, site_exist, site_id), "DEBUG") - reprovision_param = [{"id": provision_id, "siteId": site_id, "networkDeviceId": device_id}] + reprovision_param = [{"id": provision_id, + "siteId": site_id, "networkDeviceId": device_id}] provision_params = [{"siteId": site_id, "networkDeviceId": device_id}] - self.log("Reprovision parameters prepared: {0}".format(reprovision_param), "DEBUG") - self.log("Provision parameters prepared: {0}".format(provision_params), "DEBUG") + self.log("Reprovision parameters prepared: {0}".format( + reprovision_param), "DEBUG") + self.log("Provision parameters prepared: {0}".format( + provision_params), "DEBUG") if status == "success": if not to_force_provisioning: self.result["changed"] = False - msg = "Wired Device '{0}' is already provisioned.".format(self.validated_config.get("management_ip_address")) + msg = "Wired Device '{0}' is already provisioned.".format( + self.validated_config.get("management_ip_address")) self.result['msg'] = msg self.result['response'] = msg self.log(msg, "INFO") @@ -1110,18 +1170,22 @@ def provision_wired_device(self, to_provisioning, to_force_provisioning): self.assign_device_to_site([device_id], self.site_name, site_id) else: if self.compare_dnac_versions(self.get_ccc_version(), "2.3.5.3") <= 0: - self.log("Catalyst Center Version is 2.3.5.3 or earlier; directly initializing provisioning with parameters.", "INFO") + self.log( + "Catalyst Center Version is 2.3.5.3 or earlier; directly initializing provisioning with parameters.", "INFO") self.initialize_wired_provisioning(provision_params) else: - self.log("Catalyst Center Version is later than 2.3.5.3; checking if device '{0}' is assigned to site.".format(device_id), "INFO") + self.log("Catalyst Center Version is later than 2.3.5.3; checking if device '{0}' is assigned to site.".format( + device_id), "INFO") is_device_assigned = self.is_device_assigned_to_site(device_id) if is_device_assigned: - self.log("Device '{0}' is already assigned to site. Proceeding with provisioning.".format(device_id), "DEBUG") + self.log("Device '{0}' is already assigned to site. Proceeding with provisioning.".format( + device_id), "DEBUG") self.initialize_wired_provisioning(provision_params) else: self.log("Device '{0}' is not assigned to site '{1}'. Assigning device and " "initializing provisioning.".format(device_id, self.site_name), "DEBUG") - self.assign_device_to_site([device_id], self.site_name, site_id) + self.assign_device_to_site( + [device_id], self.site_name, site_id) self.initialize_wired_provisioning(provision_params) return self @@ -1145,7 +1209,8 @@ def reprovision_wired_device(self, reprovision_param): the reprovisioning process, it logs the error and adjusts the status accordingly. """ if self.compare_dnac_versions(self.get_ccc_version(), "2.3.5.3") <= 0: - self.log("Starting reprovisioning of wired device using 're_provision_wired_device' API.", "DEBUG") + self.log( + "Starting reprovisioning of wired device using 're_provision_wired_device' API.", "DEBUG") try: response = self.dnac_apply['exec']( family="sda", @@ -1154,52 +1219,65 @@ def reprovision_wired_device(self, reprovision_param): params=self.want["prov_params"], ) taskid = response.get("taskId") - self.log("Received task ID '{0}' for wired device reprovisioning.".format(taskid), "DEBUG") + self.log("Received task ID '{0}' for wired device reprovisioning.".format( + taskid), "DEBUG") while True: result = self.get_task_details(taskid) - self.log("Checking task status for ID '{0}': {1}".format(taskid, result), "DEBUG") + self.log("Checking task status for ID '{0}': {1}".format( + taskid, result), "DEBUG") if "processcfs_complete=true" in result.get("data"): - self.msg = ("Wired Device '{0}' re-provisioning completed successfully.".format(self.device_ip)) + self.msg = ( + "Wired Device '{0}' re-provisioning completed successfully.".format(self.device_ip)) self.log(self.msg, "INFO") self.result["changed"] = True - self.result['msg'] = ("Wired Device '{0}' re-provisioning completed successfully.".format(self.device_ip)) + self.result['msg'] = ( + "Wired Device '{0}' re-provisioning completed successfully.".format(self.device_ip)) self.result['response'] = self.msg self.log(self.result['msg'], "INFO") return self elif result.get("isError") is True: - self.log("Error in task status for wired device reprovisioning. Task ID: '{0}'".format(taskid), "ERROR") + self.log("Error in task status for wired device reprovisioning. Task ID: '{0}'".format( + taskid), "ERROR") raise Exception except Exception as e: - self.msg = "Error in re-provisioning device '{0}' due to {1}".format(self.device_ip, str(e)) + self.msg = "Error in re-provisioning device '{0}' due to {1}".format( + self.device_ip, str(e)) self.log(self.msg, "ERROR") self.result['response'] = self.msg self.status = "failed" self.check_return_status() else: try: - self.log("Starting reprovisioning of wired device using 're_provision_devices' API.", "DEBUG") + self.log( + "Starting reprovisioning of wired device using 're_provision_devices' API.", "DEBUG") response = self.dnac_apply['exec']( family="sda", function="re_provision_devices", op_modifies=True, params={"payload": reprovision_param} ) - self.log("Received response for 're_provision_devices': {0}".format(response), "DEBUG") - self.check_tasks_response_status(response, api_name='re_provision_devices') - self.log("Task status after 're_provision_devices' execution: {0}".format(self.status), "DEBUG") + self.log("Received response for 're_provision_devices': {0}".format( + response), "DEBUG") + self.check_tasks_response_status( + response, api_name='re_provision_devices') + self.log("Task status after 're_provision_devices' execution: {0}".format( + self.status), "DEBUG") if self.status not in ["failed", "exited"]: - self.msg = ("Wired Device '{0}' re-provisioning completed successfully.".format(self.device_ip)) + self.msg = ( + "Wired Device '{0}' re-provisioning completed successfully.".format(self.device_ip)) self.log(self.msg, "INFO") self.result["changed"] = True - self.result['msg'] = "Re-Provision for device '{0}' done successfully".format(self.device_ip) + self.result['msg'] = "Re-Provision for device '{0}' done successfully".format( + self.device_ip) self.result['response'] = self.msg self.log(self.result['msg'], "INFO") except Exception as e: - self.msg = "Error in re-provisioning device '{0}' due to {1}".format(self.device_ip, str(e)) + self.msg = "Error in re-provisioning device '{0}' due to {1}".format( + self.device_ip, str(e)) self.log(self.msg, "ERROR") self.result['response'] = self.msg self.status = "failed" @@ -1226,7 +1304,8 @@ def initialize_wired_provisioning(self, provision_params): if self.compare_dnac_versions(self.get_ccc_version(), "2.3.5.3") <= 0: try: - self.log("Starting wired device provisioning with 'provision_wired_device' API.", "DEBUG") + self.log( + "Starting wired device provisioning with 'provision_wired_device' API.", "DEBUG") response = self.dnac_apply['exec']( family="sda", function="provision_wired_device", @@ -1234,9 +1313,11 @@ def initialize_wired_provisioning(self, provision_params): params=self.want["prov_params"], ) if response: - self.log("Received API response from 'provision_wired_device': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'provision_wired_device': {0}".format( + str(response)), "DEBUG") if self.status not in ["failed", "exited"]: - success_msg = "Provisioning of the device '{0}' completed successfully.".format(self.device_ip) + success_msg = "Provisioning of the device '{0}' completed successfully.".format( + self.device_ip) self.log(success_msg, "INFO") self.result["changed"] = True self.result['msg'] = success_msg @@ -1244,14 +1325,16 @@ def initialize_wired_provisioning(self, provision_params): return self except Exception as e: - self.msg = "Error in provisioning device '{0}' due to {1}".format(self.device_ip, str(e)) + self.msg = "Error in provisioning device '{0}' due to {1}".format( + self.device_ip, str(e)) self.log(self.msg, "ERROR") self.status = "failed" self.result['response'] = self.msg self.check_return_status() else: try: - self.log("Starting wired device provisioning with 'provision_devices' API.", "DEBUG") + self.log( + "Starting wired device provisioning with 'provision_devices' API.", "DEBUG") response = self.dnac._exec( family="sda", function='provision_devices', @@ -1259,10 +1342,13 @@ def initialize_wired_provisioning(self, provision_params): params={"payload": provision_params} ) if response: - self.log("Received API response from 'provision_devices': {0}".format(str(response)), "DEBUG") - self.check_tasks_response_status(response, api_name='provision_device') + self.log("Received API response from 'provision_devices': {0}".format( + str(response)), "DEBUG") + self.check_tasks_response_status( + response, api_name='provision_device') if self.status not in ["failed", "exited"]: - success_msg = "Provisioning of the device '{0}' completed successfully.".format(self.device_ip) + success_msg = "Provisioning of the device '{0}' completed successfully.".format( + self.device_ip) self.log(success_msg, "INFO") self.result["changed"] = True self.result['msg'] = success_msg @@ -1270,10 +1356,12 @@ def initialize_wired_provisioning(self, provision_params): return self except Exception as e: - self.msg = "Exception occurred during provisioning: {0}".format(str(e)) + self.msg = "Exception occurred during provisioning: {0}".format( + str(e)) self.log(self.msg, "ERROR") self.status = "failed" - self.result['response'] = "Error in provisioning device '{0}' due to {1}".format(self.device_ip, str(e)) + self.result['response'] = "Error in provisioning device '{0}' due to {1}".format( + self.device_ip, str(e)) self.check_return_status() def provision_wireless_device(self): @@ -1299,7 +1387,8 @@ def provision_wireless_device(self): prov_params = self.want.get("prov_params") if not prov_params or not isinstance(prov_params, list) or not prov_params[0]: - self.log("Error: 'prov_params' is missing or improperly formatted. Expected a non-empty list.", "ERROR") + self.log( + "Error: 'prov_params' is missing or improperly formatted. Expected a non-empty list.", "ERROR") self.status = "failed" self.result['response'] = "Provisioning aborted due to missing or invalid 'prov_params'." return self @@ -1307,13 +1396,18 @@ def provision_wireless_device(self): prov_params_data = prov_params[0] device_uid = prov_params_data.get("device_id") site_name = self.validated_config.get("site_name_hierarchy") - primary_ap_location = prov_params_data.get("primaryManagedAPLocationsSiteIds") - secondary_ap_location = prov_params_data.get("secondaryManagedAPLocationsSiteIds") + primary_ap_location = prov_params_data.get( + "primaryManagedAPLocationsSiteIds") + secondary_ap_location = prov_params_data.get( + "secondaryManagedAPLocationsSiteIds") - self.log("Provisioning wireless device with device_id: {0}".format(device_uid), "DEBUG") + self.log("Provisioning wireless device with device_id: {0}".format( + device_uid), "DEBUG") self.log("Site name: {0}".format(site_name), "DEBUG") - self.log("Primary AP location: {0}".format(primary_ap_location), "DEBUG") - self.log("Secondary AP location: {0}".format(secondary_ap_location), "DEBUG") + self.log("Primary AP location: {0}".format( + primary_ap_location), "DEBUG") + self.log("Secondary AP location: {0}".format( + secondary_ap_location), "DEBUG") site_exist, site_id = self.get_site_id(site_name) @@ -1324,19 +1418,26 @@ def provision_wireless_device(self): if primary_ap_location: self.log("Processing primary access point locations", "INFO") for primary_sites in primary_ap_location: - self.log("Retrieving site ID for primary location: {0}".format(primary_sites), "DEBUG") - site_exist, primary_ap_location_site_id = self.get_site_id(primary_sites) - primary_ap_location_site_id_list.append(primary_ap_location_site_id) + self.log("Retrieving site ID for primary location: {0}".format( + primary_sites), "DEBUG") + site_exist, primary_ap_location_site_id = self.get_site_id( + primary_sites) + primary_ap_location_site_id_list.append( + primary_ap_location_site_id) if secondary_ap_location: self.log("Processing secondary access point locations", "INFO") for secondary_sites in secondary_ap_location: - self.log("Retrieving site ID for secondary location: {0}".format(secondary_sites), "DEBUG") - site_exist, secondary_ap_location_site_id = self.get_site_id(secondary_sites) - secondary_ap_location_site_id_list.append(secondary_ap_location_site_id) + self.log("Retrieving site ID for secondary location: {0}".format( + secondary_sites), "DEBUG") + site_exist, secondary_ap_location_site_id = self.get_site_id( + secondary_sites) + secondary_ap_location_site_id_list.append( + secondary_ap_location_site_id) if self.compare_dnac_versions(self.get_ccc_version(), "2.3.5.3") <= 0: - self.log("Detected Catalyst Center version <= 2.3.5.3; using old provisioning method", "INFO") + self.log( + "Detected Catalyst Center version <= 2.3.5.3; using old provisioning method", "INFO") try: response = self.dnac_apply['exec']( family="wireless", @@ -1345,7 +1446,8 @@ def provision_wireless_device(self): params={"payload": self.want.get("prov_params")} ) execution_id = response.get("executionId") - self.log("Received execution ID for provisioning: {0}".format(execution_id), "DEBUG") + self.log("Received execution ID for provisioning: {0}".format( + execution_id), "DEBUG") self.get_execution_status_wireless(execution_id=execution_id) self.result["changed"] = True self.result['msg'] = "Wireless device provisioned successfully" @@ -1362,15 +1464,18 @@ def provision_wireless_device(self): self.check_return_status() else: - self.log("Detected Catalyst Center version > 2.3.5.3; using new provisioning method", "INFO") + self.log( + "Detected Catalyst Center version > 2.3.5.3; using new provisioning method", "INFO") self.log("Checking if device is assigned to the site", "INFO") is_device_assigned = self.is_device_assigned_to_site(device_uid) if not is_device_assigned: - self.log("Device {0} is not assigned to site {1}; assigning now.".format(device_uid, site_name), "INFO") + self.log("Device {0} is not assigned to site {1}; assigning now.".format( + device_uid, site_name), "INFO") self.assign_device_to_site([device_uid], site_name, site_id) if primary_ap_location or secondary_ap_location: - self.log("Assigning managed AP locations to device ID: {0}".format(device_uid), "INFO") + self.log("Assigning managed AP locations to device ID: {0}".format( + device_uid), "INFO") try: self.log("Assigning managed AP locations for the WLC", "INFO") response = self.dnac_apply['exec']( @@ -1384,22 +1489,29 @@ def provision_wireless_device(self): secondary_ap_location_site_id_list, } ) - self.log("API response from 'assign_managed_ap_locations_for_w_l_c': {}".format(str(response)), "DEBUG") + self.log("API response from 'assign_managed_ap_locations_for_w_l_c': {}".format( + str(response)), "DEBUG") if response: - self.log("Received API response from 'assign_managed_ap_locations_for_w_l_c': {0}".format(str(response)), "DEBUG") - self.check_tasks_response_status(response, api_name='assign_managed_ap_locations_for_w_l_c') + self.log("Received API response from 'assign_managed_ap_locations_for_w_l_c': {0}".format( + str(response)), "DEBUG") + self.check_tasks_response_status( + response, api_name='assign_managed_ap_locations_for_w_l_c') if self.status not in ["failed", "exited"]: - self.log("wireless Device '{0}' assign_managed_ap_locations_for_w_l_c completed successfully.".format(self.device_ip), "INFO") + self.log("wireless Device '{0}' assign_managed_ap_locations_for_w_l_c completed successfully.".format( + self.device_ip), "INFO") except Exception as e: - self.log("Exception occurred during 'assign_managed_ap_locations_for_w_l_c': {0}".format(str(e)), "ERROR") - self.msg = "Error in 'assign_managed_ap_locations_for_w_l_c' '{0}' due to {1}".format(self.device_ip, str(e)) + self.log("Exception occurred during 'assign_managed_ap_locations_for_w_l_c': {0}".format( + str(e)), "ERROR") + self.msg = "Error in 'assign_managed_ap_locations_for_w_l_c' '{0}' due to {1}".format( + self.device_ip, str(e)) self.log(self.msg, "ERROR") self.status = "failed" self.result['response'] = self.msg self.check_return_status() self.log(self.want.get("prov_params")) - self.log("Starting wireless controller provisioning for device ID: {0}".format(device_uid), "INFO") + self.log("Starting wireless controller provisioning for device ID: {0}".format( + device_uid), "INFO") prov_params = self.want.get("prov_params")[0] payload = { 'device_id': prov_params.get('device_id'), @@ -1416,29 +1528,35 @@ def provision_wireless_device(self): if v is not None: cleaned_interface[k] = v else: - self.log("No dynamic interfaces found in provisioning parameters", "DEBUG") + self.log( + "No dynamic interfaces found in provisioning parameters", "DEBUG") payload['interfaces'].append(cleaned_interface) - self.log("Processed dynamic interface: {0}".format(cleaned_interface), "DEBUG") + self.log("Processed dynamic interface: {0}".format( + cleaned_interface), "DEBUG") skip_ap_provision = prov_params.get('skip_ap_provision') self.log("Processing 'rolling_ap_upgrade' if it exists", "INFO") if skip_ap_provision is not None: payload['skipApProvision'] = skip_ap_provision - self.log("Set 'skip_ap_provision' to: {0}".format(skip_ap_provision), "DEBUG") + self.log("Set 'skip_ap_provision' to: {0}".format( + skip_ap_provision), "DEBUG") else: self.log("'skip_ap_provision' is not specified", "DEBUG") self.log("Processing rolling AP upgrade settings", "INFO") if 'rolling_ap_upgrade' in prov_params: - self.log("Found 'rolling_ap_upgrade' in provisioning parameters", "DEBUG") + self.log( + "Found 'rolling_ap_upgrade' in provisioning parameters", "DEBUG") rolling_ap_upgrade = {} for k, v in prov_params['rolling_ap_upgrade'].items(): if v is not None: rolling_ap_upgrade[k] = v - self.log("Processed 'rolling_ap_upgrade': {0}".format(rolling_ap_upgrade), "DEBUG") + self.log("Processed 'rolling_ap_upgrade': {0}".format( + rolling_ap_upgrade), "DEBUG") else: - self.log("No 'rolling_ap_upgrade' found in provisioning parameters", "DEBUG") + self.log( + "No 'rolling_ap_upgrade' found in provisioning parameters", "DEBUG") payload['rollingApUpgrade'] = rolling_ap_upgrade try: @@ -1450,18 +1568,25 @@ def provision_wireless_device(self): ) if response: - self.log("Received API response from 'wireless_controller_provision': {0}".format(str(response)), "DEBUG") - self.check_tasks_response_status(response, api_name='wireless_controller_provision') + self.log("Received API response from 'wireless_controller_provision': {0}".format( + str(response)), "DEBUG") + self.check_tasks_response_status( + response, api_name='wireless_controller_provision') if self.status not in ["failed", "exited"]: - self.log("wireless Device '{0}' provisioning completed successfully.".format(self.device_ip), "INFO") + self.log("wireless Device '{0}' provisioning completed successfully.".format( + self.device_ip), "INFO") self.result["changed"] = True - self.result['msg'] = "Provisioning of the wireless device '{0}' completed successfully.".format(self.device_ip) - self.result['response'] = "Provisioning of the wireless device '{0}' completed successfully.".format(self.device_ip) + self.result['msg'] = "Provisioning of the wireless device '{0}' completed successfully.".format( + self.device_ip) + self.result['response'] = "Provisioning of the wireless device '{0}' completed successfully.".format( + self.device_ip) self.log(self.result['msg'], "INFO") return self except Exception as e: - self.log("Exception occurred during provisioning: {0}".format(str(e)), "ERROR") - self.msg = "Error in provisioning wireless device '{0}' due to {1}".format(self.device_ip, str(e)) + self.log("Exception occurred during provisioning: {0}".format( + str(e)), "ERROR") + self.msg = "Error in provisioning wireless device '{0}' due to {1}".format( + self.device_ip, str(e)) self.log(self.msg, "ERROR") self.status = "failed" self.result['response'] = self.msg @@ -1487,7 +1612,7 @@ def get_diff_deleted(self): self.log(self.result['msg'], "CRITICAL") return self device_id = self.get_device_id() - provision_id , status = self.get_device_provision_status(device_id) + provision_id, status = self.get_device_provision_status(device_id) if status != "success": self.result['msg'] = "Device associated with the passed IP address is not provisioned" @@ -1504,7 +1629,8 @@ def get_diff_deleted(self): "device_management_ip_address": self.validated_config["management_ip_address"] }, ) - self.log("Response collected from the 'delete_provisioned_wired_device' API is : {0}".format(str(response)), "DEBUG") + self.log("Response collected from the 'delete_provisioned_wired_device' API is : {0}".format( + str(response)), "DEBUG") task_id = response.get("taskId") deletion_info = self.get_task_status(task_id=task_id) @@ -1522,11 +1648,14 @@ def get_diff_deleted(self): op_modifies=True, params={'networkDeviceId': device_id}, ) - self.log("Received API response from 'delete_provisioned_devices': {0}".format(str(response)), "DEBUG") - self.check_tasks_response_status(response, api_name='delete_provisioned_devices') + self.log("Received API response from 'delete_provisioned_devices': {0}".format( + str(response)), "DEBUG") + self.check_tasks_response_status( + response, api_name='delete_provisioned_devices') if self.status not in ["failed", "exited"]: self.result["changed"] = True - self.result['msg'] = "Deletion done Successfully for the device '{0}' ".format(self.validated_config["management_ip_address"]) + self.result['msg'] = "Deletion done Successfully for the device '{0}' ".format( + self.validated_config["management_ip_address"]) self.result['diff'] = self.validated_config self.result['response'] = self.result['msg'] self.log(self.result['msg'], "INFO") @@ -1555,9 +1684,11 @@ def verify_diff_merged(self): uuid = self.get_device_id() if provisioning is False: if self.is_device_assigned_to_site(uuid) is True: - self.log("Requested device is already added to the site {0}".format(site_name_hierarchy), "INFO") + self.log("Requested device is already added to the site {0}".format( + site_name_hierarchy), "INFO") else: - self.log("Requested device is not added to the site {0}".format(site_name_hierarchy), "INFO") + self.log("Requested device is not added to the site {0}".format( + site_name_hierarchy), "INFO") return self if device_type == "wired": @@ -1571,9 +1702,11 @@ def verify_diff_merged(self): ) except Exception: status_response = {} - self.log("Wired device's status Response collected from 'get_provisioned_wired_device' API is:{0}".format(str(status_response)), "DEBUG") + self.log("Wired device's status Response collected from 'get_provisioned_wired_device' API is:{0}".format( + str(status_response)), "DEBUG") status = status_response.get("status") - self.log("The provisioned status of the wired device is {0}".format(status), "INFO") + self.log("The provisioned status of the wired device is {0}".format( + status), "INFO") if status == "success": self.log("Requested wired device is alread provisioned", "INFO") @@ -1582,7 +1715,8 @@ def verify_diff_merged(self): self.log("Requested wired device is not provisioned", "INFO") else: - self.log("Currently we don't have any API in the Cisco Catalyst Center to fetch the provisioning details of wireless devices") + self.log( + "Currently we don't have any API in the Cisco Catalyst Center to fetch the provisioning details of wireless devices") self.status = "success" return self @@ -1615,25 +1749,28 @@ def verify_diff_deleted(self): ) except Exception: status_response = {} - self.log("Wired device's status Response collected from 'get_provisioned_wired_device' API is:{0}".format(str(status_response)), "DEBUG") + self.log("Wired device's status Response collected from 'get_provisioned_wired_device' API is:{0}".format( + str(status_response)), "DEBUG") status = status_response.get("status") - self.log("The provisioned status of the wired device is {0}".format(status), "INFO") + self.log("The provisioned status of the wired device is {0}".format( + status), "INFO") if status == "success": - self.log("Requested wired device is in provisioned state and is not unprovisioned", "INFO") + self.log( + "Requested wired device is in provisioned state and is not unprovisioned", "INFO") else: self.log("Requested wired device is unprovisioned", "INFO") else: - self.log("Currently we don't have any API in the Cisco Catalyst Center to fetch the provisioning details of wireless devices") + self.log( + "Currently we don't have any API in the Cisco Catalyst Center to fetch the provisioning details of wireless devices") self.status = "success" return self def main(): - """ main entry point for module execution """ @@ -1674,7 +1811,8 @@ def main(): ccc_provision.get_want(config).check_return_status() ccc_provision.get_diff_state_apply[state]().check_return_status() if config_verify: - ccc_provision.verify_diff_state_apply[state]().check_return_status() + ccc_provision.verify_diff_state_apply[state]( + ).check_return_status() module.exit_json(**ccc_provision.result) diff --git a/plugins/modules/rma_workflow_manager.py b/plugins/modules/rma_workflow_manager.py index 9090f64765..7b7032484b 100644 --- a/plugins/modules/rma_workflow_manager.py +++ b/plugins/modules/rma_workflow_manager.py @@ -4,8 +4,18 @@ # 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 +import time +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + validate_str +) +import json +import re __metaclass__ = type -__author__ = ("Trupti A Shetty, Mohamed Rafeek, Madhan Sankaranarayanan, Ajith Andrew J") +__author__ = ( + "Trupti A Shetty, Mohamed Rafeek, Madhan Sankaranarayanan, Ajith Andrew J") DOCUMENTATION = r""" @@ -293,16 +303,6 @@ } """ -import re -import json -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - validate_str -) -from ansible.module_utils.basic import AnsibleModule -import time - class DeviceReplacement(DnacBase): """Class containing member attributes for rma_workflow_manager module""" @@ -361,7 +361,8 @@ def validate_input(self): 'replacement_device_serial_number': {'required': False, 'type': 'str'} } - valid_param, invalid_params = validate_list_of_dicts(device_list, rma_spec) + valid_param, invalid_params = validate_list_of_dicts( + device_list, rma_spec) if invalid_params: self.msg = "Invalid parameters in playbook: {0}".format( "\n".join(invalid_params) @@ -380,8 +381,10 @@ def validate_input(self): filtered_config[key] = config[key] self.validated_config.append(filtered_config) - self.log("Validated config: {0}".format(self.pprint(self.validated_config)), "INFO") - self.msg = "Successfully validated playbook config params:{0}".format(str(self.validated_config[0])) + self.log("Validated config: {0}".format( + self.pprint(self.validated_config)), "INFO") + self.msg = "Successfully validated playbook config params:{0}".format( + str(self.validated_config[0])) self.log(self.msg, "INFO") self.status = "success" return self @@ -417,7 +420,8 @@ def get_want(self, config): self.log("Validation failed. Returning with status 'failed'.", "ERROR") return self - self.log("Desired State (want): {0}".format(str(self.pprint(self.want))), "INFO") + self.log("Desired State (want): {0}".format( + str(self.pprint(self.want))), "INFO") return self def get_have(self): @@ -469,45 +473,62 @@ def get_have(self): valid_identifier_found = True # Check if faulty device exists - faulty_device = self.device_exists(faulty_identifier, faulty_key) + faulty_device = self.device_exists( + faulty_identifier, faulty_key) if not faulty_device: - self.msg = "Faulty device '{0}' not found in Cisco Catalyst Center".format(faulty_identifier) + self.msg = "Faulty device '{0}' not found in Cisco Catalyst Center".format( + faulty_identifier) self.log(self.msg, "ERROR") self.status = "failed" return self have["faulty_device_id"] = faulty_device.get("device_id") - have["faulty_device_serial_number"] = faulty_device.get("serial_number") + have["faulty_device_serial_number"] = faulty_device.get( + "serial_number") have["faulty_device_name"] = faulty_device.get("device_name") - have["faulty_device_reachability_status"] = faulty_device.get("reachability_status") - have["faulty_device_platform_id"] = faulty_device.get("platform_id") + have["faulty_device_reachability_status"] = faulty_device.get( + "reachability_status") + have["faulty_device_platform_id"] = faulty_device.get( + "platform_id") have[faulty_key] = faulty_identifier have["faulty_device_exists"] = True - self.log("Faulty device '{0}' found in Cisco Catalyst Center".format(faulty_identifier), "INFO") + self.log("Faulty device '{0}' found in Cisco Catalyst Center".format( + faulty_identifier), "INFO") # Check if replacement device exists - replacement_device = self.device_exists(replacement_identifier, replacement_key) + replacement_device = self.device_exists( + replacement_identifier, replacement_key) if not replacement_device: - self.log("Replacement device '{0}' not found in inventory, checking in PnP...", "DEBUG") - replacement_device = self.pnp_device_exists(replacement_identifier, replacement_key) + self.log( + "Replacement device '{0}' not found in inventory, checking in PnP...", "DEBUG") + replacement_device = self.pnp_device_exists( + replacement_identifier, replacement_key) if not replacement_device: - self.msg = "Replacement device '{0}' not found in PnP".format(replacement_identifier) + self.msg = "Replacement device '{0}' not found in PnP".format( + replacement_identifier) self.log(self.msg, "ERROR") self.status = "failed" return self - have["replacement_device_id"] = replacement_device.get("device_id") - have["replacement_device_serial_number"] = replacement_device.get("serial_number") - have["replacement_device_name"] = replacement_device.get("device_name") - have["replacement_device_reachability_status"] = replacement_device.get("reachability_status") - have["replacement_device_platform_id"] = replacement_device.get("platform_id") - have["is_pnp_replacement_device"] = replacement_device.get("is_pnp_device") + have["replacement_device_id"] = replacement_device.get( + "device_id") + have["replacement_device_serial_number"] = replacement_device.get( + "serial_number") + have["replacement_device_name"] = replacement_device.get( + "device_name") + have["replacement_device_reachability_status"] = replacement_device.get( + "reachability_status") + have["replacement_device_platform_id"] = replacement_device.get( + "platform_id") + have["is_pnp_replacement_device"] = replacement_device.get( + "is_pnp_device") have[replacement_key] = replacement_identifier have["replacement_device_exists"] = True - self.log("Replacement device '{0}' found in Cisco Catalyst Center".format(replacement_identifier), "INFO") + self.log("Replacement device '{0}' found in Cisco Catalyst Center".format( + replacement_identifier), "INFO") break # Check if any valid identifier combination was not found @@ -517,7 +538,8 @@ def get_have(self): for key, value in config.items() if key in [item for sublist in identifier_keys for item in sublist] and value } - self.msg = "No valid device combination found in config. Provided values in config: {0}".format(provided_identifiers) + self.msg = "No valid device combination found in config. Provided values in config: {0}".format( + provided_identifiers) self.log(self.msg, "ERROR") self.status = "failed" return self @@ -529,8 +551,10 @@ def get_have(self): self.log(self.msg, "ERROR") self.status = "failed" else: - self.msg = "Successfully retrieved device details: {0}".format(self.pprint(config)) - self.log("Current State (have): {0}".format(self.pprint(self.have)), "INFO") + self.msg = "Successfully retrieved device details: {0}".format( + self.pprint(config)) + self.log("Current State (have): {0}".format( + self.pprint(self.have)), "INFO") self.log(self.msg, "INFO") self.status = "success" @@ -559,7 +583,8 @@ def rma_device_replacement_pre_check(self): self.status = "failed" return self - self.log("The faulty device and the replacement device belong to the same platform, family and series.", "DEBUG") + self.log( + "The faulty device and the replacement device belong to the same platform, family and series.", "DEBUG") if not self.have["is_pnp_replacement_device"]: if self.have["replacement_device_reachability_status"] != "Reachable": @@ -568,7 +593,8 @@ def rma_device_replacement_pre_check(self): self.status = "failed" return self - self.log("The replacement device '{0}' is reachable.".format(self.have.get("replacement_device_name")), "DEBUG") + self.log("The replacement device '{0}' is reachable.".format( + self.have.get("replacement_device_name")), "DEBUG") return self @@ -608,7 +634,8 @@ def pnp_device_exists(self, identifier, identifier_type): op_modifies=False, params=params ) - self.log("Received API response from 'get_device_list': {0}".format(self.pprint(response)), "DEBUG") + self.log("Received API response from 'get_device_list': {0}".format( + self.pprint(response)), "DEBUG") if response: device = response[0] @@ -627,7 +654,8 @@ def pnp_device_exists(self, identifier, identifier_type): else: self.log("Device not found in Cisco Catalyst Center", "ERROR") except Exception as e: - self.log("Exception occurred while querying device: {0}".format(str(e)), "ERROR") + self.log("Exception occurred while querying device: {0}".format( + str(e)), "ERROR") return {} @@ -668,28 +696,34 @@ def device_exists(self, identifier, identifier_type): op_modifies=False, params=params ) - self.log("Received API response from 'get_device_list': {0}".format(self.pprint(response)), "DEBUG") + self.log("Received API response from 'get_device_list': {0}".format( + self.pprint(response)), "DEBUG") device_param_list = {} if response and response.get('response'): if len(response['response']) > 0: device = response['response'][0] device_param_list["device_id"] = device.get('id') - device_param_list["serial_number"] = device.get('serialNumber') + device_param_list["serial_number"] = device.get( + 'serialNumber') device_param_list["device_name"] = device.get('hostname') - device_param_list["reachability_status"] = device.get('reachabilityStatus') + device_param_list["reachability_status"] = device.get( + 'reachabilityStatus') device_param_list["platform_id"] = device.get('platformId') device_param_list["is_pnp_device"] = False if device_param_list: return device_param_list - self.log("Device found but ID or serial number missing", "ERROR") + self.log( + "Device found but ID or serial number missing", "ERROR") else: self.log("Device not found in Cisco Catalyst Center", "ERROR") else: - self.log("No valid response received from Cisco Catalyst Center", "ERROR") + self.log( + "No valid response received from Cisco Catalyst Center", "ERROR") except Exception as e: - self.log("Exception occurred while querying device: {0}".format(str(e)), "ERROR") + self.log("Exception occurred while querying device: {0}".format( + str(e)), "ERROR") return {} @@ -717,13 +751,15 @@ def validate_device_replacement_params(self): for name_field in ['faulty_device_name', 'replacement_device_name']: if config.get(name_field): param_spec = dict(type="str", length_max=255) - validate_str(config[name_field], param_spec, name_field, errormsg) + validate_str(config[name_field], + param_spec, name_field, errormsg) # Validate IP addresses for ip_field in ['faulty_device_ip_address', 'replacement_device_ip_address']: if config.get(ip_field): if not self.is_valid_ipv4(config[ip_field]): - errormsg.append("{0}: Invalid IP Address '{1}' in playbook".format(ip_field, config[ip_field])) + errormsg.append("{0}: Invalid IP Address '{1}' in playbook".format( + ip_field, config[ip_field])) # Validate serial numbers serial_regex = re.compile(r'^[A-Z0-9]{11}$') @@ -734,12 +770,14 @@ def validate_device_replacement_params(self): serial_field, config[serial_field])) if errormsg: - self.msg = "Invalid parameters in playbook config: '{0}' ".format(str("\n".join(errormsg))) + self.msg = "Invalid parameters in playbook config: '{0}' ".format( + str("\n".join(errormsg))) self.log(self.msg, "ERROR") self.status = "failed" return self - self.msg = "Successfully validated config params:{0}".format(self.pprint(config)) + self.msg = "Successfully validated config params:{0}".format( + self.pprint(config)) self.log(self.msg, "INFO") self.status = "success" return self @@ -766,7 +804,8 @@ def device_ready_for_replacement_check(self): function='return_replacement_devices_with_details' ) devices = response.get("response", []) - self.log("Received API response from 'return_replacement_devices_with_details': {0}".format(self.pprint(response)), "DEBUG") + self.log("Received API response from 'return_replacement_devices_with_details': {0}".format( + self.pprint(response)), "DEBUG") for device in devices: if device.get("faultyDeviceSerialNumber") == self.have.get("faulty_device_serial_number"): @@ -808,7 +847,8 @@ def mark_faulty_device_for_replacement(self): function='mark_device_for_replacement', params=import_params ) - self.log("Received API response from 'mark_device_for_replacement': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'mark_device_for_replacement': {0}".format( + str(response)), "DEBUG") task_id = response.get("response", {}).get("taskId") task_result = self.check_rma_task_status( task_id, @@ -824,10 +864,12 @@ def mark_faulty_device_for_replacement(self): except Exception as e: self.status = "failed" - self.msg = "Exception occurred while marking device for replacement: {0}".format(str(e)) + self.msg = "Exception occurred while marking device for replacement: {0}".format( + str(e)) self.log(self.msg, "ERROR") - self.log("The device '{0}' is already in the 'READY-FOR-REPLACEMENT' state.".format(self.have.get("faulty_device_name")), "DEBUG") + self.log("The device '{0}' is already in the 'READY-FOR-REPLACEMENT' state.".format( + self.have.get("faulty_device_name")), "DEBUG") return self def get_diff_replaced(self, config): @@ -858,7 +900,8 @@ def get_diff_replaced(self, config): } ) - self.log("Replacing device with parameters: {0}".format(self.pprint(import_params)), "INFO") + self.log("Replacing device with parameters: {0}".format( + self.pprint(import_params)), "INFO") try: response = self.dnac._exec( @@ -867,7 +910,8 @@ def get_diff_replaced(self, config): op_modifies=True, params=import_params ) - self.log("Received API response from 'deploy_device_replacement_workflow': {0}".format(self.pprint(response)), "DEBUG") + self.log("Received API response from 'deploy_device_replacement_workflow': {0}".format( + self.pprint(response)), "DEBUG") task_id = response.get("response", {}).get("taskId") # Monitor the task status using check_rma_task_status @@ -878,14 +922,16 @@ def get_diff_replaced(self, config): ) if task_result["status"] != "success": self.status = "failed" - error_msg = "Device replacement task failed: {0}".format(task_result["msg"]) + error_msg = "Device replacement task failed: {0}".format( + task_result["msg"]) self.log(error_msg, "ERROR") self.result['msg'] = error_msg # Attempt to unmark the device self.log("Attempting to unmark the device after failure", "INFO") unmark_result = self.unmark_device_for_replacement() # Combine both error messages - self.msg = "{0} | Unmarking result: {1}".format(error_msg, unmark_result.msg) + self.msg = "{0} | Unmarking result: {1}".format( + error_msg, unmark_result.msg) self.log(self.msg, "ERROR") self.result['msg'] = self.msg return self @@ -901,13 +947,15 @@ def get_diff_replaced(self, config): # Attempt to unmark the device self.log("Attempting to unmark the device after failure", "INFO") unmark_result = self.unmark_device_for_replacement() - self.msg = "{0} | Unmarking result: {1}".format(self.msg, unmark_result.msg) + self.msg = "{0} | Unmarking result: {1}".format( + self.msg, unmark_result.msg) self.log(self.msg, "ERROR") self.result['msg'] = self.msg return self self.faulty_device.append(self.have.get("faulty_device_name")) - self.replacement_device.append(self.have.get("replacement_device_name")) + self.replacement_device.append( + self.have.get("replacement_device_name")) self.result['changed'] = True self.result['msg'] = self.msg @@ -919,7 +967,8 @@ def get_diff_replaced(self, config): self.log("Attempting to unmark the device after exception", "INFO") unmark_result = self.unmark_device_for_replacement() # Combine both error messages - self.msg = "{0} | Unmarking result: {1}".format(error_msg, unmark_result.msg) + self.msg = "{0} | Unmarking result: {1}".format( + error_msg, unmark_result.msg) self.log(self.msg, "ERROR") self.result['msg'] = self.msg self.result['response'] = [] @@ -954,12 +1003,14 @@ def monitor_replacement_status(self): resync_retry_interval = self.params.get('resync_retry_interval') while resync_retry_count: task_details = self.get_task_details(self.task_id) - self.log("Task Details: {0}".format(self.pprint(task_details)), "DEBUG") + self.log("Task Details: {0}".format( + self.pprint(task_details)), "DEBUG") if task_details.get("endTime") is not None: if task_details.get("isError") is False: self.result['changed'] = True - self.msg = "Device replacement completed successfully: {0}".format(task_details.get("progress")) + self.msg = "Device replacement completed successfully: {0}".format( + task_details.get("progress")) self.log(self.msg, "INFO") self.result['task_response'] = { "replacement_task_response": task_details, @@ -969,7 +1020,8 @@ def monitor_replacement_status(self): self.result['changed'] = False self.status = "failed" - self.msg = "Error in device replacement: {0}".format(task_details.get("progress")) + self.msg = "Error in device replacement: {0}".format( + task_details.get("progress")) self.log(self.msg, "ERROR") self.result['task_response'] = { "replacement_task_response": task_details, @@ -977,13 +1029,15 @@ def monitor_replacement_status(self): } return {"status": "failed", "msg": self.msg} - self.log("RMA workflow in progress: {0}".format(task_details.get("progress")), "INFO") + self.log("RMA workflow in progress: {0}".format( + task_details.get("progress")), "INFO") time.sleep(resync_retry_interval) resync_retry_count -= 1 # If we've exhausted all retries without a definitive result self.status = "failed" - self.msg = "Device replacement monitoring timed out after {0} attempts".format(self.params.get('dnac_api_task_timeout')) + self.msg = "Device replacement monitoring timed out after {0} attempts".format( + self.params.get('dnac_api_task_timeout')) self.log(self.msg, "ERROR") return {"status": "failed", "msg": self.msg} @@ -1021,7 +1075,8 @@ def unmark_device_for_replacement(self): op_modifies=True, params=import_params ) - self.log("Received API response from 'unmark_device_for_replacement': {0}".format(self.pprint(response)), "DEBUG") + self.log("Received API response from 'unmark_device_for_replacement': {0}".format( + self.pprint(response)), "DEBUG") task_id = response.get("response", {}).get("taskId") task_result = self.check_rma_task_status( task_id, @@ -1029,7 +1084,8 @@ def unmark_device_for_replacement(self): "Error while unmarking device for replacement" ) self.status = task_result["status"] - self.msg = "RMA failed to replace the device: {0}".format(task_result["msg"]) + self.msg = "RMA failed to replace the device: {0}".format( + task_result["msg"]) except Exception: self.status = "failed" @@ -1057,7 +1113,8 @@ def get_ready_for_replacement_device_id(self): for device in devices: if device.get("replacementStatus") == "READY-FOR-REPLACEMENT": device_id = device.get("id") - self.log("Found ready-for-replacement device with ID: {0}".format(device_id)) + self.log( + "Found ready-for-replacement device with ID: {0}".format(device_id)) return device_id self.log("No devices found with status 'READY-FOR-REPLACEMENT'.") @@ -1088,7 +1145,8 @@ def check_rma_task_status(self, task_id, success_message, error_prefix): task_details = self.get_task_details(task_id) self.log(task_details) if task_details.get("isError"): - error_message = task_details.get("failureReason", "{0}: Task failed.".format(error_prefix)) + error_message = task_details.get( + "failureReason", "{0}: Task failed.".format(error_prefix)) self.log(error_message, "ERROR") return {"status": "failed", "msg": error_message} @@ -1124,7 +1182,8 @@ def update_rma_profile_messages(self): if self.faulty_device and self.replacement_device: device_replacement_msg = ( "Device replacement was successfully completed for the faulty device(s) '{0}'," - " with the replacement device(s) '{1}'.".format("', '".join(self.faulty_device), "', '".join(self.replacement_device)) + " with the replacement device(s) '{1}'.".format("', '".join( + self.faulty_device), "', '".join(self.replacement_device)) ) result_msg_list.append(device_replacement_msg) @@ -1157,12 +1216,14 @@ def verify_diff_replaced(self, config): - Always returns self to maintain method chaining. """ - replacement_device_serial = self.have.get("replacement_device_serial_number") + replacement_device_serial = self.have.get( + "replacement_device_serial_number") if not replacement_device_serial: self.log("Replacement device serial number is missing", "WARNING") return self - import_params = {"replacementDeviceSerialNumber": replacement_device_serial} + import_params = { + "replacementDeviceSerialNumber": replacement_device_serial} try: response = self.dnac._exec( @@ -1175,9 +1236,11 @@ def verify_diff_replaced(self, config): for device in devices: if device.get("id") == self.have.get("device_replacement_id"): replacement_status = device - self.log("Replacement status: {0}".format(self.pprint(replacement_status)), "INFO") + self.log("Replacement status: {0}".format( + self.pprint(replacement_status)), "INFO") except Exception as e: - self.log("Error getting replacement status: {0}".format(str(e)), "ERROR") + self.log("Error getting replacement status: {0}".format( + str(e)), "ERROR") return self @@ -1226,9 +1289,11 @@ def main(): ccc_device_replacement.get_have().check_return_status() ccc_device_replacement.rma_device_replacement_pre_check().check_return_status() ccc_device_replacement.mark_faulty_device_for_replacement().check_return_status() - ccc_device_replacement.get_diff_state_apply[state](config).check_return_status() + ccc_device_replacement.get_diff_state_apply[state]( + config).check_return_status() if config_verify: - ccc_device_replacement.verify_diff_state_apply[state](config).check_return_status() + ccc_device_replacement.verify_diff_state_apply[state]( + config).check_return_status() ccc_device_replacement.update_rma_profile_messages().check_return_status() diff --git a/plugins/modules/sda_extranet_policies_workflow_manager.py b/plugins/modules/sda_extranet_policies_workflow_manager.py index e6a12a21da..abe1684d02 100644 --- a/plugins/modules/sda_extranet_policies_workflow_manager.py +++ b/plugins/modules/sda_extranet_policies_workflow_manager.py @@ -5,6 +5,12 @@ """Ansible module to manage Extranet Policy Operations in SD-Access Fabric in Cisco Catalyst Center.""" from __future__ import absolute_import, division, print_function +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts +) +from ansible.module_utils.basic import AnsibleModule +import time __metaclass__ = type __author__ = ("Rugvedi Kapse, Madhan Sankaranarayanan") @@ -219,18 +225,12 @@ } """ -import time -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts -) - class SDAExtranetPolicies(DnacBase): """ A class for managing Extranet Policies within the Cisco DNA Center using the SDA API. """ + def __init__(self, module): """ Initialize an instance of the class. @@ -278,13 +278,15 @@ def validate_input(self): ) if invalid_params: - self.msg = "Invalid parameters in playbook: {0}".format(invalid_params) + self.msg = "Invalid parameters in playbook: {0}".format( + invalid_params) self.set_operation_result("failed", False, self.msg, "ERROR") return self # Set the validated configuration and update the result with success status self.validated_config = valid_temp - self.msg = "Successfully validated playbook configuration parameters using 'validated_input': {0}".format(str(valid_temp)) + self.msg = "Successfully validated playbook configuration parameters using 'validated_input': {0}".format( + str(valid_temp)) self.set_operation_result("success", False, self.msg, "INFO") return self @@ -374,7 +376,8 @@ def get_add_extranet_policy_params(self, config, site_details=None): # Check if 'fabric_sites' are provided and site details are available if config.get("fabric_sites") and site_details: - add_extranet_policy_params["fabricIds"] = self.get_fabric_ids_list(site_details) + add_extranet_policy_params["fabricIds"] = self.get_fabric_ids_list( + site_details) else: add_extranet_policy_params["fabricIds"] = [] @@ -407,7 +410,8 @@ def get_update_extranet_policy_params(self, config, extranet_policy_id, site_det # Check if 'fabric_sites' are provided and site details are available if config.get("fabric_sites") and site_details: - update_extranet_policy_params["fabricIds"] = self.get_fabric_ids_list(site_details) + update_extranet_policy_params["fabricIds"] = self.get_fabric_ids_list( + site_details) else: update_extranet_policy_params["fabricIds"] = [] @@ -449,10 +453,12 @@ def get_site_details(self, fabric_sites): # Iterate over each site in the provided fabric sites list for site in fabric_sites: - self.log("Starting to retrieve site details for the provided fabric site: {0}".format(site), "INFO") + self.log("Starting to retrieve site details for the provided fabric site: {0}".format( + site), "INFO") # Validate if the site exists and retrieve its ID site_exists, site_id = self.get_site_id(site) - self.log("Site details for '{0}': exists={1}, id={2}".format(site, site_exists, site_id), "INFO") + self.log("Site details for '{0}': exists={1}, id={2}".format( + site, site_exists, site_id), "INFO") site_details[site] = { "site_exists": site_exists, "site_id": site_id, @@ -480,17 +486,20 @@ def get_fabric_sites(self, site_name, site_id): op_modifies=False, params={"siteId": site_id}, ) - self.log("Response received post SDA - 'get_fabric_sites' API call: {0}".format(str(response)), "DEBUG") + self.log( + "Response received post SDA - 'get_fabric_sites' API call: {0}".format(str(response)), "DEBUG") response = response["response"] if not response: - self.log("No response received from the SDA - 'get_fabric_sites' API call.", "WARNING") + self.log( + "No response received from the SDA - 'get_fabric_sites' API call.", "WARNING") return None # Process the response if available fabric_id = response[0]["id"] - self.log("Successfully retrieved fabric ID: '{0}' for Site: '{1}'".format(fabric_id, site_name), "INFO") + self.log("Successfully retrieved fabric ID: '{0}' for Site: '{1}'".format( + fabric_id, site_name), "INFO") return fabric_id @@ -521,12 +530,15 @@ def get_fabric_sites_ids(self, site_details): # Get the fabric ID using the site name and site ID fabric_id = self.get_fabric_sites(site_name, site_id) if fabric_id is not None: - self.log("Fabric ID: {0} collected for the fabric site: {1} with siteId: {2}".format(fabric_id, site_name, site_id), "INFO") + self.log("Fabric ID: {0} collected for the fabric site: {1} with siteId: {2}".format( + fabric_id, site_name, site_id), "INFO") site_info["fabric_id"] = fabric_id else: - self.msg = "Failed to retrieve Fabric ID for site: {0} with siteId: {1}".format(site_name, site_id) + self.msg = "Failed to retrieve Fabric ID for site: {0} with siteId: {1}".format( + site_name, site_id) self.fail_and_exit(self.msg) - self.log("Updated 'site_details' with the fabric_ids of each site. {0}".format(site_details)) + self.log("Updated 'site_details' with the fabric_ids of each site. {0}".format( + site_details)) return site_details def get_extranet_policies(self, extranet_policy_name): @@ -550,12 +562,14 @@ def get_extranet_policies(self, extranet_policy_name): op_modifies=False, params={"extranetPolicyName": extranet_policy_name}, ) - self.log("Response received post SDA - 'get_extranet_policies' API call: {0}".format(str(response)), "DEBUG") + self.log( + "Response received post SDA - 'get_extranet_policies' API call: {0}".format(str(response)), "DEBUG") # Process the response if available response = response["response"] if not response: - self.log("No response received from the SDA - 'get_extranet_policies' API call.", "WARNING") + self.log( + "No response received from the SDA - 'get_extranet_policies' API call.", "WARNING") return None return response[0] @@ -563,7 +577,8 @@ def get_extranet_policies(self, extranet_policy_name): # Log an error message and fail if an exception occurs self.msg = ( "An error occurred while retrieving Extranet Policy Details: '{0}' using SDA - " - "'get_extranet_policies' API call: {1}".format(extranet_policy_name, str(e)) + "'get_extranet_policies' API call: {1}".format( + extranet_policy_name, str(e)) ) self.fail_and_exit(self.msg) @@ -587,17 +602,21 @@ def validate_extranet_policy_exists(self, extranet_policy_name): extranet_policy_exists = False extranet_policy_id = None - self.log("Validating existence of Extranet Policy: {0}".format(extranet_policy_name), "INFO") + self.log("Validating existence of Extranet Policy: {0}".format( + extranet_policy_name), "INFO") - extranet_policy_details = self.get_extranet_policies(extranet_policy_name) + extranet_policy_details = self.get_extranet_policies( + extranet_policy_name) # Check if the policy details were retrieved successfully if extranet_policy_details: extranet_policy_exists = True extranet_policy_id = extranet_policy_details["id"] - self.log("Extranet Policy: '{0}' exists with ID: {1}".format(extranet_policy_name, extranet_policy_id), "INFO") + self.log("Extranet Policy: '{0}' exists with ID: {1}".format( + extranet_policy_name, extranet_policy_id), "INFO") else: - self.log("Extranet Policy: '{0}' does not exist.".format(extranet_policy_name), "WARNING") + self.log("Extranet Policy: '{0}' does not exist.".format( + extranet_policy_name), "WARNING") return (extranet_policy_exists, extranet_policy_id, extranet_policy_details) @@ -620,25 +639,30 @@ def compare_extranet_policies(self, extranet_policy_details, update_extranet_pol current_value = extranet_policy_details.get(key) requested_value = update_extranet_policy_params.get(key) - self.log("Comparing key: {0}, existing_value: {1}, requested_value: {2}".format(key, current_value, requested_value), "INFO") + self.log("Comparing key: {0}, existing_value: {1}, requested_value: {2}".format( + key, current_value, requested_value), "INFO") if key == "fabricIds": if current_value and not requested_value: - self.log("Skipping comparison for key: 'fabricIds' as the requested value is empty.", "DEBUG") + self.log( + "Skipping comparison for key: 'fabricIds' as the requested value is empty.", "DEBUG") continue if isinstance(current_value, list) and isinstance(requested_value, list): # Compare lists regardless of order if sorted(current_value) != sorted(requested_value): - self.log("Mismatch found for key: {0}, existing list: {1}, requested list: {2}".format(key, current_value, requested_value), "INFO") + self.log("Mismatch found for key: {0}, existing list: {1}, requested list: {2}".format( + key, current_value, requested_value), "INFO") return False else: # Compare values directly if current_value != requested_value: - self.log("Mismatch found for key: {0}, existing list: {1}, requested list: {2}".format(key, current_value, requested_value), "INFO") + self.log("Mismatch found for key: {0}, existing list: {1}, requested list: {2}".format( + key, current_value, requested_value), "INFO") return False - self.log("All keys and values match between the existing and requested policies.", "INFO") + self.log( + "All keys and values match between the existing and requested policies.", "INFO") return True @@ -668,8 +692,10 @@ def get_add_extranet_policy_status(self, task_id): msg = {} # Get the name of the extranet policy from the input parameters - extranet_policy_name = self.want.get("add_extranet_policy_params").get("extranetPolicyName") - msg["{0} Succeeded for the Extranet Policy".format(task_name)] = extranet_policy_name + extranet_policy_name = self.want.get( + "add_extranet_policy_params").get("extranetPolicyName") + msg["{0} Succeeded for the Extranet Policy".format( + task_name)] = extranet_policy_name # Retrieve and return the task status using the provided task ID return self.get_task_status_from_tasks_by_id(task_id, task_name, msg) @@ -683,7 +709,8 @@ def update_extranet_policy(self, update_extranet_policy_params): str: Task ID for the update extranet policy operation. """ # Wrap the parameters in a payload dictionary - update_extranet_policy_params = {"payload": [update_extranet_policy_params]} + update_extranet_policy_params = { + "payload": [update_extranet_policy_params]} # Make the API call to update the extranet policy and return the task ID return self.get_taskid_post_api_call("sda", "update_extranet_policy", update_extranet_policy_params) @@ -700,8 +727,10 @@ def get_update_extranet_policy_status(self, task_id): msg = {} # Get the name of the extranet policy from the input parameters - extranet_policy_name = self.want.get("update_extranet_policy_params").get("extranetPolicyName") - msg["{0} Succeeded for following Extranet Policy".format(task_name)] = extranet_policy_name + extranet_policy_name = self.want.get( + "update_extranet_policy_params").get("extranetPolicyName") + msg["{0} Succeeded for following Extranet Policy".format( + task_name)] = extranet_policy_name # Retrieve and return the task status using the provided task ID return self.get_task_status_from_tasks_by_id(task_id, task_name, msg) @@ -730,7 +759,8 @@ def get_delete_extranet_policy_status(self, task_id): # Get the name of the extranet policy from the input parameters extranet_policy_name = self.want.get("extranet_policy_name") - msg["{0} Succeeded for following Extranet Policy".format(task_name)] = extranet_policy_name + msg["{0} Succeeded for following Extranet Policy".format( + task_name)] = extranet_policy_name # Retrieve and return the task status using the provided task ID return self.get_task_status_from_tasks_by_id(task_id, task_name, msg) @@ -753,16 +783,19 @@ def get_have(self, config): extranet_policy_name = config.get("extranet_policy_name") # check if given extranet policy exits, if exists store current extranet policy info - (extranet_policy_exists, extranet_policy_id, extranet_policy_details) = self.validate_extranet_policy_exists(extranet_policy_name) + (extranet_policy_exists, extranet_policy_id, + extranet_policy_details) = self.validate_extranet_policy_exists(extranet_policy_name) - self.log("Current Extranet Policy details (have): {0}".format(str(extranet_policy_details)), "DEBUG") + self.log("Current Extranet Policy details (have): {0}".format( + str(extranet_policy_details)), "DEBUG") have["extranet_policy_exists"] = extranet_policy_exists have["extranet_policy_id"] = extranet_policy_id have["current_extranet_policy"] = extranet_policy_details self.have = have - self.log("Current Extranet Policy State (have): {0}".format(str(self.have)), "INFO") + self.log("Current Extranet Policy State (have): {0}".format( + str(self.have)), "INFO") return self @@ -786,7 +819,8 @@ def get_want(self, config, state): want = {} site_details = {} - self.log("Creating Parameters for API Calls with state: {0}".format(state)) + self.log( + "Creating Parameters for API Calls with state: {0}".format(state)) # Identify if policy already exists or needs to be created extranet_policy_name = config.get("extranet_policy_name") @@ -798,21 +832,26 @@ def get_want(self, config, state): self.validate_merged_parameters(config) fabric_sites = config.get("fabric_sites") if fabric_sites: - self.log("Attempting to get the 'site ID' for the provided fabric sites: {0}".format(fabric_sites), "DEBUG") + self.log("Attempting to get the 'site ID' for the provided fabric sites: {0}".format( + fabric_sites), "DEBUG") site_details = self.get_site_details(fabric_sites) - self.log("Attempting to get the 'fabric ID' for the provided fabric sites: {0}".format(fabric_sites), "DEBUG") + self.log("Attempting to get the 'fabric ID' for the provided fabric sites: {0}".format( + fabric_sites), "DEBUG") site_details = self.get_fabric_sites_ids(site_details) if extranet_policy_exists: self.log( "Extranet Policy - '{0}' exists in the Cisco Catalyst Center, " - "therefore setting 'update_extranet_policy_params'.".format(extranet_policy_name), + "therefore setting 'update_extranet_policy_params'.".format( + extranet_policy_name), "DEBUG" ) - want = dict(update_extranet_policy_params=self.get_update_extranet_policy_params(config, extranet_policy_id, site_details)) + want = dict(update_extranet_policy_params=self.get_update_extranet_policy_params( + config, extranet_policy_id, site_details)) if self.compare_extranet_policies(extranet_policy_details, want["update_extranet_policy_params"]): self.msg = ( - "Extranet Policy '{0}' is identical to the update requested. No update operation needed.".format(extranet_policy_name) + "Extranet Policy '{0}' is identical to the update requested. No update operation needed.".format( + extranet_policy_name) ) self.set_operation_result("ok", False, self.msg, "INFO") self.check_return_status() @@ -820,16 +859,19 @@ def get_want(self, config, state): else: self.log( "Extranet Policy - '{0}' does not exist in the Cisco Catalyst Center, " - "therefore setting 'add_extranet_policy_params'.".format(extranet_policy_name), + "therefore setting 'add_extranet_policy_params'.".format( + extranet_policy_name), "DEBUG" ) - want = dict(add_extranet_policy_params=self.get_add_extranet_policy_params(config, site_details)) + want = dict(add_extranet_policy_params=self.get_add_extranet_policy_params( + config, site_details)) elif state == "deleted": if extranet_policy_exists: self.log( "State is delete and Extranet Policy - '{0}' exists in the Cisco Catalyst Center, " - "therefore setting 'delete_extranet_policy_params'.".format(extranet_policy_name), + "therefore setting 'delete_extranet_policy_params'.".format( + extranet_policy_name), "DEBUG" ) want = dict(extranet_policy_name=extranet_policy_name, @@ -837,7 +879,8 @@ def get_want(self, config, state): else: self.msg = ( "Extranet Policy - '{0}' does not exist in the Cisco Catalyst Center and " - "hence delete operation not required.".format(extranet_policy_name) + "hence delete operation not required.".format( + extranet_policy_name) ) self.set_operation_result("ok", False, self.msg, "INFO") self.check_return_status() @@ -873,7 +916,8 @@ def get_diff_merged(self): # Execute the action and check its status req_action_param = self.want.get(action_param) if req_action_param: - self.log("Executing action for parameter: {0}".format(req_action_param), "INFO") + self.log("Executing action for parameter: {0}".format( + req_action_param), "INFO") result_task_id = action_func(req_action_param) status_func(result_task_id).check_return_status() @@ -930,38 +974,52 @@ def verify_diff_merged(self, config): post_operation_state = self.have.copy() extranet_policy_name = config.get("extranet_policy_name") - add_extranet_policy_params = desired_state.get("add_extranet_policy_params") + add_extranet_policy_params = desired_state.get( + "add_extranet_policy_params") if add_extranet_policy_params: - self.log("State before performing ADD Extranet Policy operation: {0}".format(str(pre_operation_state)), "INFO") - self.log("Desired State: {0}".format(str(add_extranet_policy_params)), "INFO") - self.log("State after performing ADD Extranet Policy operation: {0}".format(str(post_operation_state)), "INFO") + self.log("State before performing ADD Extranet Policy operation: {0}".format( + str(pre_operation_state)), "INFO") + self.log("Desired State: {0}".format( + str(add_extranet_policy_params)), "INFO") + self.log("State after performing ADD Extranet Policy operation: {0}".format( + str(post_operation_state)), "INFO") if post_operation_state["extranet_policy_exists"]: - self.log("Verified the success of ADD Extranet Policy - '{0}' operation.".format(extranet_policy_name), "INFO") + self.log("Verified the success of ADD Extranet Policy - '{0}' operation.".format( + extranet_policy_name), "INFO") else: self.log( "The ADD Extranet Policy - '{0}' operation may not have been successful " - "since the Extranet Policy does not exist in the Cisco Catalyst Center.".format(extranet_policy_name), + "since the Extranet Policy does not exist in the Cisco Catalyst Center.".format( + extranet_policy_name), "WARNING" ) - self.log("Completed verification of ADD Extranet Policy operation.", "INFO") + self.log( + "Completed verification of ADD Extranet Policy operation.", "INFO") - update_extranet_policy_params = desired_state.get("update_extranet_policy_params") + update_extranet_policy_params = desired_state.get( + "update_extranet_policy_params") if update_extranet_policy_params: - self.log("State before performing UPDATE Extranet Policy operation: {0}".format(str(pre_operation_state)), "INFO") - self.log("Desired State: {0}".format(str(update_extranet_policy_params)), "INFO") - self.log("State after performing UPDATE Extranet Policy operation - '{0}'".format(str(post_operation_state)), "INFO") + self.log("State before performing UPDATE Extranet Policy operation: {0}".format( + str(pre_operation_state)), "INFO") + self.log("Desired State: {0}".format( + str(update_extranet_policy_params)), "INFO") + self.log("State after performing UPDATE Extranet Policy operation - '{0}'".format( + str(post_operation_state)), "INFO") if not self.compare_extranet_policies(pre_operation_state["current_extranet_policy"], post_operation_state["current_extranet_policy"]): - self.log("Verified the success of UPDATE Extranet Policy - '{0}' operation.".format(extranet_policy_name), "INFO") + self.log("Verified the success of UPDATE Extranet Policy - '{0}' operation.".format( + extranet_policy_name), "INFO") else: self.log( "The UPDATE Extranet Policy - '{0}' operation may not have been performed or " "may not have been successful because no change was detected in the Extranet Policy " - "in the Cisco Catalyst Center".format(extranet_policy_name), + "in the Cisco Catalyst Center".format( + extranet_policy_name), "WARNING" ) - self.log("Completed verification of UPDATE Extranet Policy operation.", "INFO") + self.log( + "Completed verification of UPDATE Extranet Policy operation.", "INFO") self.log("Completed 'verify_diff_merged' operation.", "INFO") return self @@ -988,16 +1046,20 @@ def verify_diff_deleted(self, config): post_operation_state = self.have.copy() extranet_policy_name = config.get("extranet_policy_name") - self.log("State before performing DELETE Extranet Policy operation: {0}".format(str(pre_operation_state)), "INFO") + self.log("State before performing DELETE Extranet Policy operation: {0}".format( + str(pre_operation_state)), "INFO") self.log("Desired State: {0}".format(str(desired_state)), "INFO") - self.log("State after performing DELETE Extranet Policy operation: {0}".format(str(post_operation_state)), "INFO") + self.log("State after performing DELETE Extranet Policy operation: {0}".format( + str(post_operation_state)), "INFO") if not post_operation_state["extranet_policy_exists"]: - self.log("Verified the success of DELETE Extranet Policy - '{0}' operation".format(extranet_policy_name), "INFO") + self.log("Verified the success of DELETE Extranet Policy - '{0}' operation".format( + extranet_policy_name), "INFO") else: self.log( "The DELETE Extranet Policy - '{0}' operation may not have been successful since " - "the policy still exists in the Cisco Catalyst Center.".format(extranet_policy_name), + "the policy still exists in the Cisco Catalyst Center.".format( + extranet_policy_name), "WARNING" ) @@ -1056,10 +1118,12 @@ def main(): ccc_sda_extranet_policies.reset_values() ccc_sda_extranet_policies.get_have(config).check_return_status() ccc_sda_extranet_policies.get_want(config, state).check_return_status() - ccc_sda_extranet_policies.get_diff_state_apply[state]().check_return_status() + ccc_sda_extranet_policies.get_diff_state_apply[state]( + ).check_return_status() if config_verify: - ccc_sda_extranet_policies.verify_diff_state_apply[state](config).check_return_status() + ccc_sda_extranet_policies.verify_diff_state_apply[state]( + config).check_return_status() module.exit_json(**ccc_sda_extranet_policies.result) diff --git a/plugins/modules/sda_fabric_devices_workflow_manager.py b/plugins/modules/sda_fabric_devices_workflow_manager.py index ba0a7085af..c49752163d 100644 --- a/plugins/modules/sda_fabric_devices_workflow_manager.py +++ b/plugins/modules/sda_fabric_devices_workflow_manager.py @@ -5,6 +5,13 @@ """Ansible module to perform operations on SDA fabric devices in Cisco Catalyst Center.""" from __future__ import absolute_import, division, print_function +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + get_dict_result, +) +from ansible.module_utils.basic import AnsibleModule +import time __metaclass__ = type __author__ = ['Muthu Rakesh, Madhan Sankaranarayanan'] @@ -920,14 +927,6 @@ } """ -import time -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - get_dict_result, -) - class FabricDevices(DnacBase): """Class containing member attributes for sda_fabric_devices_workflow_manager module""" @@ -936,8 +935,10 @@ def __init__(self, module): super().__init__(module) self.response = [] self.fabric_devices_obj_params = self.get_obj_params("fabricDevices") - self.fabric_l3_handoff_sda_obj_params = self.get_obj_params("fabricSdaL3Handoff") - self.fabric_l3_handoff_ip_obj_params = self.get_obj_params("fabricIpL3Handoff") + self.fabric_l3_handoff_sda_obj_params = self.get_obj_params( + "fabricSdaL3Handoff") + self.fabric_l3_handoff_ip_obj_params = self.get_obj_params( + "fabricIpL3Handoff") self.max_timeout = self.params.get('dnac_api_task_timeout') def validate_input(self): @@ -1023,7 +1024,8 @@ def validate_input(self): } # Validate playbook params against the specification (temp_spec) - valid_temp, invalid_params = validate_list_of_dicts(self.config, temp_spec) + valid_temp, invalid_params = validate_list_of_dicts( + self.config, temp_spec) if invalid_params: self.msg = ( "Invalid parameters in playbook: {invalid_params}" @@ -1063,7 +1065,8 @@ def get_obj_params(self, get_object): ("affinityIdPrime", "affinityIdPrime"), ("affinityIdDecider", "affinityIdDecider"), ("connectedToInternet", "connectedToInternet"), - ("isMulticastOverTransitEnabled", "isMulticastOverTransitEnabled"), + ("isMulticastOverTransitEnabled", + "isMulticastOverTransitEnabled"), ] elif get_object == "fabricIpL3Handoff": obj_params = [ @@ -1091,7 +1094,8 @@ def get_transit_id_from_name(self, transit_name): If the response is not empty, fetch the Id and return. Else, return None. """ - self.log("Starting to get transit ID for transit name: '{name}'".format(name=transit_name), "DEBUG") + self.log("Starting to get transit ID for transit name: '{name}'".format( + name=transit_name), "DEBUG") transit_id = None try: transit_details = self.dnac._exec( @@ -1142,7 +1146,8 @@ def get_device_details_from_ip(self, device_ip): If the response is not empty, return the device details. Else, return None. """ - self.log("Starting to get device details for device IP: '{ip}'.".format(ip=device_ip), "DEBUG") + self.log("Starting to get device details for device IP: '{ip}'.".format( + ip=device_ip), "DEBUG") device_details = None try: device_details = self.dnac._exec( @@ -1174,7 +1179,8 @@ def get_device_details_from_ip(self, device_ip): return self.check_return_status() self.log( - "Returning device details: '{details}'.".format(details=device_details), "DEBUG" + "Returning device details: '{details}'.".format( + details=device_details), "DEBUG" ) return device_details @@ -1227,7 +1233,8 @@ def check_valid_virtual_network_name(self, virtual_network_name): return False self.log( - "L3 virtual network '{name}' exists.".format(name=virtual_network_name), "DEBUG" + "L3 virtual network '{name}' exists.".format( + name=virtual_network_name), "DEBUG" ) except Exception as msg: @@ -1303,7 +1310,8 @@ def check_valid_reserved_pool(self, reserved_pool_name, fabric_name): return self.check_return_status() offset += 25 - all_reserved_pool_details = all_reserved_pool_details.get("response") + all_reserved_pool_details = all_reserved_pool_details.get( + "response") if not all_reserved_pool_details: self.log( "There is no reserved subpool in the site '{site_name}'." @@ -1322,7 +1330,8 @@ def check_valid_reserved_pool(self, reserved_pool_name, fabric_name): break # Find the reserved pool with the given name in the list of reserved pools - reserved_pool_details = get_dict_result(all_reserved_pool_details, "groupName", reserved_pool_name) + reserved_pool_details = get_dict_result( + all_reserved_pool_details, "groupName", reserved_pool_name) if reserved_pool_details: self.log( "The reserved pool found with the name '{reserved_pool}' in the site '{site_name}'." @@ -1513,7 +1522,8 @@ def check_device_is_provisioned(self, fabric_device_ip, device_id, site_id, site ) # If the response returned from the SDK is None, then the device is not provisioned to the site. - provisioned_device_details = provisioned_device_details.get("response") + provisioned_device_details = provisioned_device_details.get( + "response") if not provisioned_device_details: self.msg = ( "The network device with the IP address '{device_ip}' is not provisioned to the site '{site_name}'." @@ -1654,7 +1664,8 @@ def l2_handoff_exists(self, fabric_id, device_id, internal_vlan_id, interface_na if l2_handoff_id: self.log( - "L2 handoff ID found: {l2_handoff_id}".format(l2_handoff_id=l2_handoff_id), "INFO" + "L2 handoff ID found: {l2_handoff_id}".format( + l2_handoff_id=l2_handoff_id), "INFO" ) else: self.log( @@ -1713,7 +1724,8 @@ def sda_l3_handoff_exists(self, fabric_id, device_id, transit_name): self.status = "failed" return self.check_return_status() - all_sda_l3_handoff_details = all_sda_l3_handoff_details.get("response") + all_sda_l3_handoff_details = all_sda_l3_handoff_details.get( + "response") if not all_sda_l3_handoff_details: self.log( "There is no L3 Handoffs with SDA transit associated with the device with ID '{id}' in the Cisco Catalyst Center." @@ -1721,7 +1733,8 @@ def sda_l3_handoff_exists(self, fabric_id, device_id, transit_name): ) break - sda_l3_handoff_details = get_dict_result(all_sda_l3_handoff_details, "transitNetworkId", transit_id) + sda_l3_handoff_details = get_dict_result( + all_sda_l3_handoff_details, "transitNetworkId", transit_id) if sda_l3_handoff_details: self.log( "The L3 Handoff with SDA transit details with the transit name '{name}': '{details}" @@ -1740,7 +1753,8 @@ def sda_l3_handoff_exists(self, fabric_id, device_id, transit_name): except Exception as msg: self.msg = ( "Received API response from 'get_fabric_devices_layer3_handoffs_with_sda_transit' " - "with the transit name '{name}': {msg}".format(name=transit_name, msg=msg) + "with the transit name '{name}': {msg}".format( + name=transit_name, msg=msg) ) self.log(self.msg, "CRITICAL") self.status = "failed" @@ -1748,11 +1762,13 @@ def sda_l3_handoff_exists(self, fabric_id, device_id, transit_name): if sda_l3_handoff_details: self.log( - "L3 Handoff details found: {details}".format(details=sda_l3_handoff_details), "INFO" + "L3 Handoff details found: {details}".format( + details=sda_l3_handoff_details), "INFO" ) else: self.log( - "No L3 Handoff details found for transit name '{name}'.".format(name=transit_name), "INFO" + "No L3 Handoff details found for transit name '{name}'.".format( + name=transit_name), "INFO" ) return sda_l3_handoff_details @@ -1830,7 +1846,8 @@ def ip_l3_handoff_exists(self, fabric_id, device_id, transit_name, except Exception as msg: self.msg = ( "Exception occurred while getting the details of Layer3 Handoffs with IP transit " - "with the transit name '{name}': {msg}".format(name=transit_name, msg=msg) + "with the transit name '{name}': {msg}".format( + name=transit_name, msg=msg) ) self.log(self.msg, "CRITICAL") self.status = "failed" @@ -1843,7 +1860,8 @@ def ip_l3_handoff_exists(self, fabric_id, device_id, transit_name, self.status = "failed" return self.check_return_status() - all_ip_l3_handoff_details = all_ip_l3_handoff_details.get("response") + all_ip_l3_handoff_details = all_ip_l3_handoff_details.get( + "response") if not all_ip_l3_handoff_details: self.log( "There is no L3 Handoffs with IP transit associated with the device with ID '{id}' in the Cisco Catalyst Center." @@ -1943,7 +1961,8 @@ def fabric_device_exists(self, fabric_id, device_id, device_ip): # If the SDK return an empty response, then the fabric device is not available fabric_device_details = fabric_device_details.get("response") if not fabric_device_details: - self.log("Fabric device with IP {ip} does not exist.".format(ip=device_ip), "DEBUG") + self.log("Fabric device with IP {ip} does not exist.".format( + ip=device_ip), "DEBUG") return device_info self.log( @@ -1958,9 +1977,12 @@ def fabric_device_exists(self, fabric_id, device_id, device_ip): "device_details": self.format_fabric_device_params(fabric_device_details[0]) }) - self.log("SDA fabric device details successfully formatted for device with IP '{ip}'.".format(ip=device_ip), "DEBUG") - self.log("SDA fabric device details: {details}".format(details=device_info.get("details")), "DEBUG") - self.log("SDA fabric device id: {id}".format(id=device_info.get("id")), "DEBUG") + self.log("SDA fabric device details successfully formatted for device with IP '{ip}'.".format( + ip=device_ip), "DEBUG") + self.log("SDA fabric device details: {details}".format( + details=device_info.get("details")), "DEBUG") + self.log("SDA fabric device id: {id}".format( + id=device_info.get("id")), "DEBUG") return device_info def process_layer2_handoff(self, fabric_devices_info, layer2_handoff, fabric_site_id, network_device_id, fabric_device_ip): @@ -1980,7 +2002,8 @@ def process_layer2_handoff(self, fabric_devices_info, layer2_handoff, fabric_sit Get the L2 Handoff ID, if exists. """ - self.log("Processing the L2 Handoff for the device '{ip}'".format(ip=fabric_device_ip)) + self.log("Processing the L2 Handoff for the device '{ip}'".format( + ip=fabric_device_ip)) if not layer2_handoff: return fabric_devices_info @@ -2029,14 +2052,16 @@ def process_layer3_sda_handoff(self, fabric_devices_info, layer3_handoff_sda_tra Get the SDA L3 Handoff ID and details, if exists. """ - self.log("Processing the SDA L3 Handoff for the device '{ip}'".format(ip=fabric_device_ip)) + self.log("Processing the SDA L3 Handoff for the device '{ip}'".format( + ip=fabric_device_ip)) if not layer3_handoff_sda_transit: return fabric_devices_info if layer3_handoff_sda_transit: # Transit network name is mandatory - transit_network_name = layer3_handoff_sda_transit.get("transit_network_name") + transit_network_name = layer3_handoff_sda_transit.get( + "transit_network_name") if not transit_network_name: self.msg = ( "The required parameter 'transit_network_name' in 'layer3_handoff_sda_transit' is missing." @@ -2072,7 +2097,8 @@ def process_layer3_ip_handoff(self, fabric_devices_info, layer3_handoff_ip_trans Get the IP L3 Handoff ID and details, if exists. """ - self.log("Processing the IP L3 Handoff for the device '{ip}'".format(ip=fabric_device_ip)) + self.log("Processing the IP L3 Handoff for the device '{ip}'".format( + ip=fabric_device_ip)) if not layer3_handoff_ip_transit: return fabric_devices_info @@ -2113,7 +2139,8 @@ def process_layer3_ip_handoff(self, fabric_devices_info, layer3_handoff_ip_trans ip_l3_handoff_detail = self.ip_l3_handoff_exists(fabric_site_id, network_device_id, transit_network_name, virtual_network_name, vlan_id) - fabric_devices_info.get("ip_l3_handoff_details").append(ip_l3_handoff_detail) + fabric_devices_info.get("ip_l3_handoff_details").append( + ip_l3_handoff_detail) self.log("Successfully proccessed the IP L3 Handoff information.", "DEBUG") return fabric_devices_info @@ -2160,15 +2187,19 @@ def get_have_fabric_devices(self, fabric_devices): ) if not site_id: self.msg = ( - "Invalid site hierarchy name '{site_name}'.".format(site_name=fabric_name) + "Invalid site hierarchy name '{site_name}'.".format( + site_name=fabric_name) ) self.status = "failed" return self.check_return_status() - self.log("Fetching fabric site ID for site '{site_id}'.".format(site_id=site_id), "INFO") - fabric_site_id = self.get_fabric_site_id_from_name(fabric_name, site_id) + self.log("Fetching fabric site ID for site '{site_id}'.".format( + site_id=site_id), "INFO") + fabric_site_id = self.get_fabric_site_id_from_name( + fabric_name, site_id) if not fabric_site_id: - fabric_site_id = self.get_fabric_zone_id_from_name(fabric_name, site_id) + fabric_site_id = self.get_fabric_zone_id_from_name( + fabric_name, site_id) if not fabric_site_id: self.msg = ( "The provided 'fabric_name' '{fabric_name}' is not valid a fabric site." @@ -2229,7 +2260,8 @@ def get_have_fabric_devices(self, fabric_devices): "Fetching network device ID for IP '{device_ip}'." .format(device_ip=fabric_device_ip), "INFO" ) - network_device_details = self.get_device_details_from_ip(fabric_device_ip) + network_device_details = self.get_device_details_from_ip( + fabric_device_ip) if not network_device_details: self.msg = ( "The 'device_ip' '{ip}' in 'device_config' is not a valid IP under the fabric '{fabric_name}'." @@ -2273,7 +2305,8 @@ def get_have_fabric_devices(self, fabric_devices): "network_device_id": network_device_id, "delete_fabric_device": delete_fabric_device, }) - device_info = self.fabric_device_exists(fabric_site_id, network_device_id, fabric_device_ip) + device_info = self.fabric_device_exists( + fabric_site_id, network_device_id, fabric_device_ip) fabric_devices_info.update({ "exists": device_info.get("exists"), "id": device_info.get("id"), @@ -2356,10 +2389,13 @@ def get_have(self, config): self.status = "failed" return self - self.log("Fabric devices found in config. Proceeding with retrieval.", "DEBUG") + self.log( + "Fabric devices found in config. Proceeding with retrieval.", "DEBUG") self.get_have_fabric_devices(fabric_devices).check_return_status() - self.log("Fabric devices information retrieval was successful. Details: {details}".format(details=self.have), "DEBUG") - self.log("Current State (have): {current_state}".format(current_state=self.have), "INFO") + self.log("Fabric devices information retrieval was successful. Details: {details}".format( + details=self.have), "DEBUG") + self.log("Current State (have): {current_state}".format( + current_state=self.have), "INFO") self.msg = "Successfully retrieved the SDA fabric devices details from the Cisco Catalyst Center." self.status = "success" return self @@ -2394,7 +2430,8 @@ def validate_local_autonomous_system_number(self, local_autonomous_system_number # Validate the range for both parts if 1 <= first_part <= 65535 and 0 <= second_part <= 65535: - self.log("Input is valid in the format 1.0 to 65535.65535", "INFO") + self.log( + "Input is valid in the format 1.0 to 65535.65535", "INFO") else: self.msg = ( "The 'local_autonomous_system_number' should be in the range '1.0' to '65535.65535' for the device '{ip}'." @@ -2410,7 +2447,8 @@ def validate_local_autonomous_system_number(self, local_autonomous_system_number self.status = "failed" return self.check_return_status() else: - local_autonomous_system_number = int(local_autonomous_system_number) + local_autonomous_system_number = int( + local_autonomous_system_number) if not 1 <= local_autonomous_system_number <= 4294967295: self.msg = ( "The 'local_autonomous_system_number' should be from 1 to 4294967295 for the device '{ip}'." @@ -2464,18 +2502,22 @@ def get_device_params(self, fabric_id, network_id, device_details, config_index) # If the user didnot provide the mandatory information and if it can be # retrieved from the Cisco Catalyst Center, we will use it - have_device_details = self.have.get("fabric_devices")[config_index].get("device_details") - self.log("Existing device details found: {device_details}".format(device_details=have_device_details), "DEBUG") + have_device_details = self.have.get("fabric_devices")[ + config_index].get("device_details") + self.log("Existing device details found: {device_details}".format( + device_details=have_device_details), "DEBUG") have_device_exists = False if have_device_details: have_device_exists = self.have.get("fabric_devices")[config_index] \ .get("exists") - self.log("Device exists status: {device_exists}".format(device_exists=have_device_exists), "DEBUG") + self.log("Device exists status: {device_exists}".format( + device_exists=have_device_exists), "DEBUG") # Device IP and the Fabric name is mandatory and cannot be fetched from the Cisco Catalyst Center device_roles = device_details.get("device_roles") - self.log("Device roles provided: {roles}".format(roles=device_roles), "DEBUG") + self.log("Device roles provided: {roles}".format( + roles=device_roles), "DEBUG") if not have_device_exists: if not device_roles: self.msg = ( @@ -2513,9 +2555,11 @@ def get_device_params(self, fabric_id, network_id, device_details, config_index) device_info.update({ "deviceRoles": device_roles }) - self.log("Device info updated with roles: {device_info}".format(device_info=device_info), "DEBUG") + self.log("Device info updated with roles: {device_info}".format( + device_info=device_info), "DEBUG") if "BORDER_NODE" not in device_roles: - self.log("Device does not have 'BORDER_NODE' role, returning device_info", "DEBUG") + self.log( + "Device does not have 'BORDER_NODE' role, returning device_info", "DEBUG") return device_info self.log("Device has 'BORDER_NODE' role; processing border settings", "DEBUG") @@ -2524,7 +2568,8 @@ def get_device_params(self, fabric_id, network_id, device_details, config_index) # Get the border settings details from the Cisco Catalyst Center, if available if have_device_details: - have_border_settings = have_device_details.get("borderDeviceSettings") + have_border_settings = have_device_details.get( + "borderDeviceSettings") if not borders_settings: if not have_border_settings: @@ -2548,8 +2593,10 @@ def get_device_params(self, fabric_id, network_id, device_details, config_index) border_device_settings = {} border_types = [] layer3_settings = borders_settings.get("layer3_settings") - layer3_handoff_ip_transit = borders_settings.get("layer3_handoff_ip_transit") - layer3_handoff_sda_transit = borders_settings.get("layer3_handoff_sda_transit") + layer3_handoff_ip_transit = borders_settings.get( + "layer3_handoff_ip_transit") + layer3_handoff_sda_transit = borders_settings.get( + "layer3_handoff_sda_transit") if layer3_settings: border_types.append("LAYER_3") elif layer3_handoff_ip_transit: @@ -2569,7 +2616,8 @@ def get_device_params(self, fabric_id, network_id, device_details, config_index) if not border_types: self.msg = ( "The 'layer3_settings' parameter is required under 'borders_settings' when " - "'device_roles' includes 'BORDER_NODE' for device {ip}.".format(ip=device_ip) + "'device_roles' includes 'BORDER_NODE' for device {ip}.".format( + ip=device_ip) ) self.status = "failed" return self.check_return_status() @@ -2587,16 +2635,20 @@ def get_device_params(self, fabric_id, network_id, device_details, config_index) if not (layer3_settings or have_layer3_settings): self.msg = ( "The parameter 'layer3_settings' is mandatory under 'borders_settings' when the " - "'device_roles' has 'BORDER_NODE' for the device {ip}.".format(ip=device_ip) + "'device_roles' has 'BORDER_NODE' for the device {ip}.".format( + ip=device_ip) ) self.status = "failed" return self.check_return_status() - local_autonomous_system_number = layer3_settings.get("local_autonomous_system_number") - self.log("Local AS number: {asn_number}".format(asn_number=local_autonomous_system_number), "DEBUG") + local_autonomous_system_number = layer3_settings.get( + "local_autonomous_system_number") + self.log("Local AS number: {asn_number}".format( + asn_number=local_autonomous_system_number), "DEBUG") if local_autonomous_system_number is None: if have_layer3_settings: - local_autonomous_system_number = have_layer3_settings.get("localAutonomousSystemNumber") + local_autonomous_system_number = have_layer3_settings.get( + "localAutonomousSystemNumber") else: self.msg = ( "The parameter 'local_autonomous_system_number' is mandatory for the 'layer3_settings' " @@ -2605,7 +2657,8 @@ def get_device_params(self, fabric_id, network_id, device_details, config_index) self.status = "failed" return self.check_return_status() else: - existing_as_number = have_layer3_settings.get("localAutonomousSystemNumber") if have_layer3_settings else None + existing_as_number = have_layer3_settings.get( + "localAutonomousSystemNumber") if have_layer3_settings else None if existing_as_number and str(local_autonomous_system_number) != str(existing_as_number): self.msg = ( "The parameter 'local_autonomous_system_number' in 'layer3_settings' must not be updated " @@ -2614,7 +2667,8 @@ def get_device_params(self, fabric_id, network_id, device_details, config_index) self.status = "failed" return self.check_return_status() - self.validate_local_autonomous_system_number(local_autonomous_system_number, device_ip) + self.validate_local_autonomous_system_number( + local_autonomous_system_number, device_ip) self.log( "Successfully validated 'local_autonomous_system_number': {asn_number}" .format(asn_number=local_autonomous_system_number), "DEBUG" @@ -2622,7 +2676,8 @@ def get_device_params(self, fabric_id, network_id, device_details, config_index) is_default_exit = layer3_settings.get("is_default_exit") if is_default_exit is None: if have_layer3_settings: - is_default_exit = have_layer3_settings.get("isDefaultExit", True) + is_default_exit = have_layer3_settings.get( + "isDefaultExit", True) else: is_default_exit = True else: @@ -2630,25 +2685,30 @@ def get_device_params(self, fabric_id, network_id, device_details, config_index) if is_default_exit != have_layer3_settings.get("importExternalRoutes"): self.msg = ( "The parameter 'is_default_exit' under 'layer3_settings' should not be " - "updated for the device with IP '{ip}'.".format(ip=device_ip) + "updated for the device with IP '{ip}'.".format( + ip=device_ip) ) self.status = "failed" return self.check_return_status() - import_external_routes = layer3_settings.get("import_external_routes") + import_external_routes = layer3_settings.get( + "import_external_routes") if import_external_routes is None: if have_layer3_settings: - have_import_external_routes = have_layer3_settings.get("importExternalRoutes") + have_import_external_routes = have_layer3_settings.get( + "importExternalRoutes") import_external_routes = have_import_external_routes else: import_external_routes = True else: if have_layer3_settings: - have_import_external_routes = have_layer3_settings.get("importExternalRoutes") + have_import_external_routes = have_layer3_settings.get( + "importExternalRoutes") if import_external_routes != have_import_external_routes: self.msg = ( "The parameter 'import_external_routes' under 'layer3_settings' should not be " - "updated for the device with IP '{ip}'.".format(ip=device_ip) + "updated for the device with IP '{ip}'.".format( + ip=device_ip) ) self.status = "failed" return self.check_return_status() @@ -2658,7 +2718,8 @@ def get_device_params(self, fabric_id, network_id, device_details, config_index) # we can se the border priority from 0 to 9 if not border_priority: if have_layer3_settings: - have_border_priority = have_layer3_settings.get("borderPriority") + have_border_priority = have_layer3_settings.get( + "borderPriority") if have_border_priority and have_border_priority != 10: border_priority = have_border_priority else: @@ -2680,17 +2741,20 @@ def get_device_params(self, fabric_id, network_id, device_details, config_index) self.status = "failed" return self.check_return_status() - prepend_autonomous_system_count = layer3_settings.get("prepend_autonomous_system_count") + prepend_autonomous_system_count = layer3_settings.get( + "prepend_autonomous_system_count") # Default value of prepend autonomous system count is 0 # we can se the prepend autonomous system count from 1 to 10 if not prepend_autonomous_system_count: if have_layer3_settings: - have_prepend_autonomous_system_count = have_layer3_settings.get("prependAutonomousSystemCount") + have_prepend_autonomous_system_count = have_layer3_settings.get( + "prependAutonomousSystemCount") if have_prepend_autonomous_system_count and have_prepend_autonomous_system_count != 0: prepend_autonomous_system_count = have_prepend_autonomous_system_count else: try: - prepend_autonomous_system_count = int(prepend_autonomous_system_count) + prepend_autonomous_system_count = int( + prepend_autonomous_system_count) if not 1 <= prepend_autonomous_system_count <= 10: self.msg = ( "The 'prepend_autonomous_system_count' should be from 1 to 10 for the device '{ip}'." @@ -2725,9 +2789,10 @@ def get_device_params(self, fabric_id, network_id, device_details, config_index) }) device_info.update({ - "borderDeviceSettings" : border_device_settings + "borderDeviceSettings": border_device_settings }) - self.log("Final device info: {device_info}".format(device_info=device_info), "DEBUG") + self.log("Final device info: {device_info}".format( + device_info=device_info), "DEBUG") return device_info @@ -2824,7 +2889,8 @@ def check_transit_type(self, transit_id): If the response is valid, fetch the Id and return True, otherwise False. """ - self.log("Fetching transit type for transit ID: '{id}'".format(id=transit_id), "DEBUG") + self.log("Fetching transit type for transit ID: '{id}'".format( + id=transit_id), "DEBUG") is_transit_pub_sub = False try: transit_details = self.dnac._exec( @@ -2899,7 +2965,8 @@ def get_l2_handoff_params(self, fabric_id, network_id, device_details, device_co device_ip = device_details.get("device_ip") l2_handoff_index = -1 - have_l2_handoff_details = self.have.get("fabric_devices")[device_config_index].get("l2_handoff_details") + have_l2_handoff_details = self.have.get( + "fabric_devices")[device_config_index].get("l2_handoff_details") for item in layer2_handoff: l2_handoff_index += 1 l2_handoff = { @@ -2924,11 +2991,13 @@ def get_l2_handoff_params(self, fabric_id, network_id, device_details, device_co internal_vlan_id = item.get("internal_vlan_id") external_vlan_id = item.get("external_vlan_id") - error = self.validate_vlan_fields(internal_vlan_id, external_vlan_id, device_ip) + error = self.validate_vlan_fields( + internal_vlan_id, external_vlan_id, device_ip) if error: (self.msg, self.status) = error self.log( - "Validation error for device IP {ip}: {msg}".format(ip=device_ip, msg=self.msg) + "Validation error for device IP {ip}: {msg}".format( + ip=device_ip, msg=self.msg) ) return self.check_return_status() @@ -2976,7 +3045,8 @@ def get_sda_l3_handoff_params(self, fabric_id, network_id, device_details, devic ) return sda_l3_handoff_info - layer3_handoff_sda_transit = borders_settings.get("layer3_handoff_sda_transit") + layer3_handoff_sda_transit = borders_settings.get( + "layer3_handoff_sda_transit") if not layer3_handoff_sda_transit: self.log( "No layer3 handoff SDA transit settings found for device IP: {device_ip}" @@ -3026,10 +3096,12 @@ def get_sda_l3_handoff_params(self, fabric_id, network_id, device_details, devic "The transit type is 'LISP/PUB SUB': {is_transit_pub_sub}" .format(is_transit_pub_sub=is_transit_pub_sub) ) - connected_to_internet = layer3_handoff_sda_transit.get("connected_to_internet") + connected_to_internet = layer3_handoff_sda_transit.get( + "connected_to_internet") if connected_to_internet is None: if is_sda_l3_handoff_exists: - connected_to_internet = have_sda_l3_handoff.get("connectedToInternet") + connected_to_internet = have_sda_l3_handoff.get( + "connectedToInternet") else: connected_to_internet = False @@ -3038,10 +3110,12 @@ def get_sda_l3_handoff_params(self, fabric_id, network_id, device_details, devic .format(device_ip=device_ip, connected_to_internet=connected_to_internet), "DEBUG" ) - is_multicast_over_transit_enabled = layer3_handoff_sda_transit.get("is_multicast_over_transit_enabled") + is_multicast_over_transit_enabled = layer3_handoff_sda_transit.get( + "is_multicast_over_transit_enabled") if is_multicast_over_transit_enabled is None: if is_sda_l3_handoff_exists: - is_multicast_over_transit_enabled = have_sda_l3_handoff.get("isMulticastOverTransitEnabled") + is_multicast_over_transit_enabled = have_sda_l3_handoff.get( + "isMulticastOverTransitEnabled") else: is_multicast_over_transit_enabled = False @@ -3053,7 +3127,8 @@ def get_sda_l3_handoff_params(self, fabric_id, network_id, device_details, devic affinity_id_prime = layer3_handoff_sda_transit.get("affinity_id_prime") if not affinity_id_prime: if is_sda_l3_handoff_exists: - have_affinity_id_prime = have_sda_l3_handoff.get("affinityIdPrime") + have_affinity_id_prime = have_sda_l3_handoff.get( + "affinityIdPrime") if not have_affinity_id_prime: affinity_id_prime = have_affinity_id_prime else: @@ -3081,10 +3156,12 @@ def get_sda_l3_handoff_params(self, fabric_id, network_id, device_details, devic "Affinity ID Prime is set to: {affinity_id_prime}" .format(affinity_id_prime=affinity_id_prime), "DEBUG" ) - affinity_id_decider = layer3_handoff_sda_transit.get("affinity_id_decider") + affinity_id_decider = layer3_handoff_sda_transit.get( + "affinity_id_decider") if not affinity_id_decider: if is_sda_l3_handoff_exists: - have_affinity_id_decider = have_sda_l3_handoff.get("affinityIdDecider") + have_affinity_id_decider = have_sda_l3_handoff.get( + "affinityIdDecider") if not have_affinity_id_decider: affinity_id_decider = have_affinity_id_decider else: @@ -3168,7 +3245,8 @@ def validate_layer3_handoff_ip_transit(self, item, device_ip, is_ip_l3_handoff_e self.log(self.msg, "ERROR") return (None, None, None, None, None, False) - self.log("Transit network name found: {transit_name}".format(transit_name=transit_name), "DEBUG") + self.log("Transit network name found: {transit_name}".format( + transit_name=transit_name), "DEBUG") transit_id = self.get_transit_id_from_name(transit_name) if not transit_id: self.msg = ( @@ -3179,7 +3257,8 @@ def validate_layer3_handoff_ip_transit(self, item, device_ip, is_ip_l3_handoff_e self.log(self.msg, "ERROR") return (None, None, None, None, None, False) - self.log("Transit network ID resolved: {transit_id}".format(transit_id=transit_id), "DEBUG") + self.log("Transit network ID resolved: {transit_id}".format( + transit_id=transit_id), "DEBUG") interface_name = item.get("interface_name") if not interface_name: self.msg = ( @@ -3190,10 +3269,12 @@ def validate_layer3_handoff_ip_transit(self, item, device_ip, is_ip_l3_handoff_e self.log(self.msg, "ERROR") return (None, None, None, None, None, False) - self.log("Interface name found: {interface_name}".format(interface_name=interface_name), "DEBUG") + self.log("Interface name found: {interface_name}".format( + interface_name=interface_name), "DEBUG") virtual_network_name = item.get("virtual_network_name") if virtual_network_name: - is_valid_virtual_network = self.check_valid_virtual_network_name(virtual_network_name) + is_valid_virtual_network = self.check_valid_virtual_network_name( + virtual_network_name) if not is_valid_virtual_network: self.msg = ( "The virtual network with the name '{virtual_nw_name}' is not valid." @@ -3203,7 +3284,8 @@ def validate_layer3_handoff_ip_transit(self, item, device_ip, is_ip_l3_handoff_e self.log(self.msg, "ERROR") return (None, None, None, None, None, False) - self.log("Valid virtual network name: {vn_name}".format(vn_name=virtual_network_name), "DEBUG") + self.log("Valid virtual network name: {vn_name}".format( + vn_name=virtual_network_name), "DEBUG") vlan_id = item.get("vlan_id") if vlan_id: @@ -3252,7 +3334,8 @@ def validate_layer3_handoff_ip_transit(self, item, device_ip, is_ip_l3_handoff_e elif virtual_network_name and (not vlan_id): vlan_id = have_ip_l3_handoff[l3_ip_handoff_index].get("vlanId") elif vlan_id and (not virtual_network_name): - virtual_network_name = have_ip_l3_handoff[l3_ip_handoff_index].get("virtualNetworkName") + virtual_network_name = have_ip_l3_handoff[l3_ip_handoff_index].get( + "virtualNetworkName") else: if not (virtual_network_name and vlan_id): self.msg = ( @@ -3267,7 +3350,8 @@ def validate_layer3_handoff_ip_transit(self, item, device_ip, is_ip_l3_handoff_e tcp_mss_adjustment = item.get("tcp_mss_adjustment") if not tcp_mss_adjustment: if is_ip_l3_handoff_exists: - have_tcp_mss_adjustment = have_ip_l3_handoff[l3_ip_handoff_index].get("tcpMssAdjustment") + have_tcp_mss_adjustment = have_ip_l3_handoff[l3_ip_handoff_index].get( + "tcpMssAdjustment") if have_tcp_mss_adjustment: tcp_mss_adjustment = have_tcp_mss_adjustment else: @@ -3327,7 +3411,8 @@ def get_ip_l3_handoff_params(self, fabric_id, network_id, device_details, device ) return ip_l3_handoff_info - layer3_handoff_ip_transit = borders_settings.get("layer3_handoff_ip_transit") + layer3_handoff_ip_transit = borders_settings.get( + "layer3_handoff_ip_transit") if not layer3_handoff_ip_transit: self.log( "No Layer 3 Handoff with IP Transit found for device with IP: {ip}" @@ -3355,7 +3440,8 @@ def get_ip_l3_handoff_params(self, fabric_id, network_id, device_details, device (transit_id, interface_name, virtual_network_name, vlan_id, tcp_mss_adjustment, is_valid) = \ self.validate_layer3_handoff_ip_transit( - item, device_details.get("device_ip"), is_ip_l3_handoff_exists, + item, device_details.get( + "device_ip"), is_ip_l3_handoff_exists, have_ip_l3_handoff, l3_ip_handoff_index ) @@ -3380,10 +3466,14 @@ def get_ip_l3_handoff_params(self, fabric_id, network_id, device_details, device # If the fabric device is avaiable, then fetch the local and remote IP addresses if is_ip_l3_handoff_exists: - local_ip_address = have_ip_l3_handoff[l3_ip_handoff_index].get("localIpAddress") - remote_ip_address = have_ip_l3_handoff[l3_ip_handoff_index].get("remoteIpAddress") - local_ipv6_address = have_ip_l3_handoff[l3_ip_handoff_index].get("localIpv6Address") - remote_ipv6_address = have_ip_l3_handoff[l3_ip_handoff_index].get("remoteIpv6Address") + local_ip_address = have_ip_l3_handoff[l3_ip_handoff_index].get( + "localIpAddress") + remote_ip_address = have_ip_l3_handoff[l3_ip_handoff_index].get( + "remoteIpAddress") + local_ipv6_address = have_ip_l3_handoff[l3_ip_handoff_index].get( + "localIpv6Address") + remote_ipv6_address = have_ip_l3_handoff[l3_ip_handoff_index].get( + "remoteIpv6Address") l3_ip_handoff.update({ "localIpAddress": local_ip_address, "remoteIpAddress": remote_ip_address, @@ -3394,7 +3484,8 @@ def get_ip_l3_handoff_params(self, fabric_id, network_id, device_details, device # If external_connectivity_ip_pool_name is given local and remote address will be ignored # If external_connectivity_ip_pool_name is not given, then local and remote is mandatory - external_connectivity_ip_pool_name = item.get("external_connectivity_ip_pool_name") + external_connectivity_ip_pool_name = item.get( + "external_connectivity_ip_pool_name") if external_connectivity_ip_pool_name: # Check if the reserved pool is available in the Cisco Catalyst Center or not @@ -3474,7 +3565,8 @@ def get_want_fabric_devices(self, fabric_devices): device_config_index = -1 for item in device_config: device_config_index += 1 - fabric_site_id = self.have.get("fabric_devices")[device_config_index].get("fabric_site_id") + fabric_site_id = self.have.get("fabric_devices")[ + device_config_index].get("fabric_site_id") device_ip = fabric_devices.get("device_ip") self.log( "Processing device configuration at index: {index}" @@ -3486,7 +3578,8 @@ def get_want_fabric_devices(self, fabric_devices): "sda_l3_handoff_details": None, "ip_l3_handoff_details": [], } - network_device_id = self.have.get("fabric_devices")[device_config_index].get("network_device_id") + network_device_id = self.have.get("fabric_devices")[ + device_config_index].get("network_device_id") fabric_devices_info.update({ "device_details": self.get_device_params(fabric_site_id, network_device_id, @@ -3542,7 +3635,8 @@ def get_want(self, config): Collect the fabric devices details from the playbook if fabric_devices exists. """ - self.log("Starting to retrieve fabric devices information from the provided configuration.", "DEBUG") + self.log( + "Starting to retrieve fabric devices information from the provided configuration.", "DEBUG") fabric_devices = config.get("fabric_devices") if not fabric_devices: self.msg = "The parameter 'fabric_devices' is missing under the 'config'." @@ -3551,7 +3645,8 @@ def get_want(self, config): self.get_want_fabric_devices(fabric_devices).check_return_status() - self.log("Desired State (want): {requested_state}".format(requested_state=self.want), "INFO") + self.log("Desired State (want): {requested_state}".format( + requested_state=self.want), "INFO") self.msg = "Successfully retrieved details from the playbook." self.status = "success" return self @@ -3577,7 +3672,8 @@ def update_l2_handoff(self, have_l2_handoff, want_l2_handoff, create the L2 Handoff in the provided device. """ - self.log("Starting L2 Handoff update process for device IP: {ip}".format(ip=device_ip), "DEBUG") + self.log("Starting L2 Handoff update process for device IP: {ip}".format( + ip=device_ip), "DEBUG") create_l2_handoff = [] l2_handoff_index = -1 @@ -3598,7 +3694,8 @@ def update_l2_handoff(self, have_l2_handoff, want_l2_handoff, ) if not create_l2_handoff: - self.log("No new L2 Handoffs to create for device IP: {ip}".format(ip=device_ip), "INFO") + self.log("No new L2 Handoffs to create for device IP: {ip}".format( + ip=device_ip), "INFO") self.msg = "No new L2 Handoffs are available to create." self.status = "success" return self @@ -3619,8 +3716,10 @@ def update_l2_handoff(self, have_l2_handoff, want_l2_handoff, "L2 Handoff(s) '{l2_handoff}' added successfully in the device with IP '{ip}." .format(l2_handoff=create_l2_handoff, ip=device_ip) ) - self.log("Starting task status check for task ID: {task_id}".format(task_id=task_id), "DEBUG") - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg).check_return_status() + self.log("Starting task status check for task ID: {task_id}".format( + task_id=task_id), "DEBUG") + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg).check_return_status() except Exception as msg: self.msg = ( "Exception occurred while creating the L2 Handoff(s) in the device '{ip}': {msg}" @@ -3662,7 +3761,8 @@ def update_sda_l3_handoff(self, have_sda_l3_handoff, want_sda_l3_handoff, create the SDA L3 Handoff in the provided device. """ - self.log("Starting update process for SDA L3 Handoff on device IP: {ip}".format(ip=device_ip), "DEBUG") + self.log("Starting update process for SDA L3 Handoff on device IP: {ip}".format( + ip=device_ip), "DEBUG") # Check is SDA L3 Handoff exists or not if not have_sda_l3_handoff: @@ -3677,21 +3777,25 @@ def update_sda_l3_handoff(self, have_sda_l3_handoff, want_sda_l3_handoff, "Preparing to add new SDA L3 Handoff with payload: {payload}" .format(payload=payload), "DEBUG" ) - task_id = self.get_taskid_post_api_call("sda", task_name, payload) + task_id = self.get_taskid_post_api_call( + "sda", task_name, payload) if not task_id: self.msg = ( "Unable to retrive the task_id for the task '{task_name}'." .format(task_name=task_name) ) - self.set_operation_result("failed", False, self.msg, "ERROR") + self.set_operation_result( + "failed", False, self.msg, "ERROR") return self success_msg = ( "L3 Handoff(s) with SDA Transit '{sda_l2_handoff}' added successfully in the device with IP '{ip}." .format(sda_l2_handoff=want_sda_l3_handoff, ip=device_ip) ) - self.log("Task ID retrieved: {task_id}".format(task_id=task_id), "DEBUG") - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg).check_return_status() + self.log("Task ID retrieved: {task_id}".format( + task_id=task_id), "DEBUG") + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg).check_return_status() except Exception as msg: self.msg = ( "Exception occurred while adding the SDA L3 Handoff for the device '{ip}': {msg}" @@ -3735,7 +3839,8 @@ def update_sda_l3_handoff(self, have_sda_l3_handoff, want_sda_l3_handoff, self.status = "success" return self - self.log("Updating SDA L3 Handoff for the device '{ip}'.".format(ip=device_ip), "DEBUG") + self.log("Updating SDA L3 Handoff for the device '{ip}'.".format( + ip=device_ip), "DEBUG") # SDA L3 Handoff requires an update or not try: @@ -3761,8 +3866,10 @@ def update_sda_l3_handoff(self, have_sda_l3_handoff, want_sda_l3_handoff, "L3 Handoff(s) with SDA Transit '{sda_l3_handoff}' updated successfully in the device with IP '{ip}." .format(sda_l3_handoff=want_sda_l3_handoff, ip=device_ip) ) - self.log("Task ID retrieved: {task_id}".format(task_id=task_id), "DEBUG") - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg).check_return_status() + self.log("Task ID retrieved: {task_id}".format( + task_id=task_id), "DEBUG") + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg).check_return_status() except Exception as msg: self.msg = ( "Exception occurred while updating the SDA L3 Handoff for the device '{ip}': {msg}" @@ -3854,7 +3961,8 @@ def update_ip_l3_handoff(self, have_ip_l3_handoff, want_ip_l3_handoff, ), "DEBUG" ) - item.update({"id": have_ip_l3_handoff[ip_l3_handoff_index].get("id")}) + item.update( + {"id": have_ip_l3_handoff[ip_l3_handoff_index].get("id")}) update_ip_l3_handoff.append(item) # If both the list are empty, then not update is required @@ -3884,20 +3992,23 @@ def update_ip_l3_handoff(self, have_ip_l3_handoff, want_ip_l3_handoff, try: payload = {"payload": create_ip_l3_handoff} task_name = "add_fabric_devices_layer3_handoffs_with_ip_transit" - task_id = self.get_taskid_post_api_call("sda", task_name, payload) + task_id = self.get_taskid_post_api_call( + "sda", task_name, payload) if not task_id: self.msg = ( "Unable to retrive the task_id for the task '{task_name}'." .format(task_name=task_name) ) - self.set_operation_result("failed", False, self.msg, "ERROR") + self.set_operation_result( + "failed", False, self.msg, "ERROR") return self success_msg = ( "L3 Handoff(s) with IP Transit '{ip_l3_handoff}' added successfully in the device with IP '{ip}." .format(ip_l3_handoff=create_ip_l3_handoff, ip=device_ip) ) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg).check_return_status() + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg).check_return_status() except Exception as msg: self.msg = ( "Exception occurred while adding the L3 Handoff with IP Transit to the device '{ip}': {msg}" @@ -3923,20 +4034,23 @@ def update_ip_l3_handoff(self, have_ip_l3_handoff, want_ip_l3_handoff, try: payload = {"payload": update_ip_l3_handoff} task_name = "update_fabric_devices_layer3_handoffs_with_ip_transit" - task_id = self.get_taskid_post_api_call("sda", task_name, payload) + task_id = self.get_taskid_post_api_call( + "sda", task_name, payload) if not task_id: self.msg = ( "Unable to retrive the task_id for the task '{task_name}'." .format(task_name=task_name) ) - self.set_operation_result("failed", False, self.msg, "ERROR") + self.set_operation_result( + "failed", False, self.msg, "ERROR") return self success_msg = ( "L3 Handoff(s) with IP Transit '{ip_l3_handoff}' updated successfully in the device with IP '{ip}." .format(ip_l3_handoff=update_ip_l3_handoff, ip=device_ip) ) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg).check_return_status() + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg).check_return_status() except Exception as msg: self.msg = ( "Exception occurred while updating the L3 Handoff with IP Transit to the device '{ip}': {msg}" @@ -3986,7 +4100,8 @@ def update_fabric_devices(self, fabric_devices): fabric_name = fabric_devices.get("fabric_name") if not fabric_name: self.log("Error: 'fabric_name' is missing from input.", "ERROR") - self.set_operation_result("failed", False, "Fabric name is required.", "ERROR") + self.set_operation_result( + "failed", False, "Fabric name is required.", "ERROR") return self self.log("Fabric name: '{fabric_name}".format(fabric_name=fabric_name)) @@ -3994,7 +4109,8 @@ def update_fabric_devices(self, fabric_devices): device_config = fabric_devices.get("device_config") if not device_config: self.log("Error: 'device_config' is missing from input.", "ERROR") - self.set_operation_result("failed", False, "Device configuration is required.", "ERROR") + self.set_operation_result( + "failed", False, "Device configuration is required.", "ERROR") return self self.log( @@ -4009,7 +4125,8 @@ def update_fabric_devices(self, fabric_devices): device_ip = item.get("device_ip") if not device_config: self.log("Error: 'device_ip' is missing from input.", "ERROR") - self.set_operation_result("failed", False, "Device IP is required.", "ERROR") + self.set_operation_result( + "failed", False, "Device IP is required.", "ERROR") return self self.log( @@ -4027,11 +4144,15 @@ def update_fabric_devices(self, fabric_devices): self.response[0].get("msg").get(fabric_name).update({ device_ip: {} }) - result_fabric_device_response = self.response[0].get("response").get(fabric_name).get(device_ip) + result_fabric_device_response = self.response[0].get( + "response").get(fabric_name).get(device_ip) self.log("hi") - result_fabric_device_msg = self.response[0].get("msg").get(fabric_name).get(device_ip) - have_fabric_device = self.have.get("fabric_devices")[fabric_device_index] - want_fabric_device = self.want.get("fabric_devices")[fabric_device_index] + result_fabric_device_msg = self.response[0].get( + "msg").get(fabric_name).get(device_ip) + have_fabric_device = self.have.get("fabric_devices")[ + fabric_device_index] + want_fabric_device = self.want.get("fabric_devices")[ + fabric_device_index] have_device_details = have_fabric_device.get("device_details") want_device_details = want_fabric_device.get("device_details") self.log( @@ -4050,10 +4171,12 @@ def update_fabric_devices(self, fabric_devices): try: device_roles = want_device_details.get("deviceRoles") self.log( - "Device roles retrieved: {device_roles}".format(device_roles=device_roles), "DEBUG" + "Device roles retrieved: {device_roles}".format( + device_roles=device_roles), "DEBUG" ) if device_roles == ["CONTROL_PLANE_NODE"]: - route_distribution_protocol = item.get("route_distribution_protocol") + route_distribution_protocol = item.get( + "route_distribution_protocol") self.log( "Route distribution protocol set to: {route_distribution_protocol}".format( route_distribution_protocol=route_distribution_protocol @@ -4116,21 +4239,24 @@ def update_fabric_devices(self, fabric_devices): else: payload = {"payload": [want_device_details]} task_name = "add_fabric_devices" - task_id = self.get_taskid_post_api_call("sda", task_name, payload) + task_id = self.get_taskid_post_api_call( + "sda", task_name, payload) if not task_id: self.msg = ( "Unable to retrive the task_id for the task '{task_name}'." .format(task_name=task_name) ) - self.set_operation_result("failed", False, self.msg, "ERROR") + self.set_operation_result( + "failed", False, self.msg, "ERROR") return self success_msg = ( "Successfully added the fabric device with details '{device_details}'." .format(device_details=want_device_details) ) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg).check_return_status() + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg).check_return_status() except Exception as msg: self.msg = ( "Exception occurred while adding the device '{ip}' to the fabric site '{site}: {msg}" @@ -4171,7 +4297,8 @@ def update_fabric_devices(self, fabric_devices): "device_details": "SDA fabric device details doesn't require an update." }) else: - self.log("Updating SDA fabric device '{ip}'.".format(ip=device_ip), "DEBUG") + self.log("Updating SDA fabric device '{ip}'.".format( + ip=device_ip), "DEBUG") # Device Details Exists self.log( @@ -4182,24 +4309,28 @@ def update_fabric_devices(self, fabric_devices): "Desired SDA fabric device '{ip}' details: {requested_state}" .format(ip=device_ip, requested_state=want_device_details), "DEBUG" ) - want_device_details.update({"id": self.have.get("fabric_devices")[fabric_device_index].get("id")}) + want_device_details.update({"id": self.have.get( + "fabric_devices")[fabric_device_index].get("id")}) try: payload = {"payload": [want_device_details]} task_name = "update_fabric_devices" - task_id = self.get_taskid_post_api_call("sda", task_name, payload) + task_id = self.get_taskid_post_api_call( + "sda", task_name, payload) if not task_id: self.msg = ( "Unable to retrive the task_id for the task '{task_name}'." .format(task_name=task_name) ) - self.set_operation_result("failed", False, self.msg, "ERROR") + self.set_operation_result( + "failed", False, self.msg, "ERROR") return self success_msg = ( "Successfully updated the fabric device with details '{device_details}'." .format(device_details=want_device_details) ) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg).check_return_status() + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg).check_return_status() except Exception as msg: self.msg = ( "Exception occurred while updating the fabric device with IP '{ip}': {msg}" @@ -4235,8 +4366,10 @@ def update_fabric_devices(self, fabric_devices): result_fabric_device_response, result_fabric_device_msg) - have_sda_l3_handoff = have_fabric_device.get("sda_l3_handoff_details") - want_sda_l3_handoff = want_fabric_device.get("sda_l3_handoff_details") + have_sda_l3_handoff = have_fabric_device.get( + "sda_l3_handoff_details") + want_sda_l3_handoff = want_fabric_device.get( + "sda_l3_handoff_details") if want_sda_l3_handoff: self.log( "Operating the L3 Handoff with SDA Transit details for the device '{device_ip}'." @@ -4246,8 +4379,10 @@ def update_fabric_devices(self, fabric_devices): result_fabric_device_response, result_fabric_device_msg) - have_ip_l3_handoff = have_fabric_device.get("ip_l3_handoff_details") - want_ip_l3_handoff = want_fabric_device.get("ip_l3_handoff_details") + have_ip_l3_handoff = have_fabric_device.get( + "ip_l3_handoff_details") + want_ip_l3_handoff = want_fabric_device.get( + "ip_l3_handoff_details") if want_ip_l3_handoff: self.log( "Operating the L3 Handoff with IP Transit details for the device '{device_ip}'." @@ -4281,16 +4416,20 @@ def get_diff_merged(self, config): fabric_devices = config.get("fabric_devices") if fabric_devices is not None: - self.log("Updating fabric devices: {devices}".format(devices=fabric_devices), "DEBUG") + self.log("Updating fabric devices: {devices}".format( + devices=fabric_devices), "DEBUG") try: self.update_fabric_devices(fabric_devices) self.log("Successfully updated fabric devices.", "INFO") except Exception as e: - self.log("Error while updating fabric devices: {error}".format(error=str(e)), "ERROR") - self.set_operation_result("failed", False, "Failed to update fabric devices.", "ERROR") + self.log("Error while updating fabric devices: {error}".format( + error=str(e)), "ERROR") + self.set_operation_result( + "failed", False, "Failed to update fabric devices.", "ERROR") return self else: - self.log("No 'fabric_devices' found in configuration. Skipping update.", "WARNING") + self.log( + "No 'fabric_devices' found in configuration. Skipping update.", "WARNING") return self @@ -4313,13 +4452,16 @@ def prioritize_device_deletion(self, device_config): fabric_device_index = -1 updated_device_config = [] update_have = [] - self.log("Starting to reorder devices based on their existence and role.", "DEBUG") - self.log("Input device_config: {device_config}".format(device_config=device_config), "DEBUG") + self.log( + "Starting to reorder devices based on their existence and role.", "DEBUG") + self.log("Input device_config: {device_config}".format( + device_config=device_config), "DEBUG") for item in device_config: fabric_device_index += 1 device_ip = item.get("device_ip") self.log("Processing device with IP: {ip}".format(ip=device_ip)) - have_device_details = self.have.get("fabric_devices")[fabric_device_index] + have_device_details = self.have.get("fabric_devices")[ + fabric_device_index] exists = have_device_details.get("exists") if not exists: self.log( @@ -4330,7 +4472,8 @@ def prioritize_device_deletion(self, device_config): update_have = [have_device_details] + update_have continue - device_roles = have_device_details.get("device_details").get("deviceRoles") + device_roles = have_device_details.get( + "device_details").get("deviceRoles") if "CONTROL_PLANE_NODE" in device_roles: self.log( "Device with IP '{ip}' has role 'CONTROL_PLANE_NODE', appending to the end." @@ -4405,13 +4548,15 @@ def delete_l2_handoff(self, have_l2_handoff, device_ip, try: payload = {"id": id} task_name = "delete_fabric_device_layer2_handoff_by_id" - task_id = self.get_taskid_post_api_call("sda", task_name, payload) + task_id = self.get_taskid_post_api_call( + "sda", task_name, payload) if not task_id: self.msg = ( "Unable to retrive the task_id for the task '{task_name}'." .format(task_name=task_name) ) - self.set_operation_result("failed", False, self.msg, "ERROR") + self.set_operation_result( + "failed", False, self.msg, "ERROR") self.log(str(success_msg), "INFO") return self @@ -4419,7 +4564,8 @@ def delete_l2_handoff(self, have_l2_handoff, device_ip, "Successfully deleted the fabric device L2 Handoff with id '{id}'." .format(id=id) ) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg).check_return_status() + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg).check_return_status() except Exception as msg: self.msg = ( "Exception occurred while deleting the L2 Handoff in the fabric device with IP '{ip}': {msg}" @@ -4475,12 +4621,14 @@ def delete_sda_l3_handoff(self, have_sda_l3_handoff, device_ip, "No SDA L3 Handoff found for device IP '{device_ip}'." .format(device_ip=device_ip), "DEBUG" ) - self.log("The SDA L3 Handoff doesnot exist under the device {device_ip}.".format(device_ip=device_ip)) + self.log("The SDA L3 Handoff doesnot exist under the device {device_ip}.".format( + device_ip=device_ip)) result_fabric_device_msg.update({ "sda_l3_handoff_details": "SDA L3 Handoff is not found in the Cisco Catalyst Center." }) else: - self.log("The SDA L3 Handoff exists under the device {device_ip}.".format(device_ip=device_ip)) + self.log("The SDA L3 Handoff exists under the device {device_ip}.".format( + device_ip=device_ip)) fabric_id = have_sda_l3_handoff.get("fabricId") network_device_id = have_sda_l3_handoff.get("networkDeviceId") self.log( @@ -4493,20 +4641,23 @@ def delete_sda_l3_handoff(self, have_sda_l3_handoff, device_ip, "network_device_id": network_device_id, } task_name = "delete_fabric_device_layer3_handoffs_with_sda_transit" - task_id = self.get_taskid_post_api_call("sda", task_name, payload) + task_id = self.get_taskid_post_api_call( + "sda", task_name, payload) if not task_id: self.msg = ( "Unable to retrive the task_id for the task '{task_name}'." .format(task_name=task_name) ) - self.set_operation_result("failed", False, self.msg, "ERROR") + self.set_operation_result( + "failed", False, self.msg, "ERROR") return self success_msg = ( "Successfully deleted the fabric device SDA Transit L3 Handoff with id '{id}'." .format(id=id) ) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg).check_return_status() + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg).check_return_status() except Exception as msg: self.msg = ( "Exception occurred while deleting the SDA L3 Handoff in the fabric device with IP '{ip}': {msg}" @@ -4571,24 +4722,28 @@ def delete_ip_l3_handoff(self, have_ip_l3_handoff, device_ip, for item in delete_ip_l3_handoff: id = item.get("id") - self.log("Attempting to delete IP L3 Handoff with id: {id}".format(id=id), "DEBUG") + self.log("Attempting to delete IP L3 Handoff with id: {id}".format( + id=id), "DEBUG") try: payload = {"id": id} task_name = "delete_fabric_device_layer3_handoff_with_ip_transit_by_id" - task_id = self.get_taskid_post_api_call("sda", task_name, payload) + task_id = self.get_taskid_post_api_call( + "sda", task_name, payload) if not task_id: self.msg = ( "Unable to retrive the task_id for the task '{task_name}'." .format(task_name=task_name) ) - self.set_operation_result("failed", False, self.msg, "ERROR") + self.set_operation_result( + "failed", False, self.msg, "ERROR") return self success_msg = ( "Successfully deleted the fabric device IP Transit L3 Handoff with id '{id}'." .format(id=id) ) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg).check_return_status() + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg).check_return_status() except Exception as msg: self.msg = ( "Exception occurred while deleting the IP L3 Handoff in the fabric device with IP '{ip}': {msg}" @@ -4634,14 +4789,16 @@ def delete_fabric_devices(self, fabric_devices): fabric_name = fabric_devices.get("fabric_name") if not fabric_name: self.log("Error: 'fabric_name' is missing from input.", "ERROR") - self.set_operation_result("failed", False, "Fabric name is required.", "ERROR") + self.set_operation_result( + "failed", False, "Fabric name is required.", "ERROR") return self fabric_device_index = -1 device_config = fabric_devices.get("device_config") if not device_config: self.log("Error: 'device_config' is missing from input.", "ERROR") - self.set_operation_result("failed", False, "Device configuration is required.", "ERROR") + self.set_operation_result( + "failed", False, "Device configuration is required.", "ERROR") return self self.response.append({"response": {}, "msg": {}}) @@ -4666,13 +4823,18 @@ def delete_fabric_devices(self, fabric_devices): self.response[0].get("msg").get(fabric_name).update({ device_ip: {} }) - self.log("Processing device with IP '{device_ip}'".format(device_ip=device_ip), "DEBUG") - result_fabric_device_response = self.response[0].get("response").get(fabric_name).get(device_ip) - result_fabric_device_msg = self.response[0].get("msg").get(fabric_name).get(device_ip) - have_fabric_device = self.have.get("fabric_devices")[fabric_device_index] + self.log("Processing device with IP '{device_ip}'".format( + device_ip=device_ip), "DEBUG") + result_fabric_device_response = self.response[0].get( + "response").get(fabric_name).get(device_ip) + result_fabric_device_msg = self.response[0].get( + "msg").get(fabric_name).get(device_ip) + have_fabric_device = self.have.get("fabric_devices")[ + fabric_device_index] have_l2_handoff = have_fabric_device.get("l2_handoff_details") if have_l2_handoff: - self.log("Deleting L2 Handoff for device '{device_ip}'".format(device_ip=device_ip), "DEBUG") + self.log("Deleting L2 Handoff for device '{device_ip}'".format( + device_ip=device_ip), "DEBUG") self.delete_l2_handoff(have_l2_handoff, device_ip, result_fabric_device_response, result_fabric_device_msg).check_return_status() @@ -4680,9 +4842,11 @@ def delete_fabric_devices(self, fabric_devices): result_fabric_device_msg.update({ "l3_ip_handoff": "IP L3 Handoff doesnot found in the Cisco Catalyst Center." }) - have_sda_l3_handoff = have_fabric_device.get("sda_l3_handoff_details") + have_sda_l3_handoff = have_fabric_device.get( + "sda_l3_handoff_details") if have_sda_l3_handoff: - self.log("Deleting SDA L3 Handoff for device '{device_ip}'".format(device_ip=device_ip), "DEBUG") + self.log("Deleting SDA L3 Handoff for device '{device_ip}'".format( + device_ip=device_ip), "DEBUG") self.delete_sda_l3_handoff(have_sda_l3_handoff, device_ip, result_fabric_device_response, result_fabric_device_msg).check_return_status() @@ -4691,10 +4855,12 @@ def delete_fabric_devices(self, fabric_devices): "l3_sda_handoff": "SDA L3 Handoff doesnot found in the Cisco Catalyst Center." }) - have_ip_l3_handoff = have_fabric_device.get("ip_l3_handoff_details") + have_ip_l3_handoff = have_fabric_device.get( + "ip_l3_handoff_details") if have_ip_l3_handoff: - self.log("Deleting IP L3 Handoff for device '{device_ip}'".format(device_ip=device_ip), "DEBUG") + self.log("Deleting IP L3 Handoff for device '{device_ip}'".format( + device_ip=device_ip), "DEBUG") self.delete_ip_l3_handoff(have_ip_l3_handoff, device_ip, result_fabric_device_response, result_fabric_device_msg).check_return_status() @@ -4703,7 +4869,8 @@ def delete_fabric_devices(self, fabric_devices): "l2_handoff": "L2 Handoff doesnot found in the Cisco Catalyst Center." }) - delete_fabric_device = have_fabric_device.get("delete_fabric_device") + delete_fabric_device = have_fabric_device.get( + "delete_fabric_device") device_exists = have_fabric_device.get("exists") # If the delete_fabric_device is set to True @@ -4718,20 +4885,23 @@ def delete_fabric_devices(self, fabric_devices): try: payload = {"id": id} task_name = "delete_fabric_device_by_id" - task_id = self.get_taskid_post_api_call("sda", task_name, payload) + task_id = self.get_taskid_post_api_call( + "sda", task_name, payload) if not task_id: self.msg = ( "Unable to retrive the task_id for the task '{task_name}'." .format(task_name=task_name) ) - self.set_operation_result("failed", False, self.msg, "ERROR") + self.set_operation_result( + "failed", False, self.msg, "ERROR") return self success_msg = ( "Successfully deleted the SDA fabric device with IP '{ip}'." .format(ip=device_ip) ) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg).check_return_status() + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg).check_return_status() result_fabric_device_msg.update({ "device_details": "SDA device successfully removed from fabric." }) @@ -4776,10 +4946,12 @@ def get_diff_deleted(self, config): fabric_devices = config.get("fabric_devices") if fabric_devices is not None: - self.log("Fabric devices found in the configuration. Initiating deletion process.", "INFO") + self.log( + "Fabric devices found in the configuration. Initiating deletion process.", "INFO") self.delete_fabric_devices(fabric_devices) else: - self.log("No fabric devices found in the configuration. No deletion actions performed.", "INFO") + self.log( + "No fabric devices found in the configuration. No deletion actions performed.", "INFO") return self @@ -4803,7 +4975,8 @@ def verify_ip_l3_handoff(self, device_ip, have_l3_ip, want_l3_ip): item, self.fabric_l3_handoff_ip_obj_params): self.msg = ( "The L3 Handoff for IP transit config for the device '{ip}' is still not " - "applied to the Cisco Catalyst Center.".format(ip=device_ip) + "applied to the Cisco Catalyst Center.".format( + ip=device_ip) ) self.status = "failed" return self @@ -4831,7 +5004,8 @@ def verify_l2_handoff(self, device_ip, have_l2, want_l2): if not have_l2[l2_handoff_index]: self.msg = ( "The L2 Handoff for config '{config}' for the device '{ip}' is still not " - "applied to the Cisco Catalyst Center.".format(config=item, ip=device_ip) + "applied to the Cisco Catalyst Center.".format( + config=item, ip=device_ip) ) self.status = "failed" return self @@ -4907,8 +5081,10 @@ def verify_diff_merged(self, config): """ self.get_have(config) - self.log("Current State (have): {current_state}".format(current_state=self.have), "INFO") - self.log("Desired State (want): {requested_state}".format(requested_state=self.want), "INFO") + self.log("Current State (have): {current_state}".format( + current_state=self.have), "INFO") + self.log("Desired State (want): {requested_state}".format( + requested_state=self.want), "INFO") fabric_devices = config.get("fabric_devices") if fabric_devices is not None: fabric_name = fabric_devices.get("fabric_name") @@ -4917,14 +5093,17 @@ def verify_diff_merged(self, config): for item in device_config: fabric_device_index += 1 device_ip = item.get("device_ip") - have_details = self.have.get("fabric_devices")[fabric_device_index] - want_details = self.want.get("fabric_devices")[fabric_device_index] + have_details = self.have.get("fabric_devices")[ + fabric_device_index] + want_details = self.want.get("fabric_devices")[ + fabric_device_index] # Verifying whether the IP L3 Handoff is applied to the Cisco Catalyst Center or not if item.get("layer3_handoff_ip_transit"): have_l3_ip = have_details.get("ip_l3_handoff_details") want_l3_ip = want_details.get("ip_l3_handoff_details") - self.verify_ip_l3_handoff(device_ip, have_l3_ip, want_l3_ip).check_return_status() + self.verify_ip_l3_handoff( + device_ip, have_l3_ip, want_l3_ip).check_return_status() self.log( "Successfully validated the L3 Handoffs for IP Transit in the device '{ip}'." .format(ip=device_ip), "INFO" @@ -4934,7 +5113,8 @@ def verify_diff_merged(self, config): if item.get("layer3_handoff_sda_transit"): have_l3_sda = have_details.get("sda_l3_handoff_details") want_l3_sda = want_details.get("sda_l3_handoff_details") - self.verify_sda_l3_handoff(device_ip, have_l3_sda, want_l3_sda).check_return_status() + self.verify_sda_l3_handoff( + device_ip, have_l3_sda, want_l3_sda).check_return_status() self.log( "Successfully validated the L3 Handoffs for SDA Transit in the device '{ip}'." @@ -4945,7 +5125,8 @@ def verify_diff_merged(self, config): if item.get("layer2_handoff"): have_l2 = have_details.get("sda_l3_handoff_details") want_l2 = want_details.get("sda_l3_handoff_details") - self.verify_l2_handoff(device_ip, have_l2, want_l2).check_return_status() + self.verify_l2_handoff( + device_ip, have_l2, want_l2).check_return_status() self.log( "Successfully validated the L2 Handoffs for in the device '{ip}'." @@ -4990,7 +5171,8 @@ def verify_diff_deleted(self, config): """ self.get_have(config) - self.log("Current State (have): {current_state}".format(current_state=self.have), "INFO") + self.log("Current State (have): {current_state}".format( + current_state=self.have), "INFO") fabric_devices = config.get("fabric_devices") if fabric_devices is not None: fabric_name = fabric_devices.get("fabric_name") @@ -4998,9 +5180,11 @@ def verify_diff_deleted(self, config): fabric_device_index = -1 for item in device_config: fabric_device_index += 1 - delete_fabric_device = self.have.get("fabric_devices")[fabric_device_index].get("delete_fabric_device") + delete_fabric_device = self.have.get("fabric_devices")[ + fabric_device_index].get("delete_fabric_device") device_ip = item.get("device_ip") - fabric_device_details = self.have.get("fabric_devices")[fabric_device_index] + fabric_device_details = self.have.get("fabric_devices")[ + fabric_device_index] if item.get("layer3_handoff_ip_transit"): # Verifying the absence of IP L3 Handoff @@ -5116,7 +5300,8 @@ def main(): } # Create an AnsibleModule object with argument specifications - module = AnsibleModule(argument_spec=element_spec, supports_check_mode=False) + module = AnsibleModule(argument_spec=element_spec, + supports_check_mode=False) ccc_sda_devices = FabricDevices(module) if ccc_sda_devices.compare_dnac_versions(ccc_sda_devices.get_ccc_version(), "2.3.7.6") < 0: ccc_sda_devices.msg = ( @@ -5142,9 +5327,11 @@ def main(): ccc_sda_devices.get_have(config).check_return_status() if state != "deleted": ccc_sda_devices.get_want(config).check_return_status() - ccc_sda_devices.get_diff_state_apply[state](config).check_return_status() + ccc_sda_devices.get_diff_state_apply[state]( + config).check_return_status() if config_verify: - ccc_sda_devices.verify_diff_state_apply[state](config).check_return_status() + ccc_sda_devices.verify_diff_state_apply[state]( + config).check_return_status() module.exit_json(**ccc_sda_devices.result) diff --git a/plugins/modules/sda_fabric_sites_zones_workflow_manager.py b/plugins/modules/sda_fabric_sites_zones_workflow_manager.py index d3dfa637ea..34293be310 100644 --- a/plugins/modules/sda_fabric_sites_zones_workflow_manager.py +++ b/plugins/modules/sda_fabric_sites_zones_workflow_manager.py @@ -5,6 +5,11 @@ # 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 +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, +) +from ansible.module_utils.basic import AnsibleModule __metaclass__ = type __author__ = ("Abhishek Maheshwari, Madhan Sankaranarayanan") @@ -280,12 +285,6 @@ } """ -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, -) - class FabricSitesZones(DnacBase): """Class containing member attributes for sda fabric sites and zones workflow manager module""" @@ -349,12 +348,14 @@ def validate_input(self): ) if invalid_params: - self.msg = "The playbook contains invalid parameters: {0}".format(invalid_params) + self.msg = "The playbook contains invalid parameters: {0}".format( + invalid_params) self.set_operation_result("failed", False, self.msg, "ERROR") return self self.validated_config = valid_temp - self.msg = "Successfully validated playbook configuration parameters using 'validate_input': {0}".format(str(valid_temp)) + self.msg = "Successfully validated playbook configuration parameters using 'validate_input': {0}".format( + str(valid_temp)) self.log(self.msg, "INFO") return self @@ -384,17 +385,20 @@ def get_fabric_site_detail(self, site_name, site_id): params={"site_id": site_id}, ) response = response.get("response") - self.log("Received API response from 'get_fabric_sites' for the site '{0}': {1}".format(site_name, str(response)), "DEBUG") + self.log("Received API response from 'get_fabric_sites' for the site '{0}': {1}".format( + site_name, str(response)), "DEBUG") if not response: - self.log("Given site '{0}' is not a fabric site in Cisco Catalyst Center.".format(site_name), "INFO") + self.log("Given site '{0}' is not a fabric site in Cisco Catalyst Center.".format( + site_name), "INFO") return None return response[0] except Exception as e: self.msg = """Error while getting the details of Site with given name '{0}' present in Cisco Catalyst Center: {1}""".format(site_name, str(e)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() return None @@ -423,10 +427,12 @@ def get_fabric_zone_detail(self, site_name, site_id): params={"site_id": site_id}, ) response = response.get("response") - self.log("Received API response from 'get_fabric_zones' for the site '{0}': {1}".format(site_name, str(response)), "DEBUG") + self.log("Received API response from 'get_fabric_zones' for the site '{0}': {1}".format( + site_name, str(response)), "DEBUG") if not response: - self.log("Given site '{0}' is not a fabric zone in Cisco Catalyst Center.".format(site_name), "INFO") + self.log("Given site '{0}' is not a fabric zone in Cisco Catalyst Center.".format( + site_name), "INFO") return None return response[0] @@ -434,7 +440,8 @@ def get_fabric_zone_detail(self, site_name, site_id): except Exception as e: self.msg = """Error while getting the details of fabric zone '{0}' present in Cisco Catalyst Center: {1}""".format(site_name, str(e)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() return None @@ -468,18 +475,22 @@ def get_have(self, config): fabric_type = site.get("fabric_type", "fabric_site") site_exists, site_id = self.get_site_id(site_name) if not site_exists: - self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format( + site_name) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() if fabric_type == "fabric_site": site_detail = self.get_fabric_site_detail(site_name, site_id) if site_detail: - self.log("Site detail for fabric site {0} collected successfully.".format(site_name), "DEBUG") + self.log("Site detail for fabric site {0} collected successfully.".format( + site_name), "DEBUG") have["fabric_sites_ids"].append(site_detail.get("siteId")) else: zone_detail = self.get_fabric_zone_detail(site_name, site_id) if zone_detail: - self.log("Site detail for fabric zone {0} collected successfully.".format(site_name), "DEBUG") + self.log("Site detail for fabric zone {0} collected successfully.".format( + site_name), "DEBUG") have["fabric_zone_ids"].append(zone_detail.get("siteId")) self.have = have @@ -513,7 +524,8 @@ def get_want(self, config): "No input provided in the playbook for fabric site/zone operation or updating the " "authentication profile template in Cisco Catalysyt Center." ) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() if fabric_sites: fabric_site_info = [] @@ -527,21 +539,24 @@ def get_want(self, config): "Required parameter 'site_name' is missing. It must be provided in the playbook for fabric site/zone " "operations in Cisco Catalyst Center." ) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() if site_name.title() == "Global": self.msg = ( "Unable to create/update the given site 'Global' to {0} as it is not allowed operation " "in the Cisco Catalyst Center." ).format(fabric_type) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() if fabric_type not in ["fabric_site", "fabric_zone"]: self.msg = ( "Invalid fabric_type '{0}' provided. Please use 'fabric_site' or 'fabric_zone' for fabric site/zone operations" " in Cisco Catalyst Center." ).format(fabric_type) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() fabric_site_info.append(site) @@ -577,8 +592,10 @@ def create_fabric_site(self, site): site_name = site.get("site_name_hierarchy") site_exists, site_id = self.get_site_id(site_name) if not site_exists: - self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format( + site_name) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() auth_profile = site.get("authentication_profile") if not auth_profile: @@ -587,7 +604,8 @@ def create_fabric_site(self, site): "Please provide one of the following authentication_profile ['Closed Authentication', 'Low Impact'" ", 'No Authentication', 'Open Authentication'] in the playbook." ) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() site_payload = { "siteId": site_id, @@ -600,16 +618,20 @@ def create_fabric_site(self, site): task_id = self.get_taskid_post_api_call("sda", task_name, payload) if not task_id: - self.msg = "Unable to retrieve the task_id for the task '{0}'.".format(task_name) + self.msg = "Unable to retrieve the task_id for the task '{0}'.".format( + task_name) self.set_operation_result("failed", False, self.msg, "ERROR") return self - success_msg = "Fabric site '{0}' created successfully in the Cisco Catalyst Center".format(site_name) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + success_msg = "Fabric site '{0}' created successfully in the Cisco Catalyst Center".format( + site_name) + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) self.create_site.append(site_name) except Exception as e: - self.msg = "An exception occured while creating the fabric site '{0}' in Cisco Catalyst Center: {1}".format(site_name, str(e)) + self.msg = "An exception occured while creating the fabric site '{0}' in Cisco Catalyst Center: {1}".format( + site_name, str(e)) self.set_operation_result("failed", False, self.msg, "ERROR") return self @@ -687,16 +709,20 @@ def update_fabric_site(self, site, site_in_ccc): task_id = self.get_taskid_post_api_call("sda", task_name, payload) if not task_id: - self.msg = "Unable to retrieve the task_id for the task '{0}'.".format(task_name) + self.msg = "Unable to retrieve the task_id for the task '{0}'.".format( + task_name) self.set_operation_result("failed", False, self.msg, "ERROR") return self - success_msg = "Fabric site '{0}' updated successfully in the Cisco Catalyst Center".format(site_name) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + success_msg = "Fabric site '{0}' updated successfully in the Cisco Catalyst Center".format( + site_name) + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) self.update_site.append(site_name) except Exception as e: - self.msg = "An exception occured while updating the fabric site '{0}' in Cisco Catalyst Center: {1}".format(site_name, str(e)) + self.msg = "An exception occured while updating the fabric site '{0}' in Cisco Catalyst Center: {1}".format( + site_name, str(e)) self.log(self.msg, "ERROR") self.set_operation_result("failed", False, self.msg, "ERROR") @@ -726,30 +752,37 @@ def create_fabric_zone(self, zone): site_name = zone.get("site_name_hierarchy") site_exists, site_id = self.get_site_id(site_name) if not site_exists: - self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format( + site_name) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() zone_payload = { "siteId": site_id, "authenticationProfileName": zone.get("authentication_profile"), } fabric_zone_payload.append(zone_payload) - self.log("Requested payload for creating fabric zone '{0}' is: {1}".format(site_name, zone_payload), "INFO") + self.log("Requested payload for creating fabric zone '{0}' is: {1}".format( + site_name, zone_payload), "INFO") task_name = "add_fabric_zone" payload = {"payload": fabric_zone_payload} task_id = self.get_taskid_post_api_call("sda", task_name, payload) if not task_id: - self.msg = "Unable to retrieve the task_id for the task '{0}'.".format(task_name) + self.msg = "Unable to retrieve the task_id for the task '{0}'.".format( + task_name) self.set_operation_result("failed", False, self.msg, "ERROR") return self - success_msg = "Fabric zone '{0}' created successfully in the Cisco Catalyst Center.".format(site_name) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + success_msg = "Fabric zone '{0}' created successfully in the Cisco Catalyst Center.".format( + site_name) + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) self.create_zone.append(site_name) except Exception as e: - self.msg = "An exception occured while creating the fabric zone '{0}' in Cisco Catalyst Center: {1}".format(site_name, str(e)) + self.msg = "An exception occured while creating the fabric zone '{0}' in Cisco Catalyst Center: {1}".format( + site_name, str(e)) self.set_operation_result("failed", False, self.msg, "ERROR") return self @@ -784,24 +817,29 @@ def update_fabric_zone(self, zone, zone_in_ccc): "authenticationProfileName": zone.get("authentication_profile") or zone_in_ccc.get("authenticationProfileName") } update_zone_params.append(zone_payload) - self.log("Requested payload for updating fabric zone '{0}' is: {1}".format(site_name, zone_payload), "INFO") + self.log("Requested payload for updating fabric zone '{0}' is: {1}".format( + site_name, zone_payload), "INFO") payload = {"payload": update_zone_params} task_name = "update_fabric_zone" task_id = self.get_taskid_post_api_call("sda", task_name, payload) if not task_id: - self.msg = "Unable to retrieve the task_id for the task '{0}'.".format(task_name) + self.msg = "Unable to retrieve the task_id for the task '{0}'.".format( + task_name) self.set_operation_result("failed", False, self.msg, "ERROR") return self - success_msg = "Fabric zone '{0}' updated successfully in the Cisco Catalyst Center".format(site_name) + success_msg = "Fabric zone '{0}' updated successfully in the Cisco Catalyst Center".format( + site_name) self.log(success_msg, "DEBUG") - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) self.update_zone.append(site_name) except Exception as e: - self.msg = "An exception occured while updating the fabric zone '{0}' in Cisco Catalyst Center: {1}".format(site_name, str(e)) + self.msg = "An exception occured while updating the fabric zone '{0}' in Cisco Catalyst Center: {1}".format( + site_name, str(e)) self.log(self.msg, "ERROR") self.set_operation_result("failed", False, self.msg, "ERROR") @@ -901,10 +939,12 @@ def get_authentication_profile(self, fabric_id, auth_profile, site_name): } ) response = response.get("response") - self.log("Received API response from 'get_authentication_profiles' for the site '{0}': {1}".format(site_name, str(response)), "DEBUG") + self.log("Received API response from 'get_authentication_profiles' for the site '{0}': {1}".format( + site_name, str(response)), "DEBUG") if not response: - self.log("No Authentication profile asssociated to this site '{0}' in Cisco Catalyst Center.".format(site_name), "INFO") + self.log("No Authentication profile asssociated to this site '{0}' in Cisco Catalyst Center.".format( + site_name), "INFO") return profile_details profile_details = response[0] @@ -914,7 +954,8 @@ def get_authentication_profile(self, fabric_id, auth_profile, site_name): "Error while getting the details of authentication profiles for the site '{0}' present in " "Cisco Catalyst Center: {1}" ).format(site_name, str(e)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() return profile_details @@ -992,15 +1033,19 @@ def collect_authentication_params(self, auth_profile_dict, auth_profile_in_ccc): } if auth_profile_dict.get("wake_on_lan") is None: - authentications_params_dict["wakeOnLan"] = auth_profile_in_ccc.get("wakeOnLan") + authentications_params_dict["wakeOnLan"] = auth_profile_in_ccc.get( + "wakeOnLan") else: - authentications_params_dict["wakeOnLan"] = auth_profile_dict.get("wake_on_lan") + authentications_params_dict["wakeOnLan"] = auth_profile_dict.get( + "wake_on_lan") if profile_name == "Closed Authentication": if auth_profile_dict.get("enable_bpu_guard") is None: - auth_profile_dict["isBpduGuardEnabled"] = auth_profile_in_ccc.get("isBpduGuardEnabled", True) + auth_profile_dict["isBpduGuardEnabled"] = auth_profile_in_ccc.get( + "isBpduGuardEnabled", True) else: - auth_profile_dict["isBpduGuardEnabled"] = auth_profile_dict.get("enable_bpu_guard") + auth_profile_dict["isBpduGuardEnabled"] = auth_profile_dict.get( + "enable_bpu_guard") updated_params.append(authentications_params_dict) @@ -1024,23 +1069,28 @@ def update_authentication_profile_template(self, profile_update_params, site_nam """ try: - self.log("Requested payload for updating authentication profile for site {0}: {1}".format(site_name, profile_update_params), "DEBUG") + self.log("Requested payload for updating authentication profile for site {0}: {1}".format( + site_name, profile_update_params), "DEBUG") payload = {"payload": profile_update_params} task_name = "update_authentication_profile" task_id = self.get_taskid_post_api_call("sda", task_name, payload) if not task_id: - self.msg = "Unable to retrieve the task_id for the task '{0}'.".format(task_name) + self.msg = "Unable to retrieve the task_id for the task '{0}'.".format( + task_name) self.set_operation_result("failed", False, self.msg, "ERROR") return self - success_msg = "Authentication profile for the site '{0}' updated successfully in the Cisco Catalyst Center".format(site_name) + success_msg = "Authentication profile for the site '{0}' updated successfully in the Cisco Catalyst Center".format( + site_name) self.log(success_msg, "DEBUG") - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) self.update_auth_profile.append(site_name) except Exception as e: - self.msg = "An exception occured while updating the authentication profile for site '{0}' in Cisco Catalyst Center: {1}".format(site_name, str(e)) + self.msg = "An exception occured while updating the authentication profile for site '{0}' in Cisco Catalyst Center: {1}".format( + site_name, str(e)) self.set_operation_result("failed", False, self.msg, "ERROR") return self @@ -1073,14 +1123,18 @@ def delete_fabric_site_zone(self, fabric_id, site_name, fabric_type): task_id = self.get_taskid_post_api_call("sda", task_name, payload) if not task_id: - self.msg = "Unable to retrieve the task_id for the task '{0}'.".format(task_name) + self.msg = "Unable to retrieve the task_id for the task '{0}'.".format( + task_name) self.set_operation_result("failed", False, self.msg, "ERROR") return self - self.log("{0} '{1}' deleted successfully from the Cisco Catalyst Center".format(type_name.title(), site_name), "INFO") + self.log("{0} '{1}' deleted successfully from the Cisco Catalyst Center".format( + type_name.title(), site_name), "INFO") - success_msg = "{0} '{1}' deleted successfully from the Cisco Catalyst Center".format(type_name.title(), site_name) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + success_msg = "{0} '{1}' deleted successfully from the Cisco Catalyst Center".format( + type_name.title(), site_name) + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) if fabric_type == "fabric_site": self.delete_site.append(site_name) @@ -1088,7 +1142,8 @@ def delete_fabric_site_zone(self, fabric_id, site_name, fabric_type): self.delete_zone.append(site_name) except Exception as e: - self.msg = "Exception occurred while deleting {0} '{1}' due to: {2}".format(type_name, site_name, str(e)) + self.msg = "Exception occurred while deleting {0} '{1}' due to: {2}".format( + type_name, site_name, str(e)) self.set_operation_result("failed", False, self.msg, "ERROR") return self @@ -1113,27 +1168,33 @@ def update_site_zones_profile_messages(self): result_msg_list = [] if self.create_site: - create_site_msg = "Fabric site(s) '{0}' created successfully in Cisco Catalyst Center.".format(self.create_site) + create_site_msg = "Fabric site(s) '{0}' created successfully in Cisco Catalyst Center.".format( + self.create_site) result_msg_list.append(create_site_msg) if self.update_site: - update_site_msg = "Fabric site(s) '{0}' updated successfully in Cisco Catalyst Center.".format(self.update_site) + update_site_msg = "Fabric site(s) '{0}' updated successfully in Cisco Catalyst Center.".format( + self.update_site) result_msg_list.append(update_site_msg) if self.no_update_site: - no_update_site_msg = "Fabric site(s) '{0}' need no update in Cisco Catalyst Center.".format(self.no_update_site) + no_update_site_msg = "Fabric site(s) '{0}' need no update in Cisco Catalyst Center.".format( + self.no_update_site) result_msg_list.append(no_update_site_msg) if self.create_zone: - create_zone_msg = "Fabric zone(s) '{0}' created successfully in Cisco Catalyst Center.".format(self.create_zone) + create_zone_msg = "Fabric zone(s) '{0}' created successfully in Cisco Catalyst Center.".format( + self.create_zone) result_msg_list.append(create_zone_msg) if self.update_zone: - update_zone_msg = "Fabric zone(s) '{0}' updated successfully in Cisco Catalyst Center.".format(self.update_zone) + update_zone_msg = "Fabric zone(s) '{0}' updated successfully in Cisco Catalyst Center.".format( + self.update_zone) result_msg_list.append(update_zone_msg) if self.no_update_zone: - no_update_zone_msg = "Fabric zone(s) '{0}' need no update in Cisco Catalyst Center.".format(self.no_update_zone) + no_update_zone_msg = "Fabric zone(s) '{0}' need no update in Cisco Catalyst Center.".format( + self.no_update_zone) result_msg_list.append(no_update_zone_msg) if self.update_auth_profile: @@ -1142,23 +1203,28 @@ def update_site_zones_profile_messages(self): result_msg_list.append(update_auth_msg) if self.no_update_profile: - no_update_auth_msg = "Authentication profile template for site(s) '{0}' need no update in Cisco Catalyst Center.".format(self.no_update_profile) + no_update_auth_msg = "Authentication profile template for site(s) '{0}' need no update in Cisco Catalyst Center.".format( + self.no_update_profile) result_msg_list.append(no_update_auth_msg) if self.delete_site: - delete_site_msg = "Fabric site(s) '{0}' deleted successfully from the Cisco Catalyst Center.".format(self.delete_site) + delete_site_msg = "Fabric site(s) '{0}' deleted successfully from the Cisco Catalyst Center.".format( + self.delete_site) result_msg_list.append(delete_site_msg) if self.absent_site: - absent_site_msg = "Unable to delete fabric site(s) '{0}' as they are not present in Cisco Catalyst Center.".format(self.absent_site) + absent_site_msg = "Unable to delete fabric site(s) '{0}' as they are not present in Cisco Catalyst Center.".format( + self.absent_site) result_msg_list.append(absent_site_msg) if self.delete_zone: - delete_zone_msg = "Fabric zone(s) '{0}' deleted successfully from the Cisco Catalyst Center.".format(self.delete_zone) + delete_zone_msg = "Fabric zone(s) '{0}' deleted successfully from the Cisco Catalyst Center.".format( + self.delete_zone) result_msg_list.append(delete_zone_msg) if self.absent_zone: - absent_zone_msg = "Unable to delete fabric zone(s) '{0}' as they are not present in Cisco Catalyst Center.".format(self.absent_zone) + absent_zone_msg = "Unable to delete fabric zone(s) '{0}' as they are not present in Cisco Catalyst Center.".format( + self.absent_zone) result_msg_list.append(absent_zone_msg) if self.create_site or self.update_site or self.create_zone or self.update_zone or self.delete_site or self.update_auth_profile: @@ -1166,7 +1232,8 @@ def update_site_zones_profile_messages(self): self.msg = " ".join(result_msg_list) self.log(self.msg, "INFO") - self.set_operation_result("success", self.result["changed"], self.msg, "INFO") + self.set_operation_result( + "success", self.result["changed"], self.msg, "INFO") return self @@ -1187,7 +1254,8 @@ def is_wired_data_collection_enable(self, site_name, site_id): function logs relevant messages and returns False. If wired data collection is enabled, it returns True. """ - self.log("Checking whether wired data collection is enabled for the site: {0}".format(site_name), "INFO") + self.log("Checking whether wired data collection is enabled for the site: {0}".format( + site_name), "INFO") try: telemetry_response = self.dnac._exec( @@ -1198,26 +1266,34 @@ def is_wired_data_collection_enable(self, site_name, site_id): ) telemetry_details = telemetry_response.get("response", {}) if not telemetry_details: - self.log("No telemetry settings found for site '{0}' (ID: {1})".format(site_name, site_id), "WARNING") + self.log("No telemetry settings found for site '{0}' (ID: {1})".format( + site_name, site_id), "WARNING") return False - self.log("Successfully retrieved telemetry settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, telemetry_details), "DEBUG") - wired_data_collection = telemetry_details.get("wiredDataCollection") + self.log("Successfully retrieved telemetry settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, telemetry_details), "DEBUG") + wired_data_collection = telemetry_details.get( + "wiredDataCollection") if not wired_data_collection: - self.log("Wired Data Collection is not enabled at this site '{0}'.".format(site_name), "DEBUG") + self.log("Wired Data Collection is not enabled at this site '{0}'.".format( + site_name), "DEBUG") return False is_enabled = wired_data_collection.get("enableWiredDataCollection") if not is_enabled: - self.log("Wired Data Collection is not enabled at this site '{0}'.".format(site_name), "DEBUG") + self.log("Wired Data Collection is not enabled at this site '{0}'.".format( + site_name), "DEBUG") return False - self.log("Wired Data Collection is enabled at this site '{0}'.".format(site_name), "DEBUG") + self.log("Wired Data Collection is enabled at this site '{0}'.".format( + site_name), "DEBUG") except Exception as e: self.msg = ( - "Exception occurred while getting telemetry settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, str(e)) + "Exception occurred while getting telemetry settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, str(e)) ) - self.set_operation_result("failed", False, self.msg, "CRITICAL").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "CRITICAL").check_return_status() return True @@ -1239,7 +1315,8 @@ def get_telemetry_details(self, site_name, site_id): to "failed." """ - self.log("Fetching telemetry settings for site: {0}".format(site_name), "INFO") + self.log("Fetching telemetry settings for site: {0}".format( + site_name), "INFO") try: telemetry_response = self.dnac._exec( family="network_settings", @@ -1249,16 +1326,21 @@ def get_telemetry_details(self, site_name, site_id): ) telemetry_details = telemetry_response.get("response", {}) if not telemetry_details: - self.mg = "No telemetry settings found for site '{0}' (ID: {1})".format(site_name, site_id) - self.set_operation_result("failed", False, self.msg, "CRITICAL").check_return_status() + self.mg = "No telemetry settings found for site '{0}' (ID: {1})".format( + site_name, site_id) + self.set_operation_result( + "failed", False, self.msg, "CRITICAL").check_return_status() - self.log("Successfully retrieved telemetry settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, telemetry_details), "DEBUG") + self.log("Successfully retrieved telemetry settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, telemetry_details), "DEBUG") except Exception as e: self.msg = ( - "Exception occurred while getting telemetry settings for site '{0}' (ID: {1}): {2}".format(site_name, site_id, str(e)) + "Exception occurred while getting telemetry settings for site '{0}' (ID: {1}): {2}".format( + site_name, site_id, str(e)) ) - self.set_operation_result("failed", False, self.msg, "CRITICAL").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "CRITICAL").check_return_status() return telemetry_details @@ -1282,7 +1364,8 @@ def enable_wired_data_collection(self, site_name, site_id): If successful, it logs an informational message indicating that wired data collection was enabled. """ - self.log("Started the process of enabling wired data collection for site {0}...".format(site_name), "DEBUG") + self.log("Started the process of enabling wired data collection for site {0}...".format( + site_name), "DEBUG") try: telemetry_settings = self.get_telemetry_details(site_name, site_id) @@ -1295,16 +1378,20 @@ def enable_wired_data_collection(self, site_name, site_id): "payload": telemetry_settings } task_name = "set_telemetry_settings_for_a_site" - task_id = self.get_taskid_post_api_call("network_settings", task_name, payload) + task_id = self.get_taskid_post_api_call( + "network_settings", task_name, payload) if not task_id: - self.msg = "Unable to retrieve the task_id for the task '{0}'.".format(task_name) + self.msg = "Unable to retrieve the task_id for the task '{0}'.".format( + task_name) self.set_operation_result("failed", False, self.msg, "ERROR") return self - success_msg = "Successfully enabled wired data collection for site '{0}'.".format(site_name) + success_msg = "Successfully enabled wired data collection for site '{0}'.".format( + site_name) self.log(success_msg, "INFO") - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) except Exception as e: self.msg = ( "An exception occured while eanbling the Wired Data Collection for the site '{0}' " @@ -1340,7 +1427,8 @@ def get_diff_merged(self, config): # Create/Update Fabric sites/zones in Cisco Catalyst Center raw_fabric_sites = self.want.get('fabric_sites') # Convert each dictionary to a sorted tuple of key-value pairs - unique_fabric_sites = {tuple(sorted(d.items())) for d in raw_fabric_sites} + unique_fabric_sites = {tuple(sorted(d.items())) + for d in raw_fabric_sites} # Convert each unique tuple back into a dictionary fabric_sites = [dict(t) for t in unique_fabric_sites] @@ -1349,8 +1437,10 @@ def get_diff_merged(self, config): fabric_type = site.get("fabric_type", "fabric_site") site_exists, site_id = self.get_site_id(site_name) if not site_exists: - self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format( + site_name) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() auth_profile = site.get("authentication_profile") @@ -1360,52 +1450,73 @@ def get_diff_merged(self, config): "Please provide one of the following authentication_profile ['Closed Authentication', 'Low Impact'" ", 'No Authentication', 'Open Authentication'] in the playbook." ).format(auth_profile) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() - self.log("Checking whether Wired Endpoint Data Collection is enabled at this site '{0}'or not".format(site_name), "INFO") - is_wired_data_enable = self.is_wired_data_collection_enable(site_name, site_id) + self.log("Checking whether Wired Endpoint Data Collection is enabled at this site '{0}'or not".format( + site_name), "INFO") + is_wired_data_enable = self.is_wired_data_collection_enable( + site_name, site_id) if not is_wired_data_enable: - self.log("Wired Data Collection is not enabled at this site '{0}'.".format(site_name), "INFO") - self.enable_wired_data_collection(site_name, site_id).check_return_status() - self.log("Wired Data Collection has been successfully enabled for site '{0}'.".format(site_name), "INFO") + self.log("Wired Data Collection is not enabled at this site '{0}'.".format( + site_name), "INFO") + self.enable_wired_data_collection( + site_name, site_id).check_return_status() + self.log("Wired Data Collection has been successfully enabled for site '{0}'.".format( + site_name), "INFO") else: - self.log("Wired Data Collection is already enabled at this site '{0}'.".format(site_name), "INFO") + self.log("Wired Data Collection is already enabled at this site '{0}'.".format( + site_name), "INFO") if fabric_type == "fabric_site": - self.log("Checking whether the given site {0} is already fabric site or not.".format(site_name), "DEBUG") + self.log("Checking whether the given site {0} is already fabric site or not.".format( + site_name), "DEBUG") if site_id not in self.have.get("fabric_sites_ids"): - self.log("Starting the process of making site {0} as fabric site...".format(site_name), "DEBUG") + self.log("Starting the process of making site {0} as fabric site...".format( + site_name), "DEBUG") self.create_fabric_site(site).check_return_status() else: - self.log("Checkiing whether the given fabric site {0} needs update or not.".format(site_name), "DEBUG") - site_in_ccc = self.get_fabric_site_detail(site_name, site_id) - require_update = self.fabric_site_needs_update(site, site_in_ccc) + self.log("Checkiing whether the given fabric site {0} needs update or not.".format( + site_name), "DEBUG") + site_in_ccc = self.get_fabric_site_detail( + site_name, site_id) + require_update = self.fabric_site_needs_update( + site, site_in_ccc) if require_update: - self.update_fabric_site(site, site_in_ccc).check_return_status() + self.update_fabric_site( + site, site_in_ccc).check_return_status() else: self.no_update_site.append(site_name) - self.log("Fabric site '{0}' already present and doesnot need any update in the Cisco Catalyst Center.".format(site_name), "INFO") + self.log("Fabric site '{0}' already present and doesnot need any update in the Cisco Catalyst Center.".format( + site_name), "INFO") else: - self.log("Checking whether the given site {0} is already fabric zone or not.".format(site_name), "DEBUG") + self.log("Checking whether the given site {0} is already fabric zone or not.".format( + site_name), "DEBUG") if site_id not in self.have.get("fabric_zone_ids"): - self.log("Starting the process of making site {0} as fabric zone...".format(site_name), "DEBUG") + self.log("Starting the process of making site {0} as fabric zone...".format( + site_name), "DEBUG") self.create_fabric_zone(site).check_return_status() else: - self.log("Checking whether the given fabric zone {0} needs update or not.".format(site_name), "DEBUG") - zone_in_ccc = self.get_fabric_zone_detail(site_name, site_id) + self.log("Checking whether the given fabric zone {0} needs update or not.".format( + site_name), "DEBUG") + zone_in_ccc = self.get_fabric_zone_detail( + site_name, site_id) if auth_profile and auth_profile != zone_in_ccc.get("authenticationProfileName"): self.log( "Authentication profile '{0}' does not match the profile '{1}' in Cisco Catalyst Center " - "for the fabric zone '{2}'.".format(auth_profile, zone_in_ccc.get("authenticationProfileName"), site_name), "INFO" + "for the fabric zone '{2}'.".format(auth_profile, zone_in_ccc.get( + "authenticationProfileName"), site_name), "INFO" ) - self.update_fabric_zone(site, zone_in_ccc).check_return_status() + self.update_fabric_zone( + site, zone_in_ccc).check_return_status() else: self.no_update_zone.append(site_name) - self.log("Fabric zone '{0}' already present and doesnot need any update in the Cisco Catalyst Center.".format(site_name), "INFO") + self.log("Fabric zone '{0}' already present and doesnot need any update in the Cisco Catalyst Center.".format( + site_name), "INFO") # Updating/customising the default parameters for authentication profile template if site.get("update_authentication_profile"): @@ -1415,7 +1526,8 @@ def get_diff_merged(self, config): "Please provide one of the following authentication_profile ['Closed Authentication', 'Low Impact'" ", 'Open Authentication'] in the playbook." ) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() if auth_profile == "No Authentication": self.msg = ( @@ -1424,49 +1536,59 @@ def get_diff_merged(self, config): ", 'Low Impact', 'Open Authentication'] in the playbook." ).format(site_name) self.no_update_profile.append(site_name) - self.set_operation_result("success", False, self.msg, "INFO") + self.set_operation_result( + "success", False, self.msg, "INFO") return self # With the given site id collect the fabric site/zone id if fabric_type == "fabric_site": - site_detail = self.get_fabric_site_detail(site_name, site_id) + site_detail = self.get_fabric_site_detail( + site_name, site_id) fabric_id = site_detail.get("id") else: - zone_detail = self.get_fabric_zone_detail(site_name, site_id) + zone_detail = self.get_fabric_zone_detail( + site_name, site_id) fabric_id = zone_detail.get("id") # Validate the playbook input parameter for updating the authentication profile auth_profile_dict = site.get("update_authentication_profile") - self.validate_auth_profile_parameters(auth_profile_dict).check_return_status() + self.validate_auth_profile_parameters( + auth_profile_dict).check_return_status() validate_msg = ( "All the given parameter(s) '{0}' in the playbook for the updation of authentication " " profile in SDA fabric site/zone are validated successfully." ).format(auth_profile_dict) self.log(validate_msg, "INFO") - auth_profile_in_ccc = self.get_authentication_profile(fabric_id, auth_profile, site_name) + auth_profile_in_ccc = self.get_authentication_profile( + fabric_id, auth_profile, site_name) if not auth_profile_in_ccc: self.msg = ( "There is no authentication template profile associated to the site '{0}' " "in the Cisco Catalyst Center so unable to update the profile parameters." ).format(site_name) - self.set_operation_result("success", False, self.msg, "INFO") + self.set_operation_result( + "success", False, self.msg, "INFO") self.no_update_profile.append(site_name) return self - profile_needs_update = self.auth_profile_needs_update(auth_profile_dict, auth_profile_in_ccc) + profile_needs_update = self.auth_profile_needs_update( + auth_profile_dict, auth_profile_in_ccc) if not profile_needs_update: self.msg = ( "Authentication profile for the site '{0}' does not need any update in the " "Cisco Catalyst Center." ).format(site_name) - self.set_operation_result("success", False, self.msg, "INFO") + self.set_operation_result( + "success", False, self.msg, "INFO") self.no_update_profile.append(site_name) return self # Collect the authentication profile parameters for the update operation - profile_update_params = self.collect_authentication_params(auth_profile_dict, auth_profile_in_ccc) - self.update_authentication_profile_template(profile_update_params, site_name).check_return_status() + profile_update_params = self.collect_authentication_params( + auth_profile_dict, auth_profile_in_ccc) + self.update_authentication_profile_template( + profile_update_params, site_name).check_return_status() return self @@ -1511,35 +1633,45 @@ def get_diff_deleted(self, config): site_exists, site_id = self.get_site_id(site_name) if not site_exists: - self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format( + site_name) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() - self.log("Getting the site id: {0} for the site {1}".format(site_id, site_name), "INFO") + self.log("Getting the site id: {0} for the site {1}".format( + site_id, site_name), "INFO") if fabric_type == "fabric_site": # Check whether fabric site is present in Cisco Catalyst Center. if site_id in self.have.get("fabric_sites_ids"): - site_detail = self.get_fabric_site_detail(site_name, site_id) + site_detail = self.get_fabric_site_detail( + site_name, site_id) fabric_id = site_detail.get("id") fabric_site_dict[site_name] = fabric_id continue else: self.absent_site.append(site_name) - self.log("Unable to delete fabric site '{0}' as it is not present in the Cisco Catalyst Center.".format(site_name), "INFO") + self.log("Unable to delete fabric site '{0}' as it is not present in the Cisco Catalyst Center.".format( + site_name), "INFO") else: # Check whether fabric zone is present in Cisco Catalyst Center. if site_id in self.have.get("fabric_zone_ids"): - site_detail = self.get_fabric_zone_detail(site_name, site_id) + site_detail = self.get_fabric_zone_detail( + site_name, site_id) fabric_id = site_detail.get("id") # Delete the fabric zone from the Cisco Catalyst Center - self.delete_fabric_site_zone(fabric_id, site_name, fabric_type).check_return_status() + self.delete_fabric_site_zone( + fabric_id, site_name, fabric_type).check_return_status() else: self.absent_zone.append(site_name) - self.log("Unable to delete fabric zone '{0}' as it is not present in the Cisco Catalyst Center.".format(site_name), "INFO") + self.log("Unable to delete fabric zone '{0}' as it is not present in the Cisco Catalyst Center.".format( + site_name), "INFO") for site_name, fabric_id in fabric_site_dict.items(): - self.log("Deleting the fabric site {0}...".format(site_name), "INFO") - self.delete_fabric_site_zone(fabric_id, site_name, "fabric_site").check_return_status() + self.log("Deleting the fabric site {0}...".format( + site_name), "INFO") + self.delete_fabric_site_zone( + fabric_id, site_name, "fabric_site").check_return_status() return self @@ -1562,7 +1694,8 @@ def verify_diff_merged(self, config): if config.get('fabric_sites'): raw_fabric_sites = self.want.get('fabric_sites') - unique_fabric_sites = {tuple(sorted(d.items())) for d in raw_fabric_sites} + unique_fabric_sites = {tuple(sorted(d.items())) + for d in raw_fabric_sites} fabric_sites = [dict(t) for t in unique_fabric_sites] verify_site_list, verify_auth_list = [], [] site_name_list, auth_name_list = [], [] @@ -1573,8 +1706,10 @@ def verify_diff_merged(self, config): fabric_type = site.get("fabric_type", "fabric_site") site_exists, site_id = self.get_site_id(site_name) if not site_exists: - self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format( + site_name) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() if fabric_type == "fabric_site": if site_id not in self.have.get("fabric_sites_ids"): @@ -1592,11 +1727,13 @@ def verify_diff_merged(self, config): auth_flag = True # With the given site id collect the fabric site/zone id if fabric_type == "fabric_site": - site_detail = self.get_fabric_site_detail(site_name, site_id) + site_detail = self.get_fabric_site_detail( + site_name, site_id) fabric_id = site_detail.get("id") auth_name_list.append(site_name) else: - zone_detail = self.get_fabric_zone_detail(site_name, site_id) + zone_detail = self.get_fabric_zone_detail( + site_name, site_id) fabric_id = zone_detail.get("id") auth_name_list.append(site_name) @@ -1659,8 +1796,10 @@ def verify_diff_deleted(self, config): fabric_type = site.get("fabric_type", "fabric_site") site_exists, site_id = self.get_site_id(site_name) if not site_exists: - self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format( + site_name) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() if fabric_type == "fabric_site": # Check whether fabric site is present in Cisco Catalyst Center. @@ -1724,7 +1863,8 @@ def main(): "Fabric Sites/Zones and updating the Authentication profiles." .format(ccc_fabric_sites.get_ccc_version()) ) - ccc_fabric_sites.set_operation_result("failed", False, ccc_fabric_sites.msg, "ERROR").check_return_status() + ccc_fabric_sites.set_operation_result( + "failed", False, ccc_fabric_sites.msg, "ERROR").check_return_status() state = ccc_fabric_sites.params.get("state") @@ -1740,9 +1880,11 @@ def main(): ccc_fabric_sites.reset_values() ccc_fabric_sites.get_want(config).check_return_status() ccc_fabric_sites.get_have(config).check_return_status() - ccc_fabric_sites.get_diff_state_apply[state](config).check_return_status() + ccc_fabric_sites.get_diff_state_apply[state]( + config).check_return_status() if config_verify: - ccc_fabric_sites.verify_diff_state_apply[state](config).check_return_status() + ccc_fabric_sites.verify_diff_state_apply[state]( + config).check_return_status() # Invoke the API to check the status and log the output of each site/zone and authentication profile update on console. ccc_fabric_sites.update_site_zones_profile_messages().check_return_status() diff --git a/plugins/modules/sda_fabric_transits_workflow_manager.py b/plugins/modules/sda_fabric_transits_workflow_manager.py index 02942c4eeb..98eecd3971 100644 --- a/plugins/modules/sda_fabric_transits_workflow_manager.py +++ b/plugins/modules/sda_fabric_transits_workflow_manager.py @@ -5,6 +5,14 @@ """Ansible module to perform operations on SDA fabric transits in Cisco Catalyst Center.""" from __future__ import absolute_import, division, print_function +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + get_dict_result, + dnac_compare_equality, +) +from ansible.module_utils.basic import AnsibleModule +import copy __metaclass__ = type __author__ = ['Muthu Rakesh, Madhan Sankaranarayanan'] @@ -327,15 +335,6 @@ } """ -import copy -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - get_dict_result, - dnac_compare_equality, -) - class FabricTransit(DnacBase): """Class containing member attributes for sda_fabric_transits_workflow_manager module""" @@ -391,7 +390,8 @@ def validate_input(self): } # Validate playbook params against the specification (temp_spec) - valid_temp, invalid_params = validate_list_of_dicts(self.config, temp_spec) + valid_temp, invalid_params = validate_list_of_dicts( + self.config, temp_spec) if invalid_params: self.msg = ( "Invalid parameters in playbook: {invalid_params}" @@ -437,8 +437,10 @@ def requires_update(self, have, want, obj_params): current_obj = have requested_obj = want - self.log("Current State (have): {current_obj}".format(current_obj=current_obj), "DEBUG") - self.log("Desired State (want): {requested_obj}".format(requested_obj=requested_obj), "DEBUG") + self.log("Current State (have): {current_obj}".format( + current_obj=current_obj), "DEBUG") + self.log("Desired State (want): {requested_obj}".format( + requested_obj=requested_obj), "DEBUG") return any(not dnac_compare_equality(current_obj.get(dnac_param), requested_obj.get(ansible_param)) @@ -460,8 +462,10 @@ def get_obj_params(self, get_object): try: if get_object == "fabricTransits": obj_params = [ - ("isMulticastOverTransitEnabled", "isMulticastOverTransitEnabled"), - ("controlPlaneNetworkDeviceIds", "controlPlaneNetworkDeviceIds"), + ("isMulticastOverTransitEnabled", + "isMulticastOverTransitEnabled"), + ("controlPlaneNetworkDeviceIds", + "controlPlaneNetworkDeviceIds"), ] else: raise ValueError("Received an unexpected value for 'get_object': {object_name}" @@ -498,9 +502,11 @@ def get_device_details_by_ip(self, device_ip): device_details = response.get("response") if device_details: - self.log("Successfully retrieved device details for IP " + str(device_ip), "INFO") + self.log("Successfully retrieved device details for IP " + + str(device_ip), "INFO") else: - self.log("No device details found for IP " + str(device_ip), "WARNING") + self.log("No device details found for IP " + + str(device_ip), "WARNING") return device_details @@ -524,12 +530,15 @@ def format_fabric_transit_params(self, fabric_transit_details): ip_transit_settings = fabric_transit_details.get("ipTransitSettings") if ip_transit_settings: self.log("IP Transit settings found and processed.", "INFO") - fabric_transit_info.update({"ipTransitSettings": ip_transit_settings}) + fabric_transit_info.update( + {"ipTransitSettings": ip_transit_settings}) return fabric_transit_info sda_transit_settings = fabric_transit_details.get("sdaTransitSettings") - fabric_transit_info.update({"sdaTransitSettings": sda_transit_settings}) - control_plane_devices = fabric_transit_info.get("sdaTransitSettings").get("controlPlaneNetworkDeviceIds") + fabric_transit_info.update( + {"sdaTransitSettings": sda_transit_settings}) + control_plane_devices = fabric_transit_info.get( + "sdaTransitSettings").get("controlPlaneNetworkDeviceIds") if control_plane_devices: sorted(control_plane_devices) @@ -578,10 +587,12 @@ def fabric_transit_exists(self, name): all_fabric_transit_details = response.get("response") if not all_fabric_transit_details: - self.log("Fabric transit {name} does not exist.".format(name=name), "DEBUG") + self.log("Fabric transit {name} does not exist.".format( + name=name), "DEBUG") return transit_info - fabric_transit_details = get_dict_result(all_fabric_transit_details, "name", name) + fabric_transit_details = get_dict_result( + all_fabric_transit_details, "name", name) if fabric_transit_details: self.log("Fabric transit found with name '{name}': {details}" .format(name=name, details=fabric_transit_details), "INFO") @@ -594,8 +605,10 @@ def fabric_transit_exists(self, name): offset += 500 - self.log("SDA fabric transit details: {details}".format(details=transit_info.get("details")), "DEBUG") - self.log("SDA fabric transit id: {id}".format(id=transit_info.get("id")), "DEBUG") + self.log("SDA fabric transit details: {details}".format( + details=transit_info.get("details")), "DEBUG") + self.log("SDA fabric transit id: {id}".format( + id=transit_info.get("id")), "DEBUG") return transit_info def get_have_fabric_transits(self, fabric_transits): @@ -665,7 +678,8 @@ def get_have(self, config): self.get_have_fabric_transits(fabric_transits).check_return_status() - self.log("Current State (have): {current_state}".format(current_state=self.have), "INFO") + self.log("Current State (have): {current_state}".format( + current_state=self.have), "INFO") self.msg = "Successfully retrieved the SDA fabric transits details from the Cisco Catalyst Center." self.status = "success" return self @@ -694,7 +708,8 @@ def handle_ip_transit_settings(self, item, fabric_transits_values, fabric_transi self.status = "failed" return self.check_return_status() - routing_protocol_name = item.get("ip_transit_settings").get("routing_protocol_name") + routing_protocol_name = item.get( + "ip_transit_settings").get("routing_protocol_name") routing_protocol_name_set = ("BGP") if not routing_protocol_name: routing_protocol_name = "BGP" @@ -707,7 +722,8 @@ def handle_ip_transit_settings(self, item, fabric_transits_values, fabric_transi self.status = "failed" return self.check_return_status() - ip_transit_settings.update({"routingProtocolName": routing_protocol_name}) + ip_transit_settings.update( + {"routingProtocolName": routing_protocol_name}) have_fabric_transit_details = self.have.get("fabric_transits")[fabric_transit_index] \ .get("details") have_ip_transit_settings = None @@ -715,7 +731,8 @@ def handle_ip_transit_settings(self, item, fabric_transits_values, fabric_transi have_ip_transit_settings = self.have.get("fabric_transits")[fabric_transit_index] \ .get("details").get("ipTransitSettings") - autonomous_system_number = item.get("ip_transit_settings").get("autonomous_system_number") + autonomous_system_number = item.get( + "ip_transit_settings").get("autonomous_system_number") if not autonomous_system_number: self.msg = "The required parameter 'autonomous_system_number' in 'ip_transit_settings' is missing." self.status = "failed" @@ -742,7 +759,8 @@ def handle_ip_transit_settings(self, item, fabric_transits_values, fabric_transi self.status = "failed" return self.check_return_status() - ip_transit_settings.update({"autonomousSystemNumber": str(autonomous_system_number)}) + ip_transit_settings.update( + {"autonomousSystemNumber": str(autonomous_system_number)}) return fabric_transits_values @@ -767,7 +785,8 @@ def remove_duplicate_ips(self, control_plane_ips): # No need to proceed when there is no elements in the list if not control_plane_ips: - self.log("Received an empty or None list. Returning an empty list.", "DEBUG") + self.log( + "Received an empty or None list. Returning an empty list.", "DEBUG") return final_control_plane_ips control_plane_ips = sorted(control_plane_ips) @@ -811,27 +830,36 @@ def handle_sda_transit_settings(self, item, fabric_transits_values, transit_type fabric_transits_values.update({"sdaTransitSettings": {}}) have_sda_transit_settings = None - have_fabric_details = self.have.get("fabric_transits")[fabric_transit_index].get("details") + have_fabric_details = self.have.get("fabric_transits")[ + fabric_transit_index].get("details") if have_fabric_details: - have_sda_transit_settings = have_fabric_details.get("sdaTransitSettings") + have_sda_transit_settings = have_fabric_details.get( + "sdaTransitSettings") sda_transit_settings = fabric_transits_values.get("sdaTransitSettings") want_sda_transit_settings = item.get("sda_transit_settings") if want_sda_transit_settings: if transit_type == "SDA_LISP_PUB_SUB_TRANSIT": - is_multicast_over_transit_enabled = item.get("sda_transit_settings").get("is_multicast_over_transit_enabled") + is_multicast_over_transit_enabled = item.get( + "sda_transit_settings").get("is_multicast_over_transit_enabled") if is_multicast_over_transit_enabled is not None: - sda_transit_settings.update({"isMulticastOverTransitEnabled": is_multicast_over_transit_enabled}) + sda_transit_settings.update( + {"isMulticastOverTransitEnabled": is_multicast_over_transit_enabled}) elif have_sda_transit_settings: - sda_transit_settings.update({"isMulticastOverTransitEnabled": have_sda_transit_settings.get("isMulticastOverTransitEnabled")}) + sda_transit_settings.update({"isMulticastOverTransitEnabled": have_sda_transit_settings.get( + "isMulticastOverTransitEnabled")}) else: - sda_transit_settings.update({"isMulticastOverTransitEnabled": False}) + sda_transit_settings.update( + {"isMulticastOverTransitEnabled": False}) - control_plane_network_device_ips = self.remove_duplicate_ips(want_sda_transit_settings.get("control_plane_network_device_ips")) + control_plane_network_device_ips = self.remove_duplicate_ips( + want_sda_transit_settings.get("control_plane_network_device_ips")) if have_sda_transit_settings and not control_plane_network_device_ips: - sda_transit_settings.update({"controlPlaneNetworkDeviceIds": sorted(have_sda_transit_settings.get("controlPlaneNetworkDeviceIds"))}) + sda_transit_settings.update({"controlPlaneNetworkDeviceIds": sorted( + have_sda_transit_settings.get("controlPlaneNetworkDeviceIds"))}) elif control_plane_network_device_ips: - length_of_control_plane_network_device_ips = len(control_plane_network_device_ips) + length_of_control_plane_network_device_ips = len( + control_plane_network_device_ips) if transit_type == "SDA_LISP_BGP_TRANSIT": max_ips = 2 else: @@ -847,7 +875,8 @@ def handle_sda_transit_settings(self, item, fabric_transits_values, transit_type control_plane_network_device_ids = [] for network_device_ip in control_plane_network_device_ips: - network_device_details = self.get_device_details_by_ip(network_device_ip) + network_device_details = self.get_device_details_by_ip( + network_device_ip) if not network_device_details: self.msg = ( "There is no network device in the Cisco Catalyst Center with the IP '{device_ip}'." @@ -856,17 +885,21 @@ def handle_sda_transit_settings(self, item, fabric_transits_values, transit_type self.status = "failed" return self.check_return_status() - network_device_id = network_device_details[0].get("instanceUuid") + network_device_id = network_device_details[0].get( + "instanceUuid") control_plane_network_device_ids.append(network_device_id) - sda_transit_settings.update({"controlPlaneNetworkDeviceIds": sorted(control_plane_network_device_ids)}) + sda_transit_settings.update( + {"controlPlaneNetworkDeviceIds": sorted(control_plane_network_device_ids)}) else: self.msg = "The parameter 'control_plane_network_device_ips' in 'sda_transit_settings' should not be empty." self.status = "failed" return self.check_return_status() elif have_sda_transit_settings and not want_sda_transit_settings: - fabric_transits_values.update({"sdaTransitSettings": have_sda_transit_settings}) - sorted(fabric_transits_values.get("sdaTransitSettings").get("controlPlaneNetworkDeviceIds")) + fabric_transits_values.update( + {"sdaTransitSettings": have_sda_transit_settings}) + sorted(fabric_transits_values.get("sdaTransitSettings").get( + "controlPlaneNetworkDeviceIds")) else: self.msg = "The parameter 'sda_transit_settings' should not be empty." self.status = "failed" @@ -915,9 +948,11 @@ def get_want_fabric_transits(self, fabric_transits): continue transit_type = item.get("transit_type") - transit_type_set = ("IP_BASED_TRANSIT", "SDA_LISP_PUB_SUB_TRANSIT", "SDA_LISP_BGP_TRANSIT") + transit_type_set = ( + "IP_BASED_TRANSIT", "SDA_LISP_PUB_SUB_TRANSIT", "SDA_LISP_BGP_TRANSIT") have_type = None - fabric_transit_details = self.have.get("fabric_transits")[fabric_transit_index].get("details") + fabric_transit_details = self.have.get("fabric_transits")[ + fabric_transit_index].get("details") if fabric_transit_details: have_type = fabric_transit_details.get("type") @@ -987,7 +1022,8 @@ def get_want(self, config): self.get_want_fabric_transits(fabric_transits).check_return_status() - self.log("Desired State (want): {requested_state}".format(requested_state=self.want), "INFO") + self.log("Desired State (want): {requested_state}".format( + requested_state=self.want), "INFO") self.msg = "Successfully retrieved details from the playbook" self.status = "success" return self @@ -1013,8 +1049,10 @@ def update_fabric_transits(self, fabric_transits): fabric_transit_index += 1 name = item.get("name") result_fabric_transit = self.response[0].get("fabric_transits") - have_fabric_transit = self.have.get("fabric_transits")[fabric_transit_index] - want_fabric_transit = self.want.get("fabric_transits")[fabric_transit_index] + have_fabric_transit = self.have.get("fabric_transits")[ + fabric_transit_index] + want_fabric_transit = self.want.get("fabric_transits")[ + fabric_transit_index] self.log("Current SDA fabric transit '{name}' details in Catalyst Center: {current_details}" .format(name=name, current_details=have_fabric_transit.get("details")), "DEBUG") self.log("Desired SDA fabric transit '{name}' details for Catalyst Center: {requested_details}" @@ -1026,21 +1064,25 @@ def update_fabric_transits(self, fabric_transits): .format(name=name, requested_state=want_fabric_transit), "DEBUG") payload = {"payload": [want_fabric_transit]} task_name = "add_transit_networks" - task_id = self.get_taskid_post_api_call("sda", task_name, payload) + task_id = self.get_taskid_post_api_call( + "sda", task_name, payload) if not task_id: self.msg = ( "Unable to retrive the task_id for the task '{task_name}'." .format(task_name=task_name) ) - self.set_operation_result("failed", False, self.msg, "ERROR") + self.set_operation_result( + "failed", False, self.msg, "ERROR") return self success_msg = ( "Successfully created the SDA Transit with the details '{transit_details}'." .format(transit_details=want_fabric_transit) ) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg).check_return_status() - self.log("Successfully created SDA fabric transit '{name}'.".format(name=name), "INFO") + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg).check_return_status() + self.log("Successfully created SDA fabric transit '{name}'.".format( + name=name), "INFO") result_fabric_transit.get("response").update({ name: want_fabric_transit }) @@ -1053,15 +1095,18 @@ def update_fabric_transits(self, fabric_transits): if want_fabric_transit.get("type") == "IP_BASED_TRANSIT" or \ not self.requires_update(have_fabric_transit.get("details").get("sdaTransitSettings"), - want_fabric_transit.get("sdaTransitSettings"), + want_fabric_transit.get( + "sdaTransitSettings"), self.fabric_transits_obj_params): - self.log("SDA fabric transit '{name}' doesn't require a update".format(name=name), "INFO") + self.log("SDA fabric transit '{name}' doesn't require a update".format( + name=name), "INFO") result_fabric_transit.get("msg").update({ name: "SDA fabric transit doesn't require an update." }) continue - self.log("Updating SDA fabric transit '{name}'.".format(name=name), "DEBUG") + self.log("Updating SDA fabric transit '{name}'.".format( + name=name), "DEBUG") # Tranist Exists self.log("Current SDA fabric transit '{name}' details in Catalyst Center: {current_state}" @@ -1084,8 +1129,10 @@ def update_fabric_transits(self, fabric_transits): "Successfully updated the SDA Transit with the details '{transit_details}'." .format(transit_details=want_fabric_transit) ) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg).check_return_status() - self.log("SDA fabric transit '{name}' updated successfully.".format(name=name), "INFO") + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg).check_return_status() + self.log("SDA fabric transit '{name}' updated successfully.".format( + name=name), "INFO") result_fabric_transit.get("response").update({ name: want_fabric_transit }) @@ -1137,17 +1184,22 @@ def delete_fabric_transits(self, fabric_transits): for item in fabric_transits: fabric_transit_index += 1 name = item.get("name") - have_fabric_transit = self.have.get("fabric_transits")[fabric_transit_index] + have_fabric_transit = self.have.get("fabric_transits")[ + fabric_transit_index] result_fabric_transit = self.response[0].get("fabric_transits") if not have_fabric_transit.get("exists"): - result_fabric_transit.get("msg").update({name: "SDA fabric transit not found."}) - self.log("SDA fabric transit '{name}' not found".format(name=name), "INFO") + result_fabric_transit.get("msg").update( + {name: "SDA fabric transit not found."}) + self.log("SDA fabric transit '{name}' not found".format( + name=name), "INFO") continue - self.log("SDA fabric transit scheduled for deletion with the name '{name}'.".format(name=name), "INFO") + self.log("SDA fabric transit scheduled for deletion with the name '{name}'.".format( + name=name), "INFO") transit_id = have_fabric_transit.get("id") - self.log("SDA fabric transit '{name}' id: {id}".format(name=name, id=transit_id), "DEBUG") + self.log("SDA fabric transit '{name}' id: {id}".format( + name=name, id=transit_id), "DEBUG") payload = {"id": transit_id} task_name = "delete_transit_network_by_id" task_id = self.get_taskid_post_api_call("sda", task_name, payload) @@ -1163,7 +1215,8 @@ def delete_fabric_transits(self, fabric_transits): "Successfully deleted the SDA Transit with id '{id}'." .format(id=transit_id) ) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg).check_return_status() + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg).check_return_status() result_fabric_transit.get("response").update({name: {}}) result_fabric_transit.get("response").get(name).update({ "Task Id": task_id @@ -1216,8 +1269,10 @@ def verify_diff_merged(self, config): """ self.get_have(config) - self.log("Current State (have): {current_state}".format(current_state=self.have), "INFO") - self.log("Requested State (want): {requested_state}".format(requested_state=self.want), "INFO") + self.log("Current State (have): {current_state}".format( + current_state=self.have), "INFO") + self.log("Requested State (want): {requested_state}".format( + requested_state=self.want), "INFO") if config.get("sda_fabric_transits") is not None: want_fabric_transits = self.want.get("fabric_transits") have_fabric_transits = self.have.get("fabric_transits") @@ -1227,7 +1282,8 @@ def verify_diff_merged(self, config): .format(requested_details=want_fabric_transits), "DEBUG") fabric_transit_index = 0 for item in want_fabric_transits: - fabric_transit_details = have_fabric_transits[fabric_transit_index].get("details") + fabric_transit_details = have_fabric_transits[fabric_transit_index].get( + "details") if not fabric_transit_details: self.msg = ( "The SDA fabric transit config is not created with the config: {config}" @@ -1240,8 +1296,10 @@ def verify_diff_merged(self, config): fabric_transit_index += 1 continue - self.log("Current SDA Transit Settings: " + str(fabric_transit_details.get("sdaTransitSettings"))) - self.log("Desired SDA Transit Settings: " + str(item.get("sdaTransitSettings"))) + self.log("Current SDA Transit Settings: " + + str(fabric_transit_details.get("sdaTransitSettings"))) + self.log("Desired SDA Transit Settings: " + + str(item.get("sdaTransitSettings"))) if self.requires_update(fabric_transit_details.get("sdaTransitSettings"), item.get("sdaTransitSettings"), self.fabric_transits_obj_params): @@ -1252,7 +1310,8 @@ def verify_diff_merged(self, config): fabric_transit_index += 1 self.log("Successfully validated SDA fabric transit(s).", "INFO") - self.response[0].get("fabric_transits").update({"Validation": "Success"}) + self.response[0].get("fabric_transits").update( + {"Validation": "Success"}) self.result.update({ "response": self.response @@ -1278,15 +1337,18 @@ def verify_diff_deleted(self, config): """ self.get_have(config) - self.log("Current State (have): {current_state}".format(current_state=self.have), "INFO") - self.log("Desired State (want): {requested_state}".format(requested_state=self.want), "INFO") + self.log("Current State (have): {current_state}".format( + current_state=self.have), "INFO") + self.log("Desired State (want): {requested_state}".format( + requested_state=self.want), "INFO") fabric_transits = config.get("sda_fabric_transits") if fabric_transits is not None: fabric_transit_index = 0 fabric_transit_details = self.have.get("fabric_transits") for item in fabric_transit_details: fabric_transit_exists = item.get("exists") - name = config.get("sda_fabric_transits")[fabric_transit_index].get("name") + name = config.get("sda_fabric_transits")[ + fabric_transit_index].get("name") if fabric_transit_exists: self.msg = ( "The SDA fabric transit config '{name}' is still present in " @@ -1295,9 +1357,11 @@ def verify_diff_deleted(self, config): self.status = "failed" return self - self.log("Successfully validated absence of transit '{name}'.".format(name=name), "INFO") + self.log("Successfully validated absence of transit '{name}'.".format( + name=name), "INFO") fabric_transit_index += 1 - self.response[0].get("fabric_transits").update({"Validation": "Success"}) + self.response[0].get("fabric_transits").update( + {"Validation": "Success"}) self.result.update({ "response": self.response @@ -1346,7 +1410,8 @@ def main(): } # Create an AnsibleModule object with argument specifications - module = AnsibleModule(argument_spec=element_spec, supports_check_mode=False) + module = AnsibleModule(argument_spec=element_spec, + supports_check_mode=False) ccc_sda_transit = FabricTransit(module) if ccc_sda_transit.compare_dnac_versions(ccc_sda_transit.get_ccc_version(), "2.3.7.6") < 0: ccc_sda_transit.msg = ( @@ -1371,9 +1436,11 @@ def main(): ccc_sda_transit.get_have(config).check_return_status() if state != "deleted": ccc_sda_transit.get_want(config).check_return_status() - ccc_sda_transit.get_diff_state_apply[state](config).check_return_status() + ccc_sda_transit.get_diff_state_apply[state]( + config).check_return_status() if config_verify: - ccc_sda_transit.verify_diff_state_apply[state](config).check_return_status() + ccc_sda_transit.verify_diff_state_apply[state]( + config).check_return_status() module.exit_json(**ccc_sda_transit.result) diff --git a/plugins/modules/sda_fabric_virtual_networks_workflow_manager.py b/plugins/modules/sda_fabric_virtual_networks_workflow_manager.py index 64b13593ec..96e57dfbda 100644 --- a/plugins/modules/sda_fabric_virtual_networks_workflow_manager.py +++ b/plugins/modules/sda_fabric_virtual_networks_workflow_manager.py @@ -5,6 +5,13 @@ # 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 +import re +import copy +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, +) +from ansible.module_utils.basic import AnsibleModule __metaclass__ = type __author__ = ("Abhishek Maheshwari, Madhan Sankaranarayanan") @@ -512,14 +519,6 @@ } """ -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, -) -import copy -import re - class VirtualNetwork(DnacBase): """Class containing member attributes for fabric sites and zones workflow manager module""" @@ -629,11 +628,14 @@ def validate_input(self): ) if invalid_params: - self.msg = "The playbook contains invalid parameters: {0}".format(invalid_params) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "The playbook contains invalid parameters: {0}".format( + invalid_params) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() self.validated_config = valid_temp - self.msg = "Successfully validated playbook configuration parameters using 'validate_input': {0}".format(str(valid_temp)) + self.msg = "Successfully validated playbook configuration parameters using 'validate_input': {0}".format( + str(valid_temp)) self.log(self.msg, "INFO") self.status = "success" @@ -658,7 +660,8 @@ def get_fabric_site_id(self, site_name, site_id): """ fabric_site_id = None - self.log("Starting retrieval of fabric site ID for site '{0}' with ID '{1}'.".format(site_name, site_id), "DEBUG") + self.log("Starting retrieval of fabric site ID for site '{0}' with ID '{1}'.".format( + site_name, site_id), "DEBUG") try: response = self.dnac._exec( @@ -668,18 +671,22 @@ def get_fabric_site_id(self, site_name, site_id): params={"site_id": site_id}, ) response = response.get("response") - self.log("Received API response from 'get_fabric_sites' for the site '{0}': {1}".format(site_name, str(response)), "DEBUG") + self.log("Received API response from 'get_fabric_sites' for the site '{0}': {1}".format( + site_name, str(response)), "DEBUG") if not response: - self.log("Given site '{0}' is not a fabric site in Cisco Catalyst Center.".format(site_name), "INFO") + self.log("Given site '{0}' is not a fabric site in Cisco Catalyst Center.".format( + site_name), "INFO") return fabric_site_id fabric_site_id = response[0].get("id") - self.log("Successfully retrieved fabric site ID '{0}' for site '{1}'.".format(fabric_site_id, site_name), "DEBUG") + self.log("Successfully retrieved fabric site ID '{0}' for site '{1}'.".format( + fabric_site_id, site_name), "DEBUG") except Exception as e: self.msg = """Error while getting the details of Site with given name '{0}' present in Cisco Catalyst Center: {1}""".format(site_name, str(e)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() return fabric_site_id @@ -702,7 +709,8 @@ def get_fabric_zone_id(self, site_name, site_id): """ fabric_zone_id = None - self.log("Starting retrieval of fabric zone ID for site '{0}' with ID '{1}'.".format(site_name, site_id), "DEBUG") + self.log("Starting retrieval of fabric zone ID for site '{0}' with ID '{1}'.".format( + site_name, site_id), "DEBUG") try: response = self.dnac._exec( @@ -712,19 +720,23 @@ def get_fabric_zone_id(self, site_name, site_id): params={"site_id": site_id}, ) response = response.get("response") - self.log("Received API response from 'get_fabric_zones' for the site '{0}': {1}".format(site_name, str(response)), "DEBUG") + self.log("Received API response from 'get_fabric_zones' for the site '{0}': {1}".format( + site_name, str(response)), "DEBUG") if not response: - self.log("Given site '{0}' is not a fabric zone in Cisco Catalyst Center.".format(site_name), "INFO") + self.log("Given site '{0}' is not a fabric zone in Cisco Catalyst Center.".format( + site_name), "INFO") return fabric_zone_id fabric_zone_id = response[0].get("id") - self.log("Successfully retrieved fabric zone ID '{0}' for site '{1}'.".format(fabric_zone_id, site_name), "DEBUG") + self.log("Successfully retrieved fabric zone ID '{0}' for site '{1}'.".format( + fabric_zone_id, site_name), "DEBUG") except Exception as e: self.msg = """Error while getting the details of fabric zone '{0}' present in Cisco Catalyst Center: {1}""".format(site_name, str(e)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() return fabric_zone_id @@ -744,7 +756,8 @@ def is_valid_vn_name(self, vn_name): result dictionary. """ - self.log("Starting validation for virtual network name '{0}'.".format(vn_name), "DEBUG") + self.log("Starting validation for virtual network name '{0}'.".format( + vn_name), "DEBUG") # Regex pattern for virtual network name having only letters numbers and underscores with 1-16 character long. pattern = r'^[a-zA-Z0-9_]{1,16}$' if re.match(pattern, vn_name): @@ -768,7 +781,8 @@ def is_valid_fabric_vlan_name(self, vlan_name): warning, and stores the error message in the result dictionary. """ - self.log("Starting validation for fabric VLAN name '{0}'.".format(vlan_name), "DEBUG") + self.log("Starting validation for fabric VLAN name '{0}'.".format( + vlan_name), "DEBUG") # Regex pattern for fabric vlan name having alphanumeric characters, underscores and hyphens with 1-32 character long. vlan_name_pattern = r'^[a-zA-Z0-9_-]{1,32}$' if re.match(vlan_name_pattern, vlan_name): @@ -792,7 +806,8 @@ def validate_fabric_type(self, fabric_type): with an appropriate error message. """ - self.log("Starting validation for fabric type '{0}'.".format(fabric_type), "DEBUG") + self.log("Starting validation for fabric type '{0}'.".format( + fabric_type), "DEBUG") if fabric_type not in ["fabric_site", "fabric_zone"]: self.msg = ( "Invalid fabric_type '{0}' parameter given in the playbook. Please provide one of the following " @@ -822,7 +837,8 @@ def collect_fabric_vlan_ids(self, vlan_name, vlan_id): vlan_ids = [] try: - self.log("Starting to collect fabric VLAN IDs for VLAN '{0}' with ID '{1}'.".format(vlan_name, vlan_id), "DEBUG") + self.log("Starting to collect fabric VLAN IDs for VLAN '{0}' with ID '{1}'.".format( + vlan_name, vlan_id), "DEBUG") response = self.dnac._exec( family="sda", function='get_layer2_virtual_networks', @@ -830,25 +846,30 @@ def collect_fabric_vlan_ids(self, vlan_name, vlan_id): params={"vlan_id": vlan_id}, ) response = response.get("response") - self.log("Received API response from 'get_layer2_virtual_networks' for the VLAN '{0}': {1}".format(vlan_name, str(response)), "DEBUG") + self.log("Received API response from 'get_layer2_virtual_networks' for the VLAN '{0}': {1}".format( + vlan_name, str(response)), "DEBUG") if not response: - self.log("Given layer2 fabric VLAN '{0}' is not present in Cisco Catalyst Center.".format(vlan_name), "INFO") + self.log("Given layer2 fabric VLAN '{0}' is not present in Cisco Catalyst Center.".format( + vlan_name), "INFO") return vlan_ids for vlan_vn in response: vlan_id_value = vlan_vn.get("id") vlan_ids.append(vlan_id_value) - self.log("Collected VLAN ID '{0}' for VLAN '{1}'.".format(vlan_id_value, vlan_name), "DEBUG") + self.log("Collected VLAN ID '{0}' for VLAN '{1}'.".format( + vlan_id_value, vlan_name), "DEBUG") - self.log("Finished collecting fabric VLAN IDs for VLAN '{0}'. Collected IDs: {1}".format(vlan_name, vlan_ids), "DEBUG") + self.log("Finished collecting fabric VLAN IDs for VLAN '{0}'. Collected IDs: {1}".format( + vlan_name, vlan_ids), "DEBUG") except Exception as e: self.msg = ( "Error while getting the details for layer2 fabric VLAN '{0}' present in " "Cisco Catalyst Center: {1}" ).format(vlan_name, str(e)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() return vlan_ids @@ -870,7 +891,8 @@ def get_fabric_vlan_details(self, vlan_name, vlan_id, fabric_id): """ try: - self.log("Fetching details for VLAN '{0}' with ID '{1}' in fabric '{2}'.".format(vlan_name, vlan_id, fabric_id), "DEBUG") + self.log("Fetching details for VLAN '{0}' with ID '{1}' in fabric '{2}'.".format( + vlan_name, vlan_id, fabric_id), "DEBUG") response = self.dnac._exec( family="sda", function='get_layer2_virtual_networks', @@ -881,20 +903,24 @@ def get_fabric_vlan_details(self, vlan_name, vlan_id, fabric_id): }, ) response = response.get("response") - self.log("Received API response from 'get_layer2_virtual_networks' for VLAN '{0}': {1}".format(vlan_name, str(response)), "DEBUG") + self.log("Received API response from 'get_layer2_virtual_networks' for VLAN '{0}': {1}".format( + vlan_name, str(response)), "DEBUG") if not response: - self.log("Given layer2 VLAN '{0}' is not present in Cisco Catalyst Center.".format(vlan_name), "INFO") + self.log("Given layer2 VLAN '{0}' is not present in Cisco Catalyst Center.".format( + vlan_name), "INFO") return None - self.log("Returning details for VLAN '{0}': {1}".format(vlan_name, response[0]), "DEBUG") + self.log("Returning details for VLAN '{0}': {1}".format( + vlan_name, response[0]), "DEBUG") except Exception as e: self.msg = ( "Error while getting the details for layer2 VLAN '{0}' present in " "Cisco Catalyst Center: {1}" ).format(vlan_name, str(e)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() return response[0] @@ -920,9 +946,11 @@ def validate_traffic_type(self, traffic_type): self.msg = ( "Invalid traffic_type '{0}' given in the playbook. Allowed values are: {1}." ).format(traffic_type, allowed_types) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() - self.log("Parameter traffic_type '{0}' given in the playbook validated successfully.".format(traffic_type), "INFO") + self.log("Parameter traffic_type '{0}' given in the playbook validated successfully.".format( + traffic_type), "INFO") return self @@ -993,13 +1021,16 @@ class status accordingly. task_id = self.get_taskid_post_api_call("sda", task_name, payload) if not task_id: - self.msg = "Unable to retrieve the task_id for the task '{0}'.".format(task_name) + self.msg = "Unable to retrieve the task_id for the task '{0}'.".format( + task_name) self.set_operation_result("failed", False, self.msg, "ERROR") return self - success_msg = "Layer2 Fabric VLAN(s) '{0}' created successfully in the Cisco Catalyst Center.".format(self.created_fabric_vlans) + success_msg = "Layer2 Fabric VLAN(s) '{0}' created successfully in the Cisco Catalyst Center.".format( + self.created_fabric_vlans) self.log(success_msg, "DEBUG") - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) except Exception as e: self.msg = ( @@ -1033,14 +1064,18 @@ def fabric_vlan_needs_update(self, desired_vlan_config, current_vlan_config): current_traffic_type = current_vlan_config.get("trafficType") if desired_traffic_type and desired_traffic_type != current_traffic_type: - self.log("Traffic type needs update: desired='{0}', current='{1}'".format(desired_traffic_type, current_traffic_type), "DEBUG") + self.log("Traffic type needs update: desired='{0}', current='{1}'".format( + desired_traffic_type, current_traffic_type), "DEBUG") return True - desired_enabled_wireless = desired_vlan_config.get("fabric_enabled_wireless") - current_enabled_wireless = current_vlan_config.get("isFabricEnabledWireless") + desired_enabled_wireless = desired_vlan_config.get( + "fabric_enabled_wireless") + current_enabled_wireless = current_vlan_config.get( + "isFabricEnabledWireless") if desired_enabled_wireless is not None and desired_enabled_wireless != current_enabled_wireless: - self.log("Fabric Enable Wireless needs to be updated in the Cisco Catalyst Center.", "INFO") + self.log( + "Fabric Enable Wireless needs to be updated in the Cisco Catalyst Center.", "INFO") return True if desired_enabled_wireless is not None and desired_enabled_wireless != current_enabled_wireless: @@ -1076,12 +1111,14 @@ def update_payload_fabric_vlan(self, new_vlan_config, current_vlan_config, fabri # Validate the given traffic type for Vlan/VN/Anycast configuration. self.validate_traffic_type(traffic_type) else: - self.log("Parameter 'traffic_type' is not given in the playbook so taking it from current vlan config.", "INFO") + self.log( + "Parameter 'traffic_type' is not given in the playbook so taking it from current vlan config.", "INFO") traffic_type = current_vlan_config.get("trafficType") wireless_enabled = new_vlan_config.get("fabric_enabled_wireless") if wireless_enabled is None: - wireless_enabled = current_vlan_config.get("isFabricEnabledWireless") + wireless_enabled = current_vlan_config.get( + "isFabricEnabledWireless") vlan_update_payload = { "id": current_vlan_config.get("id"), @@ -1092,7 +1129,8 @@ def update_payload_fabric_vlan(self, new_vlan_config, current_vlan_config, fabri "isFabricEnabledWireless": wireless_enabled, "associatedLayer3VirtualNetworkName": current_vlan_config.get("associatedLayer3VirtualNetworkName") } - self.log("Constructed update payload for fabric VLAN: {0}".format(vlan_update_payload), "DEBUG") + self.log("Constructed update payload for fabric VLAN: {0}".format( + vlan_update_payload), "DEBUG") return vlan_update_payload @@ -1120,12 +1158,15 @@ def update_fabric_vlan(self, update_vlan_payload): task_id = self.get_taskid_post_api_call("sda", task_name, payload) if not task_id: - self.msg = "Unable to retrieve the task_id for the task '{0}'.".format(task_name) + self.msg = "Unable to retrieve the task_id for the task '{0}'.".format( + task_name) self.set_operation_result("failed", False, self.msg, "ERROR") return self - success_msg = "Layer2 Fabric VLAN(s) '{0}' updated successfully in the Cisco Catalyst Center.".format(self.updated_fabric_vlans) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + success_msg = "Layer2 Fabric VLAN(s) '{0}' updated successfully in the Cisco Catalyst Center.".format( + self.updated_fabric_vlans) + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) except Exception as e: self.msg = ( @@ -1163,17 +1204,22 @@ class status accordingly. task_id = self.get_taskid_post_api_call("sda", task_name, payload) if not task_id: - self.msg = "Unable to retrieve the task_id for the task '{0}'.".format(task_name) + self.msg = "Unable to retrieve the task_id for the task '{0}'.".format( + task_name) self.set_operation_result("failed", False, self.msg, "ERROR") return self - success_msg = "Fabric VLAN '{0}' deleted successfully from the Cisco Catalyst Center.".format(vlan_name_with_id_and_site) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + success_msg = "Fabric VLAN '{0}' deleted successfully from the Cisco Catalyst Center.".format( + vlan_name_with_id_and_site) + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) self.deleted_fabric_vlans.append(vlan_name_with_id_and_site) except Exception as e: - self.msg = "Exception occurred while deleting the fabric Vlan '{0}' due to: {1}".format(vlan_name_with_id_and_site, str(e)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Exception occurred while deleting the fabric Vlan '{0}' due to: {1}".format( + vlan_name_with_id_and_site, str(e)) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() return self @@ -1202,10 +1248,12 @@ def is_virtual_network_exist(self, vn_name): }, ) response = response.get("response") - self.log("Received API response from 'get_layer3_virtual_networks' for vn '{0}': {1}".format(vn_name, str(response)), "DEBUG") + self.log("Received API response from 'get_layer3_virtual_networks' for vn '{0}': {1}".format( + vn_name, str(response)), "DEBUG") if not response: - self.log("Given layer3 Virtual Network '{0}' is not present in Cisco Catalyst Center.".format(vn_name), "INFO") + self.log("Given layer3 Virtual Network '{0}' is not present in Cisco Catalyst Center.".format( + vn_name), "INFO") return False except Exception as e: @@ -1213,7 +1261,8 @@ def is_virtual_network_exist(self, vn_name): "Error while getting the details for layer3 virtual network '{0}' present in " "Cisco Catalyst Center: {1}" ).format(vn_name, str(e)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() return True @@ -1256,7 +1305,8 @@ def get_fabric_ids(self, fabric_locations): "site/zone.".format(site_name), "WARNING" ) continue - self.log("Site: '{0}' - Fabric ID: '{1}'".format(site_name, fabric_id), "DEBUG") + self.log( + "Site: '{0}' - Fabric ID: '{1}'".format(site_name, fabric_id), "DEBUG") fabric_id_list.append(fabric_id) return fabric_id_list @@ -1282,42 +1332,52 @@ def create_vn_payload(self, vn_detail): fabric_locations = vn_detail.get("fabric_site_locations") vn_name = vn_detail.get("vn_name") - self.log("Creating payload for Virtual Network '{0}'.".format(vn_name), "DEBUG") + self.log("Creating payload for Virtual Network '{0}'.".format( + vn_name), "DEBUG") vn_payload = { "virtualNetworkName": vn_name, } if fabric_locations: - self.log("Retrieving fabric IDs for locations: {0}".format(fabric_locations), "DEBUG") + self.log("Retrieving fabric IDs for locations: {0}".format( + fabric_locations), "DEBUG") fabric_ids = self.get_fabric_ids(fabric_locations) if fabric_ids: vn_payload["fabricIds"] = fabric_ids - self.log("Fabric IDs retrieved: {0}".format(fabric_ids), "DEBUG") + self.log("Fabric IDs retrieved: {0}".format( + fabric_ids), "DEBUG") else: - self.log("No fabric IDs found for the provided locations.", "WARNING") + self.log( + "No fabric IDs found for the provided locations.", "WARNING") site_name = vn_detail.get("anchored_site_name") if site_name: - self.log("Checking for anchored site '{0}'.".format(site_name), "DEBUG") + self.log("Checking for anchored site '{0}'.".format( + site_name), "DEBUG") site_exists, site_id = self.get_site_id(site_name) if not site_exists: - msg = "Given Anchor site '{0}' not present in Cisco Catalyst Center.".format(site_name) + msg = "Given Anchor site '{0}' not present in Cisco Catalyst Center.".format( + site_name) self.log(msg, "ERROR") return vn_payload try: - self.log("Anchored site ID found for '{0}': {1}".format(site_name, site_id), "DEBUG") + self.log("Anchored site ID found for '{0}': {1}".format( + site_name, site_id), "DEBUG") anchor_fabric_id = self.get_fabric_site_id(site_name, site_id) except Exception as e: anchor_fabric_id = self.get_fabric_zone_id(site_name, site_id) - self.log("Fabric zone ID retrieved for anchored site '{0}': {1}".format(site_name, anchor_fabric_id), "DEBUG") + self.log("Fabric zone ID retrieved for anchored site '{0}': {1}".format( + site_name, anchor_fabric_id), "DEBUG") if anchor_fabric_id: vn_payload["anchoredSiteId"] = anchor_fabric_id - self.log("Anchored fabric ID added to payload: {0}".format(anchor_fabric_id), "DEBUG") + self.log("Anchored fabric ID added to payload: {0}".format( + anchor_fabric_id), "DEBUG") - self.log("Payload created successfully: {0}".format(vn_payload), "INFO") + self.log("Payload created successfully: {0}".format( + vn_payload), "INFO") return vn_payload @@ -1349,10 +1409,12 @@ def get_vn_details_from_ccc(self, vn_name): }, ) response = response.get("response") - self.log("Received API response from 'get_layer3_virtual_networks' for the vn '{0}': {1}".format(vn_name, str(response)), "DEBUG") + self.log("Received API response from 'get_layer3_virtual_networks' for the vn '{0}': {1}".format( + vn_name, str(response)), "DEBUG") if not response: - self.log("Given layer3 virtual network '{0}' is not present in Cisco Catalyst Center.".format(vn_name), "INFO") + self.log("Given layer3 virtual network '{0}' is not present in Cisco Catalyst Center.".format( + vn_name), "INFO") return None except Exception as e: @@ -1360,8 +1422,10 @@ def get_vn_details_from_ccc(self, vn_name): "Error while getting the details for layer3 virtual network '{0}' present in " "Cisco Catalyst Center: {1}" ).format(vn_name, str(e)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() - self.log("Details retrieved successfully for Layer3 virtual network '{0}': {1}".format(vn_name, response[0]), "INFO") + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() + self.log("Details retrieved successfully for Layer3 virtual network '{0}': {1}".format( + vn_name, response[0]), "INFO") return response[0] @@ -1389,12 +1453,15 @@ def create_virtual_networks(self, add_vn_payloads): task_id = self.get_taskid_post_api_call("sda", task_name, payload) if not task_id: - self.msg = "Unable to retrieve the task_id for the task '{0}'.".format(task_name) + self.msg = "Unable to retrieve the task_id for the task '{0}'.".format( + task_name) self.set_operation_result("failed", False, self.msg, "ERROR") return self - success_msg = "Layer3 Virtual Network(s) '{0}' created successfully in the Cisco Catalyst Center.".format(self.created_virtual_networks) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + success_msg = "Layer3 Virtual Network(s) '{0}' created successfully in the Cisco Catalyst Center.".format( + self.created_virtual_networks) + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) except Exception as e: self.msg = ( @@ -1432,20 +1499,24 @@ def is_vn_needs_update(self, vn_details, vn_in_ccc): fabric_locations = vn_details.get("fabric_site_locations") if fabric_locations is None: - self.log("There are no fabric site details given in the playbook for the vn '{0}'.".format(vn_name), "INFO") + self.log("There are no fabric site details given in the playbook for the vn '{0}'.".format( + vn_name), "INFO") return False if not fabric_locations and fabric_ids_in_ccc: - self.log("Fabric locations not provided, but fabric IDs found for VN '{0}'.".format(vn_name), "INFO") + self.log("Fabric locations not provided, but fabric IDs found for VN '{0}'.".format( + vn_name), "INFO") return True fabric_site_ids = self.get_fabric_ids(fabric_locations) if not fabric_site_ids: - self.log("Unable to get fabric site IDs for the vn '{0}'.".format(vn_name), "INFO") + self.log("Unable to get fabric site IDs for the vn '{0}'.".format( + vn_name), "INFO") return False if not fabric_ids_in_ccc: - self.log("No fabric sites available in Cisco Catalyst Center for the VN '{0}'.".format(vn_name), "INFO") + self.log("No fabric sites available in Cisco Catalyst Center for the VN '{0}'.".format( + vn_name), "INFO") return True if len(fabric_site_ids) != len(fabric_ids_in_ccc): @@ -1456,25 +1527,30 @@ def is_vn_needs_update(self, vn_details, vn_in_ccc): for fabric_id in fabric_site_ids: if fabric_id not in fabric_ids_in_ccc: - self.log("Fabric ID '{0}' from VN '{1}' is not present in Cisco Catalyst Center".format(fabric_id, vn_name), "INFO") + self.log("Fabric ID '{0}' from VN '{1}' is not present in Cisco Catalyst Center".format( + fabric_id, vn_name), "INFO") return True anchor_site = vn_details.get("anchored_site_name") if anchor_site == "" and vn_in_ccc.get("anchoredSiteId") is not None and anchor_site != vn_in_ccc.get("anchoredSiteId"): - self.log("Need to remove the anchor site for the VN '{0}' from Cisco Catalyst Center.".format(vn_name), "INFO") + self.log("Need to remove the anchor site for the VN '{0}' from Cisco Catalyst Center.".format( + vn_name), "INFO") return True if anchor_site: site_exists, site_id = self.get_site_id(anchor_site) if not site_exists: - msg = "Given Anchor site '{0}' not present in Cisco Catalyst Center.".format(anchor_site) + msg = "Given Anchor site '{0}' not present in Cisco Catalyst Center.".format( + anchor_site) self.log(msg, "ERROR") return False try: - anchor_fabric_id = self.get_fabric_site_id(anchor_site, site_id) + anchor_fabric_id = self.get_fabric_site_id( + anchor_site, site_id) except Exception as e: - anchor_fabric_id = self.get_fabric_zone_id(anchor_site, site_id) + anchor_fabric_id = self.get_fabric_zone_id( + anchor_site, site_id) if anchor_fabric_id and anchor_fabric_id != vn_in_ccc.get("anchoredSiteId"): anchor_site_id = vn_in_ccc.get("anchoredSiteId") @@ -1524,7 +1600,8 @@ def update_payload_vn(self, vn_details, vn_in_ccc): anchor_site = vn_details.get("anchored_site_name") if anchor_site == "": - self.log("Need to remove the anchorSiteId for the VN {0}.".format(vn_name), "DEBUG") + self.log("Need to remove the anchorSiteId for the VN {0}.".format( + vn_name), "DEBUG") update_vn_payload["anchoredSiteId"] = "" return update_vn_payload @@ -1542,7 +1619,8 @@ def update_payload_vn(self, vn_details, vn_in_ccc): site_exists, site_id = self.get_site_id(anchor_site) if not site_exists: - self.log("Anchor site '{0}' not found. Cannot update payload for VN '{1}'.".format(anchor_site, vn_name), "ERROR") + self.log("Anchor site '{0}' not found. Cannot update payload for VN '{1}'.".format( + anchor_site, vn_name), "ERROR") return update_vn_payload try: @@ -1577,12 +1655,15 @@ def update_virtual_networks(self, update_vn_payloads): task_id = self.get_taskid_post_api_call("sda", task_name, payload) if not task_id: - self.msg = "Unable to retrieve the task_id for the task '{0}'.".format(task_name) + self.msg = "Unable to retrieve the task_id for the task '{0}'.".format( + task_name) self.set_operation_result("failed", False, self.msg, "ERROR") return self - success_msg = "Layer3 Virtual Network(s) '{0}' updated successfully in the Cisco Catalyst Center.".format(self.updated_virtual_networks) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + success_msg = "Layer3 Virtual Network(s) '{0}' updated successfully in the Cisco Catalyst Center.".format( + self.updated_virtual_networks) + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) except Exception as e: self.msg = ( @@ -1617,17 +1698,22 @@ def delete_layer3_virtual_network(self, vn_name, vn_id): task_id = self.get_taskid_post_api_call("sda", task_name, payload) if not task_id: - self.msg = "Unable to retrieve the task_id for the task '{0}'.".format(task_name) + self.msg = "Unable to retrieve the task_id for the task '{0}'.".format( + task_name) self.set_operation_result("failed", False, self.msg, "ERROR") return self - success_msg = "Layer3 Virtual Network '{0}' deleted successfully from the Cisco Catalyst Center.".format(vn_name) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + success_msg = "Layer3 Virtual Network '{0}' deleted successfully from the Cisco Catalyst Center.".format( + vn_name) + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) self.deleted_virtual_networks.append(vn_name) except Exception as e: - self.msg = "Exception occurred while deleting the layer3 Virtual Network '{0}' due to: {1}".format(vn_name, str(e)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Exception occurred while deleting the layer3 Virtual Network '{0}' due to: {1}".format( + vn_name, str(e)) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() return self @@ -1658,20 +1744,24 @@ def is_ip_pool_exist(self, ip_pool_name, site_id): } ) response = response.get("response") - self.log("Received API response from 'get_reserve_ip_subpool' for the IP Pool '{0}': {1}".format(ip_pool_name, str(response)), "DEBUG") + self.log("Received API response from 'get_reserve_ip_subpool' for the IP Pool '{0}': {1}".format( + ip_pool_name, str(response)), "DEBUG") if not response: - self.log("There is no reserve ip pool '{0}' present in the Cisco Catalyst Center system.".format(ip_pool_name), "INFO") + self.log("There is no reserve ip pool '{0}' present in the Cisco Catalyst Center system.".format( + ip_pool_name), "INFO") return False - self.log("IP Pool '{0}' exists in the Cisco Catalyst Center.".format(ip_pool_name), "INFO") + self.log("IP Pool '{0}' exists in the Cisco Catalyst Center.".format( + ip_pool_name), "INFO") except Exception as e: self.msg = ( "Error while getting the details for reserve IP Pool with name '{0}' present in " "Cisco Catalyst Center: {1}" ).format(ip_pool_name, str(e)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() return True @@ -1706,20 +1796,24 @@ def get_anycast_gateway_details(self, vn_name, ip_pool_name, fabric_id): } ) response = response.get("response") - self.log("Received API response from 'get_anycast_gateways' for the IP Pool '{0}': {1}".format(ip_pool_name, str(response)), "DEBUG") + self.log("Received API response from 'get_anycast_gateways' for the IP Pool '{0}': {1}".format( + ip_pool_name, str(response)), "DEBUG") if not response: - self.log("There is no reserve ip pool '{0}' present in the Cisco Catalyst Center system.".format(ip_pool_name), "INFO") + self.log("There is no reserve ip pool '{0}' present in the Cisco Catalyst Center system.".format( + ip_pool_name), "INFO") return None - self.log("Returning Anycast Gateway details for IP Pool '{0}': {1}".format(ip_pool_name, str(response[0])), "INFO") + self.log("Returning Anycast Gateway details for IP Pool '{0}': {1}".format( + ip_pool_name, str(response[0])), "INFO") except Exception as e: self.msg = ( "Error while getting the details for reserve IP Pool with name '{0}' for the virtual network '{1}' present in " "Cisco Catalyst Center: {2}" ).format(ip_pool_name, vn_name, str(e)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() return response[0] @@ -1752,14 +1846,16 @@ def validate_gateway_payload(self, anycast): "Invalid pool_type '{0}' parameter given in the playbook. Please provide one of the following " "pool_type ['EXTENDED_NODE', 'FABRIC_AP']." ).format(pool_type) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() tcp_mss_adjustment = anycast.get("tcp_mss_adjustment") if tcp_mss_adjustment and tcp_mss_adjustment not in range(500, 1441): self.msg = ( "Invalid tcp_mss_adjustment '{0}' given in the playbook. Allowed tcp_mss_adjustment range is (500,1440)." ).format(tcp_mss_adjustment) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() traffic_type = anycast.get("traffic_type") if traffic_type: @@ -1772,9 +1868,11 @@ def validate_gateway_payload(self, anycast): "Invalid vlan_id '{0}' given in the playbook. Allowed VLAN range is (2,4094) except for " "reserved VLANs 1002-1005, and 2046." ).format(vlan_id) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() - self.log("Given parameters '{0}' for the configuration of anycast gateway validated successfully.".format(str(anycast)), "INFO") + self.log("Given parameters '{0}' for the configuration of anycast gateway validated successfully.".format( + str(anycast)), "INFO") return self @@ -1825,9 +1923,11 @@ def get_anycast_gateway_mapping(self, vn_name): for item in params_to_remove: gateway_mapping.pop(item, None) - self.log("Removing parameter '{0}' from gateway mapping for INFRA_VN.".format(item), "DEBUG") + self.log("Removing parameter '{0}' from gateway mapping for INFRA_VN.".format( + item), "DEBUG") - self.log("Final gateway mapping for '{0}': {1}".format(vn_name, gateway_mapping), "INFO") + self.log("Final gateway mapping for '{0}': {1}".format( + vn_name, gateway_mapping), "INFO") return gateway_mapping @@ -1861,24 +1961,29 @@ def create_anycast_payload(self, anycast, fabric_id): "trafficType": anycast.get("traffic_type", "DATA"), } anycast_mapping = self.get_anycast_gateway_mapping(vn_name) - self.log("Initial payload structure created: {0}".format(anycast_payload), "DEBUG") + self.log("Initial payload structure created: {0}".format( + anycast_payload), "DEBUG") if vn_name == "INFRA_VN": - infra_enable_list = ["supplicant_based_extended_node_onboarding", "group_policy_enforcement_enabled"] + infra_enable_list = [ + "supplicant_based_extended_node_onboarding", "group_policy_enforcement_enabled"] for key, value in anycast_mapping.items(): playbook_param = anycast.get(key) if key == "pool_type": anycast_payload[value] = anycast.get(key, "EXTENDED_NODE") - self.log("Setting pool_type in payload: '{0}'.".format(anycast_payload[value]), "DEBUG") + self.log("Setting pool_type in payload: '{0}'.".format( + anycast_payload[value]), "DEBUG") continue if playbook_param is not None: anycast_payload[value] = playbook_param - self.log("Adding parameter '{0}' with value '{1}' to payload.".format(key, playbook_param), "DEBUG") + self.log("Adding parameter '{0}' with value '{1}' to payload.".format( + key, playbook_param), "DEBUG") elif playbook_param is None and key in infra_enable_list: anycast_payload[value] = False - self.log("Setting '{0}' to False in payload for INFRA_VN.".format(key), "DEBUG") + self.log( + "Setting '{0}' to False in payload for INFRA_VN.".format(key), "DEBUG") else: params_enable_list = ["is_critical_pool", "layer2_flooding_enabled", "fabric_enabled_wireless", "ip_directed_broadcast", "intra_subnet_routing_enabled", "multiple_ip_to_mac_addresses"] @@ -1887,16 +1992,19 @@ def create_anycast_payload(self, anycast, fabric_id): if playbook_param is not None: anycast_payload[value] = playbook_param - self.log("Adding parameter '{0}' with value '{1}' to payload.".format(key, playbook_param), "DEBUG") + self.log("Adding parameter '{0}' with value '{1}' to payload.".format( + key, playbook_param), "DEBUG") elif playbook_param is None and key in params_enable_list: anycast_payload[value] = False - self.log("Setting '{0}' to False in payload.".format(key), "DEBUG") + self.log( + "Setting '{0}' to False in payload.".format(key), "DEBUG") if anycast.get("auto_generate_vlan_name") is True or anycast_payload.get("isCriticalPool") is True: anycast_payload.pop("vlanName", None) anycast_payload.pop("vlanId", None) anycast_payload["autoGenerateVlanName"] = True - self.log("Auto-generating VLAN name and removing vlanName and vlanId from payload.", "DEBUG") + self.log( + "Auto-generating VLAN name and removing vlanName and vlanId from payload.", "DEBUG") else: vlan_id = anycast_payload.get("vlanId") if vlan_id and vlan_id not in range(2, 4094) or vlan_id in [1002, 1003, 1004, 1005, 2046]: @@ -1904,9 +2012,11 @@ def create_anycast_payload(self, anycast, fabric_id): "Invalid vlan_id '{0}' given in the playbook. Allowed VLAN range is (2,4094) except for " "reserved VLANs 1002-1005, and 2046." ).format(vlan_id) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() - self.log("Final Anycast payload created: {0}".format(anycast_payload), "INFO") + self.log("Final Anycast payload created: {0}".format( + anycast_payload), "INFO") return anycast_payload @@ -1929,12 +2039,12 @@ def is_gateway_needs_update(self, anycast, anycast_details_in_ccc): are found, the function returns False, indicating that the current configuration is up to date. """ - update_param_to_check = ["tcp_mss_adjustment", "traffic_type", "security_group_name", "layer2_flooding_enabled", "fabric_enabled_wireless" - , "ip_directed_broadcast", "multiple_ip_to_mac_addresses", "supplicant_based_extended_node_onboarding" - , "group_policy_enforcement_enabled"] + update_param_to_check = ["tcp_mss_adjustment", "traffic_type", "security_group_name", "layer2_flooding_enabled", "fabric_enabled_wireless", + "ip_directed_broadcast", "multiple_ip_to_mac_addresses", "supplicant_based_extended_node_onboarding", "group_policy_enforcement_enabled"] vn_name = anycast.get("vn_name") anycast_mapping = self.get_anycast_gateway_mapping(vn_name) - self.log("Checking if Anycast Gateway needs update for VN: '{0}'.".format(vn_name), "INFO") + self.log("Checking if Anycast Gateway needs update for VN: '{0}'.".format( + vn_name), "INFO") if vn_name == "INFRA_VN": params_to_remove = ["security_group_name", "layer2_flooding_enabled", "fabric_enabled_wireless", @@ -1942,16 +2052,19 @@ def is_gateway_needs_update(self, anycast, anycast_details_in_ccc): for param in params_to_remove: if param in update_param_to_check: update_param_to_check.remove(param) - self.log("Removing parameter '{0}' from update check for INFRA_VN.".format(param), "DEBUG") + self.log("Removing parameter '{0}' from update check for INFRA_VN.".format( + param), "DEBUG") else: - update_param_to_check.remove("supplicant_based_extended_node_onboarding") + update_param_to_check.remove( + "supplicant_based_extended_node_onboarding") update_param_to_check.remove("group_policy_enforcement_enabled") self.log("Removed parameters for non-INFRA_VN: 'supplicant_based_extended_node_onboarding' and " "'group_policy_enforcement_enabled'.", "DEBUG" ) if anycast.get("traffic_type") and anycast_details_in_ccc.get("isCriticalPool") is True: - self.log("Removing 'traffic_type' from update checks as 'is_critical_pool' is true.", "DEBUG") + self.log( + "Removing 'traffic_type' from update checks as 'is_critical_pool' is true.", "DEBUG") update_param_to_check.remove("traffic_type") for param in update_param_to_check: @@ -1964,7 +2077,8 @@ def is_gateway_needs_update(self, anycast, anycast_details_in_ccc): self.log(msg, "INFO") return True - self.log("No discrepancies found; Anycast Gateway configuration is up to date.", "INFO") + self.log( + "No discrepancies found; Anycast Gateway configuration is up to date.", "INFO") return False @@ -1986,7 +2100,8 @@ def get_anycast_gateway_update_payload(self, anycast, anycast_details_in_ccc): """ vn_name = anycast_details_in_ccc.get("virtualNetworkName") - self.log("Constructing update payload for Anycast Gateway in VN: '{0}'.".format(vn_name), "INFO") + self.log("Constructing update payload for Anycast Gateway in VN: '{0}'.".format( + vn_name), "INFO") anycast_payload = { "id": anycast_details_in_ccc.get("id"), "fabricId": anycast_details_in_ccc.get("fabricId"), @@ -2010,13 +2125,16 @@ def get_anycast_gateway_update_payload(self, anycast, anycast_details_in_ccc): for param in params_to_remove: if param in params_in_playbook: params_in_playbook.remove(param) - self.log("Removing parameter '{0}' from payload construction for INFRA_VN.".format(param), "DEBUG") + self.log("Removing parameter '{0}' from payload construction for INFRA_VN.".format( + param), "DEBUG") anycast_payload.pop("isCriticalPool", None) anycast_payload.pop("isIntraSubnetRoutingEnabled", None) - self.log("Removed 'isCriticalPool' and 'isIntraSubnetRoutingEnabled' for INFRA_VN.", "DEBUG") + self.log( + "Removed 'isCriticalPool' and 'isIntraSubnetRoutingEnabled' for INFRA_VN.", "DEBUG") else: - params_in_playbook.remove("supplicant_based_extended_node_onboarding") + params_in_playbook.remove( + "supplicant_based_extended_node_onboarding") params_in_playbook.remove("group_policy_enforcement_enabled") anycast_payload.pop("poolType", None) self.log("Removed parameters for non-INFRA_VN: 'supplicant_based_extended_node_onboarding' and " @@ -2025,19 +2143,24 @@ def get_anycast_gateway_update_payload(self, anycast, anycast_details_in_ccc): if anycast.get("traffic_type") and anycast_details_in_ccc.get("isCriticalPool") is True: params_in_playbook.remove("traffic_type") - anycast_payload["trafficType"] = anycast_details_in_ccc.get("trafficType") - self.log("Retaining 'traffic_type' from existing configuration due to 'is_critical_pool' being true.", "DEBUG") + anycast_payload["trafficType"] = anycast_details_in_ccc.get( + "trafficType") + self.log( + "Retaining 'traffic_type' from existing configuration due to 'is_critical_pool' being true.", "DEBUG") for param in params_in_playbook: key = anycast_mapping.get(param) if anycast.get(param) is not None: anycast_payload[key] = anycast.get(param) - self.log("Setting '{0}' to '{1}' in the payload.".format(key, anycast.get(param)), "DEBUG") + self.log("Setting '{0}' to '{1}' in the payload.".format( + key, anycast.get(param)), "DEBUG") else: anycast_payload[key] = anycast_details_in_ccc.get(key) - self.log("Using existing value for '{0}': '{1}'.".format(key, anycast_details_in_ccc.get(key)), "DEBUG") + self.log("Using existing value for '{0}': '{1}'.".format( + key, anycast_details_in_ccc.get(key)), "DEBUG") - self.log("Constructed payload for Anycast Gateway update: {0}".format(anycast_payload), "INFO") + self.log("Constructed payload for Anycast Gateway update: {0}".format( + anycast_payload), "INFO") return anycast_payload @@ -2061,19 +2184,24 @@ def add_anycast_gateways_in_system(self, add_anycast_payloads): self.log("Starting the process to add Anycast Gateways.", "INFO") payload = {"payload": add_anycast_payloads} task_name = "add_anycast_gateways" - self.log("Constructing API call payload for task '{0}': {1}".format(task_name, payload), "DEBUG") + self.log("Constructing API call payload for task '{0}': {1}".format( + task_name, payload), "DEBUG") try: task_id = self.get_taskid_post_api_call("sda", task_name, payload) if not task_id: - self.msg = "Unable to retrieve the task_id for the task '{0}'.".format(task_name) + self.msg = "Unable to retrieve the task_id for the task '{0}'.".format( + task_name) self.set_operation_result("failed", False, self.msg, "ERROR") return self - success_msg = "Anycast Gateway(s) '{0}' added successfully in the Cisco Catalyst Center.".format(self.created_anycast_gateways) - self.log("Task ID '{0}' received. Checking task status.".format(task_id), "INFO") - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + success_msg = "Anycast Gateway(s) '{0}' added successfully in the Cisco Catalyst Center.".format( + self.created_anycast_gateways) + self.log("Task ID '{0}' received. Checking task status.".format( + task_id), "INFO") + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) self.log("Completed the process to add Anycast Gateways.", "INFO") except Exception as e: @@ -2107,17 +2235,22 @@ def update_anycast_gateways_in_system(self, update_anycast_payloads): task_name = "update_anycast_gateways" try: - self.log("Constructing API call payload for task '{0}': {1}".format(task_name, payload), "DEBUG") + self.log("Constructing API call payload for task '{0}': {1}".format( + task_name, payload), "DEBUG") task_id = self.get_taskid_post_api_call("sda", task_name, payload) if not task_id: - self.msg = "Unable to retrieve the task_id for the task '{0}'.".format(task_name) + self.msg = "Unable to retrieve the task_id for the task '{0}'.".format( + task_name) self.set_operation_result("failed", False, self.msg, "ERROR") return self - success_msg = "Anycast Gateway(s) '{0}' updated successfully in the Cisco Catalyst Center.".format(self.updated_anycast_gateways) - self.log("Task ID '{0}' received. Checking task status.".format(task_id), "INFO") - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + success_msg = "Anycast Gateway(s) '{0}' updated successfully in the Cisco Catalyst Center.".format( + self.updated_anycast_gateways) + self.log("Task ID '{0}' received. Checking task status.".format( + task_id), "INFO") + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) self.log("Completed the process to update Anycast Gateways.", "INFO") except Exception as e: @@ -2149,27 +2282,35 @@ def delete_anycast_gateway(self, gateway_id, unique_anycast): The method returns the instance itself, allowing for further interactions with the object. """ - self.log("Initiating deletion of Anycast Gateway '{0}'.".format(unique_anycast), "INFO") + self.log("Initiating deletion of Anycast Gateway '{0}'.".format( + unique_anycast), "INFO") payload = {"id": gateway_id} task_name = "delete_anycast_gateway_by_id" try: - self.log("Constructing API call payload for task '{0}': {1}".format(task_name, payload), "DEBUG") + self.log("Constructing API call payload for task '{0}': {1}".format( + task_name, payload), "DEBUG") task_id = self.get_taskid_post_api_call("sda", task_name, payload) if not task_id: - self.msg = "Unable to retrieve the task_id for the task '{0}'.".format(task_name) + self.msg = "Unable to retrieve the task_id for the task '{0}'.".format( + task_name) self.set_operation_result("failed", False, self.msg, "ERROR") return self - success_msg = "Anycast Gateway '{0}' deleted successfully from the Cisco Catalyst Center.".format(unique_anycast) - self.log("Task ID '{0}' received. Checking task status...".format(task_id), "INFO") - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + success_msg = "Anycast Gateway '{0}' deleted successfully from the Cisco Catalyst Center.".format( + unique_anycast) + self.log("Task ID '{0}' received. Checking task status...".format( + task_id), "INFO") + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) self.deleted_anycast_gateways.append(unique_anycast) - self.log("Completed deletion process for Anycast Gateway '{0}'.".format(unique_anycast), "INFO") + self.log("Completed deletion process for Anycast Gateway '{0}'.".format( + unique_anycast), "INFO") except Exception as e: - self.msg = "Exception occurred while deleting the Anycast Gateway '{0}' due to: {1}".format(unique_anycast, str(e)) + self.msg = "Exception occurred while deleting the Anycast Gateway '{0}' due to: {1}".format( + unique_anycast, str(e)) self.set_operation_result("failed", False, self.msg, "ERROR") return self @@ -2203,7 +2344,8 @@ def get_want_fabric_vlan_details(self, fabric_vlan_details): for param in required_param: value = vlan.get(param) if not value: - self.log("Adding the missing param '{0}' required for fabric Vlan operations".format(value), "DEBUG") + self.log("Adding the missing param '{0}' required for fabric Vlan operations".format( + value), "DEBUG") missing_required_param.append(param) if vlan_id not in range(2, 4094) or vlan_id in [1002, 1003, 1004, 1005, 2046]: @@ -2211,7 +2353,8 @@ def get_want_fabric_vlan_details(self, fabric_vlan_details): "Invalid vlan_id '{0}' given in the playbook. Allowed VLAN range is (2,4094) except for " "reserved VLANs 1002-1005, and 2046." ).format(vlan_id) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() return self if missing_required_param: @@ -2219,19 +2362,22 @@ def get_want_fabric_vlan_details(self, fabric_vlan_details): "Required parameter(s) '{0}' are missing and they must be given in the playbook in order to " "perform any layer2 fabric vlan operation in Cisco Catalyst Center." ).format(missing_required_param) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() # Validate the Fabric Vlan name against the regex is_valid_vlan_name = self.is_valid_fabric_vlan_name(vlan_name) if is_valid_vlan_name: - self.log("Given fabric VLAN name '{0}' is valid for the sda operation.".format(vlan_name), "INFO") + self.log("Given fabric VLAN name '{0}' is valid for the sda operation.".format( + vlan_name), "INFO") else: self.msg = ( "Given Fabric VLAN name '{0}' in the input playbook is not valid. Fabric VLAN name " "should be 1-32 characters long and contains only alphanumeric characters, underscores and hyphens." ).format(vlan_name) - self.set_operation_result("failed", False, self.msg, "WARNING").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "WARNING").check_return_status() for fabric in fabric_site_locations: site_name = fabric.get("site_name_hierarchy") @@ -2242,11 +2388,13 @@ def get_want_fabric_vlan_details(self, fabric_vlan_details): "Required parameter 'site_name' and 'fabric_type 'must be given in the playbook in order to " "perform any operation on fabric vlan '{0}'." ).format(vlan_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() # Validate the correct fabric_type given in the playbook self.validate_fabric_type(fabric_type).check_return_status() - self.log("Fabric type '{0}' is valid.".format(fabric_type), "INFO") + self.log("Fabric type '{0}' is valid.".format( + fabric_type), "INFO") fabric_vlan_info.append(vlan) return fabric_vlan_info @@ -2280,19 +2428,22 @@ def get_want_virtual_network_details(self, vn_details): "Required parameter 'vn_name' must be given in the playbook in order to perform any virtual " "networks operation including creation/updation/deletion in Cisco Catalyst Center." ) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() # Validate the VN name against the regex is_valid_name = self.is_valid_vn_name(vn_name) if is_valid_name: - self.log("Given virtual network name '{0}' is valid for the SDA operation.".format(vn_name), "INFO") + self.log("Given virtual network name '{0}' is valid for the SDA operation.".format( + vn_name), "INFO") else: self.msg = ( "Given Virtual Network name '{0}' in the input playbook is not valid. Virtual Network " "name should be 1-16 characters long and contain only letters numbers and underscores." ).format(vn_name) - self.set_operation_result("failed", False, self.msg, "WARNING").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "WARNING").check_return_status() vn_info.append(vn) @@ -2327,7 +2478,8 @@ def get_want_anycast_gateway_details(self, anycast_gateway_details): state = self.params.get("state") for anycast in anycast_gateway_details: - required_param = ["vn_name", "fabric_site_location", "ip_pool_name"] + required_param = ["vn_name", + "fabric_site_location", "ip_pool_name"] vn_name = anycast.get("vn_name") ip_pool_name = anycast.get("ip_pool_name") missing_required_item = [] @@ -2341,7 +2493,8 @@ def get_want_anycast_gateway_details(self, anycast_gateway_details): "Required parameter '{0}' must be given in the playbook in order to perform any anycast " "networks operation including creation/updation/deletion in Cisco Catalyst Center." ).format(missing_required_item) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() is_vn_exist = self.is_virtual_network_exist(vn_name) @@ -2353,20 +2506,25 @@ def get_want_anycast_gateway_details(self, anycast_gateway_details): if state == "deleted": continue - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() - site_name = anycast.get("fabric_site_location").get("site_name_hierarchy") + site_name = anycast.get("fabric_site_location").get( + "site_name_hierarchy") if not site_name: self.msg = ( "Parameter 'site_name' must be provided in the playbook in order to configure " "anycast gateway in the Catalyst Center." ) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() site_exists, site_id = self.get_site_id(site_name) if not site_exists: - self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format( + site_name) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() is_pool_exist = self.is_ip_pool_exist(ip_pool_name, site_id) if not is_pool_exist: @@ -2375,7 +2533,8 @@ def get_want_anycast_gateway_details(self, anycast_gateway_details): "Please create and reserve the given IP pool using the network_settings_workflow_manager" " module for the configuration of Anycast gateways in the Catalyst Center." ).format(ip_pool_name, site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() anycast_info.append(anycast) @@ -2406,11 +2565,13 @@ def get_want(self, config): """ want = {} - self.log("Starting the process of gathering the desired state from the configuration.", "INFO") + self.log( + "Starting the process of gathering the desired state from the configuration.", "INFO") fabric_vlan_details = config.get('fabric_vlan') if fabric_vlan_details: - vlan_details = self.get_want_fabric_vlan_details(fabric_vlan_details) + vlan_details = self.get_want_fabric_vlan_details( + fabric_vlan_details) if vlan_details: want["fabric_vlan_info"] = vlan_details @@ -2424,7 +2585,8 @@ def get_want(self, config): anycast_gateway_details = config.get("anycast_gateways") if anycast_gateway_details: - anycast_info_details = self.get_want_anycast_gateway_details(anycast_gateway_details) + anycast_info_details = self.get_want_anycast_gateway_details( + anycast_gateway_details) if anycast_info_details: want["anycast_info"] = anycast_info_details @@ -2469,28 +2631,35 @@ def get_have(self, config): for vlan in fabric_vlan_details: vlan_name = vlan.get("vlan_name") vlan_id = vlan.get("vlan_id") - self.log("Collecting VLAN IDs for VLAN '{0}' with ID '{1}'.".format(vlan_name, vlan_id), "DEBUG") - fabric_vlan_ids = self.collect_fabric_vlan_ids(vlan_name, vlan_id) + self.log("Collecting VLAN IDs for VLAN '{0}' with ID '{1}'.".format( + vlan_name, vlan_id), "DEBUG") + fabric_vlan_ids = self.collect_fabric_vlan_ids( + vlan_name, vlan_id) if fabric_vlan_ids: - self.log("Successfully collect the vlan details for the vlan '{0}'.".format(vlan_name), "DEBUG") + self.log("Successfully collect the vlan details for the vlan '{0}'.".format( + vlan_name), "DEBUG") have["fabric_vlan_ids"].extend(fabric_vlan_ids) else: - self.log("No VLAN details found for '{0}'.".format(vlan_name), "DEBUG") + self.log("No VLAN details found for '{0}'.".format( + vlan_name), "DEBUG") virtual_networks = config.get('virtual_networks') if virtual_networks: self.log("Starting to collect Layer3 Virtual Network details.", "INFO") for vn in virtual_networks: vn_name = vn.get("vn_name") - self.log("Checking existence for Virtual Network '{0}'.".format(vn_name), "DEBUG") + self.log("Checking existence for Virtual Network '{0}'.".format( + vn_name), "DEBUG") is_vn_exist = self.is_virtual_network_exist(vn_name) if is_vn_exist: - self.log("Successfully collect the layer3 VN details for the VN '{0}'.".format(vn_name), "DEBUG") + self.log("Successfully collect the layer3 VN details for the VN '{0}'.".format( + vn_name), "DEBUG") have["l3_vn_name"].append(vn_name) else: - self.log("Virtual Network '{0}' does not exist.".format(vn_name), "DEBUG") + self.log("Virtual Network '{0}' does not exist.".format( + vn_name), "DEBUG") anycast_gateways = config.get('anycast_gateways') if anycast_gateways: @@ -2498,35 +2667,45 @@ def get_have(self, config): for anycast in anycast_gateways: vn_name = anycast.get("vn_name") ip_pool_name = anycast.get("ip_pool_name") - site_name = anycast.get("fabric_site_location").get("site_name_hierarchy") + site_name = anycast.get("fabric_site_location").get( + "site_name_hierarchy") self.log("Collecting Anycast Gateway details for VN '{0}', IP Pool '{1}', Site '{2}'." .format(vn_name, ip_pool_name, site_name), "DEBUG" ) site_exists, site_id = self.get_site_id(site_name) if not site_exists: - self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format( + site_name) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() - fabric_type = anycast.get("fabric_site_location").get("fabric_type") + fabric_type = anycast.get( + "fabric_site_location").get("fabric_type") # Validate the fabric_type given in the playbook - self.log("Validating fabric type '{0}'.".format(fabric_type), "DEBUG") + self.log("Validating fabric type '{0}'.".format( + fabric_type), "DEBUG") self.validate_fabric_type(fabric_type).check_return_status() - self.log("Fabric type '{0}' is valid.".format(fabric_type), "INFO") + self.log("Fabric type '{0}' is valid.".format( + fabric_type), "INFO") if fabric_type == "fabric_site": fabric_id = self.get_fabric_site_id(site_name, site_id) else: fabric_id = self.get_fabric_zone_id(site_name, site_id) - self.log("Collected fabric ID '{0}' for site '{1}'.".format(fabric_id, site_name), "DEBUG") + self.log("Collected fabric ID '{0}' for site '{1}'.".format( + fabric_id, site_name), "DEBUG") # Collect the gateway id with combination of vn_name, ip_pool_name and fabric id - gateway_details = self.get_anycast_gateway_details(vn_name, ip_pool_name, fabric_id) + gateway_details = self.get_anycast_gateway_details( + vn_name, ip_pool_name, fabric_id) if gateway_details: gateway_id = gateway_details.get("id") - self.log("Successfully collect the anycast gateway details for the IP pool '{0}'.".format(ip_pool_name), "DEBUG") + self.log("Successfully collect the anycast gateway details for the IP pool '{0}'.".format( + ip_pool_name), "DEBUG") have["anycast_gateway_ids"].append(gateway_id) else: - self.log("No Anycast Gateway found for IP Pool '{0}' in VN '{1}'.".format(ip_pool_name, vn_name), "DEBUG") + self.log("No Anycast Gateway found for IP Pool '{0}' in VN '{1}'.".format( + ip_pool_name, vn_name), "DEBUG") self.have = have self.log("Current State (have): {0}".format(str(have)), "INFO") @@ -2556,35 +2735,43 @@ def update_fabric_vlan_vn_anycast_gateway_messages(self): result_msg_list = [] if self.created_fabric_vlans: - create_fabric_vlan = "Layer2 Fabric VLAN(s) '{0}' created successfully in the Cisco Catalyst Center.".format(self.created_fabric_vlans) + create_fabric_vlan = "Layer2 Fabric VLAN(s) '{0}' created successfully in the Cisco Catalyst Center.".format( + self.created_fabric_vlans) result_msg_list.append(create_fabric_vlan) if self.updated_fabric_vlans: - update_fabric_vlan = "Layer2 Fabric VLAN(s) '{0}' updated successfully in the Cisco Catalyst Center.".format(self.updated_fabric_vlans) + update_fabric_vlan = "Layer2 Fabric VLAN(s) '{0}' updated successfully in the Cisco Catalyst Center.".format( + self.updated_fabric_vlans) result_msg_list.append(update_fabric_vlan) if self.no_update_fabric_vlans: - no_update_fabric_vlans = "Given Fabric VLAN(s) '{0}' does not need any update in Cisco Catalyst Center.".format(self.no_update_fabric_vlans) + no_update_fabric_vlans = "Given Fabric VLAN(s) '{0}' does not need any update in Cisco Catalyst Center.".format( + self.no_update_fabric_vlans) result_msg_list.append(no_update_fabric_vlans) if self.created_virtual_networks: - create_vn_msg = "Layer3 Virtual Network(s) '{0}' created successfully in the Cisco Catalyst Center.".format(self.created_virtual_networks) + create_vn_msg = "Layer3 Virtual Network(s) '{0}' created successfully in the Cisco Catalyst Center.".format( + self.created_virtual_networks) result_msg_list.append(create_vn_msg) if self.updated_virtual_networks: - update_vn_msg = "Layer3 Virtual Network(s '{0}' updated successfully in the Cisco Catalyst Center.".format(self.updated_virtual_networks) + update_vn_msg = "Layer3 Virtual Network(s '{0}' updated successfully in the Cisco Catalyst Center.".format( + self.updated_virtual_networks) result_msg_list.append(update_vn_msg) if self.no_update_virtual_networks: - no_update_vns_msg = "Given Virtual Network(s '{0}' does not need any update in Cisco Catalyst Center.".format(self.no_update_virtual_networks) + no_update_vns_msg = "Given Virtual Network(s '{0}' does not need any update in Cisco Catalyst Center.".format( + self.no_update_virtual_networks) result_msg_list.append(no_update_vns_msg) if self.created_anycast_gateways: - create_anycast_msg = "Anycast Gateway(s) '{0}' added successfully in the Cisco Catalyst Center.".format(self.created_anycast_gateways) + create_anycast_msg = "Anycast Gateway(s) '{0}' added successfully in the Cisco Catalyst Center.".format( + self.created_anycast_gateways) result_msg_list.append(create_anycast_msg) if self.updated_anycast_gateways: - update_anycast_msg = "Anycast Gateway(s) '{0}' updated successfully in the Cisco Catalyst Center.".format(self.updated_anycast_gateways) + update_anycast_msg = "Anycast Gateway(s) '{0}' updated successfully in the Cisco Catalyst Center.".format( + self.updated_anycast_gateways) result_msg_list.append(update_anycast_msg) if self.no_update_anycast_gateways: @@ -2594,15 +2781,18 @@ def update_fabric_vlan_vn_anycast_gateway_messages(self): result_msg_list.append(no_update_anycast_gateways_msg) if self.deleted_fabric_vlans: - delete_vlan_msg = "Fabric VLAN(s) '{0}' deleted successfully from the Cisco Catalyst Center.".format(self.deleted_fabric_vlans) + delete_vlan_msg = "Fabric VLAN(s) '{0}' deleted successfully from the Cisco Catalyst Center.".format( + self.deleted_fabric_vlans) result_msg_list.append(delete_vlan_msg) if self.absent_fabric_vlans: - absent_vlan_msg = "Unable to delete Fabric VLAN(s) '{0}' as they are not present in Cisco Catalyst Center.".format(self.absent_fabric_vlans) + absent_vlan_msg = "Unable to delete Fabric VLAN(s) '{0}' as they are not present in Cisco Catalyst Center.".format( + self.absent_fabric_vlans) result_msg_list.append(absent_vlan_msg) if self.deleted_virtual_networks: - delete_vn_msg = "Layer3 Virtual Network(s) '{0}' deleted successfully from the Cisco Catalyst Center.".format(self.deleted_virtual_networks) + delete_vn_msg = "Layer3 Virtual Network(s) '{0}' deleted successfully from the Cisco Catalyst Center.".format( + self.deleted_virtual_networks) result_msg_list.append(delete_vn_msg) if self.absent_virtual_networks: @@ -2612,7 +2802,8 @@ def update_fabric_vlan_vn_anycast_gateway_messages(self): result_msg_list.append(absent_virtual_networks_msg) if self.deleted_anycast_gateways: - delete_anycast_msg = "Anycast Gateway(s) '{0}' deleted successfully from the Cisco Catalyst Center.".format(self.deleted_anycast_gateways) + delete_anycast_msg = "Anycast Gateway(s) '{0}' deleted successfully from the Cisco Catalyst Center.".format( + self.deleted_anycast_gateways) result_msg_list.append(delete_anycast_msg) if self.absent_anycast_gateways: @@ -2629,7 +2820,8 @@ def update_fabric_vlan_vn_anycast_gateway_messages(self): self.result["changed"] = True self.msg = " ".join(result_msg_list) - self.set_operation_result("success", self.result["changed"], self.msg, "INFO") + self.set_operation_result( + "success", self.result["changed"], self.msg, "INFO") return self @@ -2658,17 +2850,21 @@ def process_fabric_vlans(self, fabric_vlan_details): vlan_id = vlan.get("vlan_id") fabric_locations = vlan.get("fabric_site_locations") fabric_id_list, site_name_list = [], [] - self.log("Processing VLAN '{0}' with ID '{1}'.".format(vlan_name, vlan_id), "INFO") + self.log("Processing VLAN '{0}' with ID '{1}'.".format( + vlan_name, vlan_id), "INFO") for fabric in fabric_locations: site_name = fabric.get("site_name_hierarchy") fabric_type = fabric.get("fabric_type") site_exists, site_id = self.get_site_id(site_name) if not site_exists: - self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format( + site_name) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() - self.log("Checking fabric type for site '{0}'.".format(site_name), "DEBUG") + self.log("Checking fabric type for site '{0}'.".format( + site_name), "DEBUG") if fabric_type == "fabric_site": fabric_id = self.get_fabric_site_id(site_name, site_id) else: @@ -2679,38 +2875,51 @@ def process_fabric_vlans(self, fabric_vlan_details): "Given site '{0}' is not the fabric site/zone. Please make it fabric site/zone " "first to perform any layer2 fabric vlan operation in Cisco Catalyst Center." ).format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() - fabric_vlan_in_ccc = self.get_fabric_vlan_details(vlan_name, vlan_id, fabric_id) + fabric_vlan_in_ccc = self.get_fabric_vlan_details( + vlan_name, vlan_id, fabric_id) if fabric_vlan_in_ccc: if fabric_type == "fabric_site": vlan_name_in_ccc = fabric_vlan_in_ccc.get("vlanName") - vlan_name_with_id_and_site = "{0} having vlan id: {1} and site: {2}".format(vlan_name_in_ccc, vlan_id, site_name) + vlan_name_with_id_and_site = "{0} having vlan id: {1} and site: {2}".format( + vlan_name_in_ccc, vlan_id, site_name) # Check fabric VLAN needs update or not only for fabric site if self.fabric_vlan_needs_update(vlan, fabric_vlan_in_ccc): - self.updated_fabric_vlans.append(vlan_name_with_id_and_site) - collected_update_vlan_payload.append(self.update_payload_fabric_vlan(vlan, fabric_vlan_in_ccc, fabric_id)) - self.log("VLAN '{0}' needs to be updated.".format(vlan_name), "INFO") + self.updated_fabric_vlans.append( + vlan_name_with_id_and_site) + collected_update_vlan_payload.append( + self.update_payload_fabric_vlan(vlan, fabric_vlan_in_ccc, fabric_id)) + self.log("VLAN '{0}' needs to be updated.".format( + vlan_name), "INFO") else: - self.no_update_fabric_vlans.append(vlan_name_with_id_and_site) - self.msg = "Given L2 Vlan '{0}' does not need any update".format(vlan_name_with_id_and_site) + self.no_update_fabric_vlans.append( + vlan_name_with_id_and_site) + self.msg = "Given L2 Vlan '{0}' does not need any update".format( + vlan_name_with_id_and_site) self.log(self.msg, "INFO") self.result["response"] = self.msg else: - self.log("Fabric ID '{0}' added for VLAN '{1}' for site {2}.".format(fabric_id, vlan_name, site_name), "DEBUG") + self.log("Fabric ID '{0}' added for VLAN '{1}' for site {2}.".format( + fabric_id, vlan_name, site_name), "DEBUG") fabric_id_list.append(fabric_id) site_name_list.append(site_name) if fabric_id_list: sites = ", ".join(site_name_list) - vlan_name_with_id_and_site = "{0} having vlan id: {1} and site: {2}".format(vlan_name, vlan_id, sites) - self.log("Creating new VLAN '{0}' with fabric IDs: {1}.".format(vlan_name, fabric_id_list), "INFO") + vlan_name_with_id_and_site = "{0} having vlan id: {1} and site: {2}".format( + vlan_name, vlan_id, sites) + self.log("Creating new VLAN '{0}' with fabric IDs: {1}.".format( + vlan_name, fabric_id_list), "INFO") self.created_fabric_vlans.append(vlan_name_with_id_and_site) - collected_add_vlan_payload.extend(self.create_payload_for_fabric_vlan(vlan, fabric_id_list)) + collected_add_vlan_payload.extend( + self.create_payload_for_fabric_vlan(vlan, fabric_id_list)) if collected_add_vlan_payload: - self.create_fabric_vlan(collected_add_vlan_payload).check_return_status() + self.create_fabric_vlan( + collected_add_vlan_payload).check_return_status() self.log("Successfully created fabric VLANs.", "INFO") if collected_update_vlan_payload: @@ -2752,27 +2961,33 @@ def process_virtual_networks(self, virtual_networks): for vn_details in virtual_networks: vn_name = vn_details.get("vn_name") vn_payload = {"virtualNetworkName": vn_name} - self.log("Processing Virtual Network '{0}'.".format(vn_name), "INFO") + self.log("Processing Virtual Network '{0}'.".format( + vn_name), "INFO") if self.have.get("l3_vn_name") and vn_name in self.have.get("l3_vn_name"): # Given VN already present in Cisco Catalyst Center, check vn needs update or not. vn_in_ccc = self.get_vn_details_from_ccc(vn_name) - vn_needs_update = self.is_vn_needs_update(vn_details, vn_in_ccc) + vn_needs_update = self.is_vn_needs_update( + vn_details, vn_in_ccc) if vn_needs_update: self.updated_virtual_networks.append(vn_name) - update_vn_payloads.append(self.update_payload_vn(vn_details, vn_in_ccc)) - self.log("Virtual Network '{0}' needs to be updated.".format(vn_name), "INFO") + update_vn_payloads.append( + self.update_payload_vn(vn_details, vn_in_ccc)) + self.log("Virtual Network '{0}' needs to be updated.".format( + vn_name), "INFO") else: # Given Virtual network doesnot need any update self.no_update_virtual_networks.append(vn_name) - self.msg = "Given Virtual network '{0}' does not need any update".format(vn_name) + self.msg = "Given Virtual network '{0}' does not need any update".format( + vn_name) self.log(self.msg, "INFO") self.result["response"] = self.msg else: self.created_virtual_networks.append(vn_name) vn_payload = self.create_vn_payload(vn_details) add_vn_payloads.append(vn_payload) - self.log("Virtual Network '{0}' is new and will be created.".format(vn_name), "INFO") + self.log("Virtual Network '{0}' is new and will be created.".format( + vn_name), "INFO") if add_vn_payloads: self.create_virtual_networks(add_vn_payloads).check_return_status() @@ -2809,13 +3024,17 @@ def process_anycast_gateways(self, anycast_gateways): for anycast in anycast_gateways: vn_name = anycast.get("vn_name") ip_pool_name = anycast.get("ip_pool_name") - site_name = anycast.get("fabric_site_location").get("site_name_hierarchy") + site_name = anycast.get("fabric_site_location").get( + "site_name_hierarchy") site_exists, site_id = self.get_site_id(site_name) if not site_exists: - self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format( + site_name) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() - fabric_type = anycast.get("fabric_site_location").get("fabric_type") + fabric_type = anycast.get( + "fabric_site_location").get("fabric_type") if fabric_type == "fabric_site": fabric_id = self.get_fabric_site_id(site_name, site_id) @@ -2824,37 +3043,48 @@ def process_anycast_gateways(self, anycast_gateways): # Collect the gateway id with combination of vn_name, ip_pool_name and fabric id unique_anycast = vn_name + "_" + ip_pool_name + "_" + site_name - anycast_details_in_ccc = self.get_anycast_gateway_details(vn_name, ip_pool_name, fabric_id) + anycast_details_in_ccc = self.get_anycast_gateway_details( + vn_name, ip_pool_name, fabric_id) self.validate_gateway_payload(anycast).check_return_status() - self.log("Processing anycast gateway: {0}".format(unique_anycast), "INFO") + self.log("Processing anycast gateway: {0}".format( + unique_anycast), "INFO") if anycast_details_in_ccc: # Already present in the Cisco Catalyst Center and check for update needed or not. - gateway_needs_update = self.is_gateway_needs_update(anycast, anycast_details_in_ccc) + gateway_needs_update = self.is_gateway_needs_update( + anycast, anycast_details_in_ccc) if gateway_needs_update: self.updated_anycast_gateways.append(unique_anycast) - gateway_update_payload = self.get_anycast_gateway_update_payload(anycast, anycast_details_in_ccc) + gateway_update_payload = self.get_anycast_gateway_update_payload( + anycast, anycast_details_in_ccc) update_anycast_payloads.append(gateway_update_payload) - self.log("Updated anycast gateway: {0}".format(unique_anycast), "INFO") + self.log("Updated anycast gateway: {0}".format( + unique_anycast), "INFO") else: self.no_update_anycast_gateways.append(unique_anycast) - self.msg = "Given Anycast gateway '{0}' does not need any update in the Cisco Catalyst Center".format(unique_anycast) + self.msg = "Given Anycast gateway '{0}' does not need any update in the Cisco Catalyst Center".format( + unique_anycast) self.log(self.msg, "INFO") self.result["response"] = self.msg else: # Given Anycast gateways details not present in the system needs to create it self.created_anycast_gateways.append(unique_anycast) - gateway_payload = self.create_anycast_payload(anycast, fabric_id) + gateway_payload = self.create_anycast_payload( + anycast, fabric_id) add_anycast_payloads.append(gateway_payload) - self.log("Created anycast gateway: {0}".format(unique_anycast), "INFO") + self.log("Created anycast gateway: {0}".format( + unique_anycast), "INFO") if add_anycast_payloads: - self.add_anycast_gateways_in_system(add_anycast_payloads).check_return_status() - self.log("Added anycast gateways: {0}".format(", ".join(self.created_anycast_gateways)), "INFO") + self.add_anycast_gateways_in_system( + add_anycast_payloads).check_return_status() + self.log("Added anycast gateways: {0}".format( + ", ".join(self.created_anycast_gateways)), "INFO") if update_anycast_payloads: self.update_anycast_gateways_in_system(update_anycast_payloads) - self.log("Updated anycast gateways: {0}".format(", ".join(self.updated_anycast_gateways)), "INFO") + self.log("Updated anycast gateways: {0}".format( + ", ".join(self.updated_anycast_gateways)), "INFO") return self @@ -2889,11 +3119,14 @@ def delete_fabric_vlan(self, fabric_vlan_details): for fabric in fabric_locations: site_name = fabric.get("site_name_hierarchy") fabric_type = fabric.get("fabric_type") - vlan_name_with_id_and_site = "{0} having vlan id: {1} and site: {2}".format(vlan_name, vlan_id, site_name) + vlan_name_with_id_and_site = "{0} having vlan id: {1} and site: {2}".format( + vlan_name, vlan_id, site_name) site_exists, site_id = self.get_site_id(site_name) if not site_exists: - self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format( + site_name) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() if fabric_type == "fabric_site": fabric_id = self.get_fabric_site_id(site_name, site_id) @@ -2909,28 +3142,37 @@ def delete_fabric_vlan(self, fabric_vlan_details): self.absent_fabric_vlans.append(vlan_name_with_id_and_site) continue - fabric_vlan_in_ccc = self.get_fabric_vlan_details(vlan_name, vlan_id, fabric_id) + fabric_vlan_in_ccc = self.get_fabric_vlan_details( + vlan_name, vlan_id, fabric_id) if not fabric_vlan_in_ccc: - self.log("Given fabric vlan '{0}' is not present in Cisco Catalyst Center.".format(vlan_name), "WARNING") + self.log("Given fabric vlan '{0}' is not present in Cisco Catalyst Center.".format( + vlan_name), "WARNING") self.absent_fabric_vlans.append(vlan_name_with_id_and_site) continue fabric_vlan_id = fabric_vlan_in_ccc.get("id") if fabric_type == "fabric_site": - name_id_site_key = "{0}${1}${2}".format(vlan_name, vlan_id, site_name) + name_id_site_key = "{0}${1}${2}".format( + vlan_name, vlan_id, site_name) fabric_site_dict[name_id_site_key] = fabric_vlan_id else: - self.delete_layer2_fabric_vlan(vlan_name, fabric_vlan_id, vlan_name_with_id_and_site).check_return_status() - self.log("Successfully deleted fabric VLAN '{0}' from Cisco Catalyst Center.".format(vlan_name_with_id_and_site), "INFO") + self.delete_layer2_fabric_vlan( + vlan_name, fabric_vlan_id, vlan_name_with_id_and_site).check_return_status() + self.log("Successfully deleted fabric VLAN '{0}' from Cisco Catalyst Center.".format( + vlan_name_with_id_and_site), "INFO") for name_id_key, fabric_vlan_id in fabric_site_dict.items(): vlan_name, vlan_id, site_name = name_id_key.split("$") - vlan_name_with_id_and_site = "{0} having vlan id: {1} and site: {2}".format(vlan_name, vlan_id, site_name) - self.delete_layer2_fabric_vlan(vlan_name, fabric_vlan_id, vlan_name_with_id_and_site).check_return_status() - self.log("Successfully deleted fabric VLAN '{0}' from Cisco Catalyst Center.".format(vlan_name_with_id_and_site), "INFO") + vlan_name_with_id_and_site = "{0} having vlan id: {1} and site: {2}".format( + vlan_name, vlan_id, site_name) + self.delete_layer2_fabric_vlan( + vlan_name, fabric_vlan_id, vlan_name_with_id_and_site).check_return_status() + self.log("Successfully deleted fabric VLAN '{0}' from Cisco Catalyst Center.".format( + vlan_name_with_id_and_site), "INFO") if self.deleted_fabric_vlans: - self.log("Given VLAN(s) '{0}' deleted successfully from the Cisco Catalyst Center".format(self.deleted_fabric_vlans), "INFO") + self.log("Given VLAN(s) '{0}' deleted successfully from the Cisco Catalyst Center".format( + self.deleted_fabric_vlans), "INFO") return self @@ -2966,14 +3208,18 @@ def delete_virtual_network(self, virtual_network_details): if self.have.get("l3_vn_name") and vn_name in self.have.get("l3_vn_name"): vn_in_ccc = self.get_vn_details_from_ccc(vn_name) vn_id = vn_in_ccc.get("id") - self.delete_layer3_virtual_network(vn_name, vn_id).check_return_status() - self.log("Successfully deleted virtual network '{0}' from Cisco Catalyst Center.".format(vn_name), "INFO") + self.delete_layer3_virtual_network( + vn_name, vn_id).check_return_status() + self.log("Successfully deleted virtual network '{0}' from Cisco Catalyst Center.".format( + vn_name), "INFO") else: - self.log("Given Virtual network '{0}' is not present in Cisco Catalyst Center.".format(vn_name), "INFO") + self.log("Given Virtual network '{0}' is not present in Cisco Catalyst Center.".format( + vn_name), "INFO") self.absent_virtual_networks.append(vn_name) if self.deleted_virtual_networks: - self.log("Given Virtual Network(s) '{0}' deleted successfully from the Cisco Catalyst Center".format(self.deleted_virtual_networks), "INFO") + self.log("Given Virtual Network(s) '{0}' deleted successfully from the Cisco Catalyst Center".format( + self.deleted_virtual_networks), "INFO") return self @@ -3006,13 +3252,17 @@ def delete_anycast_gateway_from_ccc(self, anycast_gateways): for anycast in anycast_gateways: vn_name = anycast.get("vn_name") ip_pool_name = anycast.get("ip_pool_name") - site_name = anycast.get("fabric_site_location").get("site_name_hierarchy") + site_name = anycast.get("fabric_site_location").get( + "site_name_hierarchy") site_exists, site_id = self.get_site_id(site_name) if not site_exists: - self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format( + site_name) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() - fabric_type = anycast.get("fabric_site_location").get("fabric_type") + fabric_type = anycast.get( + "fabric_site_location").get("fabric_type") if fabric_type == "fabric_site": fabric_id = self.get_fabric_site_id(site_name, site_id) @@ -3021,19 +3271,23 @@ def delete_anycast_gateway_from_ccc(self, anycast_gateways): # Collect the gateway id with combination of vn_name, ip_pool_name and fabric id unique_anycast = vn_name + "_" + ip_pool_name + "_" + site_name - anycast_details_in_ccc = self.get_anycast_gateway_details(vn_name, ip_pool_name, fabric_id) + anycast_details_in_ccc = self.get_anycast_gateway_details( + vn_name, ip_pool_name, fabric_id) if not anycast_details_in_ccc: self.absent_anycast_gateways.append(unique_anycast) - self.log("Given Anycast gateway '{0}' is not present in Cisco Catalyst Center.".format(unique_anycast), "INFO") + self.log("Given Anycast gateway '{0}' is not present in Cisco Catalyst Center.".format( + unique_anycast), "INFO") continue gateway_id = anycast_details_in_ccc.get("id") - self.delete_anycast_gateway(gateway_id, unique_anycast).check_return_status() + self.delete_anycast_gateway( + gateway_id, unique_anycast).check_return_status() if self.deleted_anycast_gateways: - self.log("Given Anycast Gateway(s) '{0}' deleted successfully from the Cisco Catalyst Center.".format(self.deleted_anycast_gateways), "INFO") + self.log("Given Anycast Gateway(s) '{0}' deleted successfully from the Cisco Catalyst Center.".format( + self.deleted_anycast_gateways), "INFO") return self @@ -3063,15 +3317,18 @@ def verify_fabric_vlan(self, fabric_vlan_details): fabric_type = fabric.get("fabric_type") site_exists, site_id = self.get_site_id(site_name) if not site_exists: - self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format( + site_name) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() if fabric_type == "fabric_site": fabric_id = self.get_fabric_site_id(site_name, site_id) else: fabric_id = self.get_fabric_zone_id(site_name, site_id) - fabric_vlan_in_ccc = self.get_fabric_vlan_details(vlan_name, vlan_id, fabric_id) + fabric_vlan_in_ccc = self.get_fabric_vlan_details( + vlan_name, vlan_id, fabric_id) if fabric_vlan_in_ccc: verify_vlan_list.append(vlan_name) else: @@ -3153,13 +3410,17 @@ def verify_anycast_gateway(self, anycast_gateways): for anycast in anycast_gateways: vn_name = anycast.get("vn_name") ip_pool_name = anycast.get("ip_pool_name") - site_name = anycast.get("fabric_site_location").get("site_name_hierarchy") + site_name = anycast.get("fabric_site_location").get( + "site_name_hierarchy") site_exists, site_id = self.get_site_id(site_name) if not site_exists: - self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format( + site_name) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() - fabric_type = anycast.get("fabric_site_location").get("fabric_type") + fabric_type = anycast.get( + "fabric_site_location").get("fabric_type") if fabric_type == "fabric_site": fabric_id = self.get_fabric_site_id(site_name, site_id) @@ -3168,7 +3429,8 @@ def verify_anycast_gateway(self, anycast_gateways): # Collect the gateway id with combination of vn_name, ip_pool_name and fabric id unique_anycast = vn_name + "_" + ip_pool_name + "_" + site_name - anycast_details_in_ccc = self.get_anycast_gateway_details(vn_name, ip_pool_name, fabric_id) + anycast_details_in_ccc = self.get_anycast_gateway_details( + vn_name, ip_pool_name, fabric_id) if anycast_details_in_ccc: verify_anycast_list.append(unique_anycast) @@ -3217,15 +3479,18 @@ def verify_vlan_deletion(self, fabric_vlan_details): fabric_type = fabric.get("fabric_type") site_exists, site_id = self.get_site_id(site_name) if not site_exists: - self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format( + site_name) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() if fabric_type == "fabric_site": fabric_id = self.get_fabric_site_id(site_name, site_id) else: fabric_id = self.get_fabric_zone_id(site_name, site_id) - fabric_vlan_in_ccc = self.get_fabric_vlan_details(vlan_name, vlan_id, fabric_id) + fabric_vlan_in_ccc = self.get_fabric_vlan_details( + vlan_name, vlan_id, fabric_id) if not fabric_vlan_in_ccc: verify_vlan_list.append(vlan_name) else: @@ -3309,13 +3574,17 @@ def verify_anycast_gateways_deletion(self, anycast_gateways): for anycast in anycast_gateways: vn_name = anycast.get("vn_name") ip_pool_name = anycast.get("ip_pool_name") - site_name = anycast.get("fabric_site_location").get("site_name_hierarchy") + site_name = anycast.get("fabric_site_location").get( + "site_name_hierarchy") site_exists, site_id = self.get_site_id(site_name) if not site_exists: - self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Given site '{0}' does not exist in the Catalyst Center.".format( + site_name) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() - fabric_type = anycast.get("fabric_site_location").get("fabric_type") + fabric_type = anycast.get( + "fabric_site_location").get("fabric_type") if fabric_type == "fabric_site": fabric_id = self.get_fabric_site_id(site_name, site_id) @@ -3324,7 +3593,8 @@ def verify_anycast_gateways_deletion(self, anycast_gateways): # Collect the gateway id with combination of vn_name, ip_pool_name and fabric id unique_anycast = vn_name + "_" + ip_pool_name + "_" + site_name - anycast_details_in_ccc = self.get_anycast_gateway_details(vn_name, ip_pool_name, fabric_id) + anycast_details_in_ccc = self.get_anycast_gateway_details( + vn_name, ip_pool_name, fabric_id) if not anycast_details_in_ccc: verify_anycast_list.append(unique_anycast) @@ -3374,19 +3644,23 @@ def get_diff_merged(self, config): # Create/Update fabric Vlan in Cisco Catalyst Center fabric_vlan_details = config.get('fabric_vlan') if fabric_vlan_details: - self.process_fabric_vlans(fabric_vlan_details).check_return_status() + self.process_fabric_vlans( + fabric_vlan_details).check_return_status() # Create/Update virtual network in Cisco Catalyst Center virtual_networks = config.get('virtual_networks') if virtual_networks: - self.process_virtual_networks(virtual_networks).check_return_status() + self.process_virtual_networks( + virtual_networks).check_return_status() # Create/Update Anycast gateway in Cisco Catalyst Center with fabric id, ip pool and vn name anycast_gateways = config.get("anycast_gateways") if anycast_gateways: - self.process_anycast_gateways(anycast_gateways).check_return_status() + self.process_anycast_gateways( + anycast_gateways).check_return_status() - self.log("Completed the creation/updation process for specified items.", "INFO") + self.log( + "Completed the creation/updation process for specified items.", "INFO") return self @@ -3471,14 +3745,16 @@ def verify_diff_merged(self, config): if virtual_networks: self.verify_virtual_network(virtual_networks) else: - self.log("No layer3 Virtual Network details provided for verification.", "DEBUG") + self.log( + "No layer3 Virtual Network details provided for verification.", "DEBUG") # Verify the creation/updation of Anycast gateway in the Cisco Catalyst Center with fabric id, ip pool and vn name anycast_gateways = config.get("anycast_gateways") if anycast_gateways: self.verify_anycast_gateway(anycast_gateways) else: - self.log("No Anycast Gateway details provided for verification.", "DEBUG") + self.log( + "No Anycast Gateway details provided for verification.", "DEBUG") return self @@ -3512,14 +3788,16 @@ def verify_diff_deleted(self, config): if virtual_network_details: self.verify_virtual_network_deletion(virtual_network_details) else: - self.log("No layer3 Virtual Network details provided for verification.", "DEBUG") + self.log( + "No layer3 Virtual Network details provided for verification.", "DEBUG") # Verify the deletion of Anycast gateway from the Cisco Catalyst Center anycast_gateways = config.get("anycast_gateways") if anycast_gateways: self.verify_anycast_gateways_deletion(anycast_gateways) else: - self.log("No Anycast Gateway details provided for verification.", "DEBUG") + self.log( + "No Anycast Gateway details provided for verification.", "DEBUG") return self @@ -3560,7 +3838,8 @@ def main(): "Fabric VLAN, Virtual Networks and Anycast Gateways." .format(ccc_virtual_network.get_ccc_version()) ) - ccc_virtual_network.set_operation_result("failed", False, ccc_virtual_network.msg, "ERROR").check_return_status() + ccc_virtual_network.set_operation_result( + "failed", False, ccc_virtual_network.msg, "ERROR").check_return_status() state = ccc_virtual_network.params.get("state") @@ -3579,9 +3858,11 @@ def main(): ccc_virtual_network.reset_values() ccc_virtual_network.get_want(config).check_return_status() ccc_virtual_network.get_have(config).check_return_status() - ccc_virtual_network.get_diff_state_apply[state](config).check_return_status() + ccc_virtual_network.get_diff_state_apply[state]( + config).check_return_status() if config_verify: - ccc_virtual_network.verify_diff_state_apply[state](config).check_return_status() + ccc_virtual_network.verify_diff_state_apply[state]( + config).check_return_status() # Invoke the API to check status and log the output of each fabric VLAN, virtual network, and # anycast gateways update on the console. diff --git a/plugins/modules/sda_host_port_onboarding_workflow_manager.py b/plugins/modules/sda_host_port_onboarding_workflow_manager.py index 27a4ce8cf8..19d3cc37e7 100644 --- a/plugins/modules/sda_host_port_onboarding_workflow_manager.py +++ b/plugins/modules/sda_host_port_onboarding_workflow_manager.py @@ -5,6 +5,11 @@ """Ansible module to manage SD-Access Host Onboarding operations in Cisco Catalyst Center.""" from __future__ import absolute_import, division, print_function +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts +) +from ansible.module_utils.basic import AnsibleModule __metaclass__ = type __author__ = ("Rugvedi Kapse, Madhan Sankaranarayanan") @@ -510,17 +515,12 @@ } """ -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts -) - class SDAHostPortOnboarding(DnacBase): """ A class for managing Extranet Policies within the Cisco DNA Center using the SDA API. """ + def __init__(self, module): """ Initialize an instance of the class. @@ -592,13 +592,15 @@ def validate_input(self): ) if invalid_params: - self.msg = "Invalid parameters in playbook: {0}".format(invalid_params) + self.msg = "Invalid parameters in playbook: {0}".format( + invalid_params) self.set_operation_result("failed", False, self.msg, "ERROR") return self # Set the validated configuration and update the result with success status self.validated_config = valid_temp - self.msg = "Successfully validated playbook configuration parameters using 'validated_input': {0}".format(str(valid_temp)) + self.msg = "Successfully validated playbook configuration parameters using 'validated_input': {0}".format( + str(valid_temp)) self.set_operation_result("success", False, self.msg, "INFO") return self @@ -618,16 +620,19 @@ def validate_ip_and_hostname(self, ip_address, hostname): if the provided IP address is a valid IPv4 address. If the IP address is invalid, it logs an error message and sets the validation status to "failed". """ - self.log("Validating IP address: '{0}' and hostname: '{1}'".format(ip_address, hostname), "DEBUG") + self.log("Validating IP address: '{0}' and hostname: '{1}'".format( + ip_address, hostname), "DEBUG") # Check if both IP address and hostname are not provided if not ip_address and not hostname: - self.msg = "Provided IP address: {0}, hostname: {1}. Either an IP address or a hostname is required.".format(ip_address, hostname) + self.msg = "Provided IP address: {0}, hostname: {1}. Either an IP address or a hostname is required.".format( + ip_address, hostname) self.fail_and_exit(self.msg) # Check if an IP address is provided but it is not valid if ip_address and not self.is_valid_ipv4(ip_address): - self.msg = "IP address: {0} is not a valid IP Address.".format(ip_address) + self.msg = "IP address: {0} is not a valid IP Address.".format( + ip_address) self.fail_and_exit(self.msg) self.log("Validation successful: Provided IP address or hostname are valid") @@ -648,7 +653,8 @@ def validate_port_assignment_params(self, interface_name, connected_device_type) These parameters are essential for Add/Update Port Assignment operations. """ # Check if either interface_name or connected_device_type is not provided - self.log("Validating if required parameters 'interface_name' and 'connected_device_type' are provided", "DEBUG") + self.log( + "Validating if required parameters 'interface_name' and 'connected_device_type' are provided", "DEBUG") if not interface_name or not connected_device_type: self.msg = ( @@ -674,7 +680,8 @@ def validate_port_assignment_connected_device_type(self, interface_name, connect for port assignments. If the type is invalid, it logs an error message and sets the validation status to "failed". If the type is valid, it logs a success message. """ - self.log("Validating connected device type: '{0}' for interface: '{1}'".format(connected_device_type, interface_name), "DEBUG") + self.log("Validating connected device type: '{0}' for interface: '{1}'".format( + connected_device_type, interface_name), "DEBUG") # List of valid connected device types valid_device_types = ["USER_DEVICE", "ACCESS_POINT", "TRUNKING_DEVICE"] @@ -689,7 +696,8 @@ def validate_port_assignment_connected_device_type(self, interface_name, connect self.fail_and_exit(self.msg) # Log a success message indicating the connected device type is valid - self.log("Interface {0}: Successfully validated the connected device type: {1}".format(interface_name, connected_device_type), "DEBUG") + self.log("Interface {0}: Successfully validated the connected device type: {1}".format( + interface_name, connected_device_type), "DEBUG") def validate_interface_authentication_template(self, interface_name, authentication_template_name): """ @@ -706,10 +714,12 @@ def validate_interface_authentication_template(self, interface_name, authenticat templates for the interface. If the template name is invalid, it logs an error message and sets the validation status to "failed". If the template name is valid, it logs a success message. """ - self.log("Validating authentication template: '{0}' for interface: '{1}'".format(authentication_template_name, interface_name), "DEBUG") + self.log("Validating authentication template: '{0}' for interface: '{1}'".format( + authentication_template_name, interface_name), "DEBUG") # List of valid authentication template names - valid_template_names = ["No Authentication", "Open Authentication", "Closed Authentication", "Low Impact"] + valid_template_names = [ + "No Authentication", "Open Authentication", "Closed Authentication", "Low Impact"] # Check if the authentication template name is valid if authentication_template_name not in valid_template_names: @@ -719,7 +729,8 @@ def validate_interface_authentication_template(self, interface_name, authenticat self.fail_and_exit(self.msg) # Log a success message indicating the authentication template name is valid - self.log("Interface {0}: Successfully validated the authentication template: {1}".format(interface_name, authentication_template_name), "DEBUG") + self.log("Interface {0}: Successfully validated the authentication template: {1}".format( + interface_name, authentication_template_name), "DEBUG") def validate_trunking_device_assignment_params(self, port_assignment): """ @@ -740,9 +751,11 @@ def validate_trunking_device_assignment_params(self, port_assignment): interface_name = port_assignment.get("interface_name") connected_device_type = port_assignment.get("connected_device_type") - authentication_template_name = port_assignment.get("authentication_template_name") + authentication_template_name = port_assignment.get( + "authentication_template_name") - self.log("Interface {0}: Starting validation for device type 'TRUNKING_DEVICE'.".format(interface_name), "DEBUG") + self.log("Interface {0}: Starting validation for device type 'TRUNKING_DEVICE'.".format( + interface_name), "DEBUG") # Check if authentication_template_name is set and not equal to 'No Authentication if authentication_template_name and authentication_template_name != "No Authentication": @@ -753,7 +766,8 @@ def validate_trunking_device_assignment_params(self, port_assignment): self.fail_and_exit(self.msg) # Check if any parameters provided in the port_assignment dictionary are not from the valid parameters - valid_params = {"interface_name", "connected_device_type", "authentication_template_name", "interface_description"} + valid_params = {"interface_name", "connected_device_type", + "authentication_template_name", "interface_description"} provided_params = set(port_assignment.keys()) invalid_params = provided_params - valid_params @@ -765,7 +779,8 @@ def validate_trunking_device_assignment_params(self, port_assignment): ).format(interface_name, invalid_params_str) self.fail_and_exit(self.msg) - self.log("Interface {0}: All provided parameters for 'TRUNKING_DEVICE' are valid".format(interface_name), "DEBUG") + self.log("Interface {0}: All provided parameters for 'TRUNKING_DEVICE' are valid".format( + interface_name), "DEBUG") def validate_user_device_params(self, port_assignment): """ @@ -784,13 +799,15 @@ def validate_user_device_params(self, port_assignment): """ # Retrieve specific parameters from the port_assignment dictionary interface_name = port_assignment.get("interface_name") - authentication_template_name = port_assignment.get("authentication_template_name") + authentication_template_name = port_assignment.get( + "authentication_template_name") connected_device_type = port_assignment.get("connected_device_type") security_group_name = port_assignment.get("security_group_name") data_vlan_name = port_assignment.get("data_vlan_name") voice_vlan_name = port_assignment.get("voice_vlan_name") - self.log("Interface {0}: Starting validation for device type 'USER_DEVICE'.".format(interface_name), "DEBUG") + self.log("Interface {0}: Starting validation for device type 'USER_DEVICE'.".format( + interface_name), "DEBUG") valid_params = { "interface_name", @@ -821,16 +838,19 @@ def validate_user_device_params(self, port_assignment): "Closed Authentication. Provided data_vlan_name: {3}, voice_vlan_name: {4}." ).format(interface_name, connected_device_type, "data_vlan_name OR voice_vlan_name", data_vlan_name, voice_vlan_name) self.fail_and_exit(self.msg) - self.log("Interface {0}: VLAN validation for 'USER_DEVICE' passed.".format(interface_name), "DEBUG") + self.log("Interface {0}: VLAN validation for 'USER_DEVICE' passed.".format( + interface_name), "DEBUG") # Check if security_group_name is provided and authentication_template_name is not "No Authentication" if security_group_name and authentication_template_name and authentication_template_name != "No Authentication": self.msg = ("Interface {0}: For Device Type - {1}, if security_group_name is provided, " "the authentication_template_name must be 'No Authentication'.".format(interface_name, connected_device_type)) self.fail_and_exit(self.msg) - self.log("Interface {0}: Security group name validation for 'USER_DEVICE' passed.".format(interface_name), "DEBUG") + self.log("Interface {0}: Security group name validation for 'USER_DEVICE' passed.".format( + interface_name), "DEBUG") - self.log("Interface {0}: All provided parameters for 'USER_DEVICE' are valid".format(interface_name), "DEBUG") + self.log("Interface {0}: All provided parameters for 'USER_DEVICE' are valid".format( + interface_name), "DEBUG") def validate_access_point_params(self, port_assignment): """ @@ -852,7 +872,8 @@ def validate_access_point_params(self, port_assignment): connected_device_type = port_assignment.get("connected_device_type") required_param = "data_vlan_name" - self.log("Interface {0}: Starting validation for device type 'ACCESS_POINT'.".format(interface_name), "DEBUG") + self.log("Interface {0}: Starting validation for device type 'ACCESS_POINT'.".format( + interface_name), "DEBUG") # Check if the required parameter is present in port_assignment dictionary for a ACCESS_POINT if required_param not in port_assignment: @@ -860,10 +881,12 @@ def validate_access_point_params(self, port_assignment): "Parameter required for onboarding device type {2} is '{1}'").format( interface_name, required_param, connected_device_type) self.fail_and_exit(self.msg) - self.log("Interface {0}: Required parameter '{1}' is present.".format(interface_name, required_param), "DEBUG") + self.log("Interface {0}: Required parameter '{1}' is present.".format( + interface_name, required_param), "DEBUG") # Check if any parameters provided in the port_assignment dictionary are not from the valid parameters - valid_params = {"interface_name", "connected_device_type", "authentication_template_name", "data_vlan_name", "interface_description"} + valid_params = {"interface_name", "connected_device_type", + "authentication_template_name", "data_vlan_name", "interface_description"} provided_params = set(port_assignment.keys()) invalid_params = provided_params - valid_params @@ -875,7 +898,8 @@ def validate_access_point_params(self, port_assignment): ).format(interface_name, invalid_params_str, valid_params) self.fail_and_exit(self.msg) - self.log("Interface {0}: All provided parameters for 'ACCESS_POINT' are valid".format(interface_name), "DEBUG") + self.log("Interface {0}: All provided parameters for 'ACCESS_POINT' are valid".format( + interface_name), "DEBUG") def validate_device_specific_params(self, port_assignment): """ @@ -894,14 +918,17 @@ def validate_device_specific_params(self, port_assignment): If all parameters are valid, it logs a success message. """ # Retrieve required parameters from the port_assignment dictionary - authentication_template_name = port_assignment.get("authentication_template_name") + authentication_template_name = port_assignment.get( + "authentication_template_name") connected_device_type = port_assignment.get("connected_device_type") connected_device_type_upper = connected_device_type.upper() # Validate authentication_template_name if it is provided if authentication_template_name: - self.log("Validating authentication template: '{0}' for interface.".format(authentication_template_name), "DEBUG") - self.validate_interface_authentication_template(port_assignment.get("interface_name"), authentication_template_name) + self.log("Validating authentication template: '{0}' for interface.".format( + authentication_template_name), "DEBUG") + self.validate_interface_authentication_template( + port_assignment.get("interface_name"), authentication_template_name) # Call the validation method for trunking device parameters if connected_device_type_upper == "TRUNKING_DEVICE": @@ -918,7 +945,8 @@ def validate_device_specific_params(self, port_assignment): self.log("Calling access point parameter validation.", "DEBUG") self.validate_access_point_params(port_assignment) - self.log("Finished validation for device type '{0}'.".format(connected_device_type), "DEBUG") + self.log("Finished validation for device type '{0}'.".format( + connected_device_type), "DEBUG") def validate_port_channel_params(self, port_channel): """ @@ -939,7 +967,8 @@ def validate_port_channel_params(self, port_channel): self.log("Starting validation for port channel parameters.", "DEBUG") required_params = ["interface_names", "connected_device_type"] - missing_params = [param for param in required_params if param not in port_channel.keys()] + missing_params = [ + param for param in required_params if param not in port_channel.keys()] if missing_params: self.msg = ("The following required parameters for add/update port channel operations are missing: {0}. " @@ -969,14 +998,16 @@ def validate_port_channel_connected_device_type(self, port_channel): self.log("Validating connected device type for port channel.", "DEBUG") if connected_device_type and connected_device_type.upper() not in valid_connected_device_types: - valid_connected_device_types_str = ", ".join(valid_connected_device_types) + valid_connected_device_types_str = ", ".join( + valid_connected_device_types) self.msg = ( "Provided connected_device_type: '{0}' is not valid for Port Channel operation: {1}. " "Valid connected_device_types for Port Channel operations are: {2}" ).format(connected_device_type, port_channel, valid_connected_device_types_str) self.fail_and_exit(self.msg) - self.log("Port channel connected device type validated successfully.", "DEBUG") + self.log( + "Port channel connected device type validated successfully.", "DEBUG") def validate_port_channel_protocol(self, port_channel): """ @@ -1007,7 +1038,8 @@ def validate_port_channel_protocol(self, port_channel): # Check if the protocol is present and is not a boolean if protocol and not isinstance(protocol, bool): protocol_upper = protocol.upper() - self.log("Validating protocol: {0} and connected_device_type: {1}".format(protocol_upper, connected_device_type), "DEBUG") + self.log("Validating protocol: {0} and connected_device_type: {1}".format( + protocol_upper, connected_device_type), "DEBUG") # Check if protocol is valid for the connected device type device_valid_protocols = valid_protocols[connected_device_type] @@ -1019,7 +1051,8 @@ def validate_port_channel_protocol(self, port_channel): ).format(protocol, connected_device_type, port_channel, valid_protocols_str) self.fail_and_exit(self.msg) - self.log("Port channel protocol validated successfully for connected_device_type: {0}".format(connected_device_type), "DEBUG") + self.log("Port channel protocol validated successfully for connected_device_type: {0}".format( + connected_device_type), "DEBUG") def validate_port_channel_interfaces(self, port_channel): """ @@ -1043,7 +1076,8 @@ def validate_port_channel_interfaces(self, port_channel): protocol = self.update_protocol(protocol, connected_device_type) - self.log("Validating 'interface_names' list for protocol: {0} in port channel.".format(protocol), "DEBUG") + self.log("Validating 'interface_names' list for protocol: {0} in port channel.".format( + protocol), "DEBUG") # Define protocol-specific interface limits protocol_limits = { @@ -1064,7 +1098,8 @@ def validate_port_channel_interfaces(self, port_channel): ).format(len(interface_names_list), protocol, max_interfaces, port_channel) self.fail_and_exit(self.msg) - self.log("Port channel 'interfaces_names' size validated successfully for protocol: {0}".format(protocol), "DEBUG") + self.log("Port channel 'interfaces_names' size validated successfully for protocol: {0}".format( + protocol), "DEBUG") def validate_port_assignment_deletion_params(self, interface): """ @@ -1080,10 +1115,12 @@ def validate_port_assignment_deletion_params(self, interface): present in the provided interface dictionary. If unsupported parameters are found, it logs an error message and sets the validation status to "failed". If all parameters are valid, the method logs a success message. """ - self.log("Starting validation for delete port assignments parameters: {0}".format(interface), "INFO") + self.log("Starting validation for delete port assignments parameters: {0}".format( + interface), "INFO") # Define allowed parameters - allowed_params = {"interface_name", "data_vlan_name", "voice_vlan_name"} + allowed_params = {"interface_name", + "data_vlan_name", "voice_vlan_name"} # Get the set of keys in the provided interface dictionary provided_params = interface.keys() @@ -1100,7 +1137,8 @@ def validate_port_assignment_deletion_params(self, interface): ).format(unsupported_params, allowed_params, interface) self.fail_and_exit(self.msg) - self.log("All provided parameters for DELETE port_assignment(s) operation are valid: {0}".format(provided_params), "INFO") + self.log("All provided parameters for DELETE port_assignment(s) operation are valid: {0}".format( + provided_params), "INFO") def validate_port_channel_deletion_params(self, port_channel): """ @@ -1116,7 +1154,8 @@ def validate_port_channel_deletion_params(self, port_channel): the provided port channel dictionary. If unsupported parameters are found, it logs an error message and sets the validation status to "failed". If all parameters are valid, the method logs a success message. """ - self.log("Starting validation for delete port channels parameters: {0}".format(port_channel), "INFO") + self.log("Starting validation for delete port channels parameters: {0}".format( + port_channel), "INFO") # Define allowed parameters allowed_params = {"port_channel_name", "connected_device_type"} @@ -1137,7 +1176,8 @@ def validate_port_channel_deletion_params(self, port_channel): self.fail_and_exit(self.msg) # If only allowed parameters are present, validation passes - self.log("All provided parameters for DELETE port_channel(s) operation are valid: {0}".format(port_channel), "INFO") + self.log("All provided parameters for DELETE port_channel(s) operation are valid: {0}".format( + port_channel), "INFO") def validate_params(self, config, state): """ @@ -1170,18 +1210,24 @@ def validate_params(self, config, state): if port_assignment_details: for interface in port_assignment_details: interface_name = interface.get("interface_name") - connected_device_type = interface.get("connected_device_type") - self.log("Validating port assignment params for interface: {0}, device type: {1}".format(interface_name, connected_device_type), "INFO") - self.validate_port_assignment_params(interface_name, connected_device_type) - self.validate_port_assignment_connected_device_type(interface_name, connected_device_type) + connected_device_type = interface.get( + "connected_device_type") + self.log("Validating port assignment params for interface: {0}, device type: {1}".format( + interface_name, connected_device_type), "INFO") + self.validate_port_assignment_params( + interface_name, connected_device_type) + self.validate_port_assignment_connected_device_type( + interface_name, connected_device_type) self.validate_device_specific_params(interface) # Validate parameters for add/update in port channels if port_channel_details: for port_channel in port_channel_details: - self.log("Validating port channel params for port_channel: {0}".format(port_channel), "INFO") + self.log("Validating port channel params for port_channel: {0}".format( + port_channel), "INFO") self.validate_port_channel_params(port_channel) - self.validate_port_channel_connected_device_type(port_channel) + self.validate_port_channel_connected_device_type( + port_channel) self.validate_port_channel_protocol(port_channel) self.validate_port_channel_interfaces(port_channel) @@ -1189,16 +1235,19 @@ def validate_params(self, config, state): # Validate parameters for deletion in port assignments if port_assignment_details: for interface in port_assignment_details: - self.log("Validating deletion of port assignment params for interface: {0}".format(interface), "INFO") + self.log("Validating deletion of port assignment params for interface: {0}".format( + interface), "INFO") self.validate_port_assignment_deletion_params(interface) # Validate parameters for deletion in port channels if port_channel_details: for port_channel in port_channel_details: - self.log("Validating deletion of port channel details for port_channel: {0}".format(port_channel), "INFO") + self.log("Validating deletion of port channel details for port_channel: {0}".format( + port_channel), "INFO") self.validate_port_channel_deletion_params(port_channel) - self.log("Validation completed for configuration: {0} with state: {1}".format(config, state), "INFO") + self.log("Validation completed for configuration: {0} with state: {1}".format( + config, state), "INFO") def get_device_list_params(self, ip_address, hostname): """ @@ -1239,7 +1288,8 @@ def get_device_ids_by_params(self, get_device_list_params): """ # Initialize the dictionary to map management IP to instance ID mgmt_ip_to_instance_id_map = {} - self.log("Parameters for 'get_device_list API call: {0}".format(get_device_list_params), "DEBUG") + self.log("Parameters for 'get_device_list API call: {0}".format( + get_device_list_params), "DEBUG") try: # Query Cisco Catalyst Center for device information using the parameters response = self.dnac._exec( @@ -1248,12 +1298,14 @@ def get_device_ids_by_params(self, get_device_list_params): op_modifies=False, params=get_device_list_params ) - self.log("Response received from 'get_device_list' API call: {0}".format(str(response)), "DEBUG") + self.log("Response received from 'get_device_list' API call: {0}".format( + str(response)), "DEBUG") response = response.get("response") # Check if a valid response is received if not response: - self.log("No devices were returned for the given parameters: {0}".format(get_device_list_params), "ERROR") + self.log("No devices were returned for the given parameters: {0}".format( + get_device_list_params), "ERROR") return mgmt_ip_to_instance_id_map # Get the device information from the response @@ -1266,9 +1318,11 @@ def get_device_ids_by_params(self, get_device_list_params): device_info.get("family") != "Unified AP"): device_id = device_info["id"] mgmt_ip_to_instance_id_map[device_ip] = device_id - self.log("Device {0} is valid and added to the map.".format(device_ip), "INFO") + self.log("Device {0} is valid and added to the map.".format( + device_ip), "INFO") else: - self.log("Device {0} is not valid (either unreachable, not managed, or a Unified AP).".format(device_ip), "ERROR") + self.log("Device {0} is not valid (either unreachable, not managed, or a Unified AP).".format( + device_ip), "ERROR") except Exception as e: # Log an error message if any exception occurs during the process @@ -1282,7 +1336,8 @@ def get_device_ids_by_params(self, get_device_list_params): self.msg = ( "Unable to retrieve details for the Device: {0}." ).format( - get_device_list_params.get("management_ip_address") or get_device_list_params.get("hostname") + get_device_list_params.get( + "management_ip_address") or get_device_list_params.get("hostname") ) self.fail_and_exit(self.msg) @@ -1310,13 +1365,15 @@ def get_device_info_from_sda_fabric(self, ip_address): op_modifies=False, params={"device_management_ip_address": ip_address}, ) - self.log("Response received post SDA - 'get_device_info' API call: {0}".format(str(response)), "DEBUG") + self.log( + "Response received post SDA - 'get_device_info' API call: {0}".format(str(response)), "DEBUG") # Process the response if available if response: site_name = response["siteNameHierarchy"] else: - self.log("No response received from the SDA - 'get_device_info' API call.", "WARNING") + self.log( + "No response received from the SDA - 'get_device_info' API call.", "WARNING") except Exception as e: # Log an error message and fail if an exception occurs @@ -1328,7 +1385,8 @@ def get_device_info_from_sda_fabric(self, ip_address): ) if not site_name: - self.msg = "Failed to retrieve site information for Device: '{0}'. Please verify that the device exists.".format(ip_address) + self.msg = "Failed to retrieve site information for Device: '{0}'. Please verify that the device exists.".format( + ip_address) self.fail_and_exit(self.msg) return site_name @@ -1353,11 +1411,13 @@ def get_fabric_sites(self, site_name, site_id): op_modifies=False, params={"siteId": site_id}, ) - self.log("Response received post SDA - 'get_fabric_sites' API call: {0}".format(str(response)), "DEBUG") + self.log( + "Response received post SDA - 'get_fabric_sites' API call: {0}".format(str(response)), "DEBUG") response = response.get("response") if not response: - self.log("No response received from the SDA - 'get_fabric_sites' API call.", "WARNING") + self.log( + "No response received from the SDA - 'get_fabric_sites' API call.", "WARNING") return None fabric_id = response[0]["id"] @@ -1387,11 +1447,14 @@ def get_network_fabric_id(self, ip_address, hostname): obtains the fabric ID of the site. The method logs relevant information and returns the instance ID map and the fabric ID. """ - get_device_list_params = self.get_device_list_params(ip_address, hostname) + get_device_list_params = self.get_device_list_params( + ip_address, hostname) # Get Device IP Address and Id (networkDeviceId required) - mgmt_ip_to_instance_id_map = self.get_device_ids_by_params(get_device_list_params) - self.log("Collected mgmt_ip_to_instance_id_map: {0}".format(mgmt_ip_to_instance_id_map), "DEBUG") + mgmt_ip_to_instance_id_map = self.get_device_ids_by_params( + get_device_list_params) + self.log("Collected mgmt_ip_to_instance_id_map: {0}".format( + mgmt_ip_to_instance_id_map), "DEBUG") # Get the Site Name the device is part of. device_ip = list(mgmt_ip_to_instance_id_map.keys())[0] @@ -1406,7 +1469,8 @@ def get_network_fabric_id(self, ip_address, hostname): # Get fabricId of the site fabric_id = self.get_fabric_sites(site_name, site_id) if not fabric_id: - self.msg = "Fabric ID not found for Site: {0} with Site ID: {1}".format(site_name, site_id) + self.msg = "Fabric ID not found for Site: {0} with Site ID: {1}".format( + site_name, site_id) self.fail_and_exit(self.msg) return mgmt_ip_to_instance_id_map, fabric_id @@ -1430,7 +1494,8 @@ def get_port_assignments_params(self, network_device_id, fabric_id): "network_device_id": network_device_id, } - self.log("Generated get_port_assignments_params: {0}".format(get_port_assignment_params), "DEBUG") + self.log("Generated get_port_assignments_params: {0}".format( + get_port_assignment_params), "DEBUG") return get_port_assignment_params @@ -1460,7 +1525,8 @@ def get_port_assignments(self, get_port_assignments_params): "limit": limit }) - self.log("Updated 'get_port_assignments_params' with offset and limit: {0} ".format(get_port_assignments_params), "INFO") + self.log("Updated 'get_port_assignments_params' with offset and limit: {0} ".format( + get_port_assignments_params), "INFO") # Execute the API call to get extranet policie response = self.dnac._exec( @@ -1486,12 +1552,14 @@ def get_port_assignments(self, get_port_assignments_params): except Exception as e: self.msg = ( "An error occurred during iteration while retrieving Port Assignment Details: '{0}' using SDA - " - "'get_port_assignments' API call: {1}".format(get_port_assignments_params, str(e)) + "'get_port_assignments' API call: {1}".format( + get_port_assignments_params, str(e)) ) self.fail_and_exit(self.msg) if port_assignments: - self.log("Port Assignment Details: {0}".format(port_assignments), "DEBUG") + self.log("Port Assignment Details: {0}".format( + port_assignments), "DEBUG") else: self.log("No port assignments found.", "DEBUG") @@ -1501,7 +1569,8 @@ def get_port_assignments(self, get_port_assignments_params): # Log an error message and fail if an exception occurs self.msg = ( "An error occurred while retrieving Port Assignment Details: '{0}' using SDA - " - "'get_port_assignments' API call: {1}".format(get_port_assignments_params, str(e)) + "'get_port_assignments' API call: {1}".format( + get_port_assignments_params, str(e)) ) self.fail_and_exit(self.msg) @@ -1564,20 +1633,25 @@ def compare_port_assignments(self, get_port_assignments_params, requested_port_a port assignment details. It categorizes the port assignments into those that need to be created, updated, or do not require any updates. The method logs relevant information and returns the categorized lists. """ - existing_port_assignment_details = self.get_port_assignments(get_port_assignments_params) + existing_port_assignment_details = self.get_port_assignments( + get_port_assignments_params) - self.log("Existing Port assignments: {0}".format(existing_port_assignment_details), "DEBUG") - self.log("Requested Port assignments: {0}".format(requested_port_assignment_details), "DEBUG") + self.log("Existing Port assignments: {0}".format( + existing_port_assignment_details), "DEBUG") + self.log("Requested Port assignments: {0}".format( + requested_port_assignment_details), "DEBUG") create_port_assignments = [] update_port_assignments = [] no_update_port_assignments = [] # Convert the requested_port_assignment_details to a dictionary for quick lookup - requested_ports_dict = {port['interface_name']: port for port in requested_port_assignment_details} + requested_ports_dict = { + port['interface_name']: port for port in requested_port_assignment_details} if not existing_port_assignment_details: - self.log("Port assignments that need to be CREATED: {0} - {1}".format(len(create_port_assignments), create_port_assignments), "DEBUG") + self.log("Port assignments that need to be CREATED: {0} - {1}".format( + len(create_port_assignments), create_port_assignments), "DEBUG") create_port_assignments.extend(requested_ports_dict.values()) return create_port_assignments, update_port_assignments, no_update_port_assignments @@ -1590,7 +1664,8 @@ def compare_port_assignments(self, get_port_assignments_params, requested_port_a requested_port = requested_ports_dict[interface_name] # Check for differences using the new function - has_diff = self.check_differences(existing_port, requested_port) + has_diff = self.check_differences( + existing_port, requested_port) if has_diff: # Add the requested port with the id and relevant metadata from the existing port @@ -1609,16 +1684,22 @@ def compare_port_assignments(self, get_port_assignments_params, requested_port_a create_port_assignments.extend(requested_ports_dict.values()) # Log details of port assignments to be created, update, not updated - self.log("Port assignments that need to be CREATED: {0} - {1}".format(len(create_port_assignments), create_port_assignments), "DEBUG") - self.log("Port assignments that need to be UPDATED: {0} - {1}".format(len(update_port_assignments), update_port_assignments), "DEBUG") - self.log("Port assignments that DON'T NEED UPDATES: {0} - {1}".format(len(no_update_port_assignments), no_update_port_assignments), "DEBUG") + self.log("Port assignments that need to be CREATED: {0} - {1}".format( + len(create_port_assignments), create_port_assignments), "DEBUG") + self.log("Port assignments that need to be UPDATED: {0} - {1}".format( + len(update_port_assignments), update_port_assignments), "DEBUG") + self.log("Port assignments that DON'T NEED UPDATES: {0} - {1}".format( + len(no_update_port_assignments), no_update_port_assignments), "DEBUG") # Calculate total ports processed and check against requested port assignments - total_ports_processed = len(create_port_assignments) + len(update_port_assignments) + len(no_update_port_assignments) + total_ports_processed = len(create_port_assignments) + len( + update_port_assignments) + len(no_update_port_assignments) if total_ports_processed == len(requested_port_assignment_details): - self.log("Match in total counts: Processed={0}, Requested={1}.".format(total_ports_processed, len(requested_port_assignment_details)), "DEBUG") + self.log("Match in total counts: Processed={0}, Requested={1}.".format( + total_ports_processed, len(requested_port_assignment_details)), "DEBUG") else: - self.log("Mismatch in total counts: Processed={0}, Requested={1}.".format(total_ports_processed, len(requested_port_assignment_details)), "ERROR") + self.log("Mismatch in total counts: Processed={0}, Requested={1}.".format( + total_ports_processed, len(requested_port_assignment_details)), "ERROR") # Return the categorized port assignments return create_port_assignments, update_port_assignments, no_update_port_assignments @@ -1642,7 +1723,8 @@ def get_port_channels_params(self, network_device_id, fabric_id): "network_device_id": network_device_id, } - self.log("get_port_channels_params: {0}".format(get_port_channels_params), "DEBUG") + self.log("get_port_channels_params: {0}".format( + get_port_channels_params), "DEBUG") return get_port_channels_params def get_port_channels(self, get_port_channels_params): @@ -1695,12 +1777,14 @@ def get_port_channels(self, get_port_channels_params): except Exception as e: self.msg = ( "An error occurred during iteration while retrieving Port Channel Details: '{0}' using " - "SDA - 'get_port_channels' API call: {1}".format(get_port_channels_params, str(e)) + "SDA - 'get_port_channels' API call: {1}".format( + get_port_channels_params, str(e)) ) self.fail_and_exit(self.msg) if port_channels: - self.log("Port Channel Details: {0}".format(port_channels), "DEBUG") + self.log("Port Channel Details: {0}".format( + port_channels), "DEBUG") else: self.log("No port channels found.", "DEBUG") @@ -1710,7 +1794,8 @@ def get_port_channels(self, get_port_channels_params): # Log an error message and fail if an exception occurs self.msg = ( "An error occurred while retrieving Port Channel Details: '{0}' using SDA - " - "'get_port_channels' API call: {1}".format(get_port_channels_params, str(e)) + "'get_port_channels' API call: {1}".format( + get_port_channels_params, str(e)) ) self.fail_and_exit(self.msg) @@ -1744,7 +1829,8 @@ def get_add_port_assignments_params(self): "connectedDeviceType": interface.get("connected_device_type").upper(), } - self.log("Basic parameters for interface {0}: {1}".format(interface.get("interface_name"), interface_params), "DEBUG") + self.log("Basic parameters for interface {0}: {1}".format( + interface.get("interface_name"), interface_params), "DEBUG") # Iterate over the parameters and add them to the result dictionary if present in the config for parameter, parameter_name in parameter_mapping.items(): @@ -1755,10 +1841,12 @@ def get_add_port_assignments_params(self): if not interface.get("authentication_template_name"): interface_params["authenticateTemplateName"] = "No Authentication" interface_params_list.append(interface_params) - self.log("Generated parameters for interface: {0}".format(interface_params), "DEBUG") + self.log("Generated parameters for interface: {0}".format( + interface_params), "DEBUG") add_port_assignments_params = {"payload": interface_params_list} - self.log("Final add_port_assignments_params: {0}".format(add_port_assignments_params), "DEBUG") + self.log("Final add_port_assignments_params: {0}".format( + add_port_assignments_params), "DEBUG") return add_port_assignments_params def get_update_port_assignments_params(self): @@ -1771,7 +1859,8 @@ def get_update_port_assignments_params(self): interfaces to be updated. It maps the relevant fields from the configuration and constructs the payload for the API call. The method logs the generated parameters for debugging purposes and returns the dictionary. """ - self.log("Starting to generate parameters for updating port assignments.", "DEBUG") + self.log( + "Starting to generate parameters for updating port assignments.", "DEBUG") update_port_assignments = self.have.get("update_port_assignments") parameters_mapping = { @@ -1792,23 +1881,28 @@ def get_update_port_assignments_params(self): "connectedDeviceType": interface.get("connected_device_type").upper() } - self.log("Basic parameters for interface {0}: {1}".format(interface.get("interface_name"), interface_params), "DEBUG") + self.log("Basic parameters for interface {0}: {1}".format( + interface.get("interface_name"), interface_params), "DEBUG") # Iterate over the parameters and add them to the result dictionary if present in the config for parameter, parameter_name in parameters_mapping.items(): if interface.get(parameter_name): interface_params[parameter] = interface.get(parameter_name) - self.log("Updated parameters with VLAN and security info for interface {0}: {1}".format(interface.get("interface_name"), interface_params), "DEBUG") + self.log("Updated parameters with VLAN and security info for interface {0}: {1}".format( + interface.get("interface_name"), interface_params), "DEBUG") if interface.get("connected_device_type") == "TRUNKING_DEVICE": interface_params["authenticateTemplateName"] = "No Authentication" - self.log("TRUNKING_DEVICE detected for interface: {0}. Setting 'No Authentication'.".format(interface.get("interface_name")), "DEBUG") + self.log("TRUNKING_DEVICE detected for interface: {0}. Setting 'No Authentication'.".format( + interface.get("interface_name")), "DEBUG") interface_params_list.append(interface_params) - self.log("Generated parameters for interface: {0}".format(interface_params), "DEBUG") + self.log("Generated parameters for interface: {0}".format( + interface_params), "DEBUG") update_port_assignments_params = {"payload": interface_params_list} - self.log("Final update_port_assignments_params: {0}".format(update_port_assignments_params), "DEBUG") + self.log("Final update_port_assignments_params: {0}".format( + update_port_assignments_params), "DEBUG") return update_port_assignments_params def get_delete_port_assignments_params(self, port_assignment_details, network_device_id, fabric_id): @@ -1826,7 +1920,8 @@ def get_delete_port_assignments_params(self, port_assignment_details, network_de 'interface_name', 'data_vlan_name', and 'voice_vlan_name'. The method logs the generated parameters for debugging purposes and returns the list of dictionaries. """ - self.log("Generating parameters for deleting port assignments. Details: {0}".format(port_assignment_details), "DEBUG") + self.log("Generating parameters for deleting port assignments. Details: {0}".format( + port_assignment_details), "DEBUG") delete_port_assignments_params_list = [] for delete_param in port_assignment_details: @@ -1838,11 +1933,14 @@ def get_delete_port_assignments_params(self, port_assignment_details, network_de # Directly iterate over the keys of delete_param for parameter in ["interface_name", "data_vlan_name", "voice_vlan_name"]: if delete_param.get(parameter): - delete_port_assignments_params[parameter] = delete_param.get(parameter) + delete_port_assignments_params[parameter] = delete_param.get( + parameter) - delete_port_assignments_params_list.append(delete_port_assignments_params) + delete_port_assignments_params_list.append( + delete_port_assignments_params) - self.log("Generated delete_port_assignments_params_list: {0}".format(delete_port_assignments_params_list), "DEBUG") + self.log("Generated delete_port_assignments_params_list: {0}".format( + delete_port_assignments_params_list), "DEBUG") return delete_port_assignments_params_list def compare_port_channels(self, get_port_channels_params, requested_port_channels_details): @@ -1861,10 +1959,13 @@ def compare_port_channels(self, get_port_channels_params, requested_port_channel port channel details. It categorizes the port channels into those that need to be created, updated, or do not require any updates. The method logs relevant information and returns the categorized lists. """ - existing_port_channel_details = self.get_port_channels(get_port_channels_params) + existing_port_channel_details = self.get_port_channels( + get_port_channels_params) - self.log("Existing Port Channels: {0}".format(existing_port_channel_details), "DEBUG") - self.log("Requested Port Channels: {0}".format(requested_port_channels_details), "DEBUG") + self.log("Existing Port Channels: {0}".format( + existing_port_channel_details), "DEBUG") + self.log("Requested Port Channels: {0}".format( + requested_port_channels_details), "DEBUG") create_port_channels = [] update_port_channels = [] @@ -1873,8 +1974,10 @@ def compare_port_channels(self, get_port_channels_params, requested_port_channel # Handle the case where there are no existing port channels if not existing_port_channel_details: create_port_channels = requested_port_channels_details - self.log("No existing port channels found. All requested port channels will be created.", "INFO") - self.log("Port channels that need to be CREATED: {0} - {1}".format(len(create_port_channels), create_port_channels), "DEBUG") + self.log( + "No existing port channels found. All requested port channels will be created.", "INFO") + self.log("Port channels that need to be CREATED: {0} - {1}".format( + len(create_port_channels), create_port_channels), "DEBUG") return create_port_channels, update_port_channels, no_update_port_channels # Define the comparison fields within the function @@ -1893,7 +1996,8 @@ def compare_port_channels(self, get_port_channels_params, requested_port_channel if set(requested_channel["interface_names"]) == set(existing_channel["interfaceNames"]): matched = True update_needed = False - updated_channel = {"id": existing_channel["id"], "port_channel_name": existing_channel["portChannelName"]} + updated_channel = { + "id": existing_channel["id"], "port_channel_name": existing_channel["portChannelName"]} for req_field, existing_field in comparison_fields: req_value = requested_channel.get(existing_field) @@ -1931,7 +2035,8 @@ def compare_port_channels(self, get_port_channels_params, requested_port_channel "Port Channel: {0} Cannot change connected_device_type from TRUNK to EXTENDED_NODE unless protocol is PAGP. " "Requested: {1}, Existing: {2}, Protocol: {3}" ).format( - existing_channel["portChannelName"], req_value, existing_value, existing_channel.get("protocol") + existing_channel["portChannelName"], req_value, existing_value, existing_channel.get( + "protocol") ) self.fail_and_exit(self.msg) @@ -1940,7 +2045,8 @@ def compare_port_channels(self, get_port_channels_params, requested_port_channel continue if req_value != existing_value: - self.log("Update needed for {0} - Requested: {1}, Existing: {2}".format(req_field, req_value, existing_value), "DEBUG") + self.log("Update needed for {0} - Requested: {1}, Existing: {2}".format( + req_field, req_value, existing_value), "DEBUG") updated_channel[existing_field] = req_value update_needed = True @@ -1963,16 +2069,22 @@ def compare_port_channels(self, get_port_channels_params, requested_port_channel create_port_channels.append(requested_channel) # Add logging for created, updated, and no-update port channels - self.log("Port channels that need to be CREATED: {0} - {1}".format(len(create_port_channels), create_port_channels), "DEBUG") - self.log("Port channels that need to be UPDATED: {0} - {1}".format(len(update_port_channels), update_port_channels), "DEBUG") - self.log("Port channels that DON'T NEED UPDATES: {0} - {1}".format(len(no_update_port_channels), no_update_port_channels), "DEBUG") + self.log("Port channels that need to be CREATED: {0} - {1}".format( + len(create_port_channels), create_port_channels), "DEBUG") + self.log("Port channels that need to be UPDATED: {0} - {1}".format( + len(update_port_channels), update_port_channels), "DEBUG") + self.log("Port channels that DON'T NEED UPDATES: {0} - {1}".format( + len(no_update_port_channels), no_update_port_channels), "DEBUG") # Check total ports processed - total_ports_processed = len(create_port_channels) + len(update_port_channels) + len(no_update_port_channels) + total_ports_processed = len( + create_port_channels) + len(update_port_channels) + len(no_update_port_channels) if total_ports_processed == len(requested_port_channels_details): - self.log("Match in total counts: Processed={0}, Requested={1}.".format(total_ports_processed, len(requested_port_channels_details)), "DEBUG") + self.log("Match in total counts: Processed={0}, Requested={1}.".format( + total_ports_processed, len(requested_port_channels_details)), "DEBUG") else: - self.log("Mismatch in total counts: Processed={0}, Requested={1}.".format(total_ports_processed, len(requested_port_channels_details)), "ERROR") + self.log("Mismatch in total counts: Processed={0}, Requested={1}.".format( + total_ports_processed, len(requested_port_channels_details)), "ERROR") # return the categorized port channels return create_port_channels, update_port_channels, no_update_port_channels @@ -1994,19 +2106,24 @@ def update_protocol(self, protocol, connected_device_type): if protocol: if protocol is True: protocol = "ON" - self.log("Protocol is set to True, updating 'protocol' to 'ON'.", "INFO") + self.log( + "Protocol is set to True, updating 'protocol' to 'ON'.", "INFO") else: - self.log("Protocol not provided, hence using default protocol values based on the 'connected_device_type'.", "INFO") - self.log("The default protocol for each 'connected_device_type': 'TRUNK' -> 'ON', 'EXTENDED_NODE' -> 'PAGP'", "INFO") + self.log( + "Protocol not provided, hence using default protocol values based on the 'connected_device_type'.", "INFO") + self.log( + "The default protocol for each 'connected_device_type': 'TRUNK' -> 'ON', 'EXTENDED_NODE' -> 'PAGP'", "INFO") # Default protocol for TRUNK -> "ON" if connected_device_type == "TRUNK": protocol = "ON" - self.log("Connected device type is 'TRUNK', setting protocol to 'ON'.", "INFO") + self.log( + "Connected device type is 'TRUNK', setting protocol to 'ON'.", "INFO") # Default protocol for EXTENDED_NODE -> "PAGP" elif connected_device_type == "EXTENDED_NODE": protocol = "PAGP" - self.log("Connected device type is 'EXTENDED_NODE', setting protocol to 'PAGP'.", "INFO") + self.log( + "Connected device type is 'EXTENDED_NODE', setting protocol to 'PAGP'.", "INFO") updated_protocol = protocol.upper() self.log("Updated 'protocol' is: {0}".format(updated_protocol), "INFO") @@ -2030,7 +2147,8 @@ def get_add_port_channels_params(self): for port_channel in create_port_channels: protocol = port_channel.get("protocol") connected_device_type = port_channel.get("connected_device_type") - port_channel_description = port_channel.get("port_channel_description") + port_channel_description = port_channel.get( + "port_channel_description") # Construct the parameters for each port channel port_channel_params = { @@ -2046,11 +2164,13 @@ def get_add_port_channels_params(self): port_channel_params["description"] = port_channel_description port_channels_params_list.append(port_channel_params) - self.log("Constructed parameters for port channel: {0}".format(port_channel_params), "DEBUG") + self.log("Constructed parameters for port channel: {0}".format( + port_channel_params), "DEBUG") # Create the final payload for adding port channels add_port_channels_params = {"payload": port_channels_params_list} - self.log("Final add_port_channels_params: {0}".format(add_port_channels_params), "DEBUG") + self.log("Final add_port_channels_params: {0}".format( + add_port_channels_params), "DEBUG") return add_port_channels_params def get_update_port_channels_params(self): @@ -2070,7 +2190,8 @@ def get_update_port_channels_params(self): for port_channel in update_port_channels: protocol = port_channel.get("protocol") connected_device_type = port_channel.get("connected_device_type") - port_channel_description = port_channel.get("port_channel_description") + port_channel_description = port_channel.get( + "port_channel_description") # Construct the parameters for each port channel port_channel_params = { @@ -2088,11 +2209,13 @@ def get_update_port_channels_params(self): port_channel_params["description"] = port_channel_description port_channels_params_list.append(port_channel_params) - self.log("Constructed parameters for updating port channel: {0}".format(port_channel_params), "DEBUG") + self.log("Constructed parameters for updating port channel: {0}".format( + port_channel_params), "DEBUG") # Create the final payload for updating port channels update_port_channels_params = {"payload": port_channels_params_list} - self.log("Final update_port_channels_params: {0}".format(update_port_channels_params), "DEBUG") + self.log("Final update_port_channels_params: {0}".format( + update_port_channels_params), "DEBUG") return update_port_channels_params def get_delete_port_channels_params(self, port_channel_details, network_device_id, fabric_id): @@ -2122,11 +2245,14 @@ def get_delete_port_channels_params(self, port_channel_details, network_device_i # Add "port_channel_name" and "connected_device_type" if they exist in delete_param for parameter in ["port_channel_name", "connected_device_type"]: if delete_param.get(parameter): - delete_port_channels_params[parameter] = delete_param.get(parameter) + delete_port_channels_params[parameter] = delete_param.get( + parameter) - delete_port_channels_params_list.append(delete_port_channels_params) + delete_port_channels_params_list.append( + delete_port_channels_params) - self.log("Final delete_port_channels_params_list: {0}".format(delete_port_channels_params_list), "DEBUG") + self.log("Final delete_port_channels_params_list: {0}".format( + delete_port_channels_params_list), "DEBUG") return delete_port_channels_params_list @@ -2140,7 +2266,8 @@ def add_port_assignments(self, add_port_assignments_params): Description: This method initiates the task to add port assignments using the provided parameters and returns the task ID. """ - self.log("Initiating addition of port assignments with parameters: {0}".format(add_port_assignments_params), "INFO") + self.log("Initiating addition of port assignments with parameters: {0}".format( + add_port_assignments_params), "INFO") return self.get_taskid_post_api_call("sda", "add_port_assignments", add_port_assignments_params) def update_port_assignments(self, update_port_assignments_params): @@ -2153,7 +2280,8 @@ def update_port_assignments(self, update_port_assignments_params): Description: This method initiates the task to update port assignments using the provided parameters and returns the task ID. """ - self.log("Initiating update of port assignments with parameters: {0}".format(update_port_assignments_params), "INFO") + self.log("Initiating update of port assignments with parameters: {0}".format( + update_port_assignments_params), "INFO") return self.get_taskid_post_api_call("sda", "update_port_assignments", update_port_assignments_params) def verify_delete_port_assignments_requirement(self, delete_port_assignments_params_list): @@ -2171,16 +2299,20 @@ def verify_delete_port_assignments_requirement(self, delete_port_assignments_par results = {} for index, delete_port_assignment_param in enumerate(delete_port_assignments_params_list): - self.log("Verifying parameters at index {0}: {1}".format(index, delete_port_assignment_param), "DEBUG") + self.log("Verifying parameters at index {0}: {1}".format( + index, delete_port_assignment_param), "DEBUG") # Check if port assignments exist for the given parameters get_port_assignments_params = delete_port_assignment_param.copy() - port_assignments = self.get_port_assignments(get_port_assignments_params) - self.log("Existing Port assignments: {0}".format(port_assignments), "DEBUG") + port_assignments = self.get_port_assignments( + get_port_assignments_params) + self.log("Existing Port assignments: {0}".format( + port_assignments), "DEBUG") # Determine if deletion is required based on the existence of port assignments delete_required = bool(port_assignments) - interfaces_list = [port.get("interfaceName") for port in port_assignments] if port_assignments else [] + interfaces_list = [port.get( + "interfaceName") for port in port_assignments] if port_assignments else [] results[index] = { "delete_required": delete_required, @@ -2188,7 +2320,8 @@ def verify_delete_port_assignments_requirement(self, delete_port_assignments_par "interfaces_list": interfaces_list } - self.log("Result generated post verifying if delete port assignment is required: {0}".format(results), "DEBUG") + self.log("Result generated post verifying if delete port assignment is required: {0}".format( + results), "DEBUG") return results @@ -2202,7 +2335,8 @@ def delete_port_assignments(self, delete_port_assignments_params): Description: This method initiates the task to delete port assignments using the provided parameters and returns the task ID. """ - self.log("Initiating deletion of port assignments with parameters: {0}".format(delete_port_assignments_params), "INFO") + self.log("Initiating deletion of port assignments with parameters: {0}".format( + delete_port_assignments_params), "INFO") return self.get_taskid_post_api_call("sda", "delete_port_assignments", delete_port_assignments_params) def add_port_channels(self, add_port_channels_params): @@ -2215,7 +2349,8 @@ def add_port_channels(self, add_port_channels_params): Description: This method initiates the task to add port channels using the provided parameters and returns the task ID. """ - self.log("Initiating addition of port channels with parameters: {0}".format(add_port_channels_params), "INFO") + self.log("Initiating addition of port channels with parameters: {0}".format( + add_port_channels_params), "INFO") return self.get_taskid_post_api_call("sda", "add_port_channels", add_port_channels_params) def update_port_channels(self, update_port_channels_params): @@ -2228,7 +2363,8 @@ def update_port_channels(self, update_port_channels_params): Description: This method initiates the task to update port channels using the provided parameters and returns the task ID. """ - self.log("Initiating update of port channels with parameters: {0}".format(update_port_channels_params), "INFO") + self.log("Initiating update of port channels with parameters: {0}".format( + update_port_channels_params), "INFO") return self.get_taskid_post_api_call("sda", "update_port_channels", update_port_channels_params) def verify_delete_port_channels_requirement(self, delete_port_channels_params_list): @@ -2245,16 +2381,19 @@ def verify_delete_port_channels_requirement(self, delete_port_channels_params_li results = {} for index, delete_port_channels_param in enumerate(delete_port_channels_params_list): - self.log("Verifying parameters at index {0}: {1}".format(index, delete_port_channels_param), "DEBUG") + self.log("Verifying parameters at index {0}: {1}".format( + index, delete_port_channels_param), "DEBUG") # Check if port assignments exist for the given parameters get_port_channels_params = delete_port_channels_param.copy() port_channels = self.get_port_channels(get_port_channels_params) - self.log("Existing Port channels for index {0}: {1}".format(index, port_channels), "DEBUG") + self.log("Existing Port channels for index {0}: {1}".format( + index, port_channels), "DEBUG") # Determine if deletion is required based on the existence of port assignments delete_required = bool(port_channels) - port_channels_list = [port.get("portChannelName") for port in port_channels] if port_channels else [] + port_channels_list = [ + port.get("portChannelName") for port in port_channels] if port_channels else [] results[index] = { "delete_required": delete_required, @@ -2262,7 +2401,8 @@ def verify_delete_port_channels_requirement(self, delete_port_channels_params_li "port_channels_list": port_channels_list } - self.log("Result generated post verifying if delete port channels is required: {0}".format(results), "DEBUG") + self.log("Result generated post verifying if delete port channels is required: {0}".format( + results), "DEBUG") return results @@ -2276,7 +2416,8 @@ def delete_port_channels(self, delete_port_channel_param): Description: This method initiates the task to delete port channels using the provided parameters and returns the task ID. """ - self.log("Initiating deletion of port channels with parameters: {0}".format(delete_port_channel_param), "DEBUG") + self.log("Initiating deletion of port channels with parameters: {0}".format( + delete_port_channel_param), "DEBUG") return self.get_taskid_post_api_call("sda", "delete_port_channels", delete_port_channel_param) def get_add_port_assignments_task_status(self, task_id): @@ -2295,8 +2436,10 @@ def get_add_port_assignments_task_status(self, task_id): # Retrieve the parameters for adding port assignments add_port_assignments_params = self.want["add_port_assignments_params"] - interface_list = [port.get("interfaceName") for port in add_port_assignments_params["payload"]] - msg["{0} Succeeded for following interface(s)".format(task_name)] = {"success_count": len(interface_list), "success_interfaces": interface_list} + interface_list = [port.get("interfaceName") + for port in add_port_assignments_params["payload"]] + msg["{0} Succeeded for following interface(s)".format(task_name)] = { + "success_count": len(interface_list), "success_interfaces": interface_list} # Retrieve and return the task status using the provided task ID return self.get_task_status_from_tasks_by_id(task_id, task_name, msg) @@ -2317,8 +2460,10 @@ def get_update_port_assignments_task_status(self, task_id): # Retrieve the parameters for update port assignments update_port_assignments_params = self.want["update_port_assignments_params"] - interface_list = [port.get("interfaceName") for port in update_port_assignments_params["payload"]] - msg["{0} Succeeded for following interface(s)".format(task_name)] = {"success_count": len(interface_list), "success_interfaces": interface_list} + interface_list = [port.get("interfaceName") + for port in update_port_assignments_params["payload"]] + msg["{0} Succeeded for following interface(s)".format(task_name)] = { + "success_count": len(interface_list), "success_interfaces": interface_list} # Retrieve and return the task status using the provided task ID return self.get_task_status_from_tasks_by_id(task_id, task_name, msg) @@ -2337,10 +2482,12 @@ def get_delete_port_assignments_task_status(self, task_id, task_name, interface_ This method constructs a message indicating the successful completion of the delete port assignments operation. It then retrieves the task status using the provided task ID and logs the relevant information. """ - msg = "{0} operation has completed successfully for {1} interfaces: {2}.".format(task_name, len(interface_list), ", ".join(interface_list)) + msg = "{0} operation has completed successfully for {1} interfaces: {2}.".format( + task_name, len(interface_list), ", ".join(interface_list)) # Retrieve and return the task status using the provided task ID - self.get_task_status_from_tasks_by_id(task_id, task_name, msg).check_return_status() + self.get_task_status_from_tasks_by_id( + task_id, task_name, msg).check_return_status() return self.status def process_delete_port_assignments(self, delete_port_assignments_params_list): @@ -2363,15 +2510,21 @@ def process_delete_port_assignments(self, delete_port_assignments_params_list): msg = {} for index, delete_port_assignment_param in delete_port_assignments_params_list.items(): - delete_required = delete_port_assignment_param.get("delete_required") - interface_list = delete_port_assignment_param.get("interfaces_list") - self.log("Processing - index: {0}, delete_port_assignment_param: {1}".format(index, delete_port_assignment_param), "DEBUG") - - self.log("Is DELETE required: {0}".format(delete_required), "DEBUG") + delete_required = delete_port_assignment_param.get( + "delete_required") + interface_list = delete_port_assignment_param.get( + "interfaces_list") + self.log("Processing - index: {0}, delete_port_assignment_param: {1}".format( + index, delete_port_assignment_param), "DEBUG") + + self.log("Is DELETE required: {0}".format( + delete_required), "DEBUG") if delete_required: - task_id = self.delete_port_assignments(delete_port_assignment_param.get("delete_port_assignment_params")) + task_id = self.delete_port_assignments( + delete_port_assignment_param.get("delete_port_assignment_params")) self.log("Task ID: {0}".format(task_id), "DEBUG") - status = self.get_delete_port_assignments_task_status(task_id, task_name, interface_list) + status = self.get_delete_port_assignments_task_status( + task_id, task_name, interface_list) if status == "success": success_interfaces.extend(interface_list) @@ -2384,15 +2537,18 @@ def process_delete_port_assignments(self, delete_port_assignments_params_list): # Set the final message if success_interfaces: - self.log("{0} Succeeded for following interface(s): {1} ".format(task_name, success_interfaces)) + self.log("{0} Succeeded for following interface(s): {1} ".format( + task_name, success_interfaces)) msg["{0} Succeeded for following interface(s)".format(task_name)] = { "success_count": len(success_interfaces), "success_interfaces": success_interfaces } if failed_interfaces: - self.log("{0} Failed for following interface(s): {1} ".format(task_name, failed_interfaces)) - msg["{0} Failed for following interface(s)".format(task_name)] = {"failed_count": len(failed_interfaces), "failed_interfaces": failed_interfaces} + self.log("{0} Failed for following interface(s): {1} ".format( + task_name, failed_interfaces)) + msg["{0} Failed for following interface(s)".format(task_name)] = { + "failed_count": len(failed_interfaces), "failed_interfaces": failed_interfaces} self.msg = msg # Check if no operations were performed @@ -2422,7 +2578,8 @@ def get_add_port_channels_task_status(self, task_id): """ task_name = "Add Port Channel(s) Task" add_port_channels_params = self.want["add_port_channels_params"] - msg = "{0} has completed successfully for params: {1}.".format(task_name, add_port_channels_params["payload"]) + msg = "{0} has completed successfully for params: {1}.".format( + task_name, add_port_channels_params["payload"]) # Execute the task and get the status self.get_task_status_from_tasks_by_id(task_id, task_name, msg) @@ -2430,20 +2587,24 @@ def get_add_port_channels_task_status(self, task_id): # Check if the operation status matches self.status if self.status == "success": # Fetch existing port channels - existing_port_channels = self.get_port_channels(self.have.get("get_port_channels_params")) + existing_port_channels = self.get_port_channels( + self.have.get("get_port_channels_params")) # Log the fetched port channels - self.log("Existing Port Channels after task completion: {0}".format(existing_port_channels), "DEBUG") + self.log("Existing Port Channels after task completion: {0}".format( + existing_port_channels), "DEBUG") # Compare interface names and collect created port channel names port_channels_names = [] for port_channel in existing_port_channels: for payload_channel in add_port_channels_params["payload"]: if set(payload_channel["interfaceNames"]) == set(port_channel["interfaceNames"]): - port_channels_names.append(port_channel["portChannelName"]) + port_channels_names.append( + port_channel["portChannelName"]) break - self.log("Names of port_channels that were successfully created: {0}".format(port_channels_names), "DEBUG") + self.log("Names of port_channels that were successfully created: {0}".format( + port_channels_names), "DEBUG") updated_msg = {} @@ -2471,8 +2632,10 @@ def get_update_port_channels_task_status(self, task_id): msg = {} # Retrieve the parameters for updating port channels - update_port_channels_params = self.want.get("update_port_channels_params") - port_channels_list = [port.get("portChannelName") for port in update_port_channels_params["payload"]] + update_port_channels_params = self.want.get( + "update_port_channels_params") + port_channels_list = [port.get("portChannelName") + for port in update_port_channels_params["payload"]] msg["{0} Succeeded for following port channel(s)".format(task_name)] = { "success_count": len(port_channels_list), "success_port_channels": port_channels_list @@ -2495,10 +2658,12 @@ def get_delete_port_channels_task_status(self, task_id, task_name, port_channels This method constructs a message indicating the successful completion of the delete port channels operation. It then retrieves the task status using the provided task ID and logs the relevant information. """ - msg = "{0} operation has completed successfully for {1} port channels: {2}.".format(task_name, len(port_channels_list), ", ".join(port_channels_list)) + msg = "{0} operation has completed successfully for {1} port channels: {2}.".format( + task_name, len(port_channels_list), ", ".join(port_channels_list)) # Retrieve the task status using the provided task ID and check the return status - self.get_task_status_from_tasks_by_id(task_id, task_name, msg).check_return_status() + self.get_task_status_from_tasks_by_id( + task_id, task_name, msg).check_return_status() return self.status def process_delete_port_channels(self, delete_port_channels_params_list): @@ -2523,13 +2688,17 @@ def process_delete_port_channels(self, delete_port_channels_params_list): for index, delete_port_channel_param in delete_port_channels_params_list.items(): delete_required = delete_port_channel_param.get("delete_required") channel_list = delete_port_channel_param.get("port_channels_list") - self.log("Processing - index: {0}, delete_port_channel_param: {1}".format(index, delete_port_channel_param), "DEBUG") + self.log("Processing - index: {0}, delete_port_channel_param: {1}".format( + index, delete_port_channel_param), "DEBUG") - self.log("Is DELETE required: {0}".format(delete_required), "DEBUG") + self.log("Is DELETE required: {0}".format( + delete_required), "DEBUG") if delete_required: - task_id = self.delete_port_channels(delete_port_channel_param.get("delete_port_channel_params")) + task_id = self.delete_port_channels( + delete_port_channel_param.get("delete_port_channel_params")) self.log("Task ID: {0}".format(task_id), "DEBUG") - status = self.get_delete_port_channels_task_status(task_id, task_name, channel_list) + status = self.get_delete_port_channels_task_status( + task_id, task_name, channel_list) if status == "success": success_channels.extend(channel_list) @@ -2541,15 +2710,18 @@ def process_delete_port_channels(self, delete_port_channels_params_list): } if success_channels: - self.log("{0} Succeeded for following port channel(s): {1} ".format(task_name, success_channels)) + self.log("{0} Succeeded for following port channel(s): {1} ".format( + task_name, success_channels)) msg["{0} Succeeded for following port channel(s)".format(task_name)] = { "success_count": len(success_channels), "success_port_channels": success_channels } if failed_channels: - self.log("{0} Failed for following channel(s): {1} ".format(task_name, failed_channels)) - msg["{0} Failed for following port channel(s)".format(task_name)] = {"failed_count": len(failed_channels), "failed_port_channels": failed_channels} + self.log("{0} Failed for following channel(s): {1} ".format( + task_name, failed_channels)) + msg["{0} Failed for following port channel(s)".format(task_name)] = { + "failed_count": len(failed_channels), "failed_port_channels": failed_channels} self.msg = msg if success_channels and failed_channels: @@ -2584,13 +2756,18 @@ def verify_port_assignments_add_operation(self, add_port_assignments_params): Args: add_port_assignments_params (dict): The parameters for the add port assignments operation. """ - get_port_assignments_params = self.have.get("get_port_assignments_params") - port_assignments = self.get_port_assignments(get_port_assignments_params) + get_port_assignments_params = self.have.get( + "get_port_assignments_params") + port_assignments = self.get_port_assignments( + get_port_assignments_params) - self.log("Desired State: {0}".format(str(add_port_assignments_params)), "INFO") - self.log("State after performing ADD Port Assignments operation: {0}".format(str(port_assignments)), "INFO") + self.log("Desired State: {0}".format( + str(add_port_assignments_params)), "INFO") + self.log("State after performing ADD Port Assignments operation: {0}".format( + str(port_assignments)), "INFO") - current_interface_names = [port.get("interfaceName") for port in port_assignments] + current_interface_names = [ + port.get("interfaceName") for port in port_assignments] add_interface_names = [ param.get("interfaceName") for param in add_port_assignments_params["payload"] ] @@ -2614,36 +2791,44 @@ def verify_port_assignments_update_operation(self, update_port_assignments_param Args: update_port_assignments_params (dict): The parameters for the update port assignments operation. """ - get_port_assignments_params = self.have.get("get_port_assignments_params") - port_assignments = self.get_port_assignments(get_port_assignments_params) + get_port_assignments_params = self.have.get( + "get_port_assignments_params") + port_assignments = self.get_port_assignments( + get_port_assignments_params) - self.log("Desired State: {0}".format(str(update_port_assignments_params)), "INFO") - self.log("State after performing UPDATE Port Assignments operation: {0}".format(str(port_assignments)), "INFO") + self.log("Desired State: {0}".format( + str(update_port_assignments_params)), "INFO") + self.log("State after performing UPDATE Port Assignments operation: {0}".format( + str(port_assignments)), "INFO") mismatched_interfaces = [] # Compare the update_port_assignments_params with the current port_assignments for update_param in update_port_assignments_params["payload"]: interface_id = update_param.get("id") - matching_port = next((port for port in port_assignments if port.get("id") == interface_id), None) + matching_port = next( + (port for port in port_assignments if port.get("id") == interface_id), None) if matching_port: for key, value in update_param.items(): if key not in ["fabricId", "networkDeviceId"] and matching_port.get(key) != value: - mismatched_interfaces.append(update_param.get("interfaceName")) + mismatched_interfaces.append( + update_param.get("interfaceName")) break # Log the results if not mismatched_interfaces: self.log( "Verified the success of UPDATE Port Assignments operation for interfaceName(s) {0}.".format( - ", ".join([param.get("interfaceName") for param in update_port_assignments_params["payload"]]) + ", ".join([param.get("interfaceName") + for param in update_port_assignments_params["payload"]]) ), "INFO" ) else: self.log( "The UPDATE Port Assignments operation may not have been successful " - "since the following interface assignments do not match: {0}.".format(", ".join(mismatched_interfaces)), + "since the following interface assignments do not match: {0}.".format( + ", ".join(mismatched_interfaces)), "WARNING" ) @@ -2658,20 +2843,27 @@ def verify_port_assignments_delete_operation(self, delete_port_assignments_param interfaces_still_exist = [] for index, delete_port_assignment_data in delete_port_assignments_params.items(): - self.log("Processing parameters at - index {0}: {1}".format(index, delete_port_assignment_data), "DEBUG") - delete_required = delete_port_assignment_data.get("delete_required") - delete_port_assignment_params = delete_port_assignment_data.get("delete_port_assignment_params") - interfaces_list = delete_port_assignment_data.get("interfaces_list", []) + self.log("Processing parameters at - index {0}: {1}".format( + index, delete_port_assignment_data), "DEBUG") + delete_required = delete_port_assignment_data.get( + "delete_required") + delete_port_assignment_params = delete_port_assignment_data.get( + "delete_port_assignment_params") + interfaces_list = delete_port_assignment_data.get( + "interfaces_list", []) if delete_required: - port_assignments = self.get_port_assignments(delete_port_assignment_params) + port_assignments = self.get_port_assignments( + delete_port_assignment_params) if port_assignments: - existing_interfaces = [port.get("interfaceName") for port in port_assignments if port.get("interfaceName") in interfaces_list] + existing_interfaces = [port.get("interfaceName") for port in port_assignments if port.get( + "interfaceName") in interfaces_list] interfaces_still_exist.extend(existing_interfaces) self.log( "The DELETE Port Assignments operation may not have been successful " - "since the following interface assignments still exist: {0}.".format(", ".join(existing_interfaces)), + "since the following interface assignments still exist: {0}.".format( + ", ".join(existing_interfaces)), "WARNING" ) else: @@ -2683,7 +2875,8 @@ def verify_port_assignments_delete_operation(self, delete_port_assignments_param if interfaces_still_exist: self.log( - "The following interfaceName(s) were not deleted: {0}.".format(", ".join(interfaces_still_exist)), + "The following interfaceName(s) were not deleted: {0}.".format( + ", ".join(interfaces_still_exist)), "ERROR" ) else: @@ -2699,20 +2892,24 @@ def verify_port_channels_add_operation(self, add_port_channels_params): add_port_channels_params (dict): The parameters for the add port channels operation. """ get_port_channels_params = self.have.get("get_port_channels_params") - existing_port_channels = self.get_port_channels(get_port_channels_params) + existing_port_channels = self.get_port_channels( + get_port_channels_params) # Log the fetched port channels - self.log("Existing Port Channels after task completion: {0}".format(existing_port_channels), "DEBUG") + self.log("Existing Port Channels after task completion: {0}".format( + existing_port_channels), "DEBUG") self.log("Desired State: {0}".format(add_port_channels_params), "INFO") if existing_port_channels: # Compare interface names and collect created port channel names port_channels_names = [] for requested_channel in add_port_channels_params.get("payload"): - requested_interface_names = requested_channel.get("interfaceNames") + requested_interface_names = requested_channel.get( + "interfaceNames") for existing_channel in existing_port_channels: if set(requested_interface_names) == set(existing_channel.get("interfaceNames")): - port_channels_names.append(existing_channel.get("portChannelName")) + port_channels_names.append( + existing_channel.get("portChannelName")) # Log the result of verification if port_channels_names: @@ -2741,15 +2938,18 @@ def verify_port_channels_update_operation(self, update_port_channels_params): get_port_channels_params = self.have.get("get_port_channels_params") port_channels = self.get_port_channels(get_port_channels_params) - self.log("Desired State: {0}".format(str(update_port_channels_params)), "INFO") - self.log("State after performing UPDATE Port Channels operation: {0}".format(str(port_channels)), "INFO") + self.log("Desired State: {0}".format( + str(update_port_channels_params)), "INFO") + self.log("State after performing UPDATE Port Channels operation: {0}".format( + str(port_channels)), "INFO") mismatched_channels = [] # Compare the update_port_channels_params with the current port_channels for update_param in update_port_channels_params["payload"]: port_channel_name = update_param.get("portChannelName") - matching_channel = next((channel for channel in port_channels if channel.get("portChannelName") == port_channel_name), None) + matching_channel = next((channel for channel in port_channels if channel.get( + "portChannelName") == port_channel_name), None) if matching_channel: for key, value in update_param.items(): @@ -2761,13 +2961,15 @@ def verify_port_channels_update_operation(self, update_port_channels_params): if not mismatched_channels: self.log( "Verified the success of UPDATE Port Channels operation for portChannelName(s) {0}.".format( - ", ".join([param.get("portChannelName") for param in update_port_channels_params["payload"]]) + ", ".join([param.get("portChannelName") + for param in update_port_channels_params["payload"]]) ), "INFO" ) else: self.log( "The UPDATE Port Channels operation may not have been successful " - "since the following port channels do not match: {0}.".format(", ".join(mismatched_channels)), + "since the following port channels do not match: {0}.".format( + ", ".join(mismatched_channels)), "WARNING" ) @@ -2782,20 +2984,25 @@ def verify_port_channels_delete_operation(self, delete_port_channels_params): channels_still_exist = [] for index, delete_port_channel_data in delete_port_channels_params.items(): - self.log("Processing parameters at - index {0}: {1}".format(index, delete_port_channel_data), "DEBUG") + self.log("Processing parameters at - index {0}: {1}".format( + index, delete_port_channel_data), "DEBUG") delete_required = delete_port_channel_data.get("delete_required") - delete_port_channel_params = delete_port_channel_data.get("delete_port_channel_params") + delete_port_channel_params = delete_port_channel_data.get( + "delete_port_channel_params") channel_list = delete_port_channel_data.get("channel_list", []) if delete_required: - port_channels = self.get_port_channels(delete_port_channel_params) + port_channels = self.get_port_channels( + delete_port_channel_params) if port_channels: - existing_channels = [channel.get("portChannelName") for channel in port_channels if channel.get("portChannelName") in channel_list] + existing_channels = [channel.get("portChannelName") for channel in port_channels if channel.get( + "portChannelName") in channel_list] channels_still_exist.extend(existing_channels) self.log( "The DELETE Port Channels operation may not have been successful " - "since the following port channels still exist: {0}.".format(", ".join(existing_channels)), + "since the following port channels still exist: {0}.".format( + ", ".join(existing_channels)), "WARNING" ) else: @@ -2807,7 +3014,8 @@ def verify_port_channels_delete_operation(self, delete_port_channels_params): if channels_still_exist: self.log( - "The following portChannelName(s) were not deleted: {0}.".format(", ".join(channels_still_exist)), + "The following portChannelName(s) were not deleted: {0}.".format( + ", ".join(channels_still_exist)), "ERROR" ) else: @@ -2836,7 +3044,8 @@ def get_have(self, config, state): self.validate_params(config, state) # Get the network fabric ID and map of management IP to instance ID - mgmt_ip_to_instance_id_map, fabric_id = self.get_network_fabric_id(config.get("ip_address"), config.get("hostname")) + mgmt_ip_to_instance_id_map, fabric_id = self.get_network_fabric_id( + config.get("ip_address"), config.get("hostname")) network_device_id = list(mgmt_ip_to_instance_id_map.values())[0] # Store Required common parameters @@ -2851,9 +3060,11 @@ def get_have(self, config, state): port_channel_details = config.get("port_channel_details") # Get parameters for port assignments and port channels - get_port_assignments_params = self.get_port_assignments_params(network_device_id, fabric_id) + get_port_assignments_params = self.get_port_assignments_params( + network_device_id, fabric_id) have["get_port_assignments_params"] = get_port_assignments_params - get_port_channels_params = self.get_port_channels_params(network_device_id, fabric_id) + get_port_channels_params = self.get_port_channels_params( + network_device_id, fabric_id) have["get_port_channels_params"] = get_port_channels_params if state == "merged": @@ -2868,7 +3079,8 @@ def get_have(self, config, state): if port_channel_details: # Compare and categorize port channels - create_port_channels, update_port_channels, no_update_port_channels = self.compare_port_channels(get_port_channels_params, port_channel_details) + create_port_channels, update_port_channels, no_update_port_channels = self.compare_port_channels( + get_port_channels_params, port_channel_details) have["create_port_channels"] = create_port_channels have["update_port_channels"] = update_port_channels have["no_update_port_channels"] = no_update_port_channels @@ -2876,20 +3088,27 @@ def get_have(self, config, state): elif state == "deleted": if port_assignment_details: # Generate and verify parameters for deleting port assignments - delete_port_assignments_params_list = self.get_delete_port_assignments_params(port_assignment_details, network_device_id, fabric_id) - have["delete_port_assignments_details"] = self.verify_delete_port_assignments_requirement(delete_port_assignments_params_list) + delete_port_assignments_params_list = self.get_delete_port_assignments_params( + port_assignment_details, network_device_id, fabric_id) + have["delete_port_assignments_details"] = self.verify_delete_port_assignments_requirement( + delete_port_assignments_params_list) if port_channel_details: # Generate and verify parameters for deleting port channels - delete_port_channels_params_list = self.get_delete_port_channels_params(port_channel_details, network_device_id, fabric_id) - have["delete_port_channels_details"] = self.verify_delete_port_channels_requirement(delete_port_channels_params_list) + delete_port_channels_params_list = self.get_delete_port_channels_params( + port_channel_details, network_device_id, fabric_id) + have["delete_port_channels_details"] = self.verify_delete_port_channels_requirement( + delete_port_channels_params_list) if not port_assignment_details and not port_channel_details: # Handle case where no specific port assignment or channel details are provided - delete_port_assignments_params_list = [get_port_assignments_params] - have["delete_port_assignments_details"] = self.verify_delete_port_assignments_requirement(delete_port_assignments_params_list) + delete_port_assignments_params_list = [ + get_port_assignments_params] + have["delete_port_assignments_details"] = self.verify_delete_port_assignments_requirement( + delete_port_assignments_params_list) delete_port_channels_params_list = [get_port_channels_params] - have["delete_port_channels_details"] = self.verify_delete_port_channels_requirement(delete_port_channels_params_list) + have["delete_port_channels_details"] = self.verify_delete_port_channels_requirement( + delete_port_channels_params_list) # Store the constructed current state in the instance attribute self.have = have @@ -2910,7 +3129,8 @@ def get_want(self, state): For the "deleted" state, it prepares parameters for deleting port assignments and port channels. The method logs the desired state and returns the instance. """ - self.log("Creating Parameters for API Calls with state: {0}".format(state)) + self.log( + "Creating Parameters for API Calls with state: {0}".format(state)) want = {} @@ -2920,7 +3140,8 @@ def get_want(self, state): want["add_port_assignments_params"] = self.get_add_port_assignments_params() self.log( "State is merged and Port Assignments need to be created in the Cisco Catalyst Center, " - "therefore setting 'add_port_assignments_params' - {0}.".format(want.get("add_port_assignments_params")), + "therefore setting 'add_port_assignments_params' - {0}.".format( + want.get("add_port_assignments_params")), "DEBUG" ) if self.have.get("update_port_assignments"): @@ -2928,7 +3149,8 @@ def get_want(self, state): want["update_port_assignments_params"] = self.get_update_port_assignments_params() self.log( "State is merged and Existing Port Assignments in the Cisco Catalyst Center need to be UPDATED." - "therefore setting 'update_port_assignments_params' - {0}.".format(want.get("update_port_assignments_params")), + "therefore setting 'update_port_assignments_params' - {0}.".format( + want.get("update_port_assignments_params")), "DEBUG" ) if self.have.get("create_port_channels"): @@ -2936,7 +3158,8 @@ def get_want(self, state): want["add_port_channels_params"] = self.get_add_port_channels_params() self.log( "State is merged and Port Channels need to be created in the Cisco Catalyst Center, " - "therefore setting 'add_port_channel_params' - {0}.".format(want.get("add_port_channels_params")), + "therefore setting 'add_port_channel_params' - {0}.".format( + want.get("add_port_channels_params")), "DEBUG" ) if self.have.get("update_port_channels"): @@ -2944,25 +3167,30 @@ def get_want(self, state): want["update_port_channels_params"] = self.get_update_port_channels_params() self.log( "State is merged and Existing Port Channels in the Cisco Catalyst Center need to be UPDATED." - "therefore setting 'update_port_channel_params' - {0}.".format(want.get("update_port_channels_params")), + "therefore setting 'update_port_channel_params' - {0}.".format( + want.get("update_port_channels_params")), "DEBUG" ) elif state == "deleted": if self.have.get("delete_port_assignments_details"): # Set parameters for deleting port assignments - want["delete_port_assignments_params"] = self.have.get("delete_port_assignments_details") + want["delete_port_assignments_params"] = self.have.get( + "delete_port_assignments_details") self.log( "State is deleted and Port Assignments need to be deleted in the Cisco Catalyst Center, " - "therefore setting 'delete_port_assignments_params' - {0}.".format(want.get("delete_port_assignments_params")), + "therefore setting 'delete_port_assignments_params' - {0}.".format( + want.get("delete_port_assignments_params")), "DEBUG" ) if self.have.get("delete_port_channels_details"): # Set parameters for deleting port channels - want["delete_port_channels_params"] = self.have.get("delete_port_channels_details") + want["delete_port_channels_params"] = self.have.get( + "delete_port_channels_details") self.log( "State is deleted and Port Channels need to be deleted in the Cisco Catalyst Center, " - "therefore setting 'delete_port_channels_params' - {0}.".format(want.get("delete_port_channels_params")), + "therefore setting 'delete_port_channels_params' - {0}.".format( + want.get("delete_port_channels_params")), "DEBUG" ) @@ -3007,18 +3235,22 @@ def get_diff_merged(self): # Execute the action and check its status req_action_param = self.want.get(action_param) if req_action_param: - self.log("Executing action function: {0} with params: {1}".format(action_func.__name__, req_action_param), "INFO") + self.log("Executing action function: {0} with params: {1}".format( + action_func.__name__, req_action_param), "INFO") result_task_id = action_func(req_action_param) - self.log("Task Id: {0} returned from the action function: {1}".format(result_task_id, action_func.__name__), "DEBUG") + self.log("Task Id: {0} returned from the action function: {1}".format( + result_task_id, action_func.__name__), "DEBUG") status_func(result_task_id).check_return_status() - self.log("Checked return status for Task Id: {0} using status function: {1}".format(result_task_id, status_func.__name__), "INFO") + self.log("Checked return status for Task Id: {0} using status function: {1}".format( + result_task_id, status_func.__name__), "INFO") result = self.msg result_details.update(result) final_status_list.append(self.status) final_status, is_changed = self.process_final_result(final_status_list) self.msg = result_details - self.log("Completed 'get_diff_merged' operation with final status: {0}, is_changed: {1}".format(final_status, is_changed), "INFO") + self.log("Completed 'get_diff_merged' operation with final status: {0}, is_changed: {1}".format( + final_status, is_changed), "INFO") self.set_operation_result(final_status, is_changed, self.msg, "INFO") return self @@ -3040,8 +3272,10 @@ def get_diff_deleted(self): # Process deletion of port assignments if required if self.want.get("delete_port_assignments_params"): self.log("Processing deletion of port assignments.", "INFO") - delete_port_assignments_params_list = self.want.get("delete_port_assignments_params") - self.process_delete_port_assignments(delete_port_assignments_params_list).check_return_status() + delete_port_assignments_params_list = self.want.get( + "delete_port_assignments_params") + self.process_delete_port_assignments( + delete_port_assignments_params_list).check_return_status() self.log("Deletion of port assignments completed.", "INFO") result = self.msg result_details.update(result) @@ -3049,8 +3283,10 @@ def get_diff_deleted(self): # Process deletion of port channels if required if self.want.get("delete_port_channels_params"): - delete_port_channels_params_list = self.want.get("delete_port_channels_params") - self.process_delete_port_channels(delete_port_channels_params_list).check_return_status() + delete_port_channels_params_list = self.want.get( + "delete_port_channels_params") + self.process_delete_port_channels( + delete_port_channels_params_list).check_return_status() result = self.msg result_details.update(result) final_status_list.append(self.status) @@ -3059,7 +3295,8 @@ def get_diff_deleted(self): final_status, is_changed = self.process_final_result(final_status_list) self.msg = result_details - self.log("Completed 'get_diff_deleted' operation with final status: {0}, is_changed: {1}".format(final_status, is_changed), "INFO") + self.log("Completed 'get_diff_deleted' operation with final status: {0}, is_changed: {1}".format( + final_status, is_changed), "INFO") self.set_operation_result(final_status, is_changed, self.msg, "INFO") return self @@ -3076,34 +3313,48 @@ def verify_diff_merged(self): self.log("Starting 'verify_diff_merged' operation.", "INFO") # Retrieve parameters for add and update operations from the desired state (self.want) - add_port_assignments_params = self.want.get("add_port_assignments_params") - update_port_assignments_params = self.want.get("update_port_assignments_params") + add_port_assignments_params = self.want.get( + "add_port_assignments_params") + update_port_assignments_params = self.want.get( + "update_port_assignments_params") add_port_channels_params = self.want.get("add_port_channels_params") - update_port_channels_params = self.want.get("update_port_channels_params") + update_port_channels_params = self.want.get( + "update_port_channels_params") # Verifying ADD Port Assignments operation if add_port_assignments_params: - self.log("Starting verification of ADD Port Assignments operation.", "INFO") - self.verify_port_assignments_add_operation(add_port_assignments_params) - self.log("Completed verification of ADD Port Assignments operation.", "INFO") + self.log( + "Starting verification of ADD Port Assignments operation.", "INFO") + self.verify_port_assignments_add_operation( + add_port_assignments_params) + self.log( + "Completed verification of ADD Port Assignments operation.", "INFO") # Verifying UPDATE Port Assignments operation if update_port_assignments_params: - self.log("Starting verification of UPDATE Port Assignments operation.", "INFO") - self.verify_port_assignments_update_operation(update_port_assignments_params) - self.log("Completed verification of UPDATE Port Assignments operation.", "INFO") + self.log( + "Starting verification of UPDATE Port Assignments operation.", "INFO") + self.verify_port_assignments_update_operation( + update_port_assignments_params) + self.log( + "Completed verification of UPDATE Port Assignments operation.", "INFO") # Verifying ADD Port Channels operation if add_port_channels_params: - self.log("Starting verification of ADD Port Channels operation.", "INFO") + self.log( + "Starting verification of ADD Port Channels operation.", "INFO") self.verify_port_channels_add_operation(add_port_channels_params) - self.log("Completed verification of ADD Port Channels operation.", "INFO") + self.log( + "Completed verification of ADD Port Channels operation.", "INFO") # Verifying UPDATE Port Channels operation if update_port_channels_params: - self.log("Starting verification of UPDATE Port Channels operation.", "INFO") - self.verify_port_channels_update_operation(update_port_channels_params) - self.log("Completed verification of UPDATE Port Channels operation.", "INFO") + self.log( + "Starting verification of UPDATE Port Channels operation.", "INFO") + self.verify_port_channels_update_operation( + update_port_channels_params) + self.log( + "Completed verification of UPDATE Port Channels operation.", "INFO") self.log("Completed 'verify_diff_merged' operation.", "INFO") return self @@ -3121,18 +3372,26 @@ def verify_diff_deleted(self): """ self.log("Starting 'verify_diff_deleted' operation.", "INFO") - delete_port_assignments_params = self.want.get("delete_port_assignments_params") - delete_port_channels_params = self.want.get("delete_port_channels_params") + delete_port_assignments_params = self.want.get( + "delete_port_assignments_params") + delete_port_channels_params = self.want.get( + "delete_port_channels_params") if delete_port_assignments_params: - self.log("Starting verification of DELETE Port Assignments operation.", "INFO") - self.verify_port_assignments_delete_operation(delete_port_assignments_params) - self.log("Completed verification of DELETE Port Assignments operation.", "INFO") + self.log( + "Starting verification of DELETE Port Assignments operation.", "INFO") + self.verify_port_assignments_delete_operation( + delete_port_assignments_params) + self.log( + "Completed verification of DELETE Port Assignments operation.", "INFO") if delete_port_channels_params: - self.log("Starting verification of DELETE Port Channels operation.", "INFO") - self.verify_port_channels_delete_operation(delete_port_channels_params) - self.log("Completed verification of DELETE Port Channels operation.", "INFO") + self.log( + "Starting verification of DELETE Port Channels operation.", "INFO") + self.verify_port_channels_delete_operation( + delete_port_channels_params) + self.log( + "Completed verification of DELETE Port Channels operation.", "INFO") self.log("Completed 'verify_diff_deleted' operation.", "INFO") return self @@ -3187,12 +3446,15 @@ def main(): # Iterate over the validated configuration parameters for config in ccc_sda_host_port_onboarding.validated_config: ccc_sda_host_port_onboarding.reset_values() - ccc_sda_host_port_onboarding.get_have(config, state).check_return_status() + ccc_sda_host_port_onboarding.get_have( + config, state).check_return_status() ccc_sda_host_port_onboarding.get_want(state).check_return_status() - ccc_sda_host_port_onboarding.get_diff_state_apply[state]().check_return_status() + ccc_sda_host_port_onboarding.get_diff_state_apply[state]( + ).check_return_status() if config_verify: - ccc_sda_host_port_onboarding.verify_diff_state_apply[state]().check_return_status() + ccc_sda_host_port_onboarding.verify_diff_state_apply[state]( + ).check_return_status() module.exit_json(**ccc_sda_host_port_onboarding.result) diff --git a/plugins/modules/site_intent.py b/plugins/modules/site_intent.py index 64dd5b9514..41f12166df 100644 --- a/plugins/modules/site_intent.py +++ b/plugins/modules/site_intent.py @@ -5,9 +5,16 @@ # 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 +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + get_dict_result, +) +from ansible.module_utils.basic import AnsibleModule __metaclass__ = type -__author__ = ("Madhan Sankaranarayanan, Rishita Chowdhary, Abhishek Maheshwari") +__author__ = ( + "Madhan Sankaranarayanan, Rishita Chowdhary, Abhishek Maheshwari") DOCUMENTATION = r""" --- @@ -320,12 +327,6 @@ } """ -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - get_dict_result, -) floor_plan = { '101101': 'Cubes And Walled Offices', @@ -391,7 +392,8 @@ def validate_input(self): return self self.validated_config = valid_temp - self.msg = "Successfully validated playbook config params: {0}".format(str(valid_temp)) + self.msg = "Successfully validated playbook config params: {0}".format( + str(valid_temp)) self.log(self.msg, "INFO") self.status = "success" @@ -415,14 +417,16 @@ def get_current_site(self, site): site_info = {} - location = get_dict_result(site[0].get("additionalInfo"), 'nameSpace', "Location") + location = get_dict_result(site[0].get( + "additionalInfo"), 'nameSpace', "Location") typeinfo = location.get("attributes").get("type") if typeinfo == "area": site_info = dict( area=dict( name=site[0].get("name"), - parentName=site[0].get("siteNameHierarchy").split("/" + site[0].get("name"))[0] + parentName=site[0].get("siteNameHierarchy").split( + "/" + site[0].get("name"))[0] ) ) @@ -430,7 +434,8 @@ def get_current_site(self, site): site_info = dict( building=dict( name=site[0].get("name"), - parentName=site[0].get("siteNameHierarchy").split("/" + site[0].get("name"))[0], + parentName=site[0].get("siteNameHierarchy").split( + "/" + site[0].get("name"))[0], address=location.get("attributes").get("address"), latitude=location.get("attributes").get("latitude"), longitude=location.get("attributes").get("longitude"), @@ -439,14 +444,17 @@ def get_current_site(self, site): ) elif typeinfo == "floor": - map_geometry = get_dict_result(site[0].get("additionalInfo"), 'nameSpace', "mapGeometry") - map_summary = get_dict_result(site[0].get("additionalInfo"), 'nameSpace', "mapsSummary") + map_geometry = get_dict_result(site[0].get( + "additionalInfo"), 'nameSpace', "mapGeometry") + map_summary = get_dict_result(site[0].get( + "additionalInfo"), 'nameSpace', "mapsSummary") rf_model = map_summary.get("attributes").get("rfModel") site_info = dict( floor=dict( name=site[0].get("name"), - parentName=site[0].get("siteNameHierarchy").split("/" + site[0].get("name"))[0], + parentName=site[0].get("siteNameHierarchy").split( + "/" + site[0].get("name"))[0], rf_model=floor_plan.get(rf_model), width=map_geometry.get("attributes").get("width"), length=map_geometry.get("attributes").get("length"), @@ -500,10 +508,12 @@ def site_exists(self): .format(self.want.get("site_name")), "WARNING") if response: response = response.get("response") - self.log("Received API response from 'get_site': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_site': {0}".format( + str(response)), "DEBUG") current_site = self.get_current_site(response) site_exists = True - self.log("Site '{0}' exists in Cisco Catalyst Center".format(self.want.get("site_name")), "INFO") + self.log("Site '{0}' exists in Cisco Catalyst Center".format( + self.want.get("site_name")), "INFO") return (site_exists, current_site) @@ -530,7 +540,8 @@ def get_site_params(self, params): if typeinfo not in ["area", "building", "floor"]: self.status = "failed" - self.msg = "Invalid site type '{0}' given in the playbook. Please select one of the type - 'area', 'building', 'floor'".format(typeinfo) + self.msg = "Invalid site type '{0}' given in the playbook. Please select one of the type - 'area', 'building', 'floor'".format( + typeinfo) self.log(self.msg, "ERROR") self.check_return_status() @@ -563,7 +574,8 @@ def get_site_params(self, params): try: site_info["floor"]["rfModel"] = floor_details.get("rf_model") except Exception as e: - self.log("The attribute 'rf_model' is missing in floor '{0}'.".format(floor_details.get('name')), "WARNING") + self.log("The attribute 'rf_model' is missing in floor '{0}'.".format( + floor_details.get('name')), "WARNING") site_params = dict( type=typeinfo, @@ -654,7 +666,8 @@ def is_building_updated(self, updated_site, requested_site): updated_site['parentName'] == requested_site['parentName'] and self.compare_float_values(updated_site['latitude'], requested_site['latitude']) and self.compare_float_values(updated_site['longitude'], requested_site['longitude']) and - ('address' in requested_site and (requested_site['address'] is None or updated_site.get('address') == requested_site['address'])) + ('address' in requested_site and (requested_site['address'] is None or updated_site.get( + 'address') == requested_site['address'])) ) def is_floor_updated(self, updated_site, requested_site): @@ -701,7 +714,8 @@ def site_requires_update(self): updated_site = self.have['current_site']['site'][type] requested_site = self.want['site_params']['site'][type] self.log("Current Site type: {0}".format(str(updated_site)), "INFO") - self.log("Requested Site type: {0}".format(str(requested_site)), "INFO") + self.log("Requested Site type: {0}".format( + str(requested_site)), "INFO") if type == "building": return not self.is_building_updated(updated_site, requested_site) @@ -733,7 +747,8 @@ def get_have(self, config): # check if given site exits, if exists store current site info (site_exists, current_site) = self.site_exists() - self.log("Current Site details (have): {0}".format(str(current_site)), "DEBUG") + self.log("Current Site details (have): {0}".format( + str(current_site)), "DEBUG") if site_exists: have["site_id"] = current_site.get("siteId") @@ -804,13 +819,15 @@ def get_diff_merged(self, config): op_modifies=True, params=site_params, ) - self.log("Received API response from 'update_site': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'update_site': {0}".format( + str(response)), "DEBUG") site_updated = True else: # Site does not neet update self.update_not_neeeded_sites.append(site_name) - self.log("Site - {0} does not need any update".format(site_name), "INFO") + self.log( + "Site - {0} does not need any update".format(site_name), "INFO") return self else: @@ -835,7 +852,8 @@ def get_diff_merged(self, config): op_modifies=True, params=site_params, ) - self.log("Received API response from 'create_site': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'create_site': {0}".format( + str(response)), "DEBUG") site_created = True if site_created or site_updated: @@ -854,14 +872,16 @@ def get_diff_merged(self, config): if site_updated: self.updated_site_list.append(site_name) - self.log("Site - {0} Updated Successfully".format(site_name), "INFO") + self.log( + "Site - {0} Updated Successfully".format(site_name), "INFO") else: # Get the site id of the newly created site. (site_exists, current_site) = self.site_exists() if site_exists: self.created_site_list.append(site_name) - self.log("Site '{0}' created successfully".format(site_name), "INFO") + self.log("Site '{0}' created successfully".format( + site_name), "INFO") return self @@ -890,7 +910,8 @@ def delete_single_site(self, site_id, site_name): ) if response and isinstance(response, dict): - self.log("Received API response from 'delete_site': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'delete_site': {0}".format( + str(response)), "DEBUG") executionid = response.get("executionId") while True: @@ -898,16 +919,20 @@ def delete_single_site(self, site_id, site_name): if execution_details.get("status") == "SUCCESS": self.status = "success" self.deleted_site_list.append(site_name) - self.log("Site '{0}' deleted successfully".format(site_name), "INFO") + self.log("Site '{0}' deleted successfully".format( + site_name), "INFO") break elif execution_details.get("bapiError"): - self.log("Error response for 'delete_site' execution: {0}".format(execution_details.get("bapiError")), "ERROR") - self.module.fail_json(msg=execution_details.get("bapiError"), response=execution_details) + self.log("Error response for 'delete_site' execution: {0}".format( + execution_details.get("bapiError")), "ERROR") + self.module.fail_json(msg=execution_details.get( + "bapiError"), response=execution_details) break except Exception as e: self.status = "failed" - self.msg = "Exception occurred while deleting site '{0}' due to: {1}".format(site_name, str(e)) + self.msg = "Exception occurred while deleting site '{0}' due to: {1}".format( + site_name, str(e)) self.log(self.msg, "ERROR") return self @@ -935,7 +960,8 @@ def get_diff_deleted(self, config): if not site_exists: self.status = "success" self.site_absent_list.append(site_name) - self.log("Unable to delete site '{0}' as it's not found in Cisco Catalyst Center".format(site_name), "INFO") + self.log("Unable to delete site '{0}' as it's not found in Cisco Catalyst Center".format( + site_name), "INFO") return self # Check here if the site have the childs then fetch it using get membership API and then sort it @@ -947,16 +973,19 @@ def get_diff_deleted(self, config): op_modifies=True, params={"site_id": site_id}, ) - self.log("Received API response from 'get_membership': {0}".format(str(mem_response)), "DEBUG") + self.log("Received API response from 'get_membership': {0}".format( + str(mem_response)), "DEBUG") site_response = mem_response.get("site").get("response") - self.log("Site {0} response along with it's child sites: {1}".format(site_name, str(site_response)), "DEBUG") + self.log("Site {0} response along with it's child sites: {1}".format( + site_name, str(site_response)), "DEBUG") if len(site_response) == 0: self.delete_single_site(site_id, site_name) return self # Sorting the response in reverse order based on hierarchy levels - sorted_site_resp = sorted(site_response, key=lambda x: x.get("groupHierarchy"), reverse=True) + sorted_site_resp = sorted( + site_response, key=lambda x: x.get("groupHierarchy"), reverse=True) # Deleting each level in reverse order till topmost parent site for item in sorted_site_resp: @@ -964,7 +993,8 @@ def get_diff_deleted(self, config): # Delete the final parent site self.delete_single_site(site_id, site_name) - self.log("The site '{0}' and its child sites have been deleted successfully".format(site_name), "INFO") + self.log("The site '{0}' and its child sites have been deleted successfully".format( + site_name), "INFO") return self @@ -992,13 +1022,15 @@ def verify_diff_merged(self, config): if site_exist: self.status = "success" - self.msg = "The requested site '{0}' is present in the Cisco Catalyst Center and its creation has been verified.".format(site_name) + self.msg = "The requested site '{0}' is present in the Cisco Catalyst Center and its creation has been verified.".format( + site_name) self.log(self.msg, "INFO") require_update = self.site_requires_update() if not require_update: - self.log("The update for site '{0}' has been successfully verified.".format(site_name), "INFO") + self.log("The update for site '{0}' has been successfully verified.".format( + site_name), "INFO") self. status = "success" return self @@ -1057,7 +1089,8 @@ def update_site_messages(self): if self.update_not_neeeded_sites: msg = """Site(s) '{0}' created successfully as well as Site(s) '{1}' updated successully and the some site(s) '{2}' needs no update in Cisco Catalyst Center""" - self.msg = msg.format(str(self.created_site_list), str(self.updated_site_list), str(self.update_not_neeeded_sites)) + self.msg = msg.format(str(self.created_site_list), str( + self.updated_site_list), str(self.update_not_neeeded_sites)) else: self.msg = """Site(s) '{0}' created successfully in Cisco Catalyst Center as well as Site(s) '{1}' updated successully in Cisco Catalyst Center""".format(str(self.created_site_list), str(self.updated_site_list)) @@ -1067,27 +1100,32 @@ def update_site_messages(self): self.msg = """Site(s) '{0}' created successfully and some site(s) '{1}' not needs any update in Cisco Catalyst Center.""".format(str(self.created_site_list), str(self.update_not_neeeded_sites)) else: - self.msg = "Site(s) '{0}' created successfully in Cisco Catalyst Center.".format(str(self.created_site_list)) + self.msg = "Site(s) '{0}' created successfully in Cisco Catalyst Center.".format( + str(self.created_site_list)) elif self.updated_site_list: self.result['changed'] = True if self.update_not_neeeded_sites: self.msg = """Site(s) '{0}' updated successfully and some site(s) '{1}' not needs any update in Cisco Catalyst Center.""".format(str(self.updated_site_list), str(self.update_not_neeeded_sites)) else: - self.msg = "Site(s) '{0}' updated successfully in Cisco Catalyst Center.".format(str(self.updated_site_list)) + self.msg = "Site(s) '{0}' updated successfully in Cisco Catalyst Center.".format( + str(self.updated_site_list)) elif self.update_not_neeeded_sites: self.result['changed'] = False - self.msg = "Site(s) '{0}' not needs any update in Cisco Catalyst Center.".format(str(self.update_not_neeeded_sites)) + self.msg = "Site(s) '{0}' not needs any update in Cisco Catalyst Center.".format( + str(self.update_not_neeeded_sites)) elif self.deleted_site_list and self.site_absent_list: self.result['changed'] = True self.msg = """Given site(s) '{0}' deleted successfully from Cisco Catalyst Center and unable to deleted some site(s) '{1}' as they are not found in Cisco Catalyst Center.""".format(str(self.deleted_site_list), str(self.site_absent_list)) elif self.deleted_site_list: self.result['changed'] = True - self.msg = "Given site(s) '{0}' deleted successfully from Cisco Catalyst Center".format(str(self.deleted_site_list)) + self.msg = "Given site(s) '{0}' deleted successfully from Cisco Catalyst Center".format( + str(self.deleted_site_list)) else: self.result['changed'] = False - self.msg = "Unable to delete site(s) '{0}' as it's not found in Cisco Catalyst Center.".format(str(self.site_absent_list)) + self.msg = "Unable to delete site(s) '{0}' as it's not found in Cisco Catalyst Center.".format( + str(self.site_absent_list)) self.status = "success" self.result['response'] = self.msg @@ -1139,7 +1177,8 @@ def main(): dnac_site.get_have(config).check_return_status() dnac_site.get_diff_state_apply[state](config).check_return_status() if config_verify: - dnac_site.verify_diff_state_apply[state](config).check_return_status() + dnac_site.verify_diff_state_apply[state]( + config).check_return_status() # Invoke the API to check the status and log the output of each site on the console dnac_site.update_site_messages().check_return_status() diff --git a/plugins/modules/site_workflow_manager.py b/plugins/modules/site_workflow_manager.py index 4989f99e2d..16e01e138c 100644 --- a/plugins/modules/site_workflow_manager.py +++ b/plugins/modules/site_workflow_manager.py @@ -5,6 +5,15 @@ # 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 +import copy +import os +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + get_dict_result, + validate_str +) +from ansible.module_utils.basic import AnsibleModule __metaclass__ = type __author__ = ( @@ -441,16 +450,6 @@ '101104': 'Indoor High Ceiling', '101103': 'Outdoor Open Space' } -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - get_dict_result, - validate_str -) - -import os -import copy class Site(DnacBase): @@ -488,7 +487,8 @@ def validate_input(self): self.msg = "Configuration is not available in the playbook for validation" self.log("Error: {0}".format(self.msg), "ERROR") return self - self.log("Configuration details found in the playbook: {0}".format(self.config), "INFO") + self.log("Configuration details found in the playbook: {0}".format( + self.config), "INFO") temp_spec = dict( type=dict(required=False, type='str'), site=dict(required=True, type='dict'), @@ -530,7 +530,8 @@ def get_current_site(self, site): """ site_info = {} - location = get_dict_result(site[0].get("additionalInfo"), 'nameSpace', "Location") + location = get_dict_result(site[0].get( + "additionalInfo"), 'nameSpace', "Location") typeinfo = location.get("attributes").get("type") if typeinfo == "area": @@ -595,7 +596,8 @@ def get_site_v1(self, site_name_hierarchy): - If the response is empty, a warning is logged. - Any exceptions during the API call are caught, logged as errors, and the function returns None. """ - self.log("Fetching site details for site hierarchy: '{0}'".format(site_name_hierarchy), "INFO") + self.log("Fetching site details for site hierarchy: '{0}'".format( + site_name_hierarchy), "INFO") try: response = self.dnac._exec( family="sites", @@ -605,10 +607,12 @@ def get_site_v1(self, site_name_hierarchy): ) if not response: - self.log("Empty response received for site: {0}".format(site_name_hierarchy), "WARNING") + self.log("Empty response received for site: {0}".format( + site_name_hierarchy), "WARNING") return None - self.log("Received API response for site '{0}' from 'get_sites': {1}".format(site_name_hierarchy, response), "DEBUG") + self.log("Received API response for site '{0}' from 'get_sites': {1}".format( + site_name_hierarchy, response), "DEBUG") return response except Exception as e: @@ -648,20 +652,24 @@ def site_exists(self, site_name_hierarchy=None): return site_exists, current_site if isinstance(response, list): - self.log("Unexpected list returned from get_site, skipping: {}".format(response), "ERROR") + self.log("Unexpected list returned from get_site, skipping: {}".format( + response), "ERROR") return site_exists, current_site if isinstance(response, dict): sites = response.get("response", []) if not sites: - self.log("No site information found: {0}".format(response), "WARNING") + self.log("No site information found: {0}".format( + response), "WARNING") return site_exists, current_site for site in sites: if isinstance(site, dict): - self.log("No site information found for name: {0}".format(self.pprint(site)), "INFO") + self.log("No site information found for name: {0}".format( + self.pprint(site)), "INFO") current_site = dict(site.items()) - current_site['parentName'] = site.get('nameHierarchy', '').rsplit('/', 1)[0] if site.get('nameHierarchy') else None + current_site['parentName'] = site.get('nameHierarchy', '').rsplit( + '/', 1)[0] if site.get('nameHierarchy') else None site_exists = True else: @@ -670,18 +678,22 @@ def site_exists(self, site_name_hierarchy=None): response = self.get_site_v1(site_name_hierarchy) if not response: - self.log("No response received from 'get_site' API for site: {0}".format(site_name_hierarchy), "ERROR") + self.log("No response received from 'get_site' API for site: {0}".format( + site_name_hierarchy), "ERROR") return site_exists, current_site response_data = response.get("response") - self.log("Received API response from 'get_site': {0}".format(str(response_data)), "DEBUG") + self.log("Received API response from 'get_site': {0}".format( + str(response_data)), "DEBUG") current_site = self.get_current_site(response_data) if current_site: site_exists = True - self.log("Site '{0}' exists in Cisco Catalyst Center".format(site_name_hierarchy), "INFO") + self.log("Site '{0}' exists in Cisco Catalyst Center".format( + site_name_hierarchy), "INFO") else: - self.log("No valid site details found for '{0}'".format(site_name_hierarchy), "WARNING") + self.log("No valid site details found for '{0}'".format( + site_name_hierarchy), "WARNING") return site_exists, current_site @@ -703,21 +715,26 @@ def get_parent_id(self, parent_name): the query, the method logs the appropriate message and returns None. """ parent_id = None - self.log("Starting retrieval of parent site ID for site name: '{}'".format(parent_name), "DEBUG") + self.log("Starting retrieval of parent site ID for site name: '{}'".format( + parent_name), "DEBUG") try: parent_response = self.get_site(parent_name) parent_response = parent_response.get("response") if not parent_response: - self.log("No data found for site '{}'. Site does not exist.".format(parent_name), "INFO") + self.log("No data found for site '{}'. Site does not exist.".format( + parent_name), "INFO") return None parent_id = parent_response[0].get("id") if parent_id: - self.log("Parent site ID for site '{}' successfully retrieved: {}".format(parent_name, parent_id), "DEBUG") + self.log("Parent site ID for site '{}' successfully retrieved: {}".format( + parent_name, parent_id), "DEBUG") else: - self.log("Parent site ID for site '{}' could not be retrieved from response.".format(parent_name), "WARNING") + self.log("Parent site ID for site '{}' could not be retrieved from response.".format( + parent_name), "WARNING") except Exception as e: - self.log("An error occurred while retrieving site '{}': {}".format(parent_name, str(e)), "ERROR") + self.log("An error occurred while retrieving site '{}': {}".format( + parent_name, str(e)), "ERROR") return parent_id def get_site_params(self, params): @@ -809,11 +826,13 @@ def get_site_name_hierarchy(self, site): self.log("Retrieving site name for site data: {}".format(site), "DEBUG") site_type = site.get("type") - parent_name = site.get("site", {}).get(site_type, {}).get("parent_name") + parent_name = site.get("site", {}).get( + site_type, {}).get("parent_name") self.log("Identified site type: {}".format(site_type), "DEBUG") self.log("Retrieved parent name: {}".format(parent_name), "DEBUG") if not parent_name: - self.msg = "Parent name is missing for site type '{}' in the playbook.".format(site_type) + self.msg = "Parent name is missing for site type '{}' in the playbook.".format( + site_type) self.result["response"] = self.msg self.set_operation_result("failed", False, self.msg, "ERROR") return None @@ -822,17 +841,20 @@ def get_site_name_hierarchy(self, site): self.log("Retrieved site name: {}".format(name), "DEBUG") if not name: - self.msg = "Site name is missing for site type '{}' in the playbook.".format(site_type) + self.msg = "Site name is missing for site type '{}' in the playbook.".format( + site_type) self.result["response"] = self.msg self.set_operation_result("failed", False, self.msg, "ERROR") return None site_name_hierarchy = '/'.join([parent_name, name]) - self.log("Constructed site name: {}".format(site_name_hierarchy), "INFO") + self.log("Constructed site name: {}".format( + site_name_hierarchy), "INFO") return site_name_hierarchy except Exception as e: - error_message = "An error occurred while getting site name: {}".format(str(e)) + error_message = "An error occurred while getting site name: {}".format( + str(e)) self.log(error_message, "ERROR") return None @@ -853,10 +875,12 @@ def get_bulk_site_names(self, site, bulk_operation=True): based on the Cisco Catalyst Center version. It logs missing hierarchy information as errors. """ name_list = [] - self.log("Starting bulk site names construction with arguments - site: {}, bulk_operation: {}".format(site, bulk_operation), "DEBUG") + self.log("Starting bulk site names construction with arguments - site: {}, bulk_operation: {}".format( + site, bulk_operation), "DEBUG") if not self.config or not isinstance(self.config, list) or not self.config[0].get('site'): - self.log("Configuration data for sites is missing or improperly formatted.", "ERROR") + self.log( + "Configuration data for sites is missing or improperly formatted.", "ERROR") return name_list try: @@ -865,42 +889,57 @@ def get_bulk_site_names(self, site, bulk_operation=True): area_name = area.get('name') area_parent_name_hierarchy = area.get('parent_name_hierarchy') if area_name and area_parent_name_hierarchy: - constructed_name = "{}/{}".format(area_parent_name_hierarchy, area_name) + constructed_name = "{}/{}".format( + area_parent_name_hierarchy, area_name) name_list.append(constructed_name) - self.log("Constructed area name: {}".format(constructed_name), "DEBUG") + self.log("Constructed area name: {}".format( + constructed_name), "DEBUG") elif not area_parent_name_hierarchy: - self.log("Missing parent name hierarchy for area: {}".format(area_name), "ERROR") + self.log("Missing parent name hierarchy for area: {}".format( + area_name), "ERROR") self.log("Processing buildings for site names.", "DEBUG") for building in self.config[0].get('site', {}).get('building', []): building_name = building.get('name') - building_parent_name_hierarchy = building.get('parent_name_hierarchy') + building_parent_name_hierarchy = building.get( + 'parent_name_hierarchy') if building_name and building_parent_name_hierarchy: - constructed_name = "{}/{}".format(building_parent_name_hierarchy, building_name) + constructed_name = "{}/{}".format( + building_parent_name_hierarchy, building_name) name_list.append(constructed_name) - self.log("Constructed building name: {}".format(constructed_name), "DEBUG") + self.log("Constructed building name: {}".format( + constructed_name), "DEBUG") elif not building_parent_name_hierarchy: - self.log("Missing parent name hierarchy for building: {}".format(building_name), "ERROR") + self.log("Missing parent name hierarchy for building: {}".format( + building_name), "ERROR") self.log("Processing floors for site names.", "DEBUG") for floor in self.config[0].get('site', {}).get('floor', []): floor_name = floor.get('name') - floor_parent_name_hierarchy = floor.get('parent_name_hierarchy') + floor_parent_name_hierarchy = floor.get( + 'parent_name_hierarchy') if floor_name and floor_parent_name_hierarchy: - constructed_name = "{}/{}".format(floor_parent_name_hierarchy, floor_name) + constructed_name = "{}/{}".format( + floor_parent_name_hierarchy, floor_name) name_list.append(constructed_name) - self.log("Constructed floor name: {}".format(constructed_name), "DEBUG") + self.log("Constructed floor name: {}".format( + constructed_name), "DEBUG") elif not floor_parent_name_hierarchy: - self.log("Missing parent name hierarchy for floor: {}".format(floor_name), "ERROR") + self.log("Missing parent name hierarchy for floor: {}".format( + floor_name), "ERROR") if not name_list: - self.log("No site names constructed from areas, buildings, or floors.", "WARNING") + self.log( + "No site names constructed from areas, buildings, or floors.", "WARNING") else: - self.log("Final constructed site names: {}".format(name_list), "DEBUG") - self.log("Bulk site names construction completed successfully.", "DEBUG") + self.log("Final constructed site names: {}".format( + name_list), "DEBUG") + self.log( + "Bulk site names construction completed successfully.", "DEBUG") except Exception as e: - self.log("An error occurred while constructing site names: {}".format(str(e)), "ERROR") + self.log("An error occurred while constructing site names: {}".format( + str(e)), "ERROR") return name_list @@ -984,14 +1023,18 @@ def is_floor_updated(self, updated_site, requested_site): It checks if the name, rf_model, length, width, and height are equal, indicating that the floor details have been updated. Returns True if the details match, and False otherwise. """ - self.log("Starting floor update check with updated_site: {} and requested_site: {}".format(updated_site, requested_site), "DEBUG") + self.log("Starting floor update check with updated_site: {} and requested_site: {}".format( + updated_site, requested_site), "DEBUG") keys_to_compare = ['length', 'width', 'height'] if updated_site['name'] != requested_site['name']: - self.log("Floor names do not match: updated '{}', requested '{}'".format(updated_site['name'], requested_site['name']), "DEBUG") + self.log("Floor names do not match: updated '{}', requested '{}'".format( + updated_site['name'], requested_site['name']), "DEBUG") return False - updated_rf_model = updated_site.get('rfModel', updated_site.get('rf_model')) + updated_rf_model = updated_site.get( + 'rfModel', updated_site.get('rf_model')) if updated_rf_model != requested_site.get('rfModel'): - self.log("RF model mismatch: updated '{}', requested '{}'".format(updated_rf_model, requested_site.get('rfModel')), "DEBUG") + self.log("RF model mismatch: updated '{}', requested '{}'".format( + updated_rf_model, requested_site.get('rfModel')), "DEBUG") return False if requested_site.get('floorNumber'): @@ -1008,7 +1051,8 @@ def is_floor_updated(self, updated_site, requested_site): for key in keys_to_compare: if not self.compare_float_values(updated_site[key], requested_site[key]): - self.log("Mismatch in '{}': updated '{}', requested '{}'".format(key, updated_site[key], requested_site[key]), "DEBUG") + self.log("Mismatch in '{}': updated '{}', requested '{}'".format( + key, updated_site[key], requested_site[key]), "DEBUG") return False self.log("Floor details match between updated and requested site.", "DEBUG") @@ -1037,27 +1081,35 @@ def site_requires_update(self, config=None): site_type = current_site.get('type') self.log("Current site details: {}".format(current_site), "INFO") updated_site = current_site - requested_site = config.get('site_params', {}).get('site', {}).get(site_type) + requested_site = config.get('site_params', {}).get( + 'site', {}).get(site_type) self.log("Updated Site details: {}".format(updated_site), "INFO") self.log("Requested Site details: {}".format(requested_site), "INFO") if site_type == "building": - needs_update = not self.is_building_updated(updated_site, requested_site) - self.log("Building site requires update: {}".format(needs_update), "DEBUG") + needs_update = not self.is_building_updated( + updated_site, requested_site) + self.log("Building site requires update: {}".format( + needs_update), "DEBUG") return needs_update if site_type == "floor": - needs_update = not self.is_floor_updated(updated_site, requested_site) - self.log("Floor site requires update: {}".format(needs_update), "DEBUG") + needs_update = not self.is_floor_updated( + updated_site, requested_site) + self.log("Floor site requires update: {}".format( + needs_update), "DEBUG") return needs_update if site_type == "area": - needs_update = not self.is_area_updated(updated_site, requested_site) - self.log("Area site requires update: {}".format(needs_update), "DEBUG") + needs_update = not self.is_area_updated( + updated_site, requested_site) + self.log("Area site requires update: {}".format( + needs_update), "DEBUG") return needs_update - self.msg = "Unsupported site type '{0}' given in the playbook.".format(site_type) + self.msg = "Unsupported site type '{0}' given in the playbook.".format( + site_type) self.set_operation_result("failed", False, self.msg, "ERROR") return False @@ -1096,7 +1148,8 @@ def get_have(self, config): } response = self.get_site(have["site_name_hierarchy"]) - self.log("Raw response from get_site: {}".format(response), "DEBUG") + self.log("Raw response from get_site: {}".format( + response), "DEBUG") if not response: self.log("Unexpected response received:", "ERROR") @@ -1105,20 +1158,24 @@ def get_have(self, config): continue if isinstance(response, list): - self.log("Unexpected list returned from get_site, skipping: {}".format(response), "ERROR") + self.log("Unexpected list returned from get_site, skipping: {}".format( + response), "ERROR") continue if isinstance(response, dict): sites = response.get("response", []) if not sites: - self.log("No site information found for name: {0}".format(have["site_name_hierarchy"]), "WARNING") + self.log("No site information found for name: {0}".format( + have["site_name_hierarchy"]), "WARNING") continue for site in sites: if isinstance(site, dict): - self.log("site information found: {0}".format(self.pprint(site)), "INFO") + self.log("site information found: {0}".format( + self.pprint(site)), "INFO") current_site = dict(site.items()) - current_site['parentName'] = site.get('nameHierarchy', '').rsplit('/', 1)[0] if site.get('nameHierarchy') else None + current_site['parentName'] = site.get('nameHierarchy', '').rsplit( + '/', 1)[0] if site.get('nameHierarchy') else None site_exists = True have["site_exists"] = site_exists @@ -1134,30 +1191,36 @@ def get_have(self, config): self.handle_config["floor"].append(have) except Exception as e: - self.log("Error fetching site for name '{0}': {1}".format(have["site_name_hierarchy"], str(e))) + self.log("Error fetching site for name '{0}': {1}".format( + have["site_name_hierarchy"], str(e))) self.have = self.handle_config["have"] self.log("All site information collected from bulk operation(create_config): {0}". format(self.pprint(self.handle_config["create_site"])), "DEBUG") - self.log("All site information collected (have): {0}".format(self.pprint(self.have)), "DEBUG") + self.log("All site information collected (have): {0}".format( + self.pprint(self.have)), "DEBUG") else: site_exists, current_site = self.site_exists() - self.log("Regular operation: Retrieved site existence: {}".format(site_exists), "DEBUG") + self.log("Regular operation: Retrieved site existence: {}".format( + site_exists), "DEBUG") if site_exists: have["site_id"] = current_site.get("siteId") - self.log("SiteId for site version <= 2.3.5.3: {}".format(have["site_id"]), "DEBUG") + self.log("SiteId for site version <= 2.3.5.3: {}".format( + have["site_id"]), "DEBUG") have["site_exists"] = site_exists have["current_site"] = current_site self.have = have - self.log("Final 'have' state updated: {}".format(self.have), "INFO") + self.log("Final 'have' state updated: {}".format( + self.have), "INFO") return self except Exception as e: - self.msg = "An unexpected error occurred while retrieving site details: {}".format(e) + self.msg = "An unexpected error occurred while retrieving site details: {}".format( + e) self.set_operation_result("failed", False, self.msg, "ERROR") def get_want(self, config): @@ -1189,7 +1252,8 @@ def get_want(self, config): for item in config: site_data = item.get('site', {}) site_type = item.get('type') - self.log("Processing site of type: {0}".format(site_type), "INFO") + self.log("Processing site of type: {0}".format( + site_type), "INFO") want = {} if site_type in ['area', 'building', 'floor'] and site_data: @@ -1201,7 +1265,8 @@ def get_want(self, config): want_list.append(want) self.want = want_list - self.log("Desired State (want): {0}".format(self.pprint(self.want)), "INFO") + self.log("Desired State (want): {0}".format( + self.pprint(self.want)), "INFO") return self except Exception as e: @@ -1238,9 +1303,11 @@ def validate_site_input_data(self, config): errormsg.append("Config data is missing.") return errormsg - self.log("Config data found with {0} entries.".format(str(len(config))), "DEBUG") + self.log("Config data found with {0} entries.".format( + str(len(config))), "DEBUG") for entry in config: - self.log("Validating entry in config: {0}".format(str(entry)), "DEBUG") + self.log("Validating entry in config: {0}".format( + str(entry)), "DEBUG") site = entry.get("site", {}) site_type = entry.get("type") name = site.get(site_type, {}).get("name") @@ -1254,7 +1321,8 @@ def validate_site_input_data(self, config): errormsg.append("name should not be None or empty") if parent_name: - self.log("Validating 'parent_name' field:{0} ".format(parent_name), "DEBUG") + self.log("Validating 'parent_name' field:{0} ".format( + parent_name), "DEBUG") param_spec = dict(type="str", length_max=400) validate_str(parent_name, param_spec, "parent_name", errormsg) else: @@ -1263,7 +1331,8 @@ def validate_site_input_data(self, config): if site_type: if site_type not in ("area", "building", "floor"): - errormsg.append("site_type: Invalid value '{0}' for site_type in playbook. Must be one of: area, building, or Floor.".format(site_type)) + errormsg.append( + "site_type: Invalid value '{0}' for site_type in playbook. Must be one of: area, building, or Floor.".format(site_type)) else: errormsg.append("Site_type should not be None or empty") @@ -1277,21 +1346,28 @@ def validate_site_input_data(self, config): latitude = site.get(site_type, {}).get("latitude") if latitude: - self.log("Validating 'latitude' value: " + str(latitude), "DEBUG") + self.log("Validating 'latitude' value: " + + str(latitude), "DEBUG") if not (isinstance(latitude, (float, int)) and -90 <= latitude <= 90): - errormsg.append("Invalid latitude, valid range is -90 to +90.") + errormsg.append( + "Invalid latitude, valid range is -90 to +90.") longitude = site.get(site_type, {}).get("longitude") if longitude: - self.log("Validating 'longitude' value: " + str(longitude), "DEBUG") + self.log("Validating 'longitude' value: " + + str(longitude), "DEBUG") if not (isinstance(longitude, (float, int)) and -180 <= longitude <= 180): - errormsg.append("Invalid longitude. Valid range is -180 to +180.") + errormsg.append( + "Invalid longitude. Valid range is -180 to +180.") if not (latitude and longitude or address): - errormsg.append("Either latitude/longitude or address is required.") - self.log("Missing required latitude/longitude or address for building.", "ERROR") + errormsg.append( + "Either latitude/longitude or address is required.") + self.log( + "Missing required latitude/longitude or address for building.", "ERROR") elif (latitude and not longitude) or (not latitude and longitude): - errormsg.append("Either Latitude or longitude is missing in the given playbook") + errormsg.append( + "Either Latitude or longitude is missing in the given playbook") country = site.get(site_type, {}).get("country") self.log("Validating 'country' field: " + country, "DEBUG") @@ -1299,17 +1375,21 @@ def validate_site_input_data(self, config): param_spec = dict(type="str", length_max=100) validate_str(country, param_spec, "country", errormsg) else: - self.log("Missing 'country' field in building entry.", "ERROR") + self.log( + "Missing 'country' field in building entry.", "ERROR") errormsg.append("country should not be None or empty") if site_type == "floor": self.log("Performing floor-specific validations.", "DEBUG") floor_number = site.get(site_type, {}).get("floor_number") if floor_number: - self.log("Validating 'floor_number': " + str(floor_number), "DEBUG") + self.log("Validating 'floor_number': " + + str(floor_number), "DEBUG") if not (isinstance(floor_number, int) and -200 <= floor_number <= 200): - errormsg.append("Please enter a valid floor number (-200 to 200)") - self.log("Missing 'floor_number' in floor entry.", "ERROR") + errormsg.append( + "Please enter a valid floor number (-200 to 200)") + self.log( + "Missing 'floor_number' in floor entry.", "ERROR") else: errormsg.append("Floor number should not be None or empty") @@ -1334,7 +1414,8 @@ def validate_site_input_data(self, config): if width: self.log("Validating 'width': " + str(width), "DEBUG") if not (isinstance(width, (float, int)) and 5.00 <= width <= 99999.00): - errormsg.append("Invalid width. Valid range is 5.00 to 99999.00 ft.") + errormsg.append( + "Invalid width. Valid range is 5.00 to 99999.00 ft.") else: errormsg.append("Width should not be None or empty") @@ -1342,32 +1423,39 @@ def validate_site_input_data(self, config): if length: self.log("Validating 'length': " + str(length), "DEBUG") if not (isinstance(length, (float, int)) and 5.00 <= length <= 99999.00): - errormsg.append("Invalid length. Valid range is 5.00 to 99999.00 ft.") + errormsg.append( + "Invalid length. Valid range is 5.00 to 99999.00 ft.") else: errormsg.append("length should not be None or empty") height = site.get(site_type, {}).get("height") if height: if not (isinstance(height, (float, int)) and 3.00 <= height <= 99999.00): - errormsg.append("Invalid height. Valid range is 3.00 to 99999.00 ft.") + errormsg.append( + "Invalid height. Valid range is 3.00 to 99999.00 ft.") else: errormsg.append("height should not be None or empty") - units_of_measure = site.get(site_type, {}).get("units_of_measure") + units_of_measure = site.get( + site_type, {}).get("units_of_measure") if units_of_measure: if units_of_measure not in ("feet", "meters"): errormsg.append( "units_of_measure: Invalid value '{0}' for units_of_measure in playbook. Must be one of 'feet' or 'meters'.".format( units_of_measure)) else: - errormsg.append("units_of_measure should not be None or empty") + errormsg.append( + "units_of_measure should not be None or empty") - upload_floor_image_path = site.get(site_type, {}).get("upload_floor_image_path") + upload_floor_image_path = site.get( + site_type, {}).get("upload_floor_image_path") if upload_floor_image_path: param_spec = dict(type="str", length_max=500) - validate_str(upload_floor_image_path, param_spec, "upload_floor_image_path", errormsg) + validate_str(upload_floor_image_path, param_spec, + "upload_floor_image_path", errormsg) elif upload_floor_image_path == "": - errormsg.append("upload_floor_image_path should not be whitespace") + errormsg.append( + "upload_floor_image_path should not be whitespace") if self.compare_dnac_versions(self.get_ccc_version(), "2.3.5.3") <= 0: if upload_floor_image_path: @@ -1377,7 +1465,8 @@ def validate_site_input_data(self, config): ) if len(errormsg) > 0: - self.msg = "Invalid parameters in playbook config: '{0}' ".format(", ".join(errormsg)) + self.msg = "Invalid parameters in playbook config: '{0}' ".format( + ", ".join(errormsg)) self.log(self.msg, "ERROR") self.status = "failed" return self @@ -1408,34 +1497,44 @@ def update_floor(self, site_params, config): "Drywall Office Only" ] try: - self.log("Updating floor with parameters: {0}".format(site_params), "INFO") - parent_name = site_params.get("site", {}).get("floor", {}).get("parentName") + self.log("Updating floor with parameters: {0}".format( + site_params), "INFO") + parent_name = site_params.get("site", {}).get( + "floor", {}).get("parentName") if not parent_name: self.log("Parent name is missing in the site parameters.", "ERROR") return None parent_id = self.get_parent_id(parent_name) if not parent_id: - self.log("Failed to retrieve parent ID for parent name: '{}'".format(parent_name), "ERROR") + self.log("Failed to retrieve parent ID for parent name: '{}'".format( + parent_name), "ERROR") return None site_params['site']['floor']['parentId'] = parent_id - self.log("Retrieved parent ID: '{}' for parent name: '{}'".format(parent_id, parent_name), "DEBUG") + self.log("Retrieved parent ID: '{}' for parent name: '{}'".format( + parent_id, parent_name), "DEBUG") units_of_measure_value = config.get("unitsOfMeasure") if units_of_measure_value not in units_of_measure: - error_msg = "Given Unit of Measure: {} not in allowed units: {}".format(units_of_measure_value, units_of_measure) + error_msg = "Given Unit of Measure: {} not in allowed units: {}".format( + units_of_measure_value, units_of_measure) self.module.fail_json(msg=error_msg) else: site_params['site']['floor']['unitsOfMeasure'] = units_of_measure_value - self.log("Set 'units of measure' to: {}".format(units_of_measure_value), "DEBUG") + self.log("Set 'units of measure' to: {}".format( + units_of_measure_value), "DEBUG") - rf_model_value = site_params.get('site', {}).get('floor', {}).get('rfModel') + rf_model_value = site_params.get( + 'site', {}).get('floor', {}).get('rfModel') if rf_model_value not in rf_model: - error_msg = "Given RF Model: {} not in valid models: {}".format(rf_model_value, rf_model) + error_msg = "Given RF Model: {} not in valid models: {}".format( + rf_model_value, rf_model) self.module.fail_json(msg=error_msg) else: - self.log("Validated 'RF Model' as: {}".format(rf_model_value), "DEBUG") + self.log("Validated 'RF Model' as: {}".format( + rf_model_value), "DEBUG") - self.log("Updated site_params with parent_id: {0}".format(site_params), "INFO") + self.log("Updated site_params with parent_id: {0}".format( + site_params), "INFO") floor_param = site_params.get('site', {}).get('floor') site_params['site']['floor']['parentId'] = parent_id site_id = site_params.get("site_id") @@ -1449,18 +1548,22 @@ def update_floor(self, site_params, config): ) if response and isinstance(response, dict): - self.log("Initial API response from 'updates_a_floor': {0}".format(response), "DEBUG") + self.log("Initial API response from 'updates_a_floor': {0}".format( + response), "DEBUG") execution_id = response.get("executionId") if execution_id: while True: - execution_details = self.get_execution_details(execution_id) + execution_details = self.get_execution_details( + execution_id) if execution_details.get("status") == "SUCCESS": - self.log("Floor update completed successfully.", "INFO") + self.log( + "Floor update completed successfully.", "INFO") break elif execution_details.get("bapiError"): self.status = "failed" - self.msg = "Error during floor update execution: {0}".format(execution_details.get("bapiError")), "ERROR" + self.msg = "Error during floor update execution: {0}".format( + execution_details.get("bapiError")), "ERROR" self.result['response'] = self.msg self.log(self.msg, "ERROR") break @@ -1485,30 +1588,37 @@ def update_building(self, site_params): """ response = None try: - self.log("Updating building with parameters: {0}".format(site_params), "INFO") - parent_name = site_params.get("site", {}).get("building", {}).get("parentName") + self.log("Updating building with parameters: {0}".format( + site_params), "INFO") + parent_name = site_params.get("site", {}).get( + "building", {}).get("parentName") parent_id = self.get_parent_id(parent_name) site_params['site']['building']['parentId'] = parent_id - self.log("Updated site_params with parent_id: {0}".format(self.pprint(site_params)), "INFO") + self.log("Updated site_params with parent_id: {0}".format( + self.pprint(site_params)), "INFO") building_param = site_params.get('site', {}).get('building') site_id = site_params.get("site_id") building_param['id'] = site_id - self.log("Before updating the building params:{0}".format(self.pprint(building_param)), "INFO") + self.log("Before updating the building params:{0}".format( + self.pprint(building_param)), "INFO") response = self.dnac._exec( family="site_design", function='updates_a_building', op_modifies=True, params=building_param, ) - self.log("Building update successful. API response: {0}".format(response), "DEBUG") + self.log("Building update successful. API response: {0}".format( + response), "DEBUG") return response except Exception as e: - self.msg = "Exception occurred while updating building '{0}' due to: {1}".format(site_params.get('site_name_hierarchy'), str(e)) + self.msg = "Exception occurred while updating building '{0}' due to: {1}".format( + site_params.get('site_name_hierarchy'), str(e)) self.result['response'] = self.msg - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() def update_area(self, site_params): """ @@ -1522,13 +1632,15 @@ def update_area(self, site_params): """ response = None try: - self.log("Updating area with parameters: {0}".format(self.have), "INFO") + self.log("Updating area with parameters: {0}".format( + self.have), "INFO") parent_id = self.have.get("current_site", {}).get("parentId") site_params['site']['area']['parentId'] = parent_id area_param = site_params.get('site', {}).get('area') site_id = self.have.get("site_id") area_param['id'] = site_id - self.log("Updating area with parameters: {0}".format(area_param), "INFO") + self.log("Updating area with parameters: {0}".format( + area_param), "INFO") response = self.dnac._exec( family="site_design", @@ -1542,9 +1654,11 @@ def update_area(self, site_params): return response except Exception as e: - self.msg = "Exception occurred while updating area'{0}' due to: {1}".format(site_params.get('site_name_hierarchy'), str(e)) + self.msg = "Exception occurred while updating area'{0}' due to: {1}".format( + site_params.get('site_name_hierarchy'), str(e)) self.result['response'] = self.msg - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() def creating_bulk_site(self, params): """ @@ -1567,16 +1681,21 @@ def creating_bulk_site(self, params): ) if not response: - self.log("Site creation failed: No response from the API.", "ERROR") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.log( + "Site creation failed: No response from the API.", "ERROR") + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() return None - self.log("Site creation successful. Response: {0}".format(response), "INFO") + self.log("Site creation successful. Response: {0}".format( + response), "INFO") return response except Exception as e: - self.msg = "Exception occurred while creating site due to: {}".format(str(e)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Exception occurred while creating site due to: {}".format( + str(e)) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() def change_payload_data(self, config): """ @@ -1608,22 +1727,27 @@ def change_payload_data(self, config): for key, value in specific_data.items(): if value is not None: - self.log("Mapping key: " + key + " to value: " + str(value), "DEBUG") + self.log("Mapping key: " + key + + " to value: " + str(value), "DEBUG") mapped_key = self.keymap.get(key, key) payload_data[mapped_key] = value payload_data["type"] = site_type - self.log("Payload data created successfully.", "DEBUG") + self.log( + "Payload data created successfully.", "DEBUG") else: - self.log("Skipping key: " + key + " as value is None.", "DEBUG") + self.log("Skipping key: " + key + + " as value is None.", "DEBUG") else: - self.log("Invalid site type or missing site data in the configuration.", "ERROR") + self.log( + "Invalid site type or missing site data in the configuration.", "ERROR") else: self.log("No configuration data provided.", "ERROR") return payload_data except Exception as e: self.msg = "Unable to process the payload data : {}".format(str(e)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() def get_diff_merged(self, config): """ @@ -1653,52 +1777,66 @@ def get_diff_merged(self, config): if len(create_site) > 0: self.log("Starting site creation process.", "DEBUG") for each_config in create_site: - payload_data = self.change_payload_data(each_config.get("want")) + payload_data = self.change_payload_data( + each_config.get("want")) if payload_data: payload_data[self.keymap["parent_name_hierarchy"]] =\ payload_data.get(self.keymap["parent_name"]) del payload_data[self.keymap["parent_name"]] - self.log("Payload data prepared for site creation: {}".format(payload_data), "DEBUG") + self.log("Payload data prepared for site creation: {}".format( + payload_data), "DEBUG") if payload_data.get("type") == "area": self.handle_config["area"].append(payload_data) - self.log("Added to area: {}".format(payload_data), "DEBUG") + self.log("Added to area: {}".format( + payload_data), "DEBUG") elif payload_data.get("type") == "building": self.handle_config["building"].append(payload_data) - self.log("Added to building: {}".format(payload_data), "DEBUG") + self.log("Added to building: {}".format( + payload_data), "DEBUG") elif payload_data.get("type") == "floor": self.handle_config["floor"].append(payload_data) - self.log("Added to floor: {}".format(payload_data), "DEBUG") + self.log("Added to floor: {}".format( + payload_data), "DEBUG") for each_type in ("area", "building", "floor"): if self.handle_config[each_type]: - response = self.creating_bulk_site(self.handle_config[each_type]) - self.log("Response from creating_bulk_site for {}: {}".format(each_type, response), "DEBUG") + response = self.creating_bulk_site( + self.handle_config[each_type]) + self.log("Response from creating_bulk_site for {}: {}".format( + each_type, response), "DEBUG") if response and isinstance(response, dict) and "response" in response: task_id = response["response"].get("taskId") if task_id: - self.log("Task Id for the 'site_creation' task is {}".format(task_id), "INFO") + self.log("Task Id for the 'site_creation' task is {}".format( + task_id), "INFO") task_name = "create_sites" success_msg = "Site created successfully." - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) for site in self.handle_config[each_type]: if "name" in site: - self.created_site_list.append(str(each_type) + ": " + site.get("name")) - self.log("Site '{}' created successfully".format(self.created_site_list), "INFO") + self.created_site_list.append( + str(each_type) + ": " + site.get("name")) + self.log("Site '{}' created successfully".format( + self.created_site_list), "INFO") for site in self.handle_config[each_type]: if site.get("type") == "floor": floor_name = site.get("name") - self.log("Floor '{}' has been created successfully.".format(floor_name), "INFO") + self.log("Floor '{}' has been created successfully.".format( + floor_name), "INFO") - upload_path = site.get("upload_floor_image_path", None) + upload_path = site.get( + "upload_floor_image_path", None) if upload_path: self.log("Upload path found for floor '{}'. Starting upload floor map from '{}.'". format(floor_name, upload_path), "INFO") - map_details, map_status, success_message = self.upload_floor_image(site) + map_details, map_status, success_message = self.upload_floor_image( + site) if map_details: self.log("Floor map for '{}' uploaded successfully: {}". format(floor_name, success_message), "INFO") @@ -1709,30 +1847,38 @@ def get_diff_merged(self, config): self.log("No upload path provided for '{}'. Floor created without floor map.". format(floor_name), "INFO") else: - self.log("No valid task ID received from the 'creating_bulk_site' response.", "WARNING") + self.log( + "No valid task ID received from the 'creating_bulk_site' response.", "WARNING") return None else: - self.log("No response received from the 'creating_bulk_site' API call.", "WARNING") + self.log( + "No response received from the 'creating_bulk_site' API call.", "WARNING") return None task_detail_list = [] for each_config in self.have: - site_name_hierarchy = each_config.get("site_name_hierarchy") + site_name_hierarchy = each_config.get( + "site_name_hierarchy") if each_config.get("site_exists"): - self.log("Processing site: {}".format(site_name_hierarchy), "DEBUG") - payload_new = self.change_payload_data(each_config.get("want")) + self.log("Processing site: {}".format( + site_name_hierarchy), "DEBUG") + payload_new = self.change_payload_data( + each_config.get("want")) if payload_new.get("type") == "area": - self.msg = "Site - {0} does not need any update".format(site_name_hierarchy) + self.msg = "Site - {0} does not need any update".format( + site_name_hierarchy) self.log(self.msg, "INFO") - self.update_not_needed_sites.append(payload_new.get("type") + ": " + site_name_hierarchy) + self.update_not_needed_sites.append( + payload_new.get("type") + ": " + site_name_hierarchy) elif payload_new.get("type") in ("building", "floor"): site_params = each_config.get("site_params") site_params["site_id"] = each_config.get("site_id") site_type = site_params.get("type") if self.site_requires_update(each_config): - self.log("Site requires update, starting update for type: {}".format(site_type), "DEBUG") + self.log("Site requires update, starting update for type: {}".format( + site_type), "DEBUG") response = (self.update_floor(site_params, payload_new) if site_type == "floor" else self.update_area(site_params) if site_type == "area" else self.update_building(site_params) if site_type == "building" @@ -1743,19 +1889,25 @@ def get_diff_merged(self, config): if response and isinstance(response, dict): taskid = response["response"]["taskId"] - task_details = self.get_task_details(taskid) + task_details = self.get_task_details( + taskid) while True: if site_type != "floor": if task_details.get("progress") == "Group is updated successfully": - task_detail_list.append(task_details) - self.updated_site_list.append(site_type + ": " + site_name_hierarchy) - self.log("Site '{}' updated successfully.".format(site_name_hierarchy), "INFO") + task_detail_list.append( + task_details) + self.updated_site_list.append( + site_type + ": " + site_name_hierarchy) + self.log("Site '{}' updated successfully.".format( + site_name_hierarchy), "INFO") break else: if task_details.get("progress") == "Service domain is updated successfully.": - task_detail_list.append(task_details) - self.updated_site_list.append(site_type + ": " + site_name_hierarchy) + task_detail_list.append( + task_details) + self.updated_site_list.append( + site_type + ": " + site_name_hierarchy) break if task_details.get("bapiError"): @@ -1764,13 +1916,17 @@ def get_diff_merged(self, config): task_details).check_return_status() break else: - self.msg = "Unable to execute the update the site: {0} ".format(site_name_hierarchy) + self.msg = "Unable to execute the update the site: {0} ".format( + site_name_hierarchy) self.log(self.msg, "INFO") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() else: - self.msg = "Site - {0} does not need any update".format(site_name_hierarchy) + self.msg = "Site - {0} does not need any update".format( + site_name_hierarchy) self.log(self.msg, "INFO") - self.update_not_needed_sites.append(payload_new.get("type") + ": " + site_name_hierarchy) + self.update_not_needed_sites.append( + payload_new.get("type") + ": " + site_name_hierarchy) except Exception as e: self.log("Yaml is not available for bulk: {}".format(e), "ERROR") @@ -1782,13 +1938,16 @@ def get_diff_merged(self, config): if self.have.get("site_exists"): site_name_hierarchy = self.want.get("site_name_hierarchy") if not self.site_requires_update(): - self.update_not_needed_sites.append(site_type + ": " + site_name_hierarchy) - self.msg = "Site - {0} does not need any update".format(site_name_hierarchy) + self.update_not_needed_sites.append( + site_type + ": " + site_name_hierarchy) + self.msg = "Site - {0} does not need any update".format( + site_name_hierarchy) self.log(self.msg, "INFO") else: try: site_params["site_id"] = self.have.get("site_id") - self.log("Site parameters prepared for update: {}".format(site_params)) + self.log( + "Site parameters prepared for update: {}".format(site_params)) self.log("Site update process started.", "INFO") if site_params['site'].get('building'): @@ -1805,25 +1964,31 @@ def get_diff_merged(self, config): op_modifies=True, params=site_params, ) - self.log("Received API response from 'update_site': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'update_site': {0}".format( + str(response)), "DEBUG") if response and isinstance(response, dict): execution_id = response.get("executionId") while True: - execution_details = self.get_execution_details(execution_id) + execution_details = self.get_execution_details( + execution_id) if execution_details.get("status") == "SUCCESS": self.result['changed'] = True site_updated = True - self.updated_site_list.append(site_type + ": " + site_name_hierarchy) - self.log("Site - {0} Updated Successfully".format(site_name_hierarchy), "INFO") + self.updated_site_list.append( + site_type + ": " + site_name_hierarchy) + self.log( + "Site - {0} Updated Successfully".format(site_name_hierarchy), "INFO") break elif execution_details.get("bapiError"): - self.msg = "Unable to Update: " + execution_details.get("bapiError") + self.msg = "Unable to Update: " + \ + execution_details.get("bapiError") self.set_operation_result("failed", False, self.msg, "ERROR", execution_details).check_return_status() except Exception as e: - self.msg = "Unexpected error occurred while update: {0}".format(str(e)) + self.msg = "Unexpected error occurred while update: {0}".format( + str(e)) self.log(self.msg, "ERROR") self.set_operation_result("failed", False, self.msg, "ERROR", site_name_hierarchy).check_return_status() @@ -1851,30 +2016,37 @@ def get_diff_merged(self, config): op_modifies=True, params=site_params, ) - self.log("Received API response from 'create_site': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'create_site': {0}".format( + str(response)), "DEBUG") if response and isinstance(response, dict): executionid = response.get("executionId") while True: - execution_details = self.get_execution_details(executionid) + execution_details = self.get_execution_details( + executionid) if execution_details.get("status") == "SUCCESS": self.result['changed'] = True break elif execution_details.get("bapiError"): - self.msg = "Unable to Create: " + execution_details.get("bapiError") + self.msg = "Unable to Create: " + \ + execution_details.get("bapiError") self.set_operation_result("failed", False, self.msg, "ERROR", execution_details).check_return_status() break site_exists, current_site = self.site_exists() if site_exists: - site_name_hierarchy = self.want.get("site_name_hierarchy") - self.created_site_list.append(site_type + ": " + site_name_hierarchy) - self.log("Site '{0}' created successfully".format(site_name_hierarchy), "INFO") + site_name_hierarchy = self.want.get( + "site_name_hierarchy") + self.created_site_list.append( + site_type + ": " + site_name_hierarchy) + self.log("Site '{0}' created successfully".format( + site_name_hierarchy), "INFO") return self except Exception as e: - self.msg = "Unexpected error occurred while create: {0}".format(str(e)) + self.msg = "Unexpected error occurred while create: {0}".format( + str(e)) self.log(self.msg, "ERROR") self.set_operation_result("failed", False, self.msg, "ERROR", site_name_hierarchy).check_return_status() @@ -1904,7 +2076,8 @@ def delete_single_site(self, site_id, site_name_hierarchy): params={"site_id": site_id}, ) if response and isinstance(response, dict): - self.log("Received API response from 'delete_site': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'delete_site': {0}".format( + str(response)), "DEBUG") executionid = response.get("executionId") while True: @@ -1912,7 +2085,8 @@ def delete_single_site(self, site_id, site_name_hierarchy): if execution_details.get("status") == "SUCCESS": self.status = "success" self.deleted_site_list.append(site_name_hierarchy) - self.log("Site '{0}' deleted successfully".format(site_name_hierarchy), "INFO") + self.log("Site '{0}' deleted successfully".format( + site_name_hierarchy), "INFO") break elif execution_details.get("bapiError"): self.log("Error response for 'delete_site' execution: {0}".format( @@ -1922,7 +2096,8 @@ def delete_single_site(self, site_id, site_name_hierarchy): break except Exception as e: - self.msg = "Exception occurred while deleting site '{0}' due to: {1}".format(site_name_hierarchy, str(e)) + self.msg = "Exception occurred while deleting site '{0}' due to: {1}".format( + site_name_hierarchy, str(e)) self.set_operation_result("failed", False, self.msg, "ERROR") return self @@ -1940,7 +2115,8 @@ def delete_floor(self, site_name_hierarchy, site_id): """ if not site_id: - self.log("No site ID found for building site: '{}'.".format(site_name_hierarchy), "ERROR") + self.log("No site ID found for building site: '{}'.".format( + site_name_hierarchy), "ERROR") return None try: self.log( @@ -1951,11 +2127,14 @@ def delete_floor(self, site_name_hierarchy, site_id): op_modifies=True, params={'id': site_id}, ) - self.log("Successfully deleted floor site: {0}. API response: {1}".format(site_name_hierarchy, response), "DEBUG") + self.log("Successfully deleted floor site: {0}. API response: {1}".format( + site_name_hierarchy, response), "DEBUG") return response except Exception as e: - self.msg = "Exception occurred while deleting floor site '{0}' with site_id '{1}' due to: {2}".format(site_name_hierarchy, site_id, str(e)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Exception occurred while deleting floor site '{0}' with site_id '{1}' due to: {2}".format( + site_name_hierarchy, site_id, str(e)) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() def delete_building(self, site_name_hierarchy, site_id): """ @@ -1970,12 +2149,14 @@ def delete_building(self, site_name_hierarchy, site_id): """ if not site_id: - self.log("No site ID found for building site: '{}'.".format(site_name_hierarchy), "ERROR") + self.log("No site ID found for building site: '{}'.".format( + site_name_hierarchy), "ERROR") return None try: - self.log("Deleting building site '{0}' with ID: '{1}'".format(site_name_hierarchy, site_id), "INFO") + self.log("Deleting building site '{0}' with ID: '{1}'".format( + site_name_hierarchy, site_id), "INFO") response = self.dnac._exec( family="site_design", @@ -1983,12 +2164,15 @@ def delete_building(self, site_name_hierarchy, site_id): op_modifies=True, params={'id': site_id}, ) - self.log("Successfully deleted building site: {0}. API response: {1}".format(site_name_hierarchy, response), "DEBUG") + self.log("Successfully deleted building site: {0}. API response: {1}".format( + site_name_hierarchy, response), "DEBUG") return response except Exception as e: - self.msg = "Exception occurred while deleting building site '{0}' with site_id '{1}' due to: {2}".format(site_name_hierarchy, site_id, str(e)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Exception occurred while deleting building site '{0}' with site_id '{1}' due to: {2}".format( + site_name_hierarchy, site_id, str(e)) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() def delete_area(self, site_name_hierarchy, site_id): """ @@ -2003,23 +2187,28 @@ def delete_area(self, site_name_hierarchy, site_id): """ if not site_id: - self.log("No site ID found for building site: '{}'.".format(site_name_hierarchy), "ERROR") + self.log("No site ID found for building site: '{}'.".format( + site_name_hierarchy), "ERROR") return None try: - self.log("Deleting area site: {0} with ID: {1}".format(site_name_hierarchy, site_id), "INFO") + self.log("Deleting area site: {0} with ID: {1}".format( + site_name_hierarchy, site_id), "INFO") response = self.dnac._exec( family="site_design", function="deletes_an_area", op_modifies=True, params={'id': site_id}, ) - self.log("Successfully deleted farea site: {0}. API response: {1}".format(site_name_hierarchy, response), "DEBUG") + self.log("Successfully deleted farea site: {0}. API response: {1}".format( + site_name_hierarchy, response), "DEBUG") return response except Exception as e: - self.msg = "Exception occurred while deleting area site '{0}' with site_id '{1}' due to: {2}".format(site_name_hierarchy, site_id, str(e)) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.msg = "Exception occurred while deleting area site '{0}' with site_id '{1}' due to: {2}".format( + site_name_hierarchy, site_id, str(e)) + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() def get_diff_deleted(self, config): """ @@ -2051,7 +2240,8 @@ def get_diff_deleted(self, config): return self site_id = self.have.get("site_id") site_name_hierarchy = self.want.get("site_name_hierarchy") - api_response, response = self.get_device_ids_from_site(site_name_hierarchy, site_id) + api_response, response = self.get_device_ids_from_site( + site_name_hierarchy, site_id) self.log( "Received API response from 'get_membership': {0}".format(str(api_response)), "DEBUG") @@ -2078,16 +2268,19 @@ def get_diff_deleted(self, config): final_deletion_list = [] for each_type in ("floor", "building", "area"): if self.handle_config[each_type]: - self.log("Starting bulk site creation for type: {}".format(each_type), "DEBUG") + self.log("Starting bulk site creation for type: {}".format( + each_type), "DEBUG") for config in self.handle_config[each_type]: site_exists = config.get("site_exists") if not site_exists: self.log("Unable to delete site {0} as it's not found in Cisco Catalyst Center". format(config.get("site_name_hierarchy")), "INFO") - self.site_absent_list.append(each_type + ": " + config.get("site_name_hierarchy")) + self.site_absent_list.append( + each_type + ": " + config.get("site_name_hierarchy")) else: final_deletion_list.append(config) - self.log("Deletion list re-arranged order: {0}.".format(self.pprint(final_deletion_list)), "INFO") + self.log( + "Deletion list re-arranged order: {0}.".format(self.pprint(final_deletion_list)), "INFO") if len(final_deletion_list) > 0: for config in final_deletion_list: @@ -2096,22 +2289,30 @@ def get_diff_deleted(self, config): site_params["site_id"] = config.get("site_id") site_type = site_params.get("type") site_id = site_params["site_id"] - self.log("Site ID from 'have' for retrieval: {0}".format(site_id), "DEBUG") - self.log("Site TYPE from 'have' for retrieval: {0}".format(site_type), "DEBUG") - self.log("Site PARAMS from 'have' for retrieval: {0}".format(site_params), "DEBUG") - self.log("Site NAME from 'want' for retrieval: {0}".format(site_name_hierarchy), "DEBUG") + self.log("Site ID from 'have' for retrieval: {0}".format( + site_id), "DEBUG") + self.log("Site TYPE from 'have' for retrieval: {0}".format( + site_type), "DEBUG") + self.log("Site PARAMS from 'have' for retrieval: {0}".format( + site_params), "DEBUG") + self.log("Site NAME from 'want' for retrieval: {0}".format( + site_name_hierarchy), "DEBUG") self.log("Initiating deletion for site '{0}' with site ID: {1} of type: {2}".format( site_name_hierarchy, site_id, site_type), "DEBUG") response = None if site_type == "floor": - response = self.delete_floor(site_name_hierarchy, site_id) + response = self.delete_floor( + site_name_hierarchy, site_id) elif site_type == "area": - response = self.delete_area(site_name_hierarchy, site_id) - self.log("Response for deleting area: {0}".format(str(response)), "DEBUG") + response = self.delete_area( + site_name_hierarchy, site_id) + self.log("Response for deleting area: {0}".format( + str(response)), "DEBUG") elif site_type == "building": - response = self.delete_building(site_name_hierarchy, site_id) + response = self.delete_building( + site_name_hierarchy, site_id) if isinstance(response, dict): task_id = response.get("response", {}).get("taskId") @@ -2121,39 +2322,48 @@ def get_diff_deleted(self, config): while True: if site_type == "area": if task_details.get("progress") == "Group is deleted successfully": - self.msg = "Area '{0}' deleted successfully.".format(site_name_hierarchy) + self.msg = "Area '{0}' deleted successfully.".format( + site_name_hierarchy) self.log(self.msg, "INFO") self.result['changed'] = True self.result['response'] = task_details - self.deleted_site_list.append(site_type + ": " + site_name_hierarchy) + self.deleted_site_list.append( + site_type + ": " + site_name_hierarchy) break elif task_details.get("failureReason"): - self.msg = "Error response for 'deletes_an_area' task: {0}".format(task_details.get('failureReason')) + self.msg = "Error response for 'deletes_an_area' task: {0}".format( + task_details.get('failureReason')) self.log(self.msg, "ERROR") self.set_operation_result("failed", False, self.msg, "ERROR", task_details).check_return_status() break elif site_type == "building": if task_details.get("progress") == "Group is deleted successfully": - self.msg = "Building '{0}' deleted successfully.".format(site_name_hierarchy) + self.msg = "Building '{0}' deleted successfully.".format( + site_name_hierarchy) self.log(self.msg, "INFO") self.result['changed'] = True self.result['response'] = task_details - self.deleted_site_list.append(site_type + ": " + site_name_hierarchy) + self.deleted_site_list.append( + site_type + ": " + site_name_hierarchy) break elif task_details.get("failureReason"): - self.msg = "Error response for 'deletes_building' task: {0}".format(task_details.get('failureReason')) + self.msg = "Error response for 'deletes_building' task: {0}".format( + task_details.get('failureReason')) self.log(self.msg, "ERROR") self.set_operation_result("failed", False, self.msg, "ERROR", task_details).check_return_status() break else: if task_details.get("progress") == "NCMP00150: Service domain is deleted successfully": - self.log("Area site '{0}' deleted successfully.".format(site_name_hierarchy), "INFO") - self.deleted_site_list.append(site_type + ": " + site_name_hierarchy) + self.log("Area site '{0}' deleted successfully.".format( + site_name_hierarchy), "INFO") + self.deleted_site_list.append( + site_type + ": " + site_name_hierarchy) break elif task_details.get("failureReason"): - self.msg = "Error response for 'deletes_an_floor' task: {0}".format(task_details.get('failureReason')) + self.msg = "Error response for 'deletes_an_floor' task: {0}".format( + task_details.get('failureReason')) self.set_operation_result("failed", False, self.msg, "ERROR", task_details).check_return_status() break @@ -2182,18 +2392,22 @@ def verify_diff_merged(self, config): for each_site in self.handle_config.get("have", []) if each_site.get("site_exists") ] - self.log("COUNTS: {0}, {1}".format(config_count, str(site_exist_list)), "INFO") + self.log("COUNTS: {0}, {1}".format( + config_count, str(site_exist_list)), "INFO") if len(site_exist_list) == config_count and len(self.update_not_needed_sites) < 1: - self.msg = "The requested site '{0}' is present in the Cisco Catalyst Center and its creation has been verified.".format(site_exist_list) + self.msg = "The requested site '{0}' is present in the Cisco Catalyst Center and its creation has been verified.".format( + site_exist_list) self.log(self.msg, "INFO") - self.set_operation_result("success", True, self.msg, "INFO", str(site_exist_list)) + self.set_operation_result( + "success", True, self.msg, "INFO", str(site_exist_list)) elif len(self.update_not_needed_sites) > 0: self.update_site_messages().check_return_status() else: msg = """Mismatch between the playbook input for site '{0}' and the Cisco Catalyst Center indicates that the deletion was not executed successfully.""".format(site_exist_list) self.log(msg, "INFO") - self.set_operation_result("success", False, self.msg, "INFO", site_exist_list) + self.set_operation_result( + "success", False, self.msg, "INFO", site_exist_list) return self @@ -2210,13 +2424,15 @@ def verify_diff_merged(self, config): if site_exist: self.status = "success" - self.msg = "The requested site '{0}' is present in the Cisco Catalyst Center and its creation has been verified.".format(site_name_hierarchy) + self.msg = "The requested site '{0}' is present in the Cisco Catalyst Center and its creation has been verified.".format( + site_name_hierarchy) self.log(self.msg, "INFO") require_update = self.site_requires_update() if not require_update: - self.log("The update for site '{0}' has been successfully verified.".format(site_name_hierarchy), "INFO") + self.log("The update for site '{0}' has been successfully verified.".format( + site_name_hierarchy), "INFO") self.status = "success" return self @@ -2250,18 +2466,22 @@ def verify_diff_deleted(self, config): msg = """The requested site(s) '{0}' has already been deleted from the Cisco Catalyst Center and this has been successfully verified.""".format(site_not_exist_list) self.log(msg, "INFO") - self.set_operation_result("success", True, msg, "INFO", str(site_not_exist_list)) + self.set_operation_result( + "success", True, msg, "INFO", str(site_not_exist_list)) else: msg = """Mismatch between the playbook input for site '{0}' and the Cisco Catalyst Center indicates that the deletion was not executed successfully.""".format(site_not_exist_list) self.log(msg, "INFO") - self.set_operation_result("success", False, msg, "INFO", site_not_exist_list) + self.set_operation_result( + "success", False, msg, "INFO", site_not_exist_list) return self else: self.get_have(config) - self.log("Current State (have): {0}".format(str(self.have)), "INFO") - self.log("Desired State (want): {0}".format(str(self.want)), "INFO") + self.log("Current State (have): {0}".format( + str(self.have)), "INFO") + self.log("Desired State (want): {0}".format( + str(self.want)), "INFO") site_exist = self.have.get("site_exists") if not site_exist: @@ -2370,21 +2590,26 @@ def upload_floor_image(self, config): try: self.log("Starting upload_floor_image function", "DEBUG") file_path = config.get('upload_floor_image_path') - self.log("File path extracted from config: {}".format(file_path), "DEBUG") + self.log("File path extracted from config: {}".format( + file_path), "DEBUG") if not isinstance(file_path, str) or not file_path: msg = "Invalid file path format. It must be a non-empty string." - self.set_operation_result("failed", False, msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, msg, "ERROR").check_return_status() if not os.path.exists(file_path): msg = "File path does not exist: {0}".format(file_path) - self.set_operation_result("failed", False, msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, msg, "ERROR").check_return_status() self.log("File path exists: {0}".format(file_path), "DEBUG") valid_extensions = ['.png', '.jpg', '.jpeg', '.pdf'] if not any(file_path.lower().endswith(ext) for ext in valid_extensions): - msg = "Unsupported file format. Supported formats: {0}".format(", ".join(valid_extensions)) - self.set_operation_result("failed", False, msg, "ERROR").check_return_status() + msg = "Unsupported file format. Supported formats: {0}".format( + ", ".join(valid_extensions)) + self.set_operation_result( + "failed", False, msg, "ERROR").check_return_status() if file_path.lower().endswith('.png'): content_type = 'image/png' @@ -2393,25 +2618,30 @@ def upload_floor_image(self, config): elif file_path.lower().endswith('.pdf'): content_type = 'application/pdf' - self.log("Determined content type: {}".format(content_type), "DEBUG") + self.log("Determined content type: {}".format( + content_type), "DEBUG") try: with open(file_path, "rb") as image_file: file_content = image_file.read() except IOError as e: - msg = "Failed to read file at {0}: {1}".format(file_path, str(e)) - self.set_operation_result("failed", False, msg, "ERROR").check_return_status() + msg = "Failed to read file at {0}: {1}".format( + file_path, str(e)) + self.set_operation_result( + "failed", False, msg, "ERROR").check_return_status() multipart_fields = { 'image': (os.path.basename(file_path), file_content, content_type) } - site_hierarchy = config.get(self.keymap["parent_name_hierarchy"], "parent_name_hierarchy") + "/" + config.get('name') + site_hierarchy = config.get( + self.keymap["parent_name_hierarchy"], "parent_name_hierarchy") + "/" + config.get('name') site_exists, current_site = self.site_exists(site_hierarchy) site_id = current_site.get("id") if not site_id: msg = "No valid site_id found in 'self.have'." - self.set_operation_result("failed", False, msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, msg, "ERROR").check_return_status() try: response = self.dnac._exec( @@ -2429,9 +2659,11 @@ def upload_floor_image(self, config): else: self.log("API response: {}".format(response), "DEBUG") except Exception as e: - self.msg = "An exception occurred during uploads_floor_image API execution: {0}".format(str(e)) + self.msg = "An exception occurred during uploads_floor_image API execution: {0}".format( + str(e)) self.log(self.msg, "ERROR") - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() except Exception as e: self.msg = "An exception occurred: {}".format(str(e)) @@ -2448,7 +2680,8 @@ def upload_floor_image(self, config): success_message = "Floor image uploaded successfully." self.log(success_message, "INFO") else: - self.log("Invalid response received from API. Response: {}".format(response), "ERROR") + self.log("Invalid response received from API. Response: {}".format( + response), "ERROR") return map_details, map_status, success_message @@ -2499,14 +2732,16 @@ def main(): ccc_site.validate_input().check_return_status() config_verify = ccc_site.params.get("config_verify") - ccc_site.validate_site_input_data(ccc_site.validated_config).check_return_status() + ccc_site.validate_site_input_data( + ccc_site.validated_config).check_return_status() if ccc_site.compare_dnac_versions(ccc_site.get_ccc_version(), "2.3.7.6") >= 0: ccc_site.reset_values() ccc_site.get_want(ccc_site.validated_config).check_return_status() ccc_site.get_have(ccc_site.validated_config).check_return_status() - ccc_site.get_diff_state_apply[state](ccc_site.validated_config).check_return_status() + ccc_site.get_diff_state_apply[state]( + ccc_site.validated_config).check_return_status() if config_verify: ccc_site.update_site_messages().check_return_status() diff --git a/plugins/modules/swim_intent.py b/plugins/modules/swim_intent.py index 6243afb254..cf84d4b77e 100644 --- a/plugins/modules/swim_intent.py +++ b/plugins/modules/swim_intent.py @@ -5,9 +5,18 @@ # 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 +import time +import os +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + get_dict_result, +) __metaclass__ = type -__author__ = ("Madhan Sankaranarayanan, Rishita Chowdhary, Abhishek Maheshwari") +__author__ = ( + "Madhan Sankaranarayanan, Rishita Chowdhary, Abhishek Maheshwari") DOCUMENTATION = r""" --- @@ -494,15 +503,6 @@ """ -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - get_dict_result, -) -from ansible.module_utils.basic import AnsibleModule -import os -import time - class DnacSwims(DnacBase): """Class containing member attributes for Swim intent module""" @@ -550,13 +550,15 @@ def validate_input(self): ) if invalid_params: - self.msg = "Invalid parameters in playbook: {0}".format(invalid_params) + self.msg = "Invalid parameters in playbook: {0}".format( + invalid_params) self.log(self.msg, "ERROR") self.status = "failed" return self self.validated_config = valid_temp - self.msg = "Successfully validated playbook config params: {0}".format(str(valid_temp)) + self.msg = "Successfully validated playbook config params: {0}".format( + str(valid_temp)) self.log(self.msg, "INFO") self.status = "success" @@ -587,12 +589,14 @@ def site_exists(self, site_name): params={"name": site_name}, ) except Exception as e: - self.msg = "An exception occurred: Site '{0}' does not exist in the Cisco Catalyst Center".format(site_name) + self.msg = "An exception occurred: Site '{0}' does not exist in the Cisco Catalyst Center".format( + site_name) self.log(self.msg, "ERROR") self.module.fail_json(msg=self.msg) if response: - self.log("Received API response from 'get_site': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_site': {0}".format( + str(response)), "DEBUG") site = response.get("response") site_id = site[0].get("id") site_exists = True @@ -621,12 +625,14 @@ def get_image_id(self, name): op_modifies=True, params={"image_name": name}, ) - self.log("Received API response from 'get_software_image_details': {0}".format(str(image_response)), "DEBUG") + self.log("Received API response from 'get_software_image_details': {0}".format( + str(image_response)), "DEBUG") image_list = image_response.get("response") if (len(image_list) == 1): image_id = image_list[0].get("imageUuid") - self.log("SWIM image '{0}' has the ID: {1}".format(name, image_id), "INFO") + self.log("SWIM image '{0}' has the ID: {1}".format( + name, image_id), "INFO") else: error_message = "SWIM image '{0}' could not be found".format(name) self.log(error_message, "ERROR") @@ -656,14 +662,17 @@ def get_image_name_from_id(self, image_id): op_modifies=True, params={"image_uuid": image_id}, ) - self.log("Received API response from 'get_software_image_details': {0}".format(str(image_response)), "DEBUG") + self.log("Received API response from 'get_software_image_details': {0}".format( + str(image_response)), "DEBUG") image_list = image_response.get("response") if (len(image_list) == 1): image_name = image_list[0].get("name") - self.log("SWIM image '{0}' has been fetched successfully from Cisco Catalyst Center".format(image_name), "INFO") + self.log("SWIM image '{0}' has been fetched successfully from Cisco Catalyst Center".format( + image_name), "INFO") else: - error_message = "SWIM image with Id '{0}' could not be found in Cisco Catalyst Center".format(image_id) + error_message = "SWIM image with Id '{0}' could not be found in Cisco Catalyst Center".format( + image_id) self.log(error_message, "ERROR") self.module.fail_json(msg=error_message, response=image_response) @@ -692,7 +701,8 @@ def is_image_exist(self, name): op_modifies=True, params={"image_name": name}, ) - self.log("Received API response from 'get_software_image_details': {0}".format(str(image_response)), "DEBUG") + self.log("Received API response from 'get_software_image_details': {0}".format( + str(image_response)), "DEBUG") image_list = image_response.get("response") if (len(image_list) == 1): @@ -720,14 +730,16 @@ def get_device_id(self, params): op_modifies=True, params=params, ) - self.log("Received API response from 'get_device_list': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_device_list': {0}".format( + str(response)), "DEBUG") device_list = response.get("response") if (len(device_list) == 1): device_id = device_list[0].get("id") self.log("Device Id: {0}".format(str(device_id)), "INFO") else: - self.msg = "Device with params: '{0}' not found in Cisco Catalyst Center so can't fetch the device id".format(str(params)) + self.msg = "Device with params: '{0}' not found in Cisco Catalyst Center so can't fetch the device id".format( + str(params)) self.log(self.msg, "WARNING") return device_id @@ -752,7 +764,8 @@ def get_device_uuids(self, site_name, device_family, device_role, device_series_ device_uuid_list = [] if not site_name: site_name = "Global" - self.log("Since site name is not given so it will be fetch all the devices under Global and mark site name as 'Global'", "INFO") + self.log( + "Since site name is not given so it will be fetch all the devices under Global and mark site name as 'Global'", "INFO") (site_exists, site_id) = self.site_exists(site_name) if not site_exists: @@ -762,7 +775,8 @@ def get_device_uuids(self, site_name, device_family, device_role, device_series_ if device_series_name: if device_series_name.startswith(".*") and device_series_name.endswith(".*"): - self.log("Device series name '{0}' is already in the regex format".format(device_series_name), "INFO") + self.log("Device series name '{0}' is already in the regex format".format( + device_series_name), "INFO") else: device_series_name = ".*" + device_series_name + ".*" @@ -779,10 +793,12 @@ def get_device_uuids(self, site_name, device_family, device_role, device_series_ params=site_params, ) except Exception as e: - self.log("Unable to fetch the device(s) associated to the site '{0}' due to '{1}'".format(site_name, str(e)), "WARNING") + self.log("Unable to fetch the device(s) associated to the site '{0}' due to '{1}'".format( + site_name, str(e)), "WARNING") return device_uuid_list - self.log("Received API response from 'get_membership': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_membership': {0}".format( + str(response)), "DEBUG") response = response['device'] site_response_list = [] @@ -826,7 +842,8 @@ def get_device_uuids(self, site_name, device_family, device_role, device_series_ device_response = device_list_response.get('response') if not response or not device_response: - self.log("Failed to retrieve devices associated with the site '{0}' due to empty API response.".format(site_name), "INFO") + self.log("Failed to retrieve devices associated with the site '{0}' due to empty API response.".format( + site_name), "INFO") break for item in site_response_list: @@ -847,16 +864,19 @@ def get_device_uuids(self, site_name, device_family, device_role, device_series_ distribution/activation.""".format(item["managementIpAddress"]), "INFO") device_response_ids.append(item["instanceUuid"]) except Exception as e: - self.msg = "An exception occured while fetching the device uuids from Cisco Catalyst Center: {0}".format(str(e)) + self.msg = "An exception occured while fetching the device uuids from Cisco Catalyst Center: {0}".format( + str(e)) self.log(self.msg, "ERROR") return device_uuid_list if not device_response_ids or not site_memberships_ids: - self.log("Failed to retrieve devices associated with the site '{0}' due to empty API response.".format(site_name), "INFO") + self.log("Failed to retrieve devices associated with the site '{0}' due to empty API response.".format( + site_name), "INFO") return device_uuid_list # Find the intersection of device IDs with the response get from get_membership api and get_device_list api with provided filters - device_uuid_list = set(site_memberships_ids).intersection(set(device_response_ids)) + device_uuid_list = set(site_memberships_ids).intersection( + set(device_response_ids)) return device_uuid_list @@ -881,18 +901,23 @@ def get_device_family_identifier(self, family_name): family="software_image_management_swim", function='get_device_family_identifiers', ) - self.log("Received API response from 'get_device_family_identifiers': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_device_family_identifiers': {0}".format( + str(response)), "DEBUG") device_family_db = response.get("response") if device_family_db: - device_family_details = get_dict_result(device_family_db, 'deviceFamily', family_name) + device_family_details = get_dict_result( + device_family_db, 'deviceFamily', family_name) if device_family_details: - device_family_identifier = device_family_details.get("deviceFamilyIdentifier") + device_family_identifier = device_family_details.get( + "deviceFamilyIdentifier") have["device_family_identifier"] = device_family_identifier - self.log("Family device indentifier: {0}".format(str(device_family_identifier)), "INFO") + self.log("Family device indentifier: {0}".format( + str(device_family_identifier)), "INFO") else: - self.msg = "Device Family: {0} not found".format(str(family_name)) + self.msg = "Device Family: {0} not found".format( + str(family_name)) self.log(self.msg, "ERROR") self.module.fail_json(msg=self.msg, response=[self.msg]) self.have.update(have) @@ -923,7 +948,8 @@ def get_have(self): else: self.log("Image details for tagging not provided", "CRITICAL") - self.module.fail_json(msg="Image details for tagging not provided", response=[]) + self.module.fail_json( + msg="Image details for tagging not provided", response=[]) # check if given site exists, store siteid # if not then use global site @@ -933,11 +959,13 @@ def get_have(self): (site_exists, site_id) = self.site_exists(site_name) if site_exists: have["site_id"] = site_id - self.log("Site {0} exists having the site id: {1}".format(site_name, str(site_id)), "DEBUG") + self.log("Site {0} exists having the site id: {1}".format( + site_name, str(site_id)), "DEBUG") else: # For global site, use -1 as siteId have["site_id"] = "-1" - self.log("Site Name not given by user. Using global site.", "WARNING") + self.log( + "Site Name not given by user. Using global site.", "WARNING") self.have.update(have) # check if given device family name exists, store indentifier value @@ -954,7 +982,8 @@ def get_have(self): if site_exists: have["site_id"] = site_id - self.log("Site '{0}' exists and has the site ID: {1}".format(site_name, str(site_id)), "DEBUG") + self.log("Site '{0}' exists and has the site ID: {1}".format( + site_name, str(site_id)), "DEBUG") # check if image for distributon is available if distribution_details.get("image_name"): @@ -963,16 +992,20 @@ def get_have(self): have["distribution_image_id"] = image_id elif self.have.get("imported_image_id"): - have["distribution_image_id"] = self.have.get("imported_image_id") + have["distribution_image_id"] = self.have.get( + "imported_image_id") else: - self.log("Image details required for distribution have not been provided", "ERROR") - self.module.fail_json(msg="Image details required for distribution have not been provided", response=[]) + self.log( + "Image details required for distribution have not been provided", "ERROR") + self.module.fail_json( + msg="Image details required for distribution have not been provided", response=[]) device_params = dict( hostname=distribution_details.get("device_hostname"), serialNumber=distribution_details.get("device_serial_number"), - managementIpAddress=distribution_details.get("device_ip_address"), + managementIpAddress=distribution_details.get( + "device_ip_address"), macAddress=distribution_details.get("device_mac_address"), ) device_id = self.get_device_id(device_params) @@ -992,10 +1025,13 @@ def get_have(self): have["activation_image_id"] = image_id elif self.have.get("imported_image_id"): - have["activation_image_id"] = self.have.get("imported_image_id") + have["activation_image_id"] = self.have.get( + "imported_image_id") else: - self.log("Image details required for activation have not been provided", "ERROR") - self.module.fail_json(msg="Image details required for activation have not been provided", response=[]) + self.log( + "Image details required for activation have not been provided", "ERROR") + self.module.fail_json( + msg="Image details required for activation have not been provided", response=[]) site_name = activation_details.get("site_name") if site_name: @@ -1003,12 +1039,14 @@ def get_have(self): (site_exists, site_id) = self.site_exists(site_name) if site_exists: have["site_id"] = site_id - self.log("The site '{0}' exists and has the site ID '{1}'".format(site_name, str(site_id)), "INFO") + self.log("The site '{0}' exists and has the site ID '{1}'".format( + site_name, str(site_id)), "INFO") device_params = dict( hostname=activation_details.get("device_hostname"), serialNumber=activation_details.get("device_serial_number"), - managementIpAddress=activation_details.get("device_ip_address"), + managementIpAddress=activation_details.get( + "device_ip_address"), macAddress=activation_details.get("device_mac_address"), ) device_id = self.get_device_id(device_params) @@ -1016,7 +1054,8 @@ def get_have(self): if device_id is not None: have["activation_device_id"] = device_id self.have.update(have) - self.log("Current State (have): {0}".format(str(self.have)), "INFO") + self.log("Current State (have): {0}".format( + str(self.have)), "INFO") return self @@ -1039,14 +1078,19 @@ def get_want(self, config): want = {} if config.get("import_image_details"): want["import_image"] = True - want["import_type"] = config.get("import_image_details").get("type").lower() + want["import_type"] = config.get( + "import_image_details").get("type").lower() if want["import_type"] == "remote": - want["url_import_details"] = config.get("import_image_details").get("url_details") + want["url_import_details"] = config.get( + "import_image_details").get("url_details") elif want["import_type"] == "local": - want["local_import_details"] = config.get("import_image_details").get("local_image_details") + want["local_import_details"] = config.get( + "import_image_details").get("local_image_details") else: - self.log("The import type '{0}' provided is incorrect. Only 'local' or 'remote' are supported.".format(want["import_type"]), "CRITICAL") - self.module.fail_json(msg="Incorrect import type. Supported Values: local or remote") + self.log("The import type '{0}' provided is incorrect. Only 'local' or 'remote' are supported.".format( + want["import_type"]), "CRITICAL") + self.module.fail_json( + msg="Incorrect import type. Supported Values: local or remote") want["tagging_details"] = config.get("tagging_details") want["distribution_details"] = config.get("image_distribution_details") @@ -1084,9 +1128,11 @@ def get_diff_import(self): return self if import_type == "remote": - image_name = self.want.get("url_import_details").get("payload")[0].get("source_url") + image_name = self.want.get("url_import_details").get("payload")[ + 0].get("source_url") else: - image_name = self.want.get("local_import_details").get("file_path") + image_name = self.want.get( + "local_import_details").get("file_path") # Code to check if the image already exists in Catalyst Center name = image_name.split('/')[-1] @@ -1102,7 +1148,8 @@ def get_diff_import(self): if image_exist: image_id = self.get_image_id(name) self.have["imported_image_id"] = image_id - self.msg = "Image '{0}' already exists in the Cisco Catalyst Center".format(name) + self.msg = "Image '{0}' already exists in the Cisco Catalyst Center".format( + name) self.result['msg'] = self.msg self.log(self.msg, "INFO") self.status = "success" @@ -1111,7 +1158,8 @@ def get_diff_import(self): if self.want.get("import_type") == "remote": import_payload_dict = {} - temp_payload = self.want.get("url_import_details").get("payload")[0] + temp_payload = self.want.get( + "url_import_details").get("payload")[0] keys_to_change = list(import_key_mapping.keys()) for key, val in temp_payload.items(): @@ -1122,19 +1170,28 @@ def get_diff_import(self): import_image_payload = [import_payload_dict] import_params = dict( payload=import_image_payload, - scheduleAt=self.want.get("url_import_details").get("schedule_at"), - scheduleDesc=self.want.get("url_import_details").get("schedule_desc"), - scheduleOrigin=self.want.get("url_import_details").get("schedule_origin"), + scheduleAt=self.want.get( + "url_import_details").get("schedule_at"), + scheduleDesc=self.want.get( + "url_import_details").get("schedule_desc"), + scheduleOrigin=self.want.get( + "url_import_details").get("schedule_origin"), ) import_function = 'import_software_image_via_url' else: - file_path = self.want.get("local_import_details").get("file_path") + file_path = self.want.get( + "local_import_details").get("file_path") import_params = dict( - is_third_party=self.want.get("local_import_details").get("is_third_party"), - third_party_vendor=self.want.get("local_import_details").get("third_party_vendor"), - third_party_image_family=self.want.get("local_import_details").get("third_party_image_family"), - third_party_application_type=self.want.get("local_import_details").get("third_party_application_type"), - multipart_fields={'file': (os.path.basename(file_path), open(file_path, 'rb'), 'application/octet-stream')}, + is_third_party=self.want.get( + "local_import_details").get("is_third_party"), + third_party_vendor=self.want.get( + "local_import_details").get("third_party_vendor"), + third_party_image_family=self.want.get( + "local_import_details").get("third_party_image_family"), + third_party_application_type=self.want.get( + "local_import_details").get("third_party_application_type"), + multipart_fields={'file': (os.path.basename(file_path), open( + file_path, 'rb'), 'application/octet-stream')}, multipart_monitor_callback=None ) import_function = 'import_local_software_image' @@ -1145,7 +1202,8 @@ def get_diff_import(self): op_modifies=True, params=import_params, ) - self.log("Received API response from {0}: {1}".format(import_function, str(response)), "DEBUG") + self.log("Received API response from {0}: {1}".format( + import_function, str(response)), "DEBUG") task_details = {} task_id = response.get("response").get("taskId") @@ -1158,14 +1216,16 @@ def get_diff_import(self): ("completed successfully" in task_details.get("progress").lower()): self.result['changed'] = True self.status = "success" - self.msg = "Swim Image {0} imported successfully".format(name) + self.msg = "Swim Image {0} imported successfully".format( + name) self.result['msg'] = self.msg self.log(self.msg, "INFO") break if task_details and task_details.get("isError"): if "already exists" in task_details.get("failureReason", ""): - self.msg = "SWIM Image {0} already exists in the Cisco Catalyst Center".format(name) + self.msg = "SWIM Image {0} already exists in the Cisco Catalyst Center".format( + name) self.result['msg'] = self.msg self.log(self.msg, "INFO") self.status = "success" @@ -1173,7 +1233,8 @@ def get_diff_import(self): break else: self.status = "failed" - self.msg = task_details.get("failureReason", "SWIM Image {0} seems to be invalid".format(image_name)) + self.msg = task_details.get( + "failureReason", "SWIM Image {0} seems to be invalid".format(image_name)) self.log(self.msg, "WARNING") self.result['response'] = self.msg return self @@ -1213,7 +1274,8 @@ def get_diff_tagging(self): tagging_details = self.want.get("tagging_details") tag_image_golden = tagging_details.get("tagging") - image_name = self.get_image_name_from_id(self.have.get("tagging_image_id")) + image_name = self.get_image_name_from_id( + self.have.get("tagging_image_id")) image_params = dict( image_id=self.have.get("tagging_image_id"), @@ -1228,7 +1290,8 @@ def get_diff_tagging(self): op_modifies=True, params=image_params ) - self.log("Received API response from 'get_golden_tag_status_of_an_image': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_golden_tag_status_of_an_image': {0}".format( + str(response)), "DEBUG") response = response.get('response') if response: @@ -1236,7 +1299,8 @@ def get_diff_tagging(self): if image_status and image_status == tag_image_golden: self.status = "success" self.result['changed'] = False - self.msg = "SWIM Image '{0}' already tagged as Golden image in Cisco Catalyst Center".format(image_name) + self.msg = "SWIM Image '{0}' already tagged as Golden image in Cisco Catalyst Center".format( + image_name) self.result['msg'] = self.msg self.log(self.msg, "INFO") return self @@ -1244,7 +1308,8 @@ def get_diff_tagging(self): if not image_status and image_status == tag_image_golden: self.status = "success" self.result['changed'] = False - self.msg = "SWIM Image '{0}' already un-tagged from Golden image in Cisco Catalyst Center".format(image_name) + self.msg = "SWIM Image '{0}' already un-tagged from Golden image in Cisco Catalyst Center".format( + image_name) self.result['msg'] = self.msg self.log(self.msg, "INFO") return self @@ -1253,10 +1318,12 @@ def get_diff_tagging(self): image_params = dict( imageId=self.have.get("tagging_image_id"), siteId=self.have.get("site_id"), - deviceFamilyIdentifier=self.have.get("device_family_identifier"), + deviceFamilyIdentifier=self.have.get( + "device_family_identifier"), deviceRole=tagging_details.get("device_role", "ALL").upper() ) - self.log("Parameters for tagging the image as golden: {0}".format(str(image_params)), "INFO") + self.log("Parameters for tagging the image as golden: {0}".format( + str(image_params)), "INFO") response = self.dnac._exec( family="software_image_management_swim", @@ -1264,10 +1331,12 @@ def get_diff_tagging(self): op_modifies=True, params=image_params ) - self.log("Received API response from 'tag_as_golden_image': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'tag_as_golden_image': {0}".format( + str(response)), "DEBUG") else: - self.log("Parameters for un-tagging the image as golden: {0}".format(str(image_params)), "INFO") + self.log( + "Parameters for un-tagging the image as golden: {0}".format(str(image_params)), "INFO") response = self.dnac._exec( family="software_image_management_swim", @@ -1275,11 +1344,13 @@ def get_diff_tagging(self): op_modifies=True, params=image_params ) - self.log("Received API response from 'remove_golden_tag_for_image': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'remove_golden_tag_for_image': {0}".format( + str(response)), "DEBUG") if not response: self.status = "failed" - self.msg = "Did not get the response of API so cannot check the Golden tagging status of image - {0}".format(image_name) + self.msg = "Did not get the response of API so cannot check the Golden tagging status of image - {0}".format( + image_name) self.log(self.msg, "ERROR") self.result['response'] = self.msg return self @@ -1309,7 +1380,8 @@ def get_diff_tagging(self): self.result['response'] = self.msg break else: - error_message = task_details.get("failureReason", "Error: while tagging/un-tagging the golden swim image.") + error_message = task_details.get( + "failureReason", "Error: while tagging/un-tagging the golden swim image.") self.status = "failed" self.msg = error_message self.result['msg'] = error_message @@ -1343,13 +1415,15 @@ def get_device_ip_from_id(self, device_id): op_modifies=True, params={"id": device_id} ) - self.log("Received API response from 'get_device_list': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_device_list': {0}".format( + str(response)), "DEBUG") response = response.get('response')[0] device_ip = response.get("managementIpAddress") return device_ip except Exception as e: - error_message = "Error occurred while getting the response of device from Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error occurred while getting the response of device from Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "ERROR") raise Exception(error_message) @@ -1393,12 +1467,14 @@ def check_swim_task_status(self, swim_task_dict, swim_task_name): ("completed successfully" in task_details.get("progress")): self.result['changed'] = True self.status = "success" - self.log("Image {0} successfully for the device '{1}".format(swim_task_name, device_ip), "INFO") + self.log("Image {0} successfully for the device '{1}".format( + swim_task_name, device_ip), "INFO") device_count += 1 break if task_details.get("isError"): - error_msg = "Image {0} gets failed for the device '{1}'".format(swim_task_name, device_ip) + error_msg = "Image {0} gets failed for the device '{1}'".format( + swim_task_name, device_ip) self.log(error_msg, "ERROR") self.result['response'] = task_details device_ips_list.append(device_ip) @@ -1425,7 +1501,8 @@ def get_diff_distribution(self): device_family = distribution_details.get("device_family_name") device_role = distribution_details.get("device_role", "ALL") device_series_name = distribution_details.get("device_series_name") - device_uuid_list = self.get_device_uuids(site_name, device_family, device_role, device_series_name) + device_uuid_list = self.get_device_uuids( + site_name, device_family, device_role, device_series_name) image_id = self.have.get("distribution_image_id") self.complete_successful_distribution = False self.partial_successful_distribution = False @@ -1439,7 +1516,8 @@ def get_diff_distribution(self): imageUuid=image_id )] ) - self.log("Distribution Params: {0}".format(str(distribution_params)), "INFO") + self.log("Distribution Params: {0}".format( + str(distribution_params)), "INFO") response = self.dnac._exec( family="software_image_management_swim", @@ -1447,7 +1525,8 @@ def get_diff_distribution(self): op_modifies=True, params=distribution_params, ) - self.log("Received API response from 'trigger_software_image_distribution': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'trigger_software_image_distribution': {0}".format( + str(response)), "DEBUG") if response: task_details = {} @@ -1461,12 +1540,14 @@ def get_diff_distribution(self): self.result['changed'] = True self.status = "success" self.single_device_distribution = True - self.result['msg'] = "Image with Id {0} Distributed Successfully".format(image_id) + self.result['msg'] = "Image with Id {0} Distributed Successfully".format( + image_id) break if task_details.get("isError"): self.status = "failed" - self.msg = "Image with Id {0} Distribution Failed".format(image_id) + self.msg = "Image with Id {0} Distribution Failed".format( + image_id) self.log(self.msg, "ERROR") self.result['response'] = task_details break @@ -1482,7 +1563,8 @@ def get_diff_distribution(self): self.log(self.msg, "WARNING") return self - self.log("Device UUIDs involved in Image Distribution: {0}".format(str(device_uuid_list)), "INFO") + self.log("Device UUIDs involved in Image Distribution: {0}".format( + str(device_uuid_list)), "INFO") distribution_task_dict = {} for device_uuid in device_uuid_list: @@ -1493,36 +1575,43 @@ def get_diff_distribution(self): imageUuid=image_id )] ) - self.log("Distribution Params: {0}".format(str(distribution_params)), "INFO") + self.log("Distribution Params: {0}".format( + str(distribution_params)), "INFO") response = self.dnac._exec( family="software_image_management_swim", function='trigger_software_image_distribution', op_modifies=True, params=distribution_params, ) - self.log("Received API response from 'trigger_software_image_distribution': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'trigger_software_image_distribution': {0}".format( + str(response)), "DEBUG") if response: task_details = {} task_id = response.get("response").get("taskId") distribution_task_dict[device_management_ip] = task_id - device_ips_list, device_distribution_count = self.check_swim_task_status(distribution_task_dict, 'Distribution') + device_ips_list, device_distribution_count = self.check_swim_task_status( + distribution_task_dict, 'Distribution') if device_distribution_count == 0: self.status = "failed" - self.msg = "Image with Id {0} Distribution Failed for all devices".format(image_id) + self.msg = "Image with Id {0} Distribution Failed for all devices".format( + image_id) elif device_distribution_count == len(device_uuid_list): self.result['changed'] = True self.status = "success" self.complete_successful_distribution = True - self.msg = "Image with Id {0} Distributed Successfully for all devices".format(image_id) + self.msg = "Image with Id {0} Distributed Successfully for all devices".format( + image_id) else: self.result['changed'] = True self.status = "success" self.partial_successful_distribution = False - self.msg = "Image with Id '{0}' Distributed and partially successfull".format(image_id) - self.log("For device(s) {0} image Distribution gets failed".format(str(device_ips_list)), "CRITICAL") + self.msg = "Image with Id '{0}' Distributed and partially successfull".format( + image_id) + self.log("For device(s) {0} image Distribution gets failed".format( + str(device_ips_list)), "CRITICAL") self.result['msg'] = self.msg self.log(self.msg, "INFO") @@ -1547,7 +1636,8 @@ def get_diff_activation(self): device_family = activation_details.get("device_family_name") device_role = activation_details.get("device_role", "ALL") device_series_name = activation_details.get("device_series_name") - device_uuid_list = self.get_device_uuids(site_name, device_family, device_role, device_series_name) + device_uuid_list = self.get_device_uuids( + site_name, device_family, device_role, device_series_name) image_id = self.have.get("activation_image_id") self.complete_successful_activation = False self.partial_successful_activation = False @@ -1555,9 +1645,12 @@ def get_diff_activation(self): if self.have.get("activation_device_id"): payload = [dict( - activateLowerImageVersion=activation_details.get("activate_lower_image_version"), - deviceUpgradeMode=activation_details.get("device_upgrade_mode"), - distributeIfNeeded=activation_details.get("distribute_if_needed"), + activateLowerImageVersion=activation_details.get( + "activate_lower_image_version"), + deviceUpgradeMode=activation_details.get( + "device_upgrade_mode"), + distributeIfNeeded=activation_details.get( + "distribute_if_needed"), deviceUuid=self.have.get("activation_device_id"), imageUuidList=[image_id] )] @@ -1566,7 +1659,8 @@ def get_diff_activation(self): schedule_validate=activation_details.get("scehdule_validate"), payload=payload ) - self.log("Activation Params: {0}".format(str(activation_params)), "INFO") + self.log("Activation Params: {0}".format( + str(activation_params)), "INFO") response = self.dnac._exec( family="software_image_management_swim", @@ -1574,7 +1668,8 @@ def get_diff_activation(self): op_modifies=True, params=activation_params, ) - self.log("Received API response from 'trigger_software_image_activation': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'trigger_software_image_activation': {0}".format( + str(response)), "DEBUG") task_details = {} task_id = response.get("response").get("taskId") @@ -1591,7 +1686,8 @@ def get_diff_activation(self): break if task_details.get("isError"): - self.msg = "Activation for Image with Id '{0}' gets failed".format(image_id) + self.msg = "Activation for Image with Id '{0}' gets failed".format( + image_id) self.status = "failed" self.result['response'] = task_details self.log(self.msg, "ERROR") @@ -1608,15 +1704,19 @@ def get_diff_activation(self): self.log(self.msg, "WARNING") return self - self.log("Device UUIDs involved in Image Activation: {0}".format(str(device_uuid_list)), "INFO") + self.log("Device UUIDs involved in Image Activation: {0}".format( + str(device_uuid_list)), "INFO") activation_task_dict = {} for device_uuid in device_uuid_list: device_management_ip = self.get_device_ip_from_id(device_uuid) payload = [dict( - activateLowerImageVersion=activation_details.get("activate_lower_image_version"), - deviceUpgradeMode=activation_details.get("device_upgrade_mode"), - distributeIfNeeded=activation_details.get("distribute_if_needed"), + activateLowerImageVersion=activation_details.get( + "activate_lower_image_version"), + deviceUpgradeMode=activation_details.get( + "device_upgrade_mode"), + distributeIfNeeded=activation_details.get( + "distribute_if_needed"), deviceUuid=device_uuid, imageUuidList=[image_id] )] @@ -1625,7 +1725,8 @@ def get_diff_activation(self): schedule_validate=activation_details.get("scehdule_validate"), payload=payload ) - self.log("Activation Params: {0}".format(str(activation_params)), "INFO") + self.log("Activation Params: {0}".format( + str(activation_params)), "INFO") response = self.dnac._exec( family="software_image_management_swim", @@ -1633,29 +1734,35 @@ def get_diff_activation(self): op_modifies=True, params=activation_params, ) - self.log("Received API response from 'trigger_software_image_activation': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'trigger_software_image_activation': {0}".format( + str(response)), "DEBUG") if response: task_details = {} task_id = response.get("response").get("taskId") activation_task_dict[device_management_ip] = task_id - device_ips_list, device_activation_count = self.check_swim_task_status(activation_task_dict, 'Activation') + device_ips_list, device_activation_count = self.check_swim_task_status( + activation_task_dict, 'Activation') if device_activation_count == 0: self.status = "failed" - self.msg = "Image with Id '{0}' activation failed for all devices".format(image_id) + self.msg = "Image with Id '{0}' activation failed for all devices".format( + image_id) elif device_activation_count == len(device_uuid_list): self.result['changed'] = True self.status = "success" self.complete_successful_activation = True - self.msg = "Image with Id '{0}' activated successfully for all devices".format(image_id) + self.msg = "Image with Id '{0}' activated successfully for all devices".format( + image_id) else: self.result['changed'] = True self.status = "success" self.partial_successful_activation = True - self.msg = "Image with Id '{0}' activated and partially successfull".format(image_id) - self.log("For Device(s) {0} Image activation gets Failed".format(str(device_ips_list)), "CRITICAL") + self.msg = "Image with Id '{0}' activated and partially successfull".format( + image_id) + self.log("For Device(s) {0} Image activation gets Failed".format( + str(device_ips_list)), "CRITICAL") self.result['msg'] = self.msg self.log(self.msg, "INFO") @@ -1704,7 +1811,8 @@ def verify_diff_imported(self, import_type): """ if import_type == "remote": - image_name = self.want.get("url_import_details").get("payload")[0].get("source_url") + image_name = self.want.get("url_import_details").get("payload")[ + 0].get("source_url") else: image_name = self.want.get("local_import_details").get("file_path") @@ -1713,7 +1821,8 @@ def verify_diff_imported(self, import_type): image_exist = self.is_image_exist(name) if image_exist: self.status = "success" - self.msg = "The requested Image '{0}' imported in the Cisco Catalyst Center and Image presence has been verified.".format(name) + self.msg = "The requested Image '{0}' imported in the Cisco Catalyst Center and Image presence has been verified.".format( + name) self.log(self.msg, "INFO") else: self.log("""The playbook input for SWIM Image '{0}' does not align with the Cisco Catalyst Center, indicating that image @@ -1748,7 +1857,8 @@ def verify_diff_tagged(self): device_family_identifier=self.have.get("device_family_identifier"), device_role=tagging_details.get("device_role", "ALL").upper() ) - self.log("Parameters for checking the status of image: {0}".format(str(image_params)), "INFO") + self.log("Parameters for checking the status of image: {0}".format( + str(image_params)), "INFO") response = self.dnac._exec( family="software_image_management_swim", @@ -1756,7 +1866,8 @@ def verify_diff_tagged(self): op_modifies=True, params=image_params ) - self.log("Received API response from 'get_golden_tag_status_of_an_image': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_golden_tag_status_of_an_image': {0}".format( + str(response)), "DEBUG") response = response.get('response') if response: @@ -1938,7 +2049,8 @@ def main(): dnac_swims.get_have().check_return_status() dnac_swims.get_diff_state_apply[state](config).check_return_status() if config_verify: - dnac_swims.verify_diff_state_apply[state](config).check_return_status() + dnac_swims.verify_diff_state_apply[state]( + config).check_return_status() module.exit_json(**dnac_swims.result) diff --git a/plugins/modules/swim_workflow_manager.py b/plugins/modules/swim_workflow_manager.py index 94d831a60d..1675ff8ff7 100644 --- a/plugins/modules/swim_workflow_manager.py +++ b/plugins/modules/swim_workflow_manager.py @@ -5,9 +5,18 @@ # 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 +import time +import os +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + get_dict_result, +) __metaclass__ = type -__author__ = ("Madhan Sankaranarayanan, Rishita Chowdhary, Abhishek Maheshwari, Syed Khadeer Ahmed, Ajith Andrew J") +__author__ = ( + "Madhan Sankaranarayanan, Rishita Chowdhary, Abhishek Maheshwari, Syed Khadeer Ahmed, Ajith Andrew J") DOCUMENTATION = r""" --- @@ -570,15 +579,6 @@ """ -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - get_dict_result, -) -from ansible.module_utils.basic import AnsibleModule -import os -import time - class Swim(DnacBase): """Class containing member attributes for Swim workflow_manager module""" @@ -625,13 +625,15 @@ def validate_input(self): ) if invalid_params: - self.msg = "Invalid parameters in playbook: {0}".format(invalid_params) + self.msg = "Invalid parameters in playbook: {0}".format( + invalid_params) self.log(self.msg, "ERROR") self.status = "failed" return self self.validated_config = valid_temp - self.msg = "Successfully validated playbook config params: {0}".format(str(valid_temp)) + self.msg = "Successfully validated playbook config params: {0}".format( + str(valid_temp)) self.log(self.msg, "INFO") self.status = "success" @@ -665,7 +667,8 @@ def site_exists(self, site_name): except Exception as e: self.status = "failed" - self.msg = ("An exception occurred: Site '{0}' does not exist in the Cisco Catalyst Center.".format(site_name)) + self.msg = ( + "An exception occurred: Site '{0}' does not exist in the Cisco Catalyst Center.".format(site_name)) self.result['response'] = self.msg self.log(self.msg, "ERROR") self.check_return_status() @@ -694,12 +697,14 @@ def get_image_id(self, name): op_modifies=True, params={"image_name": name}, ) - self.log("Received API response from 'get_software_image_details': {0}".format(str(image_response)), "DEBUG") + self.log("Received API response from 'get_software_image_details': {0}".format( + str(image_response)), "DEBUG") image_list = image_response.get("response") if (len(image_list) == 1): image_id = image_list[0].get("imageUuid") - self.log("SWIM image '{0}' has the ID: {1}".format(name, image_id), "INFO") + self.log("SWIM image '{0}' has the ID: {1}".format( + name, image_id), "INFO") else: self.msg = "SWIM image '{0}' could not be found".format(name) self.log(self.msg, "ERROR") @@ -736,11 +741,13 @@ def get_cco_image_id(self, cco_image_name): function='returns_list_of_software_images', op_modifies=True, ) - self.log("Received API response from 'returns_list_of_software_images': {0}".format(response), "DEBUG") + self.log("Received API response from 'returns_list_of_software_images': {0}".format( + response), "DEBUG") response = response.get("response") if not response or not isinstance(response, list): - self.log("The API response from 'returns_list_of_software_images' is empty or invalid.", "ERROR") + self.log( + "The API response from 'returns_list_of_software_images' is empty or invalid.", "ERROR") self.status = "failed" self.msg = "Unable to retrieve the list of software images from Cisco.com." self.result['response'] = self.msg @@ -754,7 +761,8 @@ def get_cco_image_id(self, cco_image_name): raise Exception except Exception as e: self.status = "failed" - self.msg = "Image with name '{0}' not found on Cisco.com".format(cco_image_name) + self.msg = "Image with name '{0}' not found on Cisco.com".format( + cco_image_name) self.result['response'] = self.msg self.log(self.msg, "ERROR") self.check_return_status() @@ -781,14 +789,17 @@ def get_image_name_from_id(self, image_id): op_modifies=True, params={"image_uuid": image_id}, ) - self.log("Received API response from 'get_software_image_details': {0}".format(str(image_response)), "DEBUG") + self.log("Received API response from 'get_software_image_details': {0}".format( + str(image_response)), "DEBUG") image_list = image_response.get("response") if (len(image_list) == 1): image_name = image_list[0].get("name") - self.log("SWIM image '{0}' has been fetched successfully from Cisco Catalyst Center".format(image_name), "INFO") + self.log("SWIM image '{0}' has been fetched successfully from Cisco Catalyst Center".format( + image_name), "INFO") else: - self.msg = "SWIM image with Id '{0}' could not be found in Cisco Catalyst Center".format(image_id) + self.msg = "SWIM image with Id '{0}' could not be found in Cisco Catalyst Center".format( + image_id) self.log(self.msg, "ERROR") self.status = "failed" self.result['response'] = self.msg @@ -819,7 +830,8 @@ def is_image_exist(self, name): op_modifies=True, params={"image_name": name}, ) - self.log("Received API response from 'get_software_image_details': {0}".format(str(image_response)), "DEBUG") + self.log("Received API response from 'get_software_image_details': {0}".format( + str(image_response)), "DEBUG") image_list = image_response.get("response") if (len(image_list) == 1): @@ -849,29 +861,35 @@ def get_device_id(self, params): op_modifies=True, params=params, ) - self.log("Received API response from 'get_device_list': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_device_list': {0}".format( + str(response)), "DEBUG") device_list = response.get("response") if not device_list: - self.log("Device list is empty; no devices found for given parameters.", "WARNING") + self.log( + "Device list is empty; no devices found for given parameters.", "WARNING") raise ValueError("No devices found") if len(device_list) == 1: device_id = device_list[0].get("id") - self.log("Successfully retrieved device ID: {0}".format(device_id), "INFO") + self.log("Successfully retrieved device ID: {0}".format( + device_id), "INFO") return device_id - self.log("Multiple devices found for parameters: {0}".format(params), "ERROR") + self.log("Multiple devices found for parameters: {0}".format( + params), "ERROR") raise ValueError("Multiple devices found") except ValueError as ve: - msg = "Error: {0}. Unable to fetch unique device ID with parameters: {1}".format(str(ve), params) + msg = "Error: {0}. Unable to fetch unique device ID with parameters: {1}".format( + str(ve), params) self.log(msg, "ERROR") return None except Exception as e: - msg = "An unexpected error occurred while retrieving device ID: {0}".format(str(e)) + msg = "An unexpected error occurred while retrieving device ID: {0}".format( + str(e)) self.log(msg, "ERROR") return None @@ -896,7 +914,8 @@ def get_device_uuids(self, site_name, device_family, device_role, device_series_ device_id_list, site_response_list = [], [] if not site_name: site_name = "Global" - self.log("Site name not specified; defaulting to 'Global' to fetch all devices under this category", "INFO") + self.log( + "Site name not specified; defaulting to 'Global' to fetch all devices under this category", "INFO") (site_exists, site_id) = self.site_exists(site_name) if not site_exists: @@ -906,7 +925,8 @@ def get_device_uuids(self, site_name, device_family, device_role, device_series_ if device_series_name: if device_series_name.startswith(".*") and device_series_name.endswith(".*"): - self.log("Device series name '{0}' is already in the regex format".format(device_series_name), "INFO") + self.log("Device series name '{0}' is already in the regex format".format( + device_series_name), "INFO") else: device_series_name = ".*" + device_series_name + ".*" @@ -925,10 +945,12 @@ def get_device_uuids(self, site_name, device_family, device_role, device_series_ ) except Exception as e: - self.log("Unable to fetch the device(s) associated to the site '{0}' due to '{1}'".format(site_name, str(e)), "WARNING") + self.log("Unable to fetch the device(s) associated to the site '{0}' due to '{1}'".format( + site_name, str(e)), "WARNING") return device_uuid_list - self.log("Received API response from 'get_membership': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_membership': {0}".format( + str(response)), "DEBUG") response = response.get("device") for item in response: @@ -943,14 +965,17 @@ def get_device_uuids(self, site_name, device_family, device_role, device_series_ op_modifies=True, params={"site_id": site_id}, ) - self.log("Received API response from 'get_site_assigned_network_devices': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_site_assigned_network_devices': {0}".format( + str(response)), "DEBUG") response = response.get('response') if not response: - self.log("No devices found for site '{0}'.". format(site_name), "WARNING") + self.log("No devices found for site '{0}'.". format( + site_name), "WARNING") except Exception as e: - self.log("Unable to fetch the device(s) associated to the site '{0}' due to '{1}'".format(site_name, str(e)), "WARNING") + self.log("Unable to fetch the device(s) associated to the site '{0}' due to '{1}'".format( + site_name, str(e)), "WARNING") return device_uuid_list for device_id in response: @@ -979,7 +1004,8 @@ def get_device_uuids(self, site_name, device_family, device_role, device_series_ op_modifies=True ) offset = offset + 1 - self.log("Received API response from 'device_list_response': {0}".format(str(device_list_response)), "DEBUG") + self.log("Received API response from 'device_list_response': {0}".format( + str(device_list_response)), "DEBUG") device_response = device_list_response.get('response') if not device_response: break @@ -990,7 +1016,8 @@ def get_device_uuids(self, site_name, device_family, device_role, device_series_ site_response_list.append(device) except Exception as e: - self.log("Unable to fetch the device(s) associated to the site '{0}' due to '{1}'".format(site_name, str(e)), "WARNING") + self.log("Unable to fetch the device(s) associated to the site '{0}' due to '{1}'".format( + site_name, str(e)), "WARNING") return device_uuid_list self.device_ips = [] @@ -1029,12 +1056,14 @@ def get_device_uuids(self, site_name, device_family, device_role, device_series_ op_modifies=True, params=device_params, ) - self.log("Received API response from 'device_list_response': {0}".format(str(device_list_response)), "DEBUG") + self.log("Received API response from 'device_list_response': {0}".format( + str(device_list_response)), "DEBUG") offset = offset + 1 device_response = device_list_response.get('response') if not response or not device_response: - self.log("Failed to retrieve devices associated with the site '{0}' due to empty API response.".format(site_name), "INFO") + self.log("Failed to retrieve devices associated with the site '{0}' due to empty API response.".format( + site_name), "INFO") break for item in site_response_list: @@ -1055,16 +1084,19 @@ def get_device_uuids(self, site_name, device_family, device_role, device_series_ distribution/activation.""".format(item["managementIpAddress"]), "INFO") device_response_ids.append(item["instanceUuid"]) except Exception as e: - self.msg = "An exception occured while fetching the device uuids from Cisco Catalyst Center: {0}".format(str(e)) + self.msg = "An exception occured while fetching the device uuids from Cisco Catalyst Center: {0}".format( + str(e)) self.log(self.msg, "ERROR") return device_uuid_list if not device_response_ids or not site_memberships_ids: - self.log("Failed to retrieve devices associated with the site '{0}' due to empty API response.".format(site_name), "INFO") + self.log("Failed to retrieve devices associated with the site '{0}' due to empty API response.".format( + site_name), "INFO") return device_uuid_list # Find the intersection of device IDs with the response get from get_membership api and get_device_list api with provided filters - device_uuid_list = set(site_memberships_ids).intersection(set(device_response_ids)) + device_uuid_list = set(site_memberships_ids).intersection( + set(device_response_ids)) return device_uuid_list @@ -1085,29 +1117,35 @@ def get_device_family_identifier(self, family_name): """ have = {} - if self.dnac_version >= self.version_2_2_3_3 : + if self.dnac_version >= self.version_2_2_3_3: response = self.dnac._exec( family="software_image_management_swim", function='get_device_family_identifiers', ) - self.log("Received API response from 'get_device_family_identifiers': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_device_family_identifiers': {0}".format( + str(response)), "DEBUG") device_family_db = response.get("response") else: self.status = "failed" - self.msg = "This version : '{0}' has no 'get_device_family_identifiers' functionality ".format(self.payload.get("dnac_version")) + self.msg = "This version : '{0}' has no 'get_device_family_identifiers' functionality ".format( + self.payload.get("dnac_version")) self.result['response'] = self.msg self.log(self.msg, "ERROR") self.check_return_status() if device_family_db: - device_family_details = get_dict_result(device_family_db, 'deviceFamily', family_name) + device_family_details = get_dict_result( + device_family_db, 'deviceFamily', family_name) if device_family_details: - device_family_identifier = device_family_details.get("deviceFamilyIdentifier") + device_family_identifier = device_family_details.get( + "deviceFamilyIdentifier") have["device_family_identifier"] = device_family_identifier - self.log("Family device indentifier: {0}".format(str(device_family_identifier)), "INFO") + self.log("Family device indentifier: {0}".format( + str(device_family_identifier)), "INFO") else: - self.msg = "Device Family: {0} not found".format(str(family_name)) + self.msg = "Device Family: {0} not found".format( + str(family_name)) self.log(self.msg, "ERROR") self.module.fail_json(msg=self.msg, response=self.msg) self.have.update(have) @@ -1138,7 +1176,8 @@ def get_have(self): else: self.log("Image details for tagging not provided", "CRITICAL") - self.module.fail_json(msg="Image details for tagging not provided", response=[]) + self.module.fail_json( + msg="Image details for tagging not provided", response=[]) # check if given site exists, store siteid # if not then use global site @@ -1148,11 +1187,13 @@ def get_have(self): (site_exists, site_id) = self.site_exists(site_name) if site_exists: have["site_id"] = site_id - self.log("Site {0} exists having the site id: {1}".format(site_name, str(site_id)), "DEBUG") + self.log("Site {0} exists having the site id: {1}".format( + site_name, str(site_id)), "DEBUG") else: # For global site, use -1 as siteId have["site_id"] = "-1" - self.log("Site Name not given by user. Using global site.", "WARNING") + self.log( + "Site Name not given by user. Using global site.", "WARNING") self.have.update(have) # check if given device family name exists, store indentifier value @@ -1169,7 +1210,8 @@ def get_have(self): if site_exists: have["site_id"] = site_id - self.log("Site '{0}' exists and has the site ID: {1}".format(site_name, str(site_id)), "DEBUG") + self.log("Site '{0}' exists and has the site ID: {1}".format( + site_name, str(site_id)), "DEBUG") # check if image for distributon is available if distribution_details.get("image_name"): @@ -1178,11 +1220,14 @@ def get_have(self): have["distribution_image_id"] = image_id elif self.have.get("imported_image_id"): - have["distribution_image_id"] = self.have.get("imported_image_id") + have["distribution_image_id"] = self.have.get( + "imported_image_id") else: - self.log("Image details required for distribution have not been provided", "ERROR") - self.module.fail_json(msg="Image details required for distribution have not been provided", response=[]) + self.log( + "Image details required for distribution have not been provided", "ERROR") + self.module.fail_json( + msg="Image details required for distribution have not been provided", response=[]) device_params = { "hostname": distribution_details.get("device_hostname"), @@ -1203,13 +1248,15 @@ def get_have(self): params_message = ", ".join(params_list) self.status = "failed" - self.msg = "The device with the following parameter(s): {0} could not be found in the Cisco Catalyst Center.".format(params_message) + self.msg = "The device with the following parameter(s): {0} could not be found in the Cisco Catalyst Center.".format( + params_message) self.log(self.msg, "ERROR") self.result['response'] = self.msg self.check_return_status() else: - self.log("Device with ID {0} found and added to distribution details.".format(device_id), "DEBUG") + self.log("Device with ID {0} found and added to distribution details.".format( + device_id), "DEBUG") have["distribution_device_id"] = device_id self.have.update(have) @@ -1224,10 +1271,13 @@ def get_have(self): have["activation_image_id"] = image_id elif self.have.get("imported_image_id"): - have["activation_image_id"] = self.have.get("imported_image_id") + have["activation_image_id"] = self.have.get( + "imported_image_id") else: - self.log("Image details required for activation have not been provided", "ERROR") - self.module.fail_json(msg="Image details required for activation have not been provided", response=[]) + self.log( + "Image details required for activation have not been provided", "ERROR") + self.module.fail_json( + msg="Image details required for activation have not been provided", response=[]) site_name = activation_details.get("site_name") if site_name: @@ -1235,7 +1285,8 @@ def get_have(self): (site_exists, site_id) = self.site_exists(site_name) if site_exists: have["site_id"] = site_id - self.log("The site '{0}' exists and has the site ID '{1}'".format(site_name, str(site_id)), "INFO") + self.log("The site '{0}' exists and has the site ID '{1}'".format( + site_name, str(site_id)), "INFO") device_params = { "hostname": activation_details.get("device_hostname"), @@ -1249,7 +1300,8 @@ def get_have(self): device_id = self.get_device_id(device_params) if device_id is None: - desired_keys = {"hostname", "serialNumber", "managementIpAddress", "macAddress"} + desired_keys = {"hostname", "serialNumber", + "managementIpAddress", "macAddress"} params_list = [] # Format only the parameters that are present @@ -1260,14 +1312,16 @@ def get_have(self): params_message = ", ".join(params_list) self.status = "failed" - self.msg = "The device with the following parameter(s): {0} could not be found in the Cisco Catalyst Center.".format(params_message) + self.msg = "The device with the following parameter(s): {0} could not be found in the Cisco Catalyst Center.".format( + params_message) self.log(self.msg, "ERROR") self.result['response'] = self.msg self.check_return_status() else: have["activation_device_id"] = device_id - self.log("Device with ID {0} found and added to activation details.".format(device_id), "DEBUG") + self.log("Device with ID {0} found and added to activation details.".format( + device_id), "DEBUG") self.have.update(have) @@ -1299,28 +1353,39 @@ def get_want(self, config): import_type = want["import_type"] if self.dnac_version < self.version_2_3_7_6: if import_type == "remote": - want["url_import_details"] = import_image_details.get("url_details") + want["url_import_details"] = import_image_details.get( + "url_details") elif import_type == "local": - want["local_import_details"] = import_image_details.get("local_image_details") + want["local_import_details"] = import_image_details.get( + "local_image_details") else: - self.log("The import type '{0}' provided is incorrect. Only 'local' or 'remote' is supported.".format(import_type), "CRITICAL") - self.module.fail_json(msg="Incorrect import type. Supported Values: local or remote") + self.log("The import type '{0}' provided is incorrect. Only 'local' or 'remote' is supported.".format( + import_type), "CRITICAL") + self.module.fail_json( + msg="Incorrect import type. Supported Values: local or remote") else: if import_type == "remote": - want["url_import_details"] = import_image_details.get("url_details") + want["url_import_details"] = import_image_details.get( + "url_details") elif import_type == "local": - want["local_import_details"] = import_image_details.get("local_image_details") + want["local_import_details"] = import_image_details.get( + "local_image_details") elif import_type == "cco": - cco_import_details = config.get("import_image_details", {}).get("cco_image_details") + cco_import_details = config.get( + "import_image_details", {}).get("cco_image_details") if cco_import_details is not None and cco_import_details.get("image_name") is not None: want["cco_import_details"] = cco_import_details else: - self.log("CCO import details are missing from the provided configuration.", "ERROR") - self.module.fail_json(msg="Missing CCO import details in the configuration.") + self.log( + "CCO import details are missing from the provided configuration.", "ERROR") + self.module.fail_json( + msg="Missing CCO import details in the configuration.") else: - self.log("The import type '{0}' provided is incorrect. Only 'local' or 'remote' or 'CCO' is supported.".format(import_type), "CRITICAL") - self.module.fail_json(msg="Incorrect import type. Only 'local' or 'remote' or 'CCO' is supported.") + self.log("The import type '{0}' provided is incorrect. Only 'local' or 'remote' or 'CCO' is supported.".format( + import_type), "CRITICAL") + self.module.fail_json( + msg="Incorrect import type. Only 'local' or 'remote' or 'CCO' is supported.") want["tagging_details"] = config.get("tagging_details") want["distribution_details"] = config.get("image_distribution_details") @@ -1356,14 +1421,20 @@ def get_diff_import(self): self.log("image_type - {0}".format(import_type)) if import_type == "remote": - image_names = self.want.get("url_import_details", {}).get("payload", [])[0].get("source_url", []) - self.log("Image(s) '{0}' to be imported in Cisco Catalyst Center".format(image_names), "INFO") + image_names = self.want.get("url_import_details", {}).get( + "payload", [])[0].get("source_url", []) + self.log("Image(s) '{0}' to be imported in Cisco Catalyst Center".format( + image_names), "INFO") elif import_type == "local": - image_names = [self.want.get("local_import_details", {}).get("file_path", "")] - self.log("Image '{0}' to be imported in Cisco Catalyst Center".format(image_names[0]), "INFO") + image_names = [self.want.get( + "local_import_details", {}).get("file_path", "")] + self.log("Image '{0}' to be imported in Cisco Catalyst Center".format( + image_names[0]), "INFO") else: # CCO import - image_names = [self.want.get("cco_import_details", {}).get("image_name", "")] - self.log("Image '{0}' to be imported in Cisco Catalyst Center".format(image_names[0]), "INFO") + image_names = [self.want.get( + "cco_import_details", {}).get("image_name", "")] + self.log("Image '{0}' to be imported in Cisco Catalyst Center".format( + image_names[0]), "INFO") # Code to check if the image(s) already exist in Catalyst Center existing_images, images_to_import = [], [] @@ -1373,12 +1444,14 @@ def get_diff_import(self): self.log(name) if self.is_image_exist(name): existing_images.append(name) - self.log("Image '{0}' already exists in Cisco Catalyst Center, skipping import.".format(name), "INFO") + self.log("Image '{0}' already exists in Cisco Catalyst Center, skipping import.".format( + name), "INFO") else: images_to_import.append(name) if existing_images: - self.log("Skipping import for existing images: {0}".format(", ".join(existing_images)), "INFO") + self.log("Skipping import for existing images: {0}".format( + ", ".join(existing_images)), "INFO") if images_to_import: import_key_mapping = { @@ -1390,7 +1463,8 @@ def get_diff_import(self): if import_type == "remote": import_image_payload = [] - temp_payloads = self.want.get("url_import_details").get("payload") + temp_payloads = self.want.get( + "url_import_details").get("payload") for temp_payload in temp_payloads: source_urls = temp_payload.get('source_url', []) @@ -1400,27 +1474,38 @@ def get_diff_import(self): if 'source_url' in import_key_mapping: import_payload_dict['sourceURL'] = url if 'image_family' in import_key_mapping: - import_payload_dict['imageFamily'] = temp_payload.get('image_family') + import_payload_dict['imageFamily'] = temp_payload.get( + 'image_family') if 'application_type' in import_key_mapping: - import_payload_dict['applicationType'] = temp_payload.get('application_type') - import_image_payload.append(import_payload_dict) + import_payload_dict['applicationType'] = temp_payload.get( + 'application_type') + import_image_payload.append( + import_payload_dict) import_params = dict( payload=import_image_payload, - scheduleAt=self.want.get("url_import_details").get("schedule_at"), - scheduleDesc=self.want.get("url_import_details").get("schedule_desc"), - scheduleOrigin=self.want.get("url_import_details").get("schedule_origin"), + scheduleAt=self.want.get( + "url_import_details").get("schedule_at"), + scheduleDesc=self.want.get( + "url_import_details").get("schedule_desc"), + scheduleOrigin=self.want.get( + "url_import_details").get("schedule_origin"), ) import_function = 'import_software_image_via_url' elif import_type == "local": file_path = images_to_import[0] import_params = dict( - is_third_party=self.want.get("local_import_details").get("is_third_party"), - third_party_vendor=self.want.get("local_import_details").get("third_party_vendor"), - third_party_image_family=self.want.get("local_import_details").get("third_party_image_family"), - third_party_application_type=self.want.get("local_import_details").get("third_party_application_type"), - multipart_fields={'file': (os.path.basename(file_path), open(file_path, 'rb'), 'application/octet-stream')}, + is_third_party=self.want.get( + "local_import_details").get("is_third_party"), + third_party_vendor=self.want.get( + "local_import_details").get("third_party_vendor"), + third_party_image_family=self.want.get( + "local_import_details").get("third_party_image_family"), + third_party_application_type=self.want.get( + "local_import_details").get("third_party_application_type"), + multipart_fields={'file': (os.path.basename(file_path), open( + file_path, 'rb'), 'application/octet-stream')}, multipart_monitor_callback=None ) import_function = 'import_local_software_image' @@ -1431,14 +1516,16 @@ def get_diff_import(self): import_params = {"id": cco_image_id} import_function = 'download_the_software_image' - self.log("importing with the import_params - {0}".format(import_params)) + self.log( + "importing with the import_params - {0}".format(import_params)) response = self.dnac._exec( family="software_image_management_swim", function=import_function, op_modifies=True, params=import_params, ) - self.log("Received API response from {0}: {1}".format(import_function, str(response)), "DEBUG") + self.log("Received API response from {0}: {1}".format( + import_function, str(response)), "DEBUG") task_details = {} task_id = response.get("response").get("taskId") @@ -1460,7 +1547,8 @@ def get_diff_import(self): self.result['changed'] = True self.status = "success" - self.msg = "Swim Image(s) {0} imported successfully".format(images_to_import_str) + self.msg = "Swim Image(s) {0} imported successfully".format( + images_to_import_str) self.result['msg'] = self.msg self.result['response'] = self.msg self.log(self.msg, "INFO") @@ -1468,7 +1556,8 @@ def get_diff_import(self): if task_details.get("isError"): if "already exists" in task_details.get("failureReason", ""): - self.msg = "SWIM Image {0} already exists in the Cisco Catalyst Center".format(image_name.split('/')[-1]) + self.msg = "SWIM Image {0} already exists in the Cisco Catalyst Center".format( + image_name.split('/')[-1]) self.result['msg'] = self.msg self.result['response'] = self.msg self.log(self.msg, "INFO") @@ -1477,7 +1566,8 @@ def get_diff_import(self): break else: self.status = "failed" - self.msg = task_details.get("failureReason", "SWIM Image {0} seems to be invalid".format(image_name)) + self.msg = task_details.get( + "failureReason", "SWIM Image {0} seems to be invalid".format(image_name)) self.log(self.msg, "WARNING") self.result['response'] = self.msg return self @@ -1493,13 +1583,16 @@ def get_diff_import(self): if skipped_images_str: if imported_images_str: - messages.append("Image(s) {0} were skipped as they already exist in Cisco Catalyst Center.".format(skipped_images_str)) - messages.append("Images {0} have been imported successfully.".format(imported_images_str)) + messages.append("Image(s) {0} were skipped as they already exist in Cisco Catalyst Center.".format( + skipped_images_str)) + messages.append( + "Images {0} have been imported successfully.".format(imported_images_str)) else: messages.append("Image(s) {0} were skipped as they already exist in Cisco Catalyst Center." "No new images were imported.".format(skipped_images_str)) elif imported_images_str: - messages.append("Image(s) {0} have been imported successfully into Cisco Catalyst Center.".format(imported_images_str)) + messages.append("Image(s) {0} have been imported successfully into Cisco Catalyst Center.".format( + imported_images_str)) else: messages.append("No images were imported.") @@ -1539,12 +1632,14 @@ def get_diff_tagging(self): tagging_details = self.want.get("tagging_details") tag_image_golden = tagging_details.get("tagging") - image_name = self.get_image_name_from_id(self.have.get("tagging_image_id")) + image_name = self.get_image_name_from_id( + self.have.get("tagging_image_id")) device_role = tagging_details.get("device_role", "ALL") self.log("Parsed device roles: {0}".format(device_role), "DEBUG") device_role_no, already_un_tagged_device_role, already_tagged_device_role = [], [], [] - device_roles = ["core", "distribution", "access", "border router", "unknown", "all"] + device_roles = ["core", "distribution", + "access", "border router", "unknown", "all"] for role in device_role.split(','): role = role.strip() @@ -1569,34 +1664,40 @@ def get_diff_tagging(self): "device_role": role.upper() } - self.log("Parameters for checking tag status for role '{0}': {1}".format(role, image_params), "DEBUG") + self.log("Parameters for checking tag status for role '{0}': {1}".format( + role, image_params), "DEBUG") response = self.dnac._exec( family="software_image_management_swim", function="get_golden_tag_status_of_an_image", op_modifies=True, params=image_params ) - self.log("Received API response from 'get_golden_tag_status_of_an_image': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_golden_tag_status_of_an_image': {0}".format( + str(response)), "DEBUG") api_response = response.get('response') if api_response: image_status = api_response.get('taggedGolden') if image_status and tag_image_golden is True: - msg = "SWIM Image '{0}' already tagged as Golden image in Cisco Catalyst Center".format(image_name) + msg = "SWIM Image '{0}' already tagged as Golden image in Cisco Catalyst Center".format( + image_name) self.log(msg, "INFO") already_tagged_device_role.append(role) elif not image_status and not tag_image_golden: - msg = "SWIM Image '{0}' already un-tagged from Golden image in Cisco Catalyst Center".format(image_name) + msg = "SWIM Image '{0}' already un-tagged from Golden image in Cisco Catalyst Center".format( + image_name) self.log(msg, "INFO") already_un_tagged_device_role.append(role) - self.log("Verifying if all roles are in the desired tag status...", "DEBUG") + self.log( + "Verifying if all roles are in the desired tag status...", "DEBUG") # Check if all roles are tagged as Golden if tag_image_golden: if len(already_tagged_device_role) == len(device_role_no): self.status = "success" self.result['changed'] = False - self.msg = "SWIM Image '{0}' already tagged as Golden image in Cisco Catalyst Center for the roles - {1}.".format(image_name, device_role) + self.msg = "SWIM Image '{0}' already tagged as Golden image in Cisco Catalyst Center for the roles - {1}.".format( + image_name, device_role) self.result['msg'] = self.msg self.result['response'] = self.msg self.log(self.msg, "INFO") @@ -1605,7 +1706,8 @@ def get_diff_tagging(self): if len(already_un_tagged_device_role) == len(device_role_no): self.status = "success" self.result['changed'] = False - self.msg = "SWIM Image '{0}' already un-tagged as Golden image in Cisco Catalyst Center for the roles - {1}.".format(image_name, device_role) + self.msg = "SWIM Image '{0}' already un-tagged as Golden image in Cisco Catalyst Center for the roles - {1}.".format( + image_name, device_role) self.result['msg'] = self.msg self.result['response'] = self.msg self.log(self.msg, "INFO") @@ -1616,10 +1718,12 @@ def get_diff_tagging(self): image_params = dict( imageId=self.have.get("tagging_image_id"), siteId=self.have.get("site_id"), - deviceFamilyIdentifier=self.have.get("device_family_identifier"), + deviceFamilyIdentifier=self.have.get( + "device_family_identifier"), deviceRole=role.upper() ) - self.log("Parameters for tagging the image as golden for role {0}: {1}".format(role, str(image_params)), "INFO") + self.log("Parameters for tagging the image as golden for role {0}: {1}".format( + role, str(image_params)), "INFO") response = self.dnac._exec( family="software_image_management_swim", @@ -1627,7 +1731,8 @@ def get_diff_tagging(self): op_modifies=True, params=image_params ) - self.log("Received API response from 'tag_as_golden_image': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'tag_as_golden_image': {0}".format( + str(response)), "DEBUG") else: for role in device_role.split(','): @@ -1637,7 +1742,8 @@ def get_diff_tagging(self): "device_family_identifier": self.have.get("device_family_identifier"), "device_role": role.upper() } - self.log("Parameters for un-tagging the image as golden for role {0}: {1}".format(role, str(image_params)), "INFO") + self.log("Parameters for un-tagging the image as golden for role {0}: {1}".format( + role, str(image_params)), "INFO") response = self.dnac._exec( family="software_image_management_swim", @@ -1645,11 +1751,13 @@ def get_diff_tagging(self): op_modifies=True, params=image_params ) - self.log("Received API response from 'remove_golden_tag_for_image': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'remove_golden_tag_for_image': {0}".format( + str(response)), "DEBUG") if not response: self.status = "failed" - self.msg = "Did not get the response of API so cannot check the Golden tagging status of image - {0}".format(image_name) + self.msg = "Did not get the response of API so cannot check the Golden tagging status of image - {0}".format( + image_name) self.log(self.msg, "ERROR") self.result['response'] = self.msg return self @@ -1724,13 +1832,15 @@ def get_device_ip_from_id(self, device_id): op_modifies=True, params={"id": device_id} ) - self.log("Received API response from 'get_device_list': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_device_list': {0}".format( + str(response)), "DEBUG") response = response.get('response')[0] device_ip = response.get("managementIpAddress") return device_ip except Exception as e: - error_message = "Error occurred while getting the response of device from Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error occurred while getting the response of device from Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "ERROR") raise Exception(error_message) @@ -1775,12 +1885,14 @@ def check_swim_task_status(self, swim_task_dict, swim_task_name): ("completed successfully" in task_details.get("progress")): self.result['changed'] = True self.status = "success" - self.log("Image {0} successfully for the device '{1}".format(swim_task_name, device_ip), "INFO") + self.log("Image {0} successfully for the device '{1}".format( + swim_task_name, device_ip), "INFO") device_count += 1 break if task_details.get("isError"): - error_msg = "Image {0} gets failed for the device '{1}'".format(swim_task_name, device_ip) + error_msg = "Image {0} gets failed for the device '{1}'".format( + swim_task_name, device_ip) self.log(error_msg, "ERROR") self.result['response'] = task_details device_ips_list.append(device_ip) @@ -1807,7 +1919,8 @@ def get_diff_distribution(self): device_family = distribution_details.get("device_family_name") device_role = distribution_details.get("device_role", "ALL") device_series_name = distribution_details.get("device_series_name") - device_uuid_list = self.get_device_uuids(site_name, device_family, device_role, device_series_name) + device_uuid_list = self.get_device_uuids( + site_name, device_family, device_role, device_series_name) image_id = self.have.get("distribution_image_id") self.complete_successful_distribution = False self.partial_successful_distribution = False @@ -1825,7 +1938,8 @@ def get_diff_distribution(self): imageUuid=image_id )] ) - self.log("Distribution Params: {0}".format(str(distribution_params)), "INFO") + self.log("Distribution Params: {0}".format( + str(distribution_params)), "INFO") response = self.dnac._exec( family="software_image_management_swim", @@ -1833,7 +1947,8 @@ def get_diff_distribution(self): op_modifies=True, params=distribution_params, ) - self.log("Received API response from 'trigger_software_image_distribution': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'trigger_software_image_distribution': {0}".format( + str(response)), "DEBUG") if response: task_details = {} @@ -1874,11 +1989,13 @@ def get_diff_distribution(self): self.log(self.msg, "WARNING") return self - self.log("Device UUIDs involved in Image Distribution: {0}".format(str(device_uuid_list)), "INFO") + self.log("Device UUIDs involved in Image Distribution: {0}".format( + str(device_uuid_list)), "INFO") distribution_task_dict = {} for device_uuid in device_uuid_list: - self.log("Starting distribution of image '{0}' to multiple devices.".format(image_name)) + self.log( + "Starting distribution of image '{0}' to multiple devices.".format(image_name)) device_management_ip = self.get_device_ip_from_id(device_uuid) distribution_params = dict( payload=[dict( @@ -1886,38 +2003,45 @@ def get_diff_distribution(self): imageUuid=image_id )] ) - self.log("Distribution Params: {0}".format(str(distribution_params)), "INFO") + self.log("Distribution Params: {0}".format( + str(distribution_params)), "INFO") response = self.dnac._exec( family="software_image_management_swim", function='trigger_software_image_distribution', op_modifies=True, params=distribution_params, ) - self.log("Received API response from 'trigger_software_image_distribution': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'trigger_software_image_distribution': {0}".format( + str(response)), "DEBUG") if response: task_details = {} task_id = response.get("response").get("taskId") distribution_task_dict[device_management_ip] = task_id - device_ips_list, device_distribution_count = self.check_swim_task_status(distribution_task_dict, 'Distribution') + device_ips_list, device_distribution_count = self.check_swim_task_status( + distribution_task_dict, 'Distribution') if device_distribution_count == 0: self.status = "failed" - self.msg = "Image with Id {0} Distribution Failed for all devices '{1}'".format(image_id, "', '".join(self.device_ips)) + self.msg = "Image with Id {0} Distribution Failed for all devices '{1}'".format( + image_id, "', '".join(self.device_ips)) self.result['response'] = self.msg elif device_distribution_count == len(device_uuid_list): self.result['changed'] = True self.status = "success" self.complete_successful_distribution = True - self.msg = "Image with Id {0} Distributed Successfully for all devices '{1}'".format(image_id, "', '".join(self.device_ips)) + self.msg = "Image with Id {0} Distributed Successfully for all devices '{1}'".format( + image_id, "', '".join(self.device_ips)) self.result['response'] = self.msg else: self.result['changed'] = True self.status = "success" self.partial_successful_distribution = False - self.msg = "Image {0} with Id '{1}' Distributed and partially successfull".format(image_name, image_id) - self.log("For device(s) {0} image Distribution gets failed".format(str(device_ips_list)), "CRITICAL") + self.msg = "Image {0} with Id '{1}' Distributed and partially successfull".format( + image_name, image_id) + self.log("For device(s) {0} image Distribution gets failed".format( + str(device_ips_list)), "CRITICAL") self.result['msg'] = self.msg self.result['response'] = self.msg @@ -1943,7 +2067,8 @@ def get_diff_activation(self): device_family = activation_details.get("device_family_name") device_role = activation_details.get("device_role", "ALL") device_series_name = activation_details.get("device_series_name") - device_uuid_list = self.get_device_uuids(site_name, device_family, device_role, device_series_name) + device_uuid_list = self.get_device_uuids( + site_name, device_family, device_role, device_series_name) image_id = self.have.get("activation_image_id") self.complete_successful_activation = False self.partial_successful_activation = False @@ -1956,9 +2081,12 @@ def get_diff_activation(self): self.log("Starting image activation for device IP {0} with ID {1}, targeting software version {2}.".format( device_ip, activation_device_id, image_name), "INFO") payload = [dict( - activateLowerImageVersion=activation_details.get("activate_lower_image_version"), - deviceUpgradeMode=activation_details.get("device_upgrade_mode"), - distributeIfNeeded=activation_details.get("distribute_if_needed"), + activateLowerImageVersion=activation_details.get( + "activate_lower_image_version"), + deviceUpgradeMode=activation_details.get( + "device_upgrade_mode"), + distributeIfNeeded=activation_details.get( + "distribute_if_needed"), deviceUuid=self.have.get("activation_device_id"), imageUuidList=[image_id] )] @@ -1967,7 +2095,8 @@ def get_diff_activation(self): schedule_validate=activation_details.get("scehdule_validate"), payload=payload ) - self.log("Activation Params: {0}".format(str(activation_params)), "INFO") + self.log("Activation Params: {0}".format( + str(activation_params)), "INFO") response = self.dnac._exec( family="software_image_management_swim", @@ -1975,7 +2104,8 @@ def get_diff_activation(self): op_modifies=True, params=activation_params, ) - self.log("Received API response from 'trigger_software_image_activation': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'trigger_software_image_activation': {0}".format( + str(response)), "DEBUG") task_details = {} task_id = response.get("response").get("taskId") @@ -1995,7 +2125,8 @@ def get_diff_activation(self): if task_details.get("isError"): self.status = "failed" - self.msg = "Activation of image '{0}' (ID: {1}) to the device with IP address {2} has failed.".format(image_name, image_id, device_ip) + self.msg = "Activation of image '{0}' (ID: {1}) to the device with IP address {2} has failed.".format( + image_name, image_id, device_ip) self.result['msg'] = self.msg self.result['response'] = task_details self.log(self.result['msg'], "ERROR") @@ -2013,16 +2144,21 @@ def get_diff_activation(self): self.log(self.msg, "WARNING") return self - self.log("Device UUIDs involved in Image Activation: {0}".format(str(device_uuid_list)), "INFO") + self.log("Device UUIDs involved in Image Activation: {0}".format( + str(device_uuid_list)), "INFO") activation_task_dict = {} for device_uuid in device_uuid_list: - self.log("Starting activation of image '{0}' to multiple devices.".format(image_name)) + self.log( + "Starting activation of image '{0}' to multiple devices.".format(image_name)) device_management_ip = self.get_device_ip_from_id(device_uuid) payload = [dict( - activateLowerImageVersion=activation_details.get("activate_lower_image_version"), - deviceUpgradeMode=activation_details.get("device_upgrade_mode"), - distributeIfNeeded=activation_details.get("distribute_if_needed"), + activateLowerImageVersion=activation_details.get( + "activate_lower_image_version"), + deviceUpgradeMode=activation_details.get( + "device_upgrade_mode"), + distributeIfNeeded=activation_details.get( + "distribute_if_needed"), deviceUuid=device_uuid, imageUuidList=[image_id] )] @@ -2031,7 +2167,8 @@ def get_diff_activation(self): schedule_validate=activation_details.get("scehdule_validate"), payload=payload ) - self.log("Activation Params: {0}".format(str(activation_params)), "INFO") + self.log("Activation Params: {0}".format( + str(activation_params)), "INFO") response = self.dnac._exec( family="software_image_management_swim", @@ -2039,30 +2176,35 @@ def get_diff_activation(self): op_modifies=True, params=activation_params, ) - self.log("Received API response from 'trigger_software_image_activation': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'trigger_software_image_activation': {0}".format( + str(response)), "DEBUG") if response: task_details = {} task_id = response.get("response").get("taskId") activation_task_dict[device_management_ip] = task_id - device_ips_list, device_activation_count = self.check_swim_task_status(activation_task_dict, 'Activation') + device_ips_list, device_activation_count = self.check_swim_task_status( + activation_task_dict, 'Activation') if device_activation_count == 0: self.status = "failed" - self.msg = "Image with Id '{0}' activation failed for all devices '{1}'".format(image_id, "', '".join(self.device_ips)) + self.msg = "Image with Id '{0}' activation failed for all devices '{1}'".format( + image_id, "', '".join(self.device_ips)) elif device_activation_count == len(device_uuid_list): self.result['changed'] = True self.status = "success" self.complete_successful_activation = True - self.msg = "Image with Id '{0}' activated successfully for all devices '{1}'".format(image_id, "', '".join(self.device_ips)) + self.msg = "Image with Id '{0}' activated successfully for all devices '{1}'".format( + image_id, "', '".join(self.device_ips)) else: self.result['changed'] = True self.status = "success" self.partial_successful_activation = True self.msg = ("Image with ID '{0}' was activated, but only partially successful. The image activation failed for the " "following device(s): {1}.").format(image_id, "', '".join(device_ips_list)) - self.log("Image activation failed for the following device(s): {0}".format(", ".join(device_ips_list)), "CRITICAL") + self.log("Image activation failed for the following device(s): {0}".format( + ", ".join(device_ips_list)), "CRITICAL") self.result['msg'] = self.msg self.result['response'] = self.msg @@ -2113,11 +2255,14 @@ def verify_diff_imported(self, import_type): names_of_images = [] if import_type == "remote": - image_names = self.want.get("url_import_details", {}).get("payload", [{}])[0].get("source_url", []) + image_names = self.want.get("url_import_details", {}).get( + "payload", [{}])[0].get("source_url", []) elif import_type == "local": - image_names = self.want.get("local_import_details", {}).get("file_path") + image_names = self.want.get( + "local_import_details", {}).get("file_path") else: - image_names = self.want.get("cco_import_details", {}).get("image_name") + image_names = self.want.get( + "cco_import_details", {}).get("image_name") if import_type == "remote": for image_name in image_names: @@ -2133,7 +2278,8 @@ def verify_diff_imported(self, import_type): if image_exist: self.status = "success" - self.msg = "The requested image '{0}' has been imported into the Cisco Catalyst Center and its presence has been verified.".format(imported_images) + self.msg = "The requested image '{0}' has been imported into the Cisco Catalyst Center and its presence has been verified.".format( + imported_images) self.log(self.msg, "INFO") else: self.log("The playbook input for SWIM image '{0}' does not align with the Cisco Catalyst Center," @@ -2167,10 +2313,12 @@ def verify_diff_tagged(self): image_params = dict( image_id=self.have.get("tagging_image_id"), site_id=self.have.get("site_id"), - device_family_identifier=self.have.get("device_family_identifier"), + device_family_identifier=self.have.get( + "device_family_identifier"), device_role=role.upper() ) - self.log("Parameters for checking the status of image: {0}".format(str(image_params)), "INFO") + self.log("Parameters for checking the status of image: {0}".format( + str(image_params)), "INFO") response = self.dnac._exec( family="software_image_management_swim", @@ -2178,12 +2326,14 @@ def verify_diff_tagged(self): op_modifies=True, params=image_params ) - self.log("Received API response from 'get_golden_tag_status_of_an_image': {0}".format(str(response)), "DEBUG") + self.log("Received API response from 'get_golden_tag_status_of_an_image': {0}".format( + str(response)), "DEBUG") response = response.get('response') if response: image_status = response['taggedGolden'] - self.log("Current golden tag status for image '{0}': {1}".format(image_name, image_status), "DEBUG") + self.log("Current golden tag status for image '{0}': {1}".format( + image_name, image_status), "DEBUG") if image_status == tag_image_golden: if tag_image_golden: self.msg = """The requested image '{0}' has been tagged as golden in the Cisco Catalyst Center and @@ -2360,7 +2510,8 @@ def main(): ccc_swims.get_have().check_return_status() ccc_swims.get_diff_state_apply[state](config).check_return_status() if config_verify: - ccc_swims.verify_diff_state_apply[state](config).check_return_status() + ccc_swims.verify_diff_state_apply[state]( + config).check_return_status() module.exit_json(**ccc_swims.result) diff --git a/plugins/modules/template_intent.py b/plugins/modules/template_intent.py index 53c42e0ce1..a8cfc8c338 100644 --- a/plugins/modules/template_intent.py +++ b/plugins/modules/template_intent.py @@ -5,9 +5,18 @@ """Ansible module to perform operations on project and templates in DNAC.""" from __future__ import absolute_import, division, print_function +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + get_dict_result, + dnac_compare_equality, +) +from ansible.module_utils.basic import AnsibleModule +import copy __metaclass__ = type -__author__ = ['Madhan Sankaranarayanan, Rishita Chowdhary, Akash Bhaskaran, Muthu Rakesh'] +__author__ = [ + 'Madhan Sankaranarayanan, Rishita Chowdhary, Akash Bhaskaran, Muthu Rakesh'] DOCUMENTATION = r""" --- @@ -1295,15 +1304,6 @@ """ -import copy -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - get_dict_result, - dnac_compare_equality, -) - class DnacTemplate(DnacBase): """Class containing member attributes for template intent module""" @@ -1453,7 +1453,8 @@ def validate_input(self): return self self.validated_config = valid_temp - self.log("Successfully validated playbook config params: {0}".format(valid_temp), "INFO") + self.log("Successfully validated playbook config params: {0}".format( + valid_temp), "INFO") self.msg = "Successfully validated input" self.status = "success" return self @@ -1559,7 +1560,8 @@ def get_validation_errors(self, validation_errors): return None validationErrors = {} - rollback_template_errors = validation_errors.get("rollback_template_errors") + rollback_template_errors = validation_errors.get( + "rollback_template_errors") if rollback_template_errors is not None: validationErrors.update({ "rollbackTemplateErrors": rollback_template_errors @@ -1602,7 +1604,8 @@ def get_template_info(self, template_params): templateParams = [] i = 0 - self.log("Template params details: {0}".format(template_params), "DEBUG") + self.log("Template params details: {0}".format( + template_params), "DEBUG") for item in template_params: self.log("Template params items: {0}".format(item), "DEBUG") templateParams.append({}) @@ -1667,7 +1670,8 @@ def get_template_info(self, template_params): return self.check_return_status() data_type = item.get("data_type") - datatypes = ["STRING", "INTEGER", "IPADDRESS", "MACADDRESS", "SECTIONDIVIDER"] + datatypes = ["STRING", "INTEGER", "IPADDRESS", + "MACADDRESS", "SECTIONDIVIDER"] if data_type is not None: templateParams[i].update({"dataType": data_type}) else: @@ -1675,7 +1679,8 @@ def get_template_info(self, template_params): self.status = "failed" return self.check_return_status() if data_type not in datatypes: - self.msg = "data_type under template_params should be in " + str(datatypes) + self.msg = "data_type under template_params should be in " + \ + str(datatypes) self.status = "failed" return self.check_return_status() @@ -1711,18 +1716,22 @@ def get_template_info(self, template_params): return self.check_return_status() j = j + 1 - self.log("Template params details: {0}".format(templateParams), "DEBUG") + self.log("Template params details: {0}".format( + templateParams), "DEBUG") selection = item.get("selection") - self.log("Template params selection: {0}".format(selection), "DEBUG") + self.log("Template params selection: {0}".format( + selection), "DEBUG") if selection is not None: templateParams[i].update({"selection": {}}) _selection = templateParams[i].get("selection") id = selection.get("id") if id is not None: _selection.update({"id": id}) - default_selected_values = selection.get("default_selected_values") + default_selected_values = selection.get( + "default_selected_values") if default_selected_values is not None: - _selection.update({"defaultSelectedValues": default_selected_values}) + _selection.update( + {"defaultSelectedValues": default_selected_values}) selection_values = selection.get("selection_values") if selection_values is not None: _selection.update({"selectionValues": selection_values}) @@ -1791,7 +1800,8 @@ def get_containing_templates(self, containing_templates): language_list = ["JINJA", "VELOCITY"] if language not in language_list: - self.msg = "language under containing templates should be in " + str(language_list) + self.msg = "language under containing templates should be in " + \ + str(language_list) self.status = "failed" return self.check_return_status() @@ -1813,7 +1823,8 @@ def get_containing_templates(self, containing_templates): template_content = item.get("template_content") if template_content is not None: - containingTemplates[i].update({"templateContent": template_content}) + containingTemplates[i].update( + {"templateContent": template_content}) template_params = item.get("template_params") if template_params is not None: @@ -1838,13 +1849,15 @@ def get_template_params(self, params): temp_params (dict) - Organized template parameters. """ - self.log("Template params playbook details: {0}".format(params), "DEBUG") + self.log("Template params playbook details: {0}".format( + params), "DEBUG") temp_params = { "tags": self.get_tags(params.get("template_tag")), "author": params.get("author"), "composite": params.get("composite"), "containingTemplates": - self.get_containing_templates(params.get("containing_templates")), + self.get_containing_templates( + params.get("containing_templates")), "createTime": params.get("create_time"), "customParamsOrder": params.get("custom_params_order"), "description": params.get("template_description"), @@ -1873,12 +1886,14 @@ def get_template_params(self, params): "version": params.get("version"), "project_id": params.get("project_id") } - self.log("Formatted template params details: {0}".format(temp_params), "DEBUG") + self.log("Formatted template params details: {0}".format( + temp_params), "DEBUG") copy_temp_params = copy.deepcopy(temp_params) for item in copy_temp_params: if temp_params[item] is None: del temp_params[item] - self.log("Formatted template params details: {0}".format(temp_params), "DEBUG") + self.log("Formatted template params details: {0}".format( + temp_params), "DEBUG") return temp_params def get_template(self, config): @@ -1902,7 +1917,8 @@ def get_template(self, config): if items: result = items - self.log("Received API response from 'get_template_details': {0}".format(items), "DEBUG") + self.log("Received API response from 'get_template_details': {0}".format( + items), "DEBUG") self.result['response'] = items return result @@ -1918,7 +1934,8 @@ def get_have_project(self, config): """ have_project = {} - given_projectName = config.get("configuration_templates").get("project_name") + given_projectName = config.get( + "configuration_templates").get("project_name") template_available = None # Check if project exists. @@ -1957,7 +1974,8 @@ def get_have_template(self, config, template_available): """ projectName = config.get("configuration_templates").get("project_name") - templateName = config.get("configuration_templates").get("template_name") + templateName = config.get( + "configuration_templates").get("template_name") template = None have_template = {} @@ -1971,7 +1989,8 @@ def get_have_template(self, config, template_available): if not template_details: self.log("Template {0} not found in project {1}" .format(templateName, projectName), "INFO") - self.msg = "Template : {0} missing, new template to be created".format(templateName) + self.msg = "Template : {0} missing, new template to be created".format( + templateName) self.status = "success" return self @@ -2071,7 +2090,8 @@ def get_want(self, config): if configuration_templates: template_params = self.get_template_params(configuration_templates) project_params = self.get_project_params(configuration_templates) - version_comments = configuration_templates.get("version_description") + version_comments = configuration_templates.get( + "version_description") if self.params.get("state") == "merged": self.update_mandatory_parameters(template_params) @@ -2128,7 +2148,8 @@ def create_project_or_template(self, is_create_project=False): task_id = response.get("response").get("taskId") if not task_id: - self.log("Task id {0} not found for '{1}'.".format(task_id, creation_value), "CRITICAL") + self.log("Task id {0} not found for '{1}'.".format( + task_id, creation_value), "CRITICAL") return creation_id, created while not created: @@ -2138,7 +2159,8 @@ def create_project_or_template(self, is_create_project=False): .format(creation_value, task_id), "CRITICAL") return creation_id, created - self.log("Task details for {0}: {1}".format(creation_value, task_details), "DEBUG") + self.log("Task details for {0}: {1}".format( + creation_value, task_details), "DEBUG") if task_details.get("isError"): self.log("Error occurred for '{0}' with taskid: {1}" .format(creation_value, task_id), "ERROR") @@ -2167,7 +2189,8 @@ def create_project_or_template(self, is_create_project=False): template_params["projectId"] = creation_id template_params["project_id"] = creation_id - self.log("New {0} created with id {1}".format(name, creation_id), "DEBUG") + self.log("New {0} created with id {1}".format( + name, creation_id), "DEBUG") return creation_id, created def requires_update(self): @@ -2306,7 +2329,8 @@ def get_export_template_values(self, export_values): ) for values in export_values: project_name = values.get("project_name") - self.log("Project name for export template: {0}".format(project_name), "DEBUG") + self.log("Project name for export template: {0}".format( + project_name), "DEBUG") template_details = template_details.get("response") self.log("Template details: {0}".format(template_details), "DEBUG") all_template_details = get_dict_result(template_details, @@ -2351,7 +2375,8 @@ def update_configuration_templates(self, config): project_id, project_created = \ self.create_project_or_template(is_create_project=True) if project_created: - self.log("project created with projectId: {0}".format(project_id), "DEBUG") + self.log("project created with projectId: {0}".format( + project_id), "DEBUG") else: self.status = "failed" self.msg = "Project creation failed" @@ -2359,8 +2384,10 @@ def update_configuration_templates(self, config): is_template_found = self.have_template.get("template_found") template_params = self.want.get("template_params") - self.log("Desired template details: {0}".format(template_params), "DEBUG") - self.log("Current template details: {0}".format(self.have_template), "DEBUG") + self.log("Desired template details: {0}".format( + template_params), "DEBUG") + self.log("Current template details: {0}".format( + self.have_template), "DEBUG") template_id = None template_updated = False self.validate_input_merge(is_template_found).check_return_status() @@ -2368,8 +2395,10 @@ def update_configuration_templates(self, config): if self.requires_update(): template_id = self.have_template.get("id") template_params.update({"id": template_id}) - self.log("Current State (have): {0}".format(self.have_template), "INFO") - self.log("Desired State (want): {0}".format(self.want), "INFO") + self.log("Current State (have): {0}".format( + self.have_template), "INFO") + self.log("Desired State (want): {0}".format( + self.want), "INFO") response = self.dnac_apply['exec']( family="configuration_templates", function="update_template", @@ -2416,7 +2445,8 @@ def update_configuration_templates(self, config): self.result['changed'] = True self.result['msg'] = task_details.get('progress') self.result['diff'] = config.get("configuration_templates") - self.log("Task details for 'version_template': {0}".format(task_details), "DEBUG") + self.log("Task details for 'version_template': {0}".format( + task_details), "DEBUG") self.result['response'] = task_details if task_details else response if not self.result.get('msg'): @@ -2455,7 +2485,8 @@ def handle_export(self, config): export_values = export.get("template") if export_values: - self.get_export_template_values(export_values).check_return_status() + self.get_export_template_values( + export_values).check_return_status() self.log("Exporting template playbook details: {0}" .format(self.export_template), "DEBUG") response = self.dnac._exec( @@ -2509,8 +2540,10 @@ def handle_import(self, config): params=_import_project, ) validation_string = "successfully imported project" - self.check_task_response_status(response, validation_string).check_return_status() - self.result['response'][0].update({"importProject": validation_string}) + self.check_task_response_status( + response, validation_string).check_return_status() + self.result['response'][0].update( + {"importProject": validation_string}) _import_template = _import.get("template") if _import_template.get("project_name"): @@ -2538,8 +2571,10 @@ def handle_import(self, config): params=import_template, ) validation_string = "successfully imported template" - self.check_task_response_status(response, validation_string).check_return_status() - self.result['response'][0].update({"importTemplate": validation_string}) + self.check_task_response_status( + response, validation_string).check_return_status() + self.result['response'][0].update( + {"importTemplate": validation_string}) return self @@ -2588,12 +2623,14 @@ def delete_project_or_template(self, config, is_delete_project=False): if is_delete_project: params_key = {"project_id": self.have_project.get("id")} deletion_value = "deletes_the_project" - name = "project: {0}".format(config.get("configuration_templates").get('project_name')) + name = "project: {0}".format(config.get( + "configuration_templates").get('project_name')) else: template_params = self.want.get("template_params") params_key = {"template_id": self.have_template.get("id")} deletion_value = "deletes_the_template" - name = "templateName: {0}".format(template_params.get('templateName')) + name = "templateName: {0}".format( + template_params.get('templateName')) response = self.dnac_apply['exec']( family="configuration_templates", @@ -2608,7 +2645,8 @@ def delete_project_or_template(self, config, is_delete_project=False): self.result['msg'] = task_details.get('progress') self.result['diff'] = config.get("configuration_templates") - self.log("Task details for '{0}': {1}".format(deletion_value, task_details), "DEBUG") + self.log("Task details for '{0}': {1}".format( + deletion_value, task_details), "DEBUG") self.result['response'] = task_details if task_details else response if not self.result['msg']: self.result['msg'] = "Error while deleting {name} : " @@ -2633,7 +2671,8 @@ def get_diff_deleted(self, config): configuration_templates = config.get("configuration_templates") if configuration_templates: is_project_found = self.have_project.get("project_found") - projectName = config.get("configuration_templates").get("project_name") + projectName = config.get( + "configuration_templates").get("project_name") if not is_project_found: self.msg = "Project {0} is not found".format(projectName) @@ -2642,12 +2681,14 @@ def get_diff_deleted(self, config): is_template_found = self.have_template.get("template_found") template_params = self.want.get("template_params") - templateName = config.get("configuration_templates").get("template_name") + templateName = config.get( + "configuration_templates").get("template_name") if template_params.get("name"): if is_template_found: self.delete_project_or_template(config) else: - self.msg = "Invalid template {0} under project".format(templateName) + self.msg = "Invalid template {0} under project".format( + templateName) self.status = "failed" return self else: @@ -2656,7 +2697,8 @@ def get_diff_deleted(self, config): .format(config.get("configuration_templates").get("project_name")), "INFO") is_project_deletable = self.have_project.get("isDeletable") if is_project_deletable: - self.delete_project_or_template(config, is_delete_project=True) + self.delete_project_or_template( + config, is_delete_project=True) else: self.msg = "Project is not deletable" self.status = "failed" @@ -2681,15 +2723,18 @@ def verify_diff_merged(self, config): if config.get("configuration_templates") is not None: is_template_available = self.get_have_project(config) - self.log("Template availability: {0}".format(is_template_available), "INFO") + self.log("Template availability: {0}".format( + is_template_available), "INFO") if not is_template_available: self.msg = "Configuration Template config is not applied to the DNAC." self.status = "failed" return self self.get_have_template(config, is_template_available) - self.log("Current State (have): {0}".format(self.want.get("template_params")), "INFO") - self.log("Desired State (want): {0}".format(self.have_template.get("template")), "INFO") + self.log("Current State (have): {0}".format( + self.want.get("template_params")), "INFO") + self.log("Desired State (want): {0}".format( + self.have_template.get("template")), "INFO") template_params = ["language", "name", "projectName", "softwareType", "softwareVariant", "templateContent"] for item in template_params: @@ -2697,7 +2742,8 @@ def verify_diff_merged(self, config): self.msg = " Configuration Template config is not applied to the DNAC." self.status = "failed" return self - self.log("Successfully validated the Template in the Catalyst Center.", "INFO") + self.log( + "Successfully validated the Template in the Catalyst Center.", "INFO") self.result.get("response").update({"Validation": "Success"}) self.msg = "Successfully validated the Configuration Templates." @@ -2727,7 +2773,8 @@ def verify_diff_deleted(self, config): params={"projectNames": config.get("projectName")}, ) if template_list and isinstance(template_list, list): - templateName = config.get("configuration_templates").get("template_name") + templateName = config.get( + "configuration_templates").get("template_name") template_info = get_dict_result(template_list, "name", templateName) @@ -2736,7 +2783,8 @@ def verify_diff_deleted(self, config): self.status = "failed" return self - self.log("Successfully validated absence of template in the Catalyst Center.", "INFO") + self.log( + "Successfully validated absence of template in the Catalyst Center.", "INFO") self.result.get("response").update({"Validation": "Success"}) self.msg = "Successfully validated the absence of Template in the DNAC." @@ -2797,7 +2845,8 @@ def main(): dnac_template.get_want(config).check_return_status() dnac_template.get_diff_state_apply[state](config).check_return_status() if config_verify: - dnac_template.verify_diff_state_apply[state](config).check_return_status() + dnac_template.verify_diff_state_apply[state]( + config).check_return_status() module.exit_json(**dnac_template.result) diff --git a/plugins/modules/template_workflow_manager.py b/plugins/modules/template_workflow_manager.py index 2f28205671..4facaf0ec6 100644 --- a/plugins/modules/template_workflow_manager.py +++ b/plugins/modules/template_workflow_manager.py @@ -5,9 +5,20 @@ """Ansible module to perform operations on project and templates in Cisco Catalyst Center.""" from __future__ import absolute_import, division, print_function +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + get_dict_result, + dnac_compare_equality, +) +from ansible.module_utils.basic import AnsibleModule +import time +import json +import copy __metaclass__ = type -__author__ = ['Madhan Sankaranarayanan, Rishita Chowdhary, Akash Bhaskaran, Muthu Rakesh, Abhishek Maheshwari'] +__author__ = [ + 'Madhan Sankaranarayanan, Rishita Chowdhary, Akash Bhaskaran, Muthu Rakesh, Abhishek Maheshwari'] DOCUMENTATION = r""" --- @@ -1174,17 +1185,6 @@ """ -import copy -import json -import time -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - get_dict_result, - dnac_compare_equality, -) - class Template(DnacBase): """Class containing member attributes for template_workflow_manager module""" @@ -1351,7 +1351,8 @@ def validate_input(self): return self self.validated_config = valid_temp - self.log("Successfully validated playbook config params: {0}".format(valid_temp), "INFO") + self.log("Successfully validated playbook config params: {0}".format( + valid_temp), "INFO") self.msg = "Successfully validated input" self.status = "success" return self @@ -1439,7 +1440,8 @@ def get_device_types(self, device_types): "NFVIS", "Routers", "Security and VPN", "Storage Networking", "Switches and Hubs", "Voice and Telephony", "Wireless Controller"] if product_family not in product_families_list: - self.msg = "The 'product_family should be in the following list {0}.".format(product_families_list) + self.msg = "The 'product_family should be in the following list {0}.".format( + product_families_list) self.status = "failed" return self.check_return_status() @@ -1470,7 +1472,8 @@ def get_template_info(self, template_params): templateParams = [] i = 0 - self.log("Template params details: {0}".format(template_params), "DEBUG") + self.log("Template params details: {0}".format( + template_params), "DEBUG") for item in template_params: self.log("Template params items: {0}".format(item), "DEBUG") templateParams.append({}) @@ -1535,7 +1538,8 @@ def get_template_info(self, template_params): return self.check_return_status() data_type = item.get("data_type") - datatypes = ["STRING", "INTEGER", "IPADDRESS", "MACADDRESS", "SECTIONDIVIDER"] + datatypes = ["STRING", "INTEGER", "IPADDRESS", + "MACADDRESS", "SECTIONDIVIDER"] if data_type is not None: templateParams[i].update({"dataType": data_type}) else: @@ -1543,7 +1547,8 @@ def get_template_info(self, template_params): self.status = "failed" return self.check_return_status() if data_type not in datatypes: - self.msg = "data_type under template_params should be in " + str(datatypes) + self.msg = "data_type under template_params should be in " + \ + str(datatypes) self.status = "failed" return self.check_return_status() @@ -1579,18 +1584,22 @@ def get_template_info(self, template_params): return self.check_return_status() j = j + 1 - self.log("Template params details: {0}".format(templateParams), "DEBUG") + self.log("Template params details: {0}".format( + templateParams), "DEBUG") selection = item.get("selection") - self.log("Template params selection: {0}".format(selection), "DEBUG") + self.log("Template params selection: {0}".format( + selection), "DEBUG") if selection is not None: templateParams[i].update({"selection": {}}) _selection = templateParams[i].get("selection") id = selection.get("id") if id is not None: _selection.update({"id": id}) - default_selected_values = selection.get("default_selected_values") + default_selected_values = selection.get( + "default_selected_values") if default_selected_values is not None: - _selection.update({"defaultSelectedValues": default_selected_values}) + _selection.update( + {"defaultSelectedValues": default_selected_values}) selection_values = selection.get("selection_values") if selection_values is not None: _selection.update({"selectionValues": selection_values}) @@ -1622,7 +1631,8 @@ def get_templates_details(self, name): if items: result = items - self.log("Received API response from 'get_templates_details': {0}".format(items), "DEBUG") + self.log("Received API response from 'get_templates_details': {0}".format( + items), "DEBUG") return result def get_project_defined_template_details(self, project_name, template_name): @@ -1635,7 +1645,8 @@ def get_project_defined_template_details(self, project_name, template_name): template_details (dict) - Template details for the given template name. """ - self.log("Starting to retrieve template details for project '{0}' and template '{1}'.".format(project_name, template_name), "INFO") + self.log("Starting to retrieve template details for project '{0}' and template '{1}'.".format( + project_name, template_name), "INFO") template_details = None try: items = self.dnac_apply['exec']( @@ -1649,13 +1660,17 @@ def get_project_defined_template_details(self, project_name, template_name): ) if items: template_details = items - self.log("Received template details for '{0}': {1}".format(template_name, template_details), "DEBUG") + self.log("Received template details for '{0}': {1}".format( + template_name, template_details), "DEBUG") else: - self.log("No template details found for project '{0}' and template '{1}'.".format(project_name, template_name), "WARNING") + self.log("No template details found for project '{0}' and template '{1}'.".format( + project_name, template_name), "WARNING") - self.log("Received API response from 'get_templates_details': {0}".format(template_details), "DEBUG") + self.log("Received API response from 'get_templates_details': {0}".format( + template_details), "DEBUG") except Exception as e: - self.log("Exception occurred while retrieving template details for '{0}': {1}".format(template_name, str(e)), "ERROR") + self.log("Exception occurred while retrieving template details for '{0}': {1}".format( + template_name, str(e)), "ERROR") return template_details @@ -1707,7 +1722,8 @@ def get_containing_templates(self, containing_templates): template_details = self.get_templates_details(name).get("response") if not template_details: - self.msg = "No template with the template name '{0}' or it is not versioned".format(name) + self.msg = "No template with the template name '{0}' or it is not versioned".format( + name) self.status = "failed" return self.check_return_status() @@ -1723,7 +1739,8 @@ def get_containing_templates(self, containing_templates): language_list = ["JINJA", "VELOCITY"] if language not in language_list: - self.msg = "language under containing templates should be in " + str(language_list) + self.msg = "language under containing templates should be in " + \ + str(language_list) self.status = "failed" return self.check_return_status() @@ -1738,7 +1755,8 @@ def get_containing_templates(self, containing_templates): containingTemplates[i].update({"projectName": project_name}) template_content = item.get("template_content") if template_content is not None: - containingTemplates[i].update({"templateContent": template_content}) + containingTemplates[i].update( + {"templateContent": template_content}) template_params = item.get("template_params") if template_params is not None: @@ -1765,13 +1783,15 @@ def get_template_params(self, params): temp_params (dict) - Organized template parameters. """ - self.log("Template params playbook details: {0}".format(params), "DEBUG") + self.log("Template params playbook details: {0}".format( + params), "DEBUG") temp_params = { "tags": self.get_tags(params.get("template_tag")), "author": params.get("author"), "composite": params.get("composite"), "containingTemplates": - self.get_containing_templates(params.get("containing_templates")), + self.get_containing_templates( + params.get("containing_templates")), "customParamsOrder": params.get("custom_params_order"), "description": params.get("template_description"), "deviceTypes": @@ -1824,7 +1844,8 @@ def get_template_params(self, params): "Cisco Controller", "Wide Area Application Services", "Adaptive Security Appliance", "NFV-OS", "Others"] if softwareType not in software_types_list: - self.msg = "The 'software_type' should be in the following list {0}.".format(software_types_list) + self.msg = "The 'software_type' should be in the following list {0}.".format( + software_types_list) self.status = "failed" return self.check_return_status() @@ -1834,13 +1855,15 @@ def get_template_params(self, params): failure_policy = params.get("failure_policy") failure_policy_list = ["ABORT_TARGET_ON_ERROR", None] if failure_policy not in failure_policy_list: - self.msg = "The 'failure_policy' should be in the following list {0}.".format(failure_policy) + self.msg = "The 'failure_policy' should be in the following list {0}.".format( + failure_policy) self.status = "failed" return self temp_params.update({"failurePolicy": failure_policy}) - self.log("Formatted template params details: {0}".format(temp_params), "DEBUG") + self.log("Formatted template params details: {0}".format( + temp_params), "DEBUG") copy_temp_params = copy.deepcopy(temp_params) for item in copy_temp_params: if temp_params[item] is None: @@ -1868,8 +1891,10 @@ def get_template(self, config): if items: result = items - self.log("Received API response from 'get_template_details': {0}".format(items), "DEBUG") - self.result['response'][0].get("configurationTemplate").update({"items": items}) + self.log("Received API response from 'get_template_details': {0}".format( + items), "DEBUG") + self.result['response'][0].get( + "configurationTemplate").update({"items": items}) return result def get_uncommitted_template_id(self, project_name, template_name): @@ -1915,9 +1940,11 @@ def get_uncommitted_template_id(self, project_name, template_name): for template in template_list: if template.get("name") == template_name: template_id = template.get("templateId") - self.log("Found uncommitted template '{0}' with ID: '{1}'.".format(template_name, template_id), "INFO") + self.log("Found uncommitted template '{0}' with ID: '{1}'.".format( + template_name, template_id), "INFO") return template_id - self.log("Template '{0}' not found in the uncommitted templates for project '{1}'.".format(template_name, project_name), "WARNING") + self.log("Template '{0}' not found in the uncommitted templates for project '{1}'.".format( + template_name, project_name), "WARNING") except Exception as e: error_msg = ( "Exception occurred while retrieving uncommitted template ID for project '{0}' and " @@ -1946,7 +1973,8 @@ def versioned_given_template(self, project_name, template_name, template_id): The function returns the class instance for further chaining of operations. """ - self.log("Starting the versioning process for template '{0}' in project '{1}'.".format(template_name, project_name), "INFO") + self.log("Starting the versioning process for template '{0}' in project '{1}'.".format( + template_name, project_name), "INFO") try: comments = ( "Given template '{0}' under the project '{1}' versioned successfully." @@ -1956,17 +1984,22 @@ def versioned_given_template(self, project_name, template_name, template_id): "comments": comments, "templateId": template_id } - self.log("Preparing to version template with parameters: {0}".format(version_params), "DEBUG") + self.log("Preparing to version template with parameters: {0}".format( + version_params), "DEBUG") task_name = "version_template" - task_id = self.get_taskid_post_api_call("configuration_templates", task_name, version_params) + task_id = self.get_taskid_post_api_call( + "configuration_templates", task_name, version_params) if not task_id: - self.msg = "Unable to retrieve the task_id for the task '{0}'.".format(task_name) + self.msg = "Unable to retrieve the task_id for the task '{0}'.".format( + task_name) self.set_operation_result("failed", False, self.msg, "ERROR") return self - success_msg = "Given template '{0}' versioned/committed successfully in the Cisco Catalyst Center.".format(template_name) - self.get_task_status_from_tasks_by_id(task_id, task_name, success_msg) + success_msg = "Given template '{0}' versioned/committed successfully in the Cisco Catalyst Center.".format( + template_name) + self.get_task_status_from_tasks_by_id( + task_id, task_name, success_msg) except Exception as e: self.msg = ( @@ -1989,7 +2022,8 @@ def get_have_project(self, config): """ have_project = {} - given_projectName = config.get("configuration_templates").get("project_name") + given_projectName = config.get( + "configuration_templates").get("project_name") template_available = None # Check if project exists. @@ -2028,7 +2062,8 @@ def get_have_template(self, config, template_available): """ projectName = config.get("configuration_templates").get("project_name") - templateName = config.get("configuration_templates").get("template_name") + templateName = config.get( + "configuration_templates").get("template_name") template = None have_template = {} @@ -2042,7 +2077,8 @@ def get_have_template(self, config, template_available): if not template_details: self.log("Template {0} not found in project {1}" .format(templateName, projectName), "INFO") - self.msg = "Template : {0} missing, new template to be created".format(templateName) + self.msg = "Template : {0} missing, new template to be created".format( + templateName) self.status = "success" return self @@ -2105,18 +2141,22 @@ def get_have(self, config): if deploy_temp_details: template_name = deploy_temp_details.get("template_name") project_name = deploy_temp_details.get("project_name") - self.log("Fetching template details for '{0}' under project '{1}'.".format(template_name, project_name), "INFO") - temp_details = self.get_project_defined_template_details(project_name, template_name).get("response") + self.log("Fetching template details for '{0}' under project '{1}'.".format( + template_name, project_name), "INFO") + temp_details = self.get_project_defined_template_details( + project_name, template_name).get("response") if temp_details: - self.log("Given template '{0}' is already committed in the Catalyst Center.".format(template_name), "INFO") + self.log("Given template '{0}' is already committed in the Catalyst Center.".format( + template_name), "INFO") have["temp_id"] = temp_details[0].get("id") self.log("Successfully collected the details for the template '{0}' from the " "Cisco Catalyst Center.".format(template_name), "INFO" ) else: - self.log("No details found for template '{0}' under project '{1}'.".format(template_name, project_name), "WARNING") + self.log("No details found for template '{0}' under project '{1}'.".format( + template_name, project_name), "WARNING") self.have = have @@ -2162,7 +2202,8 @@ def get_want(self, config): if configuration_templates: template_params = self.get_template_params(configuration_templates) project_params = self.get_project_params(configuration_templates) - version_comments = configuration_templates.get("version_description") + version_comments = configuration_templates.get( + "version_description") if self.params.get("state") == "merged": self.update_mandatory_parameters(template_params) @@ -2182,7 +2223,8 @@ def get_want(self, config): self.set_operation_result("failed", False, self.msg, "ERROR") return self - self.log("Project name '{0}' found in the playbook.".format(project_name), "INFO") + self.log("Project name '{0}' found in the playbook.".format( + project_name), "INFO") template_name = deploy_temp_details.get("template_name") if not template_name: self.msg = ( @@ -2192,9 +2234,11 @@ def get_want(self, config): self.set_operation_result("failed", False, self.msg, "ERROR") return self - self.log("Template name '{0}' found in the playbook.".format(template_name), "INFO") + self.log("Template name '{0}' found in the playbook.".format( + template_name), "INFO") device_details = deploy_temp_details.get("device_details") - site_provisioning_details = deploy_temp_details.get("site_provisioning_details") + site_provisioning_details = deploy_temp_details.get( + "site_provisioning_details") if not (device_details or site_provisioning_details): self.msg = ( @@ -2204,7 +2248,8 @@ def get_want(self, config): self.set_operation_result("failed", False, self.msg, "ERROR") return self - self.log("Proceeding with deployment details for template '{0}'.".format(template_name), "INFO") + self.log("Proceeding with deployment details for template '{0}'.".format( + template_name), "INFO") want["deploy_tempate"] = deploy_temp_details self.want = want @@ -2255,7 +2300,8 @@ def create_project_or_template(self, is_create_project=False): task_id = response.get("response").get("taskId") if not task_id: - self.log("Task id {0} not found for '{1}'.".format(task_id, creation_value), "CRITICAL") + self.log("Task id {0} not found for '{1}'.".format( + task_id, creation_value), "CRITICAL") return creation_id, created while not created: @@ -2265,7 +2311,8 @@ def create_project_or_template(self, is_create_project=False): .format(creation_value, task_id), "CRITICAL") return creation_id, created - self.log("Task details for {0}: {1}".format(creation_value, task_details), "DEBUG") + self.log("Task details for {0}: {1}".format( + creation_value, task_details), "DEBUG") if task_details.get("isError"): self.log("Error occurred for '{0}' with taskid: {1}" .format(creation_value, task_id), "ERROR") @@ -2294,7 +2341,8 @@ def create_project_or_template(self, is_create_project=False): template_params["projectId"] = creation_id template_params["project_id"] = creation_id - self.log("New {0} created with id {1}".format(name, creation_id), "DEBUG") + self.log("New {0} created with id {1}".format( + name, creation_id), "DEBUG") return creation_id, created def requires_update(self): @@ -2425,8 +2473,10 @@ def get_export_template_values(self, export_values): all_project_details = all_project_details.get("response") for values in export_values: project_name = values.get("project_name") - self.log("Project name for export template: {0}".format(project_name), "DEBUG") - self.log("Template details: {0}".format(all_project_details), "DEBUG") + self.log("Project name for export template: {0}".format( + project_name), "DEBUG") + self.log("Template details: {0}".format( + all_project_details), "DEBUG") project_details = get_dict_result(all_project_details, "name", project_name) @@ -2485,12 +2535,15 @@ def update_configuration_templates(self, configuration_templates): self.msg = "Project creation failed" return self - self.log("project created with projectId: {0}".format(project_id), "DEBUG") + self.log("project created with projectId: {0}".format( + project_id), "DEBUG") is_template_found = self.have_template.get("template_found") template_params = self.want.get("template_params") - self.log("Desired template details: {0}".format(template_params), "DEBUG") - self.log("Current template details: {0}".format(self.have_template), "DEBUG") + self.log("Desired template details: {0}".format( + template_params), "DEBUG") + self.log("Current template details: {0}".format( + self.have_template), "DEBUG") template_id = None template_updated = False self.validate_input_merge(is_template_found).check_return_status() @@ -2506,7 +2559,8 @@ def update_configuration_templates(self, configuration_templates): template_id = self.have_template.get("id") template_params.update({"id": template_id}) - self.log("Current State (have): {0}".format(self.have_template), "INFO") + self.log("Current State (have): {0}".format( + self.have_template), "INFO") self.log("Desired State (want): {0}".format(self.want), "INFO") response = self.dnac_apply['exec']( family="configuration_templates", @@ -2544,10 +2598,14 @@ def update_configuration_templates(self, configuration_templates): return self task_details = self.get_task_details(task_id) self.result['changed'] = True - self.result['response'][0].get("configurationTemplate")['msg'] = task_details.get('progress') - self.result['response'][0].get("configurationTemplate")['diff'] = configuration_templates - self.log("Task details for 'version_template': {0}".format(task_details), "DEBUG") - self.result['response'][0].get("configurationTemplate")['response'] = task_details if task_details else response + self.result['response'][0].get("configurationTemplate")[ + 'msg'] = task_details.get('progress') + self.result['response'][0].get("configurationTemplate")[ + 'diff'] = configuration_templates + self.log("Task details for 'version_template': {0}".format( + task_details), "DEBUG") + self.result['response'][0].get("configurationTemplate")[ + 'response'] = task_details if task_details else response if not self.result['response'][0].get("configurationTemplate").get('msg'): self.msg = "Error while versioning the template" @@ -2555,7 +2613,8 @@ def update_configuration_templates(self, configuration_templates): return self else: task_details = self.get_task_details(template_id) - self.log('Getting task details from task ID {0}: {1}'.format(template_id, task_details), "DEBUG") + self.log('Getting task details from task ID {0}: {1}'.format( + template_id, task_details), "DEBUG") if task_details.get("failureReason"): self.msg = str(task_details.get("failureReason")) else: @@ -2592,11 +2651,13 @@ def handle_export(self, export): validation_string, "export_projects", True).check_return_status() - self.result['response'][1].get("export").get("response").update({"exportProject": self.msg}) + self.result['response'][1].get("export").get( + "response").update({"exportProject": self.msg}) export_values = export.get("template") if export_values: - self.get_export_template_values(export_values).check_return_status() + self.get_export_template_values( + export_values).check_return_status() self.log("Exporting template playbook details: {0}" .format(self.export_template), "DEBUG") response = self.dnac._exec( @@ -2612,7 +2673,8 @@ def handle_export(self, export): validation_string, "export_templates", True).check_return_status() - self.result['response'][1].get("export").get("response").update({"exportTemplate": self.msg}) + self.result['response'][1].get("export").get( + "response").update({"exportTemplate": self.msg}) return self @@ -2644,13 +2706,15 @@ def handle_import(self, _import): if project_file: is_path_exists = self.is_path_exists(project_file) if not is_path_exists: - self.msg = "Import project file path '{0}' does not exist.".format(project_file) + self.msg = "Import project file path '{0}' does not exist.".format( + project_file) self.status = "failed" return self is_json = self.is_json(project_file) if not is_json: - self.msg = "Import project file '{0}' is not in JSON format".format(project_file) + self.msg = "Import project file '{0}' is not in JSON format".format( + project_file) self.status = "failed" return self try: @@ -2659,7 +2723,8 @@ def handle_import(self, _import): json_project = json.loads(json_data) final_payload = json_project except Exception as msg: - self.msg = "An unexpected error occurred while processing the file '{0}': {1}".format(project_file, msg) + self.msg = "An unexpected error occurred while processing the file '{0}': {1}".format( + project_file, msg) self.status = "failed" return self elif payload: @@ -2683,8 +2748,10 @@ def handle_import(self, _import): params=_import_project, ) validation_string = "successfully imported project" - self.check_task_response_status(response, validation_string, "imports_the_projects_provided").check_return_status() - self.result['response'][2].get("import").get("response").update({"importProject": "Successfully imported the project(s)."}) + self.check_task_response_status( + response, validation_string, "imports_the_projects_provided").check_return_status() + self.result['response'][2].get("import").get("response").update( + {"importProject": "Successfully imported the project(s)."}) else: self.msg = "Projects '{0}' already available.".format(payload) self.result['response'][2].get("import").get("response").update({ @@ -2720,13 +2787,15 @@ def handle_import(self, _import): if template_file: is_path_exists = self.is_path_exists(template_file) if not is_path_exists: - self.msg = "Import template file path '{0}' does not exist.".format(template_file) + self.msg = "Import template file path '{0}' does not exist.".format( + template_file) self.status = "failed" return self is_json = self.is_json(template_file) if not is_json: - self.msg = "Import template file '{0}' is not in JSON format".format(template_file) + self.msg = "Import template file '{0}' is not in JSON format".format( + template_file) self.status = "failed" return self try: @@ -2735,7 +2804,8 @@ def handle_import(self, _import): json_template = json.loads(json_data) final_payload = json_template except Exception as msg: - self.msg = "An unexpected error occurred while processing the file '{0}': {1}".format(template_file, msg) + self.msg = "An unexpected error occurred while processing the file '{0}': {1}".format( + template_file, msg) self.status = "failed" return self @@ -2769,7 +2839,8 @@ def handle_import(self, _import): params=import_template ) validation_string = "successfully imported template" - self.check_task_response_status(response, validation_string, "imports_the_templates_provided").check_return_status() + self.check_task_response_status( + response, validation_string, "imports_the_templates_provided").check_return_status() self.result['response'][2].get("import").get("response") \ .update({"importTemplate": "Successfully imported the templates"}) @@ -2801,12 +2872,14 @@ def filter_devices_with_family_role(self, site_assign_device_ids, device_family= filtered_device_list = [] self.log("Filtering devices from the provided site-assigned device IDs: {0}, device_family='{1}', " - "and device_role='{2}'".format(site_assign_device_ids, device_family, device_role), "DEBUG" + "and device_role='{2}'".format( + site_assign_device_ids, device_family, device_role), "DEBUG" ) for device_id in site_assign_device_ids: try: - self.log("Processing device ID: {0}".format(device_id), "DEBUG") + self.log("Processing device ID: {0}".format( + device_id), "DEBUG") response = self.dnac._exec( family="devices", function='get_device_list', @@ -2820,24 +2893,29 @@ def filter_devices_with_family_role(self, site_assign_device_ids, device_family= if response and "response" in response: response_data = response.get("response") else: - self.log("No valid response for device with ID '{0}'.".format(device_id), "INFO") + self.log("No valid response for device with ID '{0}'.".format( + device_id), "INFO") continue if not response_data: self.log( - "Device with ID '{0}' does not match family '{1}' or role '{2}'.".format(device_id, device_family, device_role), + "Device with ID '{0}' does not match family '{1}' or role '{2}'.".format( + device_id, device_family, device_role), "INFO" ) continue - self.log("Device with ID '{0}' matches the criteria.".format(device_id), "DEBUG") + self.log("Device with ID '{0}' matches the criteria.".format( + device_id), "DEBUG") filtered_device_list.append(device_id) except Exception as e: - error_message = "Error while getting the response of device from Cisco Catalyst Center: {0}".format(str(e)) + error_message = "Error while getting the response of device from Cisco Catalyst Center: {0}".format( + str(e)) self.log(error_message, "CRITICAL") continue - self.log("Completed filtering. Filtered devices: {0}".format(filtered_device_list), "DEBUG") + self.log("Completed filtering. Filtered devices: {0}".format( + filtered_device_list), "DEBUG") return filtered_device_list @@ -2874,16 +2952,19 @@ def get_latest_template_version_id(self, template_id, template_name): if not response or not isinstance(response, list) or not response[0].get("versionsInfo"): self.log( - "No version information found for template '{0}' in Cisco Catalyst Center.".format(template_name), "INFO" + "No version information found for template '{0}' in Cisco Catalyst Center.".format( + template_name), "INFO" ) return version_temp_id self.log( - "Successfully retrieved version information for template '{0}'.".format(template_name), "DEBUG" + "Successfully retrieved version information for template '{0}'.".format( + template_name), "DEBUG" ) versions_info = response[0].get("versionsInfo") self.log( - "Processing version details for template '{0}': {1}".format(template_name, str(versions_info)), "DEBUG" + "Processing version details for template '{0}': {1}".format( + template_name, str(versions_info)), "DEBUG" ) latest_version = max(versions_info, key=lambda x: x["versionTime"]) version_temp_id = latest_version.get("id") @@ -2893,10 +2974,12 @@ def get_latest_template_version_id(self, template_id, template_name): ) except Exception as e: - error_message = "Error while getting the latest version id for the template '{0}': '{1}'".format(template_name, str(e)) + error_message = "Error while getting the latest version id for the template '{0}': '{1}'".format( + template_name, str(e)) self.log(error_message, "CRITICAL") self.log( - "Returning latest version ID '{0}' for template '{1}'.".format(version_temp_id, template_name), "DEBUG" + "Returning latest version ID '{0}' for template '{1}'.".format( + version_temp_id, template_name), "DEBUG" ) return version_temp_id @@ -2935,25 +3018,30 @@ def create_payload_for_template_deploy(self, deploy_temp_details, device_ids): template_id = self.have.get("temp_id") else: self.log( - "Fetching uncommitted template ID for template '{0}' in project '{1}'.".format(template_name, project_name), + "Fetching uncommitted template ID for template '{0}' in project '{1}'.".format( + template_name, project_name), "DEBUG" ) - template_id = self.get_uncommitted_template_id(project_name, template_name) + template_id = self.get_uncommitted_template_id( + project_name, template_name) if not template_id: self.msg = ( "Unable to fetch the details for the template '{0}' from the Cisco " "Catalyst Center." ).format(template_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() self.log( - "Template '{0}' is available but not committed yet. Committing template...".format(template_name), + "Template '{0}' is available but not committed yet. Committing template...".format( + template_name), "INFO" ) # Commit or versioned the given template in the Catalyst Center - self.versioned_given_template(project_name, template_name, template_id).check_return_status() + self.versioned_given_template( + project_name, template_name, template_id).check_return_status() deploy_payload = { "forcePushTemplate": deploy_temp_details.get("force_push", False), @@ -2961,7 +3049,8 @@ def create_payload_for_template_deploy(self, deploy_temp_details, device_ids): "templateId": template_id, } self.log( - "Handling template parameters for the deployment of template '{0}'.".format(template_name), + "Handling template parameters for the deployment of template '{0}'.".format( + template_name), "DEBUG" ) target_info_list = [] @@ -2972,23 +3061,29 @@ def create_payload_for_template_deploy(self, deploy_temp_details, device_ids): "It appears that no template parameters were provided in the playbook. Unfortunately, this " "means we cannot proceed with deploying template '{0}' to the devices." ).format(template_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() for param in template_parameters: name = param["param_name"] value = param["param_value"] - self.log("Update the template placeholder for the name '{0}' with value {1}".format(name, value), "DEBUG") + self.log("Update the template placeholder for the name '{0}' with value {1}".format( + name, value), "DEBUG") template_dict[name] = value # Get the latest version template ID - version_template_id = self.get_latest_template_version_id(template_id, template_name) + version_template_id = self.get_latest_template_version_id( + template_id, template_name) if not version_template_id: - self.log("No versioning found for the template: {0}".format(template_name), "INFO") + self.log("No versioning found for the template: {0}".format( + template_name), "INFO") version_template_id = template_id - self.log("Preparing to deploy template '{0}' to the following device IDs: '{1}'".format(template_name, device_ids), "DEBUG") + self.log("Preparing to deploy template '{0}' to the following device IDs: '{1}'".format( + template_name, device_ids), "DEBUG") for device_id in device_ids: - self.log("Adding device '{0}' to the deployment payload.".format(device_id), "DEBUG") + self.log("Adding device '{0}' to the deployment payload.".format( + device_id), "DEBUG") target_device_dict = { "id": device_id, "type": "MANAGED_DEVICE_UUID", @@ -2999,7 +3094,8 @@ def create_payload_for_template_deploy(self, deploy_temp_details, device_ids): del target_device_dict deploy_payload["targetInfo"] = target_info_list - self.log("Successfully generated deployment payload for template '{0}'.".format(template_name), "INFO") + self.log("Successfully generated deployment payload for template '{0}'.".format( + template_name), "INFO") return deploy_payload @@ -3027,25 +3123,31 @@ def deploy_template_to_devices(self, deploy_temp_payload, template_name, device_ """ try: - self.log("Deploying the given template {0} to the device(s) {1}.".format(template_name, device_ips)) + self.log("Deploying the given template {0} to the device(s) {1}.".format( + template_name, device_ips)) payload = {"payload": deploy_temp_payload} task_name = "deploy_template_v2" - task_id = self.get_taskid_post_api_call("configuration_templates", task_name, payload) + task_id = self.get_taskid_post_api_call( + "configuration_templates", task_name, payload) if not task_id: - self.msg = "Unable to retrieve the task_id for the task '{0}'.".format(task_name) + self.msg = "Unable to retrieve the task_id for the task '{0}'.".format( + task_name) self.set_operation_result("failed", False, self.msg, "ERROR") return self loop_start_time = time.time() sleep_duration = self.params.get('dnac_task_poll_interval') - self.log("Starting task monitoring for '{0}' with task ID '{1}'.".format(task_name, task_id), "DEBUG") + self.log("Starting task monitoring for '{0}' with task ID '{1}'.".format( + task_name, task_id), "DEBUG") while True: task_details = self.get_task_details_by_id(task_id) if not task_details: - self.msg = "Error retrieving task status for '{0}' with task ID '{1}'".format(task_name, task_id) - self.set_operation_result("failed", False, self.msg, "ERROR") + self.msg = "Error retrieving task status for '{0}' with task ID '{1}'".format( + task_name, task_id) + self.set_operation_result( + "failed", False, self.msg, "ERROR") return self # Check if the elapsed time exceeds the timeout @@ -3058,12 +3160,15 @@ def deploy_template_to_devices(self, deploy_temp_payload, template_name, device_ return self progress = task_details.get("progress") - self.log("Task ID '{0}' details for the API '{1}': {2}".format(task_id, task_name, progress), "DEBUG") + self.log("Task ID '{0}' details for the API '{1}': {2}".format( + task_id, task_name, progress), "DEBUG") if "not deploying" in progress: - self.log("Deployment of the template {0} gets failed because of: {1}".format(template_name, progress), "WARNING") + self.log("Deployment of the template {0} gets failed because of: {1}".format( + template_name, progress), "WARNING") self.msg = progress - self.set_operation_result("failed", False, self.msg, "ERROR") + self.set_operation_result( + "failed", False, self.msg, "ERROR") return self if "ApplicableTargets" in progress: @@ -3071,10 +3176,12 @@ def deploy_template_to_devices(self, deploy_temp_payload, template_name, device_ "Given template '{0}' deployed successfully to all the device(s) '{1}' " " in the Cisco Catalyst Center." ).format(template_name, device_ips) - self.set_operation_result("success", True, self.msg, "INFO") + self.set_operation_result( + "success", True, self.msg, "INFO") return self - self.log("Waiting for {0} seconds before checking the task status again.".format(sleep_duration), "DEBUG") + self.log("Waiting for {0} seconds before checking the task status again.".format( + sleep_duration), "DEBUG") time.sleep(sleep_duration) except Exception as e: @@ -3100,7 +3207,8 @@ def get_device_ips_from_config_priority(self, device_details): If none of the information is available, an empty list is returned. """ # Retrieve device IPs from the configuration - self.log("Retrieving device IPs based on the configuration priority with details: {0}".format(device_details), "INFO") + self.log("Retrieving device IPs based on the configuration priority with details: {0}".format( + device_details), "INFO") try: device_ips = device_details.get("device_ips") @@ -3111,22 +3219,28 @@ def get_device_ips_from_config_priority(self, device_details): # If device IPs are not available, check hostnames device_hostnames = device_details.get("device_hostnames") if device_hostnames: - self.log("No device IPs found. Checking hostnames: {0}".format(device_hostnames), "INFO") - device_ip_dict = self.get_device_ips_from_hostnames(device_hostnames) + self.log("No device IPs found. Checking hostnames: {0}".format( + device_hostnames), "INFO") + device_ip_dict = self.get_device_ips_from_hostnames( + device_hostnames) return self.get_list_from_dict_values(device_ip_dict) # If hostnames are not available, check serial numbers device_serial_numbers = device_details.get("serial_numbers") if device_serial_numbers: - self.log("No device IPs or hostnames found. Checking serial numbers: {0}".format(device_serial_numbers), "INFO") - device_ip_dict = self.get_device_ips_from_serial_numbers(device_serial_numbers) + self.log("No device IPs or hostnames found. Checking serial numbers: {0}".format( + device_serial_numbers), "INFO") + device_ip_dict = self.get_device_ips_from_serial_numbers( + device_serial_numbers) return self.get_list_from_dict_values(device_ip_dict) # If serial numbers are not available, check MAC addresses device_mac_addresses = device_details.get("mac_addresses") if device_mac_addresses: - self.log("No device IPs, hostnames, or serial numbers found. Checking MAC addresses: {0}".format(device_mac_addresses), "INFO") - device_ip_dict = self.get_device_ips_from_mac_addresses(device_mac_addresses) + self.log("No device IPs, hostnames, or serial numbers found. Checking MAC addresses: {0}".format( + device_mac_addresses), "INFO") + device_ip_dict = self.get_device_ips_from_mac_addresses( + device_mac_addresses) return self.get_list_from_dict_values(device_ip_dict) # If no information is available, return an empty list @@ -3157,7 +3271,8 @@ def get_device_ids_from_tag(self, tag_name, tag_id): """ device_ids = [] - self.log("Fetching device IDs associated with the tag '{0}' (ID: {1}).".format(tag_name, tag_id), "INFO") + self.log("Fetching device IDs associated with the tag '{0}' (ID: {1}).".format( + tag_name, tag_id), "INFO") try: response = self.dnac._exec( @@ -3172,17 +3287,21 @@ def get_device_ids_from_tag(self, tag_name, tag_id): if response and "response" in response: response_data = response.get("response") else: - self.log("No valid response for device with tag ID '{0}'.".format(tag_id), "INFO") + self.log("No valid response for device with tag ID '{0}'.".format( + tag_id), "INFO") return device_ids if not response_data: - self.log("No device(s) are associated with the tag '{0}'.".format(tag_name), "WARNING") + self.log("No device(s) are associated with the tag '{0}'.".format( + tag_name), "WARNING") return device_ids - self.log("Received API response from 'get_tag_members_by_id' for the tag {0}: {1}".format(tag_name, response_data), "DEBUG") + self.log("Received API response from 'get_tag_members_by_id' for the tag {0}: {1}".format( + tag_name, response_data), "DEBUG") for tag in response_data: device_id = tag.get("id") - self.log("Device ID '{0}' found for tag '{1}'.".format(device_id, tag_name), "DEBUG") + self.log("Device ID '{0}' found for tag '{1}'.".format( + device_id, tag_name), "DEBUG") device_ids.append(device_id) except Exception as e: @@ -3190,7 +3309,8 @@ def get_device_ids_from_tag(self, tag_name, tag_id): "Exception occurred while fetching tag id for the tag '{0} 'from " "Cisco Catalyst Center: {1}" ).format(tag_name, str(e)) - self.set_operation_result("failed", False, self.msg, "INFO").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "INFO").check_return_status() return device_ids @@ -3212,7 +3332,8 @@ def get_diff_merged(self, config): configuration_templates = config.get("configuration_templates") if configuration_templates: - self.update_configuration_templates(configuration_templates).check_return_status() + self.update_configuration_templates( + configuration_templates).check_return_status() _import = config.get("import") if _import: @@ -3227,24 +3348,33 @@ def get_diff_merged(self, config): if deploy_temp_details: template_name = deploy_temp_details.get("template_name") device_details = deploy_temp_details.get("device_details") - site_specific_details = deploy_temp_details.get("site_provisioning_details") - self.log("Deploy template details found for template '{0}'".format(template_name), "DEBUG") - self.log("Device specific details: {0}".format(device_details), "DEBUG") - self.log("Site associated provisioning details: {0}".format(site_specific_details), "DEBUG") + site_specific_details = deploy_temp_details.get( + "site_provisioning_details") + self.log("Deploy template details found for template '{0}'".format( + template_name), "DEBUG") + self.log("Device specific details: {0}".format( + device_details), "DEBUG") + self.log("Site associated provisioning details: {0}".format( + site_specific_details), "DEBUG") if device_details: - self.log("Attempting to retrieve device IPs based on priority from device specific details.", "DEBUG") - device_ips = self.get_device_ips_from_config_priority(device_details) + self.log( + "Attempting to retrieve device IPs based on priority from device specific details.", "DEBUG") + device_ips = self.get_device_ips_from_config_priority( + device_details) if not device_ips: self.msg = ( "No matching device management IP addresses found for the " "deployment of template '{0}'." ).format(template_name) - self.set_operation_result("failed", False, self.msg, "ERROR") + self.set_operation_result( + "failed", False, self.msg, "ERROR") return self - self.log("Successfully retrieved device IPs for template '{0}': '{1}'".format(template_name, device_ips), "INFO") - device_id_dict = self.get_device_ids_from_device_ips(device_ips) + self.log("Successfully retrieved device IPs for template '{0}': '{1}'".format( + template_name, device_ips), "INFO") + device_id_dict = self.get_device_ids_from_device_ips( + device_ips) device_ids = self.get_list_from_dict_values(device_id_dict) device_missing_msg = ( @@ -3257,17 +3387,21 @@ def get_diff_merged(self, config): for site in site_specific_details: site_name = site.get("site_name") site_exists, site_id = self.get_site_id(site_name) - self.log("Checking if the site '{0}' exists in Cisco Catalyst Center.".format(site_name), "DEBUG") + self.log("Checking if the site '{0}' exists in Cisco Catalyst Center.".format( + site_name), "DEBUG") if not site_exists: self.msg = ( "To Deploy the template in the devices, given site '{0}' must be " "present in the Cisco Catalyst Center and it's not there currently." ).format(site_name) - self.set_operation_result("failed", False, self.msg, "ERROR") + self.set_operation_result( + "failed", False, self.msg, "ERROR") return self - self.log("Retrieving devices associated with site ID '{0}' for site '{1}'.".format(site_id, site_name), "DEBUG") - site_response, site_assign_device_ids = self.get_device_ids_from_site(site_name, site_id) + self.log("Retrieving devices associated with site ID '{0}' for site '{1}'.".format( + site_id, site_name), "DEBUG") + site_response, site_assign_device_ids = self.get_device_ids_from_site( + site_name, site_id) site_name_list.append(site_name) if not site_assign_device_ids: @@ -3288,36 +3422,48 @@ def get_diff_merged(self, config): "Filtering devices based on the device family '{0}' or role '{1}' for the site '{2}'.".format( device_family, device_role, site_name), "DEBUG" ) - self.log("Filtering devices based on the given family/role for the site {0}.".format(site_name), "INFO") - site_assign_device_ids = self.filter_devices_with_family_role(site_assign_device_ids, device_family, device_role) + self.log( + "Filtering devices based on the given family/role for the site {0}.".format(site_name), "INFO") + site_assign_device_ids = self.filter_devices_with_family_role( + site_assign_device_ids, device_family, device_role) # Filter devices based on the device tag given to the devices tag_name = site.get("device_tag") tag_device_ids = None if tag_name: - self.log("Filtering out the devices based on the given device tag: '{0}'".format(tag_name), "INFO") + self.log("Filtering out the devices based on the given device tag: '{0}'".format( + tag_name), "INFO") tag_id = self.get_network_device_tag_id(tag_name) - self.log("Successfully collected the tag id '{0}' for the tag '{1}'".format(tag_id, tag_name), "INFO") + self.log("Successfully collected the tag id '{0}' for the tag '{1}'".format( + tag_id, tag_name), "INFO") # Get the device ids associated with the given tag for given site - tag_device_ids = self.get_device_ids_from_tag(tag_name, tag_id) - self.log("Successfully collected the device ids {0} associated with the tag {1}".format(tag_device_ids, tag_name), "INFO") + tag_device_ids = self.get_device_ids_from_tag( + tag_name, tag_id) + self.log("Successfully collected the device ids {0} associated with the tag {1}".format( + tag_device_ids, tag_name), "INFO") - self.log("Getting the device ids based on device assoicated with tag or site or both.", "DEBUG") + self.log( + "Getting the device ids based on device assoicated with tag or site or both.", "DEBUG") if tag_device_ids and site_assign_device_ids: - self.log("Determining device IDs from site and tag criteria.", "DEBUG") - common_device_ids = list(set(tag_device_ids).intersection(set(site_assign_device_ids))) + self.log( + "Determining device IDs from site and tag criteria.", "DEBUG") + common_device_ids = list( + set(tag_device_ids).intersection(set(site_assign_device_ids))) device_ids.extend(common_device_ids) elif site_assign_device_ids and not tag_device_ids: - self.log("Getting the device ids based on devices fetched from site.", "DEBUG") + self.log( + "Getting the device ids based on devices fetched from site.", "DEBUG") device_ids.extend(site_assign_device_ids) elif tag_device_ids and not site_assign_device_ids: - self.log("Getting the device ids based on devices fetched with the tag {0}.".format(tag_name), "DEBUG") + self.log("Getting the device ids based on devices fetched with the tag {0}.".format( + tag_name), "DEBUG") device_ids.extend(tag_device_ids) else: self.log( "There is no matching device ids found for the deployment of template {0} " - "for the given site {1}".format(template_name, site_name), "WARNING" + "for the given site {1}".format( + template_name, site_name), "WARNING" ) continue @@ -3331,7 +3477,8 @@ def get_diff_merged(self, config): "not given in the playboook. Please provide it either via the parameter " "device_details or with site_provisioning_details." ).format(self.msg) - self.set_operation_result("failed", False, self.msg, "INFO").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "INFO").check_return_status() if not device_ids: self.msg = device_missing_msg @@ -3340,11 +3487,16 @@ def get_diff_merged(self, config): device_ip_dict = self.get_device_ips_from_device_ids(device_ids) device_ips = self.get_list_from_dict_values(device_ip_dict) - self.log("Successfully collect the device ips {0} for the device ids {1}.".format(device_ips, device_ids), "INFO") - deploy_temp_payload = self.create_payload_for_template_deploy(deploy_temp_details, device_ids) - self.log("Deployment payload created successfully for template '{0}'.".format(template_name), "INFO") - self.deploy_template_to_devices(deploy_temp_payload, template_name, device_ips).check_return_status() - self.log("Successfully deployed template '{0}'.".format(template_name), "INFO") + self.log("Successfully collect the device ips {0} for the device ids {1}.".format( + device_ips, device_ids), "INFO") + deploy_temp_payload = self.create_payload_for_template_deploy( + deploy_temp_details, device_ids) + self.log("Deployment payload created successfully for template '{0}'.".format( + template_name), "INFO") + self.deploy_template_to_devices( + deploy_temp_payload, template_name, device_ips).check_return_status() + self.log("Successfully deployed template '{0}'.".format( + template_name), "INFO") self.msg = "Successfully completed merged state execution" self.status = "success" @@ -3366,12 +3518,14 @@ def delete_project_or_template(self, config, is_delete_project=False): if is_delete_project: params_key = {"project_id": self.have_project.get("id")} deletion_value = "deletes_the_project" - name = "project: {0}".format(config.get("configuration_templates").get('project_name')) + name = "project: {0}".format(config.get( + "configuration_templates").get('project_name')) else: template_params = self.want.get("template_params") params_key = {"template_id": self.have_template.get("id")} deletion_value = "deletes_the_template" - name = "templateName: {0}".format(template_params.get('templateName')) + name = "templateName: {0}".format( + template_params.get('templateName')) response = self.dnac_apply['exec']( family="configuration_templates", @@ -3382,23 +3536,28 @@ def delete_project_or_template(self, config, is_delete_project=False): task_id = response.get("response").get("taskId") sleep_duration = self.params.get('dnac_task_poll_interval') if not task_id: - self.msg = "Unable to retrieve the task ID for the task '{0}'.".format(deletion_value) + self.msg = "Unable to retrieve the task ID for the task '{0}'.".format( + deletion_value) self.set_operation_result("failed", False, self.msg, "ERROR") return self while True: task_details = self.get_task_details_by_id(task_id) - self.log("Printing task details: {0}".format(task_details), "DEBUG") + self.log("Printing task details: {0}".format( + task_details), "DEBUG") if not task_details: - self.msg = "Unable to delete {0} as task details is empty.".format(deletion_value) + self.msg = "Unable to delete {0} as task details is empty.".format( + deletion_value) self.set_operation_result("failed", False, self.msg, "ERROR") return self progress = task_details.get("progress") - self.log("Task details for the API {0}: {1}".format(deletion_value, progress), "DEBUG") + self.log("Task details for the API {0}: {1}".format( + deletion_value, progress), "DEBUG") if "deleted" in progress: - self.log("Successfully perform the operation of {0} for {1}".format(deletion_value, name), "INFO") + self.log("Successfully perform the operation of {0} for {1}".format( + deletion_value, name), "INFO") self.msg = "Successfully deleted {0} ".format(name) self.set_operation_result("success", True, self.msg, "INFO") break @@ -3410,11 +3569,13 @@ def delete_project_or_template(self, config, is_delete_project=False): "Failed to perform the operation of {0} for {1} because of: {2}" ).format(deletion_value, name, failure_reason) else: - self.msg = "Failed to perform the operation of {0} for {1}.".format(deletion_value, name) + self.msg = "Failed to perform the operation of {0} for {1}.".format( + deletion_value, name) self.set_operation_result("failed", False, self.msg, "ERROR") break - self.log("Waiting for {0} seconds before checking the task status again.".format(sleep_duration), "DEBUG") + self.log("Waiting for {0} seconds before checking the task status again.".format( + sleep_duration), "DEBUG") time.sleep(sleep_duration) return self @@ -3433,7 +3594,8 @@ def get_diff_deleted(self, config): configuration_templates = config.get("configuration_templates") if configuration_templates: is_project_found = self.have_project.get("project_found") - projectName = config.get("configuration_templates").get("project_name") + projectName = config.get( + "configuration_templates").get("project_name") if not is_project_found: self.msg = "Project {0} is not found".format(projectName) @@ -3442,7 +3604,8 @@ def get_diff_deleted(self, config): is_template_found = self.have_template.get("template_found") template_params = self.want.get("template_params") - templateName = config.get("configuration_templates").get("template_name") + templateName = config.get( + "configuration_templates").get("template_name") if template_params.get("name"): if is_template_found: self.delete_project_or_template(config) @@ -3450,7 +3613,8 @@ def get_diff_deleted(self, config): self.result['response'][0].get("configurationTemplate").update({ "msg": "Template with template_name '{0}' already deleted".format(templateName) }) - self.msg = "Invalid template {0} under project".format(templateName) + self.msg = "Invalid template {0} under project".format( + templateName) self.status = "success" return self else: @@ -3459,7 +3623,8 @@ def get_diff_deleted(self, config): .format(config.get("configuration_templates").get("project_name")), "INFO") is_project_deletable = self.have_project.get("isDeletable") if is_project_deletable: - self.delete_project_or_template(config, is_delete_project=True) + self.delete_project_or_template( + config, is_delete_project=True) else: self.msg = "Project is not deletable" self.status = "failed" @@ -3472,7 +3637,8 @@ def get_diff_deleted(self, config): "Deleting or removing the device configuration using deployment of template is not supported " "for the template {0} in the Cisco Catalyst Center." ).format(template_name) - self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() + self.set_operation_result( + "failed", False, self.msg, "ERROR").check_return_status() self.msg = "Successfully completed delete state execution" self.status = "success" @@ -3493,17 +3659,21 @@ def verify_diff_merged(self, config): if config.get("configuration_templates") is not None: is_template_available = self.get_have_project(config) - self.log("Template availability: {0}".format(is_template_available), "INFO") + self.log("Template availability: {0}".format( + is_template_available), "INFO") if not is_template_available: self.msg = "Configuration Template config is not applied to the Cisco Catalyst Center." self.status = "failed" return self self.get_have_template(config, is_template_available) - self.log("Desired State (have): {0}".format(self.want.get("template_params")), "INFO") - self.log("Current State (want): {0}".format(self.have_template.get("template")), "INFO") + self.log("Desired State (have): {0}".format( + self.want.get("template_params")), "INFO") + self.log("Current State (want): {0}".format( + self.have_template.get("template")), "INFO") if not self.have_template.get("template"): - self.msg = "No template created with the name '{0}'".format(self.want.get("template_params").get("name")) + self.msg = "No template created with the name '{0}'".format( + self.want.get("template_params").get("name")) self.status = "failed" return self @@ -3518,11 +3688,13 @@ def verify_diff_merged(self, config): self.status = "failed" return self - want_template_containing_template = want_template.get("containingTemplates") + want_template_containing_template = want_template.get( + "containingTemplates") if want_template_containing_template: for item in want_template_containing_template: name = item.get("name") - response = get_dict_result(have_template.get("containingTemplates"), "name", name) + response = get_dict_result(have_template.get( + "containingTemplates"), "name", name) if response is None: self.msg = "Configuration Template config with template_name '{0}' under ".format(name) + \ "'containing_templates' is not available in the Cisco Catalyst Center." @@ -3531,12 +3703,15 @@ def verify_diff_merged(self, config): for value in item: if item.get(value) != response.get(value): self.msg = "Configuration Template config with template_name " + \ - "{0}'s '{1}' is not applied to the Cisco Catalyst Center.".format(name, value) + "{0}'s '{1}' is not applied to the Cisco Catalyst Center.".format( + name, value) self.status = "failed" return self - self.log("Successfully validated the Template in the Catalyst Center.", "INFO") - self.result['response'][0].get("configurationTemplate").get("response").update({"Validation": "Success"}) + self.log( + "Successfully validated the Template in the Catalyst Center.", "INFO") + self.result['response'][0].get("configurationTemplate").get( + "response").update({"Validation": "Success"}) self.msg = "Successfully validated the Configuration Templates." self.status = "success" @@ -3562,10 +3737,12 @@ def verify_diff_deleted(self, config): family="configuration_templates", function="gets_the_templates_available", op_modifies=True, - params={"projectNames": config.get("configuration_templates").get("project_name")}, + params={"projectNames": config.get( + "configuration_templates").get("project_name")}, ) if template_list and isinstance(template_list, list): - templateName = config.get("configuration_templates").get("template_name") + templateName = config.get( + "configuration_templates").get("template_name") template_info = get_dict_result(template_list, "name", templateName) @@ -3574,8 +3751,10 @@ def verify_diff_deleted(self, config): self.status = "failed" return self - self.log("Successfully validated absence of template in the Catalyst Center.", "INFO") - self.result['response'][0].get("configurationTemplate").get("response").update({"Validation": "Success"}) + self.log( + "Successfully validated absence of template in the Catalyst Center.", "INFO") + self.result['response'][0].get("configurationTemplate").get( + "response").update({"Validation": "Success"}) self.msg = "Successfully validated the absence of Template in the Cisco Catalyst Center." self.status = "success" @@ -3636,7 +3815,8 @@ def main(): ccc_template.get_want(config).check_return_status() ccc_template.get_diff_state_apply[state](config).check_return_status() if config_verify: - ccc_template.verify_diff_state_apply[state](config).check_return_status() + ccc_template.verify_diff_state_apply[state]( + config).check_return_status() module.exit_json(**ccc_template.result) diff --git a/plugins/modules/user_role_workflow_manager.py b/plugins/modules/user_role_workflow_manager.py index 6e1d0072e5..89b1d18564 100644 --- a/plugins/modules/user_role_workflow_manager.py +++ b/plugins/modules/user_role_workflow_manager.py @@ -4,8 +4,16 @@ # 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 +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + validate_list +) +import re __metaclass__ = type -__author__ = ("Ajith Andrew J, Syed khadeer Ahmed, Rangaprabhu Deenadayalu, Madhan Sankaranarayanan") +__author__ = ( + "Ajith Andrew J, Syed khadeer Ahmed, Rangaprabhu Deenadayalu, Madhan Sankaranarayanan") DOCUMENTATION = r""" --- @@ -877,17 +885,10 @@ } """ -import re -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - validate_list -) -from ansible.module_utils.basic import AnsibleModule - class UserandRole(DnacBase): """Class containing member attributes for user workflow_manager module""" + def __init__(self, module): super().__init__(module) self.result["response"] = [] @@ -946,16 +947,19 @@ def validate_input_yml(self, user_role_details): "system": {"required": False, "type": "list", "elements": "dict"}, "utilities": {"required": False, "type": "list", "elements": "dict"}, } - valid_param, invalid_param = validate_list_of_dicts(user_role_details, role_details) + valid_param, invalid_param = validate_list_of_dicts( + user_role_details, role_details) if invalid_param: - self.msg = "Invalid parameter(s) found in playbook: {0}".format(", ".join(invalid_param)) + self.msg = "Invalid parameter(s) found in playbook: {0}".format( + ", ".join(invalid_param)) self.log(self.msg, "ERROR") self.status = "failed" return self self.validated_config = valid_param - self.msg = "Successfully validated playbook config params: {0}".format(str(valid_param[0])) + self.msg = "Successfully validated playbook config params: {0}".format( + str(valid_param[0])) self.log(self.msg, "INFO") self.status = "success" return self @@ -963,15 +967,18 @@ def validate_input_yml(self, user_role_details): if "user_details" in config and "username" in user_role_details[0] or "email" in user_role_details[0]: for user in user_role_details: if 'password' in user: - encrypt_password_response = self.encrypt_password(user['password'], self.key.get("generate_key")) + encrypt_password_response = self.encrypt_password( + user['password'], self.key.get("generate_key")) if encrypt_password_response and "error_message" in encrypt_password_response: - self.msg = encrypt_password_response.get("error_message") + self.msg = encrypt_password_response.get( + "error_message") self.log(self.msg, "ERROR") self.status = "failed" return self - user["password"] = encrypt_password_response.get("encrypt_password") + user["password"] = encrypt_password_response.get( + "encrypt_password") if user_role_details[0].get("username") is not None or user_role_details[0].get("email") is not None: user_details = { @@ -985,22 +992,26 @@ def validate_input_yml(self, user_role_details): } try: - valid_param, invalid_param = validate_list_of_dicts(user_role_details, user_details) + valid_param, invalid_param = validate_list_of_dicts( + user_role_details, user_details) except Exception as e: - self.log("Unexpected error occurred: {0}".format(str(e)), "ERROR") + self.log("Unexpected error occurred: {0}".format( + str(e)), "ERROR") self.msg = "{0}.".format(str(e).split('.', maxsplit=1)[0]) self.log(self.msg, "ERROR") self.status = "failed" return self if invalid_param: - self.msg = "Invalid parameter(s) found in playbook: {0}".format(", ".join(invalid_param)) + self.msg = "Invalid parameter(s) found in playbook: {0}".format( + ", ".join(invalid_param)) self.log(self.msg, "ERROR") self.status = "failed" return self self.validated_config = valid_param - self.msg = "Successfully validated playbook config params:{0}".format(str(valid_param[0])) + self.msg = "Successfully validated playbook config params:{0}".format( + str(valid_param[0])) self.log(self.msg, "INFO") self.status = "success" return self @@ -1020,7 +1031,8 @@ def validate_string_parameter(self, param_name, param_value, error_messages): """ # Check if the parameter value is a string if not isinstance(param_value, str): - error_messages.append("Parameter '{0}' must be a string.".format(param_name)) + error_messages.append( + "Parameter '{0}' must be a string.".format(param_name)) def validate_string_field(self, field_value, regex, error_message, error_messages): """ @@ -1074,14 +1086,18 @@ def validate_password(self, password, error_messages): break if not meets_character_requirements: - self.log("Password failed character type and length validation.", "ERROR") + self.log( + "Password failed character type and length validation.", "ERROR") error_messages.append(password_criteria_message) - self.log("Checking that the password does not contain repetitive or sequential characters.", "DEBUG") + self.log( + "Checking that the password does not contain repetitive or sequential characters.", "DEBUG") if re.match(password_sequence_repetitive_regex, password): - self.log("Password passed repetitive and sequential character checks.", "INFO") + self.log( + "Password passed repetitive and sequential character checks.", "INFO") else: - self.log("Password failed repetitive or sequential character validation.", "ERROR") + self.log( + "Password failed repetitive or sequential character validation.", "ERROR") error_messages.append(password_criteria_message) def validate_role_parameters(self, role_key, params_list, role_config, role_param_map, error_messages): @@ -1094,19 +1110,24 @@ def validate_role_parameters(self, role_key, params_list, role_config, role_para self.log("Validating role: {0}".format(role), "DEBUG") for param in params_list: if role.get(param): - self.log("Validating parameter '{0}' with value '{1}'".format(param, role[param]), "DEBUG") - self.validate_string_parameter(param, role[param], error_messages) + self.log("Validating parameter '{0}' with value '{1}'".format( + param, role[param]), "DEBUG") + self.validate_string_parameter( + param, role[param], error_messages) if role == "network_provision": - inventory_management_list = role.get("inventory_management", []) + inventory_management_list = role.get( + "inventory_management", []) if inventory_management_list is not None: for inventory_management in inventory_management_list: - self.log("Validating inventory management: {0}".format(inventory_management), "DEBUG") + self.log("Validating inventory management: {0}".format( + inventory_management), "DEBUG") for param in role_param_map["inventory_management"]: if inventory_management.get(param): self.log("Validating inventory management parameter '{0}' with value '{1}'".format(param, inventory_management[param]), "DEBUG") - self.validate_string_parameter(param, inventory_management[param], error_messages) + self.validate_string_parameter( + param, inventory_management[param], error_messages) def identify_invalid_params(self, params, mismatches): """ @@ -1131,12 +1152,14 @@ def identify_invalid_params(self, params, mismatches): "scheduler", "search", 'role_name', 'description', 'assurance', 'network_analytics', 'network_design', 'network_provision', 'network_services', 'platform', 'security', 'system', 'utilities', 'overall' ] - self.log("Starting to iterate through params to identify unknown parameters.", "DEBUG") + self.log( + "Starting to iterate through params to identify unknown parameters.", "DEBUG") if isinstance(params, dict): for key, value in params.items(): if key not in allowed_params: - self.log("Invalid parameter detected: {0}".format(key), "ERROR") + self.log( + "Invalid parameter detected: {0}".format(key), "ERROR") mismatches.append(key) if isinstance(value, dict) or isinstance(value, list): @@ -1183,16 +1206,19 @@ def valid_role_config_parameters(self, role_config): role_name_regex_msg = "Role names must be 1 to 25 characters long and should contain only letters, numbers, periods, underscores, and hyphens." if role_name: - self.validate_string_field(role_name, role_name_regex, "role_name: '{0}' {1}".format(role_name, role_name_regex_msg), error_messages) + self.validate_string_field(role_name, role_name_regex, "role_name: '{0}' {1}".format( + role_name, role_name_regex_msg), error_messages) else: error_messages.append(role_name_regex_msg) description = role_config["description"] if description: if len(description) > 1000: - error_messages.append("Role description exceeds the maximum length of 1000 characters.") + error_messages.append( + "Role description exceeds the maximum length of 1000 characters.") else: - self.validate_string_parameter("description", description, error_messages) + self.validate_string_parameter( + "description", description, error_messages) role_param_map = { "assurance": ["overall", "monitoring_and_troubleshooting", "monitoring_settings", "troubleshooting_tools"], @@ -1209,15 +1235,18 @@ def valid_role_config_parameters(self, role_config): } for role_key, params_list in role_param_map.items(): - self.validate_role_parameters(role_key, params_list, role_config, role_param_map, error_messages) + self.validate_role_parameters( + role_key, params_list, role_config, role_param_map, error_messages) if error_messages: - self.msg = "Invalid parameters in playbook config: {0}".format(", ".join(error_messages)) + self.msg = "Invalid parameters in playbook config: {0}".format( + ", ".join(error_messages)) self.log(self.msg, "ERROR") self.status = "failed" return self - self.msg = "Successfully validated config params: {0}".format(str(role_config)) + self.msg = "Successfully validated config params: {0}".format( + str(role_config)) self.log(self.msg, "INFO") self.status = "success" return self @@ -1253,7 +1282,8 @@ def valid_user_config_parameters(self, user_config): password = user_config.get("password") if password: - decrypt_password_response = self.decrypt_password(password, self.key.get("generate_key")) + decrypt_password_response = self.decrypt_password( + password, self.key.get("generate_key")) if decrypt_password_response and "error_message" in decrypt_password_response: self.msg = decrypt_password_response.get("error_message") @@ -1261,10 +1291,12 @@ def valid_user_config_parameters(self, user_config): self.status = "failed" return self - user_config['password'] = decrypt_password_response.get("decrypt_password") + user_config['password'] = decrypt_password_response.get( + "decrypt_password") plain_password = user_config.get("password") self.validate_password(plain_password, error_messages) - encrypt_password_response = self.encrypt_password(plain_password, self.key.get("generate_key")) + encrypt_password_response = self.encrypt_password( + plain_password, self.key.get("generate_key")) if encrypt_password_response and "error_message" in encrypt_password_response: self.msg = encrypt_password_response.get("error_message") @@ -1272,8 +1304,10 @@ def valid_user_config_parameters(self, user_config): self.status = "failed" return self - user_config['password'] = encrypt_password_response.get("encrypt_password").decode() - self.log("Password decrypted, validated, and re-encrypted successfully.", "DEBUG") + user_config['password'] = encrypt_password_response.get( + "encrypt_password").decode() + self.log( + "Password decrypted, validated, and re-encrypted successfully.", "DEBUG") username_regex = re.compile(r"^[A-Za-z0-9@._-]{3,50}$") username_regex_msg = "The username must not contain any special characters and must be 3 to 50 characters long." @@ -1283,15 +1317,18 @@ def valid_user_config_parameters(self, user_config): if user_config.get("role_list"): param_spec = dict(type="list", elements="str") - validate_list(user_config["role_list"], param_spec, "role_list", error_messages) + validate_list(user_config["role_list"], + param_spec, "role_list", error_messages) if error_messages: - self.msg = "Invalid parameters in playbook config: {0}".format(str(", ".join(error_messages))) + self.msg = "Invalid parameters in playbook config: {0}".format( + str(", ".join(error_messages))) self.log(self.msg, "ERROR") self.status = "failed" return self - self.msg = "Successfully validated config params:{0}".format(str(user_config)) + self.msg = "Successfully validated config params:{0}".format( + str(user_config)) self.log(self.msg, "INFO") self.status = "success" return self @@ -1355,14 +1392,19 @@ def get_have(self, input_config): have = {} if "role_name" in input_config and input_config["role_name"] is not None: - role_exists, current_role_config = self.get_current_config(input_config) - self.log("Current role config details (have): {0}".format(str(current_role_config)), "DEBUG") + role_exists, current_role_config = self.get_current_config( + input_config) + self.log("Current role config details (have): {0}".format( + str(current_role_config)), "DEBUG") self.update_have_with_role(have, role_exists, current_role_config) if "username" in input_config or "email" in input_config: - user_exists, current_user_config, current_role_id_config = self.get_current_config(input_config) - self.log("Current user config details (have): {0}".format(str(current_user_config)), "DEBUG") - self.update_have_with_user(have, user_exists, current_user_config, current_role_id_config) + user_exists, current_user_config, current_role_id_config = self.get_current_config( + input_config) + self.log("Current user config details (have): {0}".format( + str(current_user_config)), "DEBUG") + self.update_have_with_user( + have, user_exists, current_user_config, current_role_id_config) self.have = have self.log("Current State (have): {0}".format(str(self.have)), "INFO") @@ -1393,13 +1435,16 @@ def get_diff_merged(self, config): if self.have.get("role_exists"): self.valid_role_config_parameters(config).check_return_status() desired_role = self.generate_role_payload(self.want, "update") - self.log("desired role with config {0}".format(str(desired_role)), "DEBUG") + self.log("desired role with config {0}".format( + str(desired_role)), "DEBUG") if "error_message" not in desired_role: - consolidated_data, update_required_param = self.role_requires_update(self.have["current_role_config"], desired_role) + consolidated_data, update_required_param = self.role_requires_update( + self.have["current_role_config"], desired_role) if not consolidated_data: - self.msg = "Role with role_name '{0}' already exists and does not require an update.".format(self.have.get("role_name")) + self.msg = "Role with role_name '{0}' already exists and does not require an update.".format( + self.have.get("role_name")) self.no_update_role.append(self.have.get("role_name")) self.log(self.msg, "INFO") responses["role_operation"] = {"response": config} @@ -1413,13 +1458,18 @@ def get_diff_merged(self, config): else: # Create the role self.valid_role_config_parameters(config).check_return_status() - self.log("Creating role with config {0}".format(str(config)), "DEBUG") - role_info_params = self.generate_role_payload(self.want, "create") + self.log("Creating role with config {0}".format( + str(config)), "DEBUG") + role_info_params = self.generate_role_payload( + self.want, "create") if "error_message" not in role_info_params: - filtered_data, overall_update_required = self.get_permissions(self.want, role_info_params, "create") - denied_permissions = self.find_denied_permissions(self.want) - denied_required, create_role_params = self.remove_denied_operations(filtered_data, denied_permissions) + filtered_data, overall_update_required = self.get_permissions( + self.want, role_info_params, "create") + denied_permissions = self.find_denied_permissions( + self.want) + denied_required, create_role_params = self.remove_denied_operations( + filtered_data, denied_permissions) if denied_required or overall_update_required: task_response = self.create_role(create_role_params) @@ -1432,16 +1482,20 @@ def get_diff_merged(self, config): # update the user if role exists if self.have.get("user_exists"): self.valid_user_config_parameters(config).check_return_status() - (consolidated_data, update_required_param) = self.user_requires_update(self.have["current_user_config"], self.have["current_role_id_config"]) + (consolidated_data, update_required_param) = self.user_requires_update( + self.have["current_user_config"], self.have["current_role_id_config"]) if self.want.get("password_update"): if update_required_param.get("role_list"): if self.want["username"] not in self.have["current_user_config"]["username"]: - task_response = {"error_message": "Username for an existing user cannot be updated."} + task_response = { + "error_message": "Username for an existing user cannot be updated."} else: self.get_diff_deleted(self.want) - update_required_param["password"] = self.want.get("password") - user_info_params = self.snake_to_camel_case(update_required_param) + update_required_param["password"] = self.want.get( + "password") + user_info_params = self.snake_to_camel_case( + update_required_param) task_response = self.create_user(user_info_params) else: task_response = { @@ -1451,7 +1505,8 @@ def get_diff_merged(self, config): else: if not consolidated_data: username = self.have.get("username") - self.msg = "User with username '{0}' already exists and does not require an update.".format(username) + self.msg = "User with username '{0}' already exists and does not require an update.".format( + username) self.no_update_user.append(username) self.log(self.msg, "INFO") responses["role_operation"] = {"response": config} @@ -1461,12 +1516,15 @@ def get_diff_merged(self, config): if update_required_param.get("role_list"): if self.want["username"] not in self.have["current_user_config"]["username"]: - task_response = {"error_message": "Username for an existing user cannot be updated."} + task_response = { + "error_message": "Username for an existing user cannot be updated."} else: user_in_have = self.have["current_user_config"] update_param = update_required_param - update_param["user_id"] = user_in_have.get("user_id") - user_info_params = self.snake_to_camel_case(update_param) + update_param["user_id"] = user_in_have.get( + "user_id") + user_info_params = self.snake_to_camel_case( + update_param) task_response = self.update_user(user_info_params) else: task_response = { @@ -1476,7 +1534,8 @@ def get_diff_merged(self, config): else: # Create the user self.valid_user_config_parameters(config).check_return_status() - self.log("Creating user with config {0}".format(str(config)), "DEBUG") + self.log("Creating user with config {0}".format( + str(config)), "DEBUG") user_params = self.want user_details = {} @@ -1485,19 +1544,22 @@ def get_diff_merged(self, config): if key != "role_list": user_details[key] = value else: - current_role = self.have.get("current_role_id_config") + current_role = self.have.get( + "current_role_id_config") user_details[key] = [] for role_name in user_params["role_list"]: role_id = current_role.get(role_name.lower()) if role_id: user_details[key].append(role_id) else: - self.log("Role ID for {0} not found in current_role_id_config".format(str(role_name)), "DEBUG") + self.log("Role ID for {0} not found in current_role_id_config".format( + str(role_name)), "DEBUG") if "role_list" not in user_details: default_role = self.have.get("current_role_id_config") if default_role: - user_details["role_list"] = [default_role.get("observer-role")] + user_details["role_list"] = [ + default_role.get("observer-role")] if user_details.get("role_list"): user_info_params = self.snake_to_camel_case(user_details) @@ -1552,7 +1614,8 @@ def get_current_config(self, input_config): current_role_id = {} if "role_name" in input_config and input_config["role_name"] is not None: - self.log("Retrieving role details for role_name: {0}".format(str(input_config["role_name"])), "DEBUG") + self.log("Retrieving role details for role_name: {0}".format( + str(input_config["role_name"])), "DEBUG") response_role = self.get_role() response_role = self.camel_to_snake_case(response_role) @@ -1593,13 +1656,16 @@ def get_current_config(self, input_config): for role_name in input_config["role_list"]: for role in roles: if role.get("name").lower() == role_name.lower(): - current_role_id[role.get("name").lower()] = role.get("role_id") + current_role_id[role.get( + "name").lower()] = role.get("role_id") else: for role in roles: if role.get("name").lower() == "observer-role": - current_role_id[role.get("name").lower()] = role.get("role_id") + current_role_id[role.get( + "name").lower()] = role.get("role_id") - self.log("Role ID retrieval result - current_role_id: {0}".format(str(current_role_id)), "DEBUG") + self.log( + "Role ID retrieval result - current_role_id: {0}".format(str(current_role_id)), "DEBUG") return user_exists, current_user_configuration, current_role_id def create_user(self, user_params): @@ -1619,7 +1685,8 @@ def create_user(self, user_params): self.log("Create user with 'user_params' argument...", "DEBUG") if user_params.get('password'): - decrypt_password_response = self.decrypt_password(user_params['password'], self.key.get("generate_key")) + decrypt_password_response = self.decrypt_password( + user_params['password'], self.key.get("generate_key")) if "error_message" in decrypt_password_response: self.msg = decrypt_password_response.get("error_message") @@ -1627,18 +1694,21 @@ def create_user(self, user_params): self.status = "failed" return self - user_params['password'] = decrypt_password_response.get("decrypt_password") + user_params['password'] = decrypt_password_response.get( + "decrypt_password") required_keys = ['username', 'password'] missing_keys = [] - self.log("Check if each required key is present in the user_params dictionary...", "DEBUG") + self.log( + "Check if each required key is present in the user_params dictionary...", "DEBUG") for key in required_keys: if key not in user_params: missing_keys.append(key) if missing_keys: - error_message = "Mandatory parameter(s) '{0}' not present in the user details.".format(", ".join(missing_keys)) + error_message = "Mandatory parameter(s) '{0}' not present in the user details.".format( + ", ".join(missing_keys)) return {"error_message": error_message} try: @@ -1648,7 +1718,8 @@ def create_user(self, user_params): op_modifies=True, params=user_params, ) - self.log("Received API response from create_user: {0}".format(str(response)), "DEBUG") + self.log("Received API response from create_user: {0}".format( + str(response)), "DEBUG") self.created_user.append(user_params.get("username")) return response @@ -1660,7 +1731,8 @@ def create_user(self, user_params): self.payload.get("dnac_username")) ) else: - error_message = "Invalid email format for '{0}' associated with username '{1}'".format(user_params.get("email"), user_params.get("username")) + error_message = "Invalid email format for '{0}' associated with username '{1}'".format( + user_params.get("email"), user_params.get("username")) return {"error_message": error_message} @@ -1681,19 +1753,22 @@ def create_role(self, role_params): if self.compare_dnac_versions(self.get_ccc_version(), "2.3.7.6") >= 0: try: - self.log("Create role with role_info_params: {0}".format(str(role_params)), "DEBUG") + self.log("Create role with role_info_params: {0}".format( + str(role_params)), "DEBUG") response = self.dnac._exec( family="user_and_roles", function="add_role_api", op_modifies=True, params=role_params, ) - self.log("Received API response from create_role: {0}".format(str(response)), "DEBUG") + self.log("Received API response from create_role: {0}".format( + str(response)), "DEBUG") self.created_role.append(role_params.get("role")) return response except Exception as e: - self.log("Unexpected error occurred: {0}".format(str(e)), "ERROR") + self.log("Unexpected error occurred: {0}".format( + str(e)), "ERROR") error_message = "The Catalyst Center user '{0}' does not have the necessary permissions to 'create a role' through the API.".format( self.payload.get("dnac_username")) return {"error_message": error_message} @@ -1720,7 +1795,8 @@ def get_user(self): op_modifies=True, params={"invoke_source": "external"}, ) - self.log("Received API response from get_users_api: {0}".format(str(response)), "DEBUG") + self.log("Received API response from get_users_api: {0}".format( + str(response)), "DEBUG") return response def get_role(self): @@ -1740,7 +1816,8 @@ def get_role(self): function="get_roles_api", op_modifies=True, ) - self.log("Received API response from get_roles_api: {0}".format(str(response)), "DEBUG") + self.log("Received API response from get_roles_api: {0}".format( + str(response)), "DEBUG") return response def add_entries(self, entry_types, operations, unique_types): @@ -1769,10 +1846,12 @@ def process_assurance_rules(self, role_config, role_operation, unique_types): # Determine if default entries should be added based on role_operation if role_operation == "create": - self.log("Role operation is 'create'. Adding default assurance entries.", "DEBUG") + self.log( + "Role operation is 'create'. Adding default assurance entries.", "DEBUG") self.add_entries(entry_types, ["gRead"], unique_types) else: - self.log("Role operation is not 'create'. Skipping default assurance entries.", "DEBUG") + self.log( + "Role operation is not 'create'. Skipping default assurance entries.", "DEBUG") if role_config["assurance"] is None: return {} @@ -1783,7 +1862,8 @@ def process_assurance_rules(self, role_config, role_operation, unique_types): for assurance_rule in role_config["assurance"]: for resource_name, permission in assurance_rule.items(): if permission is None: - self.log("Skipping resource {0} because permission is None".format(resource_name), "DEBUG") + self.log("Skipping resource {0} because permission is None".format( + resource_name), "DEBUG") continue permission = permission.lower() @@ -1795,11 +1875,13 @@ def process_assurance_rules(self, role_config, role_operation, unique_types): return {"error_message": error_message} if permission == "deny": - self.log("Skipping resource {0} because permission is 'deny'".format(resource_name), "DEBUG") + self.log("Skipping resource {0} because permission is 'deny'".format( + resource_name), "DEBUG") continue operations = self.convert_permission_to_operations(permission) - self.log("Converted permission {0} to operations {1}".format(permission, operations), "DEBUG") + self.log("Converted permission {0} to operations {1}".format( + permission, operations), "DEBUG") if resource_name == "overall": self.add_entries(entry_types, operations, unique_types) @@ -1809,14 +1891,16 @@ def process_assurance_rules(self, role_config, role_operation, unique_types): "operations": operations } unique_types[new_entry["type"]] = new_entry - self.log("Added entry for 'monitoring_and_troubleshooting': {0}".format(new_entry), "DEBUG") + self.log("Added entry for 'monitoring_and_troubleshooting': {0}".format( + new_entry), "DEBUG") else: new_entry = { "type": "Assurance.{0}".format(resource_name.replace("_", " ").title()), "operations": operations } unique_types[new_entry["type"]] = new_entry - self.log("Added entry for resource {0}: {1}".format(resource_name, new_entry), "DEBUG") + self.log("Added entry for resource {0}: {1}".format( + resource_name, new_entry), "DEBUG") return {} def process_network_analytics_rules(self, role_config, role_operation, unique_types): @@ -1834,10 +1918,12 @@ def process_network_analytics_rules(self, role_config, role_operation, unique_ty # Determine if default entries should be added based on role_operation if role_operation == "create": - self.log("Role operation is 'create'. Adding default network analytics entries.", "DEBUG") + self.log( + "Role operation is 'create'. Adding default network analytics entries.", "DEBUG") unique_types[entry_types["type"]] = entry_types else: - self.log("Role operation is not 'create'. Skipping default network analytics entries.", "DEBUG") + self.log( + "Role operation is not 'create'. Skipping default network analytics entries.", "DEBUG") if role_config["network_analytics"] is None: return {} @@ -1848,7 +1934,8 @@ def process_network_analytics_rules(self, role_config, role_operation, unique_ty for network_analytics_rule in role_config["network_analytics"]: for resource_name, permission in network_analytics_rule.items(): if permission is None: - self.log("Skipping resource {0} because permission is None".format(resource_name), "DEBUG") + self.log("Skipping resource {0} because permission is None".format( + resource_name), "DEBUG") continue permission = permission.lower() @@ -1860,11 +1947,13 @@ def process_network_analytics_rules(self, role_config, role_operation, unique_ty return {"error_message": error_message} if permission == "deny": - self.log("Skipping resource {0} because permission is 'deny'".format(resource_name), "DEBUG") + self.log("Skipping resource {0} because permission is 'deny'".format( + resource_name), "DEBUG") continue operations = self.convert_permission_to_operations(permission) - self.log("Converted permission {0} to operations {1}".format(permission, operations), "DEBUG") + self.log("Converted permission {0} to operations {1}".format( + permission, operations), "DEBUG") if resource_name == "overall": unique_types[entry_types["type"]] = entry_types @@ -1874,7 +1963,8 @@ def process_network_analytics_rules(self, role_config, role_operation, unique_ty "operations": operations } unique_types[new_entry["type"]] = new_entry - self.log("Added entry for resource {0}: {1}".format(resource_name, new_entry), "DEBUG") + self.log("Added entry for resource {0}: {1}".format( + resource_name, new_entry), "DEBUG") return {} def process_network_design_rules(self, role_config, role_operation, unique_types): @@ -1896,10 +1986,12 @@ def process_network_design_rules(self, role_config, role_operation, unique_types # Determine if default entries should be added based on role_operation if role_operation == "create": - self.log("Role operation is 'create'. Adding default network design entries.", "DEBUG") + self.log( + "Role operation is 'create'. Adding default network design entries.", "DEBUG") self.add_entries(entry_types, ["gRead"], unique_types) else: - self.log("Role operation is not 'create'. Skipping default network design entries.", "DEBUG") + self.log( + "Role operation is not 'create'. Skipping default network design entries.", "DEBUG") if role_config["network_design"] is None: return {} @@ -1910,7 +2002,8 @@ def process_network_design_rules(self, role_config, role_operation, unique_types for network_design_rule in role_config["network_design"]: for resource_name, permission in network_design_rule.items(): if permission is None: - self.log("Skipping resource {0} because permission is None".format(resource_name), "DEBUG") + self.log("Skipping resource {0} because permission is None".format( + resource_name), "DEBUG") continue permission = permission.lower() @@ -1922,11 +2015,13 @@ def process_network_design_rules(self, role_config, role_operation, unique_types return {"error_message": error_message} if permission == "deny": - self.log("Skipping resource {0} because permission is 'deny'".format(resource_name), "DEBUG") + self.log("Skipping resource {0} because permission is 'deny'".format( + resource_name), "DEBUG") continue operations = self.convert_permission_to_operations(permission) - self.log("Converted permission {0} to operations {1}".format(permission, operations), "DEBUG") + self.log("Converted permission {0} to operations {1}".format( + permission, operations), "DEBUG") if resource_name == "overall": self.add_entries(entry_types, operations, unique_types) @@ -1936,7 +2031,8 @@ def process_network_design_rules(self, role_config, role_operation, unique_types "operations": operations } unique_types[new_entry["type"]] = new_entry - self.log("Added entry for resource {0}: {1}".format(resource_name, new_entry), "DEBUG") + self.log("Added entry for resource {0}: {1}".format( + resource_name, new_entry), "DEBUG") return {} def process_network_provision_rules(self, role_config, role_operation, unique_types): @@ -1964,10 +2060,12 @@ def process_network_provision_rules(self, role_config, role_operation, unique_ty # Determine if default entries should be added based on role_operation if role_operation == "create": - self.log("Role operation is 'create'. Adding default network provision entries.", "DEBUG") + self.log( + "Role operation is 'create'. Adding default network provision entries.", "DEBUG") self.add_entries(entry_types, ["gRead"], unique_types) else: - self.log("Role operation is not 'create'. Skipping default network provision entries.", "DEBUG") + self.log( + "Role operation is not 'create'. Skipping default network provision entries.", "DEBUG") if role_config["network_provision"] is None: return {} @@ -1986,7 +2084,8 @@ def process_network_provision_rules(self, role_config, role_operation, unique_ty # Handle nested inventory_management for sub_resource_name, sub_permission in permission[0].items(): if sub_permission is None: - self.log("Skipping sub-resource {0} because permission is None".format(sub_resource_name), "DEBUG") + self.log( + "Skipping sub-resource {0} because permission is None".format(sub_resource_name), "DEBUG") continue sub_permission = sub_permission.lower() @@ -1998,11 +2097,14 @@ def process_network_provision_rules(self, role_config, role_operation, unique_ty return {"error_message": error_message} if sub_permission == "deny": - self.log("Skipping sub-resource {0} because permission is 'deny'".format(sub_resource_name), "DEBUG") + self.log( + "Skipping sub-resource {0} because permission is 'deny'".format(sub_resource_name), "DEBUG") continue - operations = self.convert_permission_to_operations(sub_permission) - self.log("Converted sub-permission {0} to operations {1}".format(sub_permission, operations), "DEBUG") + operations = self.convert_permission_to_operations( + sub_permission) + self.log( + "Converted sub-permission {0} to operations {1}".format(sub_permission, operations), "DEBUG") if sub_resource_name == "overall": overall_entry_types = [ @@ -2012,7 +2114,8 @@ def process_network_provision_rules(self, role_config, role_operation, unique_ty "Network Provision.Inventory Management.Port Management", "Network Provision.Inventory Management.Topology" ] - self.add_entries(overall_entry_types, operations, unique_types) + self.add_entries( + overall_entry_types, operations, unique_types) else: new_entry = { "type": "Network Provision.{0}.{1}".format(resource_name.replace("_", " ").title(), @@ -2020,10 +2123,12 @@ def process_network_provision_rules(self, role_config, role_operation, unique_ty "operations": operations } unique_types[new_entry["type"]] = new_entry - self.log("Added entry for resource {0}: {1}".format(sub_resource_name, new_entry), "DEBUG") + self.log("Added entry for resource {0}: {1}".format( + sub_resource_name, new_entry), "DEBUG") else: if permission is None: - self.log("Skipping resource {0} because permission is None".format(resource_name), "DEBUG") + self.log("Skipping resource {0} because permission is None".format( + resource_name), "DEBUG") continue permission = permission.lower() @@ -2035,11 +2140,14 @@ def process_network_provision_rules(self, role_config, role_operation, unique_ty return {"error_message": error_message} if permission == "deny": - self.log("Skipping resource {0} because permission is 'deny'".format(resource_name), "DEBUG") + self.log("Skipping resource {0} because permission is 'deny'".format( + resource_name), "DEBUG") continue - operations = self.convert_permission_to_operations(permission) - self.log("Converted permission {0} to operations {1}".format(permission, operations), "DEBUG") + operations = self.convert_permission_to_operations( + permission) + self.log("Converted permission {0} to operations {1}".format( + permission, operations), "DEBUG") if resource_name == "overall": self.add_entries(entry_types, operations, unique_types) @@ -2049,21 +2157,24 @@ def process_network_provision_rules(self, role_config, role_operation, unique_ty "operations": operations } unique_types[new_entry["type"]] = new_entry - self.log("Added entry for 'eox': {0}".format(new_entry), "DEBUG") + self.log("Added entry for 'eox': {0}".format( + new_entry), "DEBUG") elif resource_name == "pnp": new_entry = { "type": "Network Provision.PnP", "operations": operations } unique_types[new_entry["type"]] = new_entry - self.log("Added entry for 'pnp': {0}".format(new_entry), "DEBUG") + self.log("Added entry for 'pnp': {0}".format( + new_entry), "DEBUG") else: new_entry = { "type": "Network Provision.{0}".format(resource_name.replace("_", " ").title()), "operations": operations } unique_types[new_entry["type"]] = new_entry - self.log("Added entry for resource {0}: {1}".format(resource_name, new_entry), "DEBUG") + self.log("Added entry for resource {0}: {1}".format( + resource_name, new_entry), "DEBUG") return {} def process_network_services_rules(self, role_config, role_operation, unique_types): @@ -2083,10 +2194,12 @@ def process_network_services_rules(self, role_config, role_operation, unique_typ # Determine if default entries should be added based on role_operation if role_operation == "create": - self.log("Role operation is 'create'. Adding default network services entries.", "DEBUG") + self.log( + "Role operation is 'create'. Adding default network services entries.", "DEBUG") self.add_entries(entry_types, ["gRead"], unique_types) else: - self.log("Role operation is not 'create'. Skipping default network services entries.", "DEBUG") + self.log( + "Role operation is not 'create'. Skipping default network services entries.", "DEBUG") if role_config["network_services"] is None: return {} @@ -2097,7 +2210,8 @@ def process_network_services_rules(self, role_config, role_operation, unique_typ for services_rule in role_config["network_services"]: for resource_name, permission in services_rule.items(): if permission is None: - self.log("Skipping resource {0} because permission is None".format(resource_name), "DEBUG") + self.log("Skipping resource {0} because permission is None".format( + resource_name), "DEBUG") continue permission = permission.lower() @@ -2109,11 +2223,13 @@ def process_network_services_rules(self, role_config, role_operation, unique_typ return {"error_message": error_message} if permission == "deny": - self.log("Skipping resource {0} because permission is 'deny'".format(resource_name), "DEBUG") + self.log("Skipping resource {0} because permission is 'deny'".format( + resource_name), "DEBUG") continue operations = self.convert_permission_to_operations(permission) - self.log("Converted permission {0} to operations {1}".format(permission, operations), "DEBUG") + self.log("Converted permission {0} to operations {1}".format( + permission, operations), "DEBUG") if resource_name == "overall": self.add_entries(entry_types, operations, unique_types) @@ -2123,7 +2239,8 @@ def process_network_services_rules(self, role_config, role_operation, unique_typ "operations": operations } unique_types[new_entry["type"]] = new_entry - self.log("Added entry for resource {0}: {1}".format(resource_name, new_entry), "DEBUG") + self.log("Added entry for resource {0}: {1}".format( + resource_name, new_entry), "DEBUG") return {} def process_platform_rules(self, role_config, unique_types): @@ -2143,7 +2260,8 @@ def process_platform_rules(self, role_config, unique_types): for platform_rule in role_config["platform"]: for resource_name, permission in platform_rule.items(): if permission is None: - self.log("Skipping resource {0} because permission is None".format(resource_name), "DEBUG") + self.log("Skipping resource {0} because permission is None".format( + resource_name), "DEBUG") continue permission = permission.lower() @@ -2155,11 +2273,13 @@ def process_platform_rules(self, role_config, unique_types): return {"error_message": error_message} if permission == "deny": - self.log("Skipping resource {0} because permission is 'deny'".format(resource_name), "DEBUG") + self.log("Skipping resource {0} because permission is 'deny'".format( + resource_name), "DEBUG") continue operations = self.convert_permission_to_operations(permission) - self.log("Converted permission {0} to operations {1}".format(permission, operations), "DEBUG") + self.log("Converted permission {0} to operations {1}".format( + permission, operations), "DEBUG") if resource_name == "overall": overall_entry_types = [ @@ -2168,21 +2288,24 @@ def process_platform_rules(self, role_config, unique_types): "Platform.Events", "Platform.Reports" ] - self.add_entries(overall_entry_types, operations, unique_types) + self.add_entries(overall_entry_types, + operations, unique_types) elif resource_name == "apis": new_entry = { "type": "Platform.APIs", "operations": operations } unique_types[new_entry["type"]] = new_entry - self.log("Added entry for 'apis': {0}".format(new_entry), "DEBUG") + self.log("Added entry for 'apis': {0}".format( + new_entry), "DEBUG") else: new_entry = { "type": "Platform.{0}".format(resource_name.replace("_", " ").title()), "operations": operations } unique_types[new_entry["type"]] = new_entry - self.log("Added entry for resource {0}: {1}".format(resource_name, new_entry), "DEBUG") + self.log("Added entry for resource {0}: {1}".format( + resource_name, new_entry), "DEBUG") return {} def process_security_rules(self, role_config, role_operation, unique_types): @@ -2201,10 +2324,12 @@ def process_security_rules(self, role_config, role_operation, unique_types): # Determine if default entries should be added based on role_operation if role_operation == "create": - self.log("Role operation is 'create'. Adding default security entries.", "DEBUG") + self.log( + "Role operation is 'create'. Adding default security entries.", "DEBUG") self.add_entries(entry_types, ["gRead"], unique_types) else: - self.log("Role operation is not 'create'. Skipping default security entries.", "DEBUG") + self.log( + "Role operation is not 'create'. Skipping default security entries.", "DEBUG") if role_config["security"] is None: return {} @@ -2215,7 +2340,8 @@ def process_security_rules(self, role_config, role_operation, unique_types): for security_rule in role_config["security"]: for resource_name, permission in security_rule.items(): if permission is None: - self.log("Skipping resource {0} because permission is None".format(resource_name), "DEBUG") + self.log("Skipping resource {0} because permission is None".format( + resource_name), "DEBUG") continue permission = permission.lower() @@ -2227,11 +2353,13 @@ def process_security_rules(self, role_config, role_operation, unique_types): return {"error_message": error_message} if permission == "deny": - self.log("Skipping resource {0} because permission is 'deny'".format(resource_name), "DEBUG") + self.log("Skipping resource {0} because permission is 'deny'".format( + resource_name), "DEBUG") continue operations = self.convert_permission_to_operations(permission) - self.log("Converted permission {0} to operations {1}".format(permission, operations), "DEBUG") + self.log("Converted permission {0} to operations {1}".format( + permission, operations), "DEBUG") if resource_name == "overall": self.add_entries(entry_types, operations, unique_types) @@ -2241,21 +2369,24 @@ def process_security_rules(self, role_config, role_operation, unique_types): "operations": operations } unique_types[new_entry["type"]] = new_entry - self.log("Added entry for 'ip_based_access_control': {0}".format(new_entry), "DEBUG") + self.log("Added entry for 'ip_based_access_control': {0}".format( + new_entry), "DEBUG") elif resource_name == "group_based_policy": new_entry = { "type": "Security.Group-Based Policy", "operations": operations } unique_types[new_entry["type"]] = new_entry - self.log("Added entry for 'group_based_policy': {0}".format(new_entry), "DEBUG") + self.log("Added entry for 'group_based_policy': {0}".format( + new_entry), "DEBUG") else: new_entry = { "type": "Security.{0}".format(resource_name.replace("_", " ").title()), "operations": operations } unique_types[new_entry["type"]] = new_entry - self.log("Added entry for resource {0}: {1}".format(resource_name, new_entry), "DEBUG") + self.log("Added entry for resource {0}: {1}".format( + resource_name, new_entry), "DEBUG") return {} def process_system_rules(self, role_config, role_operation, unique_types): @@ -2273,10 +2404,12 @@ def process_system_rules(self, role_config, role_operation, unique_types): # Determine if default entries should be added based on role_operation if role_operation == "create": - self.log("Role operation is 'create'. Adding default system entries.", "DEBUG") + self.log( + "Role operation is 'create'. Adding default system entries.", "DEBUG") self.add_entries(entry_types, ["gRead"], unique_types) else: - self.log("Role operation is not 'create'. Skipping default system entries.", "DEBUG") + self.log( + "Role operation is not 'create'. Skipping default system entries.", "DEBUG") if role_config["system"] is None: return {} @@ -2287,7 +2420,8 @@ def process_system_rules(self, role_config, role_operation, unique_types): for system_rule in role_config["system"]: for resource_name, permission in system_rule.items(): if permission is None: - self.log("Skipping resource {0} because permission is None".format(resource_name), "DEBUG") + self.log("Skipping resource {0} because permission is None".format( + resource_name), "DEBUG") continue permission = permission.lower() @@ -2299,11 +2433,13 @@ def process_system_rules(self, role_config, role_operation, unique_types): return {"error_message": error_message} if permission == "deny": - self.log("Skipping resource {0} because permission is 'deny'".format(resource_name), "DEBUG") + self.log("Skipping resource {0} because permission is 'deny'".format( + resource_name), "DEBUG") continue operations = self.convert_permission_to_operations(permission) - self.log("Converted permission {0} to operations {1}".format(permission, operations), "DEBUG") + self.log("Converted permission {0} to operations {1}".format( + permission, operations), "DEBUG") if resource_name == "overall": self.add_entries(entry_types, operations, unique_types) @@ -2313,7 +2449,8 @@ def process_system_rules(self, role_config, role_operation, unique_types): "operations": operations } unique_types[new_entry["type"]] = new_entry - self.log("Added entry for resource {0}: {1}".format(resource_name, new_entry), "DEBUG") + self.log("Added entry for resource {0}: {1}".format( + resource_name, new_entry), "DEBUG") return {} def process_utilities_rules(self, role_config, role_operation, unique_types): @@ -2326,7 +2463,8 @@ def process_utilities_rules(self, role_config, role_operation, unique_types): """ # Determine if default entries should be added based on role_operation if role_operation == "create": - self.log("Role operation is 'create'. Adding default utilities entries.", "DEBUG") + self.log( + "Role operation is 'create'. Adding default utilities entries.", "DEBUG") default_entry_types = [ "Utilities.Event Viewer", "Utilities.Network Reasoner", @@ -2340,7 +2478,8 @@ def process_utilities_rules(self, role_config, role_operation, unique_types): unique_types[new_entry1["type"]] = new_entry1 else: - self.log("Role operation is not 'create'. Skipping default utilities entries.", "DEBUG") + self.log( + "Role operation is not 'create'. Skipping default utilities entries.", "DEBUG") if role_config["utilities"] is None: return {} @@ -2351,7 +2490,8 @@ def process_utilities_rules(self, role_config, role_operation, unique_types): for utilities_rule in role_config["utilities"]: for resource_name, permission in utilities_rule.items(): if permission is None: - self.log("Skipping resource {0} because permission is None".format(resource_name), "DEBUG") + self.log("Skipping resource {0} because permission is None".format( + resource_name), "DEBUG") continue permission = permission.lower() @@ -2363,11 +2503,13 @@ def process_utilities_rules(self, role_config, role_operation, unique_types): return {"error_message": error_message} if permission == "deny": - self.log("Skipping resource {0} because permission is 'deny'".format(resource_name), "DEBUG") + self.log("Skipping resource {0} because permission is 'deny'".format( + resource_name), "DEBUG") continue operations = self.convert_permission_to_operations(permission) - self.log("Converted permission {0} to operations {1}".format(permission, operations), "DEBUG") + self.log("Converted permission {0} to operations {1}".format( + permission, operations), "DEBUG") if resource_name == "overall": overall_entry_types = [ @@ -2378,14 +2520,16 @@ def process_utilities_rules(self, role_config, role_operation, unique_types): "Utilities.Remote Device Support", "Utilities.Scheduler" ] - self.add_entries(overall_entry_types, operations, unique_types) + self.add_entries(overall_entry_types, + operations, unique_types) else: new_entry = { "type": "Utilities.{0}".format(resource_name.replace("_", " ").title()), "operations": operations } unique_types[new_entry["type"]] = new_entry - self.log("Added entry for resource {0}: {1}".format(resource_name, new_entry), "DEBUG") + self.log("Added entry for resource {0}: {1}".format( + resource_name, new_entry), "DEBUG") return {} def generate_role_payload(self, role_config, role_operation): @@ -2434,14 +2578,17 @@ def generate_role_payload(self, role_config, role_operation): if func_name in "process_platform_rules": function_response = process_func(role_config, unique_types) else: - function_response = process_func(role_config, role_operation, unique_types) + function_response = process_func( + role_config, role_operation, unique_types) if function_response: - self.log("Error occurred in {0}: {1}".format(func_name, function_response), "DEBUG") + self.log("Error occurred in {0}: {1}".format( + func_name, function_response), "DEBUG") return function_response # Construct the final payload resource_types_list = list(unique_types.values()) - self.log("Generated resource types: {0}".format(resource_types_list), "DEBUG") + self.log("Generated resource types: {0}".format( + resource_types_list), "DEBUG") payload = { "role": role_name, "description": description, @@ -2498,12 +2645,14 @@ def role_requires_update(self, current_role, desired_role): if have_resource["type"] == want_resource["type"]: resource_found = True if have_resource["operations"] != want_resource["operations"]: - self.log("Updating operations for resource type {0}.".format(want_resource["type"]), "DEBUG") + self.log("Updating operations for resource type {0}.".format( + want_resource["type"]), "DEBUG") have_resource["operations"] = want_resource["operations"] update_required = True break if not resource_found: - self.log("Adding new resource type {0} to current role.".format(want_resource["type"]), "DEBUG") + self.log("Adding new resource type {0} to current role.".format( + want_resource["type"]), "DEBUG") current_role["resource_types"].append(want_resource) update_required = True @@ -2512,7 +2661,8 @@ def role_requires_update(self, current_role, desired_role): current_description = current_role.get("description") if desired_description is not None: if current_description != desired_description: - self.log("Updating description from {0} to {1}.".format(current_description, desired_description), "DEBUG") + self.log("Updating description from {0} to {1}.".format( + current_description, desired_description), "DEBUG") update_role_params["description"] = desired_description update_required = True elif "description" not in update_role_params: @@ -2528,11 +2678,13 @@ def role_requires_update(self, current_role, desired_role): } self.log("Calling get_permissions to filter permissions...", "DEBUG") - filtered_data, overall_update_required = self.get_permissions(self.want, updated_get_have, "update") + filtered_data, overall_update_required = self.get_permissions( + self.want, updated_get_have, "update") self.log("Finding denied permissions...", "DEBUG") denied_permissions = self.find_denied_permissions(self.want) - denied_update_required, updated_get_have = self.remove_denied_operations(filtered_data, denied_permissions) + denied_update_required, updated_get_have = self.remove_denied_operations( + filtered_data, denied_permissions) if update_required or denied_update_required or overall_update_required: self.log("Role update required. Changes detected.", "DEBUG") @@ -2565,7 +2717,8 @@ def user_requires_update(self, current_user, current_role): current_first_name = current_user.get("first_name") if desired_first_name is not None: if current_first_name != desired_first_name: - self.log("Updating first name from {0} to {1}.".format(current_first_name, desired_first_name), "DEBUG") + self.log("Updating first name from {0} to {1}.".format( + current_first_name, desired_first_name), "DEBUG") update_user_params["first_name"] = desired_first_name update_needed = True elif "first_name" not in update_user_params: @@ -2578,7 +2731,8 @@ def user_requires_update(self, current_user, current_role): current_last_name = current_user.get("last_name") if desired_last_name is not None: if current_last_name != desired_last_name: - self.log("Updating last name from {0} to {1}.".format(current_last_name, desired_last_name), "DEBUG") + self.log("Updating last name from {0} to {1}.".format( + current_last_name, desired_last_name), "DEBUG") update_user_params["last_name"] = desired_last_name update_needed = True elif "last_name" not in update_user_params: @@ -2591,7 +2745,8 @@ def user_requires_update(self, current_user, current_role): current_username = current_user.get("username") if desired_username is not None: if current_username != desired_username: - self.log("Username for an existing User cannot be updated from {0} to {1}.".format(current_username, desired_username), "DEBUG") + self.log("Username for an existing User cannot be updated from {0} to {1}.".format( + current_username, desired_username), "DEBUG") update_user_params["username"] = desired_username update_needed = True elif "username" not in update_user_params: @@ -2604,7 +2759,8 @@ def user_requires_update(self, current_user, current_role): current_email = current_user.get("email") if desired_email is not None: if current_email != desired_email: - self.log("Updating email from {0} to {1}.".format(current_email, desired_email), "DEBUG") + self.log("Updating email from {0} to {1}.".format( + current_email, desired_email), "DEBUG") update_user_params["email"] = desired_email update_needed = True elif "email" not in update_user_params: @@ -2620,19 +2776,22 @@ def user_requires_update(self, current_user, current_role): if desired_role_name in current_role: role_id = current_role[desired_role_name] if current_role_list[0] != role_id: - self.log("Updating role list with new role ID {0}.".format(role_id), "DEBUG") + self.log("Updating role list with new role ID {0}.".format( + role_id), "DEBUG") update_user_params["role_list"] = [role_id] update_needed = True else: update_user_params["role_list"] = current_role_list else: - self.log("Role {0} not found in current_role. Setting role list to empty.".format(desired_role_name), "DEBUG") + self.log("Role {0} not found in current_role. Setting role list to empty.".format( + desired_role_name), "DEBUG") update_user_params["role_list"] = [] update_needed = True else: update_user_params["role_list"] = current_role_list - self.log("User update parameters: {0}".format(update_user_params), "DEBUG") + self.log("User update parameters: {0}".format( + update_user_params), "DEBUG") return update_needed, update_user_params @@ -2649,20 +2808,23 @@ def update_user(self, user_params): - user parameters. It logs the response and returns it. """ try: - self.log("Updating user with parameters: {0}".format(user_params), "DEBUG") + self.log("Updating user with parameters: {0}".format( + user_params), "DEBUG") response = self.dnac._exec( family="user_and_roles", function="update_user_api", op_modifies=True, params=user_params, ) - self.log("Received API response from update_user: {0}".format(str(response)), "DEBUG") + self.log("Received API response from update_user: {0}".format( + str(response)), "DEBUG") self.updated_user.append(user_params.get("username")) return response except Exception as e: self.log("Unexpected error occurred: {0}".format(str(e)), "ERROR") - error_message = "Invalid email format for email '{0}' under username '{1}'".format(user_params.get("email"), user_params.get("username")) + error_message = "Invalid email format for email '{0}' under username '{1}'".format( + user_params.get("email"), user_params.get("username")) return {"error_message": error_message} def update_role(self, role_params): @@ -2683,19 +2845,22 @@ def update_role(self, role_params): if self.compare_dnac_versions(self.get_ccc_version(), "2.3.7.6") >= 0: try: - self.log("Updating role with role_info_params: {0}".format(str(role_params)), "DEBUG") + self.log("Updating role with role_info_params: {0}".format( + str(role_params)), "DEBUG") response = self.dnac._exec( family="user_and_roles", function="update_role_api", op_modifies=True, params=role_params, ) - self.log("Received API response from update_role: {0}".format(str(response)), "DEBUG") + self.log("Received API response from update_role: {0}".format( + str(response)), "DEBUG") self.updated_role.append(self.have.get("role_name")) return response except Exception as e: - self.log("Unexpected error occurred: {0}".format(str(e)), "ERROR") + self.log("Unexpected error occurred: {0}".format( + str(e)), "ERROR") error_message = "The catalyst center user '{0}' does not have the necessary permissions to update role through the API.".format( self.payload.get("dnac_username")) return {"error_message": error_message} @@ -2721,7 +2886,8 @@ def find_denied_permissions(self, config, parent_key=""): denied_permissions = [] if isinstance(config, dict): - self.log("Processing dictionary with parent_key: {0}".format(parent_key), "DEBUG") + self.log("Processing dictionary with parent_key: {0}".format( + parent_key), "DEBUG") for key, value in config.items(): if parent_key: @@ -2731,7 +2897,8 @@ def find_denied_permissions(self, config, parent_key=""): self.log("Checking key: {0}".format(full_key), "DEBUG") if isinstance(value, dict) or isinstance(value, list): - denied_permissions.extend(self.find_denied_permissions(value, full_key)) + denied_permissions.extend( + self.find_denied_permissions(value, full_key)) elif isinstance(value, str) and value.lower() == "deny": denied_permissions.append(full_key) self.log("Found 'deny' at key: {0}".format(full_key), "DEBUG") @@ -2739,13 +2906,17 @@ def find_denied_permissions(self, config, parent_key=""): elif isinstance(config, list): for index, item in enumerate(config): full_key = "{0}[{1}]".format(parent_key, index) - self.log("Processing list with parent_key: {0}".format(parent_key), "DEBUG") + self.log("Processing list with parent_key: {0}".format( + parent_key), "DEBUG") if isinstance(item, dict): - denied_permissions.extend(self.find_denied_permissions(item, full_key)) - self.log("Found 'deny' at index: {0}".format(full_key), "DEBUG") + denied_permissions.extend( + self.find_denied_permissions(item, full_key)) + self.log("Found 'deny' at index: {0}".format( + full_key), "DEBUG") - self.log("Denied permissions are {0}".format(str(denied_permissions)), "DEBUG") + self.log("Denied permissions are {0}".format( + str(denied_permissions)), "DEBUG") return denied_permissions def remove_denied_operations(self, input_data, denied_permissions): @@ -2773,13 +2944,15 @@ def remove_denied_operations(self, input_data, denied_permissions): keep_resource = True resource_type_lower = resource["type"].lower() for denied in denied_permissions: - denied_type_lower = denied.split(".")[-1].replace("_", " ").replace("[0]", "").lower() + denied_type_lower = denied.split( + ".")[-1].replace("_", " ").replace("[0]", "").lower() if denied_type_lower == "network settings": denied_type_lower = "network design.network settings" if denied_type_lower in resource_type_lower: keep_resource = False - self.log("Removing resource due to denied type: {0}".format(denied_type_lower), "DEBUG") + self.log("Removing resource due to denied type: {0}".format( + denied_type_lower), "DEBUG") update_required = True break @@ -2787,7 +2960,8 @@ def remove_denied_operations(self, input_data, denied_permissions): denied_type_lower = "network provision.provision" if denied_type_lower in resource_type_lower: keep_resource = False - self.log("Removing resource due to denied type: {0}".format(denied_type_lower), "DEBUG") + self.log("Removing resource due to denied type: {0}".format( + denied_type_lower), "DEBUG") update_required = True break @@ -2795,14 +2969,16 @@ def remove_denied_operations(self, input_data, denied_permissions): denied_type_lower = "security.group-based policy" if denied_type_lower in resource_type_lower: keep_resource = False - self.log("Removing resource due to denied type: {0}".format(denied_type_lower), "DEBUG") + self.log("Removing resource due to denied type: {0}".format( + denied_type_lower), "DEBUG") update_required = True break else: if denied_type_lower in resource_type_lower: keep_resource = False - self.log("Removing resource due to denied type: {0}".format(denied_type_lower), "DEBUG") + self.log("Removing resource due to denied type: {0}".format( + denied_type_lower), "DEBUG") update_required = True break @@ -2810,7 +2986,8 @@ def remove_denied_operations(self, input_data, denied_permissions): remaining_resource_types.append(resource) input_data["resourceTypes"] = remaining_resource_types - self.log("Removal complete. Update required: {0}".format(update_required), "DEBUG") + self.log("Removal complete. Update required: {0}".format( + update_required), "DEBUG") return update_required, input_data @@ -2863,14 +3040,18 @@ def check_permission(self, permissions, resource_type): current_level = current_level[key] self.log("Navigated to level: {0}".format(key), "DEBUG") elif "overall" in current_level and current_level["overall"].lower() == "deny": - self.log("Permission denied at level: {0}".format(key), "DEBUG") + self.log( + "Permission denied at level: {0}".format(key), "DEBUG") return True, False else: - self.log("Permission allowed at level: {0}".format(key), "DEBUG") + self.log( + "Permission allowed at level: {0}".format(key), "DEBUG") return False, True - overall_permission = "overall" in current_level and current_level["overall"].lower() == "deny" - self.log("Final permission check: Denied: {0}, Allowed: {1}".format(overall_permission, not overall_permission), "DEBUG") + overall_permission = "overall" in current_level and current_level["overall"].lower( + ) == "deny" + self.log("Final permission check: Denied: {0}, Allowed: {1}".format( + overall_permission, not overall_permission), "DEBUG") return False, not overall_permission def get_operations(self, permissions, resource_type): @@ -2888,7 +3069,8 @@ def get_operations(self, permissions, resource_type): - If an "overall" permission of "deny" is found, it collects and returns specific permissions that are not denied. - If no specific operations are found or if the "overall" permission is not "deny", it returns an empty list. """ - self.log("Retrieving operations for resource type: {0}".format(resource_type), "INFO") + self.log("Retrieving operations for resource type: {0}".format( + resource_type), "INFO") keys = resource_type.lower().replace(" ", "_").split(".") current_level = permissions @@ -2899,12 +3081,14 @@ def get_operations(self, permissions, resource_type): if "overall" in current_level and current_level["overall"].lower() == "deny": specific_permissions = {} - self.log("Overall permission denied for resource type: {0}".format(resource_type), "DEBUG") + self.log("Overall permission denied for resource type: {0}".format( + resource_type), "DEBUG") for k, v in current_level.items(): if k != "overall" and v.lower() != "deny": specific_permissions[k] = v - self.log("No specific operations found or overall permission not denied.", "DEBUG") + self.log( + "No specific operations found or overall permission not denied.", "DEBUG") return list(specific_permissions.values()) @@ -2928,7 +3112,8 @@ def get_permissions(self, config, input_data, role_operation): - It logs the final permissions configuration and returns the result along with a boolean indicating if any operations are denied. """ - self.log("Starting permission retrieval for role operation: {0}".format(role_operation), "INFO") + self.log("Starting permission retrieval for role operation: {0}".format( + role_operation), "INFO") permissions = self.parse_config(config) allowed_operations = [] check_deny = [] @@ -2936,11 +3121,13 @@ def get_permissions(self, config, input_data, role_operation): for resource in input_data["resourceTypes"]: res_type = resource["type"] operations = resource["operations"] - check_deny_update, check_permission = self.check_permission(permissions, res_type) + check_deny_update, check_permission = self.check_permission( + permissions, res_type) check_deny.append(str(check_deny_update)) if check_permission: - specific_operations = self.get_operations(permissions, res_type) + specific_operations = self.get_operations( + permissions, res_type) allowed_operations.append({ "type": res_type, "operations": operations if not specific_operations else specific_operations @@ -2959,10 +3146,12 @@ def get_permissions(self, config, input_data, role_operation): "resourceTypes": allowed_operations } - self.log("Final permissions configuration: {0}".format(result), "DEBUG") + self.log("Final permissions configuration: {0}".format( + result), "DEBUG") if "True" in check_deny: - self.log("Permission check complete. Any denied operations: True", "DEBUG") + self.log( + "Permission check complete. Any denied operations: True", "DEBUG") return result, True self.log("Permission check complete. Any denied operations: False", "DEBUG") @@ -2987,13 +3176,15 @@ def get_diff_deleted(self, config): if "role_name" in config: if self.have.get("role_exists"): self.valid_role_config_parameters(config).check_return_status() - self.log("Deleting role with config {0}".format(str(config)), "DEBUG") + self.log("Deleting role with config {0}".format( + str(config)), "DEBUG") current_role = self.have.get("current_role_config") role_id_to_delete = {} role_id_to_delete["role_id"] = current_role.get("role_id") task_response = self.delete_role(role_id_to_delete) - self.log("Task response {0}".format(str(task_response)), "INFO") + self.log("Task response {0}".format( + str(task_response)), "INFO") if task_response and "error_message" not in task_response: responses = {"role_operation": {"response": task_response}} @@ -3017,16 +3208,19 @@ def get_diff_deleted(self, config): if "username" in config or "email" in config: if self.have.get("user_exists"): self.valid_user_config_parameters(config).check_return_status() - self.log("Deleting user with config {0}".format(str(config)), "DEBUG") + self.log("Deleting user with config {0}".format( + str(config)), "DEBUG") current_user = self.have.get("current_user_config") user_id_to_delete = {} user_id_to_delete["user_id"] = current_user.get("user_id") task_response = self.delete_user(user_id_to_delete) - self.log("Task response {0}".format(str(task_response)), "INFO") + self.log("Task response {0}".format( + str(task_response)), "INFO") if task_response and "error_message" not in task_response: - responses = {"users_operation": {"response": task_response}} + responses = {"users_operation": { + "response": task_response}} self.msg = responses self.result["response"] = self.msg self.result["changed"] = True @@ -3046,7 +3240,8 @@ def get_diff_deleted(self, config): self.msg = ( "The specified user '{0}' does not exist in Cisco Catalyst Center. " - "Please provide a valid 'username' or 'email' for user deletion.".format(user_identifier) + "Please provide a valid 'username' or 'email' for user deletion.".format( + user_identifier) ) self.log(self.msg, "ERROR") self.status = "failed" @@ -3068,7 +3263,8 @@ def delete_user(self, user_params): if self.compare_dnac_versions(self.get_ccc_version(), "2.3.7.6") >= 0: username = self.have.get("username") - self.log("Attempting to delete user with user_params: {0}".format(str(user_params)), "DEBUG") + self.log("Attempting to delete user with user_params: {0}".format( + str(user_params)), "DEBUG") try: response = self.dnac._exec( family="user_and_roles", @@ -3078,24 +3274,29 @@ def delete_user(self, user_params): ) if response and isinstance(response, dict): - self.log("Received API response from delete_user '{0}': {1}".format(username, str(response)), "DEBUG") + self.log("Received API response from delete_user '{0}': {1}".format( + username, str(response)), "DEBUG") self.deleted_user.append(username) return response - error_msg = response.get("error_message", "Unknown error occurred while deleting user '{0}'".format(username)) - self.log("User deletion failed. Error: {0}".format(error_msg), "ERROR") + error_msg = response.get( + "error_message", "Unknown error occurred while deleting user '{0}'".format(username)) + self.log("User deletion failed. Error: {0}".format( + error_msg), "ERROR") return {"error_message": error_msg} except Exception as e: if "[404]" in str(e): - error_message = "User '{0}' was not found in Cisco Catalyst Center".format(username) + error_message = "User '{0}' was not found in Cisco Catalyst Center".format( + username) elif "[412]" in str(e): error_message = ( "User '{0}' tried to delete themselves or does not have right permission to delete a user in Cisco Catalyst Center".format( username) ) else: - error_message = "Exception occurred while deleting user {0}: {1}".format(username, str(e)) + error_message = "Exception occurred while deleting user {0}: {1}".format( + username, str(e)) return {"error_message": error_message} @@ -3121,19 +3322,22 @@ def delete_role(self, role_params): if self.compare_dnac_versions(self.get_ccc_version(), "2.3.7.6") >= 0: try: - self.log("delete role with role_params: {0}".format(str(role_params)), "DEBUG") + self.log("delete role with role_params: {0}".format( + str(role_params)), "DEBUG") response = self.dnac._exec( family="user_and_roles", function="delete_role_api", op_modifies=True, params=role_params, ) - self.log("Received API response from delete_role: {0}".format(str(response)), "DEBUG") + self.log("Received API response from delete_role: {0}".format( + str(response)), "DEBUG") self.deleted_role.append(self.have.get("role_name")) return response except Exception as e: - self.log("Unexpected error occurred: {0}".format(str(e)), "ERROR") + self.log("Unexpected error occurred: {0}".format( + str(e)), "ERROR") if "[403]" in str(e): error_message = ( "The Catalyst Center user '{0}' does not have the necessary permissions to delete the role through the API.".format( @@ -3173,8 +3377,10 @@ def verify_diff_merged(self, config): if "role_name" in config: self.get_have(config) - self.log("Current State (have): {0}".format(str(self.have)), "INFO") - self.log("Desired State (want): {0}".format(str(self.want)), "INFO") + self.log("Current State (have): {0}".format( + str(self.have)), "INFO") + self.log("Desired State (want): {0}".format( + str(self.want)), "INFO") # Code to validate ccc config for merged state role_exist = self.have.get("role_exists") @@ -3182,22 +3388,27 @@ def verify_diff_merged(self, config): if role_exist: self.status = "success" - self.msg = "The requested role {0} is present in the Cisco Catalyst Center and its creation has been verified.".format(role_name) + self.msg = "The requested role {0} is present in the Cisco Catalyst Center and its creation has been verified.".format( + role_name) self.log(self.msg, "INFO") else: self.log("The playbook input for role {0} does not align with the Cisco Catalyst Center, indicating that the \ merge task may not have executed successfully.".format(role_name), "INFO") desired_role = self.generate_role_payload(self.want, "update") - (require_update, updated_role_info) = self.role_requires_update(self.have["current_role_config"], desired_role) + (require_update, updated_role_info) = self.role_requires_update( + self.have["current_role_config"], desired_role) if not require_update: - self.log("The update for role {0} has been successfully verified. The updated info - {1}".format(role_name, updated_role_info), "INFO") + self.log("The update for role {0} has been successfully verified. The updated info - {1}".format( + role_name, updated_role_info), "INFO") self. status = "success" if "username" in config or "email" in config: self.get_have(config) - self.log("Current State (have): {0}".format(str(self.have)), "INFO") - self.log("Desired State (want): {0}".format(str(self.want)), "INFO") + self.log("Current State (have): {0}".format( + str(self.have)), "INFO") + self.log("Desired State (want): {0}".format( + str(self.want)), "INFO") # Code to validate ccc config for merged state user_exist = self.have.get("user_exists") @@ -3205,15 +3416,18 @@ def verify_diff_merged(self, config): if user_exist: self.status = "success" - self.msg = "The requested user {0} is present in the Cisco Catalyst Center and its creation has been verified.".format(user_name) + self.msg = "The requested user {0} is present in the Cisco Catalyst Center and its creation has been verified.".format( + user_name) self.log(self.msg, "INFO") else: self.log("The playbook input for user {0} does not align with the Cisco Catalyst Center, indicating that \ the merge task may not have executed successfully.".format(user_name), "INFO") - (require_update, updated_user_info) = self.user_requires_update(self.have["current_user_config"], self.have["current_role_id_config"]) + (require_update, updated_user_info) = self.user_requires_update( + self.have["current_user_config"], self.have["current_role_id_config"]) if not require_update: - self.log("The update for user {0} has been successfully verified. The updated info - {1}".format(user_name, updated_user_info), "INFO") + self.log("The update for user {0} has been successfully verified. The updated info - {1}".format( + user_name, updated_user_info), "INFO") self. status = "success" return self @@ -3236,8 +3450,10 @@ def verify_diff_deleted(self, config): if "role_name" in config: self.get_have(config) - self.log("Current State (have): {0}".format(str(self.have)), "INFO") - self.log("Desired State (want): {0}".format(str(self.want)), "INFO") + self.log("Current State (have): {0}".format( + str(self.have)), "INFO") + self.log("Desired State (want): {0}".format( + str(self.want)), "INFO") role_exist = self.have.get("role_exists") @@ -3253,8 +3469,10 @@ def verify_diff_deleted(self, config): if "username" in config or "email" in config: self.get_have(config) - self.log("Current State (have): {0}".format(str(self.have)), "INFO") - self.log("Desired State (want): {0}".format(str(self.want)), "INFO") + self.log("Current State (have): {0}".format( + str(self.have)), "INFO") + self.log("Desired State (want): {0}".format( + str(self.want)), "INFO") user_exist = self.have.get("user_exists") @@ -3294,41 +3512,50 @@ def update_user_role_profile_messages(self): update_action = "updated" if self.created_user: - create_user_msg = "User(s) '{0}' {1} successfully in Cisco Catalyst Center.".format("', '".join(self.created_user), update_action) + create_user_msg = "User(s) '{0}' {1} successfully in Cisco Catalyst Center.".format( + "', '".join(self.created_user), update_action) result_msg_list.append(create_user_msg) if self.updated_user: - update_user_msg = "User(s) '{0}' updated successfully in Cisco Catalyst Center.".format("', '".join(self.updated_user)) + update_user_msg = "User(s) '{0}' updated successfully in Cisco Catalyst Center.".format( + "', '".join(self.updated_user)) result_msg_list.append(update_user_msg) if self.no_update_user: - no_update_user_msg = "User(s) '{0}' need no update in Cisco Catalyst Center.".format("', '".join(self.no_update_user)) + no_update_user_msg = "User(s) '{0}' need no update in Cisco Catalyst Center.".format( + "', '".join(self.no_update_user)) no_update_list.append(no_update_user_msg) if self.payload.get("state") == "deleted": if self.deleted_user: - delete_user_msg = "User(s) '{0}' deleted successfully from the Cisco Catalyst Center.".format("', '".join(self.deleted_user)) + delete_user_msg = "User(s) '{0}' deleted successfully from the Cisco Catalyst Center.".format( + "', '".join(self.deleted_user)) result_msg_list.append(delete_user_msg) if self.created_role: - create_role_msg = "Role(s) '{0}' created successfully in Cisco Catalyst Center.".format("', '".join(self.created_role)) + create_role_msg = "Role(s) '{0}' created successfully in Cisco Catalyst Center.".format( + "', '".join(self.created_role)) result_msg_list.append(create_role_msg) if self.updated_role: - update_role_msg = "Role(s) '{0}' updated successfully in Cisco Catalyst Center.".format("', '".join(self.updated_role)) + update_role_msg = "Role(s) '{0}' updated successfully in Cisco Catalyst Center.".format( + "', '".join(self.updated_role)) result_msg_list.append(update_role_msg) if self.no_update_role: - no_update_role_msg = "Role(s) '{0}' need no update in Cisco Catalyst Center.".format("', '".join(self.no_update_role)) + no_update_role_msg = "Role(s) '{0}' need no update in Cisco Catalyst Center.".format( + "', '".join(self.no_update_role)) no_update_list.append(no_update_role_msg) if self.deleted_role: - delete_role_msg = "Role(s) '{0}' deleted successfully from the Cisco Catalyst Center.".format("', '".join(self.deleted_role)) + delete_role_msg = "Role(s) '{0}' deleted successfully from the Cisco Catalyst Center.".format( + "', '".join(self.deleted_role)) result_msg_list.append(delete_role_msg) if result_msg_list and no_update_list: self.result["changed"] = True - self.msg = "{0} {1}".format(" ".join(result_msg_list), " ".join(no_update_list)) + self.msg = "{0} {1}".format( + " ".join(result_msg_list), " ".join(no_update_list)) elif result_msg_list: self.result["changed"] = True self.msg = " ".join(result_msg_list) @@ -3395,7 +3622,8 @@ def process_config_details(self, config_type, state): - If `config_verify` is enabled, it verifies that the changes have been correctly applied. """ if config_type in self.payload.get("config"): - self.validate_input_yml(self.payload.get("config").get(config_type)).check_return_status() + self.validate_input_yml(self.payload.get( + "config").get(config_type)).check_return_status() config_verify = self.payload.get("config_verify") for config in self.validated_config: @@ -3405,7 +3633,8 @@ def process_config_details(self, config_type, state): self.get_diff_state_apply[state](config).check_return_status() if config_verify: - self.verify_diff_state_apply[state](config).check_return_status() + self.verify_diff_state_apply[state]( + config).check_return_status() def main(): diff --git a/plugins/plugin_utils/dnac.py b/plugins/plugin_utils/dnac.py index 514106e2f1..3989182c3d 100644 --- a/plugins/plugin_utils/dnac.py +++ b/plugins/plugin_utils/dnac.py @@ -77,7 +77,8 @@ def dnac_compare_equality(current_value, requested_value): if current_value is None: return True if isinstance(current_value, dict) and isinstance(requested_value, dict): - all_dict_params = list(current_value.keys()) + list(requested_value.keys()) + all_dict_params = list(current_value.keys()) + \ + list(requested_value.keys()) return not any((not fn_comp_key(param, current_value, requested_value) for param in all_dict_params)) elif isinstance(current_value, list) and isinstance(requested_value, list): return compare_list(current_value, requested_value) @@ -99,7 +100,8 @@ def dnac_compare_equality2(current_value, requested_value, is_query_param=False) if current_value is None: return False if isinstance(current_value, dict) and isinstance(requested_value, dict): - all_dict_params = list(current_value.keys()) + list(requested_value.keys()) + all_dict_params = list(current_value.keys()) + \ + list(requested_value.keys()) return not any((not fn_comp_key2(param, current_value, requested_value) for param in all_dict_params)) elif isinstance(current_value, list) and isinstance(requested_value, list): return compare_list(current_value, requested_value) @@ -135,14 +137,22 @@ def get_dict_result(result, key, value, cmp_fn=simple_cmp): def dnac_argument_spec(): argument_spec = dict( - dnac_host=dict(type="str", fallback=(env_fallback, ['DNAC_HOST']), required=True), - dnac_port=dict(type="int", fallback=(env_fallback, ['DNAC_PORT']), required=False, default=443), - dnac_username=dict(type="str", fallback=(env_fallback, ['DNAC_USERNAME']), default="admin", aliases=["user"]), - dnac_password=dict(type="str", fallback=(env_fallback, ['DNAC_PASSWORD']), no_log=True), - dnac_verify=dict(type="bool", fallback=(env_fallback, ['DNAC_VERIFY']), default=True), - dnac_version=dict(type="str", fallback=(env_fallback, ['DNAC_VERSION']), default="2.3.7.6"), - dnac_debug=dict(type="bool", fallback=(env_fallback, ['DNAC_DEBUG']), default=False), - validate_response_schema=dict(type="bool", fallback=(env_fallback, ['VALIDATE_RESPONSE_SCHEMA']), default=True), + dnac_host=dict(type="str", fallback=( + env_fallback, ['DNAC_HOST']), required=True), + dnac_port=dict(type="int", fallback=( + env_fallback, ['DNAC_PORT']), required=False, default=443), + dnac_username=dict(type="str", fallback=( + env_fallback, ['DNAC_USERNAME']), default="admin", aliases=["user"]), + dnac_password=dict(type="str", fallback=( + env_fallback, ['DNAC_PASSWORD']), no_log=True), + dnac_verify=dict(type="bool", fallback=( + env_fallback, ['DNAC_VERIFY']), default=True), + dnac_version=dict(type="str", fallback=( + env_fallback, ['DNAC_VERSION']), default="2.3.7.6"), + dnac_debug=dict(type="bool", fallback=( + env_fallback, ['DNAC_DEBUG']), default=False), + validate_response_schema=dict(type="bool", fallback=( + env_fallback, ['VALIDATE_RESPONSE_SCHEMA']), default=True), ) return argument_spec @@ -163,9 +173,11 @@ def __init__(self, params): debug=params.get("dnac_debug"), ) if params.get("dnac_debug") and LOGGING_IN_STANDARD: - logging.getLogger('dnacentersdk').addHandler(logging.StreamHandler()) + logging.getLogger('dnacentersdk').addHandler( + logging.StreamHandler()) else: - self.fail_json(msg="DNA Center Python SDK is not installed. Execute 'pip install dnacentersdk'") + self.fail_json( + msg="DNA Center Python SDK is not installed. Execute 'pip install dnacentersdk'") def changed(self): self.result["changed"] = True @@ -220,7 +232,8 @@ def exec(self, family, function, params=None, op_modifies=False, **kwargs): if isinstance(params.get(key), str) and self.is_file(params[key]): file_name = self.extract_file_name(params[key]) file_path = params[key] - multipart_fields[value] = (file_name, open(file_path, 'rb')) + multipart_fields[value] = ( + file_name, open(file_path, 'rb')) params.setdefault("multipart_fields", multipart_fields) params.setdefault("multipart_monitor_callback", None) diff --git a/tests/unit/modules/dnac/dnac_module.py b/tests/unit/modules/dnac/dnac_module.py index 8dc3cce8bc..4b078e9a18 100644 --- a/tests/unit/modules/dnac/dnac_module.py +++ b/tests/unit/modules/dnac/dnac_module.py @@ -113,10 +113,12 @@ def execute_module( if response is not None: if sort: self.assertEqual( - sorted(response), sorted(result["response"]), result["response"] + sorted(response), sorted( + result["response"]), result["response"] ) else: - self.assertEqual(response, result["response"], result["response"]) + self.assertEqual( + response, result["response"], result["response"]) return result diff --git a/tests/unit/modules/dnac/test_accesspoint_workflow_manager.py b/tests/unit/modules/dnac/test_accesspoint_workflow_manager.py index f3e7109c2a..c3e9484ef9 100644 --- a/tests/unit/modules/dnac/test_accesspoint_workflow_manager.py +++ b/tests/unit/modules/dnac/test_accesspoint_workflow_manager.py @@ -27,14 +27,17 @@ class TestDnacAccesspointWorkflow(TestDnacModule): test_data = loadPlaybookData("accesspoint_workflow_manager") reboot_accesspoint = test_data.get("reboot_accesspoint") - playbook_config_provision_old_version = test_data.get("playbook_config_provision_old_version") + playbook_config_provision_old_version = test_data.get( + "playbook_config_provision_old_version") playbook_config = test_data.get("playbook_config") playbook_config_provision = test_data.get("playbook_config_provision") playbook_config_complete = test_data.get("playbook_config_complete") get_membership_empty = test_data.get("get_membership_empty") get_device_detail_all_data = test_data.get("get_device_detail_all_data") - playbook_config_update_some_missing_data = test_data.get("playbook_config_update_some_missing_data") - playbook_config_update_some_error_data = test_data.get("playbook_config_update_some_error_data") + playbook_config_update_some_missing_data = test_data.get( + "playbook_config_update_some_missing_data") + playbook_config_update_some_error_data = test_data.get( + "playbook_config_update_some_error_data") def setUp(self): super(TestDnacAccesspointWorkflow, self).setUp() @@ -275,7 +278,8 @@ def test_accesspoint_workflow_manager_reboot_accesspoint(self): result = self.execute_module(changed=True, failed=False) self.maxDiff = None self.assertEqual( - result.get('response').get("accesspoints_updates").get("ap_reboot_status"), + result.get('response').get( + "accesspoints_updates").get("ap_reboot_status"), "APs ['34:b8:83:15:7c:6c'] rebooted successfully" ) @@ -353,7 +357,6 @@ def test_invalid_site_exists(self): ) def test_accesspoint_workflow_invalid_state(self): - """ Test case for access point workflow with an invalid 'state' parameter. diff --git a/tests/unit/modules/dnac/test_discovery_intent.py b/tests/unit/modules/dnac/test_discovery_intent.py index 82f9999de0..43fffdfef4 100644 --- a/tests/unit/modules/dnac/test_discovery_intent.py +++ b/tests/unit/modules/dnac/test_discovery_intent.py @@ -23,7 +23,6 @@ class TestDnacDiscoveryIntent(TestDnacModule): def __init__(self): - """ Inheriting from the base class of dnac_module """ @@ -32,7 +31,6 @@ def __init__(self): super().__init__(module) def load_fixtures(self, response=None, device=""): - """ Load fixtures for a specific device. @@ -45,14 +43,16 @@ def load_fixtures(self, response=None, device=""): self.run_dnac_exec.side_effect = [ Exception(), self.test_data.get("create_discovery_response"), - self.test_data.get("get_business_api_execution_details_response"), + self.test_data.get( + "get_business_api_execution_details_response"), self.test_data.get("get_discovery_response") ] elif "delete_existing_discovery" in self._testMethodName: self.run_dnac_exec.side_effect = [ self.test_data.get("delete_get_discovery_response"), self.test_data.get("delete_delete_discovery_response"), - self.test_data.get("get_business_api_execution_details_response") + self.test_data.get( + "get_business_api_execution_details_response") ] elif "delete_non_existing_discovery" in self._testMethodName: self.run_dnac_exec.side_effect = [ @@ -129,7 +129,8 @@ def test_discovery_intent_delete_non_existing_discovery(self): dnac_log=True, state="deleted", headers=None, - name=self.playbook_config.get('delete_non_exist_discovery_name'), + name=self.playbook_config.get( + 'delete_non_exist_discovery_name'), devices_list=self.playbook_config.get('devices_list'), discoveryType="MULTI RANGE", protocolOrder="ssh", diff --git a/tests/unit/modules/dnac/test_inventory_workflow_manager.py b/tests/unit/modules/dnac/test_inventory_workflow_manager.py index 778359d466..4872ab4914 100644 --- a/tests/unit/modules/dnac/test_inventory_workflow_manager.py +++ b/tests/unit/modules/dnac/test_inventory_workflow_manager.py @@ -32,17 +32,23 @@ class TestDnacInventoryWorkflow(TestDnacModule): playbook_add_device = test_data.get("playbook_add_device") playbook_delete_a_device = test_data.get("playbook_delete_a_device") - playbook_add_existing_devices = test_data.get("playbook_add_existing_devices") + playbook_add_existing_devices = test_data.get( + "playbook_add_existing_devices") playbook_add_udf = test_data.get("playbook_add_udf") - playbook_provision_failed_for_site = test_data.get("playbook_provision_failed_for_site") - playbook_delete_provisioned_device = test_data.get("playbook_delete_provisioned_device") - playbook_update_interface_details = test_data.get("playbook_update_interface_details") + playbook_provision_failed_for_site = test_data.get( + "playbook_provision_failed_for_site") + playbook_delete_provisioned_device = test_data.get( + "playbook_delete_provisioned_device") + playbook_update_interface_details = test_data.get( + "playbook_update_interface_details") playbook_update_role = test_data.get("playbook_update_role") playbook_delete_device_udf = test_data.get("playbook_delete_device_udf") - playbook_missing_mand_params = test_data.get("playbook_missing_mand_params") + playbook_missing_mand_params = test_data.get( + "playbook_missing_mand_params") playbook_update_mgmt_ip = test_data.get("playbook_update_mgmt_ip") playbook_provision_device = test_data.get("playbook_provision_device") - playbook_del_provisioned_device_2353 = test_data.get("playbook_del_provisioned_device_2353") + playbook_del_provisioned_device_2353 = test_data.get( + "playbook_del_provisioned_device_2353") playbook_prov_device_2353 = test_data.get("playbook_prov_device_2353") def setUp(self): @@ -112,20 +118,28 @@ def load_fixtures(self, response=None, device=""): self.test_data.get("add_udf_response"),] elif "playbook_provision_failed_for_site" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("get_device_list1_provision_failed_for_site"), - self.test_data.get("get_device_list2_provision_failed_for_site"), + self.test_data.get( + "get_device_list1_provision_failed_for_site"), + self.test_data.get( + "get_device_list2_provision_failed_for_site"), self.test_data.get("povisioning_failed_response"),] elif "playbook_delete_provisioned_device" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("get_device_list1_delete_provisioned_device"), - self.test_data.get("get_device_list2_delete_provisioned_device"), - self.test_data.get("get_device_list3_delete_provisioned_device"), - self.test_data.get("get_provisioned_devices_delete_provisioned_device"), + self.test_data.get( + "get_device_list1_delete_provisioned_device"), + self.test_data.get( + "get_device_list2_delete_provisioned_device"), + self.test_data.get( + "get_device_list3_delete_provisioned_device"), + self.test_data.get( + "get_provisioned_devices_delete_provisioned_device"), self.test_data.get("delete_provisioned_devices"), self.test_data.get("Task_Details1_delete_provisioned_device"), self.test_data.get("Task_Details2_delete_provisioned_device"), - self.test_data.get("get_device_list4_delete_provisioned_device"), - self.test_data.get("get_device_list5_delete_provisioned_device"), + self.test_data.get( + "get_device_list4_delete_provisioned_device"), + self.test_data.get( + "get_device_list5_delete_provisioned_device"), self.test_data.get("delete_provisioned_response"),] elif "playbook_update_interface_details" in self._testMethodName: self.run_dnac_exec.side_effect = [ @@ -164,7 +178,8 @@ def load_fixtures(self, response=None, device=""): self.test_data.get("get_device_list1_delete_device_udf"), self.test_data.get("get_device_list2_delete_device_udf"), self.test_data.get("get_device_list3_delete_device_udf"), - self.test_data.get("get_provisioned_devices_delete_device_udf"), + self.test_data.get( + "get_provisioned_devices_delete_device_udf"), self.test_data.get("get_device_list4_delete_device_udf"), self.test_data.get("deleted_device_by_id_delete_device_udf"), self.test_data.get("Task_Details1_delete_device_udf"), @@ -189,7 +204,8 @@ def load_fixtures(self, response=None, device=""): self.test_data.get("export_device_list2_update_mgmt_ip"), self.test_data.get("Task_Details3_update_mgmt_ip"), self.test_data.get("Task_Details4_update_mgmt_ip"), - self.test_data.get("download_a_file_by_fileid2_update_mgmt_ip"), + self.test_data.get( + "download_a_file_by_fileid2_update_mgmt_ip"), self.test_data.get("response_update_mgmt_ipaddress"),] elif "playbook_provision_device" in self._testMethodName: self.run_dnac_exec.side_effect = [ @@ -201,8 +217,10 @@ def load_fixtures(self, response=None, device=""): self.test_data.get("get_sites3_provision_device"), self.test_data.get("get_sites4_provision_device"), self.test_data.get("get_device_list4_provision_device"), - self.test_data.get("get_provisioned_devices1_provision_device"), - self.test_data.get("assign_network_devices_to_a_site_provision_device"), + self.test_data.get( + "get_provisioned_devices1_provision_device"), + self.test_data.get( + "assign_network_devices_to_a_site_provision_device"), self.test_data.get("Task_Details1_provision_device"), self.test_data.get("provision_devices"), self.test_data.get("Task_Details2_provision_device"), @@ -216,9 +234,12 @@ def load_fixtures(self, response=None, device=""): self.run_dnac_exec.side_effect = [ self.test_data.get("get_device_list1_del_prov_dev2353"), self.test_data.get("get_device_list2_del_prov_dev2353"), - self.test_data.get("get_provisioned_wired_device_del_prov_dev2353"), - self.test_data.get("delete_provisioned_wired_device_del_prov_dev2353"), - self.test_data.get("get_execution_details_device_del_prov_dev2353"), + self.test_data.get( + "get_provisioned_wired_device_del_prov_dev2353"), + self.test_data.get( + "delete_provisioned_wired_device_del_prov_dev2353"), + self.test_data.get( + "get_execution_details_device_del_prov_dev2353"), self.test_data.get("get_device_list3_del_prov_dev2353"), self.test_data.get("get_device_list4_del_prov_dev2353"), self.test_data.get("response_del_provisioned_device_2353"),] @@ -232,7 +253,8 @@ def load_fixtures(self, response=None, device=""): self.test_data.get("Task_Details_prov_device_2353"), self.test_data.get("get_device_list4_prov_device_2353"), self.test_data.get("get_device_list5_prov_device_2353"), - self.test_data.get("get_provisioned_wired_devices_prov_device_2353"), + self.test_data.get( + "get_provisioned_wired_devices_prov_device_2353"), self.test_data.get("prov_device_2353_response"),] def test_inventory_workflow_manager_playbook_add_device(self): diff --git a/tests/unit/modules/dnac/test_network_compliance_workflow_manager.py b/tests/unit/modules/dnac/test_network_compliance_workflow_manager.py index 8caaabf67f..a7eec6dc06 100644 --- a/tests/unit/modules/dnac/test_network_compliance_workflow_manager.py +++ b/tests/unit/modules/dnac/test_network_compliance_workflow_manager.py @@ -55,10 +55,12 @@ def load_fixtures(self, response=None, device=""): if "run_compliance_with_iplist" in self._testMethodName: self.run_dnac_exec.side_effect = [ self.test_data.get("response_get_device_list_success"), - self.test_data.get("response_get_compliance_details_of_device_1"), + self.test_data.get( + "response_get_compliance_details_of_device_1"), self.test_data.get("response_run_compliance_success"), self.test_data.get("response_get_task_by_id_success"), - self.test_data.get("response_get_compliance_details_of_device_1"), + self.test_data.get( + "response_get_compliance_details_of_device_1"), ] # Run full compliance using Site @@ -66,20 +68,32 @@ def load_fixtures(self, response=None, device=""): self.run_dnac_exec.side_effect = [ self.test_data.get("response_get_site_success"), self.test_data.get("response_get_membership_success"), - self.test_data.get("response_get_compliance_details_of_device_1"), - self.test_data.get("response_get_compliance_details_of_device_2"), - self.test_data.get("response_get_compliance_details_of_device_3"), - self.test_data.get("response_get_compliance_details_of_device_4"), - self.test_data.get("response_get_compliance_details_of_device_5"), - self.test_data.get("response_get_compliance_details_of_device_6"), + self.test_data.get( + "response_get_compliance_details_of_device_1"), + self.test_data.get( + "response_get_compliance_details_of_device_2"), + self.test_data.get( + "response_get_compliance_details_of_device_3"), + self.test_data.get( + "response_get_compliance_details_of_device_4"), + self.test_data.get( + "response_get_compliance_details_of_device_5"), + self.test_data.get( + "response_get_compliance_details_of_device_6"), self.test_data.get("response_run_compliance_success"), self.test_data.get("response_get_task_by_id_success"), - self.test_data.get("response_get_compliance_details_of_device_1"), - self.test_data.get("response_get_compliance_details_of_device_2"), - self.test_data.get("response_get_compliance_details_of_device_3"), - self.test_data.get("response_get_compliance_details_of_device_4"), - self.test_data.get("response_get_compliance_details_of_device_5"), - self.test_data.get("response_get_compliance_details_of_device_6"), + self.test_data.get( + "response_get_compliance_details_of_device_1"), + self.test_data.get( + "response_get_compliance_details_of_device_2"), + self.test_data.get( + "response_get_compliance_details_of_device_3"), + self.test_data.get( + "response_get_compliance_details_of_device_4"), + self.test_data.get( + "response_get_compliance_details_of_device_5"), + self.test_data.get( + "response_get_compliance_details_of_device_6"), ] # Run full compliance using both IP Address and Site @@ -88,36 +102,56 @@ def load_fixtures(self, response=None, device=""): self.test_data.get("response_get_site_success"), self.test_data.get("response_get_membership_success"), self.test_data.get("response_get_device_list_success"), - self.test_data.get("response_get_compliance_details_of_device_1"), - self.test_data.get("response_get_compliance_details_of_device_2"), - self.test_data.get("response_get_compliance_details_of_device_3"), - self.test_data.get("response_get_compliance_details_of_device_4"), - self.test_data.get("response_get_compliance_details_of_device_5"), - self.test_data.get("response_get_compliance_details_of_device_6"), + self.test_data.get( + "response_get_compliance_details_of_device_1"), + self.test_data.get( + "response_get_compliance_details_of_device_2"), + self.test_data.get( + "response_get_compliance_details_of_device_3"), + self.test_data.get( + "response_get_compliance_details_of_device_4"), + self.test_data.get( + "response_get_compliance_details_of_device_5"), + self.test_data.get( + "response_get_compliance_details_of_device_6"), self.test_data.get("response_run_compliance_success"), self.test_data.get("response_get_task_by_id_success"), - self.test_data.get("response_get_compliance_details_of_device_1"), - self.test_data.get("response_get_compliance_details_of_device_2"), - self.test_data.get("response_get_compliance_details_of_device_3"), - self.test_data.get("response_get_compliance_details_of_device_4"), - self.test_data.get("response_get_compliance_details_of_device_5"), - self.test_data.get("response_get_compliance_details_of_device_6"), + self.test_data.get( + "response_get_compliance_details_of_device_1"), + self.test_data.get( + "response_get_compliance_details_of_device_2"), + self.test_data.get( + "response_get_compliance_details_of_device_3"), + self.test_data.get( + "response_get_compliance_details_of_device_4"), + self.test_data.get( + "response_get_compliance_details_of_device_5"), + self.test_data.get( + "response_get_compliance_details_of_device_6"), ] # Run compliance against specific categories using IP Address List if "run_compliance_categories_iplist" in self._testMethodName: self.run_dnac_exec.side_effect = [ self.test_data.get("response_get_device_list_success"), - self.test_data.get("response_get_compliance_details_of_device_category_1_1"), - self.test_data.get("response_get_compliance_details_of_device_category_1_2"), - self.test_data.get("response_get_compliance_details_of_device_category_1_3"), - self.test_data.get("response_get_compliance_details_of_device_category_1_4"), + self.test_data.get( + "response_get_compliance_details_of_device_category_1_1"), + self.test_data.get( + "response_get_compliance_details_of_device_category_1_2"), + self.test_data.get( + "response_get_compliance_details_of_device_category_1_3"), + self.test_data.get( + "response_get_compliance_details_of_device_category_1_4"), self.test_data.get("response_run_compliance_success"), self.test_data.get("response_get_task_by_id_success"), - self.test_data.get("response_get_compliance_details_of_device_category_1_1"), - self.test_data.get("response_get_compliance_details_of_device_category_1_2"), - self.test_data.get("response_get_compliance_details_of_device_category_1_3"), - self.test_data.get("response_get_compliance_details_of_device_category_1_4"), + self.test_data.get( + "response_get_compliance_details_of_device_category_1_1"), + self.test_data.get( + "response_get_compliance_details_of_device_category_1_2"), + self.test_data.get( + "response_get_compliance_details_of_device_category_1_3"), + self.test_data.get( + "response_get_compliance_details_of_device_category_1_4"), ] # Scale - Run full compliance operation @@ -125,24 +159,30 @@ def load_fixtures(self, response=None, device=""): self.run_dnac_exec.side_effect = [ self.test_data.get("response_get_device_list_success"), self.test_data.get("response_get_device_list_success_2"), - self.test_data.get("response_get_compliance_details_of_device_1"), - self.test_data.get("response_get_compliance_details_of_device_2"), + self.test_data.get( + "response_get_compliance_details_of_device_1"), + self.test_data.get( + "response_get_compliance_details_of_device_2"), self.test_data.get("response_run_compliance_success"), self.test_data.get("response_run_compliance_success_2"), self.test_data.get("response_get_task_by_id_success"), self.test_data.get("response_get_task_by_id_success_2"), - self.test_data.get("response_get_compliance_details_of_device_1"), - self.test_data.get("response_get_compliance_details_of_device_2"), + self.test_data.get( + "response_get_compliance_details_of_device_1"), + self.test_data.get( + "response_get_compliance_details_of_device_2"), ] # Run Sync Device Config using IP Address list - Sync Required (Devices with RUNNING_CONFIG status - 'NON_COMPLIANT') if "sync_device_config_iplist" in self._testMethodName: self.run_dnac_exec.side_effect = [ self.test_data.get("response_get_device_list_success"), - self.test_data.get("response_get_compliance_details_of_device_1_running_config"), + self.test_data.get( + "response_get_compliance_details_of_device_1_running_config"), self.test_data.get("response_commit_device_configuration"), self.test_data.get("response_get_task_tree_success"), - self.test_data.get("response_get_compliance_details_of_device_1_running_config_2") + self.test_data.get( + "response_get_compliance_details_of_device_1_running_config_2") ] # Run Sync Device Config using Site - Sync Required (Devices with RUNNING_CONFIG status - 'NON_COMPLIANT') @@ -150,20 +190,32 @@ def load_fixtures(self, response=None, device=""): self.run_dnac_exec.side_effect = [ self.test_data.get("response_get_site_success"), self.test_data.get("response_get_membership_success"), - self.test_data.get("response_get_compliance_details_of_device_1_running_config"), - self.test_data.get("response_get_compliance_details_of_device_2_running_config"), - self.test_data.get("response_get_compliance_details_of_device_3_running_config"), - self.test_data.get("response_get_compliance_details_of_device_4_running_config"), - self.test_data.get("response_get_compliance_details_of_device_5_running_config"), - self.test_data.get("response_get_compliance_details_of_device_6_running_config"), + self.test_data.get( + "response_get_compliance_details_of_device_1_running_config"), + self.test_data.get( + "response_get_compliance_details_of_device_2_running_config"), + self.test_data.get( + "response_get_compliance_details_of_device_3_running_config"), + self.test_data.get( + "response_get_compliance_details_of_device_4_running_config"), + self.test_data.get( + "response_get_compliance_details_of_device_5_running_config"), + self.test_data.get( + "response_get_compliance_details_of_device_6_running_config"), self.test_data.get("response_commit_device_configuration"), self.test_data.get("response_get_task_tree_success"), - self.test_data.get("response_get_compliance_details_of_device_1_running_config_2"), - self.test_data.get("response_get_compliance_details_of_device_2_running_config_2"), - self.test_data.get("response_get_compliance_details_of_device_3_running_config_2"), - self.test_data.get("response_get_compliance_details_of_device_4_running_config_2"), - self.test_data.get("response_get_compliance_details_of_device_5_running_config_2"), - self.test_data.get("response_get_compliance_details_of_device_6_running_config_2") + self.test_data.get( + "response_get_compliance_details_of_device_1_running_config_2"), + self.test_data.get( + "response_get_compliance_details_of_device_2_running_config_2"), + self.test_data.get( + "response_get_compliance_details_of_device_3_running_config_2"), + self.test_data.get( + "response_get_compliance_details_of_device_4_running_config_2"), + self.test_data.get( + "response_get_compliance_details_of_device_5_running_config_2"), + self.test_data.get( + "response_get_compliance_details_of_device_6_running_config_2") ] # Run Sync Device Config using both IP Address List and Site - Sync Required (Devices with RUNNING_CONFIG status - 'NON_COMPLIANT') @@ -172,20 +224,32 @@ def load_fixtures(self, response=None, device=""): self.test_data.get("response_get_site_success"), self.test_data.get("response_get_membership_success"), self.test_data.get("response_get_device_list_success"), - self.test_data.get("response_get_compliance_details_of_device_1_running_config"), - self.test_data.get("response_get_compliance_details_of_device_2_running_config"), - self.test_data.get("response_get_compliance_details_of_device_3_running_config"), - self.test_data.get("response_get_compliance_details_of_device_4_running_config"), - self.test_data.get("response_get_compliance_details_of_device_5_running_config"), - self.test_data.get("response_get_compliance_details_of_device_6_running_config"), + self.test_data.get( + "response_get_compliance_details_of_device_1_running_config"), + self.test_data.get( + "response_get_compliance_details_of_device_2_running_config"), + self.test_data.get( + "response_get_compliance_details_of_device_3_running_config"), + self.test_data.get( + "response_get_compliance_details_of_device_4_running_config"), + self.test_data.get( + "response_get_compliance_details_of_device_5_running_config"), + self.test_data.get( + "response_get_compliance_details_of_device_6_running_config"), self.test_data.get("response_commit_device_configuration"), self.test_data.get("response_get_task_tree_success"), - self.test_data.get("response_get_compliance_details_of_device_1_running_config_2"), - self.test_data.get("response_get_compliance_details_of_device_2_running_config_2"), - self.test_data.get("response_get_compliance_details_of_device_3_running_config_2"), - self.test_data.get("response_get_compliance_details_of_device_4_running_config_2"), - self.test_data.get("response_get_compliance_details_of_device_5_running_config_2"), - self.test_data.get("response_get_compliance_details_of_device_6_running_config_2") + self.test_data.get( + "response_get_compliance_details_of_device_1_running_config_2"), + self.test_data.get( + "response_get_compliance_details_of_device_2_running_config_2"), + self.test_data.get( + "response_get_compliance_details_of_device_3_running_config_2"), + self.test_data.get( + "response_get_compliance_details_of_device_4_running_config_2"), + self.test_data.get( + "response_get_compliance_details_of_device_5_running_config_2"), + self.test_data.get( + "response_get_compliance_details_of_device_6_running_config_2") ] # Run Sync Device Config using both IP Address List and Site - Not required (All devices with RUNNING_CONFIG status - 'COMPLIANT' or other) @@ -194,12 +258,18 @@ def load_fixtures(self, response=None, device=""): self.test_data.get("response_get_site_success"), self.test_data.get("response_get_membership_success"), self.test_data.get("response_get_device_list_success"), - self.test_data.get("response_get_compliance_details_of_device_1_running_config_2"), - self.test_data.get("response_get_compliance_details_of_device_2_running_config_2"), - self.test_data.get("response_get_compliance_details_of_device_3_running_config_2"), - self.test_data.get("response_get_compliance_details_of_device_4_running_config_2"), - self.test_data.get("response_get_compliance_details_of_device_5_running_config_2"), - self.test_data.get("response_get_compliance_details_of_device_6_running_config_2") + self.test_data.get( + "response_get_compliance_details_of_device_1_running_config_2"), + self.test_data.get( + "response_get_compliance_details_of_device_2_running_config_2"), + self.test_data.get( + "response_get_compliance_details_of_device_3_running_config_2"), + self.test_data.get( + "response_get_compliance_details_of_device_4_running_config_2"), + self.test_data.get( + "response_get_compliance_details_of_device_5_running_config_2"), + self.test_data.get( + "response_get_compliance_details_of_device_6_running_config_2") ] # FIXTURES FOR FAILURE TESTCASES ############################################################ @@ -220,7 +290,8 @@ def load_fixtures(self, response=None, device=""): if "run_compliance_with_iplist_failure_3" in self._testMethodName: self.run_dnac_exec.side_effect = [ self.test_data.get("response_get_device_list_success"), - self.test_data.get("response_get_compliance_details_of_device_1"), + self.test_data.get( + "response_get_compliance_details_of_device_1"), Exception("Simulated exception"), ] @@ -228,7 +299,8 @@ def load_fixtures(self, response=None, device=""): if "run_compliance_with_iplist_failure_4" in self._testMethodName: self.run_dnac_exec.side_effect = [ self.test_data.get("response_get_device_list_success"), - self.test_data.get("response_get_compliance_details_of_device_1"), + self.test_data.get( + "response_get_compliance_details_of_device_1"), self.test_data.get("response_run_compliance_success"), Exception("Simulated exception"), ] @@ -237,7 +309,8 @@ def load_fixtures(self, response=None, device=""): if "run_compliance_with_iplist_failure_5" in self._testMethodName: self.run_dnac_exec.side_effect = [ self.test_data.get("response_get_device_list_success"), - self.test_data.get("response_get_compliance_details_of_device_1"), + self.test_data.get( + "response_get_compliance_details_of_device_1"), self.test_data.get("response_run_compliance_success"), self.test_data.get("response_get_task_by_id_success"), Exception("Simulated exception"), @@ -261,9 +334,12 @@ def load_fixtures(self, response=None, device=""): self.run_dnac_exec.side_effect = [ self.test_data.get("response_get_site_success"), self.test_data.get("response_get_membership_success"), - self.test_data.get("response_get_compliance_details_of_device_1"), - self.test_data.get("response_get_compliance_details_of_device_2"), - self.test_data.get("response_get_compliance_details_of_device_3"), + self.test_data.get( + "response_get_compliance_details_of_device_1"), + self.test_data.get( + "response_get_compliance_details_of_device_2"), + self.test_data.get( + "response_get_compliance_details_of_device_3"), Exception("Simulated exception") ] @@ -272,12 +348,18 @@ def load_fixtures(self, response=None, device=""): self.run_dnac_exec.side_effect = [ self.test_data.get("response_get_site_success"), self.test_data.get("response_get_membership_success"), - self.test_data.get("response_get_compliance_details_of_device_1"), - self.test_data.get("response_get_compliance_details_of_device_2"), - self.test_data.get("response_get_compliance_details_of_device_3"), - self.test_data.get("response_get_compliance_details_of_device_4"), - self.test_data.get("response_get_compliance_details_of_device_5"), - self.test_data.get("response_get_compliance_details_of_device_6"), + self.test_data.get( + "response_get_compliance_details_of_device_1"), + self.test_data.get( + "response_get_compliance_details_of_device_2"), + self.test_data.get( + "response_get_compliance_details_of_device_3"), + self.test_data.get( + "response_get_compliance_details_of_device_4"), + self.test_data.get( + "response_get_compliance_details_of_device_5"), + self.test_data.get( + "response_get_compliance_details_of_device_6"), Exception("Simulated exception") ] @@ -286,12 +368,18 @@ def load_fixtures(self, response=None, device=""): self.run_dnac_exec.side_effect = [ self.test_data.get("response_get_site_success"), self.test_data.get("response_get_membership_success"), - self.test_data.get("response_get_compliance_details_of_device_1"), - self.test_data.get("response_get_compliance_details_of_device_2"), - self.test_data.get("response_get_compliance_details_of_device_3"), - self.test_data.get("response_get_compliance_details_of_device_4"), - self.test_data.get("response_get_compliance_details_of_device_5"), - self.test_data.get("response_get_compliance_details_of_device_6"), + self.test_data.get( + "response_get_compliance_details_of_device_1"), + self.test_data.get( + "response_get_compliance_details_of_device_2"), + self.test_data.get( + "response_get_compliance_details_of_device_3"), + self.test_data.get( + "response_get_compliance_details_of_device_4"), + self.test_data.get( + "response_get_compliance_details_of_device_5"), + self.test_data.get( + "response_get_compliance_details_of_device_6"), self.test_data.get("response_run_compliance_success"), Exception("Simulated exception") ] @@ -301,12 +389,18 @@ def load_fixtures(self, response=None, device=""): self.run_dnac_exec.side_effect = [ self.test_data.get("response_get_site_success"), self.test_data.get("response_get_membership_success"), - self.test_data.get("response_get_compliance_details_of_device_1"), - self.test_data.get("response_get_compliance_details_of_device_2"), - self.test_data.get("response_get_compliance_details_of_device_3"), - self.test_data.get("response_get_compliance_details_of_device_4"), - self.test_data.get("response_get_compliance_details_of_device_5"), - self.test_data.get("response_get_compliance_details_of_device_6"), + self.test_data.get( + "response_get_compliance_details_of_device_1"), + self.test_data.get( + "response_get_compliance_details_of_device_2"), + self.test_data.get( + "response_get_compliance_details_of_device_3"), + self.test_data.get( + "response_get_compliance_details_of_device_4"), + self.test_data.get( + "response_get_compliance_details_of_device_5"), + self.test_data.get( + "response_get_compliance_details_of_device_6"), self.test_data.get("response_run_compliance_success"), self.test_data.get("response_get_task_by_id_success"), Exception("Simulated exception") @@ -316,7 +410,8 @@ def load_fixtures(self, response=None, device=""): if "sync_device_config_iplist_failure_1" in self._testMethodName: self.run_dnac_exec.side_effect = [ self.test_data.get("response_get_device_list_success"), - self.test_data.get("response_get_compliance_details_of_device_1_running_config"), + self.test_data.get( + "response_get_compliance_details_of_device_1_running_config"), Exception("Simulated exception") ] @@ -324,7 +419,8 @@ def load_fixtures(self, response=None, device=""): if "sync_device_config_iplist_failure_2" in self._testMethodName: self.run_dnac_exec.side_effect = [ self.test_data.get("response_get_device_list_success"), - self.test_data.get("response_get_compliance_details_of_device_1_running_config"), + self.test_data.get( + "response_get_compliance_details_of_device_1_running_config"), self.test_data.get("response_commit_device_configuration"), Exception("Simulated exception") ] @@ -343,7 +439,8 @@ def test_run_compliance_with_iplist(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_run_compliance_iplist") + config=self.test_data.get( + "playbook_config_run_compliance_iplist") ) ) result = self.execute_module(changed=True, failed=False) @@ -364,7 +461,8 @@ def test_run_compliance_with_site(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_run_compliance_site") + config=self.test_data.get( + "playbook_config_run_compliance_site") ) ) result = self.execute_module(changed=True, failed=False) @@ -385,7 +483,8 @@ def test_run_compliance_with_iplist_site(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_run_compliance_iplist_site") + config=self.test_data.get( + "playbook_config_run_compliance_iplist_site") ) ) result = self.execute_module(changed=True, failed=False) @@ -406,7 +505,8 @@ def test_run_compliance_categories_iplist(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_run_compliance_categories_iplist") + config=self.test_data.get( + "playbook_config_run_compliance_categories_iplist") ) ) result = self.execute_module(changed=True, failed=False) @@ -427,7 +527,8 @@ def test_scale_run_compliance(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_run_compliance_scale_iplist") + config=self.test_data.get( + "playbook_config_run_compliance_scale_iplist") ) ) result = self.execute_module(changed=True, failed=False) @@ -449,7 +550,8 @@ def test_sync_device_config_iplist(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_sync_device_config_iplist") + config=self.test_data.get( + "playbook_config_sync_device_config_iplist") ) ) result = self.execute_module(changed=True, failed=False) @@ -470,7 +572,8 @@ def test_sync_device_config_site(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_sync_device_config_site") + config=self.test_data.get( + "playbook_config_sync_device_config_site") ) ) result = self.execute_module(changed=True, failed=False) @@ -491,7 +594,8 @@ def test_sync_device_config_iplist_site(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_sync_device_config_iplist_site") + config=self.test_data.get( + "playbook_config_sync_device_config_iplist_site") ) ) result = self.execute_module(changed=True, failed=False) @@ -512,7 +616,8 @@ def test_sync_device_config_iplist_site_nr(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_sync_device_config_iplist_site_nr") + config=self.test_data.get( + "playbook_config_sync_device_config_iplist_site_nr") ) ) result = self.execute_module(changed=False, failed=False) @@ -535,7 +640,8 @@ def test_run_compliance_with_iplist_failure_1(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_run_compliance_iplist") + config=self.test_data.get( + "playbook_config_run_compliance_iplist") ) ) result = self.execute_module(changed=False, failed=False) @@ -556,7 +662,8 @@ def test_run_compliance_with_iplist_failure_2(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_run_compliance_iplist") + config=self.test_data.get( + "playbook_config_run_compliance_iplist") ) ) result = self.execute_module(changed=False, failed=True) @@ -577,7 +684,8 @@ def test_run_compliance_with_iplist_failure_3(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_run_compliance_iplist") + config=self.test_data.get( + "playbook_config_run_compliance_iplist") ) ) result = self.execute_module(changed=False, failed=True) @@ -598,7 +706,8 @@ def test_run_compliance_with_iplist_failure_4(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_run_compliance_iplist") + config=self.test_data.get( + "playbook_config_run_compliance_iplist") ) ) result = self.execute_module(changed=False, failed=True) @@ -619,7 +728,8 @@ def test_run_compliance_with_iplist_failure_5(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_run_compliance_iplist") + config=self.test_data.get( + "playbook_config_run_compliance_iplist") ) ) result = self.execute_module(changed=False, failed=True) @@ -640,7 +750,8 @@ def test_run_compliance_with_site_failure_1(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_run_compliance_site") + config=self.test_data.get( + "playbook_config_run_compliance_site") ) ) result = self.execute_module(changed=False, failed=True) @@ -661,7 +772,8 @@ def test_run_compliance_with_site_failure_2(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_run_compliance_site") + config=self.test_data.get( + "playbook_config_run_compliance_site") ) ) result = self.execute_module(changed=False, failed=False) @@ -682,7 +794,8 @@ def test_run_compliance_with_site_failure_3(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_run_compliance_site") + config=self.test_data.get( + "playbook_config_run_compliance_site") ) ) result = self.execute_module(changed=False, failed=True) @@ -703,7 +816,8 @@ def test_run_compliance_with_site_failure_4(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_run_compliance_site") + config=self.test_data.get( + "playbook_config_run_compliance_site") ) ) result = self.execute_module(changed=False, failed=True) @@ -724,7 +838,8 @@ def test_run_compliance_with_site_failure_5(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_run_compliance_site") + config=self.test_data.get( + "playbook_config_run_compliance_site") ) ) result = self.execute_module(changed=False, failed=True) @@ -745,7 +860,8 @@ def test_run_compliance_with_site_failure_6(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_run_compliance_site") + config=self.test_data.get( + "playbook_config_run_compliance_site") ) ) result = self.execute_module(changed=False, failed=True) @@ -766,7 +882,8 @@ def test_sync_device_config_iplist_failure_1(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_sync_device_config_iplist") + config=self.test_data.get( + "playbook_config_sync_device_config_iplist") ) ) result = self.execute_module(changed=False, failed=True) @@ -787,7 +904,8 @@ def test_sync_device_config_iplist_failure_2(self): dnac_log_level="DEBUG", dnac_log_append=False, state="merged", - config=self.test_data.get("playbook_config_sync_device_config_iplist") + config=self.test_data.get( + "playbook_config_sync_device_config_iplist") ) ) result = self.execute_module(changed=False, failed=True) diff --git a/tests/unit/modules/dnac/test_network_settings_workflow_manager.py b/tests/unit/modules/dnac/test_network_settings_workflow_manager.py index 7e1451c75c..aa69605478 100644 --- a/tests/unit/modules/dnac/test_network_settings_workflow_manager.py +++ b/tests/unit/modules/dnac/test_network_settings_workflow_manager.py @@ -27,13 +27,19 @@ class TestDnacNetworkSettings(TestDnacModule): test_data = loadPlaybookData("network_settings_workflow_manager") playbook_config_network = test_data.get("playbook_config_network") playbook_update_network = test_data.get("playbook_update_network") - playbook_config_update_not_req = test_data.get("playbook_config_update_not_req") + playbook_config_update_not_req = test_data.get( + "playbook_config_update_not_req") playbook_config_aaa_req = test_data.get("playbook_config_aaa_req") - playbook_global_pool_creation = test_data.get("playbook_global_pool_creation") - playbook_global_pool_updation = test_data.get("playbook_global_pool_updation") - playbook_config_reserve_pool = test_data.get("playbook_config_reserve_pool") - playbook_config_reserve_pool_deletion = test_data.get("playbook_config_reserve_pool_deletion") - playbook_config_global_pool_deletion = test_data.get("playbook_config_global_pool_deletion") + playbook_global_pool_creation = test_data.get( + "playbook_global_pool_creation") + playbook_global_pool_updation = test_data.get( + "playbook_global_pool_updation") + playbook_config_reserve_pool = test_data.get( + "playbook_config_reserve_pool") + playbook_config_reserve_pool_deletion = test_data.get( + "playbook_config_reserve_pool_deletion") + playbook_config_global_pool_deletion = test_data.get( + "playbook_config_global_pool_deletion") def setUp(self): super(TestDnacNetworkSettings, self).setUp() @@ -976,7 +982,8 @@ def test_Network_settings_workflow_manager_global_pool_creation(self): print(result["response"][0].get("globalPool").get("msg")) self.assertEqual( result["response"][0].get("globalPool").get("msg"), - {'Global_Pool2': 'Global Pool Created Successfully', 'Global_Pool3': 'Global Pool Created Successfully'} + {'Global_Pool2': 'Global Pool Created Successfully', + 'Global_Pool3': 'Global Pool Created Successfully'} ) @@ -1002,7 +1009,8 @@ def test_Network_settings_workflow_manager_global_pool_Updation_not_req(self): # print(result) self.assertEqual( result["response"][0].get("globalPool").get("msg"), - {'Global_Pool2': "Global pool doesn't require an update", 'Global_Pool3': "Global pool doesn't require an update"} + {'Global_Pool2': "Global pool doesn't require an update", + 'Global_Pool3': "Global pool doesn't require an update"} ) diff --git a/tests/unit/modules/dnac/test_pnp_intent.py b/tests/unit/modules/dnac/test_pnp_intent.py index 6f93e2a8ae..029a880b34 100644 --- a/tests/unit/modules/dnac/test_pnp_intent.py +++ b/tests/unit/modules/dnac/test_pnp_intent.py @@ -24,7 +24,6 @@ class TestDnacPnPIntent(TestDnacModule): def __init__(self): - """ Inheriting from the base class of dnac_module """ @@ -33,7 +32,6 @@ def __init__(self): super().__init__(module) def load_fixtures(self, response=None, device=""): - """ Load fixtures for a specific device. @@ -103,7 +101,6 @@ def load_fixtures(self, response=None, device=""): ] def test_pnp_intent_site_not_found(self): - """ Test case for PnP intent when site is not found. @@ -127,7 +124,6 @@ def test_pnp_intent_site_not_found(self): ) def test_pnp_intent_add_new_device(self): - """ Test case for PnP intent when adding a new device. @@ -151,7 +147,6 @@ def test_pnp_intent_add_new_device(self): ) def test_pnp_intent_device_exists(self): - """ Test case for PnP intent when a device already exists. @@ -175,7 +170,6 @@ def test_pnp_intent_device_exists(self): ) def test_pnp_intent_image_doesnot_exist(self): - """ Test case for PnP intent when an image does not exist. @@ -199,7 +193,6 @@ def test_pnp_intent_image_doesnot_exist(self): ) def test_pnp_intent_template_doesnot_exist(self): - """ Test case for PnP intent when a template does not exist. @@ -223,7 +216,6 @@ def test_pnp_intent_template_doesnot_exist(self): ) def test_pnp_intent_project_not_found(self): - """ Test case for PnP intent when a project is not found. @@ -247,7 +239,6 @@ def test_pnp_intent_project_not_found(self): ) def test_pnp_intent_missing_param(self): - """ Test case for PnP intent with missing parameters in the playbook. @@ -271,7 +262,6 @@ def test_pnp_intent_missing_param(self): ) def test_pnp_intent_delete_device(self): - """ Test case for PnP intent when deleting a device. @@ -295,7 +285,6 @@ def test_pnp_intent_delete_device(self): ) def test_pnp_intent_deletion_error(self): - """ Test case for PnP intent when device deletion fails. @@ -319,7 +308,6 @@ def test_pnp_intent_deletion_error(self): ) def test_pnp_intent_delete_nonexisting_device(self): - """ Test case for PnP intent when deleting a non-existing device. @@ -343,7 +331,6 @@ def test_pnp_intent_delete_nonexisting_device(self): ) def test_pnp_intent_invalid_state(self): - """ Test case for PnP intent with an invalid state parameter. diff --git a/tests/unit/modules/dnac/test_provision_workflow_manager.py b/tests/unit/modules/dnac/test_provision_workflow_manager.py index f72bdbd2e7..c8984244c0 100644 --- a/tests/unit/modules/dnac/test_provision_workflow_manager.py +++ b/tests/unit/modules/dnac/test_provision_workflow_manager.py @@ -114,7 +114,8 @@ def load_fixtures(self, response=None, device=""): self.test_data.get("get_network_device_by_ip_force_provision"), self.test_data.get("get_sites_force_provision"), self.test_data.get("get_site_force_provision"), - self.test_data.get("get_provisioned_wired_device_force_provision"), + self.test_data.get( + "get_provisioned_wired_device_force_provision"), self.test_data.get("re_provision_wired_device"), self.test_data.get("Task_Details_force_provision"), self.test_data.get("Task_Details1_force_provision"), diff --git a/tests/unit/modules/dnac/test_rma_workflow_manager.py b/tests/unit/modules/dnac/test_rma_workflow_manager.py index fe0a1c101d..3e217b7fbe 100644 --- a/tests/unit/modules/dnac/test_rma_workflow_manager.py +++ b/tests/unit/modules/dnac/test_rma_workflow_manager.py @@ -29,12 +29,16 @@ class TestDnacRmaIntent(TestDnacModule): playbook_config_valid = test_data.get("playbook_config_valid") playbook_config_device_name = test_data.get("playbook_config_device_name") - playbook_config_serial_number = test_data.get("playbook_config_serial_number") - playbook_config_device_not_found = test_data.get("playbook_config_device_not_found") - playbook_config_faulty_device_not_found = test_data.get("playbook_config_faulty_device_not_found") + playbook_config_serial_number = test_data.get( + "playbook_config_serial_number") + playbook_config_device_not_found = test_data.get( + "playbook_config_device_not_found") + playbook_config_faulty_device_not_found = test_data.get( + "playbook_config_faulty_device_not_found") playbook_invalid_serial = test_data.get("playbook_invalid_serial") playbook_config_exception = test_data.get("playbook_config_exception") - playbook_config_invalid_params = test_data.get("playbook_config_invalid_params") + playbook_config_invalid_params = test_data.get( + "playbook_config_invalid_params") playbook_invalid_config = test_data.get("playbook_invalid_config") def setUp(self): diff --git a/tests/unit/modules/dnac/test_site_intent.py b/tests/unit/modules/dnac/test_site_intent.py index 089d4ee85b..d492b39a6e 100644 --- a/tests/unit/modules/dnac/test_site_intent.py +++ b/tests/unit/modules/dnac/test_site_intent.py @@ -31,7 +31,6 @@ def __init__(self): super().__init__(module) def load_fixtures(self, response=None, device=""): - """ Load fixtures for a specific device. @@ -44,7 +43,8 @@ def load_fixtures(self, response=None, device=""): self.run_dnac_exec.side_effect = [ Exception(), self.test_data.get("create_site_response"), - self.test_data.get("get_business_api_execution_details_response"), + self.test_data.get( + "get_business_api_execution_details_response"), self.test_data.get("get_site_response") ] @@ -57,13 +57,15 @@ def load_fixtures(self, response=None, device=""): self.run_dnac_exec.side_effect = [ self.test_data.get("update_needed_get_site_response"), self.test_data.get("update_needed_update_site_response"), - self.test_data.get("get_business_api_execution_details_response") + self.test_data.get( + "get_business_api_execution_details_response") ] elif "delete_existing_site" in self._testMethodName: self.run_dnac_exec.side_effect = [ self.test_data.get("delete_get_site_response"), self.test_data.get("delete_delete_site_response"), - self.test_data.get("get_business_api_execution_details_response") + self.test_data.get( + "get_business_api_execution_details_response") ] elif "delete_non_existing_site" in self._testMethodName: self.run_dnac_exec.side_effect = [ @@ -83,7 +85,6 @@ def load_fixtures(self, response=None, device=""): ] def test_site_intent_create_site(self): - """ Test case for site intent when creating a site. @@ -107,7 +108,6 @@ def test_site_intent_create_site(self): ) def test_site_intent_update_not_needed(self): - """ Test case for site intent when no update is needed. @@ -131,7 +131,6 @@ def test_site_intent_update_not_needed(self): ) def test_site_intent_update_needed(self): - """ Test case for site intent when an update is needed. @@ -155,7 +154,6 @@ def test_site_intent_update_needed(self): ) def test_site_intent_delete_existing_site(self): - """ Test case for site intent when deleting an existing site. @@ -179,7 +177,6 @@ def test_site_intent_delete_existing_site(self): ) def test_site_intent_delete_non_existing_site(self): - """ Test case for site intent when attempting to delete a non-existing site. @@ -203,7 +200,6 @@ def test_site_intent_delete_non_existing_site(self): ) def test_site_intent_invalid_param(self): - """ Test case for site intent with invalid parameters in the playbook. @@ -226,7 +222,6 @@ def test_site_intent_invalid_param(self): ) def test_site_intent_error_delete(self): - """ Test case for site intent when an error occurs during site deletion. @@ -250,7 +245,6 @@ def test_site_intent_error_delete(self): ) def test_site_intent_error_create(self): - """ Test case for site intent when an error occurs during site creation. @@ -274,7 +268,6 @@ def test_site_intent_error_create(self): ) def test_site_intent_invalid_state(self): - """ Test case for site intent with an invalid 'state' parameter. diff --git a/tests/unit/modules/dnac/test_site_workflow_manager.py b/tests/unit/modules/dnac/test_site_workflow_manager.py index 4ea81d9f2a..72b4872e9d 100644 --- a/tests/unit/modules/dnac/test_site_workflow_manager.py +++ b/tests/unit/modules/dnac/test_site_workflow_manager.py @@ -29,11 +29,14 @@ class TestDnacSiteWorkflow(TestDnacModule): playbook_config_site = test_data.get("playbook_config_site") playbook_config_update_site = test_data.get("playbook_config_update_site") update_a_playbook = test_data.get("update_a_playbook") - playbook_config_invalid_param = test_data.get("playbook_config_invalid_param") + playbook_config_invalid_param = test_data.get( + "playbook_config_invalid_param") playbook_config_empty = test_data.get("playbook_config_empty") - playbook_config_invalid_bulk_site = test_data.get("playbook_config_invalid_bulk_site") + playbook_config_invalid_bulk_site = test_data.get( + "playbook_config_invalid_bulk_site") playbook_config_delete = test_data.get("playbook_config_delete") - playbook_config_update1_site = test_data.get("playbook_config_update1_site") + playbook_config_update1_site = test_data.get( + "playbook_config_update1_site") delete_playbook_config = test_data.get("delete_playbook_config") upload_floor_map_playbook = test_data.get("upload_floor_map_playbook") delete_config_playbook = test_data.get("delete_config_playbook") @@ -324,7 +327,6 @@ def test_Site_workflow_manager_upload_floor_map(self): ) def test_site_workflow_manager_invalid_param(self): - """ Test case for site workflow manager with invalid parameters in the playbook. @@ -348,7 +350,6 @@ def test_site_workflow_manager_invalid_param(self): ) def test_site_workflow_manager_invalid_delete_site(self): - """ Test case for site workflow manager with invalid parameters in the playbook. diff --git a/tests/unit/modules/dnac/test_swim_intent.py b/tests/unit/modules/dnac/test_swim_intent.py index d2915e6218..4c5a9583ec 100644 --- a/tests/unit/modules/dnac/test_swim_intent.py +++ b/tests/unit/modules/dnac/test_swim_intent.py @@ -31,7 +31,6 @@ def __init__(self): super().__init__(module) def load_fixtures(self, response=None, device=""): - """ Load fixtures for a specific device. @@ -109,7 +108,6 @@ def load_fixtures(self, response=None, device=""): ] def test_swim_full_flow(self): - """ Test case for a full Software Image Management (SWIM) flow. @@ -132,7 +130,6 @@ def test_swim_full_flow(self): ) def test_swim_image_import(self): - """ Test case for SWIM image import when the image already exists. @@ -155,7 +152,6 @@ def test_swim_image_import(self): ) def test_swim_image_local_import(self): - """ Test case for SWIM local image import when the image already exists. @@ -178,7 +174,6 @@ def test_swim_image_local_import(self): ) def test_swim_untag_image(self): - """ Test case for SWIM untagging an image as Golden. @@ -201,7 +196,6 @@ def test_swim_untag_image(self): ) def test_swim_missing_param_tag_golden_image(self): - """ Test case for SWIM with missing parameters for tagging a Golden image. @@ -214,7 +208,8 @@ def test_swim_missing_param_tag_golden_image(self): dnac_username="dummy", dnac_password="dummy", dnac_log=True, - config=self.test_data.get("playbook_config_tag_golden_image_missing_param") + config=self.test_data.get( + "playbook_config_tag_golden_image_missing_param") ) ) result = self.execute_module(changed=False, failed=True) @@ -224,7 +219,6 @@ def test_swim_missing_param_tag_golden_image(self): ) def test_swim_incorrect_site_untag_golden_image(self): - """ Test case for SWIM when trying to untag an image from a non-existing site. @@ -247,7 +241,6 @@ def test_swim_incorrect_site_untag_golden_image(self): ) def test_swim_image_doesnot_exist_response(self): - """ Test case for SWIM when the image does not exist in the response. @@ -270,7 +263,6 @@ def test_swim_image_doesnot_exist_response(self): ) def test_swim_only_image_distribution(self): - """ Test case for SWIM with only image distribution. @@ -293,7 +285,6 @@ def test_swim_only_image_distribution(self): ) def test_swim_image_distribution_missing_param(self): - """ Test case for SWIM image distribution with missing parameters. @@ -306,7 +297,8 @@ def test_swim_image_distribution_missing_param(self): dnac_username="dummy", dnac_password="dummy", dnac_log=True, - config=self.test_data.get("playbook_config_distribution_missing_param") + config=self.test_data.get( + "playbook_config_distribution_missing_param") ) ) result = self.execute_module(changed=False, failed=True) @@ -316,7 +308,6 @@ def test_swim_image_distribution_missing_param(self): ) def test_swim_only_image_activation(self): - """ Test case for SWIM with only image activation. @@ -339,7 +330,6 @@ def test_swim_only_image_activation(self): ) def test_swim_image_activation_missing_param(self): - """ Test case for SWIM image activation with missing parameters. @@ -352,7 +342,8 @@ def test_swim_image_activation_missing_param(self): dnac_username="dummy", dnac_password="dummy", dnac_log=True, - config=self.test_data.get("playbook_config_activation_missing_param") + config=self.test_data.get( + "playbook_config_activation_missing_param") ) ) result = self.execute_module(changed=False, failed=True) @@ -362,7 +353,6 @@ def test_swim_image_activation_missing_param(self): ) def test_swim_tag_golden_incorrect_family_name(self): - """ Test case for SWIM when tagging an image as Golden with an incorrect family name. @@ -375,7 +365,8 @@ def test_swim_tag_golden_incorrect_family_name(self): dnac_username="dummy", dnac_password="dummy", dnac_log=True, - config=self.test_data.get("playbook_config_tag_golden_image_incorrect_family_name") + config=self.test_data.get( + "playbook_config_tag_golden_image_incorrect_family_name") ) ) result = self.execute_module(changed=False, failed=True) @@ -385,7 +376,6 @@ def test_swim_tag_golden_incorrect_family_name(self): ) def test_swim_device_doesnot_exist(self): - """ Test case for SWIM when the device does not exist. @@ -408,7 +398,6 @@ def test_swim_device_doesnot_exist(self): ) def test_swim_incorrect_image_import_parameter(self): - """ Test case for SWIM with incorrect image import parameters. @@ -421,7 +410,8 @@ def test_swim_incorrect_image_import_parameter(self): dnac_username="dummy", dnac_password="dummy", dnac_log=True, - config=self.test_data.get("playbook_config_incorrect_image_import_parameter") + config=self.test_data.get( + "playbook_config_incorrect_image_import_parameter") ) ) result = self.execute_module(changed=False, failed=True) diff --git a/tests/unit/modules/dnac/test_swim_workflow_manager.py b/tests/unit/modules/dnac/test_swim_workflow_manager.py index 1225bf0e34..3f21a52363 100644 --- a/tests/unit/modules/dnac/test_swim_workflow_manager.py +++ b/tests/unit/modules/dnac/test_swim_workflow_manager.py @@ -23,20 +23,32 @@ class TestswimWorkflowManager(TestDnacModule): module = swim_workflow_manager test_data = loadPlaybookData("swim_workflow_manager") - playbook_untag_image_as_golden_and_load_on_device = test_data.get("playbook_untag_image_as_golden_and_load_on_device") - playbook_import_image_already_exist = test_data.get("playbook_import_image_already_exist") + playbook_untag_image_as_golden_and_load_on_device = test_data.get( + "playbook_untag_image_as_golden_and_load_on_device") + playbook_import_image_already_exist = test_data.get( + "playbook_import_image_already_exist") playbook_site_not_exist = test_data.get("playbook_site_not_exist") playbook_swim_image_invalid = test_data.get("playbook_swim_image_invalid") - playbook_image_distribution_failed = test_data.get("playbook_image_distribution_failed") - playbook_swim_image_golden_already_tagged = test_data.get("playbook_swim_image_golden_already_tagged") - playbook_swim_image_cant_found = test_data.get("playbook_swim_image_cant_found") - playbook_image_details_distribution_not_provided = test_data.get("playbook_image_details_distribution_not_provided") - playbook_device_family_not_found = test_data.get("playbook_device_family_not_found") - playbook_import_image_remote = test_data.get("playbook_import_image_remote") - playbook_image_distribution_successfull = test_data.get("playbook_image_distribution_successfull") - playbook_image_distribution_successfull_v2_3_7_6 = test_data.get("playbook_image_distribution_successfull_v2_3_7_6") - playbook_swim_image_golden_tag = test_data.get("playbook_swim_image_golden_tag") - playbook_inheritted_tag_cannot_be_untagged = test_data.get("playbook_inheritted_tag_cannot_be_untagged") + playbook_image_distribution_failed = test_data.get( + "playbook_image_distribution_failed") + playbook_swim_image_golden_already_tagged = test_data.get( + "playbook_swim_image_golden_already_tagged") + playbook_swim_image_cant_found = test_data.get( + "playbook_swim_image_cant_found") + playbook_image_details_distribution_not_provided = test_data.get( + "playbook_image_details_distribution_not_provided") + playbook_device_family_not_found = test_data.get( + "playbook_device_family_not_found") + playbook_import_image_remote = test_data.get( + "playbook_import_image_remote") + playbook_image_distribution_successfull = test_data.get( + "playbook_image_distribution_successfull") + playbook_image_distribution_successfull_v2_3_7_6 = test_data.get( + "playbook_image_distribution_successfull_v2_3_7_6") + playbook_swim_image_golden_tag = test_data.get( + "playbook_swim_image_golden_tag") + playbook_inheritted_tag_cannot_be_untagged = test_data.get( + "playbook_inheritted_tag_cannot_be_untagged") playbook_import_cco_image = test_data.get("playbook_import_cco_image") playbook_activate_image = test_data.get("playbook_activate_image") @@ -76,7 +88,8 @@ def load_fixtures(self, response=None, device=""): self.test_data.get("get_device_family_identifiers_1"), self.test_data.get("get_software_image_details_3"), self.test_data.get("get_golden_tag_status_of_an_image_1"), - self.test_data.get("untag_image_as_golden_and_load_on_device_responce") + self.test_data.get( + "untag_image_as_golden_and_load_on_device_responce") ] elif "playbook_import_image_already_exist" in self._testMethodName: @@ -88,41 +101,57 @@ def load_fixtures(self, response=None, device=""): elif "playbook_site_not_exist" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("get_software_image_details_site_not_exist"), + self.test_data.get( + "get_software_image_details_site_not_exist"), Exception(), self.test_data.get("site_not_exist_response"), ] elif "playbook_swim_image_invalid" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("get_software_image_details_invalid_swim_image"), - self.test_data.get("import_software_image_via_url_invalid_swim_image"), + self.test_data.get( + "get_software_image_details_invalid_swim_image"), + self.test_data.get( + "import_software_image_via_url_invalid_swim_image"), self.test_data.get("Task_details_invalid_swim_image_end"), self.test_data.get("invalid_swim_image_response"), ] elif "playbook_image_distribution_failed" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("get_software_image_details_image_distribution_failed"), - self.test_data.get("get_device_list_image_distribution_failed"), + self.test_data.get( + "get_software_image_details_image_distribution_failed"), + self.test_data.get( + "get_device_list_image_distribution_failed"), self.test_data.get("get_site_image_distribution_failed"), self.test_data.get("get_membership_image_distribution_failed"), - self.test_data.get("trigger_software_image_distribution_image_distribution_failed"), - self.test_data.get("task_details_running_image_distribution_failed"), + self.test_data.get( + "trigger_software_image_distribution_image_distribution_failed"), + self.test_data.get( + "task_details_running_image_distribution_failed"), self.test_data.get("task_details_image_distribution_failed"), self.test_data.get("image_distribution_failed_response"), ] elif "playbook_swim_image_golden_tag" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("get_software_image_details_swim_image_golden_tag"), - self.test_data.get("get_device_family_identifiers_swim_image_golden_tag"), - self.test_data.get("get_software_image_details_swim_image_golden_tag_1"), - self.test_data.get("get_golden_tag_status_of_an_image_swim_image_golden_tag"), - self.test_data.get("tag_as_golden_image_swim_image_golden_tag"), + self.test_data.get( + "get_software_image_details_swim_image_golden_tag"), + self.test_data.get( + "get_device_family_identifiers_swim_image_golden_tag"), + self.test_data.get( + "get_software_image_details_swim_image_golden_tag_1"), + self.test_data.get( + "get_golden_tag_status_of_an_image_swim_image_golden_tag"), + self.test_data.get( + "tag_as_golden_image_swim_image_golden_tag"), self.test_data.get("TaskDetails_start"), self.test_data.get("TaskDetails_end"), - self.test_data.get("get_software_image_details_swim_image_golden_tag_2"), - self.test_data.get("get_device_family_identifiers_swim_image_golden_tag_1"), - self.test_data.get("get_software_image_details_swim_image_golden_tag_3"), - self.test_data.get("get_golden_tag_status_of_an_image_swim_image_golden_tag_1"), + self.test_data.get( + "get_software_image_details_swim_image_golden_tag_2"), + self.test_data.get( + "get_device_family_identifiers_swim_image_golden_tag_1"), + self.test_data.get( + "get_software_image_details_swim_image_golden_tag_3"), + self.test_data.get( + "get_golden_tag_status_of_an_image_swim_image_golden_tag_1"), self.test_data.get("import__swim_image_golden_tag_responce"), ] elif "playbook_swim_image_golden_already_tagged" in self._testMethodName: @@ -137,108 +166,165 @@ def load_fixtures(self, response=None, device=""): self.test_data.get("get_device_family_identifiers_2"), self.test_data.get("get_software_image_details_7"), self.test_data.get("get_golden_tag_status_of_an_image_2"), - self.test_data.get("swim_image_golden_already_tagged_responce"), + self.test_data.get( + "swim_image_golden_already_tagged_responce"), ] elif "playbook_swim_image_cant_found" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("get_software_image_details_swim_image_cant_found"), + self.test_data.get( + "get_software_image_details_swim_image_cant_found"), self.test_data.get("swim_image_cant_found_response"), ] elif "playbook_image_details_distribution_not_provided" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("get_site_image_details_distribution_not_provided"), - self.test_data.get("distribution_failed_for_all_devicesresponse"), + self.test_data.get( + "get_site_image_details_distribution_not_provided"), + self.test_data.get( + "distribution_failed_for_all_devicesresponse"), ] elif "playbook_device_family_not_found" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("get_software_image_details_device_family_not_found"), + self.test_data.get( + "get_software_image_details_device_family_not_found"), self.test_data.get("get_site_device_family_not_found"), - self.test_data.get("get_device_family_identifiers_device_family_not_found"), + self.test_data.get( + "get_device_family_identifiers_device_family_not_found"), self.test_data.get("device_family_not_found_response"), ] elif "playbook_import_image_remote_v2_3_7_6" in self._testMethodName: self.run_dnac_exec.side_effect = [ self.test_data.get("get_software_image_details_remote_import"), - self.test_data.get("import_software_image_via_url_remote_import"), + self.test_data.get( + "import_software_image_via_url_remote_import"), self.test_data.get("Task_Details_start"), self.test_data.get("Task_Details_end"), - self.test_data.get("get_software_image_details_remote_import_1"), - self.test_data.get("get_software_image_details_remote_import_2"), + self.test_data.get( + "get_software_image_details_remote_import_1"), + self.test_data.get( + "get_software_image_details_remote_import_2"), self.test_data.get("import_image_remote_responce"), ] elif "playbook_import_image_remote" in self._testMethodName: self.run_dnac_exec.side_effect = [ self.test_data.get("get_software_image_details_remote_import"), - self.test_data.get("import_software_image_via_url_remote_import"), + self.test_data.get( + "import_software_image_via_url_remote_import"), self.test_data.get("Task_Details_start"), self.test_data.get("Task_Details_end"), - self.test_data.get("get_software_image_details_remote_import_1"), - self.test_data.get("get_software_image_details_remote_import_2"), + self.test_data.get( + "get_software_image_details_remote_import_1"), + self.test_data.get( + "get_software_image_details_remote_import_2"), self.test_data.get("import_image_remote_responce"), ] elif "playbook_image_distribution_successfull" in self._testMethodName: self.run_dnac_exec.side_effect = [ self.test_data.get("get_site_image_distribution_successfull"), - self.test_data.get("get_software_image_details_image_distribution_successfull"), - self.test_data.get("get_device_list_image_distribution_successfull"), - self.test_data.get("get_site_image_distribution_successfull_1"), - self.test_data.get("get_membership_image_distribution_successfull"), - self.test_data.get("get_device_list_image_distribution_successfull_1"), - self.test_data.get("get_device_list_image_distribution_successfull_ep"), - self.test_data.get("get_device_list_image_distribution_successfull_1"), - self.test_data.get("trigger_software_image_distribution_image_distribution_successfull"), - self.test_data.get("Task_Details_image_distribution_successfull_start"), - self.test_data.get("Task_Details_image_distribution_successfull_end"), - self.test_data.get("get_site_image_distribution_successfull_2"), - self.test_data.get("get_software_image_details_image_distribution_successfull_1"), - self.test_data.get("get_device_list_image_distribution_successfull_2"), - self.test_data.get("get_software_image_details_image_distribution_successfull_2"), + self.test_data.get( + "get_software_image_details_image_distribution_successfull"), + self.test_data.get( + "get_device_list_image_distribution_successfull"), + self.test_data.get( + "get_site_image_distribution_successfull_1"), + self.test_data.get( + "get_membership_image_distribution_successfull"), + self.test_data.get( + "get_device_list_image_distribution_successfull_1"), + self.test_data.get( + "get_device_list_image_distribution_successfull_ep"), + self.test_data.get( + "get_device_list_image_distribution_successfull_1"), + self.test_data.get( + "trigger_software_image_distribution_image_distribution_successfull"), + self.test_data.get( + "Task_Details_image_distribution_successfull_start"), + self.test_data.get( + "Task_Details_image_distribution_successfull_end"), + self.test_data.get( + "get_site_image_distribution_successfull_2"), + self.test_data.get( + "get_software_image_details_image_distribution_successfull_1"), + self.test_data.get( + "get_device_list_image_distribution_successfull_2"), + self.test_data.get( + "get_software_image_details_image_distribution_successfull_2"), self.test_data.get("import_image_distribution_successfull"), ] elif "playbook_image_distribution_successfull_v2_3_7_6" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("get_sites_image_distribution_successfull_v2_3_7_6"), - self.test_data.get("get_sites_image_distribution_successfull_v2_3_7_6_1"), - self.test_data.get("get_software_image_details_image_distribution_successfull_v2_3_7_6"), - self.test_data.get("get_device_list_image_distribution_successfull_v2_3_7_6"), - self.test_data.get("get_sites_image_distribution_successfull_v2_3_7_6_2"), - self.test_data.get("get_sites_image_distribution_successfull_v2_3_7_6_3"), - self.test_data.get("get_site_assigned_network_devices_image_distribution_successfull_v2_3_7_6"), - self.test_data.get("device_list_response_image_distribution_successfull_v2_3_7_6_1"), - self.test_data.get("device_list_response_image_distribution_successfull_v2_3_7_6_2"), - self.test_data.get("device_list_response_image_distribution_successfull_v2_3_7_6_3"), - self.test_data.get("device_list_response_image_distribution_successfull_v2_3_7_6_4"), - self.test_data.get("get_device_list_image_distribution_successfull_v2_3_7_6_1"), - self.test_data.get("trigger_software_image_distribution_image_distribution_successfull_v2_3_7_6"), - self.test_data.get("TaskDetails_image_distribution_successfull_v2_3_7_6"), - self.test_data.get("TaskDetails_image_distribution_successfull_v2_3_7_6_1"), - self.test_data.get("get_sites_image_distribution_successfull_v2_3_7_6_4"), - self.test_data.get("get_sites_image_distribution_successfull_v2_3_7_6_5"), - self.test_data.get("get_software_image_details_image_distribution_successfull_v2_3_7_6_1"), - self.test_data.get("get_device_list_image_distribution_successfull_v2_3_7_6_2"), - self.test_data.get("get_software_image_details_image_distribution_successfull_v2_3_7_6_2"), - self.test_data.get("image_distribution_successfull_v2_3_7_6_responce"), + self.test_data.get( + "get_sites_image_distribution_successfull_v2_3_7_6"), + self.test_data.get( + "get_sites_image_distribution_successfull_v2_3_7_6_1"), + self.test_data.get( + "get_software_image_details_image_distribution_successfull_v2_3_7_6"), + self.test_data.get( + "get_device_list_image_distribution_successfull_v2_3_7_6"), + self.test_data.get( + "get_sites_image_distribution_successfull_v2_3_7_6_2"), + self.test_data.get( + "get_sites_image_distribution_successfull_v2_3_7_6_3"), + self.test_data.get( + "get_site_assigned_network_devices_image_distribution_successfull_v2_3_7_6"), + self.test_data.get( + "device_list_response_image_distribution_successfull_v2_3_7_6_1"), + self.test_data.get( + "device_list_response_image_distribution_successfull_v2_3_7_6_2"), + self.test_data.get( + "device_list_response_image_distribution_successfull_v2_3_7_6_3"), + self.test_data.get( + "device_list_response_image_distribution_successfull_v2_3_7_6_4"), + self.test_data.get( + "get_device_list_image_distribution_successfull_v2_3_7_6_1"), + self.test_data.get( + "trigger_software_image_distribution_image_distribution_successfull_v2_3_7_6"), + self.test_data.get( + "TaskDetails_image_distribution_successfull_v2_3_7_6"), + self.test_data.get( + "TaskDetails_image_distribution_successfull_v2_3_7_6_1"), + self.test_data.get( + "get_sites_image_distribution_successfull_v2_3_7_6_4"), + self.test_data.get( + "get_sites_image_distribution_successfull_v2_3_7_6_5"), + self.test_data.get( + "get_software_image_details_image_distribution_successfull_v2_3_7_6_1"), + self.test_data.get( + "get_device_list_image_distribution_successfull_v2_3_7_6_2"), + self.test_data.get( + "get_software_image_details_image_distribution_successfull_v2_3_7_6_2"), + self.test_data.get( + "image_distribution_successfull_v2_3_7_6_responce"), ] elif "playbook_inheritted_tag_cannot_be_untagged" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("get_software_image_details_playbook_inheritted_tag_cannot_be_untagged"), - self.test_data.get("get_site_playbook_inheritted_tag_cannot_be_untagged"), - self.test_data.get("get_device_family_identifiers_playbook_inheritted_tag_cannot_be_untagged"), - self.test_data.get("get_software_image_details_playbook_inheritted_tag_cannot_be_untagged_1"), - self.test_data.get("get_golden_tag_status_of_an_image_playbook_inheritted_tag_cannot_be_untagged"), - self.test_data.get("remove_golden_tag_for_image_playbook_inheritted_tag_cannot_be_untagged"), + self.test_data.get( + "get_software_image_details_playbook_inheritted_tag_cannot_be_untagged"), + self.test_data.get( + "get_site_playbook_inheritted_tag_cannot_be_untagged"), + self.test_data.get( + "get_device_family_identifiers_playbook_inheritted_tag_cannot_be_untagged"), + self.test_data.get( + "get_software_image_details_playbook_inheritted_tag_cannot_be_untagged_1"), + self.test_data.get( + "get_golden_tag_status_of_an_image_playbook_inheritted_tag_cannot_be_untagged"), + self.test_data.get( + "remove_golden_tag_for_image_playbook_inheritted_tag_cannot_be_untagged"), self.test_data.get("TaskDetails_end_1"), - self.test_data.get("inheritted_tag_cannot_be_untagged_responce"), + self.test_data.get( + "inheritted_tag_cannot_be_untagged_responce"), ] elif "playbook_import_cco_image" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("get_software_image_details_import_cco_image"), + self.test_data.get( + "get_software_image_details_import_cco_image"), self.test_data.get("returns_list_of_software_images"), self.test_data.get("download_the_software_image"), self.test_data.get("TaskDetails"), - self.test_data.get("get_software_image_details_import_cco_image_1"), - self.test_data.get("get_software_image_details_import_cco_image_2"), + self.test_data.get( + "get_software_image_details_import_cco_image_1"), + self.test_data.get( + "get_software_image_details_import_cco_image_2"), self.test_data.get("import_cco_imageresponce"), ] elif "playbook_activate_image" in self._testMethodName: @@ -251,13 +337,16 @@ def load_fixtures(self, response=None, device=""): self.test_data.get("device_list_response_activate_image"), self.test_data.get("device_list_response_activate_image_1"), self.test_data.get("get_device_list_activate_image_1"), - self.test_data.get("trigger_software_image_activation_activate_image"), + self.test_data.get( + "trigger_software_image_activation_activate_image"), self.test_data.get("TaskDetails_activate_image"), self.test_data.get("TaskDetails_activate_image_1"), - self.test_data.get("get_software_image_details_activate_image"), + self.test_data.get( + "get_software_image_details_activate_image"), self.test_data.get("get_site_activate_image_3"), self.test_data.get("get_device_list_activate_image_2"), - self.test_data.get("get_software_image_details_activate_image_1"), + self.test_data.get( + "get_software_image_details_activate_image_1"), self.test_data.get("activate_image_responce"), ] diff --git a/tests/unit/modules/dnac/test_template_intent.py b/tests/unit/modules/dnac/test_template_intent.py index 512d31a82d..4dbfff2917 100644 --- a/tests/unit/modules/dnac/test_template_intent.py +++ b/tests/unit/modules/dnac/test_template_intent.py @@ -31,7 +31,6 @@ def __init__(self): super().__init__(module) def load_fixtures(self, response=None, device=""): - """ Load fixtures for a specific device. @@ -46,8 +45,10 @@ def load_fixtures(self, response=None, device=""): self.test_data.get("create_template_get_project_response"), self.test_data.get("create_template_response"), self.test_data.get("create_template_task_details_for_create"), - self.test_data.get("create_template_version_template_response"), - self.test_data.get("create_template_task_details_for_versioning") + self.test_data.get( + "create_template_version_template_response"), + self.test_data.get( + "create_template_task_details_for_versioning") ] elif "update_not_needed" in self._testMethodName: self.run_dnac_exec.side_effect = [ @@ -57,10 +58,13 @@ def load_fixtures(self, response=None, device=""): elif "update_needed" in self._testMethodName: self.run_dnac_exec.side_effect = [ self.test_data.get("update_template_list"), - self.test_data.get("update_template_existing_template_needs_update"), + self.test_data.get( + "update_template_existing_template_needs_update"), self.test_data.get("update_template_response"), - self.test_data.get("update_template_version_template_response"), - self.test_data.get("update_template_task_details_for_versioning") + self.test_data.get( + "update_template_version_template_response"), + self.test_data.get( + "update_template_task_details_for_versioning") ] elif "project_not_found" in self._testMethodName: self.run_dnac_exec.side_effect = [ @@ -73,13 +77,13 @@ def load_fixtures(self, response=None, device=""): elif "delete_template" in self._testMethodName: self.run_dnac_exec.side_effect = [ self.test_data.get("update_template_list"), - self.test_data.get("update_template_existing_template_needs_update"), + self.test_data.get( + "update_template_existing_template_needs_update"), self.test_data.get("delete_template_response"), self.test_data.get("delete_template_task_details"), ] def test_template_intent_create_template(self): - """ Test case for template intent when creating a template. @@ -103,7 +107,6 @@ def test_template_intent_create_template(self): ) def test_template_intent_update_not_needed(self): - """ Test case for template intent when no update is needed. @@ -127,7 +130,6 @@ def test_template_intent_update_not_needed(self): ) def test_template_intent_update_needed(self): - """ Test case for template intent when an update is needed. @@ -151,7 +153,6 @@ def test_template_intent_update_needed(self): ) def test_template_intent_project_not_found(self): - """ Test case for template intent when the project is not found. @@ -175,7 +176,6 @@ def test_template_intent_project_not_found(self): ) def test_template_intent_delete_non_existing_template(self): - """ Test case for template intent when trying to delete a non-existing template. @@ -199,7 +199,6 @@ def test_template_intent_delete_non_existing_template(self): ) def test_template_intent_delete_template(self): - """ Test case for template intent when deleting a template. @@ -223,7 +222,6 @@ def test_template_intent_delete_template(self): ) def test_template_intent_missing_param(self): - """ Test case for template intent with missing parameters in the playbook. @@ -247,7 +245,6 @@ def test_template_intent_missing_param(self): ) def test_template_intent_invalid_state(self): - """ Test case for template intent with an invalid 'state' parameter. @@ -271,7 +268,6 @@ def test_template_intent_invalid_state(self): ) def test_template_intent_invalid_param(self): - """ Test case for template intent with invalid parameters in the playbook. diff --git a/tests/unit/modules/dnac/test_user_role_workflow_manager.py b/tests/unit/modules/dnac/test_user_role_workflow_manager.py index 82dcd48e33..df06cdf896 100644 --- a/tests/unit/modules/dnac/test_user_role_workflow_manager.py +++ b/tests/unit/modules/dnac/test_user_role_workflow_manager.py @@ -31,26 +31,44 @@ class TestDnacUserRoleWorkflowManager(TestDnacModule): test_data = loadPlaybookData("user_role_workflow_manager") playbook_config_user = test_data.get("playbook_config_user") - playbook_config_delete_existing_user = test_data.get("playbook_config_delete_existing_user") - playbook_config_invalid_param_mandatory_field_not_present = test_data.get("playbook_config_invalid_param_mandatory_field_not_present") - playbook_config_invalid_param_username_email_not_present = test_data.get("playbook_config_invalid_param_username_email_not_present") - playbook_config_invalid_param_username_not_correct_formate = test_data.get("playbook_config_invalid_param_username_not_correct_formate") - playbook_config_invalid_param_user_rolelist_not_type_list = test_data.get("playbook_config_invalid_param_user_rolelist_not_type_list") - playbook_config_invalid_param_firstname_not_correct_formate = test_data.get("playbook_config_invalid_param_firstname_not_correct_formate") - playbook_config_invalid_param_lastname_not_correct_formate = test_data.get("playbook_config_invalid_param_lastname_not_correct_formate") - playbook_config_invalid_param_email_not_correct_formate = test_data.get("playbook_config_invalid_param_email_not_correct_formate") - playbook_config_invalid_param_password_not_correct_formate = test_data.get("playbook_config_invalid_param_password_not_correct_formate") - playbook_config_user_invalid_param_rolelist_not_found = test_data.get("playbook_config_user_invalid_param_rolelist_not_found") + playbook_config_delete_existing_user = test_data.get( + "playbook_config_delete_existing_user") + playbook_config_invalid_param_mandatory_field_not_present = test_data.get( + "playbook_config_invalid_param_mandatory_field_not_present") + playbook_config_invalid_param_username_email_not_present = test_data.get( + "playbook_config_invalid_param_username_email_not_present") + playbook_config_invalid_param_username_not_correct_formate = test_data.get( + "playbook_config_invalid_param_username_not_correct_formate") + playbook_config_invalid_param_user_rolelist_not_type_list = test_data.get( + "playbook_config_invalid_param_user_rolelist_not_type_list") + playbook_config_invalid_param_firstname_not_correct_formate = test_data.get( + "playbook_config_invalid_param_firstname_not_correct_formate") + playbook_config_invalid_param_lastname_not_correct_formate = test_data.get( + "playbook_config_invalid_param_lastname_not_correct_formate") + playbook_config_invalid_param_email_not_correct_formate = test_data.get( + "playbook_config_invalid_param_email_not_correct_formate") + playbook_config_invalid_param_password_not_correct_formate = test_data.get( + "playbook_config_invalid_param_password_not_correct_formate") + playbook_config_user_invalid_param_rolelist_not_found = test_data.get( + "playbook_config_user_invalid_param_rolelist_not_found") playbook_config_role = test_data.get("playbook_config_role") playbook_config_1_role = test_data.get("playbook_config_1_role") - playbook_config_invalid_param_rolename_not_present = test_data.get("playbook_config_invalid_param_rolename_not_present") - playbook_config_invalid_param_role_not_type_list = test_data.get("playbook_config_invalid_param_role_not_type_list") - playbook_config_invalid_param_with_all_permision_deny = test_data.get("playbook_config_invalid_param_with_all_permision_deny") - playbook_config_invalid_param_rolename_not_correct_formate = test_data.get("playbook_config_invalid_param_rolename_not_correct_formate") - playbook_config_invalid_param_type_list_missing = test_data.get("playbook_config_invalid_param_type_list_missing") - playbook_config_invalid_param_role_invalid_permission = test_data.get("playbook_config_invalid_param_role_invalid_permission") - playbook_config_for_creating_default_role = test_data.get("playbook_config_for_creating_default_role") - playbook_config_invalid_invalid_param_state = test_data.get("playbook_config_invalid_invalid_param_state") + playbook_config_invalid_param_rolename_not_present = test_data.get( + "playbook_config_invalid_param_rolename_not_present") + playbook_config_invalid_param_role_not_type_list = test_data.get( + "playbook_config_invalid_param_role_not_type_list") + playbook_config_invalid_param_with_all_permision_deny = test_data.get( + "playbook_config_invalid_param_with_all_permision_deny") + playbook_config_invalid_param_rolename_not_correct_formate = test_data.get( + "playbook_config_invalid_param_rolename_not_correct_formate") + playbook_config_invalid_param_type_list_missing = test_data.get( + "playbook_config_invalid_param_type_list_missing") + playbook_config_invalid_param_role_invalid_permission = test_data.get( + "playbook_config_invalid_param_role_invalid_permission") + playbook_config_for_creating_default_role = test_data.get( + "playbook_config_for_creating_default_role") + playbook_config_invalid_invalid_param_state = test_data.get( + "playbook_config_invalid_invalid_param_state") def setUp(self): super(TestDnacUserRoleWorkflowManager, self).setUp() @@ -100,25 +118,33 @@ def load_fixtures(self, response=None, device=""): elif "delete_non_existing_user" in self._testMethodName: self.run_dnac_exec.side_effect = [ self.test_data.get("delete_non_existing_get_user_response"), - self.test_data.get("delete_non_existing_user_get_role_response"), + self.test_data.get( + "delete_non_existing_user_get_role_response"), self.test_data.get("delete_non_existing_user_response") ] elif "user_invalid_mandatory_field_not_present_param" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("invalid_param_mandatory_field_not_present_get_user_response"), - self.test_data.get("invalid_param_mandatory_field_not_present_get_role_response"), + self.test_data.get( + "invalid_param_mandatory_field_not_present_get_user_response"), + self.test_data.get( + "invalid_param_mandatory_field_not_present_get_role_response"), Exception(), - self.test_data.get("user_invalid_mandatory_field_not_present_param_responce") + self.test_data.get( + "user_invalid_mandatory_field_not_present_param_responce") ] elif "user_invalid_username_email_not_present_param" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("user_invalid_username_email_not_present_param_responce") + self.test_data.get( + "user_invalid_username_email_not_present_param_responce") ] elif "user_invalid_param_not_correct_formate" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("invalid_param_not_correct_formate_get_user_response"), - self.test_data.get("invalid_param_not_correct_formate_get_role_response"), - self.test_data.get("user_invalid_param_not_correct_formate_responce") + self.test_data.get( + "invalid_param_not_correct_formate_get_user_response"), + self.test_data.get( + "invalid_param_not_correct_formate_get_role_response"), + self.test_data.get( + "user_invalid_param_not_correct_formate_responce") ] elif "user_invalid_param_not_type_list" in self._testMethodName: self.run_dnac_exec.side_effect = [ @@ -126,15 +152,21 @@ def load_fixtures(self, response=None, device=""): ] elif "user_invalid_param_rolelist_not_found" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("invalid_param_rolelist_not_found_get_user_response"), - self.test_data.get("invalid_param_rolelist_not_found_get_role_response"), - self.test_data.get("user_invalid_param_rolelist_not_found_responce") + self.test_data.get( + "invalid_param_rolelist_not_found_get_user_response"), + self.test_data.get( + "invalid_param_rolelist_not_found_get_role_response"), + self.test_data.get( + "user_invalid_param_rolelist_not_found_responce") ] elif "user_invalid_param_update_rolelist_not_found" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("invalid_param_update_rolelist_not_found_get_user_response"), - self.test_data.get("invalid_param_rolelist_not_found_get_role_response"), - self.test_data.get("user_invalid_param_update_rolelist_not_found_responce") + self.test_data.get( + "invalid_param_update_rolelist_not_found_get_user_response"), + self.test_data.get( + "invalid_param_rolelist_not_found_get_role_response"), + self.test_data.get( + "user_invalid_param_update_rolelist_not_found_responce") ] elif "create_role" in self._testMethodName: self.run_dnac_exec.side_effect = [ @@ -168,7 +200,8 @@ def load_fixtures(self, response=None, device=""): ] elif "role_invalid_param_rolename_not_present" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("role_invalid_rolename_not_present_param_response") + self.test_data.get( + "role_invalid_rolename_not_present_param_response") ] elif "role_invalid_param_not_type_list" in self._testMethodName: self.run_dnac_exec.side_effect = [ @@ -176,14 +209,18 @@ def load_fixtures(self, response=None, device=""): ] elif "role_param_with_all_permision_deny" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("role_param_with_all_permision_deny_get_role_responce"), + self.test_data.get( + "role_param_with_all_permision_deny_get_role_responce"), Exception(), - self.test_data.get("role_param_with_all_permision_deny_responce") + self.test_data.get( + "role_param_with_all_permision_deny_responce") ] elif "role_invalid_param_rolename_not_correct_formate" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("invalid_param_rolename_not_correct_formate_get_role_responce"), - self.test_data.get("role_invalid_param_rolename_not_correct_formate_responce") + self.test_data.get( + "invalid_param_rolename_not_correct_formate_get_role_responce"), + self.test_data.get( + "role_invalid_param_rolename_not_correct_formate_responce") ] elif "invalid_param_type_list_missing" in self._testMethodName: self.run_dnac_exec.side_effect = [ @@ -191,13 +228,17 @@ def load_fixtures(self, response=None, device=""): ] elif "invalid_param_role_invalid_permission" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("invalid_param_invalid_permission_role_get_response"), - self.test_data.get("invalid_param_role_invalid_permission_response") + self.test_data.get( + "invalid_param_invalid_permission_role_get_response"), + self.test_data.get( + "invalid_param_role_invalid_permission_response") ] elif "invalid_param_role_update_invalid_permission" in self._testMethodName: self.run_dnac_exec.side_effect = [ - self.test_data.get("invalid_param_invalid_permission_update_role_get_response"), - self.test_data.get("invalid_param_role_update_invalid_permission_response") + self.test_data.get( + "invalid_param_invalid_permission_update_role_get_response"), + self.test_data.get( + "invalid_param_role_update_invalid_permission_response") ] elif "create_default_role" in self._testMethodName: self.run_dnac_exec.side_effect = [ @@ -228,7 +269,8 @@ def test_user_role_workflow_manager_create_user(self): result = self.execute_module(changed=True, failed=False) print(result) self.assertEqual( - result.get('response').get("operation").get("response").get("message"), + result.get('response').get("operation").get( + "response").get("message"), "User created successfully" ) @@ -251,7 +293,8 @@ def test_user_role_workflow_manager_user_update_needed(self): result = self.execute_module(changed=True, failed=False) print(result) self.assertEqual( - result.get('response').get("operation").get("response").get("message"), + result.get('response').get("operation").get( + "response").get("message"), "User updated successfully" ) @@ -297,7 +340,8 @@ def test_user_role_workflow_manager_delete_existing_user(self): result = self.execute_module(changed=True, failed=False) print(result) self.assertEqual( - result.get('response').get("users_operation").get("response").get("message"), + result.get('response').get("users_operation").get( + "response").get("message"), "Deleted user successfully" ) @@ -487,7 +531,8 @@ def test_user_role_workflow_manager_create_role(self): result = self.execute_module(changed=True, failed=False) print(result) self.assertEqual( - result.get('response').get("operation").get("response").get("message"), + result.get('response').get("operation").get( + "response").get("message"), "Role created successfully" ) @@ -510,7 +555,8 @@ def test_user_role_workflow_manager_create_1_role(self): result = self.execute_module(changed=True, failed=False) print(result) self.assertEqual( - result.get('response').get("operation").get("response").get("message"), + result.get('response').get("operation").get( + "response").get("message"), "Role created successfully" ) @@ -533,7 +579,8 @@ def test_user_role_workflow_manager_role_update_needed(self): result = self.execute_module(changed=True, failed=False) print(result) self.assertEqual( - result.get('response').get("operation").get("response").get("message"), + result.get('response').get("operation").get( + "response").get("message"), "Role Updated successfully" ) @@ -579,7 +626,8 @@ def test_user_role_workflow_manager_delete_existing_role(self): result = self.execute_module(changed=True, failed=False) print(result) self.assertEqual( - result.get('response').get("role_operation").get("response").get("message"), + result.get('response').get("role_operation").get( + "response").get("message"), "Role deleted successfully" ) @@ -787,7 +835,8 @@ def test_user_role_workflow_manager_create_default_role(self): result = self.execute_module(changed=True, failed=False) print(f"result --> {result}") self.assertEqual( - result.get('response').get("operation").get("response").get("message"), + result.get('response').get("operation").get( + "response").get("message"), "Role created successfully" )