summaryrefslogtreecommitdiffstats
path: root/ansible_collections/cisco/dnac/plugins/action
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/cisco/dnac/plugins/action')
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/accesspoint_configuration_details_by_task_id_info.py98
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/app_policy_default_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/app_policy_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/app_policy_intent_create.py90
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/app_policy_queuing_profile.py262
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/app_policy_queuing_profile_count_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/app_policy_queuing_profile_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/application_sets.py226
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/application_sets_count_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/application_sets_info.py93
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/applications.py252
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/applications_count_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/applications_health_info.py105
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/applications_info.py93
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/assign_device_to_site.py90
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/associate_site_to_network_profile.py88
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/authentication_import_certificate.py96
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/authentication_import_certificate_p12.py93
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/authentication_policy_servers_info.py93
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/buildings_planned_access_points_info.py95
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/business_sda_hostonboarding_ssid_ippool.py201
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/business_sda_hostonboarding_ssid_ippool_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/business_sda_virtual_network_summary_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/business_sda_wireless_controller_create.py88
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/business_sda_wireless_controller_delete.py85
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/cli_credential.py239
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/client_detail_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/client_enrichment_details_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/client_health_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/client_proximity_info.py93
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/command_runner_run_command.py94
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/compliance_check_run.py90
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/compliance_device_by_id_info.py99
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/compliance_device_details_count_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/compliance_device_details_info.py97
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/compliance_device_info.py106
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/compliance_device_status_count_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/configuration_template.py355
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/configuration_template_clone.py90
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/configuration_template_create.py137
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/configuration_template_deploy.py96
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/configuration_template_deploy_status_info.py98
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/configuration_template_deploy_v2.py96
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/configuration_template_export_project.py86
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/configuration_template_export_template.py86
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/configuration_template_import_project.py86
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/configuration_template_import_template.py90
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/configuration_template_info.py124
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/configuration_template_project.py284
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/configuration_template_project_info.py104
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/configuration_template_version_create.py88
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/configuration_template_version_info.py98
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/credential_to_site_by_siteid_create_v2.py98
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_configurations_export.py88
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_credential_create.py86
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_credential_delete.py85
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_credential_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_credential_update.py86
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_details_info.py93
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_enrichment_details_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_family_identifiers_details_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_health_info.py101
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_interface_by_ip_info.py98
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_interface_count_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_interface_info.py108
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_interface_isis_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_interface_ospf_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_reboot_apreboot_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_replacement.py237
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_replacement_count_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_replacement_deploy.py88
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/device_replacement_info.py109
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/disassociate_site_to_network_profile.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/disasterrecovery_system_operationstatus_info.py90
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/disasterrecovery_system_status_info.py90
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/discovery.py443
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/discovery_count_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/discovery_device_count_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/discovery_device_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/discovery_device_range_info.py95
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/discovery_info.py98
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/discovery_job_info.py108
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/discovery_range_delete.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/discovery_range_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/discovery_summary_info.py107
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/dna_command_runner_keywords_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/dnac_packages_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/dnacaap_management_execution_status_info.py98
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/endpoint_analytics_profiling_rules.py332
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/endpoint_analytics_profiling_rules_info.py115
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/eox_status_device_info.py100
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/eox_status_summary_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_api_status_info.py98
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_artifact_count_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_artifact_info.py101
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_config_connector_types_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_count_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_email_config.py221
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_email_config_create.py96
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_email_config_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_email_config_update.py96
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_info.py99
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_series_audit_logs_info.py131
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_series_audit_logs_parent_records_info.py129
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_series_audit_logs_summary_info.py125
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_series_count_info.py105
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_series_info.py119
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_snmp_config_info.py97
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_subscription.py260
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_subscription_count_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_subscription_details_email_info.py99
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_subscription_details_rest_info.py99
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_subscription_details_syslog_info.py99
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_subscription_email.py223
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_subscription_email_info.py107
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_subscription_info.py97
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_subscription_rest.py223
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_subscription_rest_info.py107
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_subscription_syslog.py223
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_subscription_syslog_info.py107
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_syslog_config.py231
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_syslog_config_info.py101
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_webhook_create.py98
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/event_webhook_update.py98
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/execute_suggested_actions_commands.py88
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/file_import.py88
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/file_info.py110
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/file_namespace_files_info.py98
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/file_namespaces_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/global_credential_delete.py85
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/global_credential_info.py106
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/global_credential_update.py88
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/global_credential_v2.py270
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/global_credential_v2_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/global_pool.py277
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/global_pool_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/golden_image_create.py92
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/golden_tag_image_delete.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/golden_tag_image_details_info.py104
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/http_read_credential.py244
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/http_write_credential.py244
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/integration_settings_instances_itsm.py260
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/integration_settings_instances_itsm_info.py98
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/interface_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/interface_network_device_detail_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/interface_network_device_info.py98
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/interface_network_device_range_info.py93
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/interface_operation_create.py92
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/interface_update.py96
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/issues_enrichment_details_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/issues_info.py103
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/itsm_cmdb_sync_status_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/itsm_integration_events_failed_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/itsm_integration_events_retry.py86
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/lan_automation_count_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/lan_automation_create.py86
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/lan_automation_delete.py85
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/lan_automation_log_by_serial_number_info.py102
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/lan_automation_log_info.py104
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/lan_automation_status_info.py104
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/license_device_count_info.py97
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/license_device_deregistration.py86
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/license_device_license_details_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/license_device_license_summary_info.py107
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/license_device_registration.py88
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/license_smart_account_details_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/license_term_details_info.py102
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/license_usage_details_info.py102
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/license_virtual_account_change.py90
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/license_virtual_account_details_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/netconf_credential.py233
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_create.py90
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device.py439
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_by_ip_info.py98
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_by_serial_number_info.py98
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_chassis_details_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_config_count_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_config_info.py100
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_count_info.py100
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_custom_prompt.py88
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_custom_prompt_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_equipment_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_export.py94
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_functional_capability_info.py104
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_global_polling_interval_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_info.py166
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_interface_neighbor_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_interface_poe_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_inventory_insight_link_mismatch_info.py99
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_lexicographically_sorted_info.py131
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_linecard_details_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_meraki_organization_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_module_count_info.py97
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_module_info.py114
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_poe_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_polling_interval_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_range_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_register_for_wsa_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_stack_details_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_summary_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_supervisor_card_details_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_sync.py88
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_update_role.py90
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_user_defined_field.py259
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_user_defined_field_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_vlan_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_wireless_lan_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_device_with_snmp_v3_des_info.py97
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_update.py88
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_v2.py214
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/network_v2_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/nfv_profile.py248
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/nfv_profile_info.py104
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/nfv_provision.py90
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/nfv_provision_detail_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/nfv_provision_details.py88
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/path_trace.py286
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/path_trace_info.py130
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/planned_access_points_info.py95
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/platform_nodes_configuration_summary_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/platform_release_summary_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_device.py344
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_device_authorize.py86
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_device_claim.py102
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_device_claim_to_site.py108
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_device_config_preview.py90
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_device_count_info.py115
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_device_history_info.py93
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_device_import.py86
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_device_info.py142
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_device_reset.py90
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_device_unclaim.py86
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_global_settings.py182
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_global_settings_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_server_profile_update.py110
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_smart_account_domains_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_add.py110
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_deregister.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_devices_sync.py110
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_sync_result_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_virtual_accounts_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_workflow.py351
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_workflow_count_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/pnp_workflow_info.py112
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/profiling_rules_count_info.py94
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/profiling_rules_in_bulk_create.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/projects_details_info.py97
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/qos_device_interface.py264
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/qos_device_interface_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/qos_device_interface_info_count_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/reports.py259
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/reports_executions_info.py114
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/reports_info.py104
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/reports_view_group_info.py100
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/reports_view_group_view_info.py100
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool.py358
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_create.py126
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_delete.py85
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_info.py93
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_update.py116
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/role_permissions_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/roles_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_count_info.py90
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_device_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_device_role_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_fabric.py209
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_fabric_authentication_profile.py242
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_fabric_authentication_profile_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_fabric_border_device.py225
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_fabric_border_device_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_fabric_control_plane_device.py217
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_fabric_control_plane_device_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_fabric_edge_device.py213
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_fabric_edge_device_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_fabric_info.py92
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_fabric_site.py217
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_fabric_site_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_multicast.py221
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_multicast_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_access_point.py234
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_access_point_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_user_device.py246
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_user_device_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_provision_device.py233
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_provision_device_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_virtual_network.py218
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_ip_pool.py280
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_ip_pool_info.py93
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_v2.py243
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_v2_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/security_advisories_devices_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/security_advisories_ids_per_device_info.py98
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/security_advisories_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/security_advisories_per_device_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/security_advisories_summary_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sensor.py225
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sensor_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sensor_test_run.py86
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sensor_test_template_duplicate.py88
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sensor_test_template_edit.py90
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/service_provider_create.py86
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/service_provider_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/service_provider_profile_delete.py85
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/service_provider_update.py86
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/service_provider_v2.py197
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/service_provider_v2_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/site_assign_credential.py100
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/site_assign_device.py93
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/site_count_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/site_create.py90
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/site_delete.py85
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/site_design_floormap.py248
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/site_design_floormap_info.py103
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/site_health_info.py95
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/site_info.py97
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/site_membership_info.py106
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/site_update.py92
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/snmp_properties.py202
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/snmp_properties_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/snmpv2_read_community_credential.py225
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/snmpv2_write_community_credential.py225
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/snmpv3_credential.py252
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/sp_profile_delete_v2.py85
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/swim_image_details_info.py123
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/swim_import_local.py95
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/swim_import_via_url.py92
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/swim_trigger_activation.py90
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/swim_trigger_distribution.py86
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/syslog_config_create.py96
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/syslog_config_update.py96
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/system_health_count_info.py91
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/system_health_info.py97
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/system_performance_historical_info.py93
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/system_performance_info.py95
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/tag.py283
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/tag_count_info.py99
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/tag_info.py122
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/tag_member.py225
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/tag_member_count_info.py95
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/tag_member_info.py99
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/tag_member_type_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/tag_membership.py88
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/task_count_info.py107
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/task_info.py128
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/task_operation_info.py102
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/task_tree_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/template_preview.py92
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/templates_details_info.py121
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/threat_detail.py103
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/threat_detail_count.py103
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/threat_summary.py97
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/topology_layer_2_info.py98
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/topology_layer_3_info.py98
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/topology_network_health_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/topology_physical_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/topology_site_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/topology_vlan_details_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/transit_peer_network.py210
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/transit_peer_network_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/user.py225
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/user_enrichment_details_info.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/user_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/users_external_servers_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/wireless_accespoint_configuration.py130
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/wireless_accesspoint_configuration_summary_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/wireless_dynamic_interface.py229
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/wireless_dynamic_interface_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/wireless_enterprise_ssid.py347
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/wireless_enterprise_ssid_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/wireless_profile.py247
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/wireless_profile_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/wireless_provision_access_point.py88
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/wireless_provision_device_create.py86
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/wireless_provision_device_update.py88
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/wireless_provision_ssid_create_provision.py96
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/wireless_provision_ssid_delete_reprovision.py87
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/wireless_psk_override.py86
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/wireless_rf_profile.py263
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/wireless_rf_profile_info.py89
-rw-r--r--ansible_collections/cisco/dnac/plugins/action/wireless_sensor_test_results_info.py95
382 files changed, 45995 insertions, 0 deletions
diff --git a/ansible_collections/cisco/dnac/plugins/action/accesspoint_configuration_details_by_task_id_info.py b/ansible_collections/cisco/dnac/plugins/action/accesspoint_configuration_details_by_task_id_info.py
new file mode 100644
index 000000000..0e290527d
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/accesspoint_configuration_details_by_task_id_info.py
@@ -0,0 +1,98 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ task_id=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ task_id=params.get("task_id"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("task_id")
+ if id:
+ response = dnac.exec(
+ family="wireless",
+ function='get_access_point_configuration_task_result',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/app_policy_default_info.py b/ansible_collections/cisco/dnac/plugins/action/app_policy_default_info.py
new file mode 100644
index 000000000..9e8665c82
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/app_policy_default_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="application_policy",
+ function='get_application_policy_default',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/app_policy_info.py b/ansible_collections/cisco/dnac/plugins/action/app_policy_info.py
new file mode 100644
index 000000000..4f0e145a1
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/app_policy_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ policyScope=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ policy_scope=params.get("policyScope"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="application_policy",
+ function='get_application_policy',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/app_policy_intent_create.py b/ansible_collections/cisco/dnac/plugins/action/app_policy_intent_create.py
new file mode 100644
index 000000000..8b2e185c2
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/app_policy_intent_create.py
@@ -0,0 +1,90 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ createList=dict(type="list"),
+ updateList=dict(type="list"),
+ deleteList=dict(type="list"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ createList=params.get("createList"),
+ updateList=params.get("updateList"),
+ deleteList=params.get("deleteList"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="application_policy",
+ function='application_policy_intent',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/app_policy_queuing_profile.py b/ansible_collections/cisco/dnac/plugins/action/app_policy_queuing_profile.py
new file mode 100644
index 000000000..34b67d5e6
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/app_policy_queuing_profile.py
@@ -0,0 +1,262 @@
+#!/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", "absent"]),
+ payload=dict(type="list"),
+ id=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["id"], True),
+ ("state", "present", ["payload"], True),
+ ("state", "absent", ["id"], True),
+ ("state", "absent", ["payload"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class AppPolicyQueuingProfile(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ payload=params.get("payload"),
+ id=params.get("id"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['name'] = name or self.new_object.get('name')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['id'] = self.new_object.get('id')
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="application_policy",
+ function="get_application_policy_queuing_profile",
+ 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
+ try:
+ items = self.dnac.exec(
+ family="application_policy",
+ function="get_application_policy_queuing_profile",
+ params=self.get_all_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):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ requested_obj = self.new_object.get('payload')
+ 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")
+ name = self.new_object.get("name") or requested_obj.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.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+
+ obj_params = [
+ ("id", "id"),
+ ("description", "description"),
+ ("name", "name"),
+ ("clause", "clause"),
+ ("id", "id"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="application_policy",
+ function="create_application_policy_queuing_profile",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ requested_obj = self.new_object.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+ id = self.new_object.get("id") or requested_obj.get("id")
+ name = self.new_object.get("name") or requested_obj.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="application_policy",
+ function="update_application_policy_queuing_profile",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ requested_obj = self.new_object.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+ id = self.new_object.get("id") or requested_obj.get("id")
+ name = self.new_object.get("name") or requested_obj.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ if id_:
+ self.new_object.update(dict(id=id_))
+ result = self.dnac.exec(
+ family="application_policy",
+ function="delete_application_policy_queuing_profile",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = AppPolicyQueuingProfile(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/app_policy_queuing_profile_count_info.py b/ansible_collections/cisco/dnac/plugins/action/app_policy_queuing_profile_count_info.py
new file mode 100644
index 000000000..65558df42
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/app_policy_queuing_profile_count_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="application_policy",
+ function='get_application_policy_queuing_profile_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/app_policy_queuing_profile_info.py b/ansible_collections/cisco/dnac/plugins/action/app_policy_queuing_profile_info.py
new file mode 100644
index 000000000..79cf3ad07
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/app_policy_queuing_profile_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ name=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ name=params.get("name"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="application_policy",
+ function='get_application_policy_queuing_profile',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/application_sets.py b/ansible_collections/cisco/dnac/plugins/action/application_sets.py
new file mode 100644
index 000000000..b1bc7f48b
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/application_sets.py
@@ -0,0 +1,226 @@
+#!/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", "absent"]),
+ payload=dict(type="list"),
+ id=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["payload"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ApplicationSets(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ payload=params.get("payload"),
+ id=params.get("id"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['offset'] = self.new_object.get('offset')
+ new_object_params['limit'] = self.new_object.get('limit')
+ new_object_params['name'] = name or self.new_object.get('name')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ return new_object_params
+
+ def delete_all_params(self):
+ new_object_params = {}
+ new_object_params['id'] = self.new_object.get('id')
+ 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="application_policy",
+ function="get_application_sets",
+ 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
+ try:
+ items = self.dnac.exec(
+ family="application_policy",
+ function="get_application_sets",
+ params=self.get_all_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
+ requested_obj = self.new_object.get('payload')
+ 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")
+ name = self.new_object.get("name") or requested_obj.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.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+
+ obj_params = [
+ ("name", "name"),
+ ("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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="application_policy",
+ function="create_application_set",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="application_policy",
+ function="delete_application_set",
+ params=self.delete_all_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = ApplicationSets(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ 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:
+ response = obj.create()
+ dnac.object_created()
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/application_sets_count_info.py b/ansible_collections/cisco/dnac/plugins/action/application_sets_count_info.py
new file mode 100644
index 000000000..afd2e7bf0
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/application_sets_count_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="application_policy",
+ function='get_application_sets_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/application_sets_info.py b/ansible_collections/cisco/dnac/plugins/action/application_sets_info.py
new file mode 100644
index 000000000..9e388f1ac
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/application_sets_info.py
@@ -0,0 +1,93 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ name=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ name=params.get("name"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="application_policy",
+ function='get_application_sets',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/applications.py b/ansible_collections/cisco/dnac/plugins/action/applications.py
new file mode 100644
index 000000000..81c404e88
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/applications.py
@@ -0,0 +1,252 @@
+#!/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", "absent"]),
+ payload=dict(type="list"),
+ id=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["payload"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class Applications(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ payload=params.get("payload"),
+ id=params.get("id"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['offset'] = self.new_object.get('offset')
+ new_object_params['limit'] = self.new_object.get('limit')
+ new_object_params['name'] = name or self.new_object.get('name')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ return new_object_params
+
+ def delete_all_params(self):
+ new_object_params = {}
+ new_object_params['id'] = self.new_object.get('id')
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="application_policy",
+ function="get_applications",
+ 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
+ try:
+ items = self.dnac.exec(
+ family="application_policy",
+ function="get_applications",
+ params=self.get_all_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):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ requested_obj = self.new_object.get('payload')
+ 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")
+ name = self.new_object.get("name") or requested_obj.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.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+
+ obj_params = [
+ ("id", "id"),
+ ("name", "name"),
+ ("networkApplications", "networkApplications"),
+ ("networkIdentity", "networkIdentity"),
+ ("applicationSet", "applicationSet"),
+ ("id", "id"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="application_policy",
+ function="create_application",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ requested_obj = self.new_object.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+ id = self.new_object.get("id") or requested_obj.get("id")
+ name = self.new_object.get("name") or requested_obj.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="application_policy",
+ function="edit_application",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="application_policy",
+ function="delete_application",
+ params=self.delete_all_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = Applications(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/applications_count_info.py b/ansible_collections/cisco/dnac/plugins/action/applications_count_info.py
new file mode 100644
index 000000000..a7f89be1d
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/applications_count_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="application_policy",
+ function='get_applications_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/applications_health_info.py b/ansible_collections/cisco/dnac/plugins/action/applications_health_info.py
new file mode 100644
index 000000000..31d101b24
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/applications_health_info.py
@@ -0,0 +1,105 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteId=dict(type="str"),
+ deviceId=dict(type="str"),
+ macAddress=dict(type="str"),
+ startTime=dict(type="int"),
+ endTime=dict(type="int"),
+ applicationHealth=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ applicationName=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ site_id=params.get("siteId"),
+ device_id=params.get("deviceId"),
+ mac_address=params.get("macAddress"),
+ start_time=params.get("startTime"),
+ end_time=params.get("endTime"),
+ application_health=params.get("applicationHealth"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ application_name=params.get("applicationName"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="applications",
+ function='applications',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/applications_info.py b/ansible_collections/cisco/dnac/plugins/action/applications_info.py
new file mode 100644
index 000000000..8d1275175
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/applications_info.py
@@ -0,0 +1,93 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ name=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ name=params.get("name"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="application_policy",
+ function='get_applications',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/assign_device_to_site.py b/ansible_collections/cisco/dnac/plugins/action/assign_device_to_site.py
new file mode 100644
index 000000000..342f660ea
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/assign_device_to_site.py
@@ -0,0 +1,90 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ device=dict(type="list"),
+ siteId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ device=params.get("device"),
+ site_id=params.get("siteId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="sites",
+ function='assign_devices_to_site',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/associate_site_to_network_profile.py b/ansible_collections/cisco/dnac/plugins/action/associate_site_to_network_profile.py
new file mode 100644
index 000000000..d5de55cbd
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/associate_site_to_network_profile.py
@@ -0,0 +1,88 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ networkProfileId=dict(type="str"),
+ siteId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ network_profile_id=params.get("networkProfileId"),
+ site_id=params.get("siteId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="site_design",
+ function='associate',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/authentication_import_certificate.py b/ansible_collections/cisco/dnac/plugins/action/authentication_import_certificate.py
new file mode 100644
index 000000000..ae3eb2fe4
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/authentication_import_certificate.py
@@ -0,0 +1,96 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ pkPassword=dict(type="str", no_log=True),
+ listOfUsers=dict(type="list"),
+ certFilePath=dict(type="str"),
+ pkFilePath=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ pk_password=params.get("pkPassword"),
+ list_of_users=params.get("listOfUsers"),
+ cert_file_path=params.get("certFilePath"),
+ pk_file_path=params.get("pkFilePath"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="authentication_management",
+ function='import_certificate',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ file_paths=[
+ ('cert_file_path', 'certFileUpload'),
+ ('pk_file_path', 'pkFileUpload'),
+ ],
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/authentication_import_certificate_p12.py b/ansible_collections/cisco/dnac/plugins/action/authentication_import_certificate_p12.py
new file mode 100644
index 000000000..96ea393d9
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/authentication_import_certificate_p12.py
@@ -0,0 +1,93 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ p12Password=dict(type="str", no_log=True),
+ pkPassword=dict(type="str", no_log=True),
+ listOfUsers=dict(type="list"),
+ p12FilePath=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ p12_password=params.get("p12Password"),
+ pk_password=params.get("pkPassword"),
+ list_of_users=params.get("listOfUsers"),
+ p12_file_path=params.get("p12FilePath"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="authentication_management",
+ function='import_certificate_p12',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ file_paths=[('p12_file_path', 'p12FileUpload')],
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/authentication_policy_servers_info.py b/ansible_collections/cisco/dnac/plugins/action/authentication_policy_servers_info.py
new file mode 100644
index 000000000..0f219af21
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/authentication_policy_servers_info.py
@@ -0,0 +1,93 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ isIseEnabled=dict(type="bool"),
+ state_=dict(type="str"),
+ role=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ is_ise_enabled=params.get("isIseEnabled"),
+ state=params.get("state_"),
+ role=params.get("role"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="system_settings",
+ function='get_authentication_and_policy_servers',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/buildings_planned_access_points_info.py b/ansible_collections/cisco/dnac/plugins/action/buildings_planned_access_points_info.py
new file mode 100644
index 000000000..166887325
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/buildings_planned_access_points_info.py
@@ -0,0 +1,95 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ buildingId=dict(type="str"),
+ limit=dict(type="int"),
+ offset=dict(type="int"),
+ radios=dict(type="bool"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ building_id=params.get("buildingId"),
+ limit=params.get("limit"),
+ offset=params.get("offset"),
+ radios=params.get("radios"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_planned_access_points_for_building',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/business_sda_hostonboarding_ssid_ippool.py b/ansible_collections/cisco/dnac/plugins/action/business_sda_hostonboarding_ssid_ippool.py
new file mode 100644
index 000000000..0a9652a75
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/business_sda_hostonboarding_ssid_ippool.py
@@ -0,0 +1,201 @@
+#!/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,
+)
+
+# 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"]),
+ vlanName=dict(type="str"),
+ scalableGroupName=dict(type="str"),
+ ssidNames=dict(type="list"),
+ siteNameHierarchy=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = [
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class BusinessSdaHostonboardingSsidIppool(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ vlan_name=params.get("vlanName"),
+ site_name_hierarchy=params.get("siteNameHierarchy"),
+ vlanName=params.get("vlanName"),
+ scalableGroupName=params.get("scalableGroupName"),
+ ssidNames=params.get("ssidNames"),
+ siteNameHierarchy=params.get("siteNameHierarchy"),
+ headers=params.get("headers"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['vlan_name'] = self.new_object.get('vlanName') or \
+ self.new_object.get('vlan_name')
+ new_object_params['site_name_hierarchy'] = self.new_object.get('siteNameHierarchy') or \
+ self.new_object.get('site_name_hierarchy')
+ return new_object_params
+
+ 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['ssidNames'] = self.new_object.get('ssidNames')
+ 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['ssidNames'] = self.new_object.get('ssidNames')
+ new_object_params['siteNameHierarchy'] = self.new_object.get('siteNameHierarchy')
+ 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="fabric_wireless",
+ function="get_ssid_to_ip_pool_mapping",
+ 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):
+ 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
+ return (it_exists, prev_obj)
+
+ def requires_update(self, current_obj):
+ requested_obj = self.new_object
+
+ obj_params = [
+ ("vlanName", "vlanName"),
+ ("scalableGroupName", "scalableGroupName"),
+ ("ssidNames", "ssidNames"),
+ ("siteNameHierarchy", "siteNameHierarchy"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="fabric_wireless",
+ function="add_ssid_to_ip_pool_mapping",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="fabric_wireless",
+ function="update_ssid_to_ip_pool_mapping",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = BusinessSdaHostonboardingSsidIppool(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/business_sda_hostonboarding_ssid_ippool_info.py b/ansible_collections/cisco/dnac/plugins/action/business_sda_hostonboarding_ssid_ippool_info.py
new file mode 100644
index 000000000..ea9f95ffe
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/business_sda_hostonboarding_ssid_ippool_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ vlanName=dict(type="str"),
+ siteNameHierarchy=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ vlan_name=params.get("vlanName"),
+ site_name_hierarchy=params.get("siteNameHierarchy"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="fabric_wireless",
+ function='get_ssid_to_ip_pool_mapping',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/business_sda_virtual_network_summary_info.py b/ansible_collections/cisco/dnac/plugins/action/business_sda_virtual_network_summary_info.py
new file mode 100644
index 000000000..0852a2c09
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/business_sda_virtual_network_summary_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteNameHierarchy=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ site_name_hierarchy=params.get("siteNameHierarchy"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sda",
+ function='get_virtual_network_summary',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/business_sda_wireless_controller_create.py b/ansible_collections/cisco/dnac/plugins/action/business_sda_wireless_controller_create.py
new file mode 100644
index 000000000..cb3d48aa9
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/business_sda_wireless_controller_create.py
@@ -0,0 +1,88 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceName=dict(type="str"),
+ siteNameHierarchy=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ deviceName=params.get("deviceName"),
+ siteNameHierarchy=params.get("siteNameHierarchy"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="fabric_wireless",
+ function='add_w_l_c_to_fabric_domain',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/business_sda_wireless_controller_delete.py b/ansible_collections/cisco/dnac/plugins/action/business_sda_wireless_controller_delete.py
new file mode 100644
index 000000000..54ce6427c
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/business_sda_wireless_controller_delete.py
@@ -0,0 +1,85 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceIPAddress=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ device_ipaddress=params.get("deviceIPAddress"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="fabric_wireless",
+ function="remove_w_l_c_from_fabric_domain",
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/cli_credential.py b/ansible_collections/cisco/dnac/plugins/action/cli_credential.py
new file mode 100644
index 000000000..d10c90049
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/cli_credential.py
@@ -0,0 +1,239 @@
+#!/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"]),
+ comments=dict(type="str"),
+ credentialType=dict(type="str"),
+ description=dict(type="str"),
+ enablePassword=dict(type="str", no_log=True),
+ id=dict(type="str"),
+ instanceTenantId=dict(type="str"),
+ instanceUuid=dict(type="str"),
+ password=dict(type="str", no_log=True),
+ username=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["description", "id", "username"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class CliCredential(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ comments=params.get("comments"),
+ credentialType=params.get("credentialType"),
+ description=params.get("description"),
+ enablePassword=params.get("enablePassword"),
+ id=params.get("id"),
+ instanceTenantId=params.get("instanceTenantId"),
+ instanceUuid=params.get("instanceUuid"),
+ password=params.get("password"),
+ username=params.get("username"),
+ )
+
+ def create_params(self):
+ new_object_params = {}
+ payload = {}
+ keys = ['comments', 'credentialType', 'description', 'enablePassword', 'id',
+ 'instanceTenantId', 'instanceUuid', 'password', 'username']
+ for key in keys:
+ if self.new_object.get(key) is not None:
+ payload[key] = self.new_object.get(key)
+ new_object_params['payload'] = [payload]
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['comments'] = self.new_object.get('comments')
+ new_object_params['credentialType'] = self.new_object.get('credentialType')
+ new_object_params['description'] = self.new_object.get('description')
+ new_object_params['enablePassword'] = self.new_object.get('enablePassword')
+ new_object_params['id'] = self.new_object.get('id')
+ new_object_params['instanceTenantId'] = self.new_object.get('instanceTenantId')
+ new_object_params['instanceUuid'] = self.new_object.get('instanceUuid')
+ new_object_params['password'] = self.new_object.get('password')
+ new_object_params['username'] = self.new_object.get('username')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="discovery",
+ function="get_global_credentials",
+ params={'credential_sub_type': 'CLI'},
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ result = get_dict_result(items, 'description', name) or get_dict_result(items, 'username', name)
+ except Exception:
+ result = None
+ return result
+
+ def get_object_by_id(self, id):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="discovery",
+ function="get_global_credentials",
+ params={'credential_sub_type': 'CLI'},
+ )
+ 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("description") or self.new_object.get("username")
+ 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 = [
+ ("comments", "comments"),
+ ("credentialType", "credentialType"),
+ ("description", "description"),
+ ("id", "id"),
+ ("instanceTenantId", "instanceTenantId"),
+ ("instanceUuid", "instanceUuid"),
+ ("username", "username"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="discovery",
+ function="create_cli_credentials",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="discovery",
+ function="update_cli_credentials",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = CliCredential(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/client_detail_info.py b/ansible_collections/cisco/dnac/plugins/action/client_detail_info.py
new file mode 100644
index 000000000..e09db53c8
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/client_detail_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ timestamp=dict(type="str"),
+ macAddress=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ timestamp=params.get("timestamp"),
+ mac_address=params.get("macAddress"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="clients",
+ function='get_client_detail',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/client_enrichment_details_info.py b/ansible_collections/cisco/dnac/plugins/action/client_enrichment_details_info.py
new file mode 100644
index 000000000..70e1dd738
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/client_enrichment_details_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="clients",
+ function='get_client_enrichment_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/client_health_info.py b/ansible_collections/cisco/dnac/plugins/action/client_health_info.py
new file mode 100644
index 000000000..87275b036
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/client_health_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ timestamp=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ timestamp=params.get("timestamp"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="clients",
+ function='get_overall_client_health',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/client_proximity_info.py b/ansible_collections/cisco/dnac/plugins/action/client_proximity_info.py
new file mode 100644
index 000000000..b9a411856
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/client_proximity_info.py
@@ -0,0 +1,93 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ username=dict(type="str"),
+ number_days=dict(type="int"),
+ time_resolution=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ username=params.get("username"),
+ number_days=params.get("number_days"),
+ time_resolution=params.get("time_resolution"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="clients",
+ function='client_proximity',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/command_runner_run_command.py b/ansible_collections/cisco/dnac/plugins/action/command_runner_run_command.py
new file mode 100644
index 000000000..bbae4f233
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/command_runner_run_command.py
@@ -0,0 +1,94 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ commands=dict(type="list"),
+ description=dict(type="str"),
+ deviceUuids=dict(type="list"),
+ name=dict(type="str"),
+ timeout=dict(type="int"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ commands=params.get("commands"),
+ description=params.get("description"),
+ deviceUuids=params.get("deviceUuids"),
+ name=params.get("name"),
+ timeout=params.get("timeout"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="command_runner",
+ function='run_read_only_commands_on_devices',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/compliance_check_run.py b/ansible_collections/cisco/dnac/plugins/action/compliance_check_run.py
new file mode 100644
index 000000000..4fbadc0cf
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/compliance_check_run.py
@@ -0,0 +1,90 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ triggerFull=dict(type="bool"),
+ categories=dict(type="list"),
+ deviceUuids=dict(type="list"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ triggerFull=params.get("triggerFull"),
+ categories=params.get("categories"),
+ deviceUuids=params.get("deviceUuids"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="compliance",
+ function='run_compliance',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/compliance_device_by_id_info.py b/ansible_collections/cisco/dnac/plugins/action/compliance_device_by_id_info.py
new file mode 100644
index 000000000..e2c684bfc
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/compliance_device_by_id_info.py
@@ -0,0 +1,99 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceUuid=dict(type="str"),
+ category=dict(type="str"),
+ complianceType=dict(type="str"),
+ diffList=dict(type="bool"),
+ key=dict(type="str"),
+ value=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_uuid=params.get("deviceUuid"),
+ category=params.get("category"),
+ compliance_type=params.get("complianceType"),
+ diff_list=params.get("diffList"),
+ key=params.get("key"),
+ value=params.get("value"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="compliance",
+ function='compliance_details_of_device',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/compliance_device_details_count_info.py b/ansible_collections/cisco/dnac/plugins/action/compliance_device_details_count_info.py
new file mode 100644
index 000000000..922945385
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/compliance_device_details_count_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ complianceType=dict(type="str"),
+ complianceStatus=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ compliance_type=params.get("complianceType"),
+ compliance_status=params.get("complianceStatus"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="compliance",
+ function='get_compliance_detail_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/compliance_device_details_info.py b/ansible_collections/cisco/dnac/plugins/action/compliance_device_details_info.py
new file mode 100644
index 000000000..4fedf1aab
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/compliance_device_details_info.py
@@ -0,0 +1,97 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ complianceType=dict(type="str"),
+ complianceStatus=dict(type="str"),
+ deviceUuid=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ compliance_type=params.get("complianceType"),
+ compliance_status=params.get("complianceStatus"),
+ device_uuid=params.get("deviceUuid"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="compliance",
+ function='get_compliance_detail',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/compliance_device_info.py b/ansible_collections/cisco/dnac/plugins/action/compliance_device_info.py
new file mode 100644
index 000000000..25d2db9cb
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/compliance_device_info.py
@@ -0,0 +1,106 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ complianceStatus=dict(type="str"),
+ deviceUuid=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ compliance_status=params.get("complianceStatus"),
+ device_uuid=params.get("deviceUuid"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("deviceUuid")
+ if id:
+ response = dnac.exec(
+ family="compliance",
+ function='device_compliance_status',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="compliance",
+ function='get_compliance_status',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/compliance_device_status_count_info.py b/ansible_collections/cisco/dnac/plugins/action/compliance_device_status_count_info.py
new file mode 100644
index 000000000..1e3121f4b
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/compliance_device_status_count_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ complianceStatus=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ compliance_status=params.get("complianceStatus"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="compliance",
+ function='get_compliance_status_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/configuration_template.py b/ansible_collections/cisco/dnac/plugins/action/configuration_template.py
new file mode 100644
index 000000000..149e672ad
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/configuration_template.py
@@ -0,0 +1,355 @@
+#!/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", "absent"]),
+ tags=dict(type="list"),
+ author=dict(type="str"),
+ composite=dict(type="bool"),
+ containingTemplates=dict(type="list"),
+ createTime=dict(type="int"),
+ customParamsOrder=dict(type="bool"),
+ description=dict(type="str"),
+ deviceTypes=dict(type="list"),
+ failurePolicy=dict(type="str"),
+ id=dict(type="str"),
+ language=dict(type="str"),
+ lastUpdateTime=dict(type="int"),
+ latestVersionTime=dict(type="int"),
+ name=dict(type="str"),
+ parentTemplateId=dict(type="str"),
+ projectId=dict(type="str"),
+ projectName=dict(type="str"),
+ rollbackTemplateContent=dict(type="str"),
+ rollbackTemplateParams=dict(type="list"),
+ softwareType=dict(type="str"),
+ softwareVariant=dict(type="str"),
+ softwareVersion=dict(type="str"),
+ templateContent=dict(type="str"),
+ templateParams=dict(type="list"),
+ validationErrors=dict(type="dict"),
+ version=dict(type="str"),
+ templateId=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["name", "templateId"], True),
+ ("state", "absent", ["name", "templateId"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ConfigurationTemplate(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ tags=params.get("tags"),
+ author=params.get("author"),
+ composite=params.get("composite"),
+ containingTemplates=params.get("containingTemplates"),
+ createTime=params.get("createTime"),
+ customParamsOrder=params.get("customParamsOrder"),
+ description=params.get("description"),
+ deviceTypes=params.get("deviceTypes"),
+ failurePolicy=params.get("failurePolicy"),
+ id=params.get("id"),
+ language=params.get("language"),
+ lastUpdateTime=params.get("lastUpdateTime"),
+ latestVersionTime=params.get("latestVersionTime"),
+ name=params.get("name"),
+ parentTemplateId=params.get("parentTemplateId"),
+ projectId=params.get("projectId"),
+ projectName=params.get("projectName"),
+ rollbackTemplateContent=params.get("rollbackTemplateContent"),
+ rollbackTemplateParams=params.get("rollbackTemplateParams"),
+ softwareType=params.get("softwareType"),
+ softwareVariant=params.get("softwareVariant"),
+ softwareVersion=params.get("softwareVersion"),
+ templateContent=params.get("templateContent"),
+ templateParams=params.get("templateParams"),
+ validationErrors=params.get("validationErrors"),
+ version=params.get("version"),
+ template_id=params.get("templateId"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['project_id'] = self.new_object.get('projectId') or \
+ self.new_object.get('project_id')
+ new_object_params['software_type'] = self.new_object.get('softwareType') or \
+ self.new_object.get('software_type')
+ new_object_params['software_version'] = self.new_object.get('softwareVersion') or \
+ self.new_object.get('software_version')
+ new_object_params['product_family'] = self.new_object.get('productFamily') or \
+ self.new_object.get('product_family')
+ new_object_params['product_series'] = self.new_object.get('productSeries') or \
+ self.new_object.get('product_series')
+ new_object_params['product_type'] = self.new_object.get('productType') or \
+ self.new_object.get('product_type')
+ new_object_params['filter_conflicting_templates'] = self.new_object.get('filterConflictingTemplates') or \
+ self.new_object.get('filter_conflicting_templates')
+ new_object_params['tags'] = self.new_object.get('tags')
+ new_object_params['project_names'] = self.new_object.get('projectName') or self.new_object.get('projectNames') or \
+ self.new_object.get('project_names')
+ new_object_params['un_committed'] = self.new_object.get('unCommitted') or \
+ self.new_object.get('un_committed')
+ new_object_params['sort_order'] = self.new_object.get('sortOrder') or \
+ self.new_object.get('sort_order')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['template_id'] = self.new_object.get('template_id')
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ 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['createTime'] = self.new_object.get('createTime')
+ 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['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['name'] = self.new_object.get('name')
+ 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['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['version'] = self.new_object.get('version')
+ 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="configuration_templates",
+ function="gets_the_templates_available",
+ 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="configuration_templates",
+ function="get_template_details",
+ params={"template_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")
+ o_id = o_id or self.new_object.get("template_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")
+ _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")
+ if _id:
+ self.new_object.update(dict(id=_id))
+ self.new_object.update(dict(template_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 = [
+ ("tags", "tags"),
+ ("author", "author"),
+ ("composite", "composite"),
+ ("containingTemplates", "containingTemplates"),
+ ("createTime", "createTime"),
+ ("customParamsOrder", "customParamsOrder"),
+ ("description", "description"),
+ ("deviceTypes", "deviceTypes"),
+ ("failurePolicy", "failurePolicy"),
+ ("id", "id"),
+ ("language", "language"),
+ ("lastUpdateTime", "lastUpdateTime"),
+ ("latestVersionTime", "latestVersionTime"),
+ ("name", "name"),
+ ("parentTemplateId", "parentTemplateId"),
+ ("projectId", "projectId"),
+ ("projectName", "projectName"),
+ ("rollbackTemplateContent", "rollbackTemplateContent"),
+ ("rollbackTemplateParams", "rollbackTemplateParams"),
+ ("softwareType", "softwareType"),
+ ("softwareVariant", "softwareVariant"),
+ ("softwareVersion", "softwareVersion"),
+ ("templateContent", "templateContent"),
+ ("templateParams", "templateParams"),
+ ("validationErrors", "validationErrors"),
+ ("version", "version"),
+ ("templateId", "template_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)
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="configuration_templates",
+ function="update_template",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ id = id or self.new_object.get("template_id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ id_ = id_ or prev_obj_name.get("templateId")
+ if id_:
+ self.new_object.update(dict(template_id=id_))
+ result = self.dnac.exec(
+ family="configuration_templates",
+ function="deletes_the_template",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = ConfigurationTemplate(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ dnac.fail_json("Object does not exists, plugin only has update")
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/configuration_template_clone.py b/ansible_collections/cisco/dnac/plugins/action/configuration_template_clone.py
new file mode 100644
index 000000000..e0a8b0d3e
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/configuration_template_clone.py
@@ -0,0 +1,90 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ name=dict(type="str"),
+ templateId=dict(type="str"),
+ projectId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ name=params.get("name"),
+ template_id=params.get("templateId"),
+ project_id=params.get("projectId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="configuration_templates",
+ function='clone_given_template',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/configuration_template_create.py b/ansible_collections/cisco/dnac/plugins/action/configuration_template_create.py
new file mode 100644
index 000000000..a2b45f267
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/configuration_template_create.py
@@ -0,0 +1,137 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ tags=dict(type="list"),
+ author=dict(type="str"),
+ composite=dict(type="bool"),
+ containingTemplates=dict(type="list"),
+ createTime=dict(type="int"),
+ customParamsOrder=dict(type="bool"),
+ description=dict(type="str"),
+ deviceTypes=dict(type="list"),
+ failurePolicy=dict(type="str"),
+ id=dict(type="str"),
+ language=dict(type="str"),
+ lastUpdateTime=dict(type="int"),
+ latestVersionTime=dict(type="int"),
+ name=dict(type="str"),
+ parentTemplateId=dict(type="str"),
+ projectId=dict(type="str"),
+ projectName=dict(type="str"),
+ rollbackTemplateContent=dict(type="str"),
+ rollbackTemplateParams=dict(type="list"),
+ softwareType=dict(type="str"),
+ softwareVariant=dict(type="str"),
+ softwareVersion=dict(type="str"),
+ templateContent=dict(type="str"),
+ templateParams=dict(type="list"),
+ validationErrors=dict(type="dict"),
+ version=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ tags=params.get("tags"),
+ author=params.get("author"),
+ composite=params.get("composite"),
+ containingTemplates=params.get("containingTemplates"),
+ createTime=params.get("createTime"),
+ customParamsOrder=params.get("customParamsOrder"),
+ description=params.get("description"),
+ deviceTypes=params.get("deviceTypes"),
+ failurePolicy=params.get("failurePolicy"),
+ id=params.get("id"),
+ language=params.get("language"),
+ lastUpdateTime=params.get("lastUpdateTime"),
+ latestVersionTime=params.get("latestVersionTime"),
+ name=params.get("name"),
+ parentTemplateId=params.get("parentTemplateId"),
+ projectId=params.get("projectId"),
+ projectName=params.get("projectName"),
+ rollbackTemplateContent=params.get("rollbackTemplateContent"),
+ rollbackTemplateParams=params.get("rollbackTemplateParams"),
+ softwareType=params.get("softwareType"),
+ softwareVariant=params.get("softwareVariant"),
+ softwareVersion=params.get("softwareVersion"),
+ templateContent=params.get("templateContent"),
+ templateParams=params.get("templateParams"),
+ validationErrors=params.get("validationErrors"),
+ version=params.get("version"),
+ project_id=params.get("projectId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="configuration_templates",
+ function='create_template',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/configuration_template_deploy.py b/ansible_collections/cisco/dnac/plugins/action/configuration_template_deploy.py
new file mode 100644
index 000000000..55b033a76
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/configuration_template_deploy.py
@@ -0,0 +1,96 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ forcePushTemplate=dict(type="bool"),
+ isComposite=dict(type="bool"),
+ mainTemplateId=dict(type="str"),
+ memberTemplateDeploymentInfo=dict(type="str"),
+ targetInfo=dict(type="list"),
+ templateId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ forcePushTemplate=params.get("forcePushTemplate"),
+ isComposite=params.get("isComposite"),
+ mainTemplateId=params.get("mainTemplateId"),
+ memberTemplateDeploymentInfo=params.get("memberTemplateDeploymentInfo"),
+ targetInfo=params.get("targetInfo"),
+ templateId=params.get("templateId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="configuration_templates",
+ function='deploy_template',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/configuration_template_deploy_status_info.py b/ansible_collections/cisco/dnac/plugins/action/configuration_template_deploy_status_info.py
new file mode 100644
index 000000000..735b5f93f
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/configuration_template_deploy_status_info.py
@@ -0,0 +1,98 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deploymentId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ deployment_id=params.get("deploymentId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("deploymentId")
+ if id:
+ response = dnac.exec(
+ family="configuration_templates",
+ function='get_template_deployment_status',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/configuration_template_deploy_v2.py b/ansible_collections/cisco/dnac/plugins/action/configuration_template_deploy_v2.py
new file mode 100644
index 000000000..802c84d98
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/configuration_template_deploy_v2.py
@@ -0,0 +1,96 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ forcePushTemplate=dict(type="bool"),
+ isComposite=dict(type="bool"),
+ mainTemplateId=dict(type="str"),
+ memberTemplateDeploymentInfo=dict(type="str"),
+ targetInfo=dict(type="list"),
+ templateId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ forcePushTemplate=params.get("forcePushTemplate"),
+ isComposite=params.get("isComposite"),
+ mainTemplateId=params.get("mainTemplateId"),
+ memberTemplateDeploymentInfo=params.get("memberTemplateDeploymentInfo"),
+ targetInfo=params.get("targetInfo"),
+ templateId=params.get("templateId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="configuration_templates",
+ function='deploy_template_v2',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/configuration_template_export_project.py b/ansible_collections/cisco/dnac/plugins/action/configuration_template_export_project.py
new file mode 100644
index 000000000..8b9d59255
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/configuration_template_export_project.py
@@ -0,0 +1,86 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ payload=dict(type="list"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ payload=params.get("payload"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="configuration_templates",
+ function='export_projects',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/configuration_template_export_template.py b/ansible_collections/cisco/dnac/plugins/action/configuration_template_export_template.py
new file mode 100644
index 000000000..cf5f70c50
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/configuration_template_export_template.py
@@ -0,0 +1,86 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ payload=dict(type="list"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ payload=params.get("payload"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="configuration_templates",
+ function='export_templates',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/configuration_template_import_project.py b/ansible_collections/cisco/dnac/plugins/action/configuration_template_import_project.py
new file mode 100644
index 000000000..1d75337e0
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/configuration_template_import_project.py
@@ -0,0 +1,86 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ doVersion=dict(type="bool"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ do_version=params.get("doVersion"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="configuration_templates",
+ function='imports_the_projects_provided',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/configuration_template_import_template.py b/ansible_collections/cisco/dnac/plugins/action/configuration_template_import_template.py
new file mode 100644
index 000000000..6ee6f6bb7
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/configuration_template_import_template.py
@@ -0,0 +1,90 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ payload=dict(type="list"),
+ projectName=dict(type="str"),
+ doVersion=dict(type="bool"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ payload=params.get("payload"),
+ project_name=params.get("projectName"),
+ do_version=params.get("doVersion"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="configuration_templates",
+ function='imports_the_templates_provided',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/configuration_template_info.py b/ansible_collections/cisco/dnac/plugins/action/configuration_template_info.py
new file mode 100644
index 000000000..6d7ddab49
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/configuration_template_info.py
@@ -0,0 +1,124 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ projectId=dict(type="str"),
+ softwareType=dict(type="str"),
+ softwareVersion=dict(type="str"),
+ productFamily=dict(type="str"),
+ productSeries=dict(type="str"),
+ productType=dict(type="str"),
+ filterConflictingTemplates=dict(type="bool"),
+ tags=dict(type="list"),
+ projectNames=dict(type="list"),
+ unCommitted=dict(type="bool"),
+ sortOrder=dict(type="str"),
+ templateId=dict(type="str"),
+ latestVersion=dict(type="bool"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ project_id=params.get("projectId"),
+ software_type=params.get("softwareType"),
+ software_version=params.get("softwareVersion"),
+ product_family=params.get("productFamily"),
+ product_series=params.get("productSeries"),
+ product_type=params.get("productType"),
+ filter_conflicting_templates=params.get("filterConflictingTemplates"),
+ tags=params.get("tags"),
+ project_names=params.get("projectNames"),
+ un_committed=params.get("unCommitted"),
+ sort_order=params.get("sortOrder"),
+ template_id=params.get("templateId"),
+ latest_version=params.get("latestVersion"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("templateId")
+ if id:
+ response = dnac.exec(
+ family="configuration_templates",
+ function='get_template_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="configuration_templates",
+ function='gets_the_templates_available',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/configuration_template_project.py b/ansible_collections/cisco/dnac/plugins/action/configuration_template_project.py
new file mode 100644
index 000000000..e6e356aa0
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/configuration_template_project.py
@@ -0,0 +1,284 @@
+#!/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", "absent"]),
+ tags=dict(type="list"),
+ createTime=dict(type="int"),
+ description=dict(type="str"),
+ id=dict(type="str"),
+ lastUpdateTime=dict(type="int"),
+ name=dict(type="str"),
+ templates=dict(type="dict"),
+ projectId=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["name", "projectId"], True),
+ ("state", "absent", ["name", "projectId"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ConfigurationTemplateProject(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ tags=params.get("tags"),
+ createTime=params.get("createTime"),
+ description=params.get("description"),
+ id=params.get("id"),
+ lastUpdateTime=params.get("lastUpdateTime"),
+ name=params.get("name"),
+ templates=params.get("templates"),
+ project_id=params.get("projectId"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['name'] = name or self.new_object.get('name')
+ new_object_params['sort_order'] = self.new_object.get('sortOrder') or \
+ self.new_object.get('sort_order')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['tags'] = self.new_object.get('tags')
+ 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['name'] = self.new_object.get('name')
+ new_object_params['templates'] = self.new_object.get('templates')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['project_id'] = self.new_object.get('project_id')
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['tags'] = self.new_object.get('tags')
+ 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['name'] = self.new_object.get('name')
+ new_object_params['templates'] = self.new_object.get('templates')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="configuration_templates",
+ function="get_projects",
+ 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="configuration_templates",
+ function="get_project_details",
+ params={"project_id": id}
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ result = get_dict_result(items, 'projectId', id)
+ except Exception:
+ result = None
+ return result
+
+ def exists(self):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ o_id = self.new_object.get("id")
+ o_id = o_id or self.new_object.get("project_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")
+ _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")
+ if _id:
+ self.new_object.update(dict(id=_id))
+ self.new_object.update(dict(project_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 = [
+ ("tags", "tags"),
+ ("createTime", "createTime"),
+ ("description", "description"),
+ ("id", "id"),
+ ("lastUpdateTime", "lastUpdateTime"),
+ ("name", "name"),
+ ("templates", "templates"),
+ ("projectId", "project_id"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="configuration_templates",
+ function="create_project",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="configuration_templates",
+ function="update_project",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ id = id or self.new_object.get("project_id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ id_ = id_ or prev_obj_name.get("projectId")
+ if id_:
+ self.new_object.update(dict(project_id=id_))
+ result = self.dnac.exec(
+ family="configuration_templates",
+ function="deletes_the_project",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = ConfigurationTemplateProject(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/configuration_template_project_info.py b/ansible_collections/cisco/dnac/plugins/action/configuration_template_project_info.py
new file mode 100644
index 000000000..02aa0343d
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/configuration_template_project_info.py
@@ -0,0 +1,104 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ name=dict(type="str"),
+ sortOrder=dict(type="str"),
+ projectId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ name=params.get("name"),
+ sort_order=params.get("sortOrder"),
+ project_id=params.get("projectId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("projectId")
+ if id:
+ response = dnac.exec(
+ family="configuration_templates",
+ function='get_project_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="configuration_templates",
+ function='get_projects',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/configuration_template_version_create.py b/ansible_collections/cisco/dnac/plugins/action/configuration_template_version_create.py
new file mode 100644
index 000000000..5471dc5bd
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/configuration_template_version_create.py
@@ -0,0 +1,88 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ comments=dict(type="str"),
+ templateId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ comments=params.get("comments"),
+ templateId=params.get("templateId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="configuration_templates",
+ function='version_template',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/configuration_template_version_info.py b/ansible_collections/cisco/dnac/plugins/action/configuration_template_version_info.py
new file mode 100644
index 000000000..6b8de881f
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/configuration_template_version_info.py
@@ -0,0 +1,98 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ templateId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ template_id=params.get("templateId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("templateId")
+ if id:
+ response = dnac.exec(
+ family="configuration_templates",
+ function='get_template_versions',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/credential_to_site_by_siteid_create_v2.py b/ansible_collections/cisco/dnac/plugins/action/credential_to_site_by_siteid_create_v2.py
new file mode 100644
index 000000000..9c20820a3
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/credential_to_site_by_siteid_create_v2.py
@@ -0,0 +1,98 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ cliId=dict(type="str"),
+ snmpV2ReadId=dict(type="str"),
+ snmpV2WriteId=dict(type="str"),
+ snmpV3Id=dict(type="str"),
+ httpRead=dict(type="str"),
+ httpWrite=dict(type="str"),
+ siteId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ cliId=params.get("cliId"),
+ snmpV2ReadId=params.get("snmpV2ReadId"),
+ snmpV2WriteId=params.get("snmpV2WriteId"),
+ snmpV3Id=params.get("snmpV3Id"),
+ httpRead=params.get("httpRead"),
+ httpWrite=params.get("httpWrite"),
+ site_id=params.get("siteId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function='assign_device_credential_to_site_v2',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_configurations_export.py b/ansible_collections/cisco/dnac/plugins/action/device_configurations_export.py
new file mode 100644
index 000000000..20c129b99
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_configurations_export.py
@@ -0,0 +1,88 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceId=dict(type="list"),
+ password=dict(type="str", no_log=True),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ deviceId=params.get("deviceId"),
+ password=params.get("password"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="configuration_archive",
+ function='export_device_configurations',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_credential_create.py b/ansible_collections/cisco/dnac/plugins/action/device_credential_create.py
new file mode 100644
index 000000000..37309e091
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_credential_create.py
@@ -0,0 +1,86 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ settings=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ settings=params.get("settings"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function='create_device_credentials',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_credential_delete.py b/ansible_collections/cisco/dnac/plugins/action/device_credential_delete.py
new file mode 100644
index 000000000..1b565ad95
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_credential_delete.py
@@ -0,0 +1,85 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function="delete_device_credential",
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_credential_info.py b/ansible_collections/cisco/dnac/plugins/action/device_credential_info.py
new file mode 100644
index 000000000..5293cc3c2
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_credential_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ site_id=params.get("siteId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function='get_device_credential_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_credential_update.py b/ansible_collections/cisco/dnac/plugins/action/device_credential_update.py
new file mode 100644
index 000000000..9af7a0b89
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_credential_update.py
@@ -0,0 +1,86 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ settings=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ settings=params.get("settings"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function='update_device_credentials',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_details_info.py b/ansible_collections/cisco/dnac/plugins/action/device_details_info.py
new file mode 100644
index 000000000..7a743804c
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_details_info.py
@@ -0,0 +1,93 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ timestamp=dict(type="str"),
+ searchBy=dict(type="str"),
+ identifier=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ timestamp=params.get("timestamp"),
+ search_by=params.get("searchBy"),
+ identifier=params.get("identifier"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_device_detail',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_enrichment_details_info.py b/ansible_collections/cisco/dnac/plugins/action/device_enrichment_details_info.py
new file mode 100644
index 000000000..89bf00ae0
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_enrichment_details_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_device_enrichment_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_family_identifiers_details_info.py b/ansible_collections/cisco/dnac/plugins/action/device_family_identifiers_details_info.py
new file mode 100644
index 000000000..5f40e7f37
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_family_identifiers_details_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="software_image_management_swim",
+ function='get_device_family_identifiers',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_health_info.py b/ansible_collections/cisco/dnac/plugins/action/device_health_info.py
new file mode 100644
index 000000000..68bd65bfe
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_health_info.py
@@ -0,0 +1,101 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceRole=dict(type="str"),
+ siteId=dict(type="str"),
+ health=dict(type="str"),
+ startTime=dict(type="int"),
+ endTime=dict(type="int"),
+ limit=dict(type="int"),
+ offset=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_role=params.get("deviceRole"),
+ site_id=params.get("siteId"),
+ health=params.get("health"),
+ start_time=params.get("startTime"),
+ end_time=params.get("endTime"),
+ limit=params.get("limit"),
+ offset=params.get("offset"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='devices',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_interface_by_ip_info.py b/ansible_collections/cisco/dnac/plugins/action/device_interface_by_ip_info.py
new file mode 100644
index 000000000..6c6faffc0
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_interface_by_ip_info.py
@@ -0,0 +1,98 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ ipAddress=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ ip_address=params.get("ipAddress"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("ipAddress")
+ if id:
+ response = dnac.exec(
+ family="devices",
+ function='get_interface_by_ip',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_interface_count_info.py b/ansible_collections/cisco/dnac/plugins/action/device_interface_count_info.py
new file mode 100644
index 000000000..c10bffe7c
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_interface_count_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_device_interface_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_interface_info.py b/ansible_collections/cisco/dnac/plugins/action/device_interface_info.py
new file mode 100644
index 000000000..085c24c71
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_interface_info.py
@@ -0,0 +1,108 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ lastInputTime=dict(type="str"),
+ lastOutputTime=dict(type="str"),
+ id=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ last_input_time=params.get("lastInputTime"),
+ last_output_time=params.get("lastOutputTime"),
+ id=params.get("id"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ if id:
+ response = dnac.exec(
+ family="devices",
+ function='get_interface_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="devices",
+ function='get_all_interfaces',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_interface_isis_info.py b/ansible_collections/cisco/dnac/plugins/action/device_interface_isis_info.py
new file mode 100644
index 000000000..b298a0eb4
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_interface_isis_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_isis_interfaces',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_interface_ospf_info.py b/ansible_collections/cisco/dnac/plugins/action/device_interface_ospf_info.py
new file mode 100644
index 000000000..b27e0f899
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_interface_ospf_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_ospf_interfaces',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_reboot_apreboot_info.py b/ansible_collections/cisco/dnac/plugins/action/device_reboot_apreboot_info.py
new file mode 100644
index 000000000..e42c86d1b
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_reboot_apreboot_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ parentTaskId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ parent_task_id=params.get("parentTaskId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="wireless",
+ function='get_access_point_reboot_task_result',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_replacement.py b/ansible_collections/cisco/dnac/plugins/action/device_replacement.py
new file mode 100644
index 000000000..061e83363
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_replacement.py
@@ -0,0 +1,237 @@
+#!/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"]),
+ payload=dict(type="list"),
+))
+
+required_if = [
+ ("state", "present", ["payload"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class DeviceReplacement(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ payload=params.get("payload"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['faulty_device_name'] = self.new_object.get('faultyDeviceName') or \
+ self.new_object.get('faulty_device_name')
+ new_object_params['faulty_device_platform'] = self.new_object.get('faultyDevicePlatform') or \
+ self.new_object.get('faulty_device_platform')
+ new_object_params['replacement_device_platform'] = self.new_object.get('replacementDevicePlatform') or \
+ self.new_object.get('replacement_device_platform')
+ new_object_params['faulty_device_serial_number'] = self.new_object.get('faultyDeviceSerialNumber') or \
+ self.new_object.get('faulty_device_serial_number')
+ new_object_params['replacement_device_serial_number'] = self.new_object.get('replacementDeviceSerialNumber') or \
+ self.new_object.get('replacement_device_serial_number')
+ new_object_params['replacement_status'] = self.new_object.get('replacementStatus') or \
+ self.new_object.get('replacement_status')
+ new_object_params['family'] = self.new_object.get('family')
+ new_object_params['sort_by'] = self.new_object.get('sortBy') or \
+ self.new_object.get('sort_by')
+ new_object_params['sort_order'] = self.new_object.get('sortOrder') or \
+ self.new_object.get('sort_order')
+ new_object_params['offset'] = self.new_object.get('offset')
+ new_object_params['limit'] = self.new_object.get('limit')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ 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="device_replacement",
+ function="return_replacement_devices_with_details",
+ 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
+ requested_obj = self.new_object.get('payload')
+ 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")
+ name = self.new_object.get("name") or requested_obj.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.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+
+ obj_params = [
+ ("creationTime", "creationTime"),
+ ("family", "family"),
+ ("faultyDeviceId", "faultyDeviceId"),
+ ("faultyDeviceName", "faultyDeviceName"),
+ ("faultyDevicePlatform", "faultyDevicePlatform"),
+ ("faultyDeviceSerialNumber", "faultyDeviceSerialNumber"),
+ ("id", "id"),
+ ("neighbourDeviceId", "neighbourDeviceId"),
+ ("networkReadinessTaskId", "networkReadinessTaskId"),
+ ("replacementDevicePlatform", "replacementDevicePlatform"),
+ ("replacementDeviceSerialNumber", "replacementDeviceSerialNumber"),
+ ("replacementStatus", "replacementStatus"),
+ ("replacementTime", "replacementTime"),
+ ("workflowId", "workflowId"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="device_replacement",
+ function="mark_device_for_replacement",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ requested_obj = self.new_object.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+ id = self.new_object.get("id") or requested_obj.get("id")
+ name = self.new_object.get("name") or requested_obj.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="device_replacement",
+ function="unmark_device_for_replacement",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = DeviceReplacement(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_replacement_count_info.py b/ansible_collections/cisco/dnac/plugins/action/device_replacement_count_info.py
new file mode 100644
index 000000000..51ca83964
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_replacement_count_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ replacementStatus=dict(type="list"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ replacement_status=params.get("replacementStatus"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_replacement",
+ function='return_replacement_devices_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_replacement_deploy.py b/ansible_collections/cisco/dnac/plugins/action/device_replacement_deploy.py
new file mode 100644
index 000000000..c6776a3cc
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_replacement_deploy.py
@@ -0,0 +1,88 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ faultyDeviceSerialNumber=dict(type="str"),
+ replacementDeviceSerialNumber=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ faultyDeviceSerialNumber=params.get("faultyDeviceSerialNumber"),
+ replacementDeviceSerialNumber=params.get("replacementDeviceSerialNumber"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_replacement",
+ function='deploy_device_replacement_workflow',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/device_replacement_info.py b/ansible_collections/cisco/dnac/plugins/action/device_replacement_info.py
new file mode 100644
index 000000000..2a3ecf124
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/device_replacement_info.py
@@ -0,0 +1,109 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ faultyDeviceName=dict(type="str"),
+ faultyDevicePlatform=dict(type="str"),
+ replacementDevicePlatform=dict(type="str"),
+ faultyDeviceSerialNumber=dict(type="str"),
+ replacementDeviceSerialNumber=dict(type="str"),
+ replacementStatus=dict(type="list"),
+ family=dict(type="list"),
+ sortBy=dict(type="str"),
+ sortOrder=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 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"),
+ faulty_device_serial_number=params.get("faultyDeviceSerialNumber"),
+ replacement_device_serial_number=params.get("replacementDeviceSerialNumber"),
+ replacement_status=params.get("replacementStatus"),
+ family=params.get("family"),
+ sort_by=params.get("sortBy"),
+ sort_order=params.get("sortOrder"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_replacement",
+ function='return_replacement_devices_with_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/disassociate_site_to_network_profile.py b/ansible_collections/cisco/dnac/plugins/action/disassociate_site_to_network_profile.py
new file mode 100644
index 000000000..8598531b6
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/disassociate_site_to_network_profile.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ networkProfileId=dict(type="str"),
+ siteId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ network_profile_id=params.get("networkProfileId"),
+ site_id=params.get("siteId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="site_design",
+ function="disassociate",
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/disasterrecovery_system_operationstatus_info.py b/ansible_collections/cisco/dnac/plugins/action/disasterrecovery_system_operationstatus_info.py
new file mode 100644
index 000000000..ad522bbc0
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/disasterrecovery_system_operationstatus_info.py
@@ -0,0 +1,90 @@
+#!/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, Display
+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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ Display().warning("This module is currently unmaintained "
+ "and will be removed in future releases.")
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="disaster_recovery",
+ function='disaster_recovery_operational_status',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/disasterrecovery_system_status_info.py b/ansible_collections/cisco/dnac/plugins/action/disasterrecovery_system_status_info.py
new file mode 100644
index 000000000..aa57427d3
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/disasterrecovery_system_status_info.py
@@ -0,0 +1,90 @@
+#!/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, Display
+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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ Display().warning("This module is currently unmaintained "
+ "and will be removed in future releases.")
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="disaster_recovery",
+ function='disaster_recovery_status',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/discovery.py b/ansible_collections/cisco/dnac/plugins/action/discovery.py
new file mode 100644
index 000000000..b06a6a61c
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/discovery.py
@@ -0,0 +1,443 @@
+#!/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", "absent"]),
+ cdpLevel=dict(type="int"),
+ discoveryType=dict(type="str"),
+ enablePasswordList=dict(type="list", no_log=True),
+ globalCredentialIdList=dict(type="list"),
+ httpReadCredential=dict(type="dict"),
+ httpWriteCredential=dict(type="dict"),
+ ipAddressList=dict(type="str"),
+ ipFilterList=dict(type="list"),
+ lldpLevel=dict(type="int"),
+ name=dict(type="str"),
+ netconfPort=dict(type="str"),
+ passwordList=dict(type="list", no_log=True),
+ preferredMgmtIPMethod=dict(type="str"),
+ protocolOrder=dict(type="str"),
+ retry=dict(type="int"),
+ snmpAuthPassphrase=dict(type="str"),
+ snmpAuthProtocol=dict(type="str"),
+ snmpMode=dict(type="str"),
+ snmpPrivPassphrase=dict(type="str"),
+ snmpPrivProtocol=dict(type="str"),
+ snmpROCommunity=dict(type="str"),
+ snmpROCommunityDesc=dict(type="str"),
+ snmpRWCommunity=dict(type="str"),
+ snmpRWCommunityDesc=dict(type="str"),
+ snmpUserName=dict(type="str"),
+ snmpVersion=dict(type="str"),
+ timeout=dict(type="int"),
+ userNameList=dict(type="list"),
+ id=dict(type="str"),
+ attributeInfo=dict(type="dict"),
+ deviceIds=dict(type="str"),
+ discoveryCondition=dict(type="str"),
+ discoveryStatus=dict(type="str"),
+ isAutoCdp=dict(type="bool"),
+ numDevices=dict(type="int"),
+ parentDiscoveryId=dict(type="str"),
+ retryCount=dict(type="int"),
+ snmpRoCommunity=dict(type="str"),
+ snmpRoCommunityDesc=dict(type="str"),
+ snmpRwCommunity=dict(type="str"),
+ snmpRwCommunityDesc=dict(type="str"),
+ timeOut=dict(type="int"),
+ updateMgmtIp=dict(type="bool"),
+))
+
+required_if = [
+ ("state", "present", ["id", "name"], True),
+ ("state", "absent", ["id", "name"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class Discovery(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ cdpLevel=params.get("cdpLevel"),
+ discoveryType=params.get("discoveryType"),
+ enablePasswordList=params.get("enablePasswordList"),
+ globalCredentialIdList=params.get("globalCredentialIdList"),
+ httpReadCredential=params.get("httpReadCredential"),
+ httpWriteCredential=params.get("httpWriteCredential"),
+ ipAddressList=params.get("ipAddressList"),
+ ipFilterList=params.get("ipFilterList"),
+ lldpLevel=params.get("lldpLevel"),
+ name=params.get("name"),
+ netconfPort=params.get("netconfPort"),
+ passwordList=params.get("passwordList"),
+ preferredMgmtIPMethod=params.get("preferredMgmtIPMethod"),
+ protocolOrder=params.get("protocolOrder"),
+ retry=params.get("retry"),
+ snmpAuthPassphrase=params.get("snmpAuthPassphrase"),
+ snmpAuthProtocol=params.get("snmpAuthProtocol"),
+ snmpMode=params.get("snmpMode"),
+ snmpPrivPassphrase=params.get("snmpPrivPassphrase"),
+ snmpPrivProtocol=params.get("snmpPrivProtocol"),
+ snmpROCommunity=params.get("snmpROCommunity"),
+ snmpROCommunityDesc=params.get("snmpROCommunityDesc"),
+ snmpRWCommunity=params.get("snmpRWCommunity"),
+ snmpRWCommunityDesc=params.get("snmpRWCommunityDesc"),
+ snmpUserName=params.get("snmpUserName"),
+ snmpVersion=params.get("snmpVersion"),
+ timeout=params.get("timeout"),
+ userNameList=params.get("userNameList"),
+ id=params.get("id"),
+ attributeInfo=params.get("attributeInfo"),
+ deviceIds=params.get("deviceIds"),
+ discoveryCondition=params.get("discoveryCondition"),
+ discoveryStatus=params.get("discoveryStatus"),
+ isAutoCdp=params.get("isAutoCdp"),
+ numDevices=params.get("numDevices"),
+ parentDiscoveryId=params.get("parentDiscoveryId"),
+ retryCount=params.get("retryCount"),
+ snmpRoCommunity=params.get("snmpRoCommunity"),
+ snmpRoCommunityDesc=params.get("snmpRoCommunityDesc"),
+ snmpRwCommunity=params.get("snmpRwCommunity"),
+ snmpRwCommunityDesc=params.get("snmpRwCommunityDesc"),
+ timeOut=params.get("timeOut"),
+ updateMgmtIp=params.get("updateMgmtIp"),
+ )
+
+ 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['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['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['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['snmpUserName'] = self.new_object.get('snmpUserName')
+ new_object_params['snmpVersion'] = self.new_object.get('snmpVersion')
+ new_object_params['timeout'] = self.new_object.get('timeout')
+ new_object_params['userNameList'] = self.new_object.get('userNameList')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['id'] = self.new_object.get('id')
+ return new_object_params
+
+ def convert_list_string(self, pList):
+ if isinstance(pList, list):
+ if len(pList) > 0:
+ pList_str = list(map(str, pList))
+ return ', '.join(pList_str)
+ else:
+ return ''
+ else:
+ return pList
+
+ def update_all_params(self):
+ new_object_params = {}
+ 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.convert_list_string(
+ 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['ipFilterList'] = self.convert_list_string(
+ 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['passwordList'] = self.convert_list_string(
+ 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['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['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['snmpUserName'] = self.new_object.get('snmpUserName')
+ new_object_params['timeOut'] = self.new_object.get('timeOut')
+ new_object_params['updateMgmtIp'] = self.new_object.get('updateMgmtIp')
+ new_object_params['userNameList'] = self.convert_list_string(
+ self.new_object.get('userNameList')
+ )
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ # NOTE: Does not have get all
+ return result
+
+ def get_object_by_id(self, id):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="discovery",
+ function="get_discovery_by_id",
+ 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):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ 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 = dict(self.new_object)
+
+ for key in requested_obj.keys():
+ if key in ['ipFilterList', 'userNameList']:
+ requested_obj[key] = self.convert_list_string(requested_obj.get(key))
+
+ obj_params = [
+ ("cdpLevel", "cdpLevel"),
+ ("discoveryType", "discoveryType"),
+ ("globalCredentialIdList", "globalCredentialIdList"),
+ ("httpReadCredential", "httpReadCredential"),
+ ("httpWriteCredential", "httpWriteCredential"),
+ ("ipAddressList", "ipAddressList"),
+ ("ipFilterList", "ipFilterList"),
+ ("lldpLevel", "lldpLevel"),
+ ("name", "name"),
+ ("netconfPort", "netconfPort"),
+ ("preferredMgmtIPMethod", "preferredMgmtIPMethod"),
+ ("protocolOrder", "protocolOrder"),
+ ("retry", "retry"),
+ ("snmpAuthPassphrase", "snmpAuthPassphrase"),
+ ("snmpAuthProtocol", "snmpAuthProtocol"),
+ ("snmpMode", "snmpMode"),
+ ("snmpPrivPassphrase", "snmpPrivPassphrase"),
+ ("snmpPrivProtocol", "snmpPrivProtocol"),
+ ("snmpROCommunity", "snmpROCommunity"),
+ ("snmpROCommunityDesc", "snmpROCommunityDesc"),
+ ("snmpRWCommunity", "snmpRWCommunity"),
+ ("snmpRWCommunityDesc", "snmpRWCommunityDesc"),
+ ("snmpUserName", "snmpUserName"),
+ ("snmpVersion", "snmpVersion"),
+ ("timeout", "timeout"),
+ ("userNameList", "userNameList"),
+ ("id", "id"),
+ ("attributeInfo", "attributeInfo"),
+ ("deviceIds", "deviceIds"),
+ ("discoveryCondition", "discoveryCondition"),
+ ("discoveryStatus", "discoveryStatus"),
+ ("isAutoCdp", "isAutoCdp"),
+ ("numDevices", "numDevices"),
+ ("parentDiscoveryId", "parentDiscoveryId"),
+ ("retryCount", "retryCount"),
+ ("snmpRoCommunity", "snmpRoCommunity"),
+ ("snmpRoCommunityDesc", "snmpRoCommunityDesc"),
+ ("snmpRwCommunity", "snmpRwCommunity"),
+ ("snmpRwCommunityDesc", "snmpRwCommunityDesc"),
+ ("timeOut", "timeOut"),
+ ("updateMgmtIp", "updateMgmtIp"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="discovery",
+ function="start_discovery",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ if id_:
+ self.new_object.update(dict(id=id_))
+ result = self.dnac.exec(
+ family="discovery",
+ function="updates_discovery_by_id",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ if id_:
+ self.new_object.update(dict(id=id_))
+ result = self.dnac.exec(
+ family="discovery",
+ function="delete_discovery_by_id",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = Discovery(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/discovery_count_info.py b/ansible_collections/cisco/dnac/plugins/action/discovery_count_info.py
new file mode 100644
index 000000000..6332cb958
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/discovery_count_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="discovery",
+ function='get_count_of_all_discovery_jobs',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/discovery_device_count_info.py b/ansible_collections/cisco/dnac/plugins/action/discovery_device_count_info.py
new file mode 100644
index 000000000..cc72e8895
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/discovery_device_count_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+ taskId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ task_id=params.get("taskId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="discovery",
+ function='get_devices_discovered_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/discovery_device_info.py b/ansible_collections/cisco/dnac/plugins/action/discovery_device_info.py
new file mode 100644
index 000000000..ce466c5da
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/discovery_device_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+ taskId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ task_id=params.get("taskId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="discovery",
+ function='get_discovered_network_devices_by_discovery_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/discovery_device_range_info.py b/ansible_collections/cisco/dnac/plugins/action/discovery_device_range_info.py
new file mode 100644
index 000000000..fe566198b
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/discovery_device_range_info.py
@@ -0,0 +1,95 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+ startIndex=dict(type="int"),
+ recordsToReturn=dict(type="int"),
+ taskId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ start_index=params.get("startIndex"),
+ records_to_return=params.get("recordsToReturn"),
+ task_id=params.get("taskId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="discovery",
+ function='get_discovered_devices_by_range',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/discovery_info.py b/ansible_collections/cisco/dnac/plugins/action/discovery_info.py
new file mode 100644
index 000000000..7ccd6be9c
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/discovery_info.py
@@ -0,0 +1,98 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ if id:
+ response = dnac.exec(
+ family="discovery",
+ function='get_discovery_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/discovery_job_info.py b/ansible_collections/cisco/dnac/plugins/action/discovery_job_info.py
new file mode 100644
index 000000000..d820a51ea
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/discovery_job_info.py
@@ -0,0 +1,108 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ ipAddress=dict(type="str"),
+ name=dict(type="str"),
+ id=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ ip_address=params.get("ipAddress"),
+ name=params.get("name"),
+ id=params.get("id"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ if id:
+ response = dnac.exec(
+ family="discovery",
+ function='get_list_of_discoveries_by_discovery_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="discovery",
+ function='get_discovery_jobs_by_ip',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/discovery_range_delete.py b/ansible_collections/cisco/dnac/plugins/action/discovery_range_delete.py
new file mode 100644
index 000000000..f9e3da000
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/discovery_range_delete.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ startIndex=dict(type="int"),
+ recordsToDelete=dict(type="int"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ start_index=params.get("startIndex"),
+ records_to_delete=params.get("recordsToDelete"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="discovery",
+ function="delete_discovery_by_specified_range",
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/discovery_range_info.py b/ansible_collections/cisco/dnac/plugins/action/discovery_range_info.py
new file mode 100644
index 000000000..b90f7cb14
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/discovery_range_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ startIndex=dict(type="int"),
+ recordsToReturn=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ start_index=params.get("startIndex"),
+ records_to_return=params.get("recordsToReturn"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="discovery",
+ function='get_discoveries_by_range',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/discovery_summary_info.py b/ansible_collections/cisco/dnac/plugins/action/discovery_summary_info.py
new file mode 100644
index 000000000..9b64187b2
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/discovery_summary_info.py
@@ -0,0 +1,107 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+ taskId=dict(type="str"),
+ sortBy=dict(type="str"),
+ sortOrder=dict(type="str"),
+ ipAddress=dict(type="list"),
+ pingStatus=dict(type="list"),
+ snmpStatus=dict(type="list"),
+ cliStatus=dict(type="list"),
+ netconfStatus=dict(type="list"),
+ httpStatus=dict(type="list"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ task_id=params.get("taskId"),
+ sort_by=params.get("sortBy"),
+ sort_order=params.get("sortOrder"),
+ ip_address=params.get("ipAddress"),
+ ping_status=params.get("pingStatus"),
+ snmp_status=params.get("snmpStatus"),
+ cli_status=params.get("cliStatus"),
+ netconf_status=params.get("netconfStatus"),
+ http_status=params.get("httpStatus"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="discovery",
+ function='get_network_devices_from_discovery',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/dna_command_runner_keywords_info.py b/ansible_collections/cisco/dnac/plugins/action/dna_command_runner_keywords_info.py
new file mode 100644
index 000000000..aa942f1bb
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/dna_command_runner_keywords_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="command_runner",
+ function='get_all_keywords_of_clis_accepted',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/dnac_packages_info.py b/ansible_collections/cisco/dnac/plugins/action/dnac_packages_info.py
new file mode 100644
index 000000000..04d7c84de
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/dnac_packages_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="platform",
+ function='cisco_dna_center_packages_summary',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/dnacaap_management_execution_status_info.py b/ansible_collections/cisco/dnac/plugins/action/dnacaap_management_execution_status_info.py
new file mode 100644
index 000000000..e416fc357
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/dnacaap_management_execution_status_info.py
@@ -0,0 +1,98 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ executionId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ execution_id=params.get("executionId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("executionId")
+ if id:
+ response = dnac.exec(
+ family="task",
+ function='get_business_api_execution_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/endpoint_analytics_profiling_rules.py b/ansible_collections/cisco/dnac/plugins/action/endpoint_analytics_profiling_rules.py
new file mode 100644
index 000000000..24204ba7a
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/endpoint_analytics_profiling_rules.py
@@ -0,0 +1,332 @@
+#!/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, Display
+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", "absent"]),
+ ruleId=dict(type="str"),
+ ruleName=dict(type="str"),
+ ruleType=dict(type="str"),
+ ruleVersion=dict(type="int"),
+ rulePriority=dict(type="int"),
+ sourcePriority=dict(type="int"),
+ isDeleted=dict(type="bool"),
+ lastModifiedBy=dict(type="str"),
+ lastModifiedOn=dict(type="int"),
+ pluginId=dict(type="str"),
+ clusterId=dict(type="str"),
+ rejected=dict(type="bool"),
+ result=dict(type="dict"),
+ conditionGroups=dict(type="dict"),
+ usedAttributes=dict(type="list"),
+))
+
+required_if = [
+ ("state", "present", ["ruleId"], True),
+ ("state", "absent", ["ruleId"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class EndpointAnalyticsProfilingRules(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ ruleId=params.get("ruleId"),
+ ruleName=params.get("ruleName"),
+ ruleType=params.get("ruleType"),
+ ruleVersion=params.get("ruleVersion"),
+ rulePriority=params.get("rulePriority"),
+ sourcePriority=params.get("sourcePriority"),
+ isDeleted=params.get("isDeleted"),
+ lastModifiedBy=params.get("lastModifiedBy"),
+ lastModifiedOn=params.get("lastModifiedOn"),
+ pluginId=params.get("pluginId"),
+ clusterId=params.get("clusterId"),
+ rejected=params.get("rejected"),
+ result=params.get("result"),
+ conditionGroups=params.get("conditionGroups"),
+ usedAttributes=params.get("usedAttributes"),
+ rule_id=params.get("ruleId"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['rule_type'] = self.new_object.get('ruleType')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['ruleId'] = self.new_object.get('ruleId')
+ new_object_params['ruleName'] = self.new_object.get('ruleName')
+ 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['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['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')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['rule_id'] = self.new_object.get('rule_id')
+ return new_object_params
+
+ def update_by_id_params(self):
+ new_object_params = {}
+ new_object_params['ruleId'] = self.new_object.get('ruleId')
+ new_object_params['ruleName'] = self.new_object.get('ruleName')
+ 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['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['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')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTICE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="policy",
+ function="get_list_of_profiling_rules",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, dict):
+ items = items['profilingRules']
+ 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="policy",
+ function="get_details_of_a_single_profiling_rule",
+ params={"rule_id": id}
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ result = get_dict_result(items, 'ruleId', id)
+ except Exception:
+ result = None
+ return result
+
+ def exists(self):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ o_id = self.new_object.get("id")
+ o_id = o_id or self.new_object.get("rule_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")
+ _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")
+ if _id:
+ self.new_object.update(dict(id=_id))
+ self.new_object.update(dict(rule_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 = [
+ ("ruleId", "ruleId"),
+ ("ruleName", "ruleName"),
+ ("ruleType", "ruleType"),
+ ("ruleVersion", "ruleVersion"),
+ ("rulePriority", "rulePriority"),
+ ("sourcePriority", "sourcePriority"),
+ ("isDeleted", "isDeleted"),
+ ("lastModifiedBy", "lastModifiedBy"),
+ ("lastModifiedOn", "lastModifiedOn"),
+ ("pluginId", "pluginId"),
+ ("clusterId", "clusterId"),
+ ("rejected", "rejected"),
+ ("result", "result"),
+ ("conditionGroups", "conditionGroups"),
+ ("usedAttributes", "usedAttributes"),
+ ("ruleId", "rule_id"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="policy",
+ function="create_a_profiling_rule",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ id = id or self.new_object.get("rule_id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ id_ = id_ or prev_obj_name.get("ruleId")
+ if id_:
+ self.new_object.update(dict(rule_id=id_))
+ result = self.dnac.exec(
+ family="policy",
+ function="update_an_existing_profiling_rule",
+ params=self.update_by_id_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ id = id or self.new_object.get("rule_id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ id_ = id_ or prev_obj_name.get("ruleId")
+ if id_:
+ self.new_object.update(dict(rule_id=id_))
+ result = self.dnac.exec(
+ family="policy",
+ function="delete_an_existing_profiling_rule",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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()
+
+ Display().warning("This module is currently unmaintained "
+ "and will be removed in future releases.")
+
+ dnac = DNACSDK(self._task.args)
+ obj = EndpointAnalyticsProfilingRules(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/endpoint_analytics_profiling_rules_info.py b/ansible_collections/cisco/dnac/plugins/action/endpoint_analytics_profiling_rules_info.py
new file mode 100644
index 000000000..4874701e7
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/endpoint_analytics_profiling_rules_info.py
@@ -0,0 +1,115 @@
+#!/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, Display
+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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ ruleType=dict(type="str"),
+ includeDeleted=dict(type="bool"),
+ limit=dict(type="int"),
+ offset=dict(type="int"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ ruleId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ rule_type=params.get("ruleType"),
+ include_deleted=params.get("includeDeleted"),
+ limit=params.get("limit"),
+ offset=params.get("offset"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ rule_id=params.get("ruleId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ Display().warning("This module is currently unmaintained "
+ "and will be removed in future releases.")
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("ruleId")
+ if id:
+ response = dnac.exec(
+ family="policy",
+ function='get_details_of_a_single_profiling_rule',
+ params=self.get_object(self._task.args)
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="policy",
+ function='get_list_of_profiling_rules',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/eox_status_device_info.py b/ansible_collections/cisco/dnac/plugins/action/eox_status_device_info.py
new file mode 100644
index 000000000..06ef71e8b
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/eox_status_device_info.py
@@ -0,0 +1,100 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_id=params.get("deviceId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("deviceId")
+ if id:
+ response = dnac.exec(
+ family="eo_x",
+ function='get_eo_x_details_per_device',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="eo_x",
+ function='get_eo_x_status_for_all_devices',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/eox_status_summary_info.py b/ansible_collections/cisco/dnac/plugins/action/eox_status_summary_info.py
new file mode 100644
index 000000000..5b449d662
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/eox_status_summary_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="eo_x",
+ function='get_eo_x_summary',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_api_status_info.py b/ansible_collections/cisco/dnac/plugins/action/event_api_status_info.py
new file mode 100644
index 000000000..3d3ff3ca7
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_api_status_info.py
@@ -0,0 +1,98 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ executionId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ execution_id=params.get("executionId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("executionId")
+ if id:
+ response = dnac.exec(
+ family="event_management",
+ function='get_status_api_for_events',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_artifact_count_info.py b/ansible_collections/cisco/dnac/plugins/action/event_artifact_count_info.py
new file mode 100644
index 000000000..61943ead7
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_artifact_count_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='eventartifact_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_artifact_info.py b/ansible_collections/cisco/dnac/plugins/action/event_artifact_info.py
new file mode 100644
index 000000000..4376fd4f0
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_artifact_info.py
@@ -0,0 +1,101 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ eventIds=dict(type="str"),
+ tags=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ search=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ event_ids=params.get("eventIds"),
+ tags=params.get("tags"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ search=params.get("search"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='get_eventartifacts',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_config_connector_types_info.py b/ansible_collections/cisco/dnac/plugins/action/event_config_connector_types_info.py
new file mode 100644
index 000000000..27199b87e
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_config_connector_types_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='get_connector_types',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_count_info.py b/ansible_collections/cisco/dnac/plugins/action/event_count_info.py
new file mode 100644
index 000000000..43df02cb4
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_count_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ eventId=dict(type="str"),
+ tags=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ event_id=params.get("eventId"),
+ tags=params.get("tags"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='count_of_events',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_email_config.py b/ansible_collections/cisco/dnac/plugins/action/event_email_config.py
new file mode 100644
index 000000000..a80fe0eb0
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_email_config.py
@@ -0,0 +1,221 @@
+#!/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"]),
+ emailConfigId=dict(type="str"),
+ primarySMTPConfig=dict(type="dict"),
+ secondarySMTPConfig=dict(type="dict"),
+ fromEmail=dict(type="str"),
+ toEmail=dict(type="str"),
+ subject=dict(type="str"),
+))
+
+required_if = [
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class EventEmailConfig(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ emailConfigId=params.get("emailConfigId"),
+ primarySMTPConfig=params.get("primarySMTPConfig"),
+ secondarySMTPConfig=params.get("secondarySMTPConfig"),
+ fromEmail=params.get("fromEmail"),
+ toEmail=params.get("toEmail"),
+ subject=params.get("subject"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ return new_object_params
+
+ 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['fromEmail'] = self.new_object.get('fromEmail')
+ new_object_params['toEmail'] = self.new_object.get('toEmail')
+ new_object_params['subject'] = self.new_object.get('subject')
+ return new_object_params
+
+ 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['fromEmail'] = self.new_object.get('fromEmail')
+ new_object_params['toEmail'] = self.new_object.get('toEmail')
+ new_object_params['subject'] = self.new_object.get('subject')
+ 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="event_management",
+ function="get_email_destination",
+ 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 = [
+ ("emailConfigId", "emailConfigId"),
+ ("primarySMTPConfig", "primarySMTPConfig"),
+ ("secondarySMTPConfig", "secondarySMTPConfig"),
+ ("fromEmail", "fromEmail"),
+ ("toEmail", "toEmail"),
+ ("subject", "subject"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="event_management",
+ function="create_email_destination",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="event_management",
+ function="update_email_destination",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = EventEmailConfig(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_email_config_create.py b/ansible_collections/cisco/dnac/plugins/action/event_email_config_create.py
new file mode 100644
index 000000000..45eff9e1e
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_email_config_create.py
@@ -0,0 +1,96 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ emailConfigId=dict(type="str"),
+ primarySMTPConfig=dict(type="dict"),
+ secondarySMTPConfig=dict(type="dict"),
+ fromEmail=dict(type="str"),
+ toEmail=dict(type="str"),
+ subject=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ emailConfigId=params.get("emailConfigId"),
+ primarySMTPConfig=params.get("primarySMTPConfig"),
+ secondarySMTPConfig=params.get("secondarySMTPConfig"),
+ fromEmail=params.get("fromEmail"),
+ toEmail=params.get("toEmail"),
+ subject=params.get("subject"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='create_email_destination',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_email_config_info.py b/ansible_collections/cisco/dnac/plugins/action/event_email_config_info.py
new file mode 100644
index 000000000..1e380d1ae
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_email_config_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='get_email_destination',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_email_config_update.py b/ansible_collections/cisco/dnac/plugins/action/event_email_config_update.py
new file mode 100644
index 000000000..342878381
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_email_config_update.py
@@ -0,0 +1,96 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ emailConfigId=dict(type="str"),
+ primarySMTPConfig=dict(type="dict"),
+ secondarySMTPConfig=dict(type="dict"),
+ fromEmail=dict(type="str"),
+ toEmail=dict(type="str"),
+ subject=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ emailConfigId=params.get("emailConfigId"),
+ primarySMTPConfig=params.get("primarySMTPConfig"),
+ secondarySMTPConfig=params.get("secondarySMTPConfig"),
+ fromEmail=params.get("fromEmail"),
+ toEmail=params.get("toEmail"),
+ subject=params.get("subject"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='update_email_destination',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_info.py b/ansible_collections/cisco/dnac/plugins/action/event_info.py
new file mode 100644
index 000000000..d22c13f36
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_info.py
@@ -0,0 +1,99 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ eventId=dict(type="str"),
+ tags=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ event_id=params.get("eventId"),
+ tags=params.get("tags"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='get_events',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_series_audit_logs_info.py b/ansible_collections/cisco/dnac/plugins/action/event_series_audit_logs_info.py
new file mode 100644
index 000000000..a2f85bacd
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_series_audit_logs_info.py
@@ -0,0 +1,131 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ parentInstanceId=dict(type="str"),
+ instanceId=dict(type="str"),
+ name=dict(type="str"),
+ eventId=dict(type="str"),
+ category=dict(type="str"),
+ severity=dict(type="str"),
+ domain=dict(type="str"),
+ subDomain=dict(type="str"),
+ source=dict(type="str"),
+ userId=dict(type="str"),
+ context=dict(type="str"),
+ eventHierarchy=dict(type="str"),
+ siteId=dict(type="str"),
+ deviceId=dict(type="str"),
+ isSystemEvents=dict(type="bool"),
+ description=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ startTime=dict(type="int"),
+ endTime=dict(type="int"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ parent_instance_id=params.get("parentInstanceId"),
+ instance_id=params.get("instanceId"),
+ name=params.get("name"),
+ event_id=params.get("eventId"),
+ category=params.get("category"),
+ severity=params.get("severity"),
+ domain=params.get("domain"),
+ sub_domain=params.get("subDomain"),
+ source=params.get("source"),
+ user_id=params.get("userId"),
+ context=params.get("context"),
+ event_hierarchy=params.get("eventHierarchy"),
+ site_id=params.get("siteId"),
+ device_id=params.get("deviceId"),
+ is_system_events=params.get("isSystemEvents"),
+ description=params.get("description"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ start_time=params.get("startTime"),
+ end_time=params.get("endTime"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='get_auditlog_records',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_series_audit_logs_parent_records_info.py b/ansible_collections/cisco/dnac/plugins/action/event_series_audit_logs_parent_records_info.py
new file mode 100644
index 000000000..b9839c20f
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_series_audit_logs_parent_records_info.py
@@ -0,0 +1,129 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ instanceId=dict(type="str"),
+ name=dict(type="str"),
+ eventId=dict(type="str"),
+ category=dict(type="str"),
+ severity=dict(type="str"),
+ domain=dict(type="str"),
+ subDomain=dict(type="str"),
+ source=dict(type="str"),
+ userId=dict(type="str"),
+ context=dict(type="str"),
+ eventHierarchy=dict(type="str"),
+ siteId=dict(type="str"),
+ deviceId=dict(type="str"),
+ isSystemEvents=dict(type="bool"),
+ description=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ startTime=dict(type="int"),
+ endTime=dict(type="int"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ instance_id=params.get("instanceId"),
+ name=params.get("name"),
+ event_id=params.get("eventId"),
+ category=params.get("category"),
+ severity=params.get("severity"),
+ domain=params.get("domain"),
+ sub_domain=params.get("subDomain"),
+ source=params.get("source"),
+ user_id=params.get("userId"),
+ context=params.get("context"),
+ event_hierarchy=params.get("eventHierarchy"),
+ site_id=params.get("siteId"),
+ device_id=params.get("deviceId"),
+ is_system_events=params.get("isSystemEvents"),
+ description=params.get("description"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ start_time=params.get("startTime"),
+ end_time=params.get("endTime"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='get_auditlog_parent_records',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_series_audit_logs_summary_info.py b/ansible_collections/cisco/dnac/plugins/action/event_series_audit_logs_summary_info.py
new file mode 100644
index 000000000..42d15ac74
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_series_audit_logs_summary_info.py
@@ -0,0 +1,125 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ parentInstanceId=dict(type="str"),
+ isParentOnly=dict(type="bool"),
+ instanceId=dict(type="str"),
+ name=dict(type="str"),
+ eventId=dict(type="str"),
+ category=dict(type="str"),
+ severity=dict(type="str"),
+ domain=dict(type="str"),
+ subDomain=dict(type="str"),
+ source=dict(type="str"),
+ userId=dict(type="str"),
+ context=dict(type="str"),
+ eventHierarchy=dict(type="str"),
+ siteId=dict(type="str"),
+ deviceId=dict(type="str"),
+ isSystemEvents=dict(type="bool"),
+ description=dict(type="str"),
+ startTime=dict(type="int"),
+ endTime=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ parent_instance_id=params.get("parentInstanceId"),
+ is_parent_only=params.get("isParentOnly"),
+ instance_id=params.get("instanceId"),
+ name=params.get("name"),
+ event_id=params.get("eventId"),
+ category=params.get("category"),
+ severity=params.get("severity"),
+ domain=params.get("domain"),
+ sub_domain=params.get("subDomain"),
+ source=params.get("source"),
+ user_id=params.get("userId"),
+ context=params.get("context"),
+ event_hierarchy=params.get("eventHierarchy"),
+ site_id=params.get("siteId"),
+ device_id=params.get("deviceId"),
+ is_system_events=params.get("isSystemEvents"),
+ description=params.get("description"),
+ start_time=params.get("startTime"),
+ end_time=params.get("endTime"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='get_auditlog_summary',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_series_count_info.py b/ansible_collections/cisco/dnac/plugins/action/event_series_count_info.py
new file mode 100644
index 000000000..8e6372c92
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_series_count_info.py
@@ -0,0 +1,105 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ eventIds=dict(type="str"),
+ startTime=dict(type="int"),
+ endTime=dict(type="int"),
+ category=dict(type="str"),
+ type=dict(type="str"),
+ severity=dict(type="str"),
+ domain=dict(type="str"),
+ subDomain=dict(type="str"),
+ source=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ event_ids=params.get("eventIds"),
+ start_time=params.get("startTime"),
+ end_time=params.get("endTime"),
+ category=params.get("category"),
+ type=params.get("type"),
+ severity=params.get("severity"),
+ domain=params.get("domain"),
+ sub_domain=params.get("subDomain"),
+ source=params.get("source"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='count_of_notifications',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_series_info.py b/ansible_collections/cisco/dnac/plugins/action/event_series_info.py
new file mode 100644
index 000000000..8722bc05a
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_series_info.py
@@ -0,0 +1,119 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ eventIds=dict(type="str"),
+ startTime=dict(type="int"),
+ endTime=dict(type="int"),
+ category=dict(type="str"),
+ type=dict(type="str"),
+ severity=dict(type="str"),
+ domain=dict(type="str"),
+ subDomain=dict(type="str"),
+ source=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ tags=dict(type="str"),
+ namespace=dict(type="str"),
+ siteId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ event_ids=params.get("eventIds"),
+ start_time=params.get("startTime"),
+ end_time=params.get("endTime"),
+ category=params.get("category"),
+ type=params.get("type"),
+ severity=params.get("severity"),
+ domain=params.get("domain"),
+ sub_domain=params.get("subDomain"),
+ source=params.get("source"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ tags=params.get("tags"),
+ namespace=params.get("namespace"),
+ site_id=params.get("siteId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='get_notifications',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_snmp_config_info.py b/ansible_collections/cisco/dnac/plugins/action/event_snmp_config_info.py
new file mode 100644
index 000000000..1bc024081
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_snmp_config_info.py
@@ -0,0 +1,97 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ configId=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ config_id=params.get("configId"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='get_snmp_destination',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_subscription.py b/ansible_collections/cisco/dnac/plugins/action/event_subscription.py
new file mode 100644
index 000000000..52db4e8ad
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_subscription.py
@@ -0,0 +1,260 @@
+#!/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", "absent"]),
+ payload=dict(type="list"),
+ subscriptions=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["payload"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class EventSubscription(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ payload=params.get("payload"),
+ subscriptions=params.get("subscriptions"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['event_ids'] = self.new_object.get('eventIds') or \
+ self.new_object.get('event_ids')
+ 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 create_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ return new_object_params
+
+ def delete_all_params(self):
+ new_object_params = {}
+ new_object_params['subscriptions'] = self.new_object.get('subscriptions')
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="event_management",
+ function="get_event_subscriptions",
+ 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
+ try:
+ items = self.dnac.exec(
+ family="event_management",
+ function="get_event_subscriptions",
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ if 'subscriptionEndpoints' in items:
+ tmp_result = items.get('subscriptionEndpoints')
+ tmp_result = get_dict_result(tmp_result, 'id', id)
+ if tmp_result:
+ result = items
+ except Exception:
+ result = None
+ return result
+
+ def exists(self):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ requested_obj = self.new_object.get('payload')
+ 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")
+ name = self.new_object.get("name") or requested_obj.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.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+
+ obj_params = [
+ ("subscriptionId", "subscriptionId"),
+ ("version", "version"),
+ ("name", "name"),
+ ("description", "description"),
+ ("subscriptionEndpoints", "subscriptionEndpoints"),
+ ("filter", "filter"),
+ ("subscriptions", "subscriptions"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="event_management",
+ function="create_event_subscriptions",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ requested_obj = self.new_object.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+ id = self.new_object.get("id") or requested_obj.get("id")
+ name = self.new_object.get("name") or requested_obj.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="event_management",
+ function="update_event_subscriptions",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="event_management",
+ function="delete_event_subscriptions",
+ params=self.delete_all_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = EventSubscription(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_subscription_count_info.py b/ansible_collections/cisco/dnac/plugins/action/event_subscription_count_info.py
new file mode 100644
index 000000000..d581aa04d
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_subscription_count_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ eventIds=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ event_ids=params.get("eventIds"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='count_of_event_subscriptions',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_subscription_details_email_info.py b/ansible_collections/cisco/dnac/plugins/action/event_subscription_details_email_info.py
new file mode 100644
index 000000000..2ece6f956
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_subscription_details_email_info.py
@@ -0,0 +1,99 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ name=dict(type="str"),
+ instanceId=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ name=params.get("name"),
+ instance_id=params.get("instanceId"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='get_email_subscription_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_subscription_details_rest_info.py b/ansible_collections/cisco/dnac/plugins/action/event_subscription_details_rest_info.py
new file mode 100644
index 000000000..9c7321317
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_subscription_details_rest_info.py
@@ -0,0 +1,99 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ name=dict(type="str"),
+ instanceId=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ name=params.get("name"),
+ instance_id=params.get("instanceId"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='get_rest_webhook_subscription_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_subscription_details_syslog_info.py b/ansible_collections/cisco/dnac/plugins/action/event_subscription_details_syslog_info.py
new file mode 100644
index 000000000..fbec9c6ad
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_subscription_details_syslog_info.py
@@ -0,0 +1,99 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ name=dict(type="str"),
+ instanceId=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ name=params.get("name"),
+ instance_id=params.get("instanceId"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='get_syslog_subscription_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_subscription_email.py b/ansible_collections/cisco/dnac/plugins/action/event_subscription_email.py
new file mode 100644
index 000000000..103a871bc
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_subscription_email.py
@@ -0,0 +1,223 @@
+#!/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"]),
+ payload=dict(type="list"),
+))
+
+required_if = [
+ ("state", "present", ["payload"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class EventSubscriptionEmail(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ payload=params.get("payload"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['event_ids'] = self.new_object.get('eventIds') or \
+ self.new_object.get('event_ids')
+ 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')
+ new_object_params['domain'] = self.new_object.get('domain')
+ new_object_params['sub_domain'] = self.new_object.get('subDomain') or \
+ self.new_object.get('sub_domain')
+ new_object_params['category'] = self.new_object.get('category')
+ new_object_params['type'] = self.new_object.get('type')
+ new_object_params['name'] = name or self.new_object.get('name')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ 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="event_management",
+ function="get_email_event_subscriptions",
+ 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
+ requested_obj = self.new_object.get('payload')
+ 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")
+ name = self.new_object.get("name") or requested_obj.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.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+
+ obj_params = [
+ ("subscriptionId", "subscriptionId"),
+ ("version", "version"),
+ ("name", "name"),
+ ("description", "description"),
+ ("subscriptionEndpoints", "subscriptionEndpoints"),
+ ("filter", "filter"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="event_management",
+ function="create_email_event_subscription",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ requested_obj = self.new_object.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+ id = self.new_object.get("id") or requested_obj.get("id")
+ name = self.new_object.get("name") or requested_obj.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="event_management",
+ function="update_email_event_subscription",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = EventSubscriptionEmail(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_subscription_email_info.py b/ansible_collections/cisco/dnac/plugins/action/event_subscription_email_info.py
new file mode 100644
index 000000000..9e5f52866
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_subscription_email_info.py
@@ -0,0 +1,107 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ eventIds=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ domain=dict(type="str"),
+ subDomain=dict(type="str"),
+ category=dict(type="str"),
+ type=dict(type="str"),
+ name=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ event_ids=params.get("eventIds"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ domain=params.get("domain"),
+ sub_domain=params.get("subDomain"),
+ category=params.get("category"),
+ type=params.get("type"),
+ name=params.get("name"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='get_email_event_subscriptions',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_subscription_info.py b/ansible_collections/cisco/dnac/plugins/action/event_subscription_info.py
new file mode 100644
index 000000000..c5dc8d6f6
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_subscription_info.py
@@ -0,0 +1,97 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ eventIds=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ event_ids=params.get("eventIds"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='get_event_subscriptions',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_subscription_rest.py b/ansible_collections/cisco/dnac/plugins/action/event_subscription_rest.py
new file mode 100644
index 000000000..e806fd039
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_subscription_rest.py
@@ -0,0 +1,223 @@
+#!/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"]),
+ payload=dict(type="list"),
+))
+
+required_if = [
+ ("state", "present", ["payload"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class EventSubscriptionRest(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ payload=params.get("payload"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['event_ids'] = self.new_object.get('eventIds') or \
+ self.new_object.get('event_ids')
+ 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')
+ new_object_params['domain'] = self.new_object.get('domain')
+ new_object_params['sub_domain'] = self.new_object.get('subDomain') or \
+ self.new_object.get('sub_domain')
+ new_object_params['category'] = self.new_object.get('category')
+ new_object_params['type'] = self.new_object.get('type')
+ new_object_params['name'] = name or self.new_object.get('name')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ 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="event_management",
+ function="get_rest_webhook_event_subscriptions",
+ 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
+ requested_obj = self.new_object.get('payload')
+ 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")
+ name = self.new_object.get("name") or requested_obj.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.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+
+ obj_params = [
+ ("subscriptionId", "subscriptionId"),
+ ("version", "version"),
+ ("name", "name"),
+ ("description", "description"),
+ ("subscriptionEndpoints", "subscriptionEndpoints"),
+ ("filter", "filter"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="event_management",
+ function="create_rest_webhook_event_subscription",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ requested_obj = self.new_object.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+ id = self.new_object.get("id") or requested_obj.get("id")
+ name = self.new_object.get("name") or requested_obj.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="event_management",
+ function="update_rest_webhook_event_subscription",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = EventSubscriptionRest(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_subscription_rest_info.py b/ansible_collections/cisco/dnac/plugins/action/event_subscription_rest_info.py
new file mode 100644
index 000000000..046639260
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_subscription_rest_info.py
@@ -0,0 +1,107 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ eventIds=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ domain=dict(type="str"),
+ subDomain=dict(type="str"),
+ category=dict(type="str"),
+ type=dict(type="str"),
+ name=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ event_ids=params.get("eventIds"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ domain=params.get("domain"),
+ sub_domain=params.get("subDomain"),
+ category=params.get("category"),
+ type=params.get("type"),
+ name=params.get("name"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='get_rest_webhook_event_subscriptions',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_subscription_syslog.py b/ansible_collections/cisco/dnac/plugins/action/event_subscription_syslog.py
new file mode 100644
index 000000000..e1c5fd113
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_subscription_syslog.py
@@ -0,0 +1,223 @@
+#!/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"]),
+ payload=dict(type="list"),
+))
+
+required_if = [
+ ("state", "present", ["payload"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class EventSubscriptionSyslog(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ payload=params.get("payload"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['event_ids'] = self.new_object.get('eventIds') or \
+ self.new_object.get('event_ids')
+ 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')
+ new_object_params['domain'] = self.new_object.get('domain')
+ new_object_params['sub_domain'] = self.new_object.get('subDomain') or \
+ self.new_object.get('sub_domain')
+ new_object_params['category'] = self.new_object.get('category')
+ new_object_params['type'] = self.new_object.get('type')
+ new_object_params['name'] = name or self.new_object.get('name')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ 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="event_management",
+ function="get_syslog_event_subscriptions",
+ 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
+ requested_obj = self.new_object.get('payload')
+ 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")
+ name = self.new_object.get("name") or requested_obj.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.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+
+ obj_params = [
+ ("subscriptionId", "subscriptionId"),
+ ("version", "version"),
+ ("name", "name"),
+ ("description", "description"),
+ ("subscriptionEndpoints", "subscriptionEndpoints"),
+ ("filter", "filter"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="event_management",
+ function="create_syslog_event_subscription",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ requested_obj = self.new_object.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+ id = self.new_object.get("id") or requested_obj.get("id")
+ name = self.new_object.get("name") or requested_obj.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="event_management",
+ function="update_syslog_event_subscription",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = EventSubscriptionSyslog(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_subscription_syslog_info.py b/ansible_collections/cisco/dnac/plugins/action/event_subscription_syslog_info.py
new file mode 100644
index 000000000..d79db0953
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_subscription_syslog_info.py
@@ -0,0 +1,107 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ eventIds=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ domain=dict(type="str"),
+ subDomain=dict(type="str"),
+ category=dict(type="str"),
+ type=dict(type="str"),
+ name=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ event_ids=params.get("eventIds"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ domain=params.get("domain"),
+ sub_domain=params.get("subDomain"),
+ category=params.get("category"),
+ type=params.get("type"),
+ name=params.get("name"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='get_syslog_event_subscriptions',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_syslog_config.py b/ansible_collections/cisco/dnac/plugins/action/event_syslog_config.py
new file mode 100644
index 000000000..e4aae36bb
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_syslog_config.py
@@ -0,0 +1,231 @@
+#!/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"]),
+ configId=dict(type="str"),
+ name=dict(type="str"),
+ description=dict(type="str"),
+ host=dict(type="str"),
+ protocol=dict(type="str"),
+ port=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["name"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class EventSyslogConfig(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ configId=params.get("configId"),
+ name=params.get("name"),
+ description=params.get("description"),
+ host=params.get("host"),
+ protocol=params.get("protocol"),
+ port=params.get("port"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['config_id'] = self.new_object.get('configId') or \
+ self.new_object.get('config_id')
+ new_object_params['name'] = name or self.new_object.get('name')
+ new_object_params['protocol'] = self.new_object.get('protocol')
+ 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 create_params(self):
+ new_object_params = {}
+ new_object_params['configId'] = self.new_object.get('configId')
+ new_object_params['name'] = self.new_object.get('name')
+ new_object_params['description'] = self.new_object.get('description')
+ new_object_params['host'] = self.new_object.get('host')
+ new_object_params['protocol'] = self.new_object.get('protocol')
+ new_object_params['port'] = self.new_object.get('port')
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['configId'] = self.new_object.get('configId')
+ new_object_params['name'] = self.new_object.get('name')
+ new_object_params['description'] = self.new_object.get('description')
+ new_object_params['host'] = self.new_object.get('host')
+ new_object_params['protocol'] = self.new_object.get('protocol')
+ new_object_params['port'] = self.new_object.get('port')
+ 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="event_management",
+ function="get_syslog_destination",
+ 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 = [
+ ("configId", "configId"),
+ ("name", "name"),
+ ("description", "description"),
+ ("host", "host"),
+ ("protocol", "protocol"),
+ ("port", "port"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="event_management",
+ function="create_syslog_destination",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="event_management",
+ function="update_syslog_destination",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = EventSyslogConfig(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_syslog_config_info.py b/ansible_collections/cisco/dnac/plugins/action/event_syslog_config_info.py
new file mode 100644
index 000000000..bcef02393
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_syslog_config_info.py
@@ -0,0 +1,101 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ configId=dict(type="str"),
+ name=dict(type="str"),
+ protocol=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ config_id=params.get("configId"),
+ name=params.get("name"),
+ protocol=params.get("protocol"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='get_syslog_destination',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_webhook_create.py b/ansible_collections/cisco/dnac/plugins/action/event_webhook_create.py
new file mode 100644
index 000000000..de2b92514
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_webhook_create.py
@@ -0,0 +1,98 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ webhookId=dict(type="str"),
+ name=dict(type="str"),
+ description=dict(type="str"),
+ url=dict(type="str"),
+ method=dict(type="str"),
+ trustCert=dict(type="bool"),
+ headers=dict(type="list"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ webhookId=params.get("webhookId"),
+ name=params.get("name"),
+ description=params.get("description"),
+ url=params.get("url"),
+ method=params.get("method"),
+ trustCert=params.get("trustCert"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='create_webhook_destination',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/event_webhook_update.py b/ansible_collections/cisco/dnac/plugins/action/event_webhook_update.py
new file mode 100644
index 000000000..d11bc98a0
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/event_webhook_update.py
@@ -0,0 +1,98 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ webhookId=dict(type="str"),
+ name=dict(type="str"),
+ description=dict(type="str"),
+ url=dict(type="str"),
+ method=dict(type="str"),
+ trustCert=dict(type="bool"),
+ headers=dict(type="list"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ webhookId=params.get("webhookId"),
+ name=params.get("name"),
+ description=params.get("description"),
+ url=params.get("url"),
+ method=params.get("method"),
+ trustCert=params.get("trustCert"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='update_webhook_destination',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/execute_suggested_actions_commands.py b/ansible_collections/cisco/dnac/plugins/action/execute_suggested_actions_commands.py
new file mode 100644
index 000000000..48d7108ae
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/execute_suggested_actions_commands.py
@@ -0,0 +1,88 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ entity_type=dict(type="str"),
+ entity_value=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ entity_type=params.get("entity_type"),
+ entity_value=params.get("entity_value"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="issues",
+ function='execute_suggested_actions_commands',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/file_import.py b/ansible_collections/cisco/dnac/plugins/action/file_import.py
new file mode 100644
index 000000000..d27c9ef12
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/file_import.py
@@ -0,0 +1,88 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ nameSpace=dict(type="str"),
+ filePath=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ name_space=params.get("nameSpace"),
+ file_path=params.get("filePath"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="file",
+ function='upload_file',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/file_info.py b/ansible_collections/cisco/dnac/plugins/action/file_info.py
new file mode 100644
index 000000000..a251ba103
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/file_info.py
@@ -0,0 +1,110 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ fileId=dict(type="str"),
+ dirPath=dict(type="str"),
+ saveFile=dict(type="bool"),
+ filename=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ file_id=params.get("fileId"),
+ dirpath=params.get("dirPath"),
+ save_file=params.get("saveFile"),
+ filename=params.get("filename"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("fileId")
+ if id:
+ download_response = dnac.exec(
+ family="file",
+ function='download_a_file_by_fileid',
+ params=self.get_object(self._task.args),
+ )
+ response = dict(
+ data=download_response.data.decode(encoding='utf-8'),
+ filename=download_response.filename,
+ dirpath=download_response.dirpath,
+ path=download_response.path,
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/file_namespace_files_info.py b/ansible_collections/cisco/dnac/plugins/action/file_namespace_files_info.py
new file mode 100644
index 000000000..1d62e6e35
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/file_namespace_files_info.py
@@ -0,0 +1,98 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ nameSpace=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ name_space=params.get("nameSpace"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ name = self._task.args.get("nameSpace")
+ if name:
+ response = dnac.exec(
+ family="file",
+ function='get_list_of_files',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/file_namespaces_info.py b/ansible_collections/cisco/dnac/plugins/action/file_namespaces_info.py
new file mode 100644
index 000000000..f84b2c87f
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/file_namespaces_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="file",
+ function='get_list_of_available_namespaces',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/global_credential_delete.py b/ansible_collections/cisco/dnac/plugins/action/global_credential_delete.py
new file mode 100644
index 000000000..6f15dc9be
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/global_credential_delete.py
@@ -0,0 +1,85 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ globalCredentialId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ global_credential_id=params.get("globalCredentialId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="discovery",
+ function="delete_global_credentials_by_id",
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/global_credential_info.py b/ansible_collections/cisco/dnac/plugins/action/global_credential_info.py
new file mode 100644
index 000000000..af9f2ae31
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/global_credential_info.py
@@ -0,0 +1,106 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ credentialSubType=dict(type="str"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ id=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ credential_sub_type=params.get("credentialSubType"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ id=params.get("id"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ if id:
+ response = dnac.exec(
+ family="discovery",
+ function='get_credential_sub_type_by_credential_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="discovery",
+ function='get_global_credentials',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/global_credential_update.py b/ansible_collections/cisco/dnac/plugins/action/global_credential_update.py
new file mode 100644
index 000000000..b2f9504fe
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/global_credential_update.py
@@ -0,0 +1,88 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteUuids=dict(type="list"),
+ globalCredentialId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ siteUuids=params.get("siteUuids"),
+ global_credential_id=params.get("globalCredentialId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="discovery",
+ function='update_global_credentials',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/global_credential_v2.py b/ansible_collections/cisco/dnac/plugins/action/global_credential_v2.py
new file mode 100644
index 000000000..1831c0457
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/global_credential_v2.py
@@ -0,0 +1,270 @@
+#!/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", "absent"]),
+ cliCredential=dict(type="list"),
+ snmpV2cRead=dict(type="list"),
+ snmpV2cWrite=dict(type="list"),
+ snmpV3=dict(type="list"),
+ httpsRead=dict(type="list"),
+ httpsWrite=dict(type="list"),
+ id=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["id"], True),
+ ("state", "absent", ["id"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class GlobalCredentialV2(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ cliCredential=params.get("cliCredential"),
+ snmpV2cRead=params.get("snmpV2cRead"),
+ snmpV2cWrite=params.get("snmpV2cWrite"),
+ snmpV3=params.get("snmpV3"),
+ httpsRead=params.get("httpsRead"),
+ httpsWrite=params.get("httpsWrite"),
+ id=params.get("id"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ 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')
+ new_object_params['httpsRead'] = self.new_object.get('httpsRead')
+ new_object_params['httpsWrite'] = self.new_object.get('httpsWrite')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['id'] = self.new_object.get('id')
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ 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')
+ new_object_params['httpsRead'] = self.new_object.get('httpsRead')
+ new_object_params['httpsWrite'] = self.new_object.get('httpsWrite')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="discovery",
+ function="get_all_global_credentials_v2",
+ 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
+ try:
+ items = self.dnac.exec(
+ family="discovery",
+ function="get_all_global_credentials_v2",
+ params=self.get_all_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):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ 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 = [
+ ("cliCredential", "cliCredential"),
+ ("snmpV2cRead", "snmpV2cRead"),
+ ("snmpV2cWrite", "snmpV2cWrite"),
+ ("snmpV3", "snmpV3"),
+ ("httpsRead", "httpsRead"),
+ ("httpsWrite", "httpsWrite"),
+ ("id", "id"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="discovery",
+ function="create_global_credentials_v2",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="discovery",
+ function="update_global_credentials_v2",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ if id_:
+ self.new_object.update(dict(id=id_))
+ result = self.dnac.exec(
+ family="discovery",
+ function="delete_global_credential_v2",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = GlobalCredentialV2(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/global_credential_v2_info.py b/ansible_collections/cisco/dnac/plugins/action/global_credential_v2_info.py
new file mode 100644
index 000000000..128a49ecc
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/global_credential_v2_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="discovery",
+ function='get_all_global_credentials_v2',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/global_pool.py b/ansible_collections/cisco/dnac/plugins/action/global_pool.py
new file mode 100644
index 000000000..1e7a5417e
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/global_pool.py
@@ -0,0 +1,277 @@
+#!/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", "absent"]),
+ settings=dict(type="dict"),
+ id=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["id", "settings"], True),
+ ("state", "absent", ["id", "settings"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class GlobalPool(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ settings=params.get("settings"),
+ id=params.get("id"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['offset'] = self.new_object.get('offset')
+ new_object_params['limit'] = self.new_object.get('limit')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['settings'] = self.new_object.get('settings')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['id'] = self.new_object.get('id')
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['settings'] = self.new_object.get('settings')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="network_settings",
+ function="get_global_pool",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ if 'settings' in items:
+ items = items.get('settings')
+ if 'ippool' in items:
+ items = items.get('ippool')
+ settings = self.new_object.get('settings')
+ if settings and isinstance(settings, dict) and settings.get('ippool'):
+ settings = settings.get('ippool')
+ if settings and isinstance(settings, dict) and settings.get('ipPoolName'):
+ name = settings.get('ipPoolName')
+ elif settings and isinstance(settings, list) and len(settings) > 0:
+ if settings[0].get('ipPoolName'):
+ name = settings[0].get('ipPoolName')
+ result = get_dict_result(items, 'ipPoolName', 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
+ try:
+ items = self.dnac.exec(
+ family="network_settings",
+ function="get_global_pool",
+ params=self.get_all_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):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ o_id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ settings = self.new_object.get('settings')
+ if settings and isinstance(settings, dict) and settings.get('ippool'):
+ settings = settings.get('ippool')
+ if settings and isinstance(settings, dict) and settings.get('ipPoolName'):
+ name = name or settings.get('ipPoolName')
+ elif settings and isinstance(settings, list) and len(settings) > 0:
+ if settings[0].get('ipPoolName'):
+ name = settings[0].get('ipPoolName')
+ 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 = [
+ ("settings", "settings"),
+ ("id", "id"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="network_settings",
+ function="create_global_pool",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ settings = self.new_object.get('settings')
+ if settings and isinstance(settings, dict) and settings.get('ippool'):
+ settings = settings.get('ippool')
+ if settings and isinstance(settings, dict) and settings.get('ipPoolName'):
+ name = name or settings.get('ipPoolName')
+ result = self.dnac.exec(
+ family="network_settings",
+ function="update_global_pool",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ settings = self.new_object.get('settings')
+ if settings and isinstance(settings, dict) and settings.get('ippool'):
+ settings = settings.get('ippool')
+ if settings and isinstance(settings, dict) and settings.get('ipPoolName'):
+ name = name or settings.get('ipPoolName')
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ if id_:
+ self.new_object.update(dict(id=id_))
+ result = self.dnac.exec(
+ family="network_settings",
+ function="delete_global_ip_pool",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = GlobalPool(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/global_pool_info.py b/ansible_collections/cisco/dnac/plugins/action/global_pool_info.py
new file mode 100644
index 000000000..56c0161a0
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/global_pool_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function='get_global_pool',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/golden_image_create.py b/ansible_collections/cisco/dnac/plugins/action/golden_image_create.py
new file mode 100644
index 000000000..ecfacb06a
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/golden_image_create.py
@@ -0,0 +1,92 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ imageId=dict(type="str"),
+ siteId=dict(type="str"),
+ deviceRole=dict(type="str"),
+ deviceFamilyIdentifier=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ imageId=params.get("imageId"),
+ siteId=params.get("siteId"),
+ deviceRole=params.get("deviceRole"),
+ deviceFamilyIdentifier=params.get("deviceFamilyIdentifier"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="software_image_management_swim",
+ function='tag_as_golden_image',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/golden_tag_image_delete.py b/ansible_collections/cisco/dnac/plugins/action/golden_tag_image_delete.py
new file mode 100644
index 000000000..1150d623e
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/golden_tag_image_delete.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteId=dict(type="str"),
+ deviceFamilyIdentifier=dict(type="str"),
+ deviceRole=dict(type="str"),
+ imageId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ site_id=params.get("siteId"),
+ device_family_identifier=params.get("deviceFamilyIdentifier"),
+ device_role=params.get("deviceRole"),
+ image_id=params.get("imageId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="software_image_management_swim",
+ function="remove_golden_tag_for_image",
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/golden_tag_image_details_info.py b/ansible_collections/cisco/dnac/plugins/action/golden_tag_image_details_info.py
new file mode 100644
index 000000000..6b9241f0d
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/golden_tag_image_details_info.py
@@ -0,0 +1,104 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteId=dict(type="str"),
+ deviceFamilyIdentifier=dict(type="str"),
+ deviceRole=dict(type="str"),
+ imageId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ site_id=params.get("siteId"),
+ device_family_identifier=params.get("deviceFamilyIdentifier"),
+ device_role=params.get("deviceRole"),
+ image_id=params.get("imageId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("siteId")
+ if id:
+ response = dnac.exec(
+ family="software_image_management_swim",
+ function='get_golden_tag_status_of_an_image',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/http_read_credential.py b/ansible_collections/cisco/dnac/plugins/action/http_read_credential.py
new file mode 100644
index 000000000..1d1ac0acd
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/http_read_credential.py
@@ -0,0 +1,244 @@
+#!/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"]),
+ comments=dict(type="str"),
+ credentialType=dict(type="str"),
+ description=dict(type="str"),
+ id=dict(type="str"),
+ instanceTenantId=dict(type="str"),
+ instanceUuid=dict(type="str"),
+ password=dict(type="str", no_log=True),
+ port=dict(type="int"),
+ secure=dict(type="bool"),
+ username=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["description", "id", "username"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class HttpReadCredential(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ comments=params.get("comments"),
+ credentialType=params.get("credentialType"),
+ description=params.get("description"),
+ id=params.get("id"),
+ instanceTenantId=params.get("instanceTenantId"),
+ instanceUuid=params.get("instanceUuid"),
+ password=params.get("password"),
+ port=params.get("port"),
+ secure=params.get("secure"),
+ username=params.get("username"),
+ )
+
+ def create_params(self):
+ new_object_params = {}
+ payload = {}
+ keys = ['comments', 'credentialType', 'description', 'id', 'instanceTenantId',
+ 'instanceUuid', 'password', 'port', 'secure', 'username']
+ for key in keys:
+ if self.new_object.get(key) is not None:
+ payload[key] = self.new_object.get(key)
+ new_object_params['payload'] = [payload]
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['comments'] = self.new_object.get('comments')
+ new_object_params['credentialType'] = self.new_object.get('credentialType')
+ new_object_params['description'] = self.new_object.get('description')
+ new_object_params['id'] = self.new_object.get('id')
+ new_object_params['instanceTenantId'] = self.new_object.get('instanceTenantId')
+ new_object_params['instanceUuid'] = self.new_object.get('instanceUuid')
+ new_object_params['password'] = self.new_object.get('password')
+ new_object_params['port'] = self.new_object.get('port')
+ new_object_params['secure'] = self.new_object.get('secure')
+ new_object_params['username'] = self.new_object.get('username')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="discovery",
+ function="get_global_credentials",
+ params={'credential_sub_type': 'HTTP_READ'},
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ result = get_dict_result(items, 'description', name) or get_dict_result(items, 'username', name)
+ except Exception:
+ result = None
+ return result
+
+ def get_object_by_id(self, id):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="discovery",
+ function="get_global_credentials",
+ params={'credential_sub_type': 'HTTP_READ'},
+ )
+ 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("description") or self.new_object.get("username")
+ 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 = [
+ ("comments", "comments"),
+ ("credentialType", "credentialType"),
+ ("description", "description"),
+ ("id", "id"),
+ ("instanceTenantId", "instanceTenantId"),
+ ("instanceUuid", "instanceUuid"),
+ ("port", "port"),
+ ("secure", "secure"),
+ ("username", "username"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="discovery",
+ function="create_http_read_credentials",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="discovery",
+ function="update_http_read_credential",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = HttpReadCredential(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/http_write_credential.py b/ansible_collections/cisco/dnac/plugins/action/http_write_credential.py
new file mode 100644
index 000000000..5a63c0d5e
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/http_write_credential.py
@@ -0,0 +1,244 @@
+#!/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"]),
+ comments=dict(type="str"),
+ credentialType=dict(type="str"),
+ description=dict(type="str"),
+ id=dict(type="str"),
+ instanceTenantId=dict(type="str"),
+ instanceUuid=dict(type="str"),
+ password=dict(type="str", no_log=True),
+ port=dict(type="int"),
+ secure=dict(type="bool"),
+ username=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["description", "id", "username"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class HttpWriteCredential(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ comments=params.get("comments"),
+ credentialType=params.get("credentialType"),
+ description=params.get("description"),
+ id=params.get("id"),
+ instanceTenantId=params.get("instanceTenantId"),
+ instanceUuid=params.get("instanceUuid"),
+ password=params.get("password"),
+ port=params.get("port"),
+ secure=params.get("secure"),
+ username=params.get("username"),
+ )
+
+ def create_params(self):
+ new_object_params = {}
+ payload = {}
+ keys = ['comments', 'credentialType', 'description', 'id', 'instanceTenantId',
+ 'instanceUuid', 'password', 'port', 'secure', 'username']
+ for key in keys:
+ if self.new_object.get(key) is not None:
+ payload[key] = self.new_object.get(key)
+ new_object_params['payload'] = [payload]
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['comments'] = self.new_object.get('comments')
+ new_object_params['credentialType'] = self.new_object.get('credentialType')
+ new_object_params['description'] = self.new_object.get('description')
+ new_object_params['id'] = self.new_object.get('id')
+ new_object_params['instanceTenantId'] = self.new_object.get('instanceTenantId')
+ new_object_params['instanceUuid'] = self.new_object.get('instanceUuid')
+ new_object_params['password'] = self.new_object.get('password')
+ new_object_params['port'] = self.new_object.get('port')
+ new_object_params['secure'] = self.new_object.get('secure')
+ new_object_params['username'] = self.new_object.get('username')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="discovery",
+ function="get_global_credentials",
+ params={'credential_sub_type': 'HTTP_WRITE'},
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ result = get_dict_result(items, 'description', name) or get_dict_result(items, 'username', name)
+ except Exception:
+ result = None
+ return result
+
+ def get_object_by_id(self, id):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="discovery",
+ function="get_global_credentials",
+ params={'credential_sub_type': 'HTTP_WRITE'},
+ )
+ 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("description") or self.new_object.get("username")
+ 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 = [
+ ("comments", "comments"),
+ ("credentialType", "credentialType"),
+ ("description", "description"),
+ ("id", "id"),
+ ("instanceTenantId", "instanceTenantId"),
+ ("instanceUuid", "instanceUuid"),
+ ("port", "port"),
+ ("secure", "secure"),
+ ("username", "username"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="discovery",
+ function="create_http_write_credentials",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="discovery",
+ function="update_http_write_credentials",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = HttpWriteCredential(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/integration_settings_instances_itsm.py b/ansible_collections/cisco/dnac/plugins/action/integration_settings_instances_itsm.py
new file mode 100644
index 000000000..1b12af772
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/integration_settings_instances_itsm.py
@@ -0,0 +1,260 @@
+#!/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", "absent"]),
+ name=dict(type="str"),
+ description=dict(type="str"),
+ data=dict(type="dict"),
+ dypName=dict(type="str"),
+ instanceId=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["instanceId", "name"], True),
+ ("state", "absent", ["instanceId", "name"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class IntegrationSettingsInstancesItsm(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ name=params.get("name"),
+ description=params.get("description"),
+ data=params.get("data"),
+ dypName=params.get("dypName"),
+ instance_id=params.get("instanceId"),
+ )
+
+ 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['data'] = self.new_object.get('data')
+ new_object_params['dypName'] = self.new_object.get('dypName')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['instance_id'] = self.new_object.get('instance_id')
+ return new_object_params
+
+ def update_by_id_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['data'] = self.new_object.get('data')
+ new_object_params['dypName'] = self.new_object.get('dypName')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ # NOTE: Does not have get all
+ return result
+
+ def get_object_by_id(self, id):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="itsm_integration",
+ function="get_itsm_integration_setting_by_id",
+ params={"instance_id": id}
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ result = get_dict_result(items, 'instanceId', id)
+ except Exception:
+ result = None
+ return result
+
+ def exists(self):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ o_id = self.new_object.get("id")
+ o_id = o_id or self.new_object.get("instance_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")
+ _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")
+ if _id:
+ self.new_object.update(dict(id=_id))
+ self.new_object.update(dict(instance_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 = [
+ ("name", "name"),
+ ("description", "description"),
+ ("data", "data"),
+ ("dypName", "dypName"),
+ ("instanceId", "instance_id"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="itsm_integration",
+ function="create_itsm_integration_setting",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ id = id or self.new_object.get("instance_id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ id_ = id_ or prev_obj_name.get("instanceId")
+ if id_:
+ self.new_object.update(dict(instance_id=id_))
+ result = self.dnac.exec(
+ family="itsm_integration",
+ function="update_itsm_integration_setting",
+ params=self.update_by_id_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ id = id or self.new_object.get("instance_id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ id_ = id_ or prev_obj_name.get("instanceId")
+ if id_:
+ self.new_object.update(dict(instance_id=id_))
+ result = self.dnac.exec(
+ family="itsm_integration",
+ function="delete_itsm_integration_setting",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = IntegrationSettingsInstancesItsm(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/integration_settings_instances_itsm_info.py b/ansible_collections/cisco/dnac/plugins/action/integration_settings_instances_itsm_info.py
new file mode 100644
index 000000000..0d4bb91a8
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/integration_settings_instances_itsm_info.py
@@ -0,0 +1,98 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ instanceId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ instance_id=params.get("instanceId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("instanceId")
+ if id:
+ response = dnac.exec(
+ family="itsm_integration",
+ function='get_itsm_integration_setting_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/interface_info.py b/ansible_collections/cisco/dnac/plugins/action/interface_info.py
new file mode 100644
index 000000000..2477866e3
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/interface_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ interfaceUuid=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ interface_uuid=params.get("interfaceUuid"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='legit_operations_for_interface',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/interface_network_device_detail_info.py b/ansible_collections/cisco/dnac/plugins/action/interface_network_device_detail_info.py
new file mode 100644
index 000000000..3907e2ae4
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/interface_network_device_detail_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceId=dict(type="str"),
+ name=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_id=params.get("deviceId"),
+ name=params.get("name"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_interface_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/interface_network_device_info.py b/ansible_collections/cisco/dnac/plugins/action/interface_network_device_info.py
new file mode 100644
index 000000000..fdaadea37
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/interface_network_device_info.py
@@ -0,0 +1,98 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_id=params.get("deviceId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("deviceId")
+ if id:
+ response = dnac.exec(
+ family="devices",
+ function='get_interface_info_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/interface_network_device_range_info.py b/ansible_collections/cisco/dnac/plugins/action/interface_network_device_range_info.py
new file mode 100644
index 000000000..fc7f3ef31
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/interface_network_device_range_info.py
@@ -0,0 +1,93 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceId=dict(type="str"),
+ startIndex=dict(type="int"),
+ recordsToReturn=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_id=params.get("deviceId"),
+ start_index=params.get("startIndex"),
+ records_to_return=params.get("recordsToReturn"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_device_interfaces_by_specified_range',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/interface_operation_create.py b/ansible_collections/cisco/dnac/plugins/action/interface_operation_create.py
new file mode 100644
index 000000000..3aa361485
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/interface_operation_create.py
@@ -0,0 +1,92 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ operation=dict(type="str"),
+ payload=dict(type="dict"),
+ interfaceUuid=dict(type="str"),
+ deploymentMode=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ operation=params.get("operation"),
+ payload=params.get("payload"),
+ interface_uuid=params.get("interfaceUuid"),
+ deployment_mode=params.get("deploymentMode"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='clear_mac_address_table',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/interface_update.py b/ansible_collections/cisco/dnac/plugins/action/interface_update.py
new file mode 100644
index 000000000..c84c549f2
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/interface_update.py
@@ -0,0 +1,96 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ description=dict(type="str"),
+ adminStatus=dict(type="str"),
+ vlanId=dict(type="int"),
+ voiceVlanId=dict(type="int"),
+ interfaceUuid=dict(type="str"),
+ deploymentMode=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ description=params.get("description"),
+ adminStatus=params.get("adminStatus"),
+ vlanId=params.get("vlanId"),
+ voiceVlanId=params.get("voiceVlanId"),
+ interface_uuid=params.get("interfaceUuid"),
+ deployment_mode=params.get("deploymentMode"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='update_interface_details',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/issues_enrichment_details_info.py b/ansible_collections/cisco/dnac/plugins/action/issues_enrichment_details_info.py
new file mode 100644
index 000000000..c31c79cc2
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/issues_enrichment_details_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="issues",
+ function='get_issue_enrichment_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/issues_info.py b/ansible_collections/cisco/dnac/plugins/action/issues_info.py
new file mode 100644
index 000000000..ab158f9e7
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/issues_info.py
@@ -0,0 +1,103 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ startTime=dict(type="int"),
+ endTime=dict(type="int"),
+ siteId=dict(type="str"),
+ deviceId=dict(type="str"),
+ macAddress=dict(type="str"),
+ priority=dict(type="str"),
+ aiDriven=dict(type="str"),
+ issueStatus=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ start_time=params.get("startTime"),
+ end_time=params.get("endTime"),
+ site_id=params.get("siteId"),
+ device_id=params.get("deviceId"),
+ mac_address=params.get("macAddress"),
+ priority=params.get("priority"),
+ ai_driven=params.get("aiDriven"),
+ issue_status=params.get("issueStatus"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="issues",
+ function='issues',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/itsm_cmdb_sync_status_info.py b/ansible_collections/cisco/dnac/plugins/action/itsm_cmdb_sync_status_info.py
new file mode 100644
index 000000000..4ef0fb567
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/itsm_cmdb_sync_status_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ status=dict(type="str"),
+ date=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ status=params.get("status"),
+ date=params.get("date"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="itsm",
+ function='get_cmdb_sync_status',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/itsm_integration_events_failed_info.py b/ansible_collections/cisco/dnac/plugins/action/itsm_integration_events_failed_info.py
new file mode 100644
index 000000000..12d09b7d9
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/itsm_integration_events_failed_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ instanceId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ instance_id=params.get("instanceId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="itsm",
+ function='get_failed_itsm_events',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/itsm_integration_events_retry.py b/ansible_collections/cisco/dnac/plugins/action/itsm_integration_events_retry.py
new file mode 100644
index 000000000..67c7d987d
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/itsm_integration_events_retry.py
@@ -0,0 +1,86 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ payload=dict(type="list"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ payload=params.get("payload"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="itsm",
+ function='retry_integration_events',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/lan_automation_count_info.py b/ansible_collections/cisco/dnac/plugins/action/lan_automation_count_info.py
new file mode 100644
index 000000000..0fa796d62
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/lan_automation_count_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="lan_automation",
+ function='lan_automation_session_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/lan_automation_create.py b/ansible_collections/cisco/dnac/plugins/action/lan_automation_create.py
new file mode 100644
index 000000000..5d6a732d0
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/lan_automation_create.py
@@ -0,0 +1,86 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ payload=dict(type="list"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ payload=params.get("payload"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="lan_automation",
+ function='lan_automation_start',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/lan_automation_delete.py b/ansible_collections/cisco/dnac/plugins/action/lan_automation_delete.py
new file mode 100644
index 000000000..28bf35b79
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/lan_automation_delete.py
@@ -0,0 +1,85 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="lan_automation",
+ function="lan_automation_stop",
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/lan_automation_log_by_serial_number_info.py b/ansible_collections/cisco/dnac/plugins/action/lan_automation_log_by_serial_number_info.py
new file mode 100644
index 000000000..eaea3d0bd
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/lan_automation_log_by_serial_number_info.py
@@ -0,0 +1,102 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+ serialNumber=dict(type="str"),
+ logLevel=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ serial_number=params.get("serialNumber"),
+ log_level=params.get("logLevel"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ if id:
+ response = dnac.exec(
+ family="lan_automation",
+ function='lan_automation_logs_for_individual_devices',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/lan_automation_log_info.py b/ansible_collections/cisco/dnac/plugins/action/lan_automation_log_info.py
new file mode 100644
index 000000000..dfa702581
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/lan_automation_log_info.py
@@ -0,0 +1,104 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ id=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ id=params.get("id"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ if id:
+ response = dnac.exec(
+ family="lan_automation",
+ function='lan_automation_log_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="lan_automation",
+ function='lan_automation_log',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/lan_automation_status_info.py b/ansible_collections/cisco/dnac/plugins/action/lan_automation_status_info.py
new file mode 100644
index 000000000..073cfb275
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/lan_automation_status_info.py
@@ -0,0 +1,104 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ id=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ id=params.get("id"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ if id:
+ response = dnac.exec(
+ family="lan_automation",
+ function='lan_automation_status_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="lan_automation",
+ function='lan_automation_status',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/license_device_count_info.py b/ansible_collections/cisco/dnac/plugins/action/license_device_count_info.py
new file mode 100644
index 000000000..e73e32515
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/license_device_count_info.py
@@ -0,0 +1,97 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ device_type=dict(type="str"),
+ registration_status=dict(type="str"),
+ dna_level=dict(type="str"),
+ virtual_account_name=dict(type="str"),
+ smart_account_id=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_type=params.get("device_type"),
+ registration_status=params.get("registration_status"),
+ dna_level=params.get("dna_level"),
+ virtual_account_name=params.get("virtual_account_name"),
+ smart_account_id=params.get("smart_account_id"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="licenses",
+ function='device_count_details2',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/license_device_deregistration.py b/ansible_collections/cisco/dnac/plugins/action/license_device_deregistration.py
new file mode 100644
index 000000000..5e170aa99
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/license_device_deregistration.py
@@ -0,0 +1,86 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ device_uuids=dict(type="list"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ device_uuids=params.get("device_uuids"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="licenses",
+ function='device_deregistration2',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/license_device_license_details_info.py b/ansible_collections/cisco/dnac/plugins/action/license_device_license_details_info.py
new file mode 100644
index 000000000..8ffd3fe3d
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/license_device_license_details_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ device_uuid=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_uuid=params.get("device_uuid"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="licenses",
+ function='device_license_details2',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/license_device_license_summary_info.py b/ansible_collections/cisco/dnac/plugins/action/license_device_license_summary_info.py
new file mode 100644
index 000000000..af82708ca
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/license_device_license_summary_info.py
@@ -0,0 +1,107 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ page_number=dict(type="int"),
+ order=dict(type="str"),
+ sort_by=dict(type="str"),
+ dna_level=dict(type="str"),
+ device_type=dict(type="str"),
+ limit=dict(type="int"),
+ registration_status=dict(type="str"),
+ virtual_account_name=dict(type="str"),
+ smart_account_id=dict(type="int"),
+ device_uuid=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ page_number=params.get("page_number"),
+ order=params.get("order"),
+ sort_by=params.get("sort_by"),
+ dna_level=params.get("dna_level"),
+ device_type=params.get("device_type"),
+ limit=params.get("limit"),
+ registration_status=params.get("registration_status"),
+ virtual_account_name=params.get("virtual_account_name"),
+ smart_account_id=params.get("smart_account_id"),
+ device_uuid=params.get("device_uuid"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="licenses",
+ function='device_license_summary2',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/license_device_registration.py b/ansible_collections/cisco/dnac/plugins/action/license_device_registration.py
new file mode 100644
index 000000000..18e6755d1
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/license_device_registration.py
@@ -0,0 +1,88 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ device_uuids=dict(type="list"),
+ virtual_account_name=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ device_uuids=params.get("device_uuids"),
+ virtual_account_name=params.get("virtual_account_name"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="licenses",
+ function='device_registration2',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/license_smart_account_details_info.py b/ansible_collections/cisco/dnac/plugins/action/license_smart_account_details_info.py
new file mode 100644
index 000000000..a031e1c27
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/license_smart_account_details_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="licenses",
+ function='smart_account_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/license_term_details_info.py b/ansible_collections/cisco/dnac/plugins/action/license_term_details_info.py
new file mode 100644
index 000000000..e7e027718
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/license_term_details_info.py
@@ -0,0 +1,102 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ smart_account_id=dict(type="str"),
+ virtual_account_name=dict(type="str"),
+ device_type=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ smart_account_id=params.get("smart_account_id"),
+ virtual_account_name=params.get("virtual_account_name"),
+ device_type=params.get("device_type"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ name = self._task.args.get("virtual_account_name")
+ if name:
+ response = dnac.exec(
+ family="licenses",
+ function='license_term_details2',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/license_usage_details_info.py b/ansible_collections/cisco/dnac/plugins/action/license_usage_details_info.py
new file mode 100644
index 000000000..51a84a744
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/license_usage_details_info.py
@@ -0,0 +1,102 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ smart_account_id=dict(type="str"),
+ virtual_account_name=dict(type="str"),
+ device_type=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ smart_account_id=params.get("smart_account_id"),
+ virtual_account_name=params.get("virtual_account_name"),
+ device_type=params.get("device_type"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ name = self._task.args.get("virtual_account_name")
+ if name:
+ response = dnac.exec(
+ family="licenses",
+ function='license_usage_details2',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/license_virtual_account_change.py b/ansible_collections/cisco/dnac/plugins/action/license_virtual_account_change.py
new file mode 100644
index 000000000..f4fba1901
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/license_virtual_account_change.py
@@ -0,0 +1,90 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ device_uuids=dict(type="list"),
+ smart_account_id=dict(type="str"),
+ virtual_account_name=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ device_uuids=params.get("device_uuids"),
+ smart_account_id=params.get("smart_account_id"),
+ virtual_account_name=params.get("virtual_account_name"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="licenses",
+ function='change_virtual_account2',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/license_virtual_account_details_info.py b/ansible_collections/cisco/dnac/plugins/action/license_virtual_account_details_info.py
new file mode 100644
index 000000000..162c24b60
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/license_virtual_account_details_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ smart_account_id=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ smart_account_id=params.get("smart_account_id"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="licenses",
+ function='virtual_account_details2',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/netconf_credential.py b/ansible_collections/cisco/dnac/plugins/action/netconf_credential.py
new file mode 100644
index 000000000..08aa9d19c
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/netconf_credential.py
@@ -0,0 +1,233 @@
+#!/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"]),
+ comments=dict(type="str"),
+ credentialType=dict(type="str"),
+ description=dict(type="str"),
+ id=dict(type="str"),
+ instanceTenantId=dict(type="str"),
+ instanceUuid=dict(type="str"),
+ netconfPort=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["description", "id"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class NetconfCredential(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ comments=params.get("comments"),
+ credentialType=params.get("credentialType"),
+ description=params.get("description"),
+ id=params.get("id"),
+ instanceTenantId=params.get("instanceTenantId"),
+ instanceUuid=params.get("instanceUuid"),
+ netconfPort=params.get("netconfPort"),
+ )
+
+ def create_params(self):
+ new_object_params = {}
+ payload = {}
+ keys = ['comments', 'credentialType', 'description', 'id', 'instanceTenantId',
+ 'instanceUuid', 'netconfPort']
+ for key in keys:
+ if self.new_object.get(key) is not None:
+ payload[key] = self.new_object.get(key)
+ new_object_params['payload'] = [payload]
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['comments'] = self.new_object.get('comments')
+ new_object_params['credentialType'] = self.new_object.get('credentialType')
+ new_object_params['description'] = self.new_object.get('description')
+ new_object_params['id'] = self.new_object.get('id')
+ new_object_params['instanceTenantId'] = self.new_object.get('instanceTenantId')
+ new_object_params['instanceUuid'] = self.new_object.get('instanceUuid')
+ new_object_params['netconfPort'] = self.new_object.get('netconfPort')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="discovery",
+ function="get_global_credentials",
+ params={'credential_sub_type': 'NETCONF'},
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ result = get_dict_result(items, 'description', name)
+ except Exception:
+ result = None
+ return result
+
+ def get_object_by_id(self, id):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="discovery",
+ function="get_global_credentials",
+ params={'credential_sub_type': 'NETCONF'},
+ )
+ 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("description") or self.new_object.get("username")
+ 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 = [
+ ("comments", "comments"),
+ ("credentialType", "credentialType"),
+ ("description", "description"),
+ ("id", "id"),
+ ("instanceTenantId", "instanceTenantId"),
+ ("instanceUuid", "instanceUuid"),
+ ("netconfPort", "netconfPort"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="discovery",
+ function="create_netconf_credentials",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="discovery",
+ function="update_netconf_credentials",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = NetconfCredential(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_create.py b/ansible_collections/cisco/dnac/plugins/action/network_create.py
new file mode 100644
index 000000000..5fe4bd37e
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_create.py
@@ -0,0 +1,90 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ settings=dict(type="dict"),
+ siteId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ settings=params.get("settings"),
+ site_id=params.get("siteId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function='create_network',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device.py b/ansible_collections/cisco/dnac/plugins/action/network_device.py
new file mode 100644
index 000000000..650f0cc82
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device.py
@@ -0,0 +1,439 @@
+#!/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_equality2,
+ 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", "absent"]),
+ cliTransport=dict(type="str"),
+ computeDevice=dict(type="bool"),
+ enablePassword=dict(type="str", no_log=True),
+ extendedDiscoveryInfo=dict(type="str"),
+ httpPassword=dict(type="str"),
+ httpPort=dict(type="str"),
+ httpSecure=dict(type="bool"),
+ httpUserName=dict(type="str"),
+ ipAddress=dict(type="list"),
+ merakiOrgId=dict(type="list"),
+ netconfPort=dict(type="str"),
+ password=dict(type="str", no_log=True),
+ serialNumber=dict(type="str"),
+ snmpAuthPassphrase=dict(type="str"),
+ snmpAuthProtocol=dict(type="str"),
+ snmpMode=dict(type="str"),
+ snmpPrivPassphrase=dict(type="str"),
+ snmpPrivProtocol=dict(type="str"),
+ snmpROCommunity=dict(type="str"),
+ snmpRWCommunity=dict(type="str"),
+ snmpRetry=dict(type="int"),
+ snmpTimeout=dict(type="int"),
+ snmpUserName=dict(type="str"),
+ snmpVersion=dict(type="str"),
+ type=dict(type="str"),
+ updateMgmtIPaddressList=dict(type="list"),
+ userName=dict(type="str"),
+ id=dict(type="str"),
+ cleanConfig=dict(type="bool"),
+))
+
+required_if = [
+ ("state", "present", ["id", "ipAddress"], True),
+ ("state", "absent", ["id", "ipAddress"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class NetworkDevice(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ cliTransport=params.get("cliTransport"),
+ computeDevice=params.get("computeDevice"),
+ enablePassword=params.get("enablePassword"),
+ extendedDiscoveryInfo=params.get("extendedDiscoveryInfo"),
+ httpPassword=params.get("httpPassword"),
+ httpPort=params.get("httpPort"),
+ httpSecure=params.get("httpSecure"),
+ httpUserName=params.get("httpUserName"),
+ ipAddress=params.get("ipAddress"),
+ merakiOrgId=params.get("merakiOrgId"),
+ netconfPort=params.get("netconfPort"),
+ password=params.get("password"),
+ serialNumber=params.get("serialNumber"),
+ snmpAuthPassphrase=params.get("snmpAuthPassphrase"),
+ snmpAuthProtocol=params.get("snmpAuthProtocol"),
+ snmpMode=params.get("snmpMode"),
+ snmpPrivPassphrase=params.get("snmpPrivPassphrase"),
+ snmpPrivProtocol=params.get("snmpPrivProtocol"),
+ snmpROCommunity=params.get("snmpROCommunity"),
+ snmpRWCommunity=params.get("snmpRWCommunity"),
+ snmpRetry=params.get("snmpRetry"),
+ snmpTimeout=params.get("snmpTimeout"),
+ snmpUserName=params.get("snmpUserName"),
+ snmpVersion=params.get("snmpVersion"),
+ type=params.get("type"),
+ updateMgmtIPaddressList=params.get("updateMgmtIPaddressList"),
+ userName=params.get("userName"),
+ id=params.get("id"),
+ clean_config=params.get("cleanConfig"),
+ managementIpAddress=params.get("managementIpAddress"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['hostname'] = self.new_object.get('hostname')
+ new_object_params['management_ip_address'] = self.new_object.get('management_ip_address') or \
+ self.new_object.get('ipAddress')
+ new_object_params['mac_address'] = self.new_object.get('macAddress') or \
+ self.new_object.get('mac_address')
+ new_object_params['location_name'] = self.new_object.get('locationName') or \
+ self.new_object.get('location_name')
+ new_object_params['serial_number'] = self.new_object.get('serialNumber') or \
+ self.new_object.get('serial_number')
+ new_object_params['location'] = self.new_object.get('location')
+ new_object_params['family'] = self.new_object.get('family')
+ # new_object_params['type'] = self.new_object.get('type')
+ new_object_params['series'] = self.new_object.get('series')
+ new_object_params['collection_status'] = self.new_object.get('collectionStatus') or \
+ self.new_object.get('collection_status')
+ new_object_params['collection_interval'] = self.new_object.get('collectionInterval') or \
+ self.new_object.get('collection_interval')
+ new_object_params['not_synced_for_minutes'] = self.new_object.get('notSyncedForMinutes') or \
+ self.new_object.get('not_synced_for_minutes')
+ new_object_params['error_code'] = self.new_object.get('errorCode') or \
+ self.new_object.get('error_code')
+ new_object_params['error_description'] = self.new_object.get('errorDescription') or \
+ self.new_object.get('error_description')
+ new_object_params['software_version'] = self.new_object.get('softwareVersion') or \
+ self.new_object.get('software_version')
+ new_object_params['software_type'] = self.new_object.get('softwareType') or \
+ self.new_object.get('software_type')
+ new_object_params['platform_id'] = self.new_object.get('platformId') or \
+ self.new_object.get('platform_id')
+ new_object_params['role'] = self.new_object.get('role')
+ new_object_params['reachability_status'] = self.new_object.get('reachabilityStatus') or \
+ self.new_object.get('reachability_status')
+ new_object_params['up_time'] = self.new_object.get('upTime') or \
+ self.new_object.get('up_time')
+ new_object_params['associated_wlc_ip'] = self.new_object.get('associatedWlcIp') or \
+ 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['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['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')
+ new_object_params['offset'] = self.new_object.get('offset')
+ new_object_params['limit'] = self.new_object.get('limit')
+ return new_object_params
+
+ 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['httpPassword'] = self.new_object.get('httpPassword')
+ new_object_params['httpPort'] = self.new_object.get('httpPort')
+ new_object_params['httpSecure'] = self.new_object.get('httpSecure')
+ new_object_params['httpUserName'] = self.new_object.get('httpUserName')
+ new_object_params['ipAddress'] = self.new_object.get('ipAddress')
+ new_object_params['merakiOrgId'] = self.new_object.get('merakiOrgId')
+ 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['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['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['userName'] = self.new_object.get('userName')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['clean_config'] = self.new_object.get('clean_config')
+ new_object_params['id'] = self.new_object.get('id')
+ return new_object_params
+
+ 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['httpPassword'] = self.new_object.get('httpPassword')
+ new_object_params['httpPort'] = self.new_object.get('httpPort')
+ new_object_params['httpSecure'] = self.new_object.get('httpSecure')
+ new_object_params['httpUserName'] = self.new_object.get('httpUserName')
+ new_object_params['ipAddress'] = self.new_object.get('ipAddress')
+ new_object_params['merakiOrgId'] = self.new_object.get('merakiOrgId')
+ 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['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['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['userName'] = self.new_object.get('userName')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="devices",
+ function="get_device_list",
+ 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="devices",
+ function="get_device_by_id",
+ 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):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ o_id = self.new_object.get("id")
+ name = self.new_object.get("name") or \
+ self.new_object.get('ipAddress')
+ if isinstance(name, list) and len(name) > 0:
+ name = name[0]
+ 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 = [
+ ("cliTransport", "cliTransport"),
+ ("computeDevice", "computeDevice"),
+ ("enablePassword", "enablePassword"),
+ ("extendedDiscoveryInfo", "extendedDiscoveryInfo"),
+ ("httpPassword", "httpPassword"),
+ ("httpPort", "httpPort"),
+ ("httpSecure", "httpSecure"),
+ ("httpUserName", "httpUserName"),
+ ("ipAddress", "ipAddress"),
+ ("merakiOrgId", "merakiOrgId"),
+ ("netconfPort", "netconfPort"),
+ ("serialNumber", "serialNumber"),
+ ("snmpAuthPassphrase", "snmpAuthPassphrase"),
+ ("snmpAuthProtocol", "snmpAuthProtocol"),
+ ("snmpMode", "snmpMode"),
+ ("snmpPrivPassphrase", "snmpPrivPassphrase"),
+ ("snmpPrivProtocol", "snmpPrivProtocol"),
+ ("snmpROCommunity", "snmpROCommunity"),
+ ("snmpRWCommunity", "snmpRWCommunity"),
+ ("snmpRetry", "snmpRetry"),
+ ("snmpTimeout", "snmpTimeout"),
+ ("snmpUserName", "snmpUserName"),
+ ("snmpVersion", "snmpVersion"),
+ ("type", "type"),
+ ("updateMgmtIPaddressList", "updateMgmtIPaddressList"),
+ ("userName", "userName"),
+ ("id", "id"),
+ ("cleanConfig", "clean_config"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) params
+ # If any does not have eq params, it requires update
+ return any(not dnac_compare_equality2(current_obj.get(dnac_param),
+ requested_obj.get(ansible_param))
+ for (dnac_param, ansible_param) in obj_params)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="devices",
+ function="add_device",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name") or \
+ self.new_object.get('ipAddress')
+ if isinstance(name, list) and len(name) > 0:
+ name = name[0]
+ result = None
+ result = self.dnac.exec(
+ family="devices",
+ function="sync_devices",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name") or \
+ self.new_object.get('ipAddress')
+ if isinstance(name, list) and len(name) > 0:
+ name = name[0]
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ if id_:
+ self.new_object.update(dict(id=id_))
+ result = self.dnac.exec(
+ family="devices",
+ function="delete_device_by_id",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = NetworkDevice(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_by_ip_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_by_ip_info.py
new file mode 100644
index 000000000..a766c17dc
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_by_ip_info.py
@@ -0,0 +1,98 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ ipAddress=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ ip_address=params.get("ipAddress"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("ipAddress")
+ if id:
+ response = dnac.exec(
+ family="devices",
+ function='get_network_device_by_ip',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_by_serial_number_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_by_serial_number_info.py
new file mode 100644
index 000000000..68dfbe93f
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_by_serial_number_info.py
@@ -0,0 +1,98 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ serialNumber=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ serial_number=params.get("serialNumber"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("serialNumber")
+ if id:
+ response = dnac.exec(
+ family="devices",
+ function='get_device_by_serial_number',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_chassis_details_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_chassis_details_info.py
new file mode 100644
index 000000000..a38175d59
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_chassis_details_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_id=params.get("deviceId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_chassis_details_for_device',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_config_count_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_config_count_info.py
new file mode 100644
index 000000000..9c0e4ad81
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_config_count_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_device_config_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_config_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_config_info.py
new file mode 100644
index 000000000..9b91c9106
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_config_info.py
@@ -0,0 +1,100 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ networkDeviceId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ network_device_id=params.get("networkDeviceId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("networkDeviceId")
+ if id:
+ response = dnac.exec(
+ family="devices",
+ function='get_device_config_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="devices",
+ function='get_device_config_for_all_devices',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_count_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_count_info.py
new file mode 100644
index 000000000..b2e2ad364
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_count_info.py
@@ -0,0 +1,100 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_id=params.get("deviceId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("deviceId")
+ if id:
+ response = dnac.exec(
+ family="devices",
+ function='get_device_interface_count_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="devices",
+ function='get_device_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_custom_prompt.py b/ansible_collections/cisco/dnac/plugins/action/network_device_custom_prompt.py
new file mode 100644
index 000000000..9d7140d93
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_custom_prompt.py
@@ -0,0 +1,88 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ usernamePrompt=dict(type="str"),
+ passwordPrompt=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ usernamePrompt=params.get("usernamePrompt"),
+ passwordPrompt=params.get("passwordPrompt"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="system_settings",
+ function='custom_prompt_post_api',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_custom_prompt_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_custom_prompt_info.py
new file mode 100644
index 000000000..20e425c8d
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_custom_prompt_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="system_settings",
+ function='custom_prompt_support_get_api',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_equipment_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_equipment_info.py
new file mode 100644
index 000000000..2365b8a11
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_equipment_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceUuid=dict(type="str"),
+ type=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_uuid=params.get("deviceUuid"),
+ type=params.get("type"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='return_power_supply_fan_details_for_the_given_device',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_export.py b/ansible_collections/cisco/dnac/plugins/action/network_device_export.py
new file mode 100644
index 000000000..ed7447eec
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_export.py
@@ -0,0 +1,94 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceUuids=dict(type="list"),
+ id=dict(type="str"),
+ operationEnum=dict(type="str"),
+ parameters=dict(type="list"),
+ password=dict(type="str", no_log=True),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ deviceUuids=params.get("deviceUuids"),
+ id=params.get("id"),
+ operationEnum=params.get("operationEnum"),
+ parameters=params.get("parameters"),
+ password=params.get("password"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='export_device_list',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_functional_capability_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_functional_capability_info.py
new file mode 100644
index 000000000..fb00725a2
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_functional_capability_info.py
@@ -0,0 +1,104 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceId=dict(type="str"),
+ functionName=dict(type="list"),
+ id=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_id=params.get("deviceId"),
+ function_name=params.get("functionName"),
+ id=params.get("id"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ if id:
+ response = dnac.exec(
+ family="devices",
+ function='get_functional_capability_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="devices",
+ function='get_functional_capability_for_devices',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_global_polling_interval_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_global_polling_interval_info.py
new file mode 100644
index 000000000..83b408803
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_global_polling_interval_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_polling_interval_for_all_devices',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_info.py
new file mode 100644
index 000000000..4fc223827
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_info.py
@@ -0,0 +1,166 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ hostname=dict(type="list"),
+ managementIpAddress=dict(type="list"),
+ macAddress=dict(type="list"),
+ locationName=dict(type="list"),
+ serialNumber=dict(type="list"),
+ location=dict(type="list"),
+ family=dict(type="list"),
+ type=dict(type="list"),
+ series=dict(type="list"),
+ collectionStatus=dict(type="list"),
+ collectionInterval=dict(type="list"),
+ notSyncedForMinutes=dict(type="list"),
+ errorCode=dict(type="list"),
+ errorDescription=dict(type="list"),
+ softwareVersion=dict(type="list"),
+ softwareType=dict(type="list"),
+ platformId=dict(type="list"),
+ role=dict(type="list"),
+ reachabilityStatus=dict(type="list"),
+ upTime=dict(type="list"),
+ associatedWlcIp=dict(type="list"),
+ license_name=dict(type="list"),
+ license_type=dict(type="list"),
+ license_status=dict(type="list"),
+ module_name=dict(type="list"),
+ module_equpimenttype=dict(type="list"),
+ module_servicestate=dict(type="list"),
+ module_vendorequipmenttype=dict(type="list"),
+ module_partnumber=dict(type="list"),
+ module_operationstatecode=dict(type="list"),
+ id=dict(type="str"),
+ deviceSupportLevel=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ hostname=params.get("hostname"),
+ management_ip_address=params.get("managementIpAddress"),
+ mac_address=params.get("macAddress"),
+ location_name=params.get("locationName"),
+ serial_number=params.get("serialNumber"),
+ location=params.get("location"),
+ family=params.get("family"),
+ type=params.get("type"),
+ series=params.get("series"),
+ collection_status=params.get("collectionStatus"),
+ collection_interval=params.get("collectionInterval"),
+ not_synced_for_minutes=params.get("notSyncedForMinutes"),
+ error_code=params.get("errorCode"),
+ error_description=params.get("errorDescription"),
+ software_version=params.get("softwareVersion"),
+ software_type=params.get("softwareType"),
+ platform_id=params.get("platformId"),
+ role=params.get("role"),
+ reachability_status=params.get("reachabilityStatus"),
+ up_time=params.get("upTime"),
+ associated_wlc_ip=params.get("associatedWlcIp"),
+ license_name=params.get("license_name"),
+ license_type=params.get("license_type"),
+ license_status=params.get("license_status"),
+ 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_partnumber=params.get("module_partnumber"),
+ module_operationstatecode=params.get("module_operationstatecode"),
+ id=params.get("id"),
+ device_support_level=params.get("deviceSupportLevel"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ if id:
+ response = dnac.exec(
+ family="devices",
+ function='get_device_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="devices",
+ function='get_device_list',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_interface_neighbor_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_interface_neighbor_info.py
new file mode 100644
index 000000000..2272d543d
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_interface_neighbor_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceUuid=dict(type="str"),
+ interfaceUuid=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_uuid=params.get("deviceUuid"),
+ interface_uuid=params.get("interfaceUuid"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_connected_device_detail',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_interface_poe_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_interface_poe_info.py
new file mode 100644
index 000000000..d9a64e913
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_interface_poe_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceUuid=dict(type="str"),
+ interfaceNameList=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_uuid=params.get("deviceUuid"),
+ interface_name_list=params.get("interfaceNameList"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='poe_interface_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_inventory_insight_link_mismatch_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_inventory_insight_link_mismatch_info.py
new file mode 100644
index 000000000..63cdcd94b
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_inventory_insight_link_mismatch_info.py
@@ -0,0 +1,99 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteId=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ category=dict(type="str"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ site_id=params.get("siteId"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ category=params.get("category"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='inventory_insight_device_link_mismatch',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_lexicographically_sorted_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_lexicographically_sorted_info.py
new file mode 100644
index 000000000..297750c13
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_lexicographically_sorted_info.py
@@ -0,0 +1,131 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ vrfName=dict(type="str"),
+ managementIpAddress=dict(type="str"),
+ hostname=dict(type="str"),
+ macAddress=dict(type="str"),
+ family=dict(type="str"),
+ collectionStatus=dict(type="str"),
+ collectionInterval=dict(type="str"),
+ softwareVersion=dict(type="str"),
+ softwareType=dict(type="str"),
+ reachabilityStatus=dict(type="str"),
+ reachabilityFailureReason=dict(type="str"),
+ errorCode=dict(type="str"),
+ platformId=dict(type="str"),
+ series=dict(type="str"),
+ type=dict(type="str"),
+ serialNumber=dict(type="str"),
+ upTime=dict(type="str"),
+ role=dict(type="str"),
+ roleSource=dict(type="str"),
+ associatedWlcIp=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ vrf_name=params.get("vrfName"),
+ management_ip_address=params.get("managementIpAddress"),
+ hostname=params.get("hostname"),
+ mac_address=params.get("macAddress"),
+ family=params.get("family"),
+ collection_status=params.get("collectionStatus"),
+ collection_interval=params.get("collectionInterval"),
+ software_version=params.get("softwareVersion"),
+ software_type=params.get("softwareType"),
+ reachability_status=params.get("reachabilityStatus"),
+ reachability_failure_reason=params.get("reachabilityFailureReason"),
+ error_code=params.get("errorCode"),
+ platform_id=params.get("platformId"),
+ series=params.get("series"),
+ type=params.get("type"),
+ serial_number=params.get("serialNumber"),
+ up_time=params.get("upTime"),
+ role=params.get("role"),
+ role_source=params.get("roleSource"),
+ associated_wlc_ip=params.get("associatedWlcIp"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_device_values_that_match_fully_or_partially_an_attribute',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_linecard_details_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_linecard_details_info.py
new file mode 100644
index 000000000..70cb70546
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_linecard_details_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceUuid=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_uuid=params.get("deviceUuid"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_linecard_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_meraki_organization_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_meraki_organization_info.py
new file mode 100644
index 000000000..37c9f0726
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_meraki_organization_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_organization_list_for_meraki',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_module_count_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_module_count_info.py
new file mode 100644
index 000000000..10cd5608b
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_module_count_info.py
@@ -0,0 +1,97 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceId=dict(type="str"),
+ nameList=dict(type="list"),
+ vendorEquipmentTypeList=dict(type="list"),
+ partNumberList=dict(type="list"),
+ operationalStateCodeList=dict(type="list"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_id=params.get("deviceId"),
+ name_list=params.get("nameList"),
+ vendor_equipment_type_list=params.get("vendorEquipmentTypeList"),
+ part_number_list=params.get("partNumberList"),
+ operational_state_code_list=params.get("operationalStateCodeList"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_module_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_module_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_module_info.py
new file mode 100644
index 000000000..b4a18aded
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_module_info.py
@@ -0,0 +1,114 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceId=dict(type="str"),
+ limit=dict(type="int"),
+ offset=dict(type="int"),
+ nameList=dict(type="list"),
+ vendorEquipmentTypeList=dict(type="list"),
+ partNumberList=dict(type="list"),
+ operationalStateCodeList=dict(type="list"),
+ id=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_id=params.get("deviceId"),
+ limit=params.get("limit"),
+ offset=params.get("offset"),
+ name_list=params.get("nameList"),
+ vendor_equipment_type_list=params.get("vendorEquipmentTypeList"),
+ part_number_list=params.get("partNumberList"),
+ operational_state_code_list=params.get("operationalStateCodeList"),
+ id=params.get("id"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ if id:
+ response = dnac.exec(
+ family="devices",
+ function='get_module_info_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="devices",
+ function='get_modules',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_poe_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_poe_info.py
new file mode 100644
index 000000000..9ba708f64
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_poe_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceUuid=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_uuid=params.get("deviceUuid"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='poe_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_polling_interval_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_polling_interval_info.py
new file mode 100644
index 000000000..2e9bb7e45
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_polling_interval_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_polling_interval_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_range_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_range_info.py
new file mode 100644
index 000000000..4fa406d14
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_range_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ startIndex=dict(type="int"),
+ recordsToReturn=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ start_index=params.get("startIndex"),
+ records_to_return=params.get("recordsToReturn"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_network_device_by_pagination_range',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_register_for_wsa_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_register_for_wsa_info.py
new file mode 100644
index 000000000..98532f72e
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_register_for_wsa_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ serialNumber=dict(type="str"),
+ macaddress=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ serial_number=params.get("serialNumber"),
+ macaddress=params.get("macaddress"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_devices_registered_for_wsa_notification',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_stack_details_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_stack_details_info.py
new file mode 100644
index 000000000..500e44ab9
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_stack_details_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_id=params.get("deviceId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_stack_details_for_device',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_summary_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_summary_info.py
new file mode 100644
index 000000000..00b4930b9
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_summary_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_device_summary',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_supervisor_card_details_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_supervisor_card_details_info.py
new file mode 100644
index 000000000..409446f66
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_supervisor_card_details_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceUuid=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_uuid=params.get("deviceUuid"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_supervisor_card_detail',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_sync.py b/ansible_collections/cisco/dnac/plugins/action/network_device_sync.py
new file mode 100644
index 000000000..dcfcfb17f
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_sync.py
@@ -0,0 +1,88 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ payload=dict(type="list"),
+ forceSync=dict(type="bool"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ payload=params.get("payload"),
+ force_sync=params.get("forceSync"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='sync_devices_using_forcesync',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_update_role.py b/ansible_collections/cisco/dnac/plugins/action/network_device_update_role.py
new file mode 100644
index 000000000..8a59a6197
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_update_role.py
@@ -0,0 +1,90 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+ role=dict(type="str"),
+ roleSource=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ role=params.get("role"),
+ roleSource=params.get("roleSource"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='update_device_role',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_user_defined_field.py b/ansible_collections/cisco/dnac/plugins/action/network_device_user_defined_field.py
new file mode 100644
index 000000000..724221ee9
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_user_defined_field.py
@@ -0,0 +1,259 @@
+#!/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", "absent"]),
+ name=dict(type="str"),
+ description=dict(type="str"),
+ id=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["id", "name"], True),
+ ("state", "absent", ["id", "name"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class NetworkDeviceUserDefinedField(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ name=params.get("name"),
+ description=params.get("description"),
+ id=params.get("id"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['id'] = id or self.new_object.get('id')
+ new_object_params['name'] = name or self.new_object.get('name')
+ return new_object_params
+
+ 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')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['id'] = self.new_object.get('id')
+ return new_object_params
+
+ def update_by_id_params(self):
+ new_object_params = {}
+ new_object_params['name'] = self.new_object.get('name')
+ new_object_params['description'] = self.new_object.get('description')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="devices",
+ function="get_all_user_defined_fields",
+ 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
+ try:
+ items = self.dnac.exec(
+ family="devices",
+ function="get_all_user_defined_fields",
+ params=self.get_all_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):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ 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 = [
+ ("name", "name"),
+ ("description", "description"),
+ ("id", "id"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="devices",
+ function="create_user_defined_field",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ if id_:
+ self.new_object.update(dict(id=id_))
+ result = self.dnac.exec(
+ family="devices",
+ function="update_user_defined_field",
+ params=self.update_by_id_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ if id_:
+ self.new_object.update(dict(id=id_))
+ result = self.dnac.exec(
+ family="devices",
+ function="delete_user_defined_field",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = NetworkDeviceUserDefinedField(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_user_defined_field_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_user_defined_field_info.py
new file mode 100644
index 000000000..463db72de
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_user_defined_field_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+ name=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ name=params.get("name"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_all_user_defined_fields',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_vlan_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_vlan_info.py
new file mode 100644
index 000000000..7acbd4c1f
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_vlan_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+ interfaceType=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ interface_type=params.get("interfaceType"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_device_interface_vlans',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_wireless_lan_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_wireless_lan_info.py
new file mode 100644
index 000000000..313be4cc6
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_wireless_lan_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_wireless_lan_controller_details_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_device_with_snmp_v3_des_info.py b/ansible_collections/cisco/dnac/plugins/action/network_device_with_snmp_v3_des_info.py
new file mode 100644
index 000000000..8650c51d9
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_device_with_snmp_v3_des_info.py
@@ -0,0 +1,97 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteId=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ site_id=params.get("siteId"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_devices_with_snmpv3_des',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_info.py b/ansible_collections/cisco/dnac/plugins/action/network_info.py
new file mode 100644
index 000000000..f4b75fdf4
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ site_id=params.get("siteId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function='get_network',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_update.py b/ansible_collections/cisco/dnac/plugins/action/network_update.py
new file mode 100644
index 000000000..24f83abaa
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_update.py
@@ -0,0 +1,88 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ settings=dict(type="dict"),
+ siteId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ settings=params.get("settings"),
+ site_id=params.get("siteId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function='update_network',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_v2.py b/ansible_collections/cisco/dnac/plugins/action/network_v2.py
new file mode 100644
index 000000000..c1d4d0c1c
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_v2.py
@@ -0,0 +1,214 @@
+#!/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"]),
+ settings=dict(type="dict"),
+ siteId=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["settings", "siteId"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class NetworkV2(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ settings=params.get("settings"),
+ site_id=params.get("siteId"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['site_id'] = self.new_object.get('siteId') or \
+ self.new_object.get('site_id')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['settings'] = self.new_object.get('settings')
+ return new_object_params
+
+ def update_by_id_params(self):
+ new_object_params = {}
+ new_object_params['settings'] = self.new_object.get('settings')
+ 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="network_settings",
+ function="get_network_v2",
+ 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")
+ o_id = o_id or self.new_object.get("site_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")
+ _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")
+ if _id:
+ self.new_object.update(dict(id=_id))
+ self.new_object.update(dict(site_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 = [
+ ("settings", "settings"),
+ ("siteId", "site_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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="network_settings",
+ function="create_network_v2",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ id = id or self.new_object.get("site_id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ id_ = id_ or prev_obj_name.get("siteId")
+ if id_:
+ self.new_object.update(dict(site_id=id_))
+ result = self.dnac.exec(
+ family="network_settings",
+ function="update_network_v2",
+ params=self.update_by_id_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = NetworkV2(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/network_v2_info.py b/ansible_collections/cisco/dnac/plugins/action/network_v2_info.py
new file mode 100644
index 000000000..39f1e6b20
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/network_v2_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ site_id=params.get("siteId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function='get_network_v2',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/nfv_profile.py b/ansible_collections/cisco/dnac/plugins/action/nfv_profile.py
new file mode 100644
index 000000000..233762cab
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/nfv_profile.py
@@ -0,0 +1,248 @@
+#!/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", "absent"]),
+ profileName=dict(type="str"),
+ device=dict(type="list"),
+ id=dict(type="str"),
+ name=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["id"], True),
+ ("state", "absent", ["id"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class NfvProfile(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ profileName=params.get("profileName"),
+ device=params.get("device"),
+ id=params.get("id"),
+ name=params.get("name"),
+ )
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['profileName'] = self.new_object.get('profileName')
+ new_object_params['device'] = self.new_object.get('device')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['name'] = self.new_object.get('name')
+ new_object_params['id'] = self.new_object.get('id')
+ return new_object_params
+
+ def update_by_id_params(self):
+ new_object_params = {}
+ new_object_params['device'] = self.new_object.get('device')
+ new_object_params['name'] = self.new_object.get('name')
+ new_object_params['id'] = self.new_object.get('id')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ # NOTE: Does not have get all
+ return result
+
+ def get_object_by_id(self, id):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="site_design",
+ function="get_nfv_profile",
+ 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):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ 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 = [
+ ("profileName", "profileName"),
+ ("device", "device"),
+ ("id", "id"),
+ ("name", "name"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="site_design",
+ function="create_nfv_profile",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ if id_:
+ self.new_object.update(dict(id=id_))
+ result = self.dnac.exec(
+ family="site_design",
+ function="update_nfv_profile",
+ params=self.update_by_id_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ if id_:
+ self.new_object.update(dict(id=id_))
+ result = self.dnac.exec(
+ family="site_design",
+ function="delete_nfv_profile",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = NfvProfile(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/nfv_profile_info.py b/ansible_collections/cisco/dnac/plugins/action/nfv_profile_info.py
new file mode 100644
index 000000000..ce5a8308b
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/nfv_profile_info.py
@@ -0,0 +1,104 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ name=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ name=params.get("name"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ if id:
+ response = dnac.exec(
+ family="site_design",
+ function='get_nfv_profile',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/nfv_provision.py b/ansible_collections/cisco/dnac/plugins/action/nfv_provision.py
new file mode 100644
index 000000000..9d4609a64
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/nfv_provision.py
@@ -0,0 +1,90 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteProfile=dict(type="list"),
+ provisioning=dict(type="list"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ siteProfile=params.get("siteProfile"),
+ provisioning=params.get("provisioning"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="site_design",
+ function='provision_nfv',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/nfv_provision_detail_info.py b/ansible_collections/cisco/dnac/plugins/action/nfv_provision_detail_info.py
new file mode 100644
index 000000000..c2f2a8d6a
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/nfv_provision_detail_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceIp=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_ip=params.get("deviceIp"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="site_design",
+ function='get_device_details_by_ip',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/nfv_provision_details.py b/ansible_collections/cisco/dnac/plugins/action/nfv_provision_details.py
new file mode 100644
index 000000000..5bc7aff15
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/nfv_provision_details.py
@@ -0,0 +1,88 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ device_ip=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ device_ip=params.get("device_ip"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="site_design",
+ function='nfv_provisioning_detail',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/path_trace.py b/ansible_collections/cisco/dnac/plugins/action/path_trace.py
new file mode 100644
index 000000000..133122616
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/path_trace.py
@@ -0,0 +1,286 @@
+#!/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,
+)
+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", "absent"]),
+ controlPath=dict(type="bool"),
+ destIP=dict(type="str"),
+ destPort=dict(type="str"),
+ inclusions=dict(type="list"),
+ periodicRefresh=dict(type="bool"),
+ protocol=dict(type="str"),
+ sourceIP=dict(type="str"),
+ sourcePort=dict(type="str"),
+ flowAnalysisId=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["flowAnalysisId"], True),
+ ("state", "absent", ["flowAnalysisId"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class PathTrace(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ controlPath=params.get("controlPath"),
+ destIP=params.get("destIP"),
+ destPort=params.get("destPort"),
+ inclusions=params.get("inclusions"),
+ periodicRefresh=params.get("periodicRefresh"),
+ protocol=params.get("protocol"),
+ sourceIP=params.get("sourceIP"),
+ sourcePort=params.get("sourcePort"),
+ flow_analysis_id=params.get("flowAnalysisId"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['periodic_refresh'] = self.new_object.get('periodicRefresh') or \
+ self.new_object.get('periodic_refresh')
+ new_object_params['source_ip'] = self.new_object.get('sourceIP') or \
+ self.new_object.get('source_ip')
+ new_object_params['dest_ip'] = self.new_object.get('destIP') or \
+ self.new_object.get('dest_ip')
+ new_object_params['source_port'] = self.new_object.get('sourcePort') or \
+ self.new_object.get('source_port')
+ new_object_params['dest_port'] = self.new_object.get('destPort') or \
+ self.new_object.get('dest_port')
+ new_object_params['gt_create_time'] = self.new_object.get('gtCreateTime') or \
+ self.new_object.get('gt_create_time')
+ new_object_params['lt_create_time'] = self.new_object.get('ltCreateTime') or \
+ self.new_object.get('lt_create_time')
+ new_object_params['protocol'] = self.new_object.get('protocol')
+ new_object_params['status'] = self.new_object.get('status')
+ new_object_params['task_id'] = self.new_object.get('taskId') or \
+ self.new_object.get('task_id')
+ new_object_params['last_update_time'] = self.new_object.get('lastUpdateTime') or \
+ self.new_object.get('last_update_time')
+ new_object_params['limit'] = self.new_object.get('limit')
+ new_object_params['offset'] = self.new_object.get('offset')
+ new_object_params['order'] = self.new_object.get('order')
+ new_object_params['sort_by'] = self.new_object.get('sortBy') or \
+ self.new_object.get('sort_by')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['controlPath'] = self.new_object.get('controlPath')
+ 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['protocol'] = self.new_object.get('protocol')
+ new_object_params['sourceIP'] = self.new_object.get('sourceIP')
+ new_object_params['sourcePort'] = self.new_object.get('sourcePort')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['flow_analysis_id'] = self.new_object.get('flow_analysis_id')
+ 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="path_trace",
+ function="retrives_all_previous_pathtraces_summary",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ result = items
+ except Exception:
+ result = None
+ return result
+
+ def get_object_by_id(self, id):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="path_trace",
+ function="retrieves_previous_pathtrace",
+ params={"flow_analysis_id": id}
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ if 'request' in items:
+ items = items.get('request')
+ result = items
+ 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("flow_analysis_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")
+ _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")
+ if _id:
+ self.new_object.update(dict(id=_id))
+ self.new_object.update(dict(flow_analysis_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 = [
+ ("controlPath", "controlPath"),
+ ("destIP", "destIP"),
+ ("destPort", "destPort"),
+ ("inclusions", "inclusions"),
+ ("periodicRefresh", "periodicRefresh"),
+ ("protocol", "protocol"),
+ ("sourceIP", "sourceIP"),
+ ("sourcePort", "sourcePort"),
+ ("flowAnalysisId", "flow_analysis_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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="path_trace",
+ function="initiate_a_new_pathtrace",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ id = id or self.new_object.get("flow_analysis_id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ id_ = id_ or prev_obj_name.get("flowAnalysisId")
+ if id_:
+ self.new_object.update(dict(id=id_))
+ result = self.dnac.exec(
+ family="path_trace",
+ function="deletes_pathtrace_by_id",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = PathTrace(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ 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:
+ response = obj.create()
+ dnac.object_created()
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/path_trace_info.py b/ansible_collections/cisco/dnac/plugins/action/path_trace_info.py
new file mode 100644
index 000000000..be9d0dbc2
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/path_trace_info.py
@@ -0,0 +1,130 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ periodicRefresh=dict(type="bool"),
+ sourceIP=dict(type="str"),
+ destIP=dict(type="str"),
+ sourcePort=dict(type="str"),
+ destPort=dict(type="str"),
+ gtCreateTime=dict(type="str"),
+ ltCreateTime=dict(type="str"),
+ protocol=dict(type="str"),
+ status=dict(type="str"),
+ taskId=dict(type="str"),
+ lastUpdateTime=dict(type="str"),
+ limit=dict(type="int"),
+ offset=dict(type="int"),
+ order=dict(type="str"),
+ sortBy=dict(type="str"),
+ flowAnalysisId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ periodic_refresh=params.get("periodicRefresh"),
+ source_ip=params.get("sourceIP"),
+ dest_ip=params.get("destIP"),
+ source_port=params.get("sourcePort"),
+ dest_port=params.get("destPort"),
+ gt_create_time=params.get("gtCreateTime"),
+ lt_create_time=params.get("ltCreateTime"),
+ protocol=params.get("protocol"),
+ status=params.get("status"),
+ task_id=params.get("taskId"),
+ last_update_time=params.get("lastUpdateTime"),
+ limit=params.get("limit"),
+ offset=params.get("offset"),
+ order=params.get("order"),
+ sort_by=params.get("sortBy"),
+ flow_analysis_id=params.get("flowAnalysisId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("flowAnalysisId")
+ if id:
+ response = dnac.exec(
+ family="path_trace",
+ function='retrieves_previous_pathtrace',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="path_trace",
+ function='retrives_all_previous_pathtraces_summary',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/planned_access_points_info.py b/ansible_collections/cisco/dnac/plugins/action/planned_access_points_info.py
new file mode 100644
index 000000000..86cd1a87b
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/planned_access_points_info.py
@@ -0,0 +1,95 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ floorId=dict(type="str"),
+ limit=dict(type="int"),
+ offset=dict(type="int"),
+ radios=dict(type="bool"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ floor_id=params.get("floorId"),
+ limit=params.get("limit"),
+ offset=params.get("offset"),
+ radios=params.get("radios"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='get_planned_access_points_for_floor',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/platform_nodes_configuration_summary_info.py b/ansible_collections/cisco/dnac/plugins/action/platform_nodes_configuration_summary_info.py
new file mode 100644
index 000000000..8063ae16c
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/platform_nodes_configuration_summary_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="platform_configuration",
+ function='nodes_configuration_summary',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/platform_release_summary_info.py b/ansible_collections/cisco/dnac/plugins/action/platform_release_summary_info.py
new file mode 100644
index 000000000..449ac4cf8
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/platform_release_summary_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="platform_configuration",
+ function='release_summary',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_device.py b/ansible_collections/cisco/dnac/plugins/action/pnp_device.py
new file mode 100644
index 000000000..ec9c0f36a
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_device.py
@@ -0,0 +1,344 @@
+#!/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", "absent"]),
+ _id=dict(type="str"),
+ deviceInfo=dict(type="dict"),
+ runSummaryList=dict(type="list"),
+ systemResetWorkflow=dict(type="dict"),
+ systemWorkflow=dict(type="dict"),
+ tenantId=dict(type="str"),
+ version=dict(type="int"),
+ workflow=dict(type="dict"),
+ workflowParameters=dict(type="dict"),
+ id=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["id", "deviceInfo"], True),
+ ("state", "absent", ["id", "deviceInfo"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class PnpDevice(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ _id=params.get("_id"),
+ deviceInfo=params.get("deviceInfo"),
+ runSummaryList=params.get("runSummaryList"),
+ systemResetWorkflow=params.get("systemResetWorkflow"),
+ systemWorkflow=params.get("systemWorkflow"),
+ tenantId=params.get("tenantId"),
+ version=params.get("version"),
+ workflow=params.get("workflow"),
+ workflowParameters=params.get("workflowParameters"),
+ id=params.get("id"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['limit'] = self.new_object.get('limit')
+ new_object_params['offset'] = self.new_object.get('offset')
+ new_object_params['sort'] = self.new_object.get('sort')
+ new_object_params['sort_order'] = self.new_object.get('sortOrder') or \
+ self.new_object.get('sort_order')
+ new_object_params['serial_number'] = self.new_object.get('serialNumber') or \
+ self.new_object.get('serial_number')
+ new_object_params['state'] = self.new_object.get('state_') or \
+ self.new_object.get('state')
+ new_object_params['onb_state'] = self.new_object.get('onbState') or \
+ self.new_object.get('onb_state')
+ new_object_params['cm_state'] = self.new_object.get('cmState') or \
+ self.new_object.get('cm_state')
+ new_object_params['name'] = name or self.new_object.get('name')
+ new_object_params['pid'] = self.new_object.get('pid')
+ new_object_params['source'] = self.new_object.get('source')
+ new_object_params['project_id'] = self.new_object.get('projectId') or \
+ self.new_object.get('project_id')
+ new_object_params['workflow_id'] = self.new_object.get('workflowId') or \
+ self.new_object.get('workflow_id')
+ new_object_params['project_name'] = self.new_object.get('projectName') or \
+ self.new_object.get('project_name')
+ new_object_params['workflow_name'] = self.new_object.get('workflowName') or \
+ self.new_object.get('workflow_name')
+ new_object_params['smart_account_id'] = self.new_object.get('smartAccountId') or \
+ self.new_object.get('smart_account_id')
+ new_object_params['virtual_account_id'] = self.new_object.get('virtualAccountId') or \
+ self.new_object.get('virtual_account_id')
+ new_object_params['last_contact'] = self.new_object.get('lastContact') or \
+ self.new_object.get('last_contact')
+ new_object_params['mac_address'] = self.new_object.get('macAddress') or \
+ self.new_object.get('mac_address')
+ new_object_params['hostname'] = self.new_object.get('hostname')
+ new_object_params['site_name'] = self.new_object.get('siteName') or \
+ self.new_object.get('site_name')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['_id'] = self.new_object.get('_id')
+ new_object_params['deviceInfo'] = self.new_object.get('deviceInfo')
+ new_object_params['runSummaryList'] = self.new_object.get('runSummaryList')
+ new_object_params['systemResetWorkflow'] = self.new_object.get('systemResetWorkflow')
+ new_object_params['systemWorkflow'] = self.new_object.get('systemWorkflow')
+ new_object_params['tenantId'] = self.new_object.get('tenantId')
+ new_object_params['version'] = self.new_object.get('version')
+ new_object_params['workflow'] = self.new_object.get('workflow')
+ new_object_params['workflowParameters'] = self.new_object.get('workflowParameters')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['id'] = self.new_object.get('id')
+ return new_object_params
+
+ def update_by_id_params(self):
+ new_object_params = {}
+ new_object_params['_id'] = self.new_object.get('_id')
+ new_object_params['deviceInfo'] = self.new_object.get('deviceInfo')
+ new_object_params['runSummaryList'] = self.new_object.get('runSummaryList')
+ new_object_params['systemResetWorkflow'] = self.new_object.get('systemResetWorkflow')
+ new_object_params['systemWorkflow'] = self.new_object.get('systemWorkflow')
+ new_object_params['tenantId'] = self.new_object.get('tenantId')
+ new_object_params['version'] = self.new_object.get('version')
+ new_object_params['workflow'] = self.new_object.get('workflow')
+ new_object_params['workflowParameters'] = self.new_object.get('workflowParameters')
+ new_object_params['id'] = self.new_object.get('id')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="device_onboarding_pnp",
+ function="get_device_list",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, list):
+ for i in items:
+ if isinstance(i, dict) and i.get('deviceInfo'):
+ tmp = i.get('deviceInfo')
+ if isinstance(tmp, dict) and tmp.get('name') == name:
+ result = dict(i)
+ break
+ except Exception:
+ result = None
+ return result
+
+ def get_object_by_id(self, id):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="device_onboarding_pnp",
+ function="get_device_by_id",
+ params={"id": id}
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ result = result or get_dict_result(items, 'id', id)
+ except Exception:
+ result = None
+ return result
+
+ def exists(self):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ o_id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ o_id = o_id or self.new_object.get("_id")
+ device_info = self.new_object.get('deviceInfo')
+ if device_info and isinstance(device_info, dict) and device_info.get('name'):
+ name = name or device_info.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 = [
+ ("_id", "_id"),
+ ("deviceInfo", "deviceInfo"),
+ ("runSummaryList", "runSummaryList"),
+ ("systemResetWorkflow", "systemResetWorkflow"),
+ ("systemWorkflow", "systemWorkflow"),
+ ("tenantId", "tenantId"),
+ ("version", "version"),
+ ("workflow", "workflow"),
+ ("workflowParameters", "workflowParameters"),
+ ("id", "id"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="device_onboarding_pnp",
+ function="add_device",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ id = id or self.new_object.get("_id")
+ device_info = self.new_object.get('deviceInfo')
+ if device_info and isinstance(device_info, dict) and device_info.get('name'):
+ name = name or device_info.get('name')
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ if id_:
+ self.new_object.update(dict(id=id_))
+ result = self.dnac.exec(
+ family="device_onboarding_pnp",
+ function="update_device",
+ params=self.update_by_id_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ id = id or self.new_object.get("_id")
+ device_info = self.new_object.get('deviceInfo')
+ if device_info and isinstance(device_info, dict) and device_info.get('name'):
+ name = name or device_info.get('name')
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ if id_:
+ self.new_object.update(dict(id=id_))
+ result = self.dnac.exec(
+ family="device_onboarding_pnp",
+ function="delete_device_by_id_from_pnp",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = PnpDevice(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_device_authorize.py b/ansible_collections/cisco/dnac/plugins/action/pnp_device_authorize.py
new file mode 100644
index 000000000..2e6f18aca
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_device_authorize.py
@@ -0,0 +1,86 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceIdList=dict(type="list"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ deviceIdList=params.get("deviceIdList"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="cisco_dna_center_system",
+ function='authorize_device',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_device_claim.py b/ansible_collections/cisco/dnac/plugins/action/pnp_device_claim.py
new file mode 100644
index 000000000..26abade74
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_device_claim.py
@@ -0,0 +1,102 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ configFileUrl=dict(type="str"),
+ configId=dict(type="str"),
+ deviceClaimList=dict(type="list"),
+ fileServiceId=dict(type="str"),
+ imageId=dict(type="str"),
+ imageUrl=dict(type="str"),
+ populateInventory=dict(type="bool"),
+ projectId=dict(type="str"),
+ workflowId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ configFileUrl=params.get("configFileUrl"),
+ configId=params.get("configId"),
+ deviceClaimList=params.get("deviceClaimList"),
+ fileServiceId=params.get("fileServiceId"),
+ imageId=params.get("imageId"),
+ imageUrl=params.get("imageUrl"),
+ populateInventory=params.get("populateInventory"),
+ projectId=params.get("projectId"),
+ workflowId=params.get("workflowId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='claim_device',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_device_claim_to_site.py b/ansible_collections/cisco/dnac/plugins/action/pnp_device_claim_to_site.py
new file mode 100644
index 000000000..1ec73115c
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_device_claim_to_site.py
@@ -0,0 +1,108 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceId=dict(type="str"),
+ siteId=dict(type="str"),
+ type=dict(type="str"),
+ imageInfo=dict(type="dict"),
+ configInfo=dict(type="list"),
+ rfProfile=dict(type="str"),
+ staticIP=dict(type="str"),
+ subnetMask=dict(type="str"),
+ gateway=dict(type="str"),
+ vlanID=dict(type="str"),
+ interfaceName=dict(type="str"),
+ sensorProfile=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ deviceId=params.get("deviceId"),
+ siteId=params.get("siteId"),
+ type=params.get("type"),
+ imageInfo=params.get("imageInfo"),
+ configInfo=params.get("configInfo"),
+ rfProfile=params.get("rfProfile"),
+ staticIP=params.get("staticIP"),
+ subnetMask=params.get("subnetMask"),
+ gateway=params.get("gateway"),
+ vlanID=params.get("vlanID"),
+ interfaceName=params.get("interfaceName"),
+ sensorProfile=params.get("sensorProfile"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='claim_a_device_to_a_site',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_device_config_preview.py b/ansible_collections/cisco/dnac/plugins/action/pnp_device_config_preview.py
new file mode 100644
index 000000000..0caf043d2
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_device_config_preview.py
@@ -0,0 +1,90 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceId=dict(type="str"),
+ siteId=dict(type="str"),
+ type=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ deviceId=params.get("deviceId"),
+ siteId=params.get("siteId"),
+ type=params.get("type"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='preview_config',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_device_count_info.py b/ansible_collections/cisco/dnac/plugins/action/pnp_device_count_info.py
new file mode 100644
index 000000000..933b8bd0c
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_device_count_info.py
@@ -0,0 +1,115 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ serialNumber=dict(type="list"),
+ state_=dict(type="list"),
+ onbState=dict(type="list"),
+ cmState=dict(type="list"),
+ name=dict(type="list"),
+ pid=dict(type="list"),
+ source=dict(type="list"),
+ projectId=dict(type="list"),
+ workflowId=dict(type="list"),
+ projectName=dict(type="list"),
+ workflowName=dict(type="list"),
+ smartAccountId=dict(type="list"),
+ virtualAccountId=dict(type="list"),
+ lastContact=dict(type="bool"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ serial_number=params.get("serialNumber"),
+ state=params.get("state_"),
+ onb_state=params.get("onbState"),
+ cm_state=params.get("cmState"),
+ name=params.get("name"),
+ pid=params.get("pid"),
+ source=params.get("source"),
+ project_id=params.get("projectId"),
+ workflow_id=params.get("workflowId"),
+ project_name=params.get("projectName"),
+ workflow_name=params.get("workflowName"),
+ smart_account_id=params.get("smartAccountId"),
+ virtual_account_id=params.get("virtualAccountId"),
+ last_contact=params.get("lastContact"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='get_device_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_device_history_info.py b/ansible_collections/cisco/dnac/plugins/action/pnp_device_history_info.py
new file mode 100644
index 000000000..49e64041e
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_device_history_info.py
@@ -0,0 +1,93 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ serialNumber=dict(type="str"),
+ sort=dict(type="list"),
+ sortOrder=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ serial_number=params.get("serialNumber"),
+ sort=params.get("sort"),
+ sort_order=params.get("sortOrder"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='get_device_history',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_device_import.py b/ansible_collections/cisco/dnac/plugins/action/pnp_device_import.py
new file mode 100644
index 000000000..daca60d65
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_device_import.py
@@ -0,0 +1,86 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ payload=dict(type="list"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ payload=params.get("payload"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='import_devices_in_bulk',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_device_info.py b/ansible_collections/cisco/dnac/plugins/action/pnp_device_info.py
new file mode 100644
index 000000000..529736179
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_device_info.py
@@ -0,0 +1,142 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ limit=dict(type="int"),
+ offset=dict(type="int"),
+ sort=dict(type="list"),
+ sortOrder=dict(type="str"),
+ serialNumber=dict(type="list"),
+ state_=dict(type="list"),
+ onbState=dict(type="list"),
+ cmState=dict(type="list"),
+ name=dict(type="list"),
+ pid=dict(type="list"),
+ source=dict(type="list"),
+ projectId=dict(type="list"),
+ workflowId=dict(type="list"),
+ projectName=dict(type="list"),
+ workflowName=dict(type="list"),
+ smartAccountId=dict(type="list"),
+ virtualAccountId=dict(type="list"),
+ lastContact=dict(type="bool"),
+ macAddress=dict(type="str"),
+ hostname=dict(type="str"),
+ siteName=dict(type="str"),
+ id=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ limit=params.get("limit"),
+ offset=params.get("offset"),
+ sort=params.get("sort"),
+ sort_order=params.get("sortOrder"),
+ serial_number=params.get("serialNumber"),
+ state=params.get("state_"),
+ onb_state=params.get("onbState"),
+ cm_state=params.get("cmState"),
+ name=params.get("name"),
+ pid=params.get("pid"),
+ source=params.get("source"),
+ project_id=params.get("projectId"),
+ workflow_id=params.get("workflowId"),
+ project_name=params.get("projectName"),
+ workflow_name=params.get("workflowName"),
+ smart_account_id=params.get("smartAccountId"),
+ virtual_account_id=params.get("virtualAccountId"),
+ last_contact=params.get("lastContact"),
+ mac_address=params.get("macAddress"),
+ hostname=params.get("hostname"),
+ site_name=params.get("siteName"),
+ id=params.get("id"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ if id:
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='get_device_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='get_device_list',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_device_reset.py b/ansible_collections/cisco/dnac/plugins/action/pnp_device_reset.py
new file mode 100644
index 000000000..19ebab29e
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_device_reset.py
@@ -0,0 +1,90 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceResetList=dict(type="list"),
+ projectId=dict(type="str"),
+ workflowId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ deviceResetList=params.get("deviceResetList"),
+ projectId=params.get("projectId"),
+ workflowId=params.get("workflowId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='reset_device',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_device_unclaim.py b/ansible_collections/cisco/dnac/plugins/action/pnp_device_unclaim.py
new file mode 100644
index 000000000..4a950ad05
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_device_unclaim.py
@@ -0,0 +1,86 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceIdList=dict(type="list"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ deviceIdList=params.get("deviceIdList"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='un_claim_device',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_global_settings.py b/ansible_collections/cisco/dnac/plugins/action/pnp_global_settings.py
new file mode 100644
index 000000000..681e25e20
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_global_settings.py
@@ -0,0 +1,182 @@
+#!/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 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"]),
+ _id=dict(type="str"),
+ aaaCredentials=dict(type="dict"),
+ acceptEula=dict(type="bool"),
+ defaultProfile=dict(type="dict"),
+ savaMappingList=dict(type="list"),
+ taskTimeOuts=dict(type="dict"),
+ tenantId=dict(type="str"),
+ version=dict(type="int"),
+))
+
+required_if = [
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class PnpGlobalSettings(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ _id=params.get("_id"),
+ aaaCredentials=params.get("aaaCredentials"),
+ acceptEula=params.get("acceptEula"),
+ defaultProfile=params.get("defaultProfile"),
+ savaMappingList=params.get("savaMappingList"),
+ taskTimeOuts=params.get("taskTimeOuts"),
+ tenantId=params.get("tenantId"),
+ version=params.get("version"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['_id'] = self.new_object.get('_id')
+ new_object_params['aaaCredentials'] = self.new_object.get('aaaCredentials')
+ 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['taskTimeOuts'] = self.new_object.get('taskTimeOuts')
+ new_object_params['tenantId'] = self.new_object.get('tenantId')
+ new_object_params['version'] = self.new_object.get('version')
+ 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
+ result = self.dnac.exec(
+ family="device_onboarding_pnp",
+ function="get_pnp_global_settings",
+ params=self.get_all_params(name=name),
+ )
+ 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
+ name = None
+ prev_obj = self.get_object_by_name(name)
+ 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 = [
+ ("_id", "_id"),
+ ("aaaCredentials", "aaaCredentials"),
+ ("acceptEula", "acceptEula"),
+ ("defaultProfile", "defaultProfile"),
+ ("savaMappingList", "savaMappingList"),
+ ("taskTimeOuts", "taskTimeOuts"),
+ ("tenantId", "tenantId"),
+ ("version", "version"),
+ ]
+ # 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)
+
+ def update(self):
+ result = None
+ result = self.dnac.exec(
+ family="device_onboarding_pnp",
+ function="update_pnp_global_settings",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = PnpGlobalSettings(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ dnac.fail_json("Object does not exists, plugin only has update")
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_global_settings_info.py b/ansible_collections/cisco/dnac/plugins/action/pnp_global_settings_info.py
new file mode 100644
index 000000000..a087b9086
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_global_settings_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='get_pnp_global_settings',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_server_profile_update.py b/ansible_collections/cisco/dnac/plugins/action/pnp_server_profile_update.py
new file mode 100644
index 000000000..209812d6d
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_server_profile_update.py
@@ -0,0 +1,110 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ autoSyncPeriod=dict(type="int"),
+ ccoUser=dict(type="str"),
+ expiry=dict(type="int"),
+ lastSync=dict(type="int"),
+ profile=dict(type="dict"),
+ smartAccountId=dict(type="str"),
+ syncResult=dict(type="dict"),
+ syncResultStr=dict(type="str"),
+ syncStartTime=dict(type="int"),
+ syncStatus=dict(type="str"),
+ tenantId=dict(type="str"),
+ token=dict(type="str"),
+ virtualAccountId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ autoSyncPeriod=params.get("autoSyncPeriod"),
+ ccoUser=params.get("ccoUser"),
+ expiry=params.get("expiry"),
+ lastSync=params.get("lastSync"),
+ profile=params.get("profile"),
+ smartAccountId=params.get("smartAccountId"),
+ syncResult=params.get("syncResult"),
+ syncResultStr=params.get("syncResultStr"),
+ syncStartTime=params.get("syncStartTime"),
+ syncStatus=params.get("syncStatus"),
+ tenantId=params.get("tenantId"),
+ token=params.get("token"),
+ virtualAccountId=params.get("virtualAccountId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='update_pnp_server_profile',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_smart_account_domains_info.py b/ansible_collections/cisco/dnac/plugins/action/pnp_smart_account_domains_info.py
new file mode 100644
index 000000000..8fd09b47a
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_smart_account_domains_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='get_smart_account_list',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_add.py b/ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_add.py
new file mode 100644
index 000000000..a41633acd
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_add.py
@@ -0,0 +1,110 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ autoSyncPeriod=dict(type="int"),
+ ccoUser=dict(type="str"),
+ expiry=dict(type="int"),
+ lastSync=dict(type="int"),
+ profile=dict(type="dict"),
+ smartAccountId=dict(type="str"),
+ syncResult=dict(type="dict"),
+ syncResultStr=dict(type="str"),
+ syncStartTime=dict(type="int"),
+ syncStatus=dict(type="str"),
+ tenantId=dict(type="str"),
+ token=dict(type="str"),
+ virtualAccountId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ autoSyncPeriod=params.get("autoSyncPeriod"),
+ ccoUser=params.get("ccoUser"),
+ expiry=params.get("expiry"),
+ lastSync=params.get("lastSync"),
+ profile=params.get("profile"),
+ smartAccountId=params.get("smartAccountId"),
+ syncResult=params.get("syncResult"),
+ syncResultStr=params.get("syncResultStr"),
+ syncStartTime=params.get("syncStartTime"),
+ syncStatus=params.get("syncStatus"),
+ tenantId=params.get("tenantId"),
+ token=params.get("token"),
+ virtualAccountId=params.get("virtualAccountId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='add_virtual_account',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_deregister.py b/ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_deregister.py
new file mode 100644
index 000000000..71f221b8c
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_deregister.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ domain=dict(type="str"),
+ name=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ domain=params.get("domain"),
+ name=params.get("name"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function="deregister_virtual_account",
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_devices_sync.py b/ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_devices_sync.py
new file mode 100644
index 000000000..d40859bd1
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_devices_sync.py
@@ -0,0 +1,110 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ autoSyncPeriod=dict(type="int"),
+ ccoUser=dict(type="str"),
+ expiry=dict(type="int"),
+ lastSync=dict(type="int"),
+ profile=dict(type="dict"),
+ smartAccountId=dict(type="str"),
+ syncResult=dict(type="dict"),
+ syncResultStr=dict(type="str"),
+ syncStartTime=dict(type="int"),
+ syncStatus=dict(type="str"),
+ tenantId=dict(type="str"),
+ token=dict(type="str"),
+ virtualAccountId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ autoSyncPeriod=params.get("autoSyncPeriod"),
+ ccoUser=params.get("ccoUser"),
+ expiry=params.get("expiry"),
+ lastSync=params.get("lastSync"),
+ profile=params.get("profile"),
+ smartAccountId=params.get("smartAccountId"),
+ syncResult=params.get("syncResult"),
+ syncResultStr=params.get("syncResultStr"),
+ syncStartTime=params.get("syncStartTime"),
+ syncStatus=params.get("syncStatus"),
+ tenantId=params.get("tenantId"),
+ token=params.get("token"),
+ virtualAccountId=params.get("virtualAccountId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='sync_virtual_account_devices',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_sync_result_info.py b/ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_sync_result_info.py
new file mode 100644
index 000000000..9d3cc0b75
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_sync_result_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ domain=dict(type="str"),
+ name=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ domain=params.get("domain"),
+ name=params.get("name"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='get_sync_result_for_virtual_account',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_virtual_accounts_info.py b/ansible_collections/cisco/dnac/plugins/action/pnp_virtual_accounts_info.py
new file mode 100644
index 000000000..4267d9874
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_virtual_accounts_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ domain=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ domain=params.get("domain"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='get_virtual_account_list',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_workflow.py b/ansible_collections/cisco/dnac/plugins/action/pnp_workflow.py
new file mode 100644
index 000000000..7a42ea0d9
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_workflow.py
@@ -0,0 +1,351 @@
+#!/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", "absent"]),
+ _id=dict(type="str"),
+ addToInventory=dict(type="bool"),
+ addedOn=dict(type="int"),
+ configId=dict(type="str"),
+ currTaskIdx=dict(type="int"),
+ description=dict(type="str"),
+ endTime=dict(type="int"),
+ execTime=dict(type="int"),
+ imageId=dict(type="str"),
+ instanceType=dict(type="str"),
+ lastupdateOn=dict(type="int"),
+ name=dict(type="str"),
+ startTime=dict(type="int"),
+ state_=dict(type="str"),
+ tasks=dict(type="list"),
+ tenantId=dict(type="str"),
+ type=dict(type="str"),
+ useState=dict(type="str"),
+ version=dict(type="int"),
+ id=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["id", "name"], True),
+ ("state", "absent", ["id", "name"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class PnpWorkflow(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ _id=params.get("_id"),
+ addToInventory=params.get("addToInventory"),
+ addedOn=params.get("addedOn"),
+ configId=params.get("configId"),
+ currTaskIdx=params.get("currTaskIdx"),
+ description=params.get("description"),
+ endTime=params.get("endTime"),
+ execTime=params.get("execTime"),
+ imageId=params.get("imageId"),
+ instanceType=params.get("instanceType"),
+ lastupdateOn=params.get("lastupdateOn"),
+ name=params.get("name"),
+ startTime=params.get("startTime"),
+ state=params.get("state_"),
+ tasks=params.get("tasks"),
+ tenantId=params.get("tenantId"),
+ type=params.get("type"),
+ useState=params.get("useState"),
+ version=params.get("version"),
+ id=params.get("id"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['limit'] = self.new_object.get('limit')
+ new_object_params['offset'] = self.new_object.get('offset')
+ new_object_params['sort'] = self.new_object.get('sort')
+ new_object_params['sort_order'] = self.new_object.get('sortOrder') or \
+ self.new_object.get('sort_order')
+ new_object_params['type'] = self.new_object.get('type')
+ new_object_params['name'] = name or self.new_object.get('name')
+ return new_object_params
+
+ 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['addedOn'] = self.new_object.get('addedOn')
+ new_object_params['configId'] = self.new_object.get('configId')
+ new_object_params['currTaskIdx'] = self.new_object.get('currTaskIdx')
+ new_object_params['description'] = self.new_object.get('description')
+ new_object_params['endTime'] = self.new_object.get('endTime')
+ new_object_params['execTime'] = self.new_object.get('execTime')
+ new_object_params['imageId'] = self.new_object.get('imageId')
+ new_object_params['instanceType'] = self.new_object.get('instanceType')
+ new_object_params['lastupdateOn'] = self.new_object.get('lastupdateOn')
+ new_object_params['name'] = self.new_object.get('name')
+ new_object_params['startTime'] = self.new_object.get('startTime')
+ new_object_params['state_'] = self.new_object.get('state_')
+ new_object_params['tasks'] = self.new_object.get('tasks')
+ new_object_params['tenantId'] = self.new_object.get('tenantId')
+ new_object_params['type'] = self.new_object.get('type')
+ new_object_params['useState'] = self.new_object.get('useState')
+ new_object_params['version'] = self.new_object.get('version')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['id'] = self.new_object.get('id')
+ return new_object_params
+
+ 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['addedOn'] = self.new_object.get('addedOn')
+ new_object_params['configId'] = self.new_object.get('configId')
+ new_object_params['currTaskIdx'] = self.new_object.get('currTaskIdx')
+ new_object_params['description'] = self.new_object.get('description')
+ new_object_params['endTime'] = self.new_object.get('endTime')
+ new_object_params['execTime'] = self.new_object.get('execTime')
+ new_object_params['imageId'] = self.new_object.get('imageId')
+ new_object_params['instanceType'] = self.new_object.get('instanceType')
+ new_object_params['lastupdateOn'] = self.new_object.get('lastupdateOn')
+ new_object_params['name'] = self.new_object.get('name')
+ new_object_params['startTime'] = self.new_object.get('startTime')
+ new_object_params['state_'] = self.new_object.get('state_')
+ new_object_params['tasks'] = self.new_object.get('tasks')
+ new_object_params['tenantId'] = self.new_object.get('tenantId')
+ new_object_params['type'] = self.new_object.get('type')
+ new_object_params['useState'] = self.new_object.get('useState')
+ new_object_params['version'] = self.new_object.get('version')
+ new_object_params['id'] = self.new_object.get('id')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="device_onboarding_pnp",
+ function="get_workflows",
+ 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="device_onboarding_pnp",
+ function="get_workflow_by_id",
+ 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):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ 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 = [
+ ("_id", "_id"),
+ ("addToInventory", "addToInventory"),
+ ("addedOn", "addedOn"),
+ ("configId", "configId"),
+ ("currTaskIdx", "currTaskIdx"),
+ ("description", "description"),
+ ("endTime", "endTime"),
+ ("execTime", "execTime"),
+ ("imageId", "imageId"),
+ ("instanceType", "instanceType"),
+ ("lastupdateOn", "lastupdateOn"),
+ ("name", "name"),
+ ("startTime", "startTime"),
+ ("state_", "state"),
+ ("tasks", "tasks"),
+ ("tenantId", "tenantId"),
+ ("type", "type"),
+ ("useState", "useState"),
+ ("version", "version"),
+ ("id", "id"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="device_onboarding_pnp",
+ function="add_a_workflow",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ if id_:
+ self.new_object.update(dict(id=id_))
+ result = self.dnac.exec(
+ family="device_onboarding_pnp",
+ function="update_workflow",
+ params=self.update_by_id_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ if id_:
+ self.new_object.update(dict(id=id_))
+ result = self.dnac.exec(
+ family="device_onboarding_pnp",
+ function="delete_workflow_by_id",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = PnpWorkflow(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_workflow_count_info.py b/ansible_collections/cisco/dnac/plugins/action/pnp_workflow_count_info.py
new file mode 100644
index 000000000..a5641d09a
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_workflow_count_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ name=dict(type="list"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ name=params.get("name"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='get_workflow_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/pnp_workflow_info.py b/ansible_collections/cisco/dnac/plugins/action/pnp_workflow_info.py
new file mode 100644
index 000000000..c1847fc79
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/pnp_workflow_info.py
@@ -0,0 +1,112 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ limit=dict(type="int"),
+ offset=dict(type="int"),
+ sort=dict(type="list"),
+ sortOrder=dict(type="str"),
+ type=dict(type="list"),
+ name=dict(type="list"),
+ id=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ limit=params.get("limit"),
+ offset=params.get("offset"),
+ sort=params.get("sort"),
+ sort_order=params.get("sortOrder"),
+ type=params.get("type"),
+ name=params.get("name"),
+ id=params.get("id"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ if id:
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='get_workflow_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="device_onboarding_pnp",
+ function='get_workflows',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/profiling_rules_count_info.py b/ansible_collections/cisco/dnac/plugins/action/profiling_rules_count_info.py
new file mode 100644
index 000000000..9f528781f
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/profiling_rules_count_info.py
@@ -0,0 +1,94 @@
+#!/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, Display
+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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ ruleType=dict(type="str"),
+ includeDeleted=dict(type="bool"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ rule_type=params.get("ruleType"),
+ include_deleted=params.get("includeDeleted"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ Display().warning("This module is currently unmaintained "
+ "and will be removed in future releases.")
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="policy",
+ function='get_count_of_profiling_rules',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/profiling_rules_in_bulk_create.py b/ansible_collections/cisco/dnac/plugins/action/profiling_rules_in_bulk_create.py
new file mode 100644
index 000000000..ed2944bba
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/profiling_rules_in_bulk_create.py
@@ -0,0 +1,89 @@
+#!/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, Display
+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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ profilingRules=dict(type="list"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ profilingRules=params.get("profilingRules"),
+ )
+ return new_object
+
+ 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()
+
+ Display().warning("This module is currently unmaintained "
+ "and will be removed in future releases.")
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="policy",
+ function='import_profiling_rules_in_bulk',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/projects_details_info.py b/ansible_collections/cisco/dnac/plugins/action/projects_details_info.py
new file mode 100644
index 000000000..c1f786404
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/projects_details_info.py
@@ -0,0 +1,97 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+ name=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ sortOrder=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ name=params.get("name"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ sort_order=params.get("sortOrder"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="configuration_templates",
+ function='get_projects_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/qos_device_interface.py b/ansible_collections/cisco/dnac/plugins/action/qos_device_interface.py
new file mode 100644
index 000000000..262824cdc
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/qos_device_interface.py
@@ -0,0 +1,264 @@
+#!/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", "absent"]),
+ payload=dict(type="list"),
+ id=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["id"], True),
+ ("state", "present", ["payload"], True),
+ ("state", "absent", ["id"], True),
+ ("state", "absent", ["payload"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class QosDeviceInterface(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ payload=params.get("payload"),
+ id=params.get("id"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['network_device_id'] = self.new_object.get('networkDeviceId') or \
+ self.new_object.get('network_device_id')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['id'] = self.new_object.get('id')
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="application_policy",
+ function="get_qos_device_interface_info",
+ 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
+ try:
+ items = self.dnac.exec(
+ family="application_policy",
+ function="get_qos_device_interface_info",
+ params=self.get_all_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):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ requested_obj = self.new_object.get('payload')
+ 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")
+ name = self.new_object.get("name") or requested_obj.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.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+
+ obj_params = [
+ ("id", "id"),
+ ("name", "name"),
+ ("excludedInterfaces", "excludedInterfaces"),
+ ("networkDeviceId", "networkDeviceId"),
+ ("qosDeviceInterfaceInfo", "qosDeviceInterfaceInfo"),
+ ("id", "id"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="application_policy",
+ function="create_qos_device_interface_info",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ requested_obj = self.new_object.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+ id = self.new_object.get("id") or requested_obj.get("id")
+ name = self.new_object.get("name") or requested_obj.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="application_policy",
+ function="update_qos_device_interface_info",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ requested_obj = self.new_object.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+ id = self.new_object.get("id") or requested_obj.get("id")
+ name = self.new_object.get("name") or requested_obj.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ if id_:
+ self.new_object.update(dict(id=id_))
+ result = self.dnac.exec(
+ family="application_policy",
+ function="delete_qos_device_interface_info",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = QosDeviceInterface(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/qos_device_interface_info.py b/ansible_collections/cisco/dnac/plugins/action/qos_device_interface_info.py
new file mode 100644
index 000000000..906116e0a
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/qos_device_interface_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ networkDeviceId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ network_device_id=params.get("networkDeviceId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="application_policy",
+ function='get_qos_device_interface_info',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/qos_device_interface_info_count_info.py b/ansible_collections/cisco/dnac/plugins/action/qos_device_interface_info_count_info.py
new file mode 100644
index 000000000..d89693b36
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/qos_device_interface_info_count_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="application_policy",
+ function='get_qos_device_interface_info_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/reports.py b/ansible_collections/cisco/dnac/plugins/action/reports.py
new file mode 100644
index 000000000..28f656870
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/reports.py
@@ -0,0 +1,259 @@
+#!/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", "absent"]),
+ tags=dict(type="list"),
+ deliveries=dict(type="list"),
+ name=dict(type="str"),
+ schedule=dict(type="dict"),
+ view=dict(type="dict"),
+ viewGroupId=dict(type="str"),
+ viewGroupVersion=dict(type="str"),
+ reportId=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["name", "reportId"], True),
+ ("state", "absent", ["name", "reportId"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class Reports(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ tags=params.get("tags"),
+ deliveries=params.get("deliveries"),
+ name=params.get("name"),
+ schedule=params.get("schedule"),
+ view=params.get("view"),
+ viewGroupId=params.get("viewGroupId"),
+ viewGroupVersion=params.get("viewGroupVersion"),
+ report_id=params.get("reportId"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['view_group_id'] = self.new_object.get('viewGroupId') or \
+ self.new_object.get('view_group_id')
+ new_object_params['view_id'] = self.new_object.get('view', {}).get('viewId')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['tags'] = self.dnac.verify_array((self.new_object.get('tags')))
+ new_object_params['deliveries'] = self.dnac.verify_array(self.new_object.get('deliveries'))
+ new_object_params['name'] = self.new_object.get('name')
+ 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')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['report_id'] = self.new_object.get('report_id')
+ 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="reports",
+ function="get_list_of_scheduled_reports",
+ 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="reports",
+ function="get_a_scheduled_report",
+ params={"report_id": id}
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ result = get_dict_result(items, 'reportId', 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("report_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")
+ _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")
+ if _id:
+ self.new_object.update(dict(id=_id))
+ self.new_object.update(dict(report_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 = [
+ ("tags", "tags"),
+ ("deliveries", "deliveries"),
+ ("name", "name"),
+ ("schedule", "schedule"),
+ ("view", "view"),
+ ("viewGroupId", "viewGroupId"),
+ ("viewGroupVersion", "viewGroupVersion"),
+ ("reportId", "report_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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="reports",
+ function="create_or_schedule_a_report",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ id = id or self.new_object.get("report_id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ id_ = id_ or prev_obj_name.get("reportId")
+ if id_:
+ self.new_object.update(dict(report_id=id_))
+ result = self.dnac.exec(
+ family="reports",
+ function="delete_a_scheduled_report",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = Reports(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ 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:
+ response = obj.create()
+ dnac.object_created()
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/reports_executions_info.py b/ansible_collections/cisco/dnac/plugins/action/reports_executions_info.py
new file mode 100644
index 000000000..a1de3e4c7
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/reports_executions_info.py
@@ -0,0 +1,114 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ reportId=dict(type="str"),
+ executionId=dict(type="str"),
+ dirPath=dict(type="str"),
+ saveFile=dict(type="bool"),
+ filename=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ report_id=params.get("reportId"),
+ execution_id=params.get("executionId"),
+ dirpath=params.get("dirPath"),
+ save_file=params.get("saveFile"),
+ filename=params.get("filename"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("executionId")
+ if id:
+ download_response = dnac.exec(
+ family="reports",
+ function='download_report_content',
+ params=self.get_object(self._task.args),
+ )
+ response = dict(
+ data=download_response.data.decode(encoding='utf-8'),
+ filename=download_response.filename,
+ dirpath=download_response.dirpath,
+ path=download_response.path,
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="reports",
+ function='get_all_execution_details_for_a_given_report',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/reports_info.py b/ansible_collections/cisco/dnac/plugins/action/reports_info.py
new file mode 100644
index 000000000..6aad484fa
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/reports_info.py
@@ -0,0 +1,104 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ viewGroupId=dict(type="str"),
+ viewId=dict(type="str"),
+ reportId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ view_group_id=params.get("viewGroupId"),
+ view_id=params.get("viewId"),
+ report_id=params.get("reportId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("reportId")
+ if id:
+ response = dnac.exec(
+ family="reports",
+ function='get_a_scheduled_report',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="reports",
+ function='get_list_of_scheduled_reports',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/reports_view_group_info.py b/ansible_collections/cisco/dnac/plugins/action/reports_view_group_info.py
new file mode 100644
index 000000000..983527273
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/reports_view_group_info.py
@@ -0,0 +1,100 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ viewGroupId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ view_group_id=params.get("viewGroupId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("viewGroupId")
+ if id:
+ response = dnac.exec(
+ family="reports",
+ function='get_views_for_a_given_view_group',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="reports",
+ function='get_all_view_groups',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/reports_view_group_view_info.py b/ansible_collections/cisco/dnac/plugins/action/reports_view_group_view_info.py
new file mode 100644
index 000000000..32bd3026d
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/reports_view_group_view_info.py
@@ -0,0 +1,100 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ viewGroupId=dict(type="str"),
+ viewId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ view_group_id=params.get("viewGroupId"),
+ view_id=params.get("viewId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("viewGroupId")
+ if id:
+ response = dnac.exec(
+ family="reports",
+ function='get_view_details_for_a_given_view_group_and_view',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool.py b/ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool.py
new file mode 100644
index 000000000..22ea8edae
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool.py
@@ -0,0 +1,358 @@
+#!/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", "absent"]),
+ name=dict(type="str"),
+ type=dict(type="str"),
+ ipv6AddressSpace=dict(type="bool"),
+ ipv4GlobalPool=dict(type="str"),
+ ipv4Prefix=dict(type="bool"),
+ ipv4PrefixLength=dict(type="int"),
+ ipv4Subnet=dict(type="str"),
+ ipv4GateWay=dict(type="str"),
+ ipv4DhcpServers=dict(type="list"),
+ ipv4DnsServers=dict(type="list"),
+ ipv6GlobalPool=dict(type="str"),
+ ipv6Prefix=dict(type="bool"),
+ ipv6PrefixLength=dict(type="int"),
+ ipv6Subnet=dict(type="str"),
+ ipv6GateWay=dict(type="str"),
+ ipv6DhcpServers=dict(type="list"),
+ ipv6DnsServers=dict(type="list"),
+ ipv4TotalHost=dict(type="int"),
+ ipv6TotalHost=dict(type="int"),
+ slaacSupport=dict(type="bool"),
+ siteId=dict(type="str"),
+ id=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["id", "name", "siteId"], True),
+ ("state", "absent", ["id", "name", "siteId"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ReserveIpSubpool(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ name=params.get("name"),
+ type=params.get("type"),
+ ipv6AddressSpace=params.get("ipv6AddressSpace"),
+ ipv4GlobalPool=params.get("ipv4GlobalPool"),
+ ipv4Prefix=params.get("ipv4Prefix"),
+ ipv4PrefixLength=params.get("ipv4PrefixLength"),
+ ipv4Subnet=params.get("ipv4Subnet"),
+ ipv4GateWay=params.get("ipv4GateWay"),
+ ipv4DhcpServers=params.get("ipv4DhcpServers"),
+ ipv4DnsServers=params.get("ipv4DnsServers"),
+ ipv6GlobalPool=params.get("ipv6GlobalPool"),
+ ipv6Prefix=params.get("ipv6Prefix"),
+ ipv6PrefixLength=params.get("ipv6PrefixLength"),
+ ipv6Subnet=params.get("ipv6Subnet"),
+ ipv6GateWay=params.get("ipv6GateWay"),
+ ipv6DhcpServers=params.get("ipv6DhcpServers"),
+ ipv6DnsServers=params.get("ipv6DnsServers"),
+ ipv4TotalHost=params.get("ipv4TotalHost"),
+ ipv6TotalHost=params.get("ipv6TotalHost"),
+ slaacSupport=params.get("slaacSupport"),
+ site_id=params.get("siteId"),
+ id=params.get("id"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['site_id'] = self.new_object.get('siteId') or \
+ self.new_object.get('site_id')
+ new_object_params['offset'] = self.new_object.get('offset')
+ new_object_params['limit'] = self.new_object.get('limit')
+ return new_object_params
+
+ 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['ipv4Prefix'] = self.new_object.get('ipv4Prefix')
+ 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['ipv6Prefix'] = self.new_object.get('ipv6Prefix')
+ 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['slaacSupport'] = self.new_object.get('slaacSupport')
+ new_object_params['site_id'] = self.new_object.get('site_id')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['id'] = self.new_object.get('id')
+ return new_object_params
+
+ 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['ipv6Prefix'] = self.new_object.get('ipv6Prefix')
+ 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['ipv6TotalHost'] = self.new_object.get('ipv6TotalHost')
+ new_object_params['slaacSupport'] = self.new_object.get('slaacSupport')
+ new_object_params['ipv4GateWay'] = self.new_object.get('ipv4GateWay')
+ new_object_params['id'] = self.new_object.get('id')
+ new_object_params['site_id'] = self.new_object.get('site_id')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="network_settings",
+ function="get_reserve_ip_subpool",
+ 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
+ try:
+ items = self.dnac.exec(
+ family="network_settings",
+ function="get_reserve_ip_subpool",
+ params=self.get_all_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):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ o_id = self.new_object.get("id")
+ o_id = o_id or self.new_object.get("site_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")
+ _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")
+ if _id:
+ self.new_object.update(dict(id=_id))
+ self.new_object.update(dict(site_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 = [
+ ("name", "name"),
+ ("type", "type"),
+ ("ipv6AddressSpace", "ipv6AddressSpace"),
+ ("ipv4GlobalPool", "ipv4GlobalPool"),
+ ("ipv4Prefix", "ipv4Prefix"),
+ ("ipv4PrefixLength", "ipv4PrefixLength"),
+ ("ipv4Subnet", "ipv4Subnet"),
+ ("ipv4GateWay", "ipv4GateWay"),
+ ("ipv4DhcpServers", "ipv4DhcpServers"),
+ ("ipv4DnsServers", "ipv4DnsServers"),
+ ("ipv6GlobalPool", "ipv6GlobalPool"),
+ ("ipv6Prefix", "ipv6Prefix"),
+ ("ipv6PrefixLength", "ipv6PrefixLength"),
+ ("ipv6Subnet", "ipv6Subnet"),
+ ("ipv6GateWay", "ipv6GateWay"),
+ ("ipv6DhcpServers", "ipv6DhcpServers"),
+ ("ipv6DnsServers", "ipv6DnsServers"),
+ ("ipv4TotalHost", "ipv4TotalHost"),
+ ("ipv6TotalHost", "ipv6TotalHost"),
+ ("slaacSupport", "slaacSupport"),
+ ("siteId", "site_id"),
+ ("id", "id"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="network_settings",
+ function="reserve_ip_subpool",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ id = id or self.new_object.get("site_id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ id_ = id_ or prev_obj_name.get("siteId")
+ if id_:
+ self.new_object.update(dict(site_id=id_))
+ result = self.dnac.exec(
+ family="network_settings",
+ function="update_reserve_ip_subpool",
+ params=self.update_by_id_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ id = id or self.new_object.get("site_id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ id_ = id_ or prev_obj_name.get("siteId")
+ if id_:
+ self.new_object.update(dict(id=id_))
+ result = self.dnac.exec(
+ family="network_settings",
+ function="release_reserve_ip_subpool",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = ReserveIpSubpool(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_create.py b/ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_create.py
new file mode 100644
index 000000000..0b34b1798
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_create.py
@@ -0,0 +1,126 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ name=dict(type="str"),
+ type=dict(type="str"),
+ ipv6AddressSpace=dict(type="bool"),
+ ipv4GlobalPool=dict(type="str"),
+ ipv4Prefix=dict(type="bool"),
+ ipv4PrefixLength=dict(type="int"),
+ ipv4Subnet=dict(type="str"),
+ ipv4GateWay=dict(type="str"),
+ ipv4DhcpServers=dict(type="list"),
+ ipv4DnsServers=dict(type="list"),
+ ipv6GlobalPool=dict(type="str"),
+ ipv6Prefix=dict(type="bool"),
+ ipv6PrefixLength=dict(type="int"),
+ ipv6Subnet=dict(type="str"),
+ ipv6GateWay=dict(type="str"),
+ ipv6DhcpServers=dict(type="list"),
+ ipv6DnsServers=dict(type="list"),
+ ipv4TotalHost=dict(type="int"),
+ ipv6TotalHost=dict(type="int"),
+ slaacSupport=dict(type="bool"),
+ siteId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ name=params.get("name"),
+ type=params.get("type"),
+ ipv6AddressSpace=params.get("ipv6AddressSpace"),
+ ipv4GlobalPool=params.get("ipv4GlobalPool"),
+ ipv4Prefix=params.get("ipv4Prefix"),
+ ipv4PrefixLength=params.get("ipv4PrefixLength"),
+ ipv4Subnet=params.get("ipv4Subnet"),
+ ipv4GateWay=params.get("ipv4GateWay"),
+ ipv4DhcpServers=params.get("ipv4DhcpServers"),
+ ipv4DnsServers=params.get("ipv4DnsServers"),
+ ipv6GlobalPool=params.get("ipv6GlobalPool"),
+ ipv6Prefix=params.get("ipv6Prefix"),
+ ipv6PrefixLength=params.get("ipv6PrefixLength"),
+ ipv6Subnet=params.get("ipv6Subnet"),
+ ipv6GateWay=params.get("ipv6GateWay"),
+ ipv6DhcpServers=params.get("ipv6DhcpServers"),
+ ipv6DnsServers=params.get("ipv6DnsServers"),
+ ipv4TotalHost=params.get("ipv4TotalHost"),
+ ipv6TotalHost=params.get("ipv6TotalHost"),
+ slaacSupport=params.get("slaacSupport"),
+ site_id=params.get("siteId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function='reserve_ip_subpool',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_delete.py b/ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_delete.py
new file mode 100644
index 000000000..d48b57d71
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_delete.py
@@ -0,0 +1,85 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function="release_reserve_ip_subpool",
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_info.py b/ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_info.py
new file mode 100644
index 000000000..c704db1ef
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_info.py
@@ -0,0 +1,93 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteId=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ site_id=params.get("siteId"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function='get_reserve_ip_subpool',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_update.py b/ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_update.py
new file mode 100644
index 000000000..4d2f8bf58
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_update.py
@@ -0,0 +1,116 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ name=dict(type="str"),
+ ipv6AddressSpace=dict(type="bool"),
+ ipv4DhcpServers=dict(type="list"),
+ ipv4DnsServers=dict(type="list"),
+ ipv6GlobalPool=dict(type="str"),
+ ipv6Prefix=dict(type="bool"),
+ ipv6PrefixLength=dict(type="int"),
+ ipv6Subnet=dict(type="str"),
+ ipv6GateWay=dict(type="str"),
+ ipv6DhcpServers=dict(type="list"),
+ ipv6DnsServers=dict(type="list"),
+ ipv6TotalHost=dict(type="int"),
+ slaacSupport=dict(type="bool"),
+ ipv4GateWay=dict(type="str"),
+ siteId=dict(type="str"),
+ id=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ name=params.get("name"),
+ ipv6AddressSpace=params.get("ipv6AddressSpace"),
+ ipv4DhcpServers=params.get("ipv4DhcpServers"),
+ ipv4DnsServers=params.get("ipv4DnsServers"),
+ ipv6GlobalPool=params.get("ipv6GlobalPool"),
+ ipv6Prefix=params.get("ipv6Prefix"),
+ ipv6PrefixLength=params.get("ipv6PrefixLength"),
+ ipv6Subnet=params.get("ipv6Subnet"),
+ ipv6GateWay=params.get("ipv6GateWay"),
+ ipv6DhcpServers=params.get("ipv6DhcpServers"),
+ ipv6DnsServers=params.get("ipv6DnsServers"),
+ ipv6TotalHost=params.get("ipv6TotalHost"),
+ slaacSupport=params.get("slaacSupport"),
+ ipv4GateWay=params.get("ipv4GateWay"),
+ site_id=params.get("siteId"),
+ id=params.get("id"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function='update_reserve_ip_subpool',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/role_permissions_info.py b/ansible_collections/cisco/dnac/plugins/action/role_permissions_info.py
new file mode 100644
index 000000000..39728ba46
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/role_permissions_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="userand_roles",
+ function='get_permissions_ap_i',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/roles_info.py b/ansible_collections/cisco/dnac/plugins/action/roles_info.py
new file mode 100644
index 000000000..380c9c687
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/roles_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="userand_roles",
+ function='get_roles_ap_i',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_count_info.py b/ansible_collections/cisco/dnac/plugins/action/sda_count_info.py
new file mode 100644
index 000000000..f4b53d82d
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_count_info.py
@@ -0,0 +1,90 @@
+#!/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, Display
+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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ Display().warning("This module is currently unmaintained "
+ "and will be removed in future releases.")
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sda",
+ function='get_sda_fabric_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_device_info.py b/ansible_collections/cisco/dnac/plugins/action/sda_device_info.py
new file mode 100644
index 000000000..111300278
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_device_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceManagementIpAddress=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_management_ip_address=params.get("deviceManagementIpAddress"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sda",
+ function='get_device_info',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_device_role_info.py b/ansible_collections/cisco/dnac/plugins/action/sda_device_role_info.py
new file mode 100644
index 000000000..175324235
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_device_role_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceManagementIpAddress=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_management_ip_address=params.get("deviceManagementIpAddress"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sda",
+ function='get_device_role_in_sda_fabric',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_fabric.py b/ansible_collections/cisco/dnac/plugins/action/sda_fabric.py
new file mode 100644
index 000000000..d99b4863f
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_fabric.py
@@ -0,0 +1,209 @@
+#!/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, Display
+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 (
+ AnsibleSDAException,
+)
+
+# 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", "absent"]),
+ fabricName=dict(type="str"),
+))
+
+required_if = [
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class SdaFabric(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ fabricName=params.get("fabricName"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['fabric_name'] = self.new_object.get('fabricName')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['fabricName'] = self.new_object.get('fabricName')
+ return new_object_params
+
+ def delete_all_params(self):
+ new_object_params = {}
+ new_object_params['fabric_name'] = self.new_object.get('fabricName')
+ return new_object_params
+
+ def get_object_by_name(self, name, is_absent=False):
+ result = None
+ # NOTICE: Does not have a get by name method, using get all
+ try:
+ items = self.dnac.exec(
+ family="sda",
+ function="get_sda_fabric_info",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ if isinstance(items, dict) and items.get("status") == "failed":
+ if is_absent:
+ raise AnsibleSDAException(response=items)
+ result = None
+ return result
+ result = get_dict_result(items, 'fabricName', name)
+ except Exception:
+ if is_absent:
+ raise
+ 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, is_absent=False):
+ name = self.new_object.get("fabricName")
+ 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"
+ return (it_exists, prev_obj)
+
+ def requires_update(self, current_obj):
+ requested_obj = self.new_object
+
+ obj_params = [
+ ("fabricName", "fabricName"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="sda",
+ function="add_fabric",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ if isinstance(result, dict):
+ if 'response' in result:
+ result = result.get('response')
+ if isinstance(result, dict) and result.get("status") == "failed":
+ raise AnsibleSDAException(response=result)
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("fabricName")
+ result = None
+ result = self.dnac.exec(
+ family="sda",
+ function="delete_sda_fabric",
+ params=self.delete_all_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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()
+
+ Display().warning("This module is currently unmaintained "
+ "and will be removed in future releases.")
+
+ dnac = DNACSDK(self._task.args)
+ obj = SdaFabric(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ 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:
+ try:
+ response = obj.create()
+ dnac.object_created()
+ except AnsibleSDAException as e:
+ 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)
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+ except AnsibleSDAException as e:
+ 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())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_fabric_authentication_profile.py b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_authentication_profile.py
new file mode 100644
index 000000000..91a1f3ae5
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_authentication_profile.py
@@ -0,0 +1,242 @@
+#!/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 (
+ AnsibleSDAException,
+)
+
+# 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", "absent"]),
+ payload=dict(type="list"),
+ siteNameHierarchy=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["payload"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class SdaFabricAuthenticationProfile(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ payload=params.get("payload"),
+ site_name_hierarchy=params.get("siteNameHierarchy"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['site_name_hierarchy'] = self.new_object.get('siteNameHierarchy') or \
+ self.new_object.get('site_name_hierarchy')
+ new_object_params['authenticate_template_name'] = self.new_object.get('authenticateTemplateName') or \
+ self.new_object.get('authenticate_template_name')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ 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')
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ return new_object_params
+
+ def get_object_by_name(self, name, is_absent=False):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="sda",
+ function="get_default_authentication_profile",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ if isinstance(items, dict) and items.get("status") == "failed":
+ if is_absent:
+ raise AnsibleSDAException(response=items)
+ result = None
+ return result
+ result = get_dict_result(items, 'name', name)
+ except Exception:
+ if is_absent:
+ raise
+ 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, 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 'siteNameHierarchy' in prev_obj
+ return (it_exists, prev_obj)
+
+ def requires_update(self, current_obj):
+ requested_obj = self.new_object.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+
+ obj_params = [
+ ("siteNameHierarchy", "siteNameHierarchy"),
+ ("authenticateTemplateName", "authenticateTemplateName"),
+ ("authenticationOrder", "authenticationOrder"),
+ ("dot1xToMabFallbackTimeout", "dot1xToMabFallbackTimeout"),
+ ("wakeOnLan", "wakeOnLan"),
+ ("numberOfHosts", "numberOfHosts"),
+ ("siteNameHierarchy", "site_name_hierarchy"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="sda",
+ function="add_default_authentication_profile",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ if isinstance(result, dict):
+ if 'response' in result:
+ result = result.get('response')
+ if isinstance(result, dict) and result.get("status") == "failed":
+ raise AnsibleSDAException(response=result)
+ return result
+
+ def update(self):
+ requested_obj = self.new_object.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+ id = self.new_object.get("id") or requested_obj.get("id")
+ name = self.new_object.get("name") or requested_obj.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="sda",
+ function="update_default_authentication_profile",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="sda",
+ function="delete_default_authentication_profile",
+ params=self.delete_all_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = SdaFabricAuthenticationProfile(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ try:
+ response = obj.create()
+ dnac.object_created()
+ except AnsibleSDAException as e:
+ 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)
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+ except AnsibleSDAException as e:
+ 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())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_fabric_authentication_profile_info.py b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_authentication_profile_info.py
new file mode 100644
index 000000000..fc99a83d1
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_authentication_profile_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteNameHierarchy=dict(type="str"),
+ authenticateTemplateName=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ site_name_hierarchy=params.get("siteNameHierarchy"),
+ authenticate_template_name=params.get("authenticateTemplateName"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sda",
+ function='get_default_authentication_profile',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_fabric_border_device.py b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_border_device.py
new file mode 100644
index 000000000..ab907f808
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_border_device.py
@@ -0,0 +1,225 @@
+#!/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 (
+ AnsibleSDAException,
+)
+
+# 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", "absent"]),
+ payload=dict(type="list"),
+ deviceManagementIpAddress=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["payload"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class SdaFabricBorderDevice(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ payload=params.get("payload"),
+ device_management_ip_address=params.get("deviceManagementIpAddress"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['device_management_ip_address'] = self.new_object.get('deviceManagementIpAddress') or \
+ self.new_object.get('device_management_ip_address')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ 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')
+ return new_object_params
+
+ def get_object_by_name(self, name, is_absent=False):
+ result = None
+ # NOTE: Does not have a get by name method, using get all
+ try:
+ items = self.dnac.exec(
+ family="sda",
+ function="gets_border_device_detail",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ if isinstance(items, dict) and items.get("status") == "failed":
+ if is_absent:
+ raise AnsibleSDAException(response=items)
+ result = None
+ return result
+ result = get_dict_result(items, 'name', name)
+ except Exception:
+ if is_absent:
+ raise
+ 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, 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"
+ return (it_exists, prev_obj)
+
+ def requires_update(self, current_obj):
+ requested_obj = self.new_object.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+
+ obj_params = [
+ ("deviceManagementIpAddress", "deviceManagementIpAddress"),
+ ("siteNameHierarchy", "siteNameHierarchy"),
+ ("deviceRole", "deviceRole"),
+ ("routeDistributionProtocol", "routeDistributionProtocol"),
+ ("externalDomainRoutingProtocolName", "externalDomainRoutingProtocolName"),
+ ("externalConnectivityIpPoolName", "externalConnectivityIpPoolName"),
+ ("internalAutonomouSystemNumber", "internalAutonomouSystemNumber"),
+ ("borderPriority", "borderPriority"),
+ ("borderSessionType", "borderSessionType"),
+ ("connectedToInternet", "connectedToInternet"),
+ ("sdaTransitNetworkName", "sdaTransitNetworkName"),
+ ("borderWithExternalConnectivity", "borderWithExternalConnectivity"),
+ ("externalConnectivitySettings", "externalConnectivitySettings"),
+ ("deviceManagementIpAddress", "device_management_ip_address"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="sda",
+ function="adds_border_device",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ if isinstance(result, dict):
+ if 'response' in result:
+ result = result.get('response')
+ if isinstance(result, dict) and result.get("status") == "failed":
+ raise AnsibleSDAException(response=result)
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="sda",
+ function="deletes_border_device",
+ params=self.delete_all_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = SdaFabricBorderDevice(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ 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:
+ try:
+ response = obj.create()
+ dnac.object_created()
+ except AnsibleSDAException as e:
+ 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)
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+ except AnsibleSDAException as e:
+ 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())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_fabric_border_device_info.py b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_border_device_info.py
new file mode 100644
index 000000000..bf3c2aefd
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_border_device_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceManagementIpAddress=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_management_ip_address=params.get("deviceManagementIpAddress"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sda",
+ function='gets_border_device_detail',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_fabric_control_plane_device.py b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_control_plane_device.py
new file mode 100644
index 000000000..c2df756d5
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_control_plane_device.py
@@ -0,0 +1,217 @@
+#!/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 (
+ AnsibleSDAException,
+)
+
+# 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", "absent"]),
+ deviceManagementIpAddress=dict(type="str"),
+ siteNameHierarchy=dict(type="str"),
+ routeDistributionProtocol=dict(type="str"),
+))
+
+required_if = [
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class SdaFabricControlPlaneDevice(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ deviceManagementIpAddress=params.get("deviceManagementIpAddress"),
+ siteNameHierarchy=params.get("siteNameHierarchy"),
+ routeDistributionProtocol=params.get("routeDistributionProtocol"),
+ device_management_ip_address=params.get("deviceManagementIpAddress"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['device_management_ip_address'] = self.new_object.get('deviceManagementIpAddress') or \
+ self.new_object.get('device_management_ip_address')
+ return new_object_params
+
+ 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')
+ 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')
+ return new_object_params
+
+ def get_object_by_name(self, name, is_absent=False):
+ result = None
+ # NOTE: Does not have a get by name method, using get all
+ try:
+ items = self.dnac.exec(
+ family="sda",
+ function="get_control_plane_device",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ if isinstance(items, dict) and items.get("status") == "failed":
+ if is_absent:
+ raise AnsibleSDAException(response=items)
+ result = None
+ return result
+ result = get_dict_result(items, 'name', name)
+ except Exception:
+ if is_absent:
+ raise
+ 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, 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"
+ return (it_exists, prev_obj)
+
+ def requires_update(self, current_obj):
+ requested_obj = self.new_object
+
+ obj_params = [
+ ("deviceManagementIpAddress", "deviceManagementIpAddress"),
+ ("siteNameHierarchy", "siteNameHierarchy"),
+ ("routeDistributionProtocol", "routeDistributionProtocol"),
+ ("deviceManagementIpAddress", "device_management_ip_address"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="sda",
+ function="add_control_plane_device",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ if isinstance(result, dict):
+ if 'response' in result:
+ result = result.get('response')
+ if isinstance(result, dict) and result.get("status") == "failed":
+ raise AnsibleSDAException(response=result)
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="sda",
+ function="delete_control_plane_device",
+ params=self.delete_all_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = SdaFabricControlPlaneDevice(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ 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:
+ try:
+ response = obj.create()
+ dnac.object_created()
+ except AnsibleSDAException as e:
+ 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)
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+ except AnsibleSDAException as e:
+ 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())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_fabric_control_plane_device_info.py b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_control_plane_device_info.py
new file mode 100644
index 000000000..27a324ea9
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_control_plane_device_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceManagementIpAddress=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_management_ip_address=params.get("deviceManagementIpAddress"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sda",
+ function='get_control_plane_device',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_fabric_edge_device.py b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_edge_device.py
new file mode 100644
index 000000000..84bd9ed57
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_edge_device.py
@@ -0,0 +1,213 @@
+#!/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 (
+ AnsibleSDAException,
+)
+
+# 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", "absent"]),
+ deviceManagementIpAddress=dict(type="str"),
+ siteNameHierarchy=dict(type="str"),
+))
+
+required_if = [
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class SdaFabricEdgeDevice(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ deviceManagementIpAddress=params.get("deviceManagementIpAddress"),
+ siteNameHierarchy=params.get("siteNameHierarchy"),
+ device_management_ip_address=params.get("deviceManagementIpAddress"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['device_management_ip_address'] = self.new_object.get('deviceManagementIpAddress') or \
+ self.new_object.get('device_management_ip_address')
+ return new_object_params
+
+ 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')
+ 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')
+ return new_object_params
+
+ def get_object_by_name(self, name, is_absent=False):
+ result = None
+ # NOTE: Does not have a get by name method, using get all
+ try:
+ items = self.dnac.exec(
+ family="sda",
+ function="get_edge_device",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ if isinstance(items, dict) and items.get("status") == "failed":
+ if is_absent:
+ raise AnsibleSDAException(response=items)
+ result = None
+ return result
+ result = get_dict_result(items, 'name', name)
+ except Exception:
+ if is_absent:
+ raise
+ 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, 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"
+ return (it_exists, prev_obj)
+
+ def requires_update(self, current_obj):
+ requested_obj = self.new_object
+
+ obj_params = [
+ ("deviceManagementIpAddress", "deviceManagementIpAddress"),
+ ("siteNameHierarchy", "siteNameHierarchy"),
+ ("deviceManagementIpAddress", "device_management_ip_address"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="sda",
+ function="add_edge_device",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ if isinstance(result, dict):
+ if 'response' in result:
+ result = result.get('response')
+ if isinstance(result, dict) and result.get("status") == "failed":
+ raise AnsibleSDAException(response=result)
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="sda",
+ function="delete_edge_device",
+ params=self.delete_all_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = SdaFabricEdgeDevice(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ 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:
+ try:
+ response = obj.create()
+ dnac.object_created()
+ except AnsibleSDAException as e:
+ 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)
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+ except AnsibleSDAException as e:
+ 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())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_fabric_edge_device_info.py b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_edge_device_info.py
new file mode 100644
index 000000000..ca369d738
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_edge_device_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceManagementIpAddress=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_management_ip_address=params.get("deviceManagementIpAddress"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sda",
+ function='get_edge_device',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_fabric_info.py b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_info.py
new file mode 100644
index 000000000..02a2aa595
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_info.py
@@ -0,0 +1,92 @@
+#!/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, Display
+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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ fabricName=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ fabric_name=params.get("fabricName"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ Display().warning("This module is currently unmaintained "
+ "and will be removed in future releases.")
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sda",
+ function='get_sda_fabric_info',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_fabric_site.py b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_site.py
new file mode 100644
index 000000000..47af15276
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_site.py
@@ -0,0 +1,217 @@
+#!/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 (
+ AnsibleSDAException,
+)
+
+# 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", "absent"]),
+ fabricName=dict(type="str"),
+ siteNameHierarchy=dict(type="str"),
+ fabricType=dict(type="str"),
+))
+
+required_if = [
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class SdaFabricSite(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ fabricName=params.get("fabricName"),
+ siteNameHierarchy=params.get("siteNameHierarchy"),
+ fabricType=params.get("fabricType"),
+ site_name_hierarchy=params.get("siteNameHierarchy"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['site_name_hierarchy'] = self.new_object.get('siteNameHierarchy') or \
+ self.new_object.get('site_name_hierarchy')
+ return new_object_params
+
+ 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['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')
+ return new_object_params
+
+ def get_object_by_name(self, name, is_absent=False):
+ result = None
+ # NOTE: Does not have a get by name method, using get all
+ try:
+ items = self.dnac.exec(
+ family="sda",
+ function="get_site",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ if isinstance(items, dict) and items.get("status") == "failed":
+ if is_absent:
+ raise AnsibleSDAException(response=items)
+ result = None
+ return result
+ result = get_dict_result(items, 'name', name)
+ except Exception:
+ if is_absent:
+ raise
+ 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, 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 'fabricName' in prev_obj
+ return (it_exists, prev_obj)
+
+ def requires_update(self, current_obj):
+ requested_obj = self.new_object
+
+ obj_params = [
+ ("fabricName", "fabricName"),
+ ("siteNameHierarchy", "siteNameHierarchy"),
+ ("fabricType", "fabricType"),
+ ("siteNameHierarchy", "site_name_hierarchy"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="sda",
+ function="add_site",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ if isinstance(result, dict):
+ if 'response' in result:
+ result = result.get('response')
+ if isinstance(result, dict) and result.get("status") == "failed":
+ raise AnsibleSDAException(response=result)
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="sda",
+ function="delete_site",
+ params=self.delete_all_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = SdaFabricSite(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ 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:
+ try:
+ response = obj.create()
+ dnac.object_created()
+ except AnsibleSDAException as e:
+ 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)
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+ except AnsibleSDAException as e:
+ 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())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_fabric_site_info.py b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_site_info.py
new file mode 100644
index 000000000..09cf70756
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_fabric_site_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteNameHierarchy=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ site_name_hierarchy=params.get("siteNameHierarchy"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sda",
+ function='get_site',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_multicast.py b/ansible_collections/cisco/dnac/plugins/action/sda_multicast.py
new file mode 100644
index 000000000..60c6b68ab
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_multicast.py
@@ -0,0 +1,221 @@
+#!/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 (
+ AnsibleSDAException,
+)
+
+# 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", "absent"]),
+ siteNameHierarchy=dict(type="str"),
+ multicastMethod=dict(type="str"),
+ multicastType=dict(type="str"),
+ multicastVnInfo=dict(type="list"),
+))
+
+required_if = [
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class SdaMulticast(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ siteNameHierarchy=params.get("siteNameHierarchy"),
+ multicastMethod=params.get("multicastMethod"),
+ multicastType=params.get("multicastType"),
+ multicastVnInfo=params.get("multicastVnInfo"),
+ site_name_hierarchy=params.get("siteNameHierarchy"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['site_name_hierarchy'] = self.new_object.get('siteNameHierarchy') or \
+ self.new_object.get('site_name_hierarchy')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['siteNameHierarchy'] = self.new_object.get('siteNameHierarchy')
+ new_object_params['multicastMethod'] = self.new_object.get('multicastMethod')
+ new_object_params['multicastType'] = self.new_object.get('multicastType')
+ new_object_params['multicastVnInfo'] = self.new_object.get('multicastVnInfo')
+ 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')
+ return new_object_params
+
+ def get_object_by_name(self, name, is_absent=False):
+ result = None
+ # NOTE: Does not have a get by name method, using get all
+ try:
+ items = self.dnac.exec(
+ family="sda",
+ function="get_multicast_details_from_sda_fabric",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ if isinstance(items, dict) and items.get("status") == "failed":
+ if is_absent:
+ raise AnsibleSDAException(response=items)
+ result = None
+ return result
+ result = get_dict_result(items, 'name', name)
+ except Exception:
+ if is_absent:
+ raise
+ 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, 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 'siteNameHierarchy' in prev_obj
+ return (it_exists, prev_obj)
+
+ def requires_update(self, current_obj):
+ requested_obj = self.new_object
+
+ obj_params = [
+ ("siteNameHierarchy", "siteNameHierarchy"),
+ ("multicastMethod", "multicastMethod"),
+ ("multicastType", "multicastType"),
+ ("multicastVnInfo", "multicastVnInfo"),
+ ("siteNameHierarchy", "site_name_hierarchy"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="sda",
+ function="add_multicast_in_sda_fabric",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ if isinstance(result, dict):
+ if 'response' in result:
+ result = result.get('response')
+ if isinstance(result, dict) and result.get("status") == "failed":
+ raise AnsibleSDAException(response=result)
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="sda",
+ function="delete_multicast_from_sda_fabric",
+ params=self.delete_all_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = SdaMulticast(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ 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:
+ try:
+ response = obj.create()
+ dnac.object_created()
+ except AnsibleSDAException as e:
+ 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)
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+ except AnsibleSDAException as e:
+ 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())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_multicast_info.py b/ansible_collections/cisco/dnac/plugins/action/sda_multicast_info.py
new file mode 100644
index 000000000..51716bd43
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_multicast_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteNameHierarchy=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ site_name_hierarchy=params.get("siteNameHierarchy"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sda",
+ function='get_multicast_details_from_sda_fabric',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_access_point.py b/ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_access_point.py
new file mode 100644
index 000000000..0cdfd8bf5
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_access_point.py
@@ -0,0 +1,234 @@
+#!/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 (
+ AnsibleSDAException,
+)
+
+# 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", "absent"]),
+ siteNameHierarchy=dict(type="str"),
+ deviceManagementIpAddress=dict(type="str"),
+ interfaceName=dict(type="str"),
+ dataIpAddressPoolName=dict(type="str"),
+ authenticateTemplateName=dict(type="str"),
+ interfaceDescription=dict(type="str"),
+))
+
+required_if = [
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class SdaPortAssignmentForAccessPoint(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ siteNameHierarchy=params.get("siteNameHierarchy"),
+ deviceManagementIpAddress=params.get("deviceManagementIpAddress"),
+ interfaceName=params.get("interfaceName"),
+ dataIpAddressPoolName=params.get("dataIpAddressPoolName"),
+ authenticateTemplateName=params.get("authenticateTemplateName"),
+ interfaceDescription=params.get("interfaceDescription"),
+ device_management_ip_address=params.get("deviceManagementIpAddress"),
+ interface_name=params.get("interfaceName"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['device_management_ip_address'] = self.new_object.get('deviceManagementIpAddress') or \
+ self.new_object.get('device_management_ip_address')
+ new_object_params['interface_name'] = self.new_object.get('interfaceName') or \
+ self.new_object.get('interface_name')
+ return new_object_params
+
+ 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')
+ 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')
+ return new_object_params
+
+ def get_object_by_name(self, name, is_absent=False):
+ result = None
+ # NOTE: Does not have a get by name method, using get all
+ try:
+ items = self.dnac.exec(
+ family="sda",
+ function="get_port_assignment_for_access_point",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ if isinstance(items, dict) and items.get("status") == "failed":
+ if is_absent:
+ raise AnsibleSDAException(response=items)
+ result = None
+ return result
+ result = get_dict_result(items, 'name', name)
+ except Exception:
+ if is_absent:
+ raise
+ 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, 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"
+ return (it_exists, prev_obj)
+
+ def requires_update(self, current_obj):
+ requested_obj = self.new_object
+
+ obj_params = [
+ ("siteNameHierarchy", "siteNameHierarchy"),
+ ("deviceManagementIpAddress", "deviceManagementIpAddress"),
+ ("interfaceName", "interfaceName"),
+ ("dataIpAddressPoolName", "dataIpAddressPoolName"),
+ ("authenticateTemplateName", "authenticateTemplateName"),
+ ("interfaceDescription", "interfaceDescription"),
+ ("deviceManagementIpAddress", "device_management_ip_address"),
+ ("interfaceName", "interface_name"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="sda",
+ function="add_port_assignment_for_access_point",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ if isinstance(result, dict):
+ if 'response' in result:
+ result = result.get('response')
+ if isinstance(result, dict) and result.get("status") == "failed":
+ raise AnsibleSDAException(response=result)
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="sda",
+ function="delete_port_assignment_for_access_point",
+ params=self.delete_all_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = SdaPortAssignmentForAccessPoint(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ 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:
+ try:
+ response = obj.create()
+ dnac.object_created()
+ except AnsibleSDAException as e:
+ 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)
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+ except AnsibleSDAException as e:
+ 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())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_access_point_info.py b/ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_access_point_info.py
new file mode 100644
index 000000000..8ff378449
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_access_point_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceManagementIpAddress=dict(type="str"),
+ interfaceName=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_management_ip_address=params.get("deviceManagementIpAddress"),
+ interface_name=params.get("interfaceName"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sda",
+ function='get_port_assignment_for_access_point',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_user_device.py b/ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_user_device.py
new file mode 100644
index 000000000..3c2a0728a
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_user_device.py
@@ -0,0 +1,246 @@
+#!/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 (
+ AnsibleSDAException,
+)
+
+# 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", "absent"]),
+ siteNameHierarchy=dict(type="str"),
+ deviceManagementIpAddress=dict(type="str"),
+ interfaceName=dict(type="str"),
+ interfaceNames=dict(type="list"),
+ dataIpAddressPoolName=dict(type="str"),
+ voiceIpAddressPoolName=dict(type="str"),
+ authenticateTemplateName=dict(type="str"),
+ scalableGroupName=dict(type="str"),
+ interfaceDescription=dict(type="str"),
+))
+
+required_if = [
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class SdaPortAssignmentForUserDevice(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ siteNameHierarchy=params.get("siteNameHierarchy"),
+ deviceManagementIpAddress=params.get("deviceManagementIpAddress"),
+ interfaceName=params.get("interfaceName"),
+ interfaceNames=params.get("interfaceNames"),
+ dataIpAddressPoolName=params.get("dataIpAddressPoolName"),
+ voiceIpAddressPoolName=params.get("voiceIpAddressPoolName"),
+ authenticateTemplateName=params.get("authenticateTemplateName"),
+ scalableGroupName=params.get("scalableGroupName"),
+ interfaceDescription=params.get("interfaceDescription"),
+ device_management_ip_address=params.get("deviceManagementIpAddress"),
+ interface_name=params.get("interfaceName"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['device_management_ip_address'] = self.new_object.get('deviceManagementIpAddress') or \
+ self.new_object.get('device_management_ip_address')
+ new_object_params['interface_name'] = self.new_object.get('interfaceName') or \
+ self.new_object.get('interface_name')
+ return new_object_params
+
+ 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')
+ 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')
+ return new_object_params
+
+ def get_object_by_name(self, name, is_absent=False):
+ result = None
+ # NOTE: Does not have a get by name method, using get all
+ try:
+ items = self.dnac.exec(
+ family="sda",
+ function="get_port_assignment_for_user_device",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ if isinstance(items, dict) and items.get("status") == "failed":
+ if is_absent:
+ raise AnsibleSDAException(response=items)
+ result = None
+ return result
+ result = get_dict_result(items, 'name', name)
+ except Exception:
+ if is_absent:
+ raise
+ 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, 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"
+ return (it_exists, prev_obj)
+
+ def requires_update(self, current_obj):
+ requested_obj = self.new_object
+
+ obj_params = [
+ ("siteNameHierarchy", "siteNameHierarchy"),
+ ("deviceManagementIpAddress", "deviceManagementIpAddress"),
+ ("interfaceName", "interfaceName"),
+ ("interfaceNames", "interfaceNames"),
+ ("dataIpAddressPoolName", "dataIpAddressPoolName"),
+ ("voiceIpAddressPoolName", "voiceIpAddressPoolName"),
+ ("authenticateTemplateName", "authenticateTemplateName"),
+ ("scalableGroupName", "scalableGroupName"),
+ ("interfaceDescription", "interfaceDescription"),
+ ("deviceManagementIpAddress", "device_management_ip_address"),
+ ("interfaceName", "interface_name"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="sda",
+ function="add_port_assignment_for_user_device",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ if isinstance(result, dict):
+ if 'response' in result:
+ result = result.get('response')
+ if isinstance(result, dict) and result.get("status") == "failed":
+ raise AnsibleSDAException(response=result)
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="sda",
+ function="delete_port_assignment_for_user_device",
+ params=self.delete_all_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = SdaPortAssignmentForUserDevice(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ 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:
+ try:
+ response = obj.create()
+ dnac.object_created()
+ except AnsibleSDAException as e:
+ 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)
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+ except AnsibleSDAException as e:
+ 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())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_user_device_info.py b/ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_user_device_info.py
new file mode 100644
index 000000000..978a8b042
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_user_device_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceManagementIpAddress=dict(type="str"),
+ interfaceName=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_management_ip_address=params.get("deviceManagementIpAddress"),
+ interface_name=params.get("interfaceName"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sda",
+ function='get_port_assignment_for_user_device',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_provision_device.py b/ansible_collections/cisco/dnac/plugins/action/sda_provision_device.py
new file mode 100644
index 000000000..d9215cb0d
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_provision_device.py
@@ -0,0 +1,233 @@
+#!/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 (
+ AnsibleSDAException,
+)
+
+# 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", "absent"]),
+ deviceManagementIpAddress=dict(type="str"),
+ siteNameHierarchy=dict(type="str"),
+))
+
+required_if = [
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class SdaProvisionDevice(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ deviceManagementIpAddress=params.get("deviceManagementIpAddress"),
+ siteNameHierarchy=params.get("siteNameHierarchy"),
+ device_management_ip_address=params.get("deviceManagementIpAddress"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['device_management_ip_address'] = self.new_object.get('deviceManagementIpAddress') or \
+ self.new_object.get('device_management_ip_address')
+ return new_object_params
+
+ 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')
+ 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')
+ 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')
+ return new_object_params
+
+ def get_object_by_name(self, name, is_absent=False):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="sda",
+ function="get_provisioned_wired_device",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ if isinstance(items, dict) and items.get("status") == "failed":
+ if is_absent:
+ raise AnsibleSDAException(response=items)
+ result = None
+ return result
+ result = get_dict_result(items, 'name', name)
+ except Exception:
+ if is_absent:
+ raise
+ 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, 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"
+ return (it_exists, prev_obj)
+
+ def requires_update(self, current_obj):
+ requested_obj = self.new_object
+
+ obj_params = [
+ ("deviceManagementIpAddress", "deviceManagementIpAddress"),
+ ("siteNameHierarchy", "siteNameHierarchy"),
+ ("deviceManagementIpAddress", "device_management_ip_address"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="sda",
+ function="provision_wired_device",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ if isinstance(result, dict):
+ if 'response' in result:
+ result = result.get('response')
+ if isinstance(result, dict) and result.get("status") == "failed":
+ raise AnsibleSDAException(response=result)
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="sda",
+ function="re_provision_wired_device",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="sda",
+ function="delete_provisioned_wired_device",
+ params=self.delete_all_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = SdaProvisionDevice(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ try:
+ response = obj.create()
+ dnac.object_created()
+ except AnsibleSDAException as e:
+ 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)
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+ except AnsibleSDAException as e:
+ 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())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_provision_device_info.py b/ansible_collections/cisco/dnac/plugins/action/sda_provision_device_info.py
new file mode 100644
index 000000000..f40817858
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_provision_device_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceManagementIpAddress=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_management_ip_address=params.get("deviceManagementIpAddress"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sda",
+ function='get_provisioned_wired_device',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_virtual_network.py b/ansible_collections/cisco/dnac/plugins/action/sda_virtual_network.py
new file mode 100644
index 000000000..5f8405aba
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_virtual_network.py
@@ -0,0 +1,218 @@
+#!/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 (
+ AnsibleSDAException,
+)
+
+# 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", "absent"]),
+ virtualNetworkName=dict(type="str"),
+ siteNameHierarchy=dict(type="str"),
+))
+
+required_if = [
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class SdaVirtualNetwork(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ virtualNetworkName=params.get("virtualNetworkName"),
+ siteNameHierarchy=params.get("siteNameHierarchy"),
+ virtual_network_name=params.get("virtualNetworkName"),
+ site_name_hierarchy=params.get("siteNameHierarchy"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['virtual_network_name'] = self.new_object.get('virtualNetworkName') or \
+ self.new_object.get('virtual_network_name')
+ new_object_params['site_name_hierarchy'] = self.new_object.get('siteNameHierarchy') or \
+ self.new_object.get('site_name_hierarchy')
+ return new_object_params
+
+ 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')
+ 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')
+ return new_object_params
+
+ def get_object_by_name(self, name, is_absent=False):
+ result = None
+ # NOTE: Does not have a get by name method, using get all
+ try:
+ items = self.dnac.exec(
+ family="sda",
+ function="get_vn",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ if isinstance(items, dict) and items.get("status") == "failed":
+ if is_absent:
+ raise AnsibleSDAException(response=items)
+ result = None
+ return result
+ result = get_dict_result(items, 'name', name)
+ except Exception:
+ if is_absent:
+ raise
+ 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, 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"
+ return (it_exists, prev_obj)
+
+ def requires_update(self, current_obj):
+ requested_obj = self.new_object
+
+ obj_params = [
+ ("virtualNetworkName", "virtualNetworkName"),
+ ("siteNameHierarchy", "siteNameHierarchy"),
+ ("virtualNetworkName", "virtual_network_name"),
+ ("siteNameHierarchy", "site_name_hierarchy"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="sda",
+ function="add_vn",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ if isinstance(result, dict):
+ if 'response' in result:
+ result = result.get('response')
+ if isinstance(result, dict) and result.get("status") == "failed":
+ raise AnsibleSDAException(response=result)
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="sda",
+ function="delete_vn",
+ params=self.delete_all_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = SdaVirtualNetwork(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ 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:
+ try:
+ response = obj.create()
+ dnac.object_created()
+ except AnsibleSDAException as e:
+ 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)
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+ except AnsibleSDAException as e:
+ 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())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_info.py b/ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_info.py
new file mode 100644
index 000000000..1397d9e0a
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ virtualNetworkName=dict(type="str"),
+ siteNameHierarchy=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ virtual_network_name=params.get("virtualNetworkName"),
+ site_name_hierarchy=params.get("siteNameHierarchy"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sda",
+ function='get_vn',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_ip_pool.py b/ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_ip_pool.py
new file mode 100644
index 000000000..674f55018
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_ip_pool.py
@@ -0,0 +1,280 @@
+#!/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 (
+ AnsibleSDAException,
+)
+
+# 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", "absent"]),
+ siteNameHierarchy=dict(type="str"),
+ virtualNetworkName=dict(type="str"),
+ isLayer2Only=dict(type="bool"),
+ ipPoolName=dict(type="str"),
+ vlanId=dict(type="str"),
+ vlanName=dict(type="str"),
+ autoGenerateVlanName=dict(type="bool"),
+ trafficType=dict(type="str"),
+ scalableGroupName=dict(type="str"),
+ isL2FloodingEnabled=dict(type="bool"),
+ isThisCriticalPool=dict(type="bool"),
+ isWirelessPool=dict(type="bool"),
+ isIpDirectedBroadcast=dict(type="bool"),
+ isCommonPool=dict(type="bool"),
+ isBridgeModeVm=dict(type="bool"),
+ poolType=dict(type="str"),
+))
+
+required_if = [
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class SdaVirtualNetworkIpPool(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ site_name_hierarchy=params.get("siteNameHierarchy"),
+ siteNameHierarchy=params.get("siteNameHierarchy"),
+ virtualNetworkName=params.get("virtualNetworkName"),
+ isLayer2Only=params.get("isLayer2Only"),
+ ipPoolName=params.get("ipPoolName"),
+ vlanId=params.get("vlanId"),
+ vlanName=params.get("vlanName"),
+ autoGenerateVlanName=params.get("autoGenerateVlanName"),
+ trafficType=params.get("trafficType"),
+ scalableGroupName=params.get("scalableGroupName"),
+ isL2FloodingEnabled=params.get("isL2FloodingEnabled"),
+ isThisCriticalPool=params.get("isThisCriticalPool"),
+ isWirelessPool=params.get("isWirelessPool"),
+ isIpDirectedBroadcast=params.get("isIpDirectedBroadcast"),
+ isCommonPool=params.get("isCommonPool"),
+ isBridgeModeVm=params.get("isBridgeModeVm"),
+ poolType=params.get("poolType"),
+ virtual_network_name=params.get("virtualNetworkName"),
+ ip_pool_name=params.get("ipPoolName"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['site_name_hierarchy'] = self.new_object.get('site_name_hierarchy') or \
+ self.new_object.get('siteNameHierarchy')
+ new_object_params['virtual_network_name'] = self.new_object.get('virtualNetworkName') or \
+ self.new_object.get('virtual_network_name')
+ new_object_params['ip_pool_name'] = self.new_object.get('ipPoolName') or \
+ self.new_object.get('ip_pool_name')
+ return new_object_params
+
+ 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['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['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['isCommonPool'] = self.new_object.get('isCommonPool')
+ 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['siteNameHierarchy'] = self.new_object.get('site_name_hierarchy')
+ 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
+
+ def get_object_by_name(self, name, is_absent=False):
+ result = None
+ # NOTE: Does not have a get by name method, using get all
+ try:
+ items = self.dnac.exec(
+ family="sda",
+ function="get_ip_pool_from_sda_virtual_network",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ if isinstance(items, dict) and items.get("status") == "failed":
+ if is_absent:
+ raise AnsibleSDAException(response=items)
+ result = None
+ return result
+ result = get_dict_result(items, 'name', name)
+ except Exception:
+ if is_absent:
+ raise
+ 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, 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"
+ return (it_exists, prev_obj)
+
+ def requires_update(self, current_obj):
+ requested_obj = self.new_object
+
+ obj_params = [
+ ("siteNameHierarchy", "siteNameHierarchy"),
+ ("virtualNetworkName", "virtualNetworkName"),
+ ("isLayer2Only", "isLayer2Only"),
+ ("ipPoolName", "ipPoolName"),
+ ("vlanId", "vlanId"),
+ ("vlanName", "vlanName"),
+ ("autoGenerateVlanName", "autoGenerateVlanName"),
+ ("trafficType", "trafficType"),
+ ("scalableGroupName", "scalableGroupName"),
+ ("isL2FloodingEnabled", "isL2FloodingEnabled"),
+ ("isThisCriticalPool", "isThisCriticalPool"),
+ ("isWirelessPool", "isWirelessPool"),
+ ("isIpDirectedBroadcast", "isIpDirectedBroadcast"),
+ ("isCommonPool", "isCommonPool"),
+ ("isBridgeModeVm", "isBridgeModeVm"),
+ ("poolType", "poolType"),
+ ("siteNameHierarchy", "site_name_hierarchy"),
+ ("virtualNetworkName", "virtual_network_name"),
+ ("ipPoolName", "ip_pool_name"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="sda",
+ function="add_ip_pool_in_sda_virtual_network",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ if isinstance(result, dict):
+ if 'response' in result:
+ result = result.get('response')
+ if isinstance(result, dict) and result.get("status") == "failed":
+ raise AnsibleSDAException(response=result)
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="sda",
+ function="delete_ip_pool_from_sda_virtual_network",
+ params=self.delete_all_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = SdaVirtualNetworkIpPool(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ 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:
+ try:
+ response = obj.create()
+ dnac.object_created()
+ except AnsibleSDAException as e:
+ 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)
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+ except AnsibleSDAException as e:
+ 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())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_ip_pool_info.py b/ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_ip_pool_info.py
new file mode 100644
index 000000000..055dece7f
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_ip_pool_info.py
@@ -0,0 +1,93 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteNameHierarchy=dict(type="str"),
+ virtualNetworkName=dict(type="str"),
+ ipPoolName=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ site_name_hierarchy=params.get("siteNameHierarchy"),
+ virtual_network_name=params.get("virtualNetworkName"),
+ ip_pool_name=params.get("ipPoolName"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sda",
+ function='get_ip_pool_from_sda_virtual_network',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_v2.py b/ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_v2.py
new file mode 100644
index 000000000..45c66872d
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_v2.py
@@ -0,0 +1,243 @@
+#!/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 (
+ AnsibleSDAException,
+)
+
+# 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", "absent"]),
+ virtualNetworkName=dict(type="str"),
+ isGuestVirtualNetwork=dict(type="bool"),
+ scalableGroupNames=dict(type="list"),
+ vManageVpnId=dict(type="str"),
+))
+
+required_if = [
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class SdaVirtualNetworkV2(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ virtualNetworkName=params.get("virtualNetworkName"),
+ isGuestVirtualNetwork=params.get("isGuestVirtualNetwork"),
+ scalableGroupNames=params.get("scalableGroupNames"),
+ vManageVpnId=params.get("vManageVpnId"),
+ virtual_network_name=params.get("virtualNetworkName"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['virtual_network_name'] = self.new_object.get('virtualNetworkName') or \
+ self.new_object.get('virtual_network_name')
+ return new_object_params
+
+ 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['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')
+ 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['vManageVpnId'] = self.new_object.get('vManageVpnId')
+ return new_object_params
+
+ def get_object_by_name(self, name, is_absent=False):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="sda",
+ function="get_virtual_network_with_scalable_groups",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ if isinstance(items, dict) and items.get("status") == "failed":
+ if is_absent:
+ raise AnsibleSDAException(response=items)
+ result = None
+ return result
+ result = get_dict_result(items, 'name', name)
+ except Exception:
+ if is_absent:
+ raise
+ 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, 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"
+ return (it_exists, prev_obj)
+
+ def requires_update(self, current_obj):
+ requested_obj = self.new_object
+
+ obj_params = [
+ ("virtualNetworkName", "virtualNetworkName"),
+ ("isGuestVirtualNetwork", "isGuestVirtualNetwork"),
+ ("scalableGroupNames", "scalableGroupNames"),
+ ("vManageVpnId", "vManageVpnId"),
+ ("virtualNetworkName", "virtual_network_name"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="sda",
+ function="add_virtual_network_with_scalable_groups",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ if isinstance(result, dict):
+ if 'response' in result:
+ result = result.get('response')
+ if isinstance(result, dict) and result.get("status") == "failed":
+ raise AnsibleSDAException(response=result)
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="sda",
+ function="update_virtual_network_with_scalable_groups",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="sda",
+ function="delete_virtual_network_with_scalable_groups",
+ params=self.delete_all_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = SdaVirtualNetworkV2(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ try:
+ response = obj.create()
+ dnac.object_created()
+ except AnsibleSDAException as e:
+ 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)
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+ except AnsibleSDAException as e:
+ 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())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_v2_info.py b/ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_v2_info.py
new file mode 100644
index 000000000..0044c8b0d
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_v2_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ virtualNetworkName=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ virtual_network_name=params.get("virtualNetworkName"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sda",
+ function='get_virtual_network_with_scalable_groups',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/security_advisories_devices_info.py b/ansible_collections/cisco/dnac/plugins/action/security_advisories_devices_info.py
new file mode 100644
index 000000000..83e51e4e1
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/security_advisories_devices_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ advisoryId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ advisory_id=params.get("advisoryId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="security_advisories",
+ function='get_devices_per_advisory',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/security_advisories_ids_per_device_info.py b/ansible_collections/cisco/dnac/plugins/action/security_advisories_ids_per_device_info.py
new file mode 100644
index 000000000..eebfa5627
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/security_advisories_ids_per_device_info.py
@@ -0,0 +1,98 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_id=params.get("deviceId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("deviceId")
+ if id:
+ response = dnac.exec(
+ family="security_advisories",
+ function='get_advisory_ids_per_device',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/security_advisories_info.py b/ansible_collections/cisco/dnac/plugins/action/security_advisories_info.py
new file mode 100644
index 000000000..a365433e2
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/security_advisories_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="security_advisories",
+ function='get_advisories_list',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/security_advisories_per_device_info.py b/ansible_collections/cisco/dnac/plugins/action/security_advisories_per_device_info.py
new file mode 100644
index 000000000..9694438e3
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/security_advisories_per_device_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ device_id=params.get("deviceId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="security_advisories",
+ function='get_advisories_per_device',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/security_advisories_summary_info.py b/ansible_collections/cisco/dnac/plugins/action/security_advisories_summary_info.py
new file mode 100644
index 000000000..cf2a7ce8a
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/security_advisories_summary_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="security_advisories",
+ function='get_advisories_summary',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sensor.py b/ansible_collections/cisco/dnac/plugins/action/sensor.py
new file mode 100644
index 000000000..797239834
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sensor.py
@@ -0,0 +1,225 @@
+#!/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", "absent"]),
+ ssids=dict(type="list"),
+ name=dict(type="str"),
+ connection=dict(type="str"),
+ apCoverage=dict(type="list"),
+ modelVersion=dict(type="int"),
+ templateName=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["name"], True),
+ ("state", "absent", ["name"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class Sensor(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ ssids=params.get("ssids"),
+ name=params.get("name"),
+ connection=params.get("connection"),
+ apCoverage=params.get("apCoverage"),
+ modelVersion=params.get("modelVersion"),
+ template_name=params.get("templateName"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['site_id'] = self.new_object.get('siteId') or \
+ self.new_object.get('site_id')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['ssids'] = self.new_object.get('ssids')
+ new_object_params['name'] = self.new_object.get('name')
+ new_object_params['connection'] = self.new_object.get('connection')
+ new_object_params['apCoverage'] = self.new_object.get('apCoverage')
+ new_object_params['modelVersion'] = self.new_object.get('modelVersion')
+ return new_object_params
+
+ def delete_all_params(self):
+ new_object_params = {}
+ new_object_params['template_name'] = self.new_object.get('template_name')
+ 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="sensors",
+ function="sensors",
+ 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 = [
+ ("ssids", "ssids"),
+ ("name", "name"),
+ ("connection", "connection"),
+ ("apCoverage", "apCoverage"),
+ ("modelVersion", "modelVersion"),
+ ("templateName", "template_name"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="sensors",
+ function="create_sensor_test_template",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="sensors",
+ function="delete_sensor_test",
+ params=self.delete_all_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = Sensor(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ 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:
+ response = obj.create()
+ dnac.object_created()
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sensor_info.py b/ansible_collections/cisco/dnac/plugins/action/sensor_info.py
new file mode 100644
index 000000000..66277baea
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sensor_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ site_id=params.get("siteId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sensors",
+ function='sensors',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sensor_test_run.py b/ansible_collections/cisco/dnac/plugins/action/sensor_test_run.py
new file mode 100644
index 000000000..e3939dc67
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sensor_test_run.py
@@ -0,0 +1,86 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ templateName=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ templateName=params.get("templateName"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="sensors",
+ function='run_now_sensor_test',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sensor_test_template_duplicate.py b/ansible_collections/cisco/dnac/plugins/action/sensor_test_template_duplicate.py
new file mode 100644
index 000000000..49c831c39
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sensor_test_template_duplicate.py
@@ -0,0 +1,88 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ templateName=dict(type="str"),
+ newTemplateName=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ templateName=params.get("templateName"),
+ newTemplateName=params.get("newTemplateName"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="sensors",
+ function='duplicate_sensor_test_template',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sensor_test_template_edit.py b/ansible_collections/cisco/dnac/plugins/action/sensor_test_template_edit.py
new file mode 100644
index 000000000..5e75c953b
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sensor_test_template_edit.py
@@ -0,0 +1,90 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ templateName=dict(type="str"),
+ locationInfoList=dict(type="list"),
+ schedule=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ templateName=params.get("templateName"),
+ locationInfoList=params.get("locationInfoList"),
+ schedule=params.get("schedule"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="sensors",
+ function='edit_sensor_test_template',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/service_provider_create.py b/ansible_collections/cisco/dnac/plugins/action/service_provider_create.py
new file mode 100644
index 000000000..eb7ca82c8
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/service_provider_create.py
@@ -0,0 +1,86 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ settings=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ settings=params.get("settings"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function='create_sp_profile',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/service_provider_info.py b/ansible_collections/cisco/dnac/plugins/action/service_provider_info.py
new file mode 100644
index 000000000..9fefca6fa
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/service_provider_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function='get_service_provider_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/service_provider_profile_delete.py b/ansible_collections/cisco/dnac/plugins/action/service_provider_profile_delete.py
new file mode 100644
index 000000000..31a5f3e43
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/service_provider_profile_delete.py
@@ -0,0 +1,85 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ spProfileName=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ sp_profile_name=params.get("spProfileName"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function="delete_sp_profile",
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/service_provider_update.py b/ansible_collections/cisco/dnac/plugins/action/service_provider_update.py
new file mode 100644
index 000000000..c3bb62473
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/service_provider_update.py
@@ -0,0 +1,86 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ settings=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ settings=params.get("settings"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function='update_sp_profile',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/service_provider_v2.py b/ansible_collections/cisco/dnac/plugins/action/service_provider_v2.py
new file mode 100644
index 000000000..36ce8ab08
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/service_provider_v2.py
@@ -0,0 +1,197 @@
+#!/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"]),
+ settings=dict(type="dict"),
+))
+
+required_if = [
+ ("state", "present", ["settings"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ServiceProviderV2(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ settings=params.get("settings"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['settings'] = self.new_object.get('settings')
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['settings'] = self.new_object.get('settings')
+ 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="network_settings",
+ function="get_service_provider_details_v2",
+ 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 = [
+ ("settings", "settings"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="network_settings",
+ function="create_sp_profile_v2",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="network_settings",
+ function="update_sp_profile_v2",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = ServiceProviderV2(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/service_provider_v2_info.py b/ansible_collections/cisco/dnac/plugins/action/service_provider_v2_info.py
new file mode 100644
index 000000000..f81c0e81c
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/service_provider_v2_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function='get_service_provider_details_v2',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/site_assign_credential.py b/ansible_collections/cisco/dnac/plugins/action/site_assign_credential.py
new file mode 100644
index 000000000..8e7d1841c
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/site_assign_credential.py
@@ -0,0 +1,100 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ cliId=dict(type="str"),
+ snmpV2ReadId=dict(type="str"),
+ snmpV2WriteId=dict(type="str"),
+ httpRead=dict(type="str"),
+ httpWrite=dict(type="str"),
+ snmpV3Id=dict(type="str"),
+ siteId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ cliId=params.get("cliId"),
+ snmpV2ReadId=params.get("snmpV2ReadId"),
+ snmpV2WriteId=params.get("snmpV2WriteId"),
+ httpRead=params.get("httpRead"),
+ httpWrite=params.get("httpWrite"),
+ snmpV3Id=params.get("snmpV3Id"),
+ site_id=params.get("siteId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function='assign_device_credential_to_site',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/site_assign_device.py b/ansible_collections/cisco/dnac/plugins/action/site_assign_device.py
new file mode 100644
index 000000000..dec7df437
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/site_assign_device.py
@@ -0,0 +1,93 @@
+#!/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, Display
+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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ device=dict(type="list"),
+ siteId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ device=params.get("device"),
+ site_id=params.get("siteId"),
+ )
+ return new_object
+
+ 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()
+
+ Display().warning("This module is currently unmaintained "
+ "and will be removed in future releases."
+ "New module is assign_device_to_site "
+ "for 2.3.5.3 or higher")
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sites",
+ function='assign_device_to_site',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/site_count_info.py b/ansible_collections/cisco/dnac/plugins/action/site_count_info.py
new file mode 100644
index 000000000..528b95e01
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/site_count_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ site_id=params.get("siteId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sites",
+ function='get_site_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/site_create.py b/ansible_collections/cisco/dnac/plugins/action/site_create.py
new file mode 100644
index 000000000..5f805c4c5
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/site_create.py
@@ -0,0 +1,90 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ type=dict(type="str"),
+ site=dict(type="dict"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ type=params.get("type"),
+ site=params.get("site"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="sites",
+ function='create_site',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/site_delete.py b/ansible_collections/cisco/dnac/plugins/action/site_delete.py
new file mode 100644
index 000000000..5e3b1f0f7
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/site_delete.py
@@ -0,0 +1,85 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ site_id=params.get("siteId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="sites",
+ function="delete_site",
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/site_design_floormap.py b/ansible_collections/cisco/dnac/plugins/action/site_design_floormap.py
new file mode 100644
index 000000000..3ec7c65b4
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/site_design_floormap.py
@@ -0,0 +1,248 @@
+#!/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, Display
+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", "absent"]),
+ floorId=dict(type="str"),
+ payload=dict(type="dict"),
+))
+
+required_if = [
+ ("state", "present", ["floorId"], True),
+ ("state", "absent", ["floorId"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class SiteDesignFloormap(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ floor_id=params.get("floorId"),
+ payload=params.get("payload"),
+ )
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['floor_id'] = self.new_object.get('floor_id')
+ return new_object_params
+
+ def update_by_id_params(self):
+ new_object_params = {}
+ new_object_params['floor_id'] = self.new_object.get('floor_id')
+ new_object_params['payload'] = self.new_object.get('payload')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTICE: Does not have a get by name method or it is in another action
+ # NOTICE: Does not have get all
+ return result
+
+ def get_object_by_id(self, id):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="site_design",
+ function="get_floormap",
+ params={"floor_id": id}
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ result = get_dict_result(items, 'floorId', id)
+ except Exception:
+ result = None
+ return result
+
+ def exists(self):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ o_id = self.new_object.get("id")
+ o_id = o_id or self.new_object.get("floor_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")
+ _id = _id or prev_obj.get("floorId")
+ 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(floor_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 = [
+ ("floorId", "floor_id"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="site_design",
+ function="create_floormap",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ id = id or self.new_object.get("floor_id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ id_ = id_ or prev_obj_name.get("floorId")
+ if id_:
+ self.new_object.update(dict(floor_id=id_))
+ result = self.dnac.exec(
+ family="site_design",
+ function="update_floormap",
+ params=self.update_by_id_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ id = id or self.new_object.get("floor_id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ id_ = id_ or prev_obj_name.get("floorId")
+ if id_:
+ self.new_object.update(dict(floor_id=id_))
+ result = self.dnac.exec(
+ family="site_design",
+ function="delete_floormap",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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()
+
+ Display().warning("This module is currently unmaintained "
+ "and will be removed in future releases.")
+
+ dnac = DNACSDK(self._task.args)
+ obj = SiteDesignFloormap(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/site_design_floormap_info.py b/ansible_collections/cisco/dnac/plugins/action/site_design_floormap_info.py
new file mode 100644
index 000000000..83f52b493
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/site_design_floormap_info.py
@@ -0,0 +1,103 @@
+#!/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, Display
+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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ floorId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ floor_id=params.get("floorId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ Display().warning("This module is currently unmaintained "
+ "and will be removed in future releases.")
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("floorId")
+ if id:
+ response = dnac.exec(
+ family="site_design",
+ function='get_floormap',
+ params=self.get_object(self._task.args)
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="site_design",
+ function='get_floormaps',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/site_health_info.py b/ansible_collections/cisco/dnac/plugins/action/site_health_info.py
new file mode 100644
index 000000000..7a38d07db
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/site_health_info.py
@@ -0,0 +1,95 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ timestamp=dict(type="str"),
+ siteType=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ timestamp=params.get("timestamp"),
+ site_type=params.get("siteType"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sites",
+ function='get_site_health',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/site_info.py b/ansible_collections/cisco/dnac/plugins/action/site_info.py
new file mode 100644
index 000000000..73e2733a1
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/site_info.py
@@ -0,0 +1,97 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ name=dict(type="str"),
+ siteId=dict(type="str"),
+ type=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ name=params.get("name"),
+ site_id=params.get("siteId"),
+ type=params.get("type"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sites",
+ function='get_site',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/site_membership_info.py b/ansible_collections/cisco/dnac/plugins/action/site_membership_info.py
new file mode 100644
index 000000000..7c5ec8467
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/site_membership_info.py
@@ -0,0 +1,106 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteId=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ deviceFamily=dict(type="str"),
+ serialNumber=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ site_id=params.get("siteId"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ device_family=params.get("deviceFamily"),
+ serial_number=params.get("serialNumber"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("siteId")
+ if id:
+ response = dnac.exec(
+ family="sites",
+ function='get_membership',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/site_update.py b/ansible_collections/cisco/dnac/plugins/action/site_update.py
new file mode 100644
index 000000000..0f7359d16
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/site_update.py
@@ -0,0 +1,92 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ type=dict(type="str"),
+ site=dict(type="dict"),
+ siteId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ type=params.get("type"),
+ site=params.get("site"),
+ site_id=params.get("siteId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="sites",
+ function='update_site',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/snmp_properties.py b/ansible_collections/cisco/dnac/plugins/action/snmp_properties.py
new file mode 100644
index 000000000..88acb70b2
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/snmp_properties.py
@@ -0,0 +1,202 @@
+#!/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"]),
+ payload=dict(type="list"),
+))
+
+required_if = [
+ ("state", "present", ["payload"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class SnmpProperties(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ payload=params.get("payload"),
+ )
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ 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="discovery",
+ function="get_snmp_properties"
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ result = get_dict_result(items, 'systemPropertyName', 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
+ try:
+ items = self.dnac.exec(
+ family="discovery",
+ function="get_snmp_properties"
+ )
+ 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
+ requested_obj = self.new_object.get('payload')
+ 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")
+ name = requested_obj.get("systemPropertyName")
+ 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 'systemPropertyName' params don't refer to the same object")
+ if _id:
+ payload = self.new_object.get('payload')
+ payload.update(id=_id)
+ self.new_object.update(dict(payload=payload))
+ 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.get('payload')
+ if requested_obj and len(requested_obj) > 0:
+ requested_obj = requested_obj[0]
+
+ obj_params = [
+ ("id", "id"),
+ ("instanceTenantId", "instanceTenantId"),
+ ("instanceUuid", "instanceUuid"),
+ ("intValue", "intValue"),
+ ("systemPropertyName", "systemPropertyName"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="discovery",
+ function="create_update_snmp_properties",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = SnmpProperties(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ try:
+ response = obj.create()
+ dnac.object_updated()
+ except Exception:
+ response = prev_obj
+ dnac.object_present_and_different()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/snmp_properties_info.py b/ansible_collections/cisco/dnac/plugins/action/snmp_properties_info.py
new file mode 100644
index 000000000..cd02442a7
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/snmp_properties_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="discovery",
+ function='get_snmp_properties',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/snmpv2_read_community_credential.py b/ansible_collections/cisco/dnac/plugins/action/snmpv2_read_community_credential.py
new file mode 100644
index 000000000..60edf5c83
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/snmpv2_read_community_credential.py
@@ -0,0 +1,225 @@
+#!/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"]),
+ comments=dict(type="str"),
+ credentialType=dict(type="str"),
+ description=dict(type="str"),
+ instanceUuid=dict(type="str"),
+ readCommunity=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["description"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class Snmpv2ReadCommunityCredential(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ comments=params.get("comments"),
+ credentialType=params.get("credentialType"),
+ description=params.get("description"),
+ instanceUuid=params.get("instanceUuid"),
+ readCommunity=params.get("readCommunity"),
+ )
+
+ def create_params(self):
+ new_object_params = {}
+ payload = {}
+ keys = ['comments', 'credentialType', 'description', 'instanceUuid', 'readCommunity',
+ 'readCommunity']
+ for key in keys:
+ if self.new_object.get(key) is not None:
+ payload[key] = self.new_object.get(key)
+ new_object_params['payload'] = [payload]
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['comments'] = self.new_object.get('comments')
+ new_object_params['credentialType'] = self.new_object.get('credentialType')
+ new_object_params['description'] = self.new_object.get('description')
+ new_object_params['instanceUuid'] = self.new_object.get('instanceUuid')
+ new_object_params['readCommunity'] = self.new_object.get('readCommunity')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="discovery",
+ function="get_global_credentials",
+ params={'credential_sub_type': 'SNMPV2_READ_COMMUNITY'},
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ result = get_dict_result(items, 'description', name)
+ except Exception:
+ result = None
+ return result
+
+ def get_object_by_id(self, id):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="discovery",
+ function="get_global_credentials",
+ params={'credential_sub_type': 'SNMPV2_READ_COMMUNITY'},
+ )
+ 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("description") or self.new_object.get("username")
+ 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 = [
+ ("comments", "comments"),
+ ("credentialType", "credentialType"),
+ ("description", "description"),
+ ("instanceUuid", "instanceUuid"),
+ ("readCommunity", "readCommunity"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="discovery",
+ function="create_snmp_read_community",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="discovery",
+ function="update_snmp_read_community",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = Snmpv2ReadCommunityCredential(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/snmpv2_write_community_credential.py b/ansible_collections/cisco/dnac/plugins/action/snmpv2_write_community_credential.py
new file mode 100644
index 000000000..97982d2c7
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/snmpv2_write_community_credential.py
@@ -0,0 +1,225 @@
+#!/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"]),
+ comments=dict(type="str"),
+ credentialType=dict(type="str"),
+ description=dict(type="str"),
+ instanceUuid=dict(type="str"),
+ writeCommunity=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["description"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class Snmpv2WriteCommunityCredential(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ comments=params.get("comments"),
+ credentialType=params.get("credentialType"),
+ description=params.get("description"),
+ instanceUuid=params.get("instanceUuid"),
+ writeCommunity=params.get("writeCommunity"),
+ )
+
+ def create_params(self):
+ new_object_params = {}
+ payload = {}
+ keys = ['comments', 'credentialType', 'description', 'instanceUuid', 'writeCommunity',
+ 'writeCommunity']
+ for key in keys:
+ if self.new_object.get(key) is not None:
+ payload[key] = self.new_object.get(key)
+ new_object_params['payload'] = [payload]
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['comments'] = self.new_object.get('comments')
+ new_object_params['credentialType'] = self.new_object.get('credentialType')
+ new_object_params['description'] = self.new_object.get('description')
+ new_object_params['instanceUuid'] = self.new_object.get('instanceUuid')
+ new_object_params['writeCommunity'] = self.new_object.get('writeCommunity')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="discovery",
+ function="get_global_credentials",
+ params={'credential_sub_type': 'SNMPV2_WRITE_COMMUNITY'},
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ result = get_dict_result(items, 'description', name)
+ except Exception:
+ result = None
+ return result
+
+ def get_object_by_id(self, id):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="discovery",
+ function="get_global_credentials",
+ params={'credential_sub_type': 'SNMPV2_WRITE_COMMUNITY'},
+ )
+ 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("description") or self.new_object.get("username")
+ 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 = [
+ ("comments", "comments"),
+ ("credentialType", "credentialType"),
+ ("description", "description"),
+ ("instanceUuid", "instanceUuid"),
+ ("writeCommunity", "writeCommunity"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="discovery",
+ function="create_snmp_write_community",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="discovery",
+ function="update_snmp_write_community",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = Snmpv2WriteCommunityCredential(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/snmpv3_credential.py b/ansible_collections/cisco/dnac/plugins/action/snmpv3_credential.py
new file mode 100644
index 000000000..480c82e66
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/snmpv3_credential.py
@@ -0,0 +1,252 @@
+#!/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"]),
+ authPassword=dict(type="str", no_log=True),
+ authType=dict(type="str"),
+ comments=dict(type="str"),
+ credentialType=dict(type="str"),
+ description=dict(type="str"),
+ id=dict(type="str"),
+ instanceTenantId=dict(type="str"),
+ instanceUuid=dict(type="str"),
+ privacyPassword=dict(type="str", no_log=True),
+ privacyType=dict(type="str"),
+ snmpMode=dict(type="str"),
+ username=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["description", "id", "username"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class Snmpv3Credential(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ authPassword=params.get("authPassword"),
+ authType=params.get("authType"),
+ comments=params.get("comments"),
+ credentialType=params.get("credentialType"),
+ description=params.get("description"),
+ id=params.get("id"),
+ instanceTenantId=params.get("instanceTenantId"),
+ instanceUuid=params.get("instanceUuid"),
+ privacyPassword=params.get("privacyPassword"),
+ privacyType=params.get("privacyType"),
+ snmpMode=params.get("snmpMode"),
+ username=params.get("username"),
+ )
+
+ def create_params(self):
+ new_object_params = {}
+ payload = {}
+ keys = ['authPassword', 'authType', 'comments', 'credentialType', 'description',
+ 'id', 'instanceTenantId', 'instanceUuid', 'privacyPassword', 'privacyType',
+ 'snmpMode', 'username']
+ for key in keys:
+ if self.new_object.get(key) is not None:
+ payload[key] = self.new_object.get(key)
+ new_object_params['payload'] = [payload]
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['authPassword'] = self.new_object.get('authPassword')
+ new_object_params['authType'] = self.new_object.get('authType')
+ new_object_params['comments'] = self.new_object.get('comments')
+ new_object_params['credentialType'] = self.new_object.get('credentialType')
+ new_object_params['description'] = self.new_object.get('description')
+ new_object_params['id'] = self.new_object.get('id')
+ new_object_params['instanceTenantId'] = self.new_object.get('instanceTenantId')
+ new_object_params['instanceUuid'] = self.new_object.get('instanceUuid')
+ new_object_params['privacyPassword'] = self.new_object.get('privacyPassword')
+ new_object_params['privacyType'] = self.new_object.get('privacyType')
+ new_object_params['snmpMode'] = self.new_object.get('snmpMode')
+ new_object_params['username'] = self.new_object.get('username')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="discovery",
+ function="get_global_credentials",
+ params={'credential_sub_type': 'SNMPV3'},
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ result = get_dict_result(items, 'description', name) or get_dict_result(items, 'username', name)
+ except Exception:
+ result = None
+ return result
+
+ def get_object_by_id(self, id):
+ result = None
+ try:
+ items = self.dnac.exec(
+ family="discovery",
+ function="get_global_credentials",
+ params={'credential_sub_type': 'SNMPV3'},
+ )
+ 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("description") or self.new_object.get("username")
+ 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 = [
+ ("authType", "authType"),
+ ("comments", "comments"),
+ ("credentialType", "credentialType"),
+ ("description", "description"),
+ ("id", "id"),
+ ("instanceTenantId", "instanceTenantId"),
+ ("instanceUuid", "instanceUuid"),
+ ("privacyType", "privacyType"),
+ ("snmpMode", "snmpMode"),
+ ("username", "username"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="discovery",
+ function="create_snmpv3_credentials",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="discovery",
+ function="update_snmpv3_credentials",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = Snmpv3Credential(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/sp_profile_delete_v2.py b/ansible_collections/cisco/dnac/plugins/action/sp_profile_delete_v2.py
new file mode 100644
index 000000000..52219be6a
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/sp_profile_delete_v2.py
@@ -0,0 +1,85 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ spProfileName=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ sp_profile_name=params.get("spProfileName"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="network_settings",
+ function="delete_sp_profile_v2",
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/swim_image_details_info.py b/ansible_collections/cisco/dnac/plugins/action/swim_image_details_info.py
new file mode 100644
index 000000000..e7151893c
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/swim_image_details_info.py
@@ -0,0 +1,123 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ imageUuid=dict(type="str"),
+ name=dict(type="str"),
+ family=dict(type="str"),
+ applicationType=dict(type="str"),
+ imageIntegrityStatus=dict(type="str"),
+ version=dict(type="str"),
+ imageSeries=dict(type="str"),
+ imageName=dict(type="str"),
+ isTaggedGolden=dict(type="bool"),
+ isCCORecommended=dict(type="bool"),
+ isCCOLatest=dict(type="bool"),
+ createdTime=dict(type="int"),
+ imageSizeGreaterThan=dict(type="int"),
+ imageSizeLesserThan=dict(type="int"),
+ sortBy=dict(type="str"),
+ sortOrder=dict(type="str"),
+ limit=dict(type="int"),
+ offset=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ image_uuid=params.get("imageUuid"),
+ name=params.get("name"),
+ family=params.get("family"),
+ application_type=params.get("applicationType"),
+ image_integrity_status=params.get("imageIntegrityStatus"),
+ version=params.get("version"),
+ image_series=params.get("imageSeries"),
+ image_name=params.get("imageName"),
+ is_tagged_golden=params.get("isTaggedGolden"),
+ is_cco_recommended=params.get("isCCORecommended"),
+ is_cco_latest=params.get("isCCOLatest"),
+ created_time=params.get("createdTime"),
+ image_size_greater_than=params.get("imageSizeGreaterThan"),
+ image_size_lesser_than=params.get("imageSizeLesserThan"),
+ sort_by=params.get("sortBy"),
+ sort_order=params.get("sortOrder"),
+ limit=params.get("limit"),
+ offset=params.get("offset"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="software_image_management_swim",
+ function='get_software_image_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/swim_import_local.py b/ansible_collections/cisco/dnac/plugins/action/swim_import_local.py
new file mode 100644
index 000000000..57946e44e
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/swim_import_local.py
@@ -0,0 +1,95 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ isThirdParty=dict(type="bool"),
+ thirdPartyVendor=dict(type="str"),
+ thirdPartyImageFamily=dict(type="str"),
+ thirdPartyApplicationType=dict(type="str"),
+ filePath=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ 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"),
+ file_path=params.get("filePath"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="software_image_management_swim",
+ function='import_local_software_image',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ file_paths=[('file_path', 'file')],
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/swim_import_via_url.py b/ansible_collections/cisco/dnac/plugins/action/swim_import_via_url.py
new file mode 100644
index 000000000..3cf0528a3
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/swim_import_via_url.py
@@ -0,0 +1,92 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ payload=dict(type="list"),
+ scheduleAt=dict(type="str"),
+ scheduleDesc=dict(type="str"),
+ scheduleOrigin=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ payload=params.get("payload"),
+ schedule_at=params.get("scheduleAt"),
+ schedule_desc=params.get("scheduleDesc"),
+ schedule_origin=params.get("scheduleOrigin"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="software_image_management_swim",
+ function='import_software_image_via_url',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/swim_trigger_activation.py b/ansible_collections/cisco/dnac/plugins/action/swim_trigger_activation.py
new file mode 100644
index 000000000..b223b8784
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/swim_trigger_activation.py
@@ -0,0 +1,90 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ payload=dict(type="list"),
+ scheduleValidate=dict(type="bool"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ payload=params.get("payload"),
+ schedule_validate=params.get("scheduleValidate"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="software_image_management_swim",
+ function='trigger_software_image_activation',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/swim_trigger_distribution.py b/ansible_collections/cisco/dnac/plugins/action/swim_trigger_distribution.py
new file mode 100644
index 000000000..b3d75d663
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/swim_trigger_distribution.py
@@ -0,0 +1,86 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ payload=dict(type="list"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ payload=params.get("payload"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="software_image_management_swim",
+ function='trigger_software_image_distribution',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/syslog_config_create.py b/ansible_collections/cisco/dnac/plugins/action/syslog_config_create.py
new file mode 100644
index 000000000..ec91631b7
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/syslog_config_create.py
@@ -0,0 +1,96 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ configId=dict(type="str"),
+ name=dict(type="str"),
+ description=dict(type="str"),
+ host=dict(type="str"),
+ protocol=dict(type="str"),
+ port=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ configId=params.get("configId"),
+ name=params.get("name"),
+ description=params.get("description"),
+ host=params.get("host"),
+ protocol=params.get("protocol"),
+ port=params.get("port"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='create_syslog_destination',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/syslog_config_update.py b/ansible_collections/cisco/dnac/plugins/action/syslog_config_update.py
new file mode 100644
index 000000000..3529c3244
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/syslog_config_update.py
@@ -0,0 +1,96 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ configId=dict(type="str"),
+ name=dict(type="str"),
+ description=dict(type="str"),
+ host=dict(type="str"),
+ protocol=dict(type="str"),
+ port=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ configId=params.get("configId"),
+ name=params.get("name"),
+ description=params.get("description"),
+ host=params.get("host"),
+ protocol=params.get("protocol"),
+ port=params.get("port"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="event_management",
+ function='update_syslog_destination',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/system_health_count_info.py b/ansible_collections/cisco/dnac/plugins/action/system_health_count_info.py
new file mode 100644
index 000000000..58b74f6ca
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/system_health_count_info.py
@@ -0,0 +1,91 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ domain=dict(type="str"),
+ subdomain=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ domain=params.get("domain"),
+ subdomain=params.get("subdomain"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="health_and_performance",
+ function='system_health_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/system_health_info.py b/ansible_collections/cisco/dnac/plugins/action/system_health_info.py
new file mode 100644
index 000000000..28683d23b
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/system_health_info.py
@@ -0,0 +1,97 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ summary=dict(type="bool"),
+ domain=dict(type="str"),
+ subdomain=dict(type="str"),
+ limit=dict(type="int"),
+ offset=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ summary=params.get("summary"),
+ domain=params.get("domain"),
+ subdomain=params.get("subdomain"),
+ limit=params.get("limit"),
+ offset=params.get("offset"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="health_and_performance",
+ function='system_health',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/system_performance_historical_info.py b/ansible_collections/cisco/dnac/plugins/action/system_performance_historical_info.py
new file mode 100644
index 000000000..287c72245
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/system_performance_historical_info.py
@@ -0,0 +1,93 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ kpi=dict(type="str"),
+ startTime=dict(type="int"),
+ endTime=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ kpi=params.get("kpi"),
+ start_time=params.get("startTime"),
+ end_time=params.get("endTime"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="health_and_performance",
+ function='system_performance_historical',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/system_performance_info.py b/ansible_collections/cisco/dnac/plugins/action/system_performance_info.py
new file mode 100644
index 000000000..b05406cbf
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/system_performance_info.py
@@ -0,0 +1,95 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ kpi=dict(type="str"),
+ function=dict(type="str"),
+ startTime=dict(type="int"),
+ endTime=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ kpi=params.get("kpi"),
+ function=params.get("function"),
+ start_time=params.get("startTime"),
+ end_time=params.get("endTime"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="health_and_performance",
+ function='system_performance',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/tag.py b/ansible_collections/cisco/dnac/plugins/action/tag.py
new file mode 100644
index 000000000..15596748e
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/tag.py
@@ -0,0 +1,283 @@
+#!/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", "absent"]),
+ systemTag=dict(type="bool"),
+ description=dict(type="str"),
+ dynamicRules=dict(type="list"),
+ name=dict(type="str"),
+ id=dict(type="str"),
+ instanceTenantId=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["id", "name"], True),
+ ("state", "absent", ["id", "name"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class Tag(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ systemTag=params.get("systemTag"),
+ description=params.get("description"),
+ dynamicRules=params.get("dynamicRules"),
+ name=params.get("name"),
+ id=params.get("id"),
+ instanceTenantId=params.get("instanceTenantId"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['name'] = name or self.new_object.get('name')
+ new_object_params['additional_info_name_space'] = self.new_object.get('additionalInfo_nameSpace') or \
+ self.new_object.get('additional_info_name_space')
+ new_object_params['additional_info_attributes'] = self.new_object.get('additionalInfo_attributes') or \
+ self.new_object.get('additional_info_attributes')
+ new_object_params['level'] = self.new_object.get('level')
+ new_object_params['offset'] = self.new_object.get('offset')
+ new_object_params['limit'] = self.new_object.get('limit')
+ new_object_params['size'] = self.new_object.get('size')
+ new_object_params['field'] = self.new_object.get('field')
+ 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')
+ new_object_params['system_tag'] = self.new_object.get('systemTag') or \
+ self.new_object.get('system_tag')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['systemTag'] = self.new_object.get('systemTag')
+ new_object_params['description'] = self.new_object.get('description')
+ 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')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['id'] = self.new_object.get('id')
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['systemTag'] = self.new_object.get('systemTag')
+ new_object_params['description'] = self.new_object.get('description')
+ 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')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="tag",
+ function="get_tag",
+ 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="tag",
+ function="get_tag_by_id",
+ 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):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ 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 = [
+ ("systemTag", "systemTag"),
+ ("description", "description"),
+ ("dynamicRules", "dynamicRules"),
+ ("name", "name"),
+ ("id", "id"),
+ ("instanceTenantId", "instanceTenantId"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="tag",
+ function="create_tag",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="tag",
+ function="update_tag",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ if id_:
+ self.new_object.update(dict(id=id_))
+ result = self.dnac.exec(
+ family="tag",
+ function="delete_tag",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = Tag(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/tag_count_info.py b/ansible_collections/cisco/dnac/plugins/action/tag_count_info.py
new file mode 100644
index 000000000..03827a43d
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/tag_count_info.py
@@ -0,0 +1,99 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ name=dict(type="str"),
+ nameSpace=dict(type="str"),
+ attributeName=dict(type="str"),
+ level=dict(type="str"),
+ size=dict(type="str"),
+ systemTag=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ name=params.get("name"),
+ name_space=params.get("nameSpace"),
+ attribute_name=params.get("attributeName"),
+ level=params.get("level"),
+ size=params.get("size"),
+ system_tag=params.get("systemTag"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="tag",
+ function='get_tag_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/tag_info.py b/ansible_collections/cisco/dnac/plugins/action/tag_info.py
new file mode 100644
index 000000000..773cc8858
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/tag_info.py
@@ -0,0 +1,122 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ name=dict(type="str"),
+ additionalInfo_nameSpace=dict(type="str"),
+ additionalInfo_attributes=dict(type="str"),
+ level=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ size=dict(type="str"),
+ field=dict(type="str"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ systemTag=dict(type="str"),
+ id=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ name=params.get("name"),
+ additional_info_name_space=params.get("additionalInfo_nameSpace"),
+ additional_info_attributes=params.get("additionalInfo_attributes"),
+ level=params.get("level"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ size=params.get("size"),
+ field=params.get("field"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ system_tag=params.get("systemTag"),
+ id=params.get("id"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ if id:
+ response = dnac.exec(
+ family="tag",
+ function='get_tag_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="tag",
+ function='get_tag',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/tag_member.py b/ansible_collections/cisco/dnac/plugins/action/tag_member.py
new file mode 100644
index 000000000..e92fdf505
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/tag_member.py
@@ -0,0 +1,225 @@
+#!/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", "absent"]),
+ payload=dict(type="dict"),
+ object=dict(type="str"),
+ id=dict(type="str"),
+ memberId=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["id", "memberId"], True),
+ ("state", "absent", ["id", "memberId"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class TagMember(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ payload=params.get("payload"),
+ object=params.get("object"),
+ id=params.get("id"),
+ member_id=params.get("memberId"),
+ )
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['payload'] = self.new_object.get('payload')
+ new_object_params['id'] = self.new_object.get('id')
+ new_object_params['object'] = self.new_object.get('object')
+ return new_object_params
+
+ def delete_by_id_params(self):
+ new_object_params = {}
+ new_object_params['id'] = self.new_object.get('id')
+ new_object_params['member_id'] = self.new_object.get('member_id')
+ 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
+ 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
+ try:
+ items = self.dnac.exec(
+ family="tag",
+ function="get_tag_members_by_id",
+ 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")
+ o_id = o_id or self.new_object.get("member_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")
+ _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")
+ if _id:
+ self.new_object.update(dict(id=_id))
+ self.new_object.update(dict(member_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 = [
+ ("object", "object"),
+ ("id", "id"),
+ ("memberId", "member_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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="tag",
+ function="add_members_to_the_tag",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ id = id or self.new_object.get("member_id")
+ name = self.new_object.get("name")
+ result = None
+ if not id:
+ prev_obj_name = self.get_object_by_name(name)
+ id_ = None
+ if prev_obj_name:
+ id_ = prev_obj_name.get("id")
+ id_ = id_ or prev_obj_name.get("memberId")
+ if id_:
+ self.new_object.update(dict(member_id=id_))
+ result = self.dnac.exec(
+ family="tag",
+ function="remove_tag_member",
+ params=self.delete_by_id_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = TagMember(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ 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:
+ response = obj.create()
+ dnac.object_created()
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/tag_member_count_info.py b/ansible_collections/cisco/dnac/plugins/action/tag_member_count_info.py
new file mode 100644
index 000000000..f3457c067
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/tag_member_count_info.py
@@ -0,0 +1,95 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+ memberType=dict(type="str"),
+ memberAssociationType=dict(type="str"),
+ level=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ member_type=params.get("memberType"),
+ member_association_type=params.get("memberAssociationType"),
+ level=params.get("level"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="tag",
+ function='get_tag_member_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/tag_member_info.py b/ansible_collections/cisco/dnac/plugins/action/tag_member_info.py
new file mode 100644
index 000000000..e90f5551e
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/tag_member_info.py
@@ -0,0 +1,99 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+ memberType=dict(type="str"),
+ offset=dict(type="str"),
+ limit=dict(type="str"),
+ memberAssociationType=dict(type="str"),
+ level=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ member_type=params.get("memberType"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ member_association_type=params.get("memberAssociationType"),
+ level=params.get("level"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="tag",
+ function='get_tag_members_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/tag_member_type_info.py b/ansible_collections/cisco/dnac/plugins/action/tag_member_type_info.py
new file mode 100644
index 000000000..69ff6ea37
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/tag_member_type_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="tag",
+ function='get_tag_resource_types',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/tag_membership.py b/ansible_collections/cisco/dnac/plugins/action/tag_membership.py
new file mode 100644
index 000000000..451501f94
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/tag_membership.py
@@ -0,0 +1,88 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ memberToTags=dict(type="list"),
+ memberType=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ memberToTags=params["memberToTags"][0] if params.get("memberToTags") and len(params["memberToTags"]) > 0 else None,
+ memberType=params.get("memberType"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="tag",
+ function='updates_tag_membership',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/task_count_info.py b/ansible_collections/cisco/dnac/plugins/action/task_count_info.py
new file mode 100644
index 000000000..0c3021123
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/task_count_info.py
@@ -0,0 +1,107 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ startTime=dict(type="str"),
+ endTime=dict(type="str"),
+ data=dict(type="str"),
+ errorCode=dict(type="str"),
+ serviceType=dict(type="str"),
+ username=dict(type="str"),
+ progress=dict(type="str"),
+ isError=dict(type="str"),
+ failureReason=dict(type="str"),
+ parentId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ start_time=params.get("startTime"),
+ end_time=params.get("endTime"),
+ data=params.get("data"),
+ error_code=params.get("errorCode"),
+ service_type=params.get("serviceType"),
+ username=params.get("username"),
+ progress=params.get("progress"),
+ is_error=params.get("isError"),
+ failure_reason=params.get("failureReason"),
+ parent_id=params.get("parentId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="task",
+ function='get_task_count',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/task_info.py b/ansible_collections/cisco/dnac/plugins/action/task_info.py
new file mode 100644
index 000000000..0f79bcb06
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/task_info.py
@@ -0,0 +1,128 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ startTime=dict(type="str"),
+ endTime=dict(type="str"),
+ data=dict(type="str"),
+ errorCode=dict(type="str"),
+ serviceType=dict(type="str"),
+ username=dict(type="str"),
+ progress=dict(type="str"),
+ isError=dict(type="str"),
+ failureReason=dict(type="str"),
+ parentId=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ sortBy=dict(type="str"),
+ order=dict(type="str"),
+ taskId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ start_time=params.get("startTime"),
+ end_time=params.get("endTime"),
+ data=params.get("data"),
+ error_code=params.get("errorCode"),
+ service_type=params.get("serviceType"),
+ username=params.get("username"),
+ progress=params.get("progress"),
+ is_error=params.get("isError"),
+ failure_reason=params.get("failureReason"),
+ parent_id=params.get("parentId"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ sort_by=params.get("sortBy"),
+ order=params.get("order"),
+ task_id=params.get("taskId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("taskId")
+ if id:
+ response = dnac.exec(
+ family="task",
+ function='get_task_by_id',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ if not id:
+ response = dnac.exec(
+ family="task",
+ function='get_tasks',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/task_operation_info.py b/ansible_collections/cisco/dnac/plugins/action/task_operation_info.py
new file mode 100644
index 000000000..cd17674ca
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/task_operation_info.py
@@ -0,0 +1,102 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ operationId=dict(type="str"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ operation_id=params.get("operationId"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("operationId")
+ if id:
+ response = dnac.exec(
+ family="task",
+ function='get_task_by_operationid',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/task_tree_info.py b/ansible_collections/cisco/dnac/plugins/action/task_tree_info.py
new file mode 100644
index 000000000..872f8156c
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/task_tree_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ taskId=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ task_id=params.get("taskId"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="task",
+ function='get_task_tree',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/template_preview.py b/ansible_collections/cisco/dnac/plugins/action/template_preview.py
new file mode 100644
index 000000000..1f21d5bb3
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/template_preview.py
@@ -0,0 +1,92 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ deviceId=dict(type="str"),
+ params=dict(type="dict"),
+ resourceParams=dict(type="dict"),
+ templateId=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ deviceId=params.get("deviceId"),
+ params=params.get("params"),
+ resourceParams=params.get("resourceParams"),
+ templateId=params.get("templateId"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="configuration_templates",
+ function='preview_template',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/templates_details_info.py b/ansible_collections/cisco/dnac/plugins/action/templates_details_info.py
new file mode 100644
index 000000000..9c8f0ab9b
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/templates_details_info.py
@@ -0,0 +1,121 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ id=dict(type="str"),
+ name=dict(type="str"),
+ projectId=dict(type="str"),
+ projectName=dict(type="str"),
+ softwareType=dict(type="str"),
+ softwareVersion=dict(type="str"),
+ productFamily=dict(type="str"),
+ productSeries=dict(type="str"),
+ productType=dict(type="str"),
+ filterConflictingTemplates=dict(type="bool"),
+ tags=dict(type="list"),
+ unCommitted=dict(type="bool"),
+ sortOrder=dict(type="str"),
+ allTemplateAttributes=dict(type="bool"),
+ includeVersionDetails=dict(type="bool"),
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ id=params.get("id"),
+ name=params.get("name"),
+ project_id=params.get("projectId"),
+ project_name=params.get("projectName"),
+ software_type=params.get("softwareType"),
+ software_version=params.get("softwareVersion"),
+ product_family=params.get("productFamily"),
+ product_series=params.get("productSeries"),
+ product_type=params.get("productType"),
+ filter_conflicting_templates=params.get("filterConflictingTemplates"),
+ tags=params.get("tags"),
+ un_committed=params.get("unCommitted"),
+ sort_order=params.get("sortOrder"),
+ all_template_attributes=params.get("allTemplateAttributes"),
+ include_version_details=params.get("includeVersionDetails"),
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="configuration_templates",
+ function='get_templates_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/threat_detail.py b/ansible_collections/cisco/dnac/plugins/action/threat_detail.py
new file mode 100644
index 000000000..5ecfa84f7
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/threat_detail.py
@@ -0,0 +1,103 @@
+#!/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, Display
+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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ startTime=dict(type="int"),
+ endTime=dict(type="int"),
+ siteId=dict(type="list"),
+ threatLevel=dict(type="list"),
+ threatType=dict(type="list"),
+ isNewThreat=dict(type="bool"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ startTime=params.get("startTime"),
+ endTime=params.get("endTime"),
+ siteId=params.get("siteId"),
+ threatLevel=params.get("threatLevel"),
+ threatType=params.get("threatType"),
+ isNewThreat=params.get("isNewThreat"),
+ )
+ return new_object
+
+ 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()
+
+ Display().warning("This module is currently unmaintained "
+ "and will be removed in future releases.")
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='threat_details',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/threat_detail_count.py b/ansible_collections/cisco/dnac/plugins/action/threat_detail_count.py
new file mode 100644
index 000000000..25fc96d21
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/threat_detail_count.py
@@ -0,0 +1,103 @@
+#!/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, Display
+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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ offset=dict(type="int"),
+ limit=dict(type="int"),
+ startTime=dict(type="int"),
+ endTime=dict(type="int"),
+ siteId=dict(type="list"),
+ threatLevel=dict(type="list"),
+ threatType=dict(type="list"),
+ isNewThreat=dict(type="bool"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ offset=params.get("offset"),
+ limit=params.get("limit"),
+ startTime=params.get("startTime"),
+ endTime=params.get("endTime"),
+ siteId=params.get("siteId"),
+ threatLevel=params.get("threatLevel"),
+ threatType=params.get("threatType"),
+ isNewThreat=params.get("isNewThreat"),
+ )
+ return new_object
+
+ 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()
+
+ Display().warning("This module is currently unmaintained "
+ "and will be removed in future releases.")
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='threat_detail_count',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/threat_summary.py b/ansible_collections/cisco/dnac/plugins/action/threat_summary.py
new file mode 100644
index 000000000..898abe1a2
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/threat_summary.py
@@ -0,0 +1,97 @@
+#!/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, Display
+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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ startTime=dict(type="int"),
+ endTime=dict(type="int"),
+ siteId=dict(type="list"),
+ threatLevel=dict(type="list"),
+ threatType=dict(type="list"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ startTime=params.get("startTime"),
+ endTime=params.get("endTime"),
+ siteId=params.get("siteId"),
+ threatLevel=params.get("threatLevel"),
+ threatType=params.get("threatType"),
+ )
+ return new_object
+
+ 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()
+
+ Display().warning("This module is currently unmaintained "
+ "and will be removed in future releases.")
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="devices",
+ function='threat_summary',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/topology_layer_2_info.py b/ansible_collections/cisco/dnac/plugins/action/topology_layer_2_info.py
new file mode 100644
index 000000000..2697ad3b5
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/topology_layer_2_info.py
@@ -0,0 +1,98 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ vlanID=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ vlan_id=params.get("vlanID"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("vlanID")
+ if id:
+ response = dnac.exec(
+ family="topology",
+ function='get_topology_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/topology_layer_3_info.py b/ansible_collections/cisco/dnac/plugins/action/topology_layer_3_info.py
new file mode 100644
index 000000000..5b295903f
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/topology_layer_3_info.py
@@ -0,0 +1,98 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ topologyType=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ topology_type=params.get("topologyType"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ id = self._task.args.get("topologyType")
+ if id:
+ response = dnac.exec(
+ family="topology",
+ function='get_l3_topology_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
+ 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")
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/topology_network_health_info.py b/ansible_collections/cisco/dnac/plugins/action/topology_network_health_info.py
new file mode 100644
index 000000000..d8a8e75da
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/topology_network_health_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ timestamp=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ timestamp=params.get("timestamp"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="topology",
+ function='get_overall_network_health',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/topology_physical_info.py b/ansible_collections/cisco/dnac/plugins/action/topology_physical_info.py
new file mode 100644
index 000000000..d2bf38e72
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/topology_physical_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ nodeType=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ node_type=params.get("nodeType"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="topology",
+ function='get_physical_topology',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/topology_site_info.py b/ansible_collections/cisco/dnac/plugins/action/topology_site_info.py
new file mode 100644
index 000000000..4f903dbc0
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/topology_site_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="topology",
+ function='get_site_topology',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/topology_vlan_details_info.py b/ansible_collections/cisco/dnac/plugins/action/topology_vlan_details_info.py
new file mode 100644
index 000000000..f613a3416
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/topology_vlan_details_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="topology",
+ function='get_vlan_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/transit_peer_network.py b/ansible_collections/cisco/dnac/plugins/action/transit_peer_network.py
new file mode 100644
index 000000000..a15848230
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/transit_peer_network.py
@@ -0,0 +1,210 @@
+#!/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 (
+ AnsibleSDAException,
+)
+
+# 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", "absent"]),
+ transitPeerNetworkName=dict(type="str"),
+ transitPeerNetworkType=dict(type="str"),
+ ipTransitSettings=dict(type="dict"),
+ sdaTransitSettings=dict(type="dict"),
+))
+
+required_if = [
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class TransitPeerNetwork(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ transitPeerNetworkName=params.get("transitPeerNetworkName"),
+ transitPeerNetworkType=params.get("transitPeerNetworkType"),
+ ipTransitSettings=params.get("ipTransitSettings"),
+ sdaTransitSettings=params.get("sdaTransitSettings"),
+ transit_peer_network_name=params.get("transitPeerNetworkName"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['transit_peer_network_name'] = self.new_object.get('transitPeerNetworkName') or \
+ self.new_object.get('transit_peer_network_name')
+ return new_object_params
+
+ 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')
+ 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')
+ return new_object_params
+
+ def get_object_by_name(self, name, is_absent=False):
+ result = None
+ # NOTE: Does not have a get by name method, using get all
+ try:
+ items = self.dnac.exec(
+ family="sda",
+ function="get_transit_peer_network_info",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ if isinstance(items, dict) and items.get("status") == "failed":
+ if is_absent:
+ raise AnsibleSDAException(response=items)
+ result = None
+ return result
+ result = get_dict_result(items, 'name', name)
+ except Exception:
+ if is_absent:
+ raise
+ 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, is_absent=False):
+ name = self.new_object.get("transitPeerNetworkName")
+ 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"
+ return (it_exists, prev_obj)
+
+ def requires_update(self, current_obj):
+ requested_obj = self.new_object
+
+ obj_params = [
+ ("transitPeerNetworkName", "transitPeerNetworkName"),
+ ("transitPeerNetworkType", "transitPeerNetworkType"),
+ ("ipTransitSettings", "ipTransitSettings"),
+ ("sdaTransitSettings", "sdaTransitSettings"),
+ ("transitPeerNetworkName", "transit_peer_network_name"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="sda",
+ function="add_transit_peer_network",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="sda",
+ function="delete_transit_peer_network",
+ params=self.delete_all_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = TransitPeerNetwork(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ 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:
+ response = obj.create()
+ dnac.object_created()
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists(is_absent=True)
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/transit_peer_network_info.py b/ansible_collections/cisco/dnac/plugins/action/transit_peer_network_info.py
new file mode 100644
index 000000000..a0856733d
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/transit_peer_network_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ transitPeerNetworkName=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ transit_peer_network_name=params.get("transitPeerNetworkName"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="sda",
+ function='get_transit_peer_network_info',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/user.py b/ansible_collections/cisco/dnac/plugins/action/user.py
new file mode 100644
index 000000000..b9c8d5c4e
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/user.py
@@ -0,0 +1,225 @@
+#!/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"]),
+ firstName=dict(type="str"),
+ lastName=dict(type="str"),
+ username=dict(type="str"),
+ password=dict(type="str", no_log=True),
+ email=dict(type="str"),
+ roleList=dict(type="list"),
+ userId=dict(type="str"),
+))
+
+required_if = [
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class User(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ firstName=params.get("firstName"),
+ lastName=params.get("lastName"),
+ username=params.get("username"),
+ password=params.get("password"),
+ email=params.get("email"),
+ roleList=params.get("roleList"),
+ userId=params.get("userId"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['invoke_source'] = self.new_object.get('invokeSource') or \
+ self.new_object.get('invoke_source')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['firstName'] = self.new_object.get('firstName')
+ new_object_params['lastName'] = self.new_object.get('lastName')
+ new_object_params['username'] = self.new_object.get('username')
+ new_object_params['password'] = self.new_object.get('password')
+ new_object_params['email'] = self.new_object.get('email')
+ new_object_params['roleList'] = self.new_object.get('roleList')
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['firstName'] = self.new_object.get('firstName')
+ new_object_params['lastName'] = self.new_object.get('lastName')
+ new_object_params['email'] = self.new_object.get('email')
+ new_object_params['username'] = self.new_object.get('username')
+ new_object_params['userId'] = self.new_object.get('userId')
+ new_object_params['roleList'] = self.new_object.get('roleList')
+ 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="userand_roles",
+ function="get_users_ap_i",
+ 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 = [
+ ("firstName", "firstName"),
+ ("lastName", "lastName"),
+ ("username", "username"),
+ ("email", "email"),
+ ("roleList", "roleList"),
+ ("userId", "userId"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="userand_roles",
+ function="add_user_ap_i",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="userand_roles",
+ function="update_user_ap_i",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = User(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/user_enrichment_details_info.py b/ansible_collections/cisco/dnac/plugins/action/user_enrichment_details_info.py
new file mode 100644
index 000000000..da4c16cde
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/user_enrichment_details_info.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="users",
+ function='get_user_enrichment_details',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/user_info.py b/ansible_collections/cisco/dnac/plugins/action/user_info.py
new file mode 100644
index 000000000..eb9ccc38e
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/user_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ invokeSource=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ invoke_source=params.get("invokeSource"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="userand_roles",
+ function='get_users_ap_i',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/users_external_servers_info.py b/ansible_collections/cisco/dnac/plugins/action/users_external_servers_info.py
new file mode 100644
index 000000000..1436338cc
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/users_external_servers_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ invokeSource=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ invoke_source=params.get("invokeSource"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="userand_roles",
+ function='get_external_authentication_servers_ap_i',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/wireless_accespoint_configuration.py b/ansible_collections/cisco/dnac/plugins/action/wireless_accespoint_configuration.py
new file mode 100644
index 000000000..f99e312ed
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/wireless_accespoint_configuration.py
@@ -0,0 +1,130 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ apList=dict(type="list"),
+ configureAdminStatus=dict(type="bool"),
+ adminStatus=dict(type="bool"),
+ configureApMode=dict(type="bool"),
+ apMode=dict(type="int"),
+ configureApHeight=dict(type="bool"),
+ apHeight=dict(type="int"),
+ configureFailoverPriority=dict(type="bool"),
+ failoverPriority=dict(type="int"),
+ configureLedStatus=dict(type="bool"),
+ ledStatus=dict(type="bool"),
+ configureLedBrightnessLevel=dict(type="bool"),
+ ledBrightnessLevel=dict(type="int"),
+ configureLocation=dict(type="bool"),
+ location=dict(type="str"),
+ configureHAController=dict(type="bool"),
+ primaryControllerName=dict(type="str"),
+ primaryIpAddress=dict(type="dict"),
+ secondaryControllerName=dict(type="str"),
+ secondaryIpAddress=dict(type="dict"),
+ tertiaryControllerName=dict(type="str"),
+ tertiaryIpAddress=dict(type="dict"),
+ radioConfigurations=dict(type="list"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ apList=params.get("apList"),
+ configureAdminStatus=params.get("configureAdminStatus"),
+ adminStatus=params.get("adminStatus"),
+ configureApMode=params.get("configureApMode"),
+ apMode=params.get("apMode"),
+ configureApHeight=params.get("configureApHeight"),
+ apHeight=params.get("apHeight"),
+ configureFailoverPriority=params.get("configureFailoverPriority"),
+ failoverPriority=params.get("failoverPriority"),
+ configureLedStatus=params.get("configureLedStatus"),
+ ledStatus=params.get("ledStatus"),
+ configureLedBrightnessLevel=params.get("configureLedBrightnessLevel"),
+ ledBrightnessLevel=params.get("ledBrightnessLevel"),
+ configureLocation=params.get("configureLocation"),
+ location=params.get("location"),
+ configureHAController=params.get("configureHAController"),
+ primaryControllerName=params.get("primaryControllerName"),
+ primaryIpAddress=params.get("primaryIpAddress"),
+ secondaryControllerName=params.get("secondaryControllerName"),
+ secondaryIpAddress=params.get("secondaryIpAddress"),
+ tertiaryControllerName=params.get("tertiaryControllerName"),
+ tertiaryIpAddress=params.get("tertiaryIpAddress"),
+ radioConfigurations=params.get("radioConfigurations"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="wireless",
+ function='configure_access_points',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/wireless_accesspoint_configuration_summary_info.py b/ansible_collections/cisco/dnac/plugins/action/wireless_accesspoint_configuration_summary_info.py
new file mode 100644
index 000000000..f1f4ab0ed
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/wireless_accesspoint_configuration_summary_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ key=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ key=params.get("key"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="wireless",
+ function='get_access_point_configuration',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/wireless_dynamic_interface.py b/ansible_collections/cisco/dnac/plugins/action/wireless_dynamic_interface.py
new file mode 100644
index 000000000..51f458f57
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/wireless_dynamic_interface.py
@@ -0,0 +1,229 @@
+#!/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", "absent"]),
+ interfaceName=dict(type="str"),
+ vlanId=dict(type="int"),
+ headers=dict(type="dict"),
+))
+
+required_if = [
+ ("state", "present", ["interfaceName"], True),
+ ("state", "absent", ["interfaceName"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class WirelessDynamicInterface(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ interfaceName=params.get("interfaceName"),
+ vlanId=params.get("vlanId"),
+ headers=params.get("headers"),
+ interface_name=params.get("interfaceName"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ 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['vlanId'] = self.new_object.get('vlanId')
+ return new_object_params
+
+ def delete_by_name_params(self):
+ new_object_params = {}
+ new_object_params['interface_name'] = self.new_object.get('interface_name')
+ new_object_params['headers'] = self.new_object.get('headers')
+ 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="wireless",
+ function="get_dynamic_interface",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ result = get_dict_result(items, 'interfaceName', 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")
+ name = name or self.new_object.get("interface_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 id_exists:
+ _name = prev_obj.get("name")
+ _name = _name or prev_obj.get("interfaceName")
+ if _name:
+ self.new_object.update(dict(interface_name=_name))
+ 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 = [
+ ("interfaceName", "interfaceName"),
+ ("vlanId", "vlanId"),
+ ("interfaceName", "interface_name"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="wireless",
+ function="create_update_dynamic_interface",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ name = name or self.new_object.get("interface_name")
+ result = None
+ if not name:
+ prev_obj_id = self.get_object_by_id(id)
+ name_ = None
+ if prev_obj_id:
+ name_ = prev_obj_id.get("name")
+ name_ = name_ or prev_obj_id.get("interfaceName")
+ if name_:
+ self.new_object.update(dict(interface_name=name_))
+ result = self.dnac.exec(
+ family="wireless",
+ function="delete_dynamic_interface",
+ params=self.delete_by_name_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = WirelessDynamicInterface(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ 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:
+ response = obj.create()
+ dnac.object_created()
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/wireless_dynamic_interface_info.py b/ansible_collections/cisco/dnac/plugins/action/wireless_dynamic_interface_info.py
new file mode 100644
index 000000000..561b620e1
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/wireless_dynamic_interface_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ interface_name=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ interface_name=params.get("interface_name"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="wireless",
+ function='get_dynamic_interface',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/wireless_enterprise_ssid.py b/ansible_collections/cisco/dnac/plugins/action/wireless_enterprise_ssid.py
new file mode 100644
index 000000000..7e2d129c0
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/wireless_enterprise_ssid.py
@@ -0,0 +1,347 @@
+#!/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", "absent"]),
+ name=dict(type="str"),
+ securityLevel=dict(type="str"),
+ passphrase=dict(type="str"),
+ enableFastLane=dict(type="bool"),
+ enableMACFiltering=dict(type="bool"),
+ trafficType=dict(type="str"),
+ radioPolicy=dict(type="str"),
+ enableBroadcastSSID=dict(type="bool"),
+ fastTransition=dict(type="str"),
+ enableSessionTimeOut=dict(type="bool"),
+ sessionTimeOut=dict(type="int"),
+ enableClientExclusion=dict(type="bool"),
+ clientExclusionTimeout=dict(type="int"),
+ enableBasicServiceSetMaxIdle=dict(type="bool"),
+ basicServiceSetClientIdleTimeout=dict(type="int"),
+ enableDirectedMulticastService=dict(type="bool"),
+ enableNeighborList=dict(type="bool"),
+ mfpClientProtection=dict(type="str"),
+ nasOptions=dict(type="list"),
+ ssidName=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["name", "ssidName"], True),
+ ("state", "absent", ["name", "ssidName"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class WirelessEnterpriseSsid(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ name=params.get("name"),
+ securityLevel=params.get("securityLevel"),
+ passphrase=params.get("passphrase"),
+ enableFastLane=params.get("enableFastLane"),
+ enableMACFiltering=params.get("enableMACFiltering"),
+ trafficType=params.get("trafficType"),
+ radioPolicy=params.get("radioPolicy"),
+ enableBroadcastSSID=params.get("enableBroadcastSSID"),
+ fastTransition=params.get("fastTransition"),
+ enableSessionTimeOut=params.get("enableSessionTimeOut"),
+ sessionTimeOut=params.get("sessionTimeOut"),
+ enableClientExclusion=params.get("enableClientExclusion"),
+ clientExclusionTimeout=params.get("clientExclusionTimeout"),
+ enableBasicServiceSetMaxIdle=params.get("enableBasicServiceSetMaxIdle"),
+ basicServiceSetClientIdleTimeout=params.get("basicServiceSetClientIdleTimeout"),
+ enableDirectedMulticastService=params.get("enableDirectedMulticastService"),
+ enableNeighborList=params.get("enableNeighborList"),
+ mfpClientProtection=params.get("mfpClientProtection"),
+ nasOptions=params.get("nasOptions"),
+ ssid_name=params.get("ssidName"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['ssid_name'] = self.new_object.get('ssidName') or \
+ self.new_object.get('ssid_name')
+ return new_object_params
+
+ 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['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['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['nasOptions'] = self.new_object.get('nasOptions')
+ return new_object_params
+
+ def delete_by_name_params(self):
+ new_object_params = {}
+ new_object_params['ssid_name'] = self.new_object.get('ssid_name')
+ return new_object_params
+
+ 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['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['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['nasOptions'] = self.new_object.get('nasOptions')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="wireless",
+ function="get_enterprise_ssid",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, list):
+ for item in items:
+ if isinstance(item, dict):
+ n_item = None
+ if 'response' in item:
+ n_item = item.get('response')
+ if 'ssidDetails' in item:
+ n_item = item.get('ssidDetails')
+ n_item = get_dict_result(n_item, 'name', name)
+ if n_item is not None:
+ return n_item
+ return result
+ if isinstance(items, dict):
+ if 'response' in items:
+ items = items.get('response')
+ if 'ssidDetails' in items:
+ items = items.get('ssidDetails')
+ 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):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ o_id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ name = name or self.new_object.get("ssid_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 id_exists:
+ _name = prev_obj.get("name")
+ _name = _name or prev_obj.get("ssidName")
+ if _name:
+ self.new_object.update(dict(ssid_name=_name))
+ 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 = [
+ ("name", "name"),
+ ("securityLevel", "securityLevel"),
+ ("passphrase", "passphrase"),
+ ("enableFastLane", "enableFastLane"),
+ ("enableMACFiltering", "enableMACFiltering"),
+ ("trafficType", "trafficType"),
+ ("radioPolicy", "radioPolicy"),
+ ("enableBroadcastSSID", "enableBroadcastSSID"),
+ ("fastTransition", "fastTransition"),
+ ("enableSessionTimeOut", "enableSessionTimeOut"),
+ ("sessionTimeOut", "sessionTimeOut"),
+ ("enableClientExclusion", "enableClientExclusion"),
+ ("clientExclusionTimeout", "clientExclusionTimeout"),
+ ("enableBasicServiceSetMaxIdle", "enableBasicServiceSetMaxIdle"),
+ ("basicServiceSetClientIdleTimeout", "basicServiceSetClientIdleTimeout"),
+ ("enableDirectedMulticastService", "enableDirectedMulticastService"),
+ ("enableNeighborList", "enableNeighborList"),
+ ("mfpClientProtection", "mfpClientProtection"),
+ ("nasOptions", "nasOptions"),
+ ("ssidName", "ssid_name"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="wireless",
+ function="create_enterprise_ssid",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="wireless",
+ function="update_enterprise_ssid",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ name = name or self.new_object.get("ssid_name")
+ result = None
+ if not name:
+ prev_obj_id = self.get_object_by_id(id)
+ name_ = None
+ if prev_obj_id:
+ name_ = prev_obj_id.get("name")
+ name_ = name_ or prev_obj_id.get("ssidName")
+ if name_:
+ self.new_object.update(dict(ssid_name=name_))
+ result = self.dnac.exec(
+ family="wireless",
+ function="delete_enterprise_ssid",
+ params=self.delete_by_name_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = WirelessEnterpriseSsid(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/wireless_enterprise_ssid_info.py b/ansible_collections/cisco/dnac/plugins/action/wireless_enterprise_ssid_info.py
new file mode 100644
index 000000000..37048d0a2
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/wireless_enterprise_ssid_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ ssidName=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ ssid_name=params.get("ssidName"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="wireless",
+ function='get_enterprise_ssid',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/wireless_profile.py b/ansible_collections/cisco/dnac/plugins/action/wireless_profile.py
new file mode 100644
index 000000000..b2b22fb8e
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/wireless_profile.py
@@ -0,0 +1,247 @@
+#!/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,
+)
+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", "absent"]),
+ profileDetails=dict(type="dict"),
+ wirelessProfileName=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["profileDetails"], True),
+ ("state", "absent", ["wirelessProfileName"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class WirelessProfile(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ profileDetails=params.get("profileDetails"),
+ wireless_profile_name=params.get("wirelessProfileName"),
+ )
+
+ def get_all_params(self, name=None, id=None):
+ new_object_params = {}
+ new_object_params['profile_name'] = name or self.new_object.get('wireless_profile_name')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ 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')
+ return new_object_params
+
+ def update_all_params(self):
+ new_object_params = {}
+ new_object_params['profileDetails'] = self.new_object.get('profileDetails')
+ return new_object_params
+
+ def get_object_by_name(self, name):
+ result = None
+ # NOTE: Does not have a get by name method or it is in another action
+ try:
+ items = self.dnac.exec(
+ family="wireless",
+ function="get_wireless_profile",
+ params=self.get_all_params(name=name),
+ )
+ if isinstance(items, list):
+ for i in items:
+ if isinstance(i, dict) and 'profileDetails' in i:
+ tmp = i.get('profileDetails')
+ if isinstance(tmp, dict) and tmp.get('name') == name:
+ result = dict(i)
+ break
+ 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):
+ id_exists = False
+ name_exists = False
+ prev_obj = None
+ o_id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ name = name or self.new_object.get("wireless_profile_name")
+ profile_details = self.new_object.get("profileDetails")
+ if profile_details and profile_details.get("name"):
+ name = name or profile_details.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 id_exists:
+ _name = prev_obj.get("name")
+ _name = _name or prev_obj.get("wirelessProfileName")
+ if _name:
+ self.new_object.update(dict(wireless_profile_name=_name))
+ 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 = [
+ ("profileDetails", "profileDetails"),
+ ("wirelessProfileName", "wireless_profile_name"),
+ ]
+ # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="wireless",
+ function="create_wireless_profile",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def update(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ result = None
+ result = self.dnac.exec(
+ family="wireless",
+ function="update_wireless_profile",
+ params=self.update_all_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ name = name or self.new_object.get("wireless_profile_name")
+ result = None
+ if not name:
+ prev_obj_id = self.get_object_by_id(id)
+ name_ = None
+ if prev_obj_id:
+ name_ = prev_obj_id.get("name")
+ name_ = name_ or prev_obj_id.get("wirelessProfileName")
+ if name_:
+ self.new_object.update(dict(wireless_profile_name=name_))
+ result = self.dnac.exec(
+ family="wireless",
+ function="delete_wireless_profile",
+ params=self.delete_by_name_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = WirelessProfile(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ response = None
+
+ if state == "present":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ if obj.requires_update(prev_obj):
+ response = obj.update()
+ dnac.object_updated()
+ else:
+ response = prev_obj
+ dnac.object_already_present()
+ else:
+ response = obj.create()
+ dnac.object_created()
+
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/wireless_profile_info.py b/ansible_collections/cisco/dnac/plugins/action/wireless_profile_info.py
new file mode 100644
index 000000000..24027bd6b
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/wireless_profile_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ profileName=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ profile_name=params.get("profileName"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="wireless",
+ function='get_wireless_profile',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/wireless_provision_access_point.py b/ansible_collections/cisco/dnac/plugins/action/wireless_provision_access_point.py
new file mode 100644
index 000000000..8cbce8d39
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/wireless_provision_access_point.py
@@ -0,0 +1,88 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ payload=dict(type="list"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ payload=params.get("payload"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="wireless",
+ function='ap_provision',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/wireless_provision_device_create.py b/ansible_collections/cisco/dnac/plugins/action/wireless_provision_device_create.py
new file mode 100644
index 000000000..95d3e443d
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/wireless_provision_device_create.py
@@ -0,0 +1,86 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ payload=dict(type="list"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ payload=params.get("payload"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="wireless",
+ function='provision',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/wireless_provision_device_update.py b/ansible_collections/cisco/dnac/plugins/action/wireless_provision_device_update.py
new file mode 100644
index 000000000..c62d176e2
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/wireless_provision_device_update.py
@@ -0,0 +1,88 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ payload=dict(type="list"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ payload=params.get("payload"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="wireless",
+ function='provision_update',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/wireless_provision_ssid_create_provision.py b/ansible_collections/cisco/dnac/plugins/action/wireless_provision_ssid_create_provision.py
new file mode 100644
index 000000000..b1787ff6b
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/wireless_provision_ssid_create_provision.py
@@ -0,0 +1,96 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ managedAPLocations=dict(type="list"),
+ ssidDetails=dict(type="dict"),
+ ssidType=dict(type="str"),
+ enableFabric=dict(type="bool"),
+ flexConnect=dict(type="dict"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ managedAPLocations=params.get("managedAPLocations"),
+ ssidDetails=params.get("ssidDetails"),
+ ssidType=params.get("ssidType"),
+ enableFabric=params.get("enableFabric"),
+ flexConnect=params.get("flexConnect"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="wireless",
+ function='create_and_provision_ssid',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/wireless_provision_ssid_delete_reprovision.py b/ansible_collections/cisco/dnac/plugins/action/wireless_provision_ssid_delete_reprovision.py
new file mode 100644
index 000000000..6480f992e
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/wireless_provision_ssid_delete_reprovision.py
@@ -0,0 +1,87 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ ssidName=dict(type="str"),
+ managedAPLocations=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ ssid_name=params.get("ssidName"),
+ managed_aplocations=params.get("managedAPLocations"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="wireless",
+ function="delete_ssid_and_provision_it_to_devices",
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/wireless_psk_override.py b/ansible_collections/cisco/dnac/plugins/action/wireless_psk_override.py
new file mode 100644
index 000000000..6fe372d58
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/wireless_psk_override.py
@@ -0,0 +1,86 @@
+#!/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,
+)
+
+# Get common arguements specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ payload=dict(type="list"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 get_object(self, params):
+ new_object = dict(
+ payload=params.get("payload"),
+ )
+ return new_object
+
+ 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(params=self._task.args)
+
+ response = dnac.exec(
+ family="wireless",
+ function='psk_override',
+ op_modifies=True,
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/wireless_rf_profile.py b/ansible_collections/cisco/dnac/plugins/action/wireless_rf_profile.py
new file mode 100644
index 000000000..07ac522dc
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/wireless_rf_profile.py
@@ -0,0 +1,263 @@
+#!/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", "absent"]),
+ name=dict(type="str"),
+ defaultRfProfile=dict(type="bool"),
+ enableRadioTypeA=dict(type="bool"),
+ enableRadioTypeB=dict(type="bool"),
+ channelWidth=dict(type="str"),
+ enableCustom=dict(type="bool"),
+ enableBrownField=dict(type="bool"),
+ radioTypeAProperties=dict(type="dict"),
+ radioTypeBProperties=dict(type="dict"),
+ radioTypeCProperties=dict(type="dict"),
+ enableRadioTypeC=dict(type="bool"),
+ rfProfileName=dict(type="str"),
+))
+
+required_if = [
+ ("state", "present", ["name", "rfProfileName"], True),
+ ("state", "absent", ["name", "rfProfileName"], True),
+]
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class WirelessRfProfile(object):
+ def __init__(self, params, dnac):
+ self.dnac = dnac
+ self.new_object = dict(
+ name=params.get("name"),
+ defaultRfProfile=params.get("defaultRfProfile"),
+ enableRadioTypeA=params.get("enableRadioTypeA"),
+ enableRadioTypeB=params.get("enableRadioTypeB"),
+ channelWidth=params.get("channelWidth"),
+ enableCustom=params.get("enableCustom"),
+ enableBrownField=params.get("enableBrownField"),
+ radioTypeAProperties=params.get("radioTypeAProperties"),
+ radioTypeBProperties=params.get("radioTypeBProperties"),
+ radioTypeCProperties=params.get("radioTypeCProperties"),
+ enableRadioTypeC=params.get("enableRadioTypeC"),
+ rf_profile_name=params.get("rfProfileName"),
+ )
+
+ 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') or self.new_object.get('name')
+ return new_object_params
+
+ def create_params(self):
+ new_object_params = {}
+ new_object_params['name'] = self.new_object.get('rf_profile_name') or 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['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')
+ 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') or self.new_object.get('name')
+ 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="wireless",
+ function="retrieve_rf_profiles",
+ 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")
+ name = name or self.new_object.get("rf_profile_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 id_exists:
+ _name = prev_obj.get("name")
+ _name = _name or prev_obj.get("rfProfileName")
+ if _name:
+ self.new_object.update(dict(rf_profile_name=_name))
+ 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 = [
+ ("name", "name"),
+ ("defaultRfProfile", "defaultRfProfile"),
+ ("enableRadioTypeA", "enableRadioTypeA"),
+ ("enableRadioTypeB", "enableRadioTypeB"),
+ ("channelWidth", "channelWidth"),
+ ("enableCustom", "enableCustom"),
+ ("enableBrownField", "enableBrownField"),
+ ("radioTypeAProperties", "radioTypeAProperties"),
+ ("radioTypeBProperties", "radioTypeBProperties"),
+ ("radioTypeCProperties", "radioTypeCProperties"),
+ ("enableRadioTypeC", "enableRadioTypeC"),
+ ("rfProfileName", "rf_profile_name"),
+ ]
+ # 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)
+
+ def create(self):
+ result = self.dnac.exec(
+ family="wireless",
+ function="create_or_update_rf_profile",
+ params=self.create_params(),
+ op_modifies=True,
+ )
+ return result
+
+ def delete(self):
+ id = self.new_object.get("id")
+ name = self.new_object.get("name")
+ name = name or self.new_object.get("rf_profile_name")
+ result = None
+ if not name:
+ prev_obj_id = self.get_object_by_id(id)
+ name_ = None
+ if prev_obj_id:
+ name_ = prev_obj_id.get("name")
+ name_ = name_ or prev_obj_id.get("rfProfileName")
+ if name_:
+ self.new_object.update(dict(rf_profile_name=name_))
+ result = self.dnac.exec(
+ family="wireless",
+ function="delete_rf_profiles",
+ params=self.delete_by_name_params(),
+ )
+ return result
+
+
+class ActionModule(ActionBase):
+ def __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 = WirelessRfProfile(self._task.args, dnac)
+
+ state = self._task.args.get("state")
+
+ 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:
+ response = obj.create()
+ dnac.object_created()
+ elif state == "absent":
+ (obj_exists, prev_obj) = obj.exists()
+ if obj_exists:
+ response = obj.delete()
+ dnac.object_deleted()
+ else:
+ dnac.object_already_absent()
+
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/wireless_rf_profile_info.py b/ansible_collections/cisco/dnac/plugins/action/wireless_rf_profile_info.py
new file mode 100644
index 000000000..ec207fa45
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/wireless_rf_profile_info.py
@@ -0,0 +1,89 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ rf_profile_name=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ rf_profile_name=params.get("rf_profile_name"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="wireless",
+ function='retrieve_rf_profiles',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/dnac/plugins/action/wireless_sensor_test_results_info.py b/ansible_collections/cisco/dnac/plugins/action/wireless_sensor_test_results_info.py
new file mode 100644
index 000000000..5948fad3c
--- /dev/null
+++ b/ansible_collections/cisco/dnac/plugins/action/wireless_sensor_test_results_info.py
@@ -0,0 +1,95 @@
+#!/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,
+)
+
+# Get common arguments specification
+argument_spec = dnac_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ siteId=dict(type="str"),
+ startTime=dict(type="int"),
+ endTime=dict(type="int"),
+ testFailureBy=dict(type="str"),
+ headers=dict(type="dict"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __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 = True
+ 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 get_object(self, params):
+ new_object = dict(
+ site_id=params.get("siteId"),
+ start_time=params.get("startTime"),
+ end_time=params.get("endTime"),
+ test_failure_by=params.get("testFailureBy"),
+ headers=params.get("headers"),
+ )
+ return new_object
+
+ 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()
+
+ self._result.update(dict(dnac_response={}))
+
+ dnac = DNACSDK(params=self._task.args)
+
+ response = dnac.exec(
+ family="wireless",
+ function='sensor_test_results',
+ params=self.get_object(self._task.args),
+ )
+ self._result.update(dict(dnac_response=response))
+ self._result.update(dnac.exit_json())
+ return self._result