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 ea2f91a656..f4d72f2041 100644 --- a/plugins/action/accesspoint_configuration_details_by_task_id_info.py +++ b/plugins/action/accesspoint_configuration_details_by_task_id_info.py @@ -15,4 +15,4 @@ def __init__(self, *args, **kwargs): def run(self, tmp=None, task_vars=None): module = ActionModule(self._task.args, self._play_context, self._task) return module.run(tmp, task_vars) - + \ No newline at end of file diff --git a/plugins/action/application_policy_application_set_v2.py b/plugins/action/application_policy_application_set_v2.py index 9faeb2206f..b6c55cb4b3 100644 --- a/plugins/action/application_policy_application_set_v2.py +++ b/plugins/action/application_policy_application_set_v2.py @@ -3,7 +3,6 @@ # 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 diff --git a/plugins/action/business_sda_hostonboarding_ssid_ippool_v1.py b/plugins/action/business_sda_hostonboarding_ssid_ippool_v1.py index 1477a147e1..5af26bcdd6 100644 --- a/plugins/action/business_sda_hostonboarding_ssid_ippool_v1.py +++ b/plugins/action/business_sda_hostonboarding_ssid_ippool_v1.py @@ -22,9 +22,6 @@ dnac_compare_equality, get_dict_result, ) -from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, -) # Get common arguments specification argument_spec = dnac_argument_spec() diff --git a/plugins/action/compliance_device.py b/plugins/action/compliance_device.py deleted file mode 100644 index 687e32bec9..0000000000 --- a/plugins/action/compliance_device.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python -# -- coding: utf-8 -- -from ansible.plugins.action import ActionBase -from ansible_collections.cisco.dnac.plugins.action.compliance_device_v1 import ActionModule - - -class ActionModule2(ActionBase): - - def __init__(self, *args, **kwargs): - super(ActionModule2, self).__init__(*args, **kwargs) - self._supports_async = False - self._supports_check_mode = True - self._result = None - - def run(self, tmp=None, task_vars=None): - module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) diff --git a/plugins/action/compliance_device_v1.py b/plugins/action/compliance_device_v1.py deleted file mode 100644 index 281d9dfa57..0000000000 --- a/plugins/action/compliance_device_v1.py +++ /dev/null @@ -1,174 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# 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 -try: - from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import ( - AnsibleArgSpecValidator, - ) -except ImportError: - ANSIBLE_UTILS_IS_INSTALLED = False -else: - ANSIBLE_UTILS_IS_INSTALLED = True -from ansible.errors import AnsibleActionFail -from ansible_collections.cisco.dnac.plugins.plugin_utils.dnac import ( - DNACSDK, - dnac_argument_spec, - dnac_compare_equality, - get_dict_result, -) -from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, -) - -# Get common arguments specification -argument_spec = dnac_argument_spec() -# Add arguments specific for this module -argument_spec.update(dict( - state=dict(type="str", default="present", choices=["present"]), -)) - -required_if = [ - ("state", "present", ["deviceUuid"], True), -] -required_one_of = [] -mutually_exclusive = [] -required_together = [] - - -class ComplianceDeviceV1(object): - def __init__(self, params, dnac): - self.dnac = dnac - self.new_object = dict( - ) - - def get_all_params(self, name=None, id=None): - new_object_params = {} - new_object_params['compliance_status'] = self.new_object.get('complianceStatus') or \ - self.new_object.get('compliance_status') - new_object_params['device_uuid'] = self.new_object.get('deviceUuid') or \ - self.new_object.get('device_uuid') - return new_object_params - - def get_object_by_name(self, name): - result = None - # NOTE: Does not have a get by name method, using get all - try: - items = self.dnac.exec( - family="compliance", - function="get_compliance_status_v1", - params=self.get_all_params(name=name), - ) - if isinstance(items, dict): - if 'response' in items: - items = items.get('response') - result = get_dict_result(items, 'name', name) - except Exception: - result = None - return result - - def get_object_by_id(self, id): - result = None - try: - items = self.dnac.exec( - family="compliance", - function="device_compliance_status_v1", - params={"device_uuid": id} - ) - if isinstance(items, dict): - if 'response' in items: - items = items.get('response') - result = get_dict_result(items, 'device_uuid', id) - except Exception: - result = None - return result - - def exists(self): - prev_obj = None - id_exists = False - name_exists = False - o_id = self.new_object.get("id") - o_id = o_id or self.new_object.get("device_uuid") - name = self.new_object.get("name") - if o_id: - prev_obj = self.get_object_by_id(o_id) - id_exists = prev_obj is not None and isinstance(prev_obj, dict) - if not id_exists and name: - prev_obj = self.get_object_by_name(name) - name_exists = prev_obj is not None and isinstance(prev_obj, dict) - if name_exists: - _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") - if _id: - self.new_object.update(dict(id=_id)) - self.new_object.update(dict(device_uuid=_id)) - if _id: - prev_obj = self.get_object_by_id(_id) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) - return (it_exists, prev_obj) - - def requires_update(self, current_obj): - requested_obj = self.new_object - - obj_params = [ - ] - # 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 - return any(not dnac_compare_equality(current_obj.get(dnac_param), - requested_obj.get(ansible_param)) - for (dnac_param, ansible_param) in obj_params) - - -class ActionModule(ActionBase): - def __init__(self, *args, **kwargs): - if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail( - "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") - super(ActionModule, self).__init__(*args, **kwargs) - self._supports_async = False - self._supports_check_mode = False - self._result = None - - # Checks the supplied parameters against the argument spec for this module - def _check_argspec(self): - aav = AnsibleArgSpecValidator( - data=self._task.args, - schema=dict(argument_spec=argument_spec), - schema_format="argspec", - schema_conditionals=dict( - required_if=required_if, - required_one_of=required_one_of, - mutually_exclusive=mutually_exclusive, - required_together=required_together, - ), - name=self._task.action, - ) - valid, errors, self._task.args = aav.validate() - if not valid: - raise AnsibleActionFail(errors) - - def run(self, tmp=None, task_vars=None): - self._task.diff = False - self._result = super(ActionModule, self).run(tmp, task_vars) - self._result["changed"] = False - self._check_argspec() - - dnac = DNACSDK(self._task.args) - obj = ComplianceDeviceV1(self._task.args, dnac) - - state = self._task.args.get("state") - - response = None - if state == "present": - - self._result.update(dict(dnac_response=response)) - self._result.update(dnac.exit_json()) - return self._result diff --git a/plugins/action/event_snmp_config_v1.py b/plugins/action/event_snmp_config_v1.py index 2c2c9900b7..acb79571a4 100644 --- a/plugins/action/event_snmp_config_v1.py +++ b/plugins/action/event_snmp_config_v1.py @@ -20,7 +20,6 @@ DNACSDK, dnac_argument_spec, dnac_compare_equality, - get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( InconsistentParameters, diff --git a/plugins/action/images_site_wise_product_names_v1.py b/plugins/action/images_site_wise_product_names_v1.py index 753ab8df54..702851d974 100644 --- a/plugins/action/images_site_wise_product_names_v1.py +++ b/plugins/action/images_site_wise_product_names_v1.py @@ -143,7 +143,6 @@ def exists(self): _name = prev_obj.get("name") _name = _name or prev_obj.get("productNameOrdinal") if _name: - _payload_first.update(dict(productNameOrdinal=_name)) self.new_object.update(dict(product_name_ordinal=_name)) if name_exists: _id = prev_obj.get("id") 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 4174944092..5268904b99 100644 --- a/plugins/action/network_devices_network_profiles_for_sites_v1.py +++ b/plugins/action/network_devices_network_profiles_for_sites_v1.py @@ -194,6 +194,17 @@ def run(self, tmp=None, task_vars=None): response = None if state == "present": + (obj_exists, prev_obj) = obj.exists() + if obj_exists: + if obj.requires_update(prev_obj): + response = prev_obj + dnac.object_present_and_different() + else: + response = prev_obj + dnac.object_already_present() + else: + dnac.fail_json( + "Object does not exists") elif state == "absent": (obj_exists, prev_obj) = obj.exists() if obj_exists: diff --git a/plugins/action/sda_anycast_gateways_v1.py b/plugins/action/sda_anycast_gateways_v1.py index 811dbf0540..65c42a2a3e 100644 --- a/plugins/action/sda_anycast_gateways_v1.py +++ b/plugins/action/sda_anycast_gateways_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_authentication_profiles_v1.py b/plugins/action/sda_authentication_profiles_v1.py index 75075d3c28..0e72b052d9 100644 --- a/plugins/action/sda_authentication_profiles_v1.py +++ b/plugins/action/sda_authentication_profiles_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_extranet_policies_v1.py b/plugins/action/sda_extranet_policies_v1.py index ef5803e1ef..50c3da2f9f 100644 --- a/plugins/action/sda_extranet_policies_v1.py +++ b/plugins/action/sda_extranet_policies_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_fabric_authentication_profile_v1.py b/plugins/action/sda_fabric_authentication_profile_v1.py index afb37fd6f4..a429656279 100644 --- a/plugins/action/sda_fabric_authentication_profile_v1.py +++ b/plugins/action/sda_fabric_authentication_profile_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_fabric_border_device_v1.py b/plugins/action/sda_fabric_border_device_v1.py index e6461f6ed8..26eb9dfdff 100644 --- a/plugins/action/sda_fabric_border_device_v1.py +++ b/plugins/action/sda_fabric_border_device_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_fabric_control_plane_device_v1.py b/plugins/action/sda_fabric_control_plane_device_v1.py index 967825f5d1..36ccabe527 100644 --- a/plugins/action/sda_fabric_control_plane_device_v1.py +++ b/plugins/action/sda_fabric_control_plane_device_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) 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 c43d4aca78..dff7e1f163 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 @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) 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 b029285dcc..3007357014 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 @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_fabric_devices_layer2_handoffs_v1.py b/plugins/action/sda_fabric_devices_layer2_handoffs_v1.py index 638f588a6d..6f6c6c1991 100644 --- a/plugins/action/sda_fabric_devices_layer2_handoffs_v1.py +++ b/plugins/action/sda_fabric_devices_layer2_handoffs_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_fabric_devices_v1.py b/plugins/action/sda_fabric_devices_v1.py index f44cee7842..a9f67dafb6 100644 --- a/plugins/action/sda_fabric_devices_v1.py +++ b/plugins/action/sda_fabric_devices_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_fabric_edge_device_v1.py b/plugins/action/sda_fabric_edge_device_v1.py index 38470e9897..f40a8884bd 100644 --- a/plugins/action/sda_fabric_edge_device_v1.py +++ b/plugins/action/sda_fabric_edge_device_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_fabric_site_v1.py b/plugins/action/sda_fabric_site_v1.py index 8f751154ad..63edaa8842 100644 --- a/plugins/action/sda_fabric_site_v1.py +++ b/plugins/action/sda_fabric_site_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_fabric_sites_v1.py b/plugins/action/sda_fabric_sites_v1.py index 5bc5f5da57..5b248c42f7 100644 --- a/plugins/action/sda_fabric_sites_v1.py +++ b/plugins/action/sda_fabric_sites_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_fabric_zones_v1.py b/plugins/action/sda_fabric_zones_v1.py index 4c4dd45c54..99835923ef 100644 --- a/plugins/action/sda_fabric_zones_v1.py +++ b/plugins/action/sda_fabric_zones_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) 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 c35b11c4e2..3af692f717 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 @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_layer2_virtual_networks_v1.py b/plugins/action/sda_layer2_virtual_networks_v1.py index 4dca7aa266..b70861e7c1 100644 --- a/plugins/action/sda_layer2_virtual_networks_v1.py +++ b/plugins/action/sda_layer2_virtual_networks_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_layer3_virtual_networks_v1.py b/plugins/action/sda_layer3_virtual_networks_v1.py index b300c9dd96..60b7a660db 100644 --- a/plugins/action/sda_layer3_virtual_networks_v1.py +++ b/plugins/action/sda_layer3_virtual_networks_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_multicast_v1.py b/plugins/action/sda_multicast_v1.py index 89251a8c71..1c4dafe1cb 100644 --- a/plugins/action/sda_multicast_v1.py +++ b/plugins/action/sda_multicast_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_multicast_virtual_networks_v1.py b/plugins/action/sda_multicast_virtual_networks_v1.py index cd589ee660..1a7bc6b83f 100644 --- a/plugins/action/sda_multicast_virtual_networks_v1.py +++ b/plugins/action/sda_multicast_virtual_networks_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) 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 1013ed2880..2cd292f4f0 100644 --- a/plugins/action/sda_port_assignment_for_access_point_v1.py +++ b/plugins/action/sda_port_assignment_for_access_point_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) 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 ee97dab364..25c21debde 100644 --- a/plugins/action/sda_port_assignment_for_user_device_v1.py +++ b/plugins/action/sda_port_assignment_for_user_device_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_port_assignments_v1.py b/plugins/action/sda_port_assignments_v1.py index d85faf11ba..cd31bdad1c 100644 --- a/plugins/action/sda_port_assignments_v1.py +++ b/plugins/action/sda_port_assignments_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_port_channels_v1.py b/plugins/action/sda_port_channels_v1.py index ed0a1f1b70..d73a771e14 100644 --- a/plugins/action/sda_port_channels_v1.py +++ b/plugins/action/sda_port_channels_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_provision_device_v1.py b/plugins/action/sda_provision_device_v1.py index cb4b0204ff..9c11116e37 100644 --- a/plugins/action/sda_provision_device_v1.py +++ b/plugins/action/sda_provision_device_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_provision_devices_v1.py b/plugins/action/sda_provision_devices_v1.py index 1b17b9b4e5..d8a9ba23a1 100644 --- a/plugins/action/sda_provision_devices_v1.py +++ b/plugins/action/sda_provision_devices_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_transit_networks_v1.py b/plugins/action/sda_transit_networks_v1.py index e5aed58b16..8801d25dc0 100644 --- a/plugins/action/sda_transit_networks_v1.py +++ b/plugins/action/sda_transit_networks_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_virtual_network_ip_pool_v1.py b/plugins/action/sda_virtual_network_ip_pool_v1.py index 2265a484c1..223d7982e1 100644 --- a/plugins/action/sda_virtual_network_ip_pool_v1.py +++ b/plugins/action/sda_virtual_network_ip_pool_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_virtual_network_v1.py b/plugins/action/sda_virtual_network_v1.py index 319b8f5451..cbaead576c 100644 --- a/plugins/action/sda_virtual_network_v1.py +++ b/plugins/action/sda_virtual_network_v1.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/sda_virtual_network_v2.py b/plugins/action/sda_virtual_network_v2.py index 6b96ec1d2f..aba5845c52 100644 --- a/plugins/action/sda_virtual_network_v2.py +++ b/plugins/action/sda_virtual_network_v2.py @@ -23,7 +23,6 @@ get_dict_result, ) from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, AnsibleSDAException, ) diff --git a/plugins/action/system_issue_definitions.py b/plugins/action/system_issue_definitions.py deleted file mode 100644 index 39516127bb..0000000000 --- a/plugins/action/system_issue_definitions.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python -# -- coding: utf-8 -- -from ansible.plugins.action import ActionBase -from ansible_collections.cisco.dnac.plugins.action.system_issue_definitions_v1 import ActionModule - - -class ActionModule2(ActionBase): - - def __init__(self, *args, **kwargs): - super(ActionModule2, self).__init__(*args, **kwargs) - self._supports_async = False - self._supports_check_mode = True - self._result = None - - def run(self, tmp=None, task_vars=None): - module = ActionModule(self._task.args, self._play_context, self._task) - return module.run(tmp, task_vars) diff --git a/plugins/action/system_issue_definitions_count.py b/plugins/action/system_issue_definitions_count.py deleted file mode 100644 index b1dca2bd74..0000000000 --- a/plugins/action/system_issue_definitions_count.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python -# -- coding: utf-8 -- -from ansible.plugins.action import ActionBase -from ansible_collections.cisco.dnac.plugins.action.system_issue_definitions_count_v1 import ActionModule - - -class ActionModule2(ActionBase): - - def __init__(self, *args, **kwargs): - super(ActionModule2, self).__init__(*args, **kwargs) - self._supports_async = False - self._supports_check_mode = True - self._result = None - - def run(self, tmp=None, task_vars=None): - module = ActionModule(self._task.args, self._play_context, self._task) - 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 deleted file mode 100644 index dd2ed107bf..0000000000 --- a/plugins/action/system_issue_definitions_count_v1.py +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# 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 -try: - from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import ( - AnsibleArgSpecValidator, - ) -except ImportError: - ANSIBLE_UTILS_IS_INSTALLED = False -else: - ANSIBLE_UTILS_IS_INSTALLED = True -from ansible.errors import AnsibleActionFail -from ansible_collections.cisco.dnac.plugins.plugin_utils.dnac import ( - DNACSDK, - dnac_argument_spec, - dnac_compare_equality, - get_dict_result, -) -from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, -) - -# Get common arguments specification -argument_spec = dnac_argument_spec() -# Add arguments specific for this module -argument_spec.update(dict( - state=dict(type="str", default="present", choices=["present"]), -)) - -required_if = [ -] -required_one_of = [] -mutually_exclusive = [] -required_together = [] - - -class SystemIssueDefinitionsCountV1(object): - def __init__(self, params, dnac): - self.dnac = dnac - self.new_object = dict( - ) - - def get_all_params(self, name=None, id=None): - new_object_params = {} - new_object_params['device_type'] = self.new_object.get('deviceType') or \ - self.new_object.get('device_type') - new_object_params['profile_id'] = self.new_object.get('profileId') or \ - self.new_object.get('profile_id') - new_object_params['id'] = id or self.new_object.get('id') - new_object_params['name'] = name or self.new_object.get('name') - new_object_params['priority'] = self.new_object.get('priority') - new_object_params['issue_enabled'] = self.new_object.get('issueEnabled') or \ - self.new_object.get('issue_enabled') - return new_object_params - - def get_object_by_name(self, name): - result = None - # NOTE: Does not have a get by name method, using get all - try: - items = self.dnac.exec( - family="issues", - function="get_the_count_of_system_defined_issue_definitions_based_on_provided_filters_v1", - params=self.get_all_params(name=name), - ) - if isinstance(items, dict): - if 'response' in items: - items = items.get('response') - result = get_dict_result(items, 'name', name) - except Exception: - result = None - return result - - def get_object_by_id(self, id): - result = None - # NOTE: Does not have a get by id method or it is in another action - return result - - def exists(self): - prev_obj = None - id_exists = False - name_exists = False - o_id = self.new_object.get("id") - name = self.new_object.get("name") - if o_id: - prev_obj = self.get_object_by_id(o_id) - id_exists = prev_obj is not None and isinstance(prev_obj, dict) - if not id_exists and name: - prev_obj = self.get_object_by_name(name) - name_exists = prev_obj is not None and isinstance(prev_obj, dict) - 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") - if _id: - self.new_object.update(dict(id=_id)) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) - return (it_exists, prev_obj) - - def requires_update(self, current_obj): - requested_obj = self.new_object - - obj_params = [ - ] - # 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 - return any(not dnac_compare_equality(current_obj.get(dnac_param), - requested_obj.get(ansible_param)) - for (dnac_param, ansible_param) in obj_params) - - -class ActionModule(ActionBase): - def __init__(self, *args, **kwargs): - if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail( - "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") - super(ActionModule, self).__init__(*args, **kwargs) - self._supports_async = False - self._supports_check_mode = False - self._result = None - - # Checks the supplied parameters against the argument spec for this module - def _check_argspec(self): - aav = AnsibleArgSpecValidator( - data=self._task.args, - schema=dict(argument_spec=argument_spec), - schema_format="argspec", - schema_conditionals=dict( - required_if=required_if, - required_one_of=required_one_of, - mutually_exclusive=mutually_exclusive, - required_together=required_together, - ), - name=self._task.action, - ) - valid, errors, self._task.args = aav.validate() - if not valid: - raise AnsibleActionFail(errors) - - def run(self, tmp=None, task_vars=None): - self._task.diff = False - self._result = super(ActionModule, self).run(tmp, task_vars) - self._result["changed"] = False - self._check_argspec() - - dnac = DNACSDK(self._task.args) - obj = SystemIssueDefinitionsCountV1(self._task.args, dnac) - - state = self._task.args.get("state") - - response = None - if state == "present": - - self._result.update(dict(dnac_response=response)) - self._result.update(dnac.exit_json()) - return self._result diff --git a/plugins/action/system_issue_definitions_v1.py b/plugins/action/system_issue_definitions_v1.py deleted file mode 100644 index 45d83dffe4..0000000000 --- a/plugins/action/system_issue_definitions_v1.py +++ /dev/null @@ -1,198 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# 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 -try: - from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import ( - AnsibleArgSpecValidator, - ) -except ImportError: - ANSIBLE_UTILS_IS_INSTALLED = False -else: - ANSIBLE_UTILS_IS_INSTALLED = True -from ansible.errors import AnsibleActionFail -from ansible_collections.cisco.dnac.plugins.plugin_utils.dnac import ( - DNACSDK, - dnac_argument_spec, - dnac_compare_equality, - get_dict_result, -) -from ansible_collections.cisco.dnac.plugins.plugin_utils.exceptions import ( - InconsistentParameters, -) - -# Get common arguments specification -argument_spec = dnac_argument_spec() -# Add arguments specific for this module -argument_spec.update(dict( - state=dict(type="str", default="present", choices=["present"]), - synchronizeToHealthThreshold=dict(type="bool"), - priority=dict(type="str"), - issueEnabled=dict(type="bool"), - thresholdValue=dict(type="float"), - id=dict(type="str"), -)) - -required_if = [ - ("state", "present", ["id"], True), -] -required_one_of = [] -mutually_exclusive = [] -required_together = [] - - -class SystemIssueDefinitionsV1(object): - def __init__(self, params, dnac): - self.dnac = dnac - self.new_object = dict( - synchronizeToHealthThreshold=params.get( - "synchronizeToHealthThreshold"), - priority=params.get("priority"), - issueEnabled=params.get("issueEnabled"), - thresholdValue=params.get("thresholdValue"), - id=params.get("id"), - ) - - def get_all_params(self, name=None, id=None): - new_object_params = {} - new_object_params['device_type'] = self.new_object.get('deviceType') or \ - self.new_object.get('device_type') - new_object_params['profile_id'] = self.new_object.get('profileId') or \ - self.new_object.get('profile_id') - new_object_params['id'] = id or self.new_object.get('id') - new_object_params['name'] = name or self.new_object.get('name') - new_object_params['priority'] = self.new_object.get('priority') - new_object_params['issue_enabled'] = self.new_object.get('issueEnabled') or \ - self.new_object.get('issue_enabled') - new_object_params['attribute'] = self.new_object.get('attribute') - new_object_params['offset'] = self.new_object.get('offset') - new_object_params['limit'] = self.new_object.get('limit') - new_object_params['sort_by'] = self.new_object.get('sortBy') or \ - self.new_object.get('sort_by') - new_object_params['order'] = self.new_object.get('order') - return new_object_params - - def get_object_by_name(self, name): - result = None - # NOTE: Does not have a get by name method, using get all - try: - items = self.dnac.exec( - family="issues", - function="returns_all_issue_trigger_definitions_for_given_filters_v1", - params=self.get_all_params(name=name), - ) - if isinstance(items, dict): - if 'response' in items: - items = items.get('response') - result = get_dict_result(items, 'name', name) - except Exception: - result = None - return result - - def get_object_by_id(self, id): - result = None - try: - items = self.dnac.exec( - family="issues", - function="issue_trigger_definition_update_v1", - params={"id": id} - ) - if isinstance(items, dict): - if 'response' in items: - items = items.get('response') - result = get_dict_result(items, 'id', id) - except Exception: - result = None - return result - - def exists(self): - prev_obj = None - id_exists = False - name_exists = False - o_id = self.new_object.get("id") - name = self.new_object.get("name") - if o_id: - prev_obj = self.get_object_by_id(o_id) - id_exists = prev_obj is not None and isinstance(prev_obj, dict) - if not id_exists and name: - prev_obj = self.get_object_by_name(name) - name_exists = prev_obj is not None and isinstance(prev_obj, dict) - 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") - if _id: - self.new_object.update(dict(id=_id)) - if _id: - prev_obj = self.get_object_by_id(_id) - it_exists = prev_obj is not None and isinstance(prev_obj, dict) - return (it_exists, prev_obj) - - def requires_update(self, current_obj): - requested_obj = self.new_object - - obj_params = [ - ("synchronizeToHealthThreshold", "synchronizeToHealthThreshold"), - ("priority", "priority"), - ("issueEnabled", "issueEnabled"), - ("thresholdValue", "thresholdValue"), - ("id", "id"), - ] - # 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 - return any(not dnac_compare_equality(current_obj.get(dnac_param), - requested_obj.get(ansible_param)) - for (dnac_param, ansible_param) in obj_params) - - -class ActionModule(ActionBase): - def __init__(self, *args, **kwargs): - if not ANSIBLE_UTILS_IS_INSTALLED: - raise AnsibleActionFail( - "ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'") - super(ActionModule, self).__init__(*args, **kwargs) - self._supports_async = False - self._supports_check_mode = False - self._result = None - - # Checks the supplied parameters against the argument spec for this module - def _check_argspec(self): - aav = AnsibleArgSpecValidator( - data=self._task.args, - schema=dict(argument_spec=argument_spec), - schema_format="argspec", - schema_conditionals=dict( - required_if=required_if, - required_one_of=required_one_of, - mutually_exclusive=mutually_exclusive, - required_together=required_together, - ), - name=self._task.action, - ) - valid, errors, self._task.args = aav.validate() - if not valid: - raise AnsibleActionFail(errors) - - def run(self, tmp=None, task_vars=None): - self._task.diff = False - self._result = super(ActionModule, self).run(tmp, task_vars) - self._result["changed"] = False - self._check_argspec() - - dnac = DNACSDK(self._task.args) - obj = SystemIssueDefinitionsV1(self._task.args, dnac) - - state = self._task.args.get("state") - - response = None - if state == "present": - - self._result.update(dict(dnac_response=response)) - self._result.update(dnac.exit_json()) - return self._result diff --git a/plugins/modules/compliance_device.py b/plugins/modules/compliance_device.py deleted file mode 100644 index b849c0e56c..0000000000 --- a/plugins/modules/compliance_device.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# Copyright (c) 2021, Cisco Systems -# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - - -DOCUMENTATION = r""" ---- -module: compliance_device -short_description: Resource module for Compliance Device -description: -- This module represents an alias of the module compliance_device_v1 -version_added: '3.1.0' -extends_documentation_fragment: - - cisco.dnac.module -author: Rafael Campos (@racampos) -options: {} -requirements: -- dnacentersdk >= 2.4.9 -- python >= 3.5 -notes: - - Paths used are - - It should be noted that this module is an alias of compliance_device_v1 - -""" - -EXAMPLES = r""" -""" -RETURN = r""" -dnac_response: - description: A dictionary or list with the response returned by the Cisco DNAC Python SDK - returned: always - type: dict - sample: > - {} -""" diff --git a/plugins/modules/compliance_device_v1.py b/plugins/modules/compliance_device_v1.py deleted file mode 100644 index 3bdbef53d5..0000000000 --- a/plugins/modules/compliance_device_v1.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# Copyright (c) 2021, Cisco Systems -# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - -DOCUMENTATION = r""" ---- -module: compliance_device_v1 -short_description: Resource module for Compliance Device V1 -description: -- Manage operation create of the resource Compliance Device V1. -version_added: '3.1.0' -extends_documentation_fragment: - - cisco.dnac.module -author: Rafael Campos (@racampos) -options: {} -requirements: -- dnacentersdk >= 2.4.9 -- python >= 3.5 -notes: - - Paths used are - -""" - -EXAMPLES = r""" -""" -RETURN = r""" -dnac_response: - description: A dictionary or list with the response returned by the Cisco DNAC Python SDK - returned: always - type: dict - sample: > - {} -""" diff --git a/plugins/modules/system_issue_definitions.py b/plugins/modules/system_issue_definitions.py deleted file mode 100644 index 124a571128..0000000000 --- a/plugins/modules/system_issue_definitions.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# Copyright (c) 2021, Cisco Systems -# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - - -DOCUMENTATION = r""" ---- -module: system_issue_definitions -short_description: Resource module for System Issue Definitions -description: -- This module represents an alias of the module system_issue_definitions_v1 -version_added: '6.15.0' -extends_documentation_fragment: - - cisco.dnac.module -author: Rafael Campos (@racampos) -options: {} -requirements: -- dnacentersdk >= 2.4.9 -- python >= 3.5 -notes: - - Paths used are - - It should be noted that this module is an alias of system_issue_definitions_v1 - -""" - -EXAMPLES = r""" -""" -RETURN = r""" -dnac_response: - description: A dictionary or list with the response returned by the Cisco DNAC Python SDK - returned: always - type: dict - sample: > - {} -""" diff --git a/plugins/modules/system_issue_definitions_count.py b/plugins/modules/system_issue_definitions_count.py deleted file mode 100644 index 67c3baafd9..0000000000 --- a/plugins/modules/system_issue_definitions_count.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# Copyright (c) 2021, Cisco Systems -# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - - -DOCUMENTATION = r""" ---- -module: system_issue_definitions_count -short_description: Resource module for System Issue Definitions Count -description: -- This module represents an alias of the module system_issue_definitions_count_v1 -version_added: '6.15.0' -extends_documentation_fragment: - - cisco.dnac.module -author: Rafael Campos (@racampos) -options: {} -requirements: -- dnacentersdk >= 2.4.9 -- python >= 3.5 -notes: - - Paths used are - - It should be noted that this module is an alias of system_issue_definitions_count_v1 - -""" - -EXAMPLES = r""" -""" -RETURN = r""" -dnac_response: - description: A dictionary or list with the response returned by the Cisco DNAC Python SDK - returned: always - type: dict - sample: > - {} -""" diff --git a/plugins/modules/system_issue_definitions_count_v1.py b/plugins/modules/system_issue_definitions_count_v1.py deleted file mode 100644 index 8f82d4eb3a..0000000000 --- a/plugins/modules/system_issue_definitions_count_v1.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# Copyright (c) 2021, Cisco Systems -# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - -DOCUMENTATION = r""" ---- -module: system_issue_definitions_count_v1 -short_description: Resource module for System Issue Definitions Count V1 -description: -- Manage operation update of the resource System Issue Definitions Count V1. -version_added: '6.15.0' -extends_documentation_fragment: - - cisco.dnac.module -author: Rafael Campos (@racampos) -options: {} -requirements: -- dnacentersdk >= 2.4.9 -- python >= 3.5 -notes: - - Paths used are - -""" - -EXAMPLES = r""" -""" -RETURN = r""" -dnac_response: - description: A dictionary or list with the response returned by the Cisco DNAC Python SDK - returned: always - type: dict - sample: > - {} -""" diff --git a/plugins/modules/system_issue_definitions_v1.py b/plugins/modules/system_issue_definitions_v1.py deleted file mode 100644 index f7bd2077f1..0000000000 --- a/plugins/modules/system_issue_definitions_v1.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# Copyright (c) 2021, Cisco Systems -# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - -DOCUMENTATION = r""" ---- -module: system_issue_definitions_v1 -short_description: Resource module for System Issue Definitions V1 -description: -- Manage operation update of the resource System Issue Definitions V1. -version_added: '6.15.0' -extends_documentation_fragment: - - cisco.dnac.module -author: Rafael Campos (@racampos) -options: {} -requirements: -- dnacentersdk >= 2.4.9 -- python >= 3.5 -notes: - - Paths used are - -""" - -EXAMPLES = r""" -""" -RETURN = r""" -dnac_response: - description: A dictionary or list with the response returned by the Cisco DNAC Python SDK - returned: always - type: dict - sample: > - {} -"""