From 975f66f2eebe9dadba04f275774d4ab83f74cf25 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 14:04:41 +0200 Subject: Adding upstream version 7.7.0+dfsg. Signed-off-by: Daniel Baumann --- ansible_collections/cisco/dnac/plugins/README.md | 31 + ansible_collections/cisco/dnac/plugins/__init__.py | 0 ...spoint_configuration_details_by_task_id_info.py | 98 ++ .../dnac/plugins/action/app_policy_default_info.py | 87 + .../cisco/dnac/plugins/action/app_policy_info.py | 89 + .../plugins/action/app_policy_intent_create.py | 90 + .../plugins/action/app_policy_queuing_profile.py | 262 +++ .../app_policy_queuing_profile_count_info.py | 87 + .../action/app_policy_queuing_profile_info.py | 89 + .../cisco/dnac/plugins/action/application_sets.py | 226 +++ .../plugins/action/application_sets_count_info.py | 87 + .../dnac/plugins/action/application_sets_info.py | 93 ++ .../cisco/dnac/plugins/action/applications.py | 252 +++ .../dnac/plugins/action/applications_count_info.py | 87 + .../plugins/action/applications_health_info.py | 105 ++ .../cisco/dnac/plugins/action/applications_info.py | 93 ++ .../dnac/plugins/action/assign_device_to_site.py | 90 + .../action/associate_site_to_network_profile.py | 88 + .../action/authentication_import_certificate.py | 96 ++ .../authentication_import_certificate_p12.py | 93 ++ .../action/authentication_policy_servers_info.py | 93 ++ .../action/buildings_planned_access_points_info.py | 95 ++ .../business_sda_hostonboarding_ssid_ippool.py | 201 +++ ...business_sda_hostonboarding_ssid_ippool_info.py | 91 + .../business_sda_virtual_network_summary_info.py | 89 + .../business_sda_wireless_controller_create.py | 88 + .../business_sda_wireless_controller_delete.py | 85 + .../cisco/dnac/plugins/action/cli_credential.py | 239 +++ .../dnac/plugins/action/client_detail_info.py | 91 + .../action/client_enrichment_details_info.py | 87 + .../dnac/plugins/action/client_health_info.py | 89 + .../dnac/plugins/action/client_proximity_info.py | 93 ++ .../plugins/action/command_runner_run_command.py | 94 ++ .../dnac/plugins/action/compliance_check_run.py | 90 + .../plugins/action/compliance_device_by_id_info.py | 99 ++ .../action/compliance_device_details_count_info.py | 91 + .../action/compliance_device_details_info.py | 97 ++ .../dnac/plugins/action/compliance_device_info.py | 106 ++ .../action/compliance_device_status_count_info.py | 89 + .../dnac/plugins/action/configuration_template.py | 355 ++++ .../plugins/action/configuration_template_clone.py | 90 + .../action/configuration_template_create.py | 137 ++ .../action/configuration_template_deploy.py | 96 ++ .../configuration_template_deploy_status_info.py | 98 ++ .../action/configuration_template_deploy_v2.py | 96 ++ .../configuration_template_export_project.py | 86 + .../configuration_template_export_template.py | 86 + .../configuration_template_import_project.py | 86 + .../configuration_template_import_template.py | 90 + .../plugins/action/configuration_template_info.py | 124 ++ .../action/configuration_template_project.py | 284 ++++ .../action/configuration_template_project_info.py | 104 ++ .../configuration_template_version_create.py | 88 + .../action/configuration_template_version_info.py | 98 ++ .../credential_to_site_by_siteid_create_v2.py | 98 ++ .../plugins/action/device_configurations_export.py | 88 + .../plugins/action/device_credential_create.py | 86 + .../plugins/action/device_credential_delete.py | 85 + .../dnac/plugins/action/device_credential_info.py | 89 + .../plugins/action/device_credential_update.py | 86 + .../dnac/plugins/action/device_details_info.py | 93 ++ .../action/device_enrichment_details_info.py | 87 + .../device_family_identifiers_details_info.py | 87 + .../dnac/plugins/action/device_health_info.py | 101 ++ .../plugins/action/device_interface_by_ip_info.py | 98 ++ .../plugins/action/device_interface_count_info.py | 87 + .../dnac/plugins/action/device_interface_info.py | 108 ++ .../plugins/action/device_interface_isis_info.py | 87 + .../plugins/action/device_interface_ospf_info.py | 87 + .../plugins/action/device_reboot_apreboot_info.py | 89 + .../dnac/plugins/action/device_replacement.py | 237 +++ .../action/device_replacement_count_info.py | 89 + .../plugins/action/device_replacement_deploy.py | 88 + .../dnac/plugins/action/device_replacement_info.py | 109 ++ .../action/disassociate_site_to_network_profile.py | 87 + ...disasterrecovery_system_operationstatus_info.py | 90 + .../action/disasterrecovery_system_status_info.py | 90 + .../cisco/dnac/plugins/action/discovery.py | 443 +++++ .../dnac/plugins/action/discovery_count_info.py | 87 + .../plugins/action/discovery_device_count_info.py | 91 + .../dnac/plugins/action/discovery_device_info.py | 91 + .../plugins/action/discovery_device_range_info.py | 95 ++ .../cisco/dnac/plugins/action/discovery_info.py | 98 ++ .../dnac/plugins/action/discovery_job_info.py | 108 ++ .../dnac/plugins/action/discovery_range_delete.py | 87 + .../dnac/plugins/action/discovery_range_info.py | 91 + .../dnac/plugins/action/discovery_summary_info.py | 107 ++ .../action/dna_command_runner_keywords_info.py | 87 + .../dnac/plugins/action/dnac_packages_info.py | 87 + .../dnacaap_management_execution_status_info.py | 98 ++ .../action/endpoint_analytics_profiling_rules.py | 332 ++++ .../endpoint_analytics_profiling_rules_info.py | 115 ++ .../dnac/plugins/action/eox_status_device_info.py | 100 ++ .../dnac/plugins/action/eox_status_summary_info.py | 87 + .../dnac/plugins/action/event_api_status_info.py | 98 ++ .../plugins/action/event_artifact_count_info.py | 87 + .../dnac/plugins/action/event_artifact_info.py | 101 ++ .../action/event_config_connector_types_info.py | 87 + .../cisco/dnac/plugins/action/event_count_info.py | 91 + .../dnac/plugins/action/event_email_config.py | 221 +++ .../plugins/action/event_email_config_create.py | 96 ++ .../dnac/plugins/action/event_email_config_info.py | 87 + .../plugins/action/event_email_config_update.py | 96 ++ .../cisco/dnac/plugins/action/event_info.py | 99 ++ .../plugins/action/event_series_audit_logs_info.py | 131 ++ .../event_series_audit_logs_parent_records_info.py | 129 ++ .../action/event_series_audit_logs_summary_info.py | 125 ++ .../dnac/plugins/action/event_series_count_info.py | 105 ++ .../cisco/dnac/plugins/action/event_series_info.py | 119 ++ .../dnac/plugins/action/event_snmp_config_info.py | 97 ++ .../dnac/plugins/action/event_subscription.py | 260 +++ .../action/event_subscription_count_info.py | 89 + .../event_subscription_details_email_info.py | 99 ++ .../action/event_subscription_details_rest_info.py | 99 ++ .../event_subscription_details_syslog_info.py | 99 ++ .../plugins/action/event_subscription_email.py | 223 +++ .../action/event_subscription_email_info.py | 107 ++ .../dnac/plugins/action/event_subscription_info.py | 97 ++ .../dnac/plugins/action/event_subscription_rest.py | 223 +++ .../plugins/action/event_subscription_rest_info.py | 107 ++ .../plugins/action/event_subscription_syslog.py | 223 +++ .../action/event_subscription_syslog_info.py | 107 ++ .../dnac/plugins/action/event_syslog_config.py | 231 +++ .../plugins/action/event_syslog_config_info.py | 101 ++ .../dnac/plugins/action/event_webhook_create.py | 98 ++ .../dnac/plugins/action/event_webhook_update.py | 98 ++ .../action/execute_suggested_actions_commands.py | 88 + .../cisco/dnac/plugins/action/file_import.py | 88 + .../cisco/dnac/plugins/action/file_info.py | 110 ++ .../plugins/action/file_namespace_files_info.py | 98 ++ .../dnac/plugins/action/file_namespaces_info.py | 87 + .../plugins/action/global_credential_delete.py | 85 + .../dnac/plugins/action/global_credential_info.py | 106 ++ .../plugins/action/global_credential_update.py | 88 + .../dnac/plugins/action/global_credential_v2.py | 270 +++ .../plugins/action/global_credential_v2_info.py | 87 + .../cisco/dnac/plugins/action/global_pool.py | 277 ++++ .../cisco/dnac/plugins/action/global_pool_info.py | 91 + .../dnac/plugins/action/golden_image_create.py | 92 ++ .../dnac/plugins/action/golden_tag_image_delete.py | 91 + .../action/golden_tag_image_details_info.py | 104 ++ .../dnac/plugins/action/http_read_credential.py | 244 +++ .../dnac/plugins/action/http_write_credential.py | 244 +++ .../action/integration_settings_instances_itsm.py | 260 +++ .../integration_settings_instances_itsm_info.py | 98 ++ .../cisco/dnac/plugins/action/interface_info.py | 89 + .../action/interface_network_device_detail_info.py | 91 + .../action/interface_network_device_info.py | 98 ++ .../action/interface_network_device_range_info.py | 93 ++ .../plugins/action/interface_operation_create.py | 92 ++ .../cisco/dnac/plugins/action/interface_update.py | 96 ++ .../action/issues_enrichment_details_info.py | 87 + .../cisco/dnac/plugins/action/issues_info.py | 103 ++ .../plugins/action/itsm_cmdb_sync_status_info.py | 91 + .../action/itsm_integration_events_failed_info.py | 89 + .../action/itsm_integration_events_retry.py | 86 + .../plugins/action/lan_automation_count_info.py | 87 + .../dnac/plugins/action/lan_automation_create.py | 86 + .../dnac/plugins/action/lan_automation_delete.py | 85 + .../lan_automation_log_by_serial_number_info.py | 102 ++ .../dnac/plugins/action/lan_automation_log_info.py | 104 ++ .../plugins/action/lan_automation_status_info.py | 104 ++ .../plugins/action/license_device_count_info.py | 97 ++ .../action/license_device_deregistration.py | 86 + .../action/license_device_license_details_info.py | 89 + .../action/license_device_license_summary_info.py | 107 ++ .../plugins/action/license_device_registration.py | 88 + .../action/license_smart_account_details_info.py | 87 + .../plugins/action/license_term_details_info.py | 102 ++ .../plugins/action/license_usage_details_info.py | 102 ++ .../action/license_virtual_account_change.py | 90 + .../action/license_virtual_account_details_info.py | 89 + .../dnac/plugins/action/netconf_credential.py | 233 +++ .../cisco/dnac/plugins/action/network_create.py | 90 + .../cisco/dnac/plugins/action/network_device.py | 439 +++++ .../plugins/action/network_device_by_ip_info.py | 98 ++ .../action/network_device_by_serial_number_info.py | 98 ++ .../action/network_device_chassis_details_info.py | 89 + .../action/network_device_config_count_info.py | 87 + .../plugins/action/network_device_config_info.py | 100 ++ .../plugins/action/network_device_count_info.py | 100 ++ .../plugins/action/network_device_custom_prompt.py | 88 + .../action/network_device_custom_prompt_info.py | 87 + .../action/network_device_equipment_info.py | 91 + .../dnac/plugins/action/network_device_export.py | 94 ++ .../network_device_functional_capability_info.py | 104 ++ .../network_device_global_polling_interval_info.py | 87 + .../dnac/plugins/action/network_device_info.py | 166 ++ .../network_device_interface_neighbor_info.py | 91 + .../action/network_device_interface_poe_info.py | 91 + ..._device_inventory_insight_link_mismatch_info.py | 99 ++ ...network_device_lexicographically_sorted_info.py | 131 ++ .../action/network_device_linecard_details_info.py | 89 + .../network_device_meraki_organization_info.py | 89 + .../action/network_device_module_count_info.py | 97 ++ .../plugins/action/network_device_module_info.py | 114 ++ .../dnac/plugins/action/network_device_poe_info.py | 89 + .../action/network_device_polling_interval_info.py | 89 + .../plugins/action/network_device_range_info.py | 91 + .../action/network_device_register_for_wsa_info.py | 91 + .../action/network_device_stack_details_info.py | 89 + .../plugins/action/network_device_summary_info.py | 89 + .../network_device_supervisor_card_details_info.py | 89 + .../dnac/plugins/action/network_device_sync.py | 88 + .../plugins/action/network_device_update_role.py | 90 + .../action/network_device_user_defined_field.py | 259 +++ .../network_device_user_defined_field_info.py | 91 + .../plugins/action/network_device_vlan_info.py | 91 + .../action/network_device_wireless_lan_info.py | 89 + .../action/network_device_with_snmp_v3_des_info.py | 97 ++ .../cisco/dnac/plugins/action/network_info.py | 89 + .../cisco/dnac/plugins/action/network_update.py | 88 + .../cisco/dnac/plugins/action/network_v2.py | 214 +++ .../cisco/dnac/plugins/action/network_v2_info.py | 89 + .../cisco/dnac/plugins/action/nfv_profile.py | 248 +++ .../cisco/dnac/plugins/action/nfv_profile_info.py | 104 ++ .../cisco/dnac/plugins/action/nfv_provision.py | 90 + .../plugins/action/nfv_provision_detail_info.py | 89 + .../dnac/plugins/action/nfv_provision_details.py | 88 + .../cisco/dnac/plugins/action/path_trace.py | 286 ++++ .../cisco/dnac/plugins/action/path_trace_info.py | 130 ++ .../plugins/action/planned_access_points_info.py | 95 ++ .../platform_nodes_configuration_summary_info.py | 87 + .../action/platform_release_summary_info.py | 87 + .../cisco/dnac/plugins/action/pnp_device.py | 344 ++++ .../dnac/plugins/action/pnp_device_authorize.py | 86 + .../cisco/dnac/plugins/action/pnp_device_claim.py | 102 ++ .../plugins/action/pnp_device_claim_to_site.py | 108 ++ .../plugins/action/pnp_device_config_preview.py | 90 + .../dnac/plugins/action/pnp_device_count_info.py | 115 ++ .../dnac/plugins/action/pnp_device_history_info.py | 93 ++ .../cisco/dnac/plugins/action/pnp_device_import.py | 86 + .../cisco/dnac/plugins/action/pnp_device_info.py | 142 ++ .../cisco/dnac/plugins/action/pnp_device_reset.py | 90 + .../dnac/plugins/action/pnp_device_unclaim.py | 86 + .../dnac/plugins/action/pnp_global_settings.py | 182 ++ .../plugins/action/pnp_global_settings_info.py | 87 + .../plugins/action/pnp_server_profile_update.py | 110 ++ .../action/pnp_smart_account_domains_info.py | 87 + .../dnac/plugins/action/pnp_virtual_account_add.py | 110 ++ .../action/pnp_virtual_account_deregister.py | 87 + .../action/pnp_virtual_account_devices_sync.py | 110 ++ .../action/pnp_virtual_account_sync_result_info.py | 91 + .../plugins/action/pnp_virtual_accounts_info.py | 89 + .../cisco/dnac/plugins/action/pnp_workflow.py | 351 ++++ .../dnac/plugins/action/pnp_workflow_count_info.py | 89 + .../cisco/dnac/plugins/action/pnp_workflow_info.py | 112 ++ .../plugins/action/profiling_rules_count_info.py | 94 ++ .../action/profiling_rules_in_bulk_create.py | 89 + .../dnac/plugins/action/projects_details_info.py | 97 ++ .../dnac/plugins/action/qos_device_interface.py | 264 +++ .../plugins/action/qos_device_interface_info.py | 89 + .../action/qos_device_interface_info_count_info.py | 87 + .../cisco/dnac/plugins/action/reports.py | 259 +++ .../dnac/plugins/action/reports_executions_info.py | 114 ++ .../cisco/dnac/plugins/action/reports_info.py | 104 ++ .../dnac/plugins/action/reports_view_group_info.py | 100 ++ .../plugins/action/reports_view_group_view_info.py | 100 ++ .../dnac/plugins/action/reserve_ip_subpool.py | 358 ++++ .../plugins/action/reserve_ip_subpool_create.py | 126 ++ .../plugins/action/reserve_ip_subpool_delete.py | 85 + .../dnac/plugins/action/reserve_ip_subpool_info.py | 93 ++ .../plugins/action/reserve_ip_subpool_update.py | 116 ++ .../dnac/plugins/action/role_permissions_info.py | 87 + .../cisco/dnac/plugins/action/roles_info.py | 87 + .../cisco/dnac/plugins/action/sda_count_info.py | 90 + .../cisco/dnac/plugins/action/sda_device_info.py | 89 + .../dnac/plugins/action/sda_device_role_info.py | 89 + .../cisco/dnac/plugins/action/sda_fabric.py | 209 +++ .../action/sda_fabric_authentication_profile.py | 242 +++ .../sda_fabric_authentication_profile_info.py | 91 + .../plugins/action/sda_fabric_border_device.py | 225 +++ .../action/sda_fabric_border_device_info.py | 89 + .../action/sda_fabric_control_plane_device.py | 217 +++ .../action/sda_fabric_control_plane_device_info.py | 89 + .../dnac/plugins/action/sda_fabric_edge_device.py | 213 +++ .../plugins/action/sda_fabric_edge_device_info.py | 89 + .../cisco/dnac/plugins/action/sda_fabric_info.py | 92 ++ .../cisco/dnac/plugins/action/sda_fabric_site.py | 217 +++ .../dnac/plugins/action/sda_fabric_site_info.py | 89 + .../cisco/dnac/plugins/action/sda_multicast.py | 221 +++ .../dnac/plugins/action/sda_multicast_info.py | 89 + .../action/sda_port_assignment_for_access_point.py | 234 +++ .../sda_port_assignment_for_access_point_info.py | 91 + .../action/sda_port_assignment_for_user_device.py | 246 +++ .../sda_port_assignment_for_user_device_info.py | 91 + .../dnac/plugins/action/sda_provision_device.py | 233 +++ .../plugins/action/sda_provision_device_info.py | 89 + .../dnac/plugins/action/sda_virtual_network.py | 218 +++ .../plugins/action/sda_virtual_network_info.py | 91 + .../plugins/action/sda_virtual_network_ip_pool.py | 280 ++++ .../action/sda_virtual_network_ip_pool_info.py | 93 ++ .../dnac/plugins/action/sda_virtual_network_v2.py | 243 +++ .../plugins/action/sda_virtual_network_v2_info.py | 89 + .../action/security_advisories_devices_info.py | 89 + .../security_advisories_ids_per_device_info.py | 98 ++ .../plugins/action/security_advisories_info.py | 87 + .../action/security_advisories_per_device_info.py | 89 + .../action/security_advisories_summary_info.py | 87 + .../cisco/dnac/plugins/action/sensor.py | 225 +++ .../cisco/dnac/plugins/action/sensor_info.py | 89 + .../cisco/dnac/plugins/action/sensor_test_run.py | 86 + .../action/sensor_test_template_duplicate.py | 88 + .../plugins/action/sensor_test_template_edit.py | 90 + .../dnac/plugins/action/service_provider_create.py | 86 + .../dnac/plugins/action/service_provider_info.py | 87 + .../action/service_provider_profile_delete.py | 85 + .../dnac/plugins/action/service_provider_update.py | 86 + .../dnac/plugins/action/service_provider_v2.py | 197 +++ .../plugins/action/service_provider_v2_info.py | 87 + .../dnac/plugins/action/site_assign_credential.py | 100 ++ .../dnac/plugins/action/site_assign_device.py | 93 ++ .../cisco/dnac/plugins/action/site_count_info.py | 89 + .../cisco/dnac/plugins/action/site_create.py | 90 + .../cisco/dnac/plugins/action/site_delete.py | 85 + .../dnac/plugins/action/site_design_floormap.py | 248 +++ .../plugins/action/site_design_floormap_info.py | 103 ++ .../cisco/dnac/plugins/action/site_health_info.py | 95 ++ .../cisco/dnac/plugins/action/site_info.py | 97 ++ .../dnac/plugins/action/site_membership_info.py | 106 ++ .../cisco/dnac/plugins/action/site_update.py | 92 ++ .../cisco/dnac/plugins/action/snmp_properties.py | 202 +++ .../dnac/plugins/action/snmp_properties_info.py | 87 + .../action/snmpv2_read_community_credential.py | 225 +++ .../action/snmpv2_write_community_credential.py | 225 +++ .../cisco/dnac/plugins/action/snmpv3_credential.py | 252 +++ .../dnac/plugins/action/sp_profile_delete_v2.py | 85 + .../dnac/plugins/action/swim_image_details_info.py | 123 ++ .../cisco/dnac/plugins/action/swim_import_local.py | 95 ++ .../dnac/plugins/action/swim_import_via_url.py | 92 ++ .../dnac/plugins/action/swim_trigger_activation.py | 90 + .../plugins/action/swim_trigger_distribution.py | 86 + .../dnac/plugins/action/syslog_config_create.py | 96 ++ .../dnac/plugins/action/syslog_config_update.py | 96 ++ .../plugins/action/system_health_count_info.py | 91 + .../dnac/plugins/action/system_health_info.py | 97 ++ .../action/system_performance_historical_info.py | 93 ++ .../dnac/plugins/action/system_performance_info.py | 95 ++ .../cisco/dnac/plugins/action/tag.py | 283 ++++ .../cisco/dnac/plugins/action/tag_count_info.py | 99 ++ .../cisco/dnac/plugins/action/tag_info.py | 122 ++ .../cisco/dnac/plugins/action/tag_member.py | 225 +++ .../dnac/plugins/action/tag_member_count_info.py | 95 ++ .../cisco/dnac/plugins/action/tag_member_info.py | 99 ++ .../dnac/plugins/action/tag_member_type_info.py | 87 + .../cisco/dnac/plugins/action/tag_membership.py | 88 + .../cisco/dnac/plugins/action/task_count_info.py | 107 ++ .../cisco/dnac/plugins/action/task_info.py | 128 ++ .../dnac/plugins/action/task_operation_info.py | 102 ++ .../cisco/dnac/plugins/action/task_tree_info.py | 89 + .../cisco/dnac/plugins/action/template_preview.py | 92 ++ .../dnac/plugins/action/templates_details_info.py | 121 ++ .../cisco/dnac/plugins/action/threat_detail.py | 103 ++ .../dnac/plugins/action/threat_detail_count.py | 103 ++ .../cisco/dnac/plugins/action/threat_summary.py | 97 ++ .../dnac/plugins/action/topology_layer_2_info.py | 98 ++ .../dnac/plugins/action/topology_layer_3_info.py | 98 ++ .../plugins/action/topology_network_health_info.py | 89 + .../dnac/plugins/action/topology_physical_info.py | 89 + .../dnac/plugins/action/topology_site_info.py | 87 + .../plugins/action/topology_vlan_details_info.py | 87 + .../dnac/plugins/action/transit_peer_network.py | 210 +++ .../plugins/action/transit_peer_network_info.py | 89 + .../cisco/dnac/plugins/action/user.py | 225 +++ .../plugins/action/user_enrichment_details_info.py | 87 + .../cisco/dnac/plugins/action/user_info.py | 89 + .../plugins/action/users_external_servers_info.py | 89 + .../action/wireless_accespoint_configuration.py | 130 ++ ...eless_accesspoint_configuration_summary_info.py | 89 + .../plugins/action/wireless_dynamic_interface.py | 229 +++ .../action/wireless_dynamic_interface_info.py | 89 + .../plugins/action/wireless_enterprise_ssid.py | 347 ++++ .../action/wireless_enterprise_ssid_info.py | 89 + .../cisco/dnac/plugins/action/wireless_profile.py | 247 +++ .../dnac/plugins/action/wireless_profile_info.py | 89 + .../action/wireless_provision_access_point.py | 88 + .../action/wireless_provision_device_create.py | 86 + .../action/wireless_provision_device_update.py | 88 + .../wireless_provision_ssid_create_provision.py | 96 ++ .../wireless_provision_ssid_delete_reprovision.py | 87 + .../dnac/plugins/action/wireless_psk_override.py | 86 + .../dnac/plugins/action/wireless_rf_profile.py | 263 +++ .../plugins/action/wireless_rf_profile_info.py | 89 + .../action/wireless_sensor_test_results_info.py | 95 ++ .../cisco/dnac/plugins/doc_fragments/__init__.py | 0 .../dnac/plugins/doc_fragments/intent_params.py | 66 + .../cisco/dnac/plugins/doc_fragments/module.py | 61 + .../dnac/plugins/doc_fragments/module_info.py | 61 + .../cisco/dnac/plugins/module_utils/__init__.py | 0 .../cisco/dnac/plugins/module_utils/dnac.py | 318 ++++ .../cisco/dnac/plugins/module_utils/exceptions.py | 13 + .../cisco/dnac/plugins/modules/__init__.py | 0 ...spoint_configuration_details_by_task_id_info.py | 98 ++ .../plugins/modules/app_policy_default_info.py | 148 ++ .../cisco/dnac/plugins/modules/app_policy_info.py | 194 +++ .../plugins/modules/app_policy_intent_create.py | 331 ++++ .../plugins/modules/app_policy_queuing_profile.py | 200 +++ .../app_policy_queuing_profile_count_info.py | 63 + .../modules/app_policy_queuing_profile_info.py | 154 ++ .../cisco/dnac/plugins/modules/application_sets.py | 90 + .../plugins/modules/application_sets_count_info.py | 63 + .../dnac/plugins/modules/application_sets_info.py | 85 + .../cisco/dnac/plugins/modules/applications.py | 272 +++ .../plugins/modules/applications_count_info.py | 63 + .../plugins/modules/applications_health_info.py | 151 ++ .../dnac/plugins/modules/applications_info.py | 125 ++ .../dnac/plugins/modules/assign_device_to_site.py | 77 + .../modules/associate_site_to_network_profile.py | 69 + .../modules/authentication_import_certificate.py | 78 + .../authentication_import_certificate_p12.py | 78 + .../modules/authentication_policy_servers_info.py | 121 ++ .../buildings_planned_access_points_info.py | 129 ++ .../business_sda_hostonboarding_ssid_ippool.py | 106 ++ ...business_sda_hostonboarding_ssid_ippool_info.py | 78 + .../business_sda_virtual_network_summary_info.py | 75 + .../business_sda_wireless_controller_create.py | 68 + .../business_sda_wireless_controller_delete.py | 67 + .../cisco/dnac/plugins/modules/cli_credential.py | 124 ++ .../dnac/plugins/modules/client_detail_info.py | 196 +++ .../modules/client_enrichment_details_info.py | 230 +++ .../dnac/plugins/modules/client_health_info.py | 109 ++ .../dnac/plugins/modules/client_proximity_info.py | 87 + .../plugins/modules/command_runner_run_command.py | 85 + .../dnac/plugins/modules/compliance_check_run.py | 77 + .../modules/compliance_device_by_id_info.py | 143 ++ .../compliance_device_details_count_info.py | 77 + .../modules/compliance_device_details_info.py | 103 ++ .../dnac/plugins/modules/compliance_device_info.py | 111 ++ .../modules/compliance_device_status_count_info.py | 70 + .../dnac/plugins/modules/configuration_template.py | 730 ++++++++ .../modules/configuration_template_clone.py | 75 + .../modules/configuration_template_create.py | 708 ++++++++ .../modules/configuration_template_deploy.py | 130 ++ .../configuration_template_deploy_status_info.py | 90 + .../modules/configuration_template_deploy_v2.py | 111 ++ .../configuration_template_export_project.py | 67 + .../configuration_template_export_template.py | 67 + .../configuration_template_import_project.py | 68 + .../configuration_template_import_template.py | 726 ++++++++ .../plugins/modules/configuration_template_info.py | 351 ++++ .../modules/configuration_template_project.py | 958 +++++++++++ .../modules/configuration_template_project_info.py | 314 ++++ .../configuration_template_version_create.py | 69 + .../modules/configuration_template_version_info.py | 84 + .../credential_to_site_by_siteid_create_v2.py | 89 + .../modules/device_configurations_export.py | 71 + .../plugins/modules/device_credential_create.py | 192 +++ .../plugins/modules/device_credential_delete.py | 63 + .../dnac/plugins/modules/device_credential_info.py | 145 ++ .../plugins/modules/device_credential_update.py | 210 +++ .../dnac/plugins/modules/device_details_info.py | 120 ++ .../modules/device_enrichment_details_info.py | 143 ++ .../device_family_identifiers_details_info.py | 68 + .../dnac/plugins/modules/device_health_info.py | 149 ++ .../plugins/modules/device_interface_by_ip_info.py | 101 ++ .../plugins/modules/device_interface_count_info.py | 63 + .../dnac/plugins/modules/device_interface_info.py | 138 ++ .../plugins/modules/device_interface_isis_info.py | 96 ++ .../plugins/modules/device_interface_ospf_info.py | 96 ++ .../dnac/plugins/modules/device_reboot_apreboot.py | 68 + .../plugins/modules/device_reboot_apreboot_info.py | 77 + .../dnac/plugins/modules/device_replacement.py | 156 ++ .../modules/device_replacement_count_info.py | 71 + .../plugins/modules/device_replacement_deploy.py | 71 + .../plugins/modules/device_replacement_info.py | 142 ++ .../disassociate_site_to_network_profile.py | 69 + ...disasterrecovery_system_operationstatus_info.py | 90 + .../modules/disasterrecovery_system_status_info.py | 143 ++ .../cisco/dnac/plugins/modules/discovery.py | 405 +++++ .../dnac/plugins/modules/discovery_count_info.py | 63 + .../plugins/modules/discovery_device_count_info.py | 75 + .../dnac/plugins/modules/discovery_device_info.py | 124 ++ .../plugins/modules/discovery_device_range_info.py | 134 ++ .../cisco/dnac/plugins/modules/discovery_info.py | 129 ++ .../dnac/plugins/modules/discovery_job_info.py | 131 ++ .../dnac/plugins/modules/discovery_range_delete.py | 69 + .../dnac/plugins/modules/discovery_range_info.py | 136 ++ .../dnac/plugins/modules/discovery_summary_info.py | 121 ++ .../modules/dna_command_runner_keywords_info.py | 65 + .../dnac/plugins/modules/dnac_packages_info.py | 68 + .../dnacaap_management_execution_status_info.py | 77 + .../modules/endpoint_analytics_profiling_rules.py | 244 +++ .../endpoint_analytics_profiling_rules_info.py | 162 ++ .../dnac/plugins/modules/eox_status_device_info.py | 115 ++ .../plugins/modules/eox_status_summary_info.py | 68 + .../dnac/plugins/modules/event_api_status_info.py | 69 + .../plugins/modules/event_artifact_count_info.py | 62 + .../dnac/plugins/modules/event_artifact_info.py | 134 ++ .../modules/event_config_connector_types_info.py | 68 + .../cisco/dnac/plugins/modules/event_count_info.py | 72 + .../dnac/plugins/modules/event_email_config.py | 147 ++ .../plugins/modules/event_email_config_create.py | 115 ++ .../plugins/modules/event_email_config_info.py | 84 + .../plugins/modules/event_email_config_update.py | 115 ++ .../cisco/dnac/plugins/modules/event_info.py | 111 ++ .../modules/event_series_audit_logs_info.py | 219 +++ .../event_series_audit_logs_parent_records_info.py | 214 +++ .../event_series_audit_logs_summary_info.py | 172 ++ .../plugins/modules/event_series_count_info.py | 105 ++ .../dnac/plugins/modules/event_series_info.py | 163 ++ .../dnac/plugins/modules/event_snmp_config_info.py | 111 ++ .../dnac/plugins/modules/event_subscription.py | 220 +++ .../modules/event_subscription_count_info.py | 67 + .../event_subscription_details_email_info.py | 103 ++ .../event_subscription_details_rest_info.py | 117 ++ .../event_subscription_details_syslog_info.py | 108 ++ .../plugins/modules/event_subscription_email.py | 227 +++ .../modules/event_subscription_email_info.py | 170 ++ .../plugins/modules/event_subscription_info.py | 161 ++ .../plugins/modules/event_subscription_rest.py | 199 +++ .../modules/event_subscription_rest_info.py | 186 +++ .../plugins/modules/event_subscription_syslog.py | 199 +++ .../modules/event_subscription_syslog_info.py | 172 ++ .../dnac/plugins/modules/event_syslog_config.py | 111 ++ .../plugins/modules/event_syslog_config_info.py | 114 ++ .../dnac/plugins/modules/event_webhook_create.py | 109 ++ .../dnac/plugins/modules/event_webhook_update.py | 109 ++ .../modules/execute_suggested_actions_commands.py | 77 + .../cisco/dnac/plugins/modules/file_import.py | 63 + .../cisco/dnac/plugins/modules/file_info.py | 85 + .../plugins/modules/file_namespace_files_info.py | 85 + .../dnac/plugins/modules/file_namespaces_info.py | 65 + .../plugins/modules/global_credential_delete.py | 65 + .../dnac/plugins/modules/global_credential_info.py | 104 ++ .../plugins/modules/global_credential_update.py | 71 + .../dnac/plugins/modules/global_credential_v2.py | 279 ++++ .../plugins/modules/global_credential_v2_info.py | 145 ++ .../cisco/dnac/plugins/modules/global_pool.py | 144 ++ .../cisco/dnac/plugins/modules/global_pool_info.py | 107 ++ .../dnac/plugins/modules/golden_image_create.py | 78 + .../plugins/modules/golden_tag_image_delete.py | 80 + .../modules/golden_tag_image_details_info.py | 90 + .../dnac/plugins/modules/http_read_credential.py | 129 ++ .../dnac/plugins/modules/http_write_credential.py | 129 ++ .../modules/integration_settings_instances_itsm.py | 160 ++ .../integration_settings_instances_itsm_info.py | 84 + .../cisco/dnac/plugins/modules/interface_info.py | 124 ++ .../interface_network_device_detail_info.py | 104 ++ .../modules/interface_network_device_info.py | 101 ++ .../modules/interface_network_device_range_info.py | 111 ++ .../plugins/modules/interface_operation_create.py | 81 + .../cisco/dnac/plugins/modules/interface_update.py | 101 ++ .../modules/issues_enrichment_details_info.py | 89 + .../cisco/dnac/plugins/modules/issues_info.py | 125 ++ .../plugins/modules/itsm_cmdb_sync_status_info.py | 91 + .../modules/itsm_integration_events_failed_info.py | 86 + .../modules/itsm_integration_events_retry.py | 68 + .../plugins/modules/lan_automation_count_info.py | 62 + .../dnac/plugins/modules/lan_automation_create.py | 121 ++ .../dnac/plugins/modules/lan_automation_delete.py | 66 + .../lan_automation_log_by_serial_number_info.py | 95 ++ .../plugins/modules/lan_automation_log_info.py | 109 ++ .../plugins/modules/lan_automation_status_info.py | 128 ++ .../plugins/modules/license_device_count_info.py | 88 + .../modules/license_device_deregistration.py | 66 + .../modules/license_device_license_details_info.py | 123 ++ .../modules/license_device_license_summary_info.py | 149 ++ .../plugins/modules/license_device_registration.py | 70 + .../modules/license_smart_account_details_info.py | 70 + .../plugins/modules/license_term_details_info.py | 89 + .../plugins/modules/license_usage_details_info.py | 114 ++ .../modules/license_virtual_account_change.py | 74 + .../license_virtual_account_details_info.py | 74 + .../dnac/plugins/modules/netconf_credential.py | 115 ++ .../cisco/dnac/plugins/modules/network_create.py | 214 +++ .../cisco/dnac/plugins/modules/network_device.py | 259 +++ .../plugins/modules/network_device_by_ip_info.py | 108 ++ .../network_device_by_serial_number_info.py | 108 ++ .../modules/network_device_chassis_details_info.py | 85 + .../modules/network_device_config_count_info.py | 63 + .../plugins/modules/network_device_config_info.py | 87 + .../plugins/modules/network_device_count_info.py | 89 + .../modules/network_device_custom_prompt.py | 71 + .../modules/network_device_custom_prompt_info.py | 68 + .../modules/network_device_equipment_info.py | 85 + .../dnac/plugins/modules/network_device_export.py | 85 + .../network_device_functional_capability_info.py | 113 ++ .../network_device_global_polling_interval_info.py | 63 + .../dnac/plugins/modules/network_device_info.py | 325 ++++ .../network_device_interface_neighbor_info.py | 79 + .../modules/network_device_interface_poe_info.py | 85 + ..._device_inventory_insight_link_mismatch_info.py | 127 ++ ...network_device_lexicographically_sorted_info.py | 175 ++ .../network_device_linecard_details_info.py | 75 + .../network_device_meraki_organization_info.py | 70 + .../modules/network_device_module_count_info.py | 92 ++ .../plugins/modules/network_device_module_info.py | 143 ++ .../plugins/modules/network_device_poe_info.py | 72 + .../network_device_polling_interval_info.py | 68 + .../plugins/modules/network_device_range_info.py | 117 ++ .../network_device_register_for_wsa_info.py | 81 + .../modules/network_device_stack_details_info.py | 132 ++ .../plugins/modules/network_device_summary_info.py | 72 + .../network_device_supervisor_card_details_info.py | 75 + .../dnac/plugins/modules/network_device_sync.py | 74 + .../plugins/modules/network_device_update_role.py | 73 + .../modules/network_device_user_defined_field.py | 111 ++ .../network_device_user_defined_field_info.py | 81 + .../plugins/modules/network_device_vlan_info.py | 84 + .../modules/network_device_wireless_lan_info.py | 83 + .../network_device_with_snmp_v3_des_info.py | 101 ++ .../cisco/dnac/plugins/modules/network_info.py | 88 + .../cisco/dnac/plugins/modules/network_update.py | 210 +++ .../cisco/dnac/plugins/modules/network_v2.py | 266 +++ .../cisco/dnac/plugins/modules/network_v2_info.py | 81 + .../cisco/dnac/plugins/modules/nfv_profile.py | 288 ++++ .../cisco/dnac/plugins/modules/nfv_profile_info.py | 144 ++ .../cisco/dnac/plugins/modules/nfv_provision.py | 521 ++++++ .../plugins/modules/nfv_provision_detail_info.py | 91 + .../dnac/plugins/modules/nfv_provision_details.py | 67 + .../cisco/dnac/plugins/modules/path_trace.py | 121 ++ .../cisco/dnac/plugins/modules/path_trace_info.py | 1076 ++++++++++++ .../plugins/modules/planned_access_points_info.py | 129 ++ .../platform_nodes_configuration_summary_info.py | 118 ++ .../modules/platform_release_summary_info.py | 79 + .../cisco/dnac/plugins/modules/pnp_device.py | 1747 ++++++++++++++++++++ .../dnac/plugins/modules/pnp_device_authorize.py | 70 + .../cisco/dnac/plugins/modules/pnp_device_claim.py | 140 ++ .../plugins/modules/pnp_device_claim_to_site.py | 139 ++ .../plugins/modules/pnp_device_config_preview.py | 81 + .../dnac/plugins/modules/pnp_device_count_info.py | 145 ++ .../plugins/modules/pnp_device_history_info.py | 106 ++ .../dnac/plugins/modules/pnp_device_import.py | 1470 ++++++++++++++++ .../cisco/dnac/plugins/modules/pnp_device_info.py | 544 ++++++ .../cisco/dnac/plugins/modules/pnp_device_reset.py | 116 ++ .../dnac/plugins/modules/pnp_device_unclaim.py | 68 + .../dnac/plugins/modules/pnp_global_settings.py | 305 ++++ .../plugins/modules/pnp_global_settings_info.py | 122 ++ .../cisco/dnac/plugins/modules/pnp_intent.py | 955 +++++++++++ .../plugins/modules/pnp_server_profile_update.py | 196 +++ .../modules/pnp_smart_account_domains_info.py | 63 + .../plugins/modules/pnp_virtual_account_add.py | 197 +++ .../modules/pnp_virtual_account_deregister.py | 99 ++ .../modules/pnp_virtual_account_devices_sync.py | 196 +++ .../pnp_virtual_account_sync_result_info.py | 103 ++ .../plugins/modules/pnp_virtual_accounts_info.py | 68 + .../cisco/dnac/plugins/modules/pnp_workflow.py | 310 ++++ .../plugins/modules/pnp_workflow_count_info.py | 68 + .../dnac/plugins/modules/pnp_workflow_info.py | 160 ++ .../plugins/modules/profiling_rules_count_info.py | 70 + .../modules/profiling_rules_in_bulk_create.py | 189 +++ .../dnac/plugins/modules/projects_details_info.py | 99 ++ .../dnac/plugins/modules/qos_device_interface.py | 176 ++ .../plugins/modules/qos_device_interface_info.py | 121 ++ .../qos_device_interface_info_count_info.py | 63 + .../cisco/dnac/plugins/modules/reports.py | 244 +++ .../plugins/modules/reports_executions_info.py | 109 ++ .../cisco/dnac/plugins/modules/reports_info.py | 155 ++ .../plugins/modules/reports_view_group_info.py | 95 ++ .../modules/reports_view_group_view_info.py | 138 ++ .../dnac/plugins/modules/reserve_ip_subpool.py | 215 +++ .../plugins/modules/reserve_ip_subpool_create.py | 155 ++ .../plugins/modules/reserve_ip_subpool_delete.py | 63 + .../plugins/modules/reserve_ip_subpool_info.py | 123 ++ .../plugins/modules/reserve_ip_subpool_update.py | 137 ++ .../dnac/plugins/modules/role_permissions_info.py | 69 + .../cisco/dnac/plugins/modules/roles_info.py | 82 + .../cisco/dnac/plugins/modules/sda_count_info.py | 64 + .../cisco/dnac/plugins/modules/sda_device_info.py | 74 + .../dnac/plugins/modules/sda_device_role_info.py | 74 + .../cisco/dnac/plugins/modules/sda_fabric.py | 78 + .../modules/sda_fabric_authentication_profile.py | 123 ++ .../sda_fabric_authentication_profile_info.py | 83 + .../plugins/modules/sda_fabric_border_device.py | 213 +++ .../modules/sda_fabric_border_device_info.py | 239 +++ .../modules/sda_fabric_control_plane_device.py | 97 ++ .../sda_fabric_control_plane_device_info.py | 74 + .../dnac/plugins/modules/sda_fabric_edge_device.py | 91 + .../plugins/modules/sda_fabric_edge_device_info.py | 73 + .../cisco/dnac/plugins/modules/sda_fabric_info.py | 69 + .../cisco/dnac/plugins/modules/sda_fabric_site.py | 97 ++ .../dnac/plugins/modules/sda_fabric_site_info.py | 72 + .../cisco/dnac/plugins/modules/sda_multicast.py | 131 ++ .../dnac/plugins/modules/sda_multicast_info.py | 86 + .../sda_port_assignment_for_access_point.py | 111 ++ .../sda_port_assignment_for_access_point_info.py | 81 + .../modules/sda_port_assignment_for_user_device.py | 128 ++ .../sda_port_assignment_for_user_device_info.py | 80 + .../dnac/plugins/modules/sda_provision_device.py | 109 ++ .../plugins/modules/sda_provision_device_info.py | 70 + .../dnac/plugins/modules/sda_virtual_network.py | 90 + .../plugins/modules/sda_virtual_network_info.py | 78 + .../plugins/modules/sda_virtual_network_ip_pool.py | 164 ++ .../modules/sda_virtual_network_ip_pool_info.py | 87 + .../dnac/plugins/modules/sda_virtual_network_v2.py | 121 ++ .../plugins/modules/sda_virtual_network_v2_info.py | 74 + .../modules/security_advisories_devices_info.py | 70 + .../security_advisories_ids_per_device_info.py | 75 + .../plugins/modules/security_advisories_info.py | 77 + .../modules/security_advisories_per_device_info.py | 82 + .../modules/security_advisories_summary_info.py | 94 ++ .../cisco/dnac/plugins/modules/sensor.py | 262 +++ .../cisco/dnac/plugins/modules/sensor_info.py | 89 + .../cisco/dnac/plugins/modules/sensor_test_run.py | 59 + .../modules/sensor_test_template_duplicate.py | 191 +++ .../plugins/modules/sensor_test_template_edit.py | 268 +++ .../plugins/modules/service_provider_create.py | 82 + .../dnac/plugins/modules/service_provider_info.py | 82 + .../modules/service_provider_profile_delete.py | 63 + .../plugins/modules/service_provider_update.py | 86 + .../dnac/plugins/modules/service_provider_v2.py | 108 ++ .../plugins/modules/service_provider_v2_info.py | 82 + .../dnac/plugins/modules/site_assign_credential.py | 91 + .../dnac/plugins/modules/site_assign_device.py | 69 + .../cisco/dnac/plugins/modules/site_count_info.py | 68 + .../cisco/dnac/plugins/modules/site_create.py | 147 ++ .../cisco/dnac/plugins/modules/site_delete.py | 63 + .../dnac/plugins/modules/site_design_floormap.py | 88 + .../plugins/modules/site_design_floormap_info.py | 79 + .../cisco/dnac/plugins/modules/site_health_info.py | 144 ++ .../cisco/dnac/plugins/modules/site_info.py | 98 ++ .../cisco/dnac/plugins/modules/site_intent.py | 592 +++++++ .../dnac/plugins/modules/site_membership_info.py | 101 ++ .../cisco/dnac/plugins/modules/site_update.py | 153 ++ .../cisco/dnac/plugins/modules/snmp_properties.py | 88 + .../dnac/plugins/modules/snmp_properties_info.py | 71 + .../modules/snmpv2_read_community_credential.py | 103 ++ .../modules/snmpv2_write_community_credential.py | 103 ++ .../dnac/plugins/modules/snmpv3_credential.py | 139 ++ .../dnac/plugins/modules/sp_profile_delete_v2.py | 65 + .../plugins/modules/swim_image_details_info.py | 198 +++ .../dnac/plugins/modules/swim_import_local.py | 84 + .../dnac/plugins/modules/swim_import_via_url.py | 102 ++ .../cisco/dnac/plugins/modules/swim_intent.py | 754 +++++++++ .../plugins/modules/swim_trigger_activation.py | 104 ++ .../plugins/modules/swim_trigger_distribution.py | 77 + .../dnac/plugins/modules/syslog_config_create.py | 87 + .../dnac/plugins/modules/syslog_config_update.py | 87 + .../plugins/modules/system_health_count_info.py | 76 + .../dnac/plugins/modules/system_health_info.py | 108 ++ .../modules/system_performance_historical_info.py | 103 ++ .../plugins/modules/system_performance_info.py | 105 ++ .../cisco/dnac/plugins/modules/tag.py | 170 ++ .../cisco/dnac/plugins/modules/tag_count_info.py | 93 ++ .../cisco/dnac/plugins/modules/tag_info.py | 164 ++ .../cisco/dnac/plugins/modules/tag_member.py | 98 ++ .../dnac/plugins/modules/tag_member_count_info.py | 83 + .../cisco/dnac/plugins/modules/tag_member_info.py | 103 ++ .../dnac/plugins/modules/tag_member_type_info.py | 65 + .../cisco/dnac/plugins/modules/tag_membership.py | 80 + .../cisco/dnac/plugins/modules/task_count_info.py | 113 ++ .../cisco/dnac/plugins/modules/task_info.py | 176 ++ .../dnac/plugins/modules/task_operation_info.py | 101 ++ .../cisco/dnac/plugins/modules/task_tree_info.py | 89 + .../cisco/dnac/plugins/modules/template_intent.py | 1061 ++++++++++++ .../cisco/dnac/plugins/modules/template_preview.py | 76 + .../dnac/plugins/modules/templates_details_info.py | 362 ++++ .../cisco/dnac/plugins/modules/threat_detail.py | 104 ++ .../dnac/plugins/modules/threat_detail_count.py | 92 ++ .../cisco/dnac/plugins/modules/threat_summary.py | 91 + .../dnac/plugins/modules/topology_layer_2_info.py | 128 ++ .../dnac/plugins/modules/topology_layer_3_info.py | 128 ++ .../modules/topology_network_health_info.py | 107 ++ .../dnac/plugins/modules/topology_physical_info.py | 128 ++ .../dnac/plugins/modules/topology_site_info.py | 78 + .../plugins/modules/topology_vlan_details_info.py | 65 + .../dnac/plugins/modules/transit_peer_network.py | 121 ++ .../plugins/modules/transit_peer_network_info.py | 82 + .../cisco/dnac/plugins/modules/user.py | 112 ++ .../modules/user_enrichment_details_info.py | 174 ++ .../cisco/dnac/plugins/modules/user_info.py | 80 + .../plugins/modules/users_external_servers_info.py | 80 + .../modules/wireless_accespoint_configuration.py | 338 ++++ ...eless_accesspoint_configuration_summary_info.py | 152 ++ .../plugins/modules/wireless_dynamic_interface.py | 93 ++ .../modules/wireless_dynamic_interface_info.py | 73 + .../plugins/modules/wireless_enterprise_ssid.py | 197 +++ .../modules/wireless_enterprise_ssid_info.py | 107 ++ .../cisco/dnac/plugins/modules/wireless_profile.py | 172 ++ .../dnac/plugins/modules/wireless_profile_info.py | 87 + .../modules/wireless_provision_access_point.py | 98 ++ .../modules/wireless_provision_device_create.py | 116 ++ .../modules/wireless_provision_device_update.py | 116 ++ .../wireless_provision_ssid_create_provision.py | 139 ++ .../wireless_provision_ssid_delete_reprovision.py | 71 + .../dnac/plugins/modules/wireless_psk_override.py | 81 + .../dnac/plugins/modules/wireless_rf_profile.py | 225 +++ .../plugins/modules/wireless_rf_profile_info.py | 99 ++ .../modules/wireless_sensor_test_results_info.py | 148 ++ .../cisco/dnac/plugins/plugin_utils/__init__.py | 0 .../cisco/dnac/plugins/plugin_utils/dnac.py | 267 +++ .../cisco/dnac/plugins/plugin_utils/exceptions.py | 23 + 782 files changed, 102169 insertions(+) create mode 100644 ansible_collections/cisco/dnac/plugins/README.md create mode 100644 ansible_collections/cisco/dnac/plugins/__init__.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/accesspoint_configuration_details_by_task_id_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/app_policy_default_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/app_policy_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/app_policy_intent_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/app_policy_queuing_profile.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/app_policy_queuing_profile_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/app_policy_queuing_profile_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/application_sets.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/application_sets_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/application_sets_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/applications.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/applications_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/applications_health_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/applications_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/assign_device_to_site.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/associate_site_to_network_profile.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/authentication_import_certificate.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/authentication_import_certificate_p12.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/authentication_policy_servers_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/buildings_planned_access_points_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/business_sda_hostonboarding_ssid_ippool.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/business_sda_hostonboarding_ssid_ippool_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/business_sda_virtual_network_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/business_sda_wireless_controller_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/business_sda_wireless_controller_delete.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/cli_credential.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/client_detail_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/client_enrichment_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/client_health_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/client_proximity_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/command_runner_run_command.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/compliance_check_run.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/compliance_device_by_id_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/compliance_device_details_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/compliance_device_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/compliance_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/compliance_device_status_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/configuration_template.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/configuration_template_clone.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/configuration_template_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/configuration_template_deploy.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/configuration_template_deploy_status_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/configuration_template_deploy_v2.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/configuration_template_export_project.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/configuration_template_export_template.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/configuration_template_import_project.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/configuration_template_import_template.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/configuration_template_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/configuration_template_project.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/configuration_template_project_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/configuration_template_version_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/configuration_template_version_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/credential_to_site_by_siteid_create_v2.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_configurations_export.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_credential_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_credential_delete.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_credential_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_credential_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_enrichment_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_family_identifiers_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_health_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_interface_by_ip_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_interface_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_interface_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_interface_isis_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_interface_ospf_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_reboot_apreboot_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_replacement.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_replacement_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_replacement_deploy.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/device_replacement_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/disassociate_site_to_network_profile.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/disasterrecovery_system_operationstatus_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/disasterrecovery_system_status_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/discovery.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/discovery_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/discovery_device_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/discovery_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/discovery_device_range_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/discovery_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/discovery_job_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/discovery_range_delete.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/discovery_range_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/discovery_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/dna_command_runner_keywords_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/dnac_packages_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/dnacaap_management_execution_status_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/endpoint_analytics_profiling_rules.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/endpoint_analytics_profiling_rules_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/eox_status_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/eox_status_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_api_status_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_artifact_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_artifact_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_config_connector_types_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_email_config.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_email_config_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_email_config_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_email_config_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_series_audit_logs_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_series_audit_logs_parent_records_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_series_audit_logs_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_series_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_series_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_snmp_config_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_subscription.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_subscription_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_subscription_details_email_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_subscription_details_rest_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_subscription_details_syslog_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_subscription_email.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_subscription_email_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_subscription_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_subscription_rest.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_subscription_rest_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_subscription_syslog.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_subscription_syslog_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_syslog_config.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_syslog_config_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_webhook_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/event_webhook_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/execute_suggested_actions_commands.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/file_import.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/file_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/file_namespace_files_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/file_namespaces_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/global_credential_delete.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/global_credential_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/global_credential_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/global_credential_v2.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/global_credential_v2_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/global_pool.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/global_pool_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/golden_image_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/golden_tag_image_delete.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/golden_tag_image_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/http_read_credential.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/http_write_credential.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/integration_settings_instances_itsm.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/integration_settings_instances_itsm_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/interface_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/interface_network_device_detail_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/interface_network_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/interface_network_device_range_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/interface_operation_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/interface_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/issues_enrichment_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/issues_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/itsm_cmdb_sync_status_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/itsm_integration_events_failed_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/itsm_integration_events_retry.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/lan_automation_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/lan_automation_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/lan_automation_delete.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/lan_automation_log_by_serial_number_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/lan_automation_log_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/lan_automation_status_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/license_device_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/license_device_deregistration.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/license_device_license_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/license_device_license_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/license_device_registration.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/license_smart_account_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/license_term_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/license_usage_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/license_virtual_account_change.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/license_virtual_account_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/netconf_credential.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_by_ip_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_by_serial_number_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_chassis_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_config_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_config_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_custom_prompt.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_custom_prompt_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_equipment_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_export.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_functional_capability_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_global_polling_interval_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_interface_neighbor_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_interface_poe_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_inventory_insight_link_mismatch_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_lexicographically_sorted_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_linecard_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_meraki_organization_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_module_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_module_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_poe_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_polling_interval_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_range_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_register_for_wsa_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_stack_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_supervisor_card_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_sync.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_update_role.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_user_defined_field.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_user_defined_field_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_vlan_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_wireless_lan_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_device_with_snmp_v3_des_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_v2.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/network_v2_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/nfv_profile.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/nfv_profile_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/nfv_provision.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/nfv_provision_detail_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/nfv_provision_details.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/path_trace.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/path_trace_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/planned_access_points_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/platform_nodes_configuration_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/platform_release_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_device.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_device_authorize.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_device_claim.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_device_claim_to_site.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_device_config_preview.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_device_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_device_history_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_device_import.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_device_reset.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_device_unclaim.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_global_settings.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_global_settings_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_server_profile_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_smart_account_domains_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_add.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_deregister.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_devices_sync.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_virtual_account_sync_result_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_virtual_accounts_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_workflow.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_workflow_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/pnp_workflow_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/profiling_rules_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/profiling_rules_in_bulk_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/projects_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/qos_device_interface.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/qos_device_interface_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/qos_device_interface_info_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/reports.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/reports_executions_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/reports_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/reports_view_group_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/reports_view_group_view_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_delete.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/reserve_ip_subpool_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/role_permissions_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/roles_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_device_role_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_fabric.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_fabric_authentication_profile.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_fabric_authentication_profile_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_fabric_border_device.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_fabric_border_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_fabric_control_plane_device.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_fabric_control_plane_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_fabric_edge_device.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_fabric_edge_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_fabric_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_fabric_site.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_fabric_site_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_multicast.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_multicast_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_access_point.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_access_point_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_user_device.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_port_assignment_for_user_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_provision_device.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_provision_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_virtual_network.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_ip_pool.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_ip_pool_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_v2.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sda_virtual_network_v2_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/security_advisories_devices_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/security_advisories_ids_per_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/security_advisories_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/security_advisories_per_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/security_advisories_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sensor.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sensor_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sensor_test_run.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sensor_test_template_duplicate.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sensor_test_template_edit.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/service_provider_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/service_provider_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/service_provider_profile_delete.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/service_provider_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/service_provider_v2.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/service_provider_v2_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/site_assign_credential.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/site_assign_device.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/site_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/site_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/site_delete.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/site_design_floormap.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/site_design_floormap_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/site_health_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/site_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/site_membership_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/site_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/snmp_properties.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/snmp_properties_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/snmpv2_read_community_credential.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/snmpv2_write_community_credential.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/snmpv3_credential.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/sp_profile_delete_v2.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/swim_image_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/swim_import_local.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/swim_import_via_url.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/swim_trigger_activation.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/swim_trigger_distribution.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/syslog_config_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/syslog_config_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/system_health_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/system_health_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/system_performance_historical_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/system_performance_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/tag.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/tag_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/tag_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/tag_member.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/tag_member_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/tag_member_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/tag_member_type_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/tag_membership.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/task_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/task_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/task_operation_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/task_tree_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/template_preview.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/templates_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/threat_detail.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/threat_detail_count.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/threat_summary.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/topology_layer_2_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/topology_layer_3_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/topology_network_health_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/topology_physical_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/topology_site_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/topology_vlan_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/transit_peer_network.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/transit_peer_network_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/user.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/user_enrichment_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/user_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/users_external_servers_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/wireless_accespoint_configuration.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/wireless_accesspoint_configuration_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/wireless_dynamic_interface.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/wireless_dynamic_interface_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/wireless_enterprise_ssid.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/wireless_enterprise_ssid_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/wireless_profile.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/wireless_profile_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/wireless_provision_access_point.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/wireless_provision_device_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/wireless_provision_device_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/wireless_provision_ssid_create_provision.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/wireless_provision_ssid_delete_reprovision.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/wireless_psk_override.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/wireless_rf_profile.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/wireless_rf_profile_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/action/wireless_sensor_test_results_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/doc_fragments/__init__.py create mode 100644 ansible_collections/cisco/dnac/plugins/doc_fragments/intent_params.py create mode 100644 ansible_collections/cisco/dnac/plugins/doc_fragments/module.py create mode 100644 ansible_collections/cisco/dnac/plugins/doc_fragments/module_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/module_utils/__init__.py create mode 100644 ansible_collections/cisco/dnac/plugins/module_utils/dnac.py create mode 100644 ansible_collections/cisco/dnac/plugins/module_utils/exceptions.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/__init__.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/accesspoint_configuration_details_by_task_id_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/app_policy_default_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/app_policy_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/app_policy_intent_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/app_policy_queuing_profile.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/app_policy_queuing_profile_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/app_policy_queuing_profile_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/application_sets.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/application_sets_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/application_sets_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/applications.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/applications_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/applications_health_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/applications_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/assign_device_to_site.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/associate_site_to_network_profile.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/authentication_import_certificate.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/authentication_import_certificate_p12.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/authentication_policy_servers_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/buildings_planned_access_points_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/business_sda_hostonboarding_ssid_ippool.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/business_sda_hostonboarding_ssid_ippool_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/business_sda_virtual_network_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/business_sda_wireless_controller_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/business_sda_wireless_controller_delete.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/cli_credential.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/client_detail_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/client_enrichment_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/client_health_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/client_proximity_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/command_runner_run_command.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/compliance_check_run.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/compliance_device_by_id_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/compliance_device_details_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/compliance_device_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/compliance_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/compliance_device_status_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/configuration_template.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/configuration_template_clone.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/configuration_template_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/configuration_template_deploy.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/configuration_template_deploy_status_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/configuration_template_deploy_v2.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/configuration_template_export_project.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/configuration_template_export_template.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/configuration_template_import_project.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/configuration_template_import_template.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/configuration_template_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/configuration_template_project.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/configuration_template_project_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/configuration_template_version_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/configuration_template_version_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/credential_to_site_by_siteid_create_v2.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_configurations_export.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_credential_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_credential_delete.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_credential_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_credential_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_enrichment_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_family_identifiers_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_health_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_interface_by_ip_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_interface_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_interface_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_interface_isis_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_interface_ospf_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_reboot_apreboot.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_reboot_apreboot_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_replacement.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_replacement_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_replacement_deploy.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/device_replacement_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/disassociate_site_to_network_profile.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/disasterrecovery_system_operationstatus_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/disasterrecovery_system_status_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/discovery.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/discovery_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/discovery_device_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/discovery_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/discovery_device_range_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/discovery_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/discovery_job_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/discovery_range_delete.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/discovery_range_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/discovery_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/dna_command_runner_keywords_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/dnac_packages_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/dnacaap_management_execution_status_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/endpoint_analytics_profiling_rules.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/endpoint_analytics_profiling_rules_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/eox_status_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/eox_status_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_api_status_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_artifact_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_artifact_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_config_connector_types_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_email_config.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_email_config_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_email_config_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_email_config_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_series_audit_logs_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_series_audit_logs_parent_records_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_series_audit_logs_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_series_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_series_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_snmp_config_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_subscription.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_subscription_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_subscription_details_email_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_subscription_details_rest_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_subscription_details_syslog_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_subscription_email.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_subscription_email_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_subscription_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_subscription_rest.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_subscription_rest_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_subscription_syslog.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_subscription_syslog_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_syslog_config.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_syslog_config_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_webhook_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/event_webhook_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/execute_suggested_actions_commands.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/file_import.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/file_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/file_namespace_files_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/file_namespaces_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/global_credential_delete.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/global_credential_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/global_credential_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/global_credential_v2.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/global_credential_v2_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/global_pool.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/global_pool_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/golden_image_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/golden_tag_image_delete.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/golden_tag_image_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/http_read_credential.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/http_write_credential.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/integration_settings_instances_itsm.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/integration_settings_instances_itsm_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/interface_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/interface_network_device_detail_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/interface_network_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/interface_network_device_range_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/interface_operation_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/interface_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/issues_enrichment_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/issues_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/itsm_cmdb_sync_status_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/itsm_integration_events_failed_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/itsm_integration_events_retry.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/lan_automation_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/lan_automation_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/lan_automation_delete.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/lan_automation_log_by_serial_number_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/lan_automation_log_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/lan_automation_status_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/license_device_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/license_device_deregistration.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/license_device_license_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/license_device_license_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/license_device_registration.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/license_smart_account_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/license_term_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/license_usage_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/license_virtual_account_change.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/license_virtual_account_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/netconf_credential.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_by_ip_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_by_serial_number_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_chassis_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_config_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_config_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_custom_prompt.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_custom_prompt_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_equipment_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_export.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_functional_capability_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_global_polling_interval_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_interface_neighbor_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_interface_poe_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_inventory_insight_link_mismatch_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_lexicographically_sorted_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_linecard_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_meraki_organization_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_module_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_module_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_poe_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_polling_interval_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_range_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_register_for_wsa_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_stack_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_supervisor_card_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_sync.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_update_role.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_user_defined_field.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_user_defined_field_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_vlan_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_wireless_lan_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_device_with_snmp_v3_des_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_v2.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/network_v2_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/nfv_profile.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/nfv_profile_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/nfv_provision.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/nfv_provision_detail_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/nfv_provision_details.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/path_trace.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/path_trace_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/planned_access_points_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/platform_nodes_configuration_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/platform_release_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_device.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_device_authorize.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_device_claim.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_device_claim_to_site.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_device_config_preview.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_device_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_device_history_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_device_import.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_device_reset.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_device_unclaim.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_global_settings.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_global_settings_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_intent.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_server_profile_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_smart_account_domains_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_account_add.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_account_deregister.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_account_devices_sync.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_account_sync_result_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_accounts_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_workflow.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_workflow_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/pnp_workflow_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/profiling_rules_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/profiling_rules_in_bulk_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/projects_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/qos_device_interface.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/qos_device_interface_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/qos_device_interface_info_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/reports.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/reports_executions_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/reports_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/reports_view_group_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/reports_view_group_view_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool_delete.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/role_permissions_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/roles_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_device_role_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_fabric.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_fabric_authentication_profile.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_fabric_authentication_profile_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_fabric_border_device.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_fabric_border_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_fabric_control_plane_device.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_fabric_control_plane_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_fabric_edge_device.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_fabric_edge_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_fabric_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_fabric_site.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_fabric_site_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_multicast.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_multicast_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_port_assignment_for_access_point.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_port_assignment_for_access_point_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_port_assignment_for_user_device.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_port_assignment_for_user_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_provision_device.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_provision_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_ip_pool.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_ip_pool_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_v2.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_v2_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/security_advisories_devices_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/security_advisories_ids_per_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/security_advisories_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/security_advisories_per_device_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/security_advisories_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sensor.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sensor_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sensor_test_run.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sensor_test_template_duplicate.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sensor_test_template_edit.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/service_provider_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/service_provider_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/service_provider_profile_delete.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/service_provider_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/service_provider_v2.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/service_provider_v2_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/site_assign_credential.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/site_assign_device.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/site_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/site_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/site_delete.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/site_design_floormap.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/site_design_floormap_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/site_health_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/site_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/site_intent.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/site_membership_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/site_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/snmp_properties.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/snmp_properties_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/snmpv2_read_community_credential.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/snmpv2_write_community_credential.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/snmpv3_credential.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/sp_profile_delete_v2.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/swim_image_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/swim_import_local.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/swim_import_via_url.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/swim_intent.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/swim_trigger_activation.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/swim_trigger_distribution.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/syslog_config_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/syslog_config_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/system_health_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/system_health_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/system_performance_historical_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/system_performance_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/tag.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/tag_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/tag_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/tag_member.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/tag_member_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/tag_member_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/tag_member_type_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/tag_membership.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/task_count_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/task_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/task_operation_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/task_tree_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/template_intent.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/template_preview.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/templates_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/threat_detail.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/threat_detail_count.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/threat_summary.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/topology_layer_2_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/topology_layer_3_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/topology_network_health_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/topology_physical_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/topology_site_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/topology_vlan_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/transit_peer_network.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/transit_peer_network_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/user.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/user_enrichment_details_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/user_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/users_external_servers_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/wireless_accespoint_configuration.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/wireless_accesspoint_configuration_summary_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/wireless_dynamic_interface.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/wireless_dynamic_interface_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/wireless_enterprise_ssid.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/wireless_enterprise_ssid_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/wireless_profile.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/wireless_profile_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/wireless_provision_access_point.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/wireless_provision_device_create.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/wireless_provision_device_update.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/wireless_provision_ssid_create_provision.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/wireless_provision_ssid_delete_reprovision.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/wireless_psk_override.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/wireless_rf_profile.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/wireless_rf_profile_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/modules/wireless_sensor_test_results_info.py create mode 100644 ansible_collections/cisco/dnac/plugins/plugin_utils/__init__.py create mode 100644 ansible_collections/cisco/dnac/plugins/plugin_utils/dnac.py create mode 100644 ansible_collections/cisco/dnac/plugins/plugin_utils/exceptions.py (limited to 'ansible_collections/cisco/dnac/plugins') diff --git a/ansible_collections/cisco/dnac/plugins/README.md b/ansible_collections/cisco/dnac/plugins/README.md new file mode 100644 index 000000000..448a4ba60 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/README.md @@ -0,0 +1,31 @@ +# Collections Plugins Directory + +This directory can be used to ship various plugins inside an Ansible collection. Each plugin is placed in a folder that +is named after the type of plugin it is in. It can also include the `module_utils` and `modules` directory that +would contain module utils and modules respectively. + +Here is an example directory of the majority of plugins currently supported by Ansible: + +``` +└── plugins + ├── action + ├── become + ├── cache + ├── callback + ├── cliconf + ├── connection + ├── filter + ├── httpapi + ├── inventory + ├── lookup + ├── module_utils + ├── modules + ├── netconf + ├── shell + ├── strategy + ├── terminal + ├── test + └── vars +``` + +A full list of plugin types can be found at [Working With Plugins](https://docs.ansible.com/ansible/2.10/plugins/plugins.html). diff --git a/ansible_collections/cisco/dnac/plugins/__init__.py b/ansible_collections/cisco/dnac/plugins/__init__.py new file mode 100644 index 000000000..e69de29bb 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 diff --git a/ansible_collections/cisco/dnac/plugins/doc_fragments/__init__.py b/ansible_collections/cisco/dnac/plugins/doc_fragments/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/ansible_collections/cisco/dnac/plugins/doc_fragments/intent_params.py b/ansible_collections/cisco/dnac/plugins/doc_fragments/intent_params.py new file mode 100644 index 000000000..fe95d684d --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/doc_fragments/intent_params.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +class ModuleDocFragment(object): + + # Standard files documentation fragment + DOCUMENTATION = r''' +options: + dnac_host: + description: + - The Cisco DNA Center hostname. + type: str + required: true + dnac_port: + description: + - The Cisco DNA Center port. + type: str + default: '443' + dnac_username: + description: + - The Cisco DNA Center username to authenticate. + type: str + default: admin + aliases: [ user ] + dnac_password: + description: + - The Cisco DNA Center password to authenticate. + type: str + dnac_verify: + description: + - Flag to enable or disable SSL certificate verification. + type: bool + default: true + dnac_version: + description: + - Informs the SDK which version of Cisco DNA Center to use. + type: str + default: 2.2.3.3 + dnac_debug: + description: + - Flag for Cisco DNA Center SDK to enable debugging. + type: bool + default: false + dnac_log: + description: + - Flag for logging playbook execution details. + If set to true the log file will be created at the location of the execution with the name dnac.log + type: bool + default: false + validate_response_schema: + description: + - Flag for Cisco DNA Center SDK to enable the validation of request bodies against a JSON schema. + type: bool + default: true +notes: + - "Does not support C(check_mode)" + - "The plugin runs on the control node and does not use any ansible connection plugins, but instead the embedded connection manager from Cisco DNAC SDK" + - "The parameters starting with dnac_ are used by the Cisco DNAC Python SDK to establish the connection" +''' diff --git a/ansible_collections/cisco/dnac/plugins/doc_fragments/module.py b/ansible_collections/cisco/dnac/plugins/doc_fragments/module.py new file mode 100644 index 000000000..6c92fb75f --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/doc_fragments/module.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +class ModuleDocFragment(object): + + # Standard files documentation fragment + DOCUMENTATION = r''' +options: + dnac_host: + description: + - The Cisco DNA Center hostname. + type: str + required: true + dnac_port: + description: + - The Cisco DNA Center port. + type: int + default: 443 + dnac_username: + description: + - The Cisco DNA Center username to authenticate. + type: str + default: admin + aliases: [ user ] + dnac_password: + description: + - The Cisco DNA Center password to authenticate. + type: str + dnac_verify: + description: + - Flag to enable or disable SSL certificate verification. + type: bool + default: true + dnac_version: + description: + - Informs the SDK which version of Cisco DNA Center to use. + type: str + default: 2.3.5.3 + dnac_debug: + description: + - Flag for Cisco DNA Center SDK to enable debugging. + type: bool + default: false + validate_response_schema: + description: + - Flag for Cisco DNA Center SDK to enable the validation of request bodies against a JSON schema. + type: bool + default: true +notes: + - "Does not support C(check_mode)" + - "The plugin runs on the control node and does not use any ansible connection plugins, but instead the embedded connection manager from Cisco DNAC SDK" + - "The parameters starting with dnac_ are used by the Cisco DNAC Python SDK to establish the connection" +''' diff --git a/ansible_collections/cisco/dnac/plugins/doc_fragments/module_info.py b/ansible_collections/cisco/dnac/plugins/doc_fragments/module_info.py new file mode 100644 index 000000000..7ac68f449 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/doc_fragments/module_info.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +class ModuleDocFragment(object): + + # Standard files documentation fragment + DOCUMENTATION = r''' +options: + dnac_host: + description: + - The Cisco DNA Center hostname. + type: str + required: true + dnac_port: + description: + - The Cisco DNA Center port. + type: int + default: 443 + dnac_username: + description: + - The Cisco DNA Center username to authenticate. + type: str + default: admin + aliases: [ user ] + dnac_password: + description: + - The Cisco DNA Center password to authenticate. + type: str + dnac_verify: + description: + - Flag to enable or disable SSL certificate verification. + type: bool + default: true + dnac_version: + description: + - Informs the SDK which version of Cisco DNA Center to use. + type: str + default: 2.3.5.3 + dnac_debug: + description: + - Flag for Cisco DNA Center SDK to enable debugging. + type: bool + default: false + validate_response_schema: + description: + - Flag for Cisco DNA Center SDK to enable the validation of request bodies against a JSON schema. + type: bool + default: true +notes: + - "Supports C(check_mode)" + - "The plugin runs on the control node and does not use any ansible connection plugins, but instead the embedded connection manager from Cisco DNAC SDK" + - "The parameters starting with dnac_ are used by the Cisco DNAC Python SDK to establish the connection" +''' diff --git a/ansible_collections/cisco/dnac/plugins/module_utils/__init__.py b/ansible_collections/cisco/dnac/plugins/module_utils/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/ansible_collections/cisco/dnac/plugins/module_utils/dnac.py b/ansible_collections/cisco/dnac/plugins/module_utils/dnac.py new file mode 100644 index 000000000..e9d61527d --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/module_utils/dnac.py @@ -0,0 +1,318 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type +try: + from dnacentersdk import api, exceptions +except ImportError: + DNAC_SDK_IS_INSTALLED = False +else: + DNAC_SDK_IS_INSTALLED = True +from ansible.module_utils._text import to_native +from ansible.module_utils.common import validation +try: + import logging +except ImportError: + LOGGING_IN_STANDARD = False +else: + LOGGING_IN_STANDARD = True +import os.path +import datetime +import inspect + + +def log(msg): + with open('dnac.log', 'a') as of: + callerframerecord = inspect.stack()[1] + frame = callerframerecord[0] + info = inspect.getframeinfo(frame) + d = datetime.datetime.now().replace(microsecond=0).isoformat() + of.write("---- %s ---- %s@%s ---- %s \n" % (d, info.lineno, info.function, msg)) + + +def is_list_complex(x): + return isinstance(x[0], dict) or isinstance(x[0], list) + + +def has_diff_elem(ls1, ls2): + return any((elem not in ls1 for elem in ls2)) + + +def compare_list(list1, list2): + len_list1 = len(list1) + len_list2 = len(list2) + if len_list1 != len_list2: + return False + + if len_list1 == 0: + return True + + attempt_std_cmp = list1 == list2 + if attempt_std_cmp: + return True + + if not is_list_complex(list1) and not is_list_complex(list2): + return set(list1) == set(list2) + + # Compare normally if it exceeds expected size * 2 (len_list1==len_list2) + MAX_SIZE_CMP = 100 + # Fail fast if elem not in list, thanks to any and generators + if len_list1 > MAX_SIZE_CMP: + return attempt_std_cmp + else: + # not changes 'has diff elem' to list1 != list2 ':lists are not equal' + return not (has_diff_elem(list1, list2)) or not (has_diff_elem(list2, list1)) + + +def fn_comp_key(k, dict1, dict2): + return dnac_compare_equality(dict1.get(k), dict2.get(k)) + + +def dnac_compare_equality(current_value, requested_value): + # print("dnac_compare_equality", current_value, requested_value) + if requested_value is None: + return True + if current_value is None: + return True + if isinstance(current_value, dict) and isinstance(requested_value, dict): + all_dict_params = list(current_value.keys()) + list(requested_value.keys()) + return not any((not fn_comp_key(param, current_value, requested_value) for param in all_dict_params)) + elif isinstance(current_value, list) and isinstance(requested_value, list): + return compare_list(current_value, requested_value) + else: + return current_value == requested_value + + +def simple_cmp(obj1, obj2): + return obj1 == obj2 + + +def get_dict_result(result, key, value, cmp_fn=simple_cmp): + if isinstance(result, list): + if len(result) == 1: + if isinstance(result[0], dict): + result = result[0] + if result.get(key) is not None and result.get(key) != value: + result = None + else: + result = None + else: + for item in result: + if isinstance(item, dict) and (item.get(key) is None or item.get(key) == value): + result = item + return result + result = None + elif not isinstance(result, dict): + result = None + elif result.get(key) is not None and result.get(key) != value: + result = None + return result + + +def dnac_argument_spec(): + argument_spec = dict( + dnac_host=dict(type="str", required=True), + dnac_port=dict(type="int", required=False, default=443), + dnac_username=dict(type="str", default="admin", aliases=["user"]), + dnac_password=dict(type="str", no_log=True), + dnac_verify=dict(type="bool", default=True), + dnac_version=dict(type="str", default="2.2.3.3"), + dnac_debug=dict(type="bool", default=False), + validate_response_schema=dict(type="bool", default=True), + ) + return argument_spec + + +def validate_list_of_dicts(param_list, spec, module=None): + """Validate/Normalize playbook params. Will raise when invalid parameters found. + param_list: a playbook parameter list of dicts + spec: an argument spec dict + e.g. spec = dict(ip=dict(required=True, type='bool'), + foo=dict(type='str', default='bar')) + return: list of normalized input data + """ + v = validation + normalized = [] + invalid_params = [] + for list_entry in param_list: + valid_params_dict = {} + for param in spec: + item = list_entry.get(param) + log(str(item)) + if item is None: + if spec[param].get("required"): + invalid_params.append( + "{0} : Required parameter not found".format(param) + ) + else: + item = spec[param].get("default") + else: + type = spec[param].get("type") + if type == "str": + item = v.check_type_str(item) + if spec[param].get("length_max"): + if 1 <= len(item) <= spec[param].get("length_max"): + pass + else: + invalid_params.append( + "{0}:{1} : The string exceeds the allowed " + "range of max {2} char".format( + param, item, spec[param].get("length_max") + ) + ) + elif type == "int": + item = v.check_type_int(item) + min_value = 1 + if spec[param].get("range_min") is not None: + min_value = spec[param].get("range_min") + if spec[param].get("range_max"): + if min_value <= item <= spec[param].get("range_max"): + pass + else: + invalid_params.append( + "{0}:{1} : The item exceeds the allowed " + "range of max {2}".format( + param, item, spec[param].get("range_max") + ) + ) + elif type == "bool": + item = v.check_type_bool(item) + elif type == "list": + item = v.check_type_list(item) + elif type == "dict": + item = v.check_type_dict(item) + + choice = spec[param].get("choices") + if choice: + if item not in choice: + invalid_params.append( + "{0} : Invalid choice provided".format(item) + ) + + no_log = spec[param].get("no_log") + if no_log: + if module is not None: + module.no_log_values.add(item) + else: + msg = "\n\n'{0}' is a no_log parameter".format(param) + msg += "\nAnsible module object must be passed to this " + msg += "\nfunction to ensure it is not logged\n\n" + raise Exception(msg) + + valid_params_dict[param] = item + normalized.append(valid_params_dict) + + return normalized, invalid_params + + +class DNACSDK(object): + def __init__(self, params): + self.result = dict(changed=False, result="") + self.validate_response_schema = params.get("validate_response_schema") + if DNAC_SDK_IS_INSTALLED: + self.api = api.DNACenterAPI( + username=params.get("dnac_username"), + password=params.get("dnac_password"), + base_url="https://{dnac_host}:{dnac_port}".format( + dnac_host=params.get("dnac_host"), dnac_port=params.get("dnac_port") + ), + version=params.get("dnac_version"), + verify=params.get("dnac_verify"), + debug=params.get("dnac_debug"), + ) + if params.get("dnac_debug") and LOGGING_IN_STANDARD: + logging.getLogger('dnacentersdk').addHandler(logging.StreamHandler()) + else: + self.fail_json(msg="DNA Center Python SDK is not installed. Execute 'pip install dnacentersdk'") + + def changed(self): + self.result["changed"] = True + + def object_created(self): + self.changed() + self.result["result"] = "Object created" + + def object_updated(self): + self.changed() + self.result["result"] = "Object updated" + + def object_deleted(self): + self.changed() + self.result["result"] = "Object deleted" + + def object_already_absent(self): + self.result["result"] = "Object already absent" + + def object_already_present(self): + self.result["result"] = "Object already present" + + def object_present_and_different(self): + self.result["result"] = "Object already present, but it has different values to the requested" + + def object_modify_result(self, changed=None, result=None): + if result is not None: + self.result["result"] = result + if changed: + self.changed() + + def is_file(self, file_path): + return os.path.isfile(file_path) + + def extract_file_name(self, file_path): + return os.path.basename(file_path) + + def _exec(self, family, function, params=None, op_modifies=False, **kwargs): + try: + family = getattr(self.api, family) + func = getattr(family, function) + except Exception as e: + self.fail_json(msg=e) + + try: + if params: + file_paths_params = kwargs.get('file_paths', []) + # This substitution is for the import file operation + if file_paths_params and isinstance(file_paths_params, list): + multipart_fields = {} + for (key, value) in file_paths_params: + if isinstance(params.get(key), str) and self.is_file(params[key]): + file_name = self.extract_file_name(params[key]) + file_path = params[key] + multipart_fields[value] = (file_name, open(file_path, 'rb')) + + params.setdefault("multipart_fields", multipart_fields) + params.setdefault("multipart_monitor_callback", None) + + if not self.validate_response_schema and op_modifies: + params["active_validation"] = False + + response = func(**params) + else: + response = func() + except exceptions.dnacentersdkException as e: + self.fail_json( + msg=( + "An error occured when executing operation." + " The error was: {error}" + ).format(error=to_native(e)) + ) + return response + + def fail_json(self, msg, **kwargs): + self.result.update(**kwargs) + raise Exception(msg) + + def exit_json(self): + return self.result + + +def main(): + pass + + +if __name__ == "__main__": + main() diff --git a/ansible_collections/cisco/dnac/plugins/module_utils/exceptions.py b/ansible_collections/cisco/dnac/plugins/module_utils/exceptions.py new file mode 100644 index 000000000..007f8e1f4 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/module_utils/exceptions.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +class AnsibleDNACException(Exception): + """Base class for all Ansible DNAC package exceptions.""" + pass + + +class InconsistentParameters(AnsibleDNACException): + """Provided parameters are not consistent.""" + pass diff --git a/ansible_collections/cisco/dnac/plugins/modules/__init__.py b/ansible_collections/cisco/dnac/plugins/modules/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/ansible_collections/cisco/dnac/plugins/modules/accesspoint_configuration_details_by_task_id_info.py b/ansible_collections/cisco/dnac/plugins/modules/accesspoint_configuration_details_by_task_id_info.py new file mode 100644 index 000000000..63bf5df7e --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/accesspoint_configuration_details_by_task_id_info.py @@ -0,0 +1,98 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: accesspoint_configuration_details_by_task_id_info +short_description: Information module for Accesspoint Configuration Details By Task Id +description: +- Get Accesspoint Configuration Details By Task Id by id. +- Users can query the access point configuration result using this intent API. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + task_id: + description: + - Task_id path parameter. Task id information of ap config. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless GetAccessPointConfigurationTaskResult + description: Complete reference of the GetAccessPointConfigurationTaskResult API. + link: https://developer.cisco.com/docs/dna-center/#!get-access-point-configuration-task-result +notes: + - SDK Method used are + wireless.Wireless.get_access_point_configuration_task_result, + + - Paths used are + get /dna/intent/api/v1/wireless/accesspoint-configuration/details/{task_id}, + +""" + +EXAMPLES = r""" +- name: Get Accesspoint Configuration Details By Task Id by id + cisco.dnac.accesspoint_configuration_details_by_task_id_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + task_id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "instanceUuid": {}, + "instanceId": 0, + "authEntityId": {}, + "displayName": "string", + "authEntityClass": {}, + "instanceTenantId": "string", + "_orderedListOEIndex": 0, + "_orderedListOEAssocName": {}, + "_creationOrderIndex": 0, + "_isBeingChanged": true, + "deployPending": "string", + "instanceCreatedOn": {}, + "instanceUpdatedOn": {}, + "changeLogList": {}, + "instanceOrigin": {}, + "lazyLoadedEntities": {}, + "instanceVersion": 0, + "apName": "string", + "controllerName": "string", + "locationHeirarchy": "string", + "macAddress": "string", + "status": "string", + "statusDetails": "string", + "internalKey": { + "type": "string", + "id": 0, + "longType": "string", + "url": "string" + } + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/app_policy_default_info.py b/ansible_collections/cisco/dnac/plugins/modules/app_policy_default_info.py new file mode 100644 index 000000000..3ad0878fb --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/app_policy_default_info.py @@ -0,0 +1,148 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: app_policy_default_info +short_description: Information module for App Policy Default +description: +- Get all App Policy Default. +- Get default application policy. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Application Policy GetApplicationPolicyDefault + description: Complete reference of the GetApplicationPolicyDefault API. + link: https://developer.cisco.com/docs/dna-center/#!get-application-policy-default +notes: + - SDK Method used are + application_policy.ApplicationPolicy.get_application_policy_default, + + - Paths used are + get /dna/intent/api/v1/app-policy-default, + +""" + +EXAMPLES = r""" +- name: Get all App Policy Default + cisco.dnac.app_policy_default_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "createTime": 0, + "deployed": true, + "isSeeded": true, + "isStale": true, + "lastUpdateTime": 0, + "name": "string", + "namespace": "string", + "provisioningState": "string", + "qualifier": "string", + "resourceVersion": 0, + "targetIdList": [ + {} + ], + "type": "string", + "cfsChangeInfo": [ + {} + ], + "customProvisions": [ + {} + ], + "deletePolicyStatus": "string", + "internal": true, + "isDeleted": true, + "isEnabled": true, + "isScopeStale": true, + "iseReserved": true, + "policyStatus": "string", + "priority": 0, + "pushed": true, + "contractList": [ + {} + ], + "exclusiveContract": { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "clause": [ + { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "priority": 0, + "type": "string", + "relevanceLevel": "string" + } + ] + }, + "identitySource": { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "state": "string", + "type": "string" + }, + "producer": { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "scalableGroup": [ + { + "idRef": "string" + } + ] + } + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/app_policy_info.py b/ansible_collections/cisco/dnac/plugins/modules/app_policy_info.py new file mode 100644 index 000000000..d70d8fd44 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/app_policy_info.py @@ -0,0 +1,194 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: app_policy_info +short_description: Information module for App Policy +description: +- Get all App Policy. +- Get all existing application policies. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + policyScope: + description: + - PolicyScope query parameter. Policy scope name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Application Policy GetApplicationPolicy + description: Complete reference of the GetApplicationPolicy API. + link: https://developer.cisco.com/docs/dna-center/#!get-application-policy +notes: + - SDK Method used are + application_policy.ApplicationPolicy.get_application_policy, + + - Paths used are + get /dna/intent/api/v1/app-policy, + +""" + +EXAMPLES = r""" +- name: Get all App Policy + cisco.dnac.app_policy_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + policyScope: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "createTime": 0, + "deployed": true, + "isSeeded": true, + "isStale": true, + "lastUpdateTime": 0, + "name": "string", + "namespace": "string", + "provisioningState": "string", + "qualifier": "string", + "resourceVersion": 0, + "targetIdList": [ + {} + ], + "type": "string", + "cfsChangeInfo": [ + {} + ], + "customProvisions": [ + {} + ], + "deletePolicyStatus": "string", + "internal": true, + "isDeleted": true, + "isEnabled": true, + "isScopeStale": true, + "iseReserved": true, + "policyScope": "string", + "policyStatus": "string", + "priority": 0, + "pushed": true, + "advancedPolicyScope": { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "name": "string", + "advancedPolicyScopeElement": [ + { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "groupId": [ + "string" + ], + "ssid": [ + {} + ] + } + ] + }, + "contractList": [ + {} + ], + "exclusiveContract": { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "clause": [ + { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "priority": 0, + "type": "string", + "relevanceLevel": "string", + "deviceRemovalBehavior": "string", + "hostTrackingEnabled": true + } + ] + }, + "identitySource": { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "state": "string", + "type": "string" + }, + "producer": { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "scalableGroup": [ + { + "idRef": "string" + } + ] + }, + "consumer": { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "scalableGroup": [ + { + "idRef": "string" + } + ] + } + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/app_policy_intent_create.py b/ansible_collections/cisco/dnac/plugins/modules/app_policy_intent_create.py new file mode 100644 index 000000000..6c1b46832 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/app_policy_intent_create.py @@ -0,0 +1,331 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: app_policy_intent_create +short_description: Resource module for App Policy Intent Create +description: +- Manage operation create of the resource App Policy Intent Create. +- Create/Update/Delete application policy. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + createList: + description: App Policy Intent Create's createList. + elements: dict + suboptions: + advancedPolicyScope: + description: App Policy Intent Create's advancedPolicyScope. + suboptions: + advancedPolicyScopeElement: + description: App Policy Intent Create's advancedPolicyScopeElement. + elements: dict + suboptions: + groupId: + description: Group id. + elements: str + type: list + ssid: + description: Ssid. + elements: str + type: list + type: list + name: + description: Policy name. + type: str + type: dict + consumer: + description: App Policy Intent Create's consumer. + suboptions: + scalableGroup: + description: App Policy Intent Create's scalableGroup. + elements: dict + suboptions: + idRef: + description: Id ref to application Scalable group. + type: str + type: list + type: dict + contract: + description: App Policy Intent Create's contract. + suboptions: + idRef: + description: Id ref to Queueing profile. + type: str + type: dict + deletePolicyStatus: + description: NONE deployed policy to devices, DELETED delete policy from devices, + RESTORED restored to original configuration. + type: str + exclusiveContract: + description: App Policy Intent Create's exclusiveContract. + suboptions: + clause: + description: App Policy Intent Create's clause. + elements: dict + suboptions: + deviceRemovalBehavior: + description: Device eemoval behavior. + type: str + hostTrackingEnabled: + description: Is host tracking enabled. + type: bool + relevanceLevel: + description: Relevance level. + type: str + type: + description: Type. + type: str + type: list + type: dict + name: + description: Concatination of _ or _global_policy_configuration or _queuing_customization. + type: str + policyScope: + description: Policy name. + type: str + priority: + description: Set to 4095 while producer refer to application Scalable group + otherwise 100. + type: str + producer: + description: App Policy Intent Create's producer. + suboptions: + scalableGroup: + description: App Policy Intent Create's scalableGroup. + elements: dict + suboptions: + idRef: + description: Id ref to application-set or application Scalable group. + type: str + type: list + type: dict + type: list + deleteList: + description: Delete list of Group Based Policy ids. + elements: str + type: list + updateList: + description: App Policy Intent Create's updateList. + elements: dict + suboptions: + advancedPolicyScope: + description: App Policy Intent Create's advancedPolicyScope. + suboptions: + advancedPolicyScopeElement: + description: App Policy Intent Create's advancedPolicyScopeElement. + elements: dict + suboptions: + groupId: + description: Group id. + elements: str + type: list + id: + description: Id of Advance policy scope element. + type: str + ssid: + description: Ssid. + elements: str + type: list + type: list + id: + description: Id of Advance policy scope. + type: str + name: + description: Policy name. + type: str + type: dict + consumer: + description: App Policy Intent Create's consumer. + suboptions: + id: + description: Id of Consumer. + type: str + scalableGroup: + description: App Policy Intent Create's scalableGroup. + elements: dict + suboptions: + idRef: + description: Id ref to application Scalable group. + type: str + type: list + type: dict + contract: + description: App Policy Intent Create's contract. + suboptions: + idRef: + description: Id ref to Queueing profile. + type: str + type: dict + deletePolicyStatus: + description: NONE deployed policy to devices, DELETED delete policy from devices, + RESTORED restored to original configuration. + type: str + exclusiveContract: + description: App Policy Intent Create's exclusiveContract. + suboptions: + clause: + description: App Policy Intent Create's clause. + elements: dict + suboptions: + deviceRemovalBehavior: + description: Device removal behavior. + type: str + hostTrackingEnabled: + description: Host tracking enabled. + type: bool + id: + description: Id of Business relevance or Application policy knobs clause. + type: str + relevanceLevel: + description: Relevance level. + type: str + type: + description: Type. + type: str + type: list + id: + description: Id of Exclusive contract. + type: str + type: dict + id: + description: Id of Group based policy. + type: str + name: + description: Concatination of _ or _global_policy_configuration or _queuing_customization. + type: str + policyScope: + description: Policy name. + type: str + priority: + description: Set to 4095 while producer refer to application Scalable group + otherwise 100. + type: str + producer: + description: App Policy Intent Create's producer. + suboptions: + id: + description: Id of Producer. + type: str + scalableGroup: + description: App Policy Intent Create's scalableGroup. + elements: dict + suboptions: + idRef: + description: Id ref to application-set or application Scalable group. + type: str + type: list + type: dict + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Application Policy ApplicationPolicyIntent + description: Complete reference of the ApplicationPolicyIntent API. + link: https://developer.cisco.com/docs/dna-center/#!application-policy-intent +notes: + - SDK Method used are + application_policy.ApplicationPolicy.application_policy_intent, + + - Paths used are + post /dna/intent/api/v1/app-policy-intent, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.app_policy_intent_create: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + createList: + - advancedPolicyScope: + advancedPolicyScopeElement: + - groupId: + - string + ssid: + - string + name: string + consumer: + scalableGroup: + - idRef: string + contract: + idRef: string + deletePolicyStatus: string + exclusiveContract: + clause: + - deviceRemovalBehavior: string + hostTrackingEnabled: true + relevanceLevel: string + type: string + name: string + policyScope: string + priority: string + producer: + scalableGroup: + - idRef: string + deleteList: + - string + updateList: + - advancedPolicyScope: + advancedPolicyScopeElement: + - groupId: + - string + id: string + ssid: + - string + id: string + name: string + consumer: + id: string + scalableGroup: + - idRef: string + contract: + idRef: string + deletePolicyStatus: string + exclusiveContract: + clause: + - deviceRemovalBehavior: string + hostTrackingEnabled: true + id: string + relevanceLevel: string + type: string + id: string + id: string + name: string + policyScope: string + priority: string + producer: + id: string + scalableGroup: + - idRef: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/app_policy_queuing_profile.py b/ansible_collections/cisco/dnac/plugins/modules/app_policy_queuing_profile.py new file mode 100644 index 000000000..769e87fc1 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/app_policy_queuing_profile.py @@ -0,0 +1,200 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: app_policy_queuing_profile +short_description: Resource module for App Policy Queuing Profile +description: +- Manage operations create, update and delete of the resource App Policy Queuing Profile. +- Create new custom application queuing profile. +- Delete existing custom application policy queuing profile by id. +- Update existing custom application queuing profile. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + id: + description: Id path parameter. Id of custom queuing profile to delete. + type: str + payload: + description: App Policy Queuing Profile's payload. + elements: dict + suboptions: + clause: + description: App Policy Queuing Profile's clause. + elements: dict + suboptions: + instanceId: + description: Instance id. + type: int + interfaceSpeedBandwidthClauses: + description: App Policy Queuing Profile's interfaceSpeedBandwidthClauses. + elements: dict + suboptions: + instanceId: + description: Instance id. + type: int + interfaceSpeed: + description: Interface speed. + type: str + tcBandwidthSettings: + description: App Policy Queuing Profile's tcBandwidthSettings. + elements: dict + suboptions: + bandwidthPercentage: + description: Bandwidth percentage. + type: int + instanceId: + description: Instance id. + type: int + trafficClass: + description: Traffic Class. + type: str + type: list + type: list + isCommonBetweenAllInterfaceSpeeds: + description: Is common between all interface speeds. + type: bool + tcDscpSettings: + description: App Policy Queuing Profile's tcDscpSettings. + elements: dict + suboptions: + dscp: + description: Dscp value. + type: str + instanceId: + description: Instance id. + type: int + trafficClass: + description: Traffic Class. + type: str + type: list + type: + description: Type. + type: str + type: list + description: + description: Free test description. + type: str + id: + description: Id of Queueing profile. + type: str + name: + description: Queueing profile name. + type: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Application Policy CreateApplicationPolicyQueuingProfile + description: Complete reference of the CreateApplicationPolicyQueuingProfile API. + link: https://developer.cisco.com/docs/dna-center/#!create-application-policy-queuing-profile +- name: Cisco DNA Center documentation for Application Policy DeleteApplicationPolicyQueuingProfile + description: Complete reference of the DeleteApplicationPolicyQueuingProfile API. + link: https://developer.cisco.com/docs/dna-center/#!delete-application-policy-queuing-profile +- name: Cisco DNA Center documentation for Application Policy UpdateApplicationPolicyQueuingProfile + description: Complete reference of the UpdateApplicationPolicyQueuingProfile API. + link: https://developer.cisco.com/docs/dna-center/#!update-application-policy-queuing-profile +notes: + - SDK Method used are + application_policy.ApplicationPolicy.create_application_policy_queuing_profile, + application_policy.ApplicationPolicy.delete_application_policy_queuing_profile, + application_policy.ApplicationPolicy.update_application_policy_queuing_profile, + + - Paths used are + post /dna/intent/api/v1/app-policy-queuing-profile, + delete /dna/intent/api/v1/app-policy-queuing-profile/{id}, + put /dna/intent/api/v1/app-policy-queuing-profile, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.app_policy_queuing_profile: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - clause: + - instanceId: 0 + interfaceSpeedBandwidthClauses: + - instanceId: 0 + interfaceSpeed: string + tcBandwidthSettings: + - bandwidthPercentage: 0 + instanceId: 0 + trafficClass: string + isCommonBetweenAllInterfaceSpeeds: true + tcDscpSettings: + - dscp: string + instanceId: 0 + trafficClass: string + type: string + description: string + id: string + name: string + +- name: Create + cisco.dnac.app_policy_queuing_profile: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - clause: + - interfaceSpeedBandwidthClauses: + - interfaceSpeed: string + tcBandwidthSettings: + - bandwidthPercentage: 0 + trafficClass: string + isCommonBetweenAllInterfaceSpeeds: true + tcDscpSettings: + - dscp: string + trafficClass: string + type: string + description: string + name: string + +- name: Delete by id + cisco.dnac.app_policy_queuing_profile: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + id: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/app_policy_queuing_profile_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/app_policy_queuing_profile_count_info.py new file mode 100644 index 000000000..5f814ac1d --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/app_policy_queuing_profile_count_info.py @@ -0,0 +1,63 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: app_policy_queuing_profile_count_info +short_description: Information module for App Policy Queuing Profile Count +description: +- Get all App Policy Queuing Profile Count. +- Get the number of all existing application policy queuing profile. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Application Policy GetApplicationPolicyQueuingProfileCount + description: Complete reference of the GetApplicationPolicyQueuingProfileCount API. + link: https://developer.cisco.com/docs/dna-center/#!get-application-policy-queuing-profile-count +notes: + - SDK Method used are + application_policy.ApplicationPolicy.get_application_policy_queuing_profile_count, + + - Paths used are + get /dna/intent/api/v1/app-policy-queuing-profile-count, + +""" + +EXAMPLES = r""" +- name: Get all App Policy Queuing Profile Count + cisco.dnac.app_policy_queuing_profile_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/app_policy_queuing_profile_info.py b/ansible_collections/cisco/dnac/plugins/modules/app_policy_queuing_profile_info.py new file mode 100644 index 000000000..860545f2c --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/app_policy_queuing_profile_info.py @@ -0,0 +1,154 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: app_policy_queuing_profile_info +short_description: Information module for App Policy Queuing Profile +description: +- Get all App Policy Queuing Profile. +- Get all or by name, existing application policy queuing profiles. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + name: + description: + - Name query parameter. Queuing profile name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Application Policy GetApplicationPolicyQueuingProfile + description: Complete reference of the GetApplicationPolicyQueuingProfile API. + link: https://developer.cisco.com/docs/dna-center/#!get-application-policy-queuing-profile +notes: + - SDK Method used are + application_policy.ApplicationPolicy.get_application_policy_queuing_profile, + + - Paths used are + get /dna/intent/api/v1/app-policy-queuing-profile, + +""" + +EXAMPLES = r""" +- name: Get all App Policy Queuing Profile + cisco.dnac.app_policy_queuing_profile_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + name: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "createTime": 0, + "deployed": true, + "description": "string", + "isSeeded": true, + "isStale": true, + "lastUpdateTime": 0, + "name": "string", + "namespace": "string", + "provisioningState": "string", + "qualifier": "string", + "resourceVersion": 0, + "targetIdList": [ + {} + ], + "type": "string", + "cfsChangeInfo": [ + {} + ], + "customProvisions": [ + {} + ], + "genId": 0, + "internal": true, + "isDeleted": true, + "iseReserved": true, + "pushed": true, + "clause": [ + { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "priority": 0, + "type": "string", + "isCommonBetweenAllInterfaceSpeeds": true, + "interfaceSpeedBandwidthClauses": [ + { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "interfaceSpeed": "string", + "tcBandwidthSettings": [ + { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "bandwidthPercentage": 0, + "trafficClass": "string" + } + ] + } + ], + "tcDscpSettings": [ + { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "dscp": "string", + "trafficClass": "string" + } + ] + } + ], + "contractClassifier": [ + {} + ] + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/application_sets.py b/ansible_collections/cisco/dnac/plugins/modules/application_sets.py new file mode 100644 index 000000000..1210f90d6 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/application_sets.py @@ -0,0 +1,90 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: application_sets +short_description: Resource module for Application Sets +description: +- Manage operations create and delete of the resource Application Sets. +- Create new custom application-set/s. +- Delete existing application-set by it's id. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + id: + description: Id query parameter. + type: str + payload: + description: Application Sets's payload. + elements: dict + suboptions: + name: + description: Name. + type: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Application Policy CreateApplicationSet + description: Complete reference of the CreateApplicationSet API. + link: https://developer.cisco.com/docs/dna-center/#!create-application-set +- name: Cisco DNA Center documentation for Application Policy DeleteApplicationSet + description: Complete reference of the DeleteApplicationSet API. + link: https://developer.cisco.com/docs/dna-center/#!delete-application-set +notes: + - SDK Method used are + application_policy.ApplicationPolicy.create_application_set, + application_policy.ApplicationPolicy.delete_application_set, + + - Paths used are + post /dna/intent/api/v1/application-policy-application-set, + delete /dna/intent/api/v1/application-policy-application-set, + +""" + +EXAMPLES = r""" +- name: Delete all + cisco.dnac.application_sets: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + id: string + +- name: Create + cisco.dnac.application_sets: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - name: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "taskId": "string", + "url": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/application_sets_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/application_sets_count_info.py new file mode 100644 index 000000000..b71923719 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/application_sets_count_info.py @@ -0,0 +1,63 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: application_sets_count_info +short_description: Information module for Application Sets Count +description: +- Get all Application Sets Count. +- Get the number of existing application-sets. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Application Policy GetApplicationSetsCount + description: Complete reference of the GetApplicationSetsCount API. + link: https://developer.cisco.com/docs/dna-center/#!get-application-sets-count +notes: + - SDK Method used are + application_policy.ApplicationPolicy.get_application_sets_count, + + - Paths used are + get /dna/intent/api/v1/application-policy-application-set-count, + +""" + +EXAMPLES = r""" +- name: Get all Application Sets Count + cisco.dnac.application_sets_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": "string", + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/application_sets_info.py b/ansible_collections/cisco/dnac/plugins/modules/application_sets_info.py new file mode 100644 index 000000000..844341de0 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/application_sets_info.py @@ -0,0 +1,85 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: application_sets_info +short_description: Information module for Application Sets +description: +- Get all Application Sets. +- Get appllication-sets by offset/limit or by name. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + offset: + description: + - Offset query parameter. + type: int + limit: + description: + - Limit query parameter. + type: int + name: + description: + - Name query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Application Policy GetApplicationSets + description: Complete reference of the GetApplicationSets API. + link: https://developer.cisco.com/docs/dna-center/#!get-application-sets +notes: + - SDK Method used are + application_policy.ApplicationPolicy.get_application_sets, + + - Paths used are + get /dna/intent/api/v1/application-policy-application-set, + +""" + +EXAMPLES = r""" +- name: Get all Application Sets + cisco.dnac.application_sets_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + offset: 0 + limit: 0 + name: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "id": "string", + "identitySource": { + "id": "string", + "type": "string" + }, + "name": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/applications.py b/ansible_collections/cisco/dnac/plugins/modules/applications.py new file mode 100644 index 000000000..22c309bd4 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/applications.py @@ -0,0 +1,272 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: applications +short_description: Resource module for Applications +description: +- Manage operations create, update and delete of the resource Applications. +- Create new Custom application. +- Delete existing application by its id. +- Edit the attributes of an existing application. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + id: + description: Id query parameter. Application's Id. + type: str + payload: + description: Applications's payload. + elements: dict + suboptions: + applicationSet: + description: Applications's applicationSet. + suboptions: + idRef: + description: Id Ref. + type: str + type: dict + indicativeNetworkIdentity: + description: Applications's indicativeNetworkIdentity. + elements: dict + suboptions: + displayName: + description: DisplayName. + type: str + id: + description: Id. + type: str + lowerPort: + description: LowerPort. + type: int + ports: + description: Ports. + type: str + protocol: + description: Protocol. + type: str + upperPort: + description: UpperPort. + type: int + type: list + name: + description: Name. + type: str + networkApplications: + description: Applications's networkApplications. + elements: dict + suboptions: + appProtocol: + description: App Protocol. + type: str + applicationSubType: + description: Application Sub Type. + type: str + applicationType: + description: Application Type. + type: str + categoryId: + description: Category Id. + type: str + displayName: + description: Display Name. + type: str + dscp: + description: Dscp. + type: str + engineId: + description: Engine Id. + type: str + helpString: + description: Help String. + type: str + ignoreConflict: + description: Ignore Conflict. + type: str + longDescription: + description: Long Description. + type: str + name: + description: Name. + type: str + popularity: + description: Popularity. + type: str + rank: + description: Rank. + type: str + serverName: + description: Server Name. + type: str + trafficClass: + description: Traffic Class. + type: str + url: + description: Url. + type: str + type: list + networkIdentity: + description: Applications's networkIdentity. + elements: dict + suboptions: + displayName: + description: Display Name. + type: str + lowerPort: + description: Lower Port. + type: str + ports: + description: Ports. + type: str + protocol: + description: Protocol. + type: str + upperPort: + description: Upper Port. + type: str + type: list + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Application Policy CreateApplication + description: Complete reference of the CreateApplication API. + link: https://developer.cisco.com/docs/dna-center/#!create-application +- name: Cisco DNA Center documentation for Application Policy DeleteApplication + description: Complete reference of the DeleteApplication API. + link: https://developer.cisco.com/docs/dna-center/#!delete-application +- name: Cisco DNA Center documentation for Application Policy EditApplication + description: Complete reference of the EditApplication API. + link: https://developer.cisco.com/docs/dna-center/#!edit-application +notes: + - SDK Method used are + application_policy.ApplicationPolicy.create_application, + application_policy.ApplicationPolicy.delete_application, + application_policy.ApplicationPolicy.edit_application, + + - Paths used are + post /dna/intent/api/v1/applications, + delete /dna/intent/api/v1/applications, + put /dna/intent/api/v1/applications, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.applications: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - applicationSet: + idRef: string + indicativeNetworkIdentity: + - displayName: string + id: string + lowerPort: 0 + ports: string + protocol: string + upperPort: 0 + name: string + networkApplications: + - appProtocol: string + applicationSubType: string + applicationType: string + categoryId: string + displayName: string + dscp: string + engineId: string + helpString: string + ignoreConflict: string + longDescription: string + name: string + popularity: string + rank: string + serverName: string + trafficClass: string + url: string + networkIdentity: + - displayName: string + lowerPort: string + ports: string + protocol: string + upperPort: string + +- name: Update all + cisco.dnac.applications: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - applicationSet: + idRef: string + id: string + name: string + networkApplications: + - appProtocol: string + applicationSubType: string + applicationType: string + categoryId: string + displayName: string + dscp: string + engineId: string + helpString: string + id: string + ignoreConflict: string + longDescription: string + name: string + popularity: string + rank: string + serverName: string + trafficClass: string + url: string + networkIdentity: + - displayName: string + id: string + lowerPort: string + ports: string + protocol: string + upperPort: string + +- name: Delete all + cisco.dnac.applications: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + id: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "taskId": "string", + "url": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/applications_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/applications_count_info.py new file mode 100644 index 000000000..1c725cb14 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/applications_count_info.py @@ -0,0 +1,63 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: applications_count_info +short_description: Information module for Applications Count +description: +- Get all Applications Count. +- Get the number of all existing applications. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Application Policy GetApplicationsCount + description: Complete reference of the GetApplicationsCount API. + link: https://developer.cisco.com/docs/dna-center/#!get-applications-count +notes: + - SDK Method used are + application_policy.ApplicationPolicy.get_applications_count, + + - Paths used are + get /dna/intent/api/v1/applications-count, + +""" + +EXAMPLES = r""" +- name: Get all Applications Count + cisco.dnac.applications_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/applications_health_info.py b/ansible_collections/cisco/dnac/plugins/modules/applications_health_info.py new file mode 100644 index 000000000..4bc998401 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/applications_health_info.py @@ -0,0 +1,151 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: applications_health_info +short_description: Information module for Applications Health +description: +- Get all Applications Health. +- > + Intent API to get a list of applications for a specific site, a device, or a client device's MAC address. For a + combination of a specific application with site and/or device the API gets list of issues/devices/endpoints. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + siteId: + description: + - SiteId query parameter. Assurance site UUID value (Cannot be submitted together with deviceId and clientMac). + type: str + deviceId: + description: + - DeviceId query parameter. Assurance device UUID value (Cannot be submitted together with siteId and clientMac). + type: str + macAddress: + description: + - MacAddress query parameter. Client device's MAC address (Cannot be submitted together with siteId and deviceId). + type: str + startTime: + description: + - StartTime query parameter. Starting epoch time in milliseconds of time window. + type: int + endTime: + description: + - EndTime query parameter. Ending epoch time in milliseconds of time window. + type: int + applicationHealth: + description: + - > + ApplicationHealth query parameter. Application health category (POOR, FAIR, or GOOD. Optionally use with + siteId only). + type: str + offset: + description: + - > + Offset query parameter. The offset of the first application in the returned data (optionally used with + siteId only). + type: int + limit: + description: + - > + Limit query parameter. The max number of application entries in returned data 1, 1000 (optionally used with + siteId only). + type: int + applicationName: + description: + - ApplicationName query parameter. The name of the application to get information on. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Applications Applications + description: Complete reference of the Applications API. + link: https://developer.cisco.com/docs/dna-center/#!applications-applications +notes: + - SDK Method used are + applications.Applications.applications, + + - Paths used are + get /dna/intent/api/v1/application-health, + +""" + +EXAMPLES = r""" +- name: Get all Applications Health + cisco.dnac.applications_health_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + siteId: string + deviceId: string + macAddress: string + startTime: 0 + endTime: 0 + applicationHealth: string + offset: 0 + limit: 0 + applicationName: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "totalCount": 0, + "response": [ + { + "name": "string", + "health": 0, + "businessRelevance": "string", + "trafficClass": "string", + "usageBytes": 0, + "averageThroughput": 0, + "packetLossPercent": {}, + "networkLatency": {}, + "jitter": {}, + "applicationServerLatency": {}, + "clientNetworkLatency": {}, + "serverNetworkLatency": {}, + "exporterIpAddress": "string", + "exporterName": "string", + "exporterUUID": "string", + "exporterFamily": "string", + "clientName": "string", + "clientIp": "string", + "location": "string", + "operatingSystem": "string", + "deviceType": "string", + "clientMacAddress": "string", + "issueId": "string", + "issueName": "string", + "application": "string", + "severity": "string", + "summary": "string", + "rootCause": "string", + "timestamp": 0, + "occurrences": 0, + "priority": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/applications_info.py b/ansible_collections/cisco/dnac/plugins/modules/applications_info.py new file mode 100644 index 000000000..431d62e37 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/applications_info.py @@ -0,0 +1,125 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: applications_info +short_description: Information module for Applications +description: +- Get all Applications. +- Get applications by offset/limit or by name. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + offset: + description: + - Offset query parameter. The offset of the first application to be returned. + type: int + limit: + description: + - Limit query parameter. The maximum number of applications to be returned. + type: int + name: + description: + - Name query parameter. Application's name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Application Policy GetApplications + description: Complete reference of the GetApplications API. + link: https://developer.cisco.com/docs/dna-center/#!get-applications +notes: + - SDK Method used are + application_policy.ApplicationPolicy.get_applications, + + - Paths used are + get /dna/intent/api/v1/applications, + +""" + +EXAMPLES = r""" +- name: Get all Applications + cisco.dnac.applications_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + offset: 0 + limit: 0 + name: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "id": "string", + "name": "string", + "indicativeNetworkIdentity": [ + { + "id": "string", + "displayName": "string", + "lowerPort": 0, + "ports": "string", + "protocol": "string", + "upperPort": 0 + } + ], + "networkApplications": [ + { + "id": "string", + "appProtocol": "string", + "applicationSubType": "string", + "applicationType": "string", + "categoryId": "string", + "displayName": "string", + "engineId": "string", + "helpString": "string", + "longDescription": "string", + "name": "string", + "popularity": 0, + "rank": 0, + "trafficClass": "string", + "serverName": "string", + "url": "string", + "dscp": "string", + "ignoreConflict": "string" + } + ], + "networkIdentity": [ + { + "id": "string", + "displayName": "string", + "lowerPort": 0, + "ports": "string", + "protocol": "string", + "upperPort": 0 + } + ], + "applicationSet": { + "idRef": "string" + } + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/assign_device_to_site.py b/ansible_collections/cisco/dnac/plugins/modules/assign_device_to_site.py new file mode 100644 index 000000000..fbd3cec3d --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/assign_device_to_site.py @@ -0,0 +1,77 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: assign_device_to_site +short_description: Resource module for Assign Device To Site +description: +- Manage operation create of the resource Assign Device To Site. +- Assigns unassigned devices to a site. This API does not move assigned devices to other sites. +version_added: '6.5.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + device: + description: Assign Device To Site's device. + elements: dict + suboptions: + ip: + description: Device ip (eg 10.104.240.64). + type: str + type: list + headers: + description: Additional headers. + type: dict + siteId: + description: SiteId path parameter. Site id to which site the device to assign. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for AssignDevicesToSite + description: Complete reference of the AssignDevicesToSite API. + link: https://developer.cisco.com/docs/dna-center/#!assign-devices-to-site +notes: + - SDK Method used are + ..assign_devices_to_site, + + - Paths used are + post /dna/intent/api/v1/assign-device-to-site/{siteId}/device, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.assign_device_to_site: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + device: + - ip: string + headers: '{{my_headers | from_json}}' + siteId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/associate_site_to_network_profile.py b/ansible_collections/cisco/dnac/plugins/modules/associate_site_to_network_profile.py new file mode 100644 index 000000000..7a2aab8e5 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/associate_site_to_network_profile.py @@ -0,0 +1,69 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: associate_site_to_network_profile +short_description: Resource module for Associate Site To Network Profile +description: +- Manage operation create of the resource Associate Site To Network Profile. +- Associate Site to a Network Profile. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + networkProfileId: + description: NetworkProfileId path parameter. Network-Profile Id to be associated. + type: str + siteId: + description: SiteId path parameter. Site Id to be associated. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Site Design Associate + description: Complete reference of the Associate API. + link: https://developer.cisco.com/docs/dna-center/#!associate +notes: + - SDK Method used are + site_design.SiteDesign.associate, + + - Paths used are + post /dna/intent/api/v1/networkprofile/{networkProfileId}/site/{siteId}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.associate_site_to_network_profile: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + networkProfileId: string + siteId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": { + "taskId": "string", + "url": "string" + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/authentication_import_certificate.py b/ansible_collections/cisco/dnac/plugins/modules/authentication_import_certificate.py new file mode 100644 index 000000000..7cfca0c47 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/authentication_import_certificate.py @@ -0,0 +1,78 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: authentication_import_certificate +short_description: Resource module for Authentication Import Certificate +description: +- Manage operation create of the resource Authentication Import Certificate. +- This method is used to upload a certificate. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + certFilePath: + description: Cert file absolute path. + type: str + listOfUsers: + description: ListOfUsers query parameter. + elements: str + type: list + pkFilePath: + description: Pk file absolute path. + type: str + pkPassword: + description: PkPassword query parameter. Private Key Passsword. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Authentication Management ImportCertificate + description: Complete reference of the ImportCertificate API. + link: https://developer.cisco.com/docs/dna-center/#!import-certificate +notes: + - SDK Method used are + authentication_management.AuthenticationManagement.import_certificate, + + - Paths used are + post /dna/intent/api/v1/certificate, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.authentication_import_certificate: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + certFilePath: /tmp/uploads/Test-242.pem + listOfUsers: [] + pkFilePath: /tmp/uploads/Test-242.key + pkPassword: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/authentication_import_certificate_p12.py b/ansible_collections/cisco/dnac/plugins/modules/authentication_import_certificate_p12.py new file mode 100644 index 000000000..ab19906f7 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/authentication_import_certificate_p12.py @@ -0,0 +1,78 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: authentication_import_certificate_p12 +short_description: Resource module for Authentication Import Certificate P12 +description: +- Manage operation create of the resource Authentication Import Certificate P12. +- This method is used to upload a PKCS\#12 file. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + listOfUsers: + description: ListOfUsers query parameter. + elements: str + type: list + p12FilePath: + description: P12 file absolute path. + type: str + p12Password: + description: P12Password query parameter. P12 Passsword. + type: str + pkPassword: + description: PkPassword query parameter. Private Key Passsword. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Authentication Management ImportCertificateP12 + description: Complete reference of the ImportCertificateP12 API. + link: https://developer.cisco.com/docs/dna-center/#!import-certificate-p-12 +notes: + - SDK Method used are + authentication_management.AuthenticationManagement.import_certificate_p12, + + - Paths used are + post /dna/intent/api/v1/certificate-p12, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.authentication_import_certificate_p12: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + listOfUsers: [] + p12FilePath: /tmp/uploads/Test-242.p12 + p12Password: string + pkPassword: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/authentication_policy_servers_info.py b/ansible_collections/cisco/dnac/plugins/modules/authentication_policy_servers_info.py new file mode 100644 index 000000000..cb5124de7 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/authentication_policy_servers_info.py @@ -0,0 +1,121 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: authentication_policy_servers_info +short_description: Information module for Authentication Policy Servers +description: +- Get all Authentication Policy Servers. +- API to get Authentication and Policy Servers. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + isIseEnabled: + description: + - IsIseEnabled query parameter. Valid values are true, false. + type: bool + state_: + description: + - State query parameter. Valid values are INPROGRESS, ACTIVE, DELETED, RBAC-FAILURE, FAILED. + type: str + role: + description: + - Role query parameter. Authentication and Policy Server Role (Example primary, secondary). + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for System Settings GetAuthenticationAndPolicyServers + description: Complete reference of the GetAuthenticationAndPolicyServers API. + link: https://developer.cisco.com/docs/dna-center/#!get-authentication-and-policy-servers +notes: + - SDK Method used are + system_settings.SystemSettings.get_authentication_and_policy_servers, + + - Paths used are + get /dna/intent/api/v1/authentication-policy-servers, + +""" + +EXAMPLES = r""" +- name: Get all Authentication Policy Servers + cisco.dnac.authentication_policy_servers_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + isIseEnabled: True + state_: string + role: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "ipAddress": "string", + "sharedSecret": "string", + "protocol": "string", + "role": "string", + "port": 0, + "authenticationPort": "string", + "accountingPort": "string", + "retries": 0, + "timeoutSeconds": 0, + "isIseEnabled": true, + "instanceUuid": "string", + "state": "string", + "ciscoIseDtos": [ + { + "subscriberName": "string", + "description": "string", + "password": "string", + "userName": "string", + "fqdn": "string", + "ipAddress": "string", + "trustState": "string", + "instanceUuid": "string", + "sshkey": "string", + "type": "string", + "failureReason": "string", + "role": "string", + "externalCiscoIseIpAddrDtos": { + "type": "string", + "externalCiscoIseIpAddresses": [ + { + "externalIpAddress": "string" + } + ] + } + } + ], + "encryptionScheme": "string", + "messageKey": "string", + "encryptionKey": "string", + "useDnacCertForPxgrid": true, + "iseEnabled": true, + "pxgridEnabled": true + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/buildings_planned_access_points_info.py b/ansible_collections/cisco/dnac/plugins/modules/buildings_planned_access_points_info.py new file mode 100644 index 000000000..07dda3ca9 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/buildings_planned_access_points_info.py @@ -0,0 +1,129 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: buildings_planned_access_points_info +short_description: Information module for Buildings Planned Access Points +description: +- Get all Buildings Planned Access Points. +- Provides a list of Planned Access Points for the Building it is requested for. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + buildingId: + description: + - BuildingId path parameter. Building Id. + type: str + limit: + description: + - Limit query parameter. + type: int + offset: + description: + - Offset query parameter. + type: int + radios: + description: + - Radios query parameter. Inlcude planned radio details. + type: bool +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetPlannedAccessPointsForBuilding + description: Complete reference of the GetPlannedAccessPointsForBuilding API. + link: https://developer.cisco.com/docs/dna-center/#!get-planned-access-points-for-building +notes: + - SDK Method used are + devices.Devices.get_planned_access_points_for_building, + + - Paths used are + get /dna/intent/api/v1/buildings/{buildingId}/planned-access-points, + +""" + +EXAMPLES = r""" +- name: Get all Buildings Planned Access Points + cisco.dnac.buildings_planned_access_points_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + limit: 0 + offset: 0 + radios: True + buildingId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "attributes": { + "id": 0, + "instanceUuid": "string", + "name": "string", + "typeString": "string", + "domain": "string", + "heirarchyName": "string", + "source": "string", + "createDate": 0, + "macaddress": {} + }, + "location": {}, + "position": { + "x": 0, + "y": 0, + "z": 0 + }, + "radioCount": 0, + "radios": [ + { + "attributes": { + "id": 0, + "instanceUuid": "string", + "slotId": 0, + "ifTypeString": "string", + "ifTypeSubband": "string", + "channel": {}, + "channelString": {}, + "ifMode": "string" + }, + "antenna": { + "name": "string", + "type": "string", + "mode": "string", + "azimuthAngle": 0, + "elevationAngle": 0, + "gain": 0 + }, + "isSensor": true + } + ], + "isSensor": true + } + ], + "version": 0, + "total": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/business_sda_hostonboarding_ssid_ippool.py b/ansible_collections/cisco/dnac/plugins/modules/business_sda_hostonboarding_ssid_ippool.py new file mode 100644 index 000000000..daa0bbc00 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/business_sda_hostonboarding_ssid_ippool.py @@ -0,0 +1,106 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: business_sda_hostonboarding_ssid_ippool +short_description: Resource module for Business Sda Hostonboarding Ssid Ippool +description: +- Manage operations create and update of the resource Business Sda Hostonboarding Ssid Ippool. +- Add SSID to IP Pool Mapping. +- Update SSID to IP Pool Mapping. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + scalableGroupName: + description: Scalable Group Name. + type: str + siteNameHierarchy: + description: Site Name Hierarchy. + type: str + ssidNames: + description: List of SSIDs. + elements: str + type: list + vlanName: + description: VLAN Name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Fabric Wireless AddSSIDToIPPoolMapping + description: Complete reference of the AddSSIDToIPPoolMapping API. + link: https://developer.cisco.com/docs/dna-center/#!add-ssid-to-ip-pool-mapping +- name: Cisco DNA Center documentation for Fabric Wireless UpdateSSIDToIPPoolMapping + description: Complete reference of the UpdateSSIDToIPPoolMapping API. + link: https://developer.cisco.com/docs/dna-center/#!update-ssid-to-ip-pool-mapping +notes: + - SDK Method used are + fabric_wireless.FabricWireless.add_ssid_to_ip_pool_mapping, + fabric_wireless.FabricWireless.update_ssid_to_ip_pool_mapping, + + - Paths used are + post /dna/intent/api/v1/business/sda/hostonboarding/ssid-ippool, + put /dna/intent/api/v1/business/sda/hostonboarding/ssid-ippool, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.business_sda_hostonboarding_ssid_ippool: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + headers: '{{my_headers | from_json}}' + scalableGroupName: string + siteNameHierarchy: string + ssidNames: + - string + vlanName: string + +- name: Update all + cisco.dnac.business_sda_hostonboarding_ssid_ippool: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + scalableGroupName: string + siteNameHierarchy: string + ssidNames: + - string + vlanName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + sample: > + [ + { + "executionId": "string", + "executionStatusURL": "string", + "message": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/business_sda_hostonboarding_ssid_ippool_info.py b/ansible_collections/cisco/dnac/plugins/modules/business_sda_hostonboarding_ssid_ippool_info.py new file mode 100644 index 000000000..6ecfdd80f --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/business_sda_hostonboarding_ssid_ippool_info.py @@ -0,0 +1,78 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: business_sda_hostonboarding_ssid_ippool_info +short_description: Information module for Business Sda Hostonboarding Ssid Ippool +description: +- Get all Business Sda Hostonboarding Ssid Ippool. +- Get SSID to IP Pool Mapping. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + vlanName: + description: + - VlanName query parameter. VLAN Name. + type: str + siteNameHierarchy: + description: + - SiteNameHierarchy query parameter. Site Name Heirarchy. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Fabric Wireless GetSSIDToIPPoolMapping + description: Complete reference of the GetSSIDToIPPoolMapping API. + link: https://developer.cisco.com/docs/dna-center/#!get-ssid-to-ip-pool-mapping +notes: + - SDK Method used are + fabric_wireless.FabricWireless.get_ssid_to_ip_pool_mapping, + + - Paths used are + get /dna/intent/api/v1/business/sda/hostonboarding/ssid-ippool, + +""" + +EXAMPLES = r""" +- name: Get all Business Sda Hostonboarding Ssid Ippool + cisco.dnac.business_sda_hostonboarding_ssid_ippool_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + vlanName: string + siteNameHierarchy: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "vlanName": "string", + "ssidDetails": [ + { + "name": "string", + "scalableGroupName": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/business_sda_virtual_network_summary_info.py b/ansible_collections/cisco/dnac/plugins/modules/business_sda_virtual_network_summary_info.py new file mode 100644 index 000000000..941822ad5 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/business_sda_virtual_network_summary_info.py @@ -0,0 +1,75 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: business_sda_virtual_network_summary_info +short_description: Information module for Business Sda Virtual Network Summary +description: +- Get all Business Sda Virtual Network Summary. +- Get Virtual Network Summary. +version_added: '6.5.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + siteNameHierarchy: + description: + - SiteNameHierarchy query parameter. Complete fabric siteNameHierarchy Path. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for GetVirtualNetworkSummary + description: Complete reference of the GetVirtualNetworkSummary API. + link: https://developer.cisco.com/docs/dna-center/#!get-virtual-network-summary +notes: + - SDK Method used are + ..get_virtual_network_summary, + + - Paths used are + get /dna/intent/api/v1/business/sda/virtual-network/summary, + +""" + +EXAMPLES = r""" +- name: Get all Business Sda Virtual Network Summary + cisco.dnac.business_sda_virtual_network_summary_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + siteNameHierarchy: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "virtualNetworkCount": 0, + "virtualNetworkSummary": [ + { + "siteNameHierarchy": "string", + "virtualNetworkName": "string" + } + ], + "status": "string", + "description": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/business_sda_wireless_controller_create.py b/ansible_collections/cisco/dnac/plugins/modules/business_sda_wireless_controller_create.py new file mode 100644 index 000000000..1d9993a6c --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/business_sda_wireless_controller_create.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: business_sda_wireless_controller_create +short_description: Resource module for Business Sda Wireless Controller Create +description: +- Manage operation create of the resource Business Sda Wireless Controller Create. +- Add WLC to Fabric Domain. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + deviceName: + description: EWLC Device Name. + type: str + siteNameHierarchy: + description: Site Name Hierarchy. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Fabric Wireless AddWLCToFabricDomain + description: Complete reference of the AddWLCToFabricDomain API. + link: https://developer.cisco.com/docs/dna-center/#!add-wlc-to-fabric-domain +notes: + - SDK Method used are + fabric_wireless.FabricWireless.add_w_l_c_to_fabric_domain, + + - Paths used are + post /dna/intent/api/v1/business/sda/wireless-controller, + + - Removed 'deviceIPAddress' options in v4.3.0. +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.business_sda_wireless_controller_create: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + deviceName: string + siteNameHierarchy: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusURL": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/business_sda_wireless_controller_delete.py b/ansible_collections/cisco/dnac/plugins/modules/business_sda_wireless_controller_delete.py new file mode 100644 index 000000000..4ca615500 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/business_sda_wireless_controller_delete.py @@ -0,0 +1,67 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: business_sda_wireless_controller_delete +short_description: Resource module for Business Sda Wireless Controller Delete +description: +- Manage operation delete of the resource Business Sda Wireless Controller Delete. +- Remove WLC from Fabric Domain. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + deviceIPAddress: + description: DeviceIPAddress query parameter. Device Management IP Address. + type: str + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Fabric Wireless RemoveWLCFromFabricDomain + description: Complete reference of the RemoveWLCFromFabricDomain API. + link: https://developer.cisco.com/docs/dna-center/#!remove-wlc-from-fabric-domain +notes: + - SDK Method used are + fabric_wireless.FabricWireless.remove_w_l_c_from_fabric_domain, + + - Paths used are + delete /dna/intent/api/v1/business/sda/wireless-controller, + + - Removed 'deviceName' and 'siteNameHierarchy' options in v4.3.0. +""" + +EXAMPLES = r""" +- name: Delete all + cisco.dnac.business_sda_wireless_controller_delete: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + deviceIPAddress: string + headers: '{{my_headers | from_json}}' + +""" +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/cli_credential.py b/ansible_collections/cisco/dnac/plugins/modules/cli_credential.py new file mode 100644 index 000000000..d7b542962 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/cli_credential.py @@ -0,0 +1,124 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: cli_credential +short_description: Resource module for Cli Credential +description: +- Manage operations create and update of the resource Cli Credential. +- Adds global CLI credential. +- Updates global CLI credentials. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + comments: + description: Cli Credential's comments. + type: str + credentialType: + description: Cli Credential's credentialType. + type: str + description: + description: Cli Credential's description. + type: str + enablePassword: + description: Cli Credential's enablePassword. + type: str + id: + description: Cli Credential's id. + type: str + instanceTenantId: + description: Cli Credential's instanceTenantId. + type: str + instanceUuid: + description: Cli Credential's instanceUuid. + type: str + password: + description: Cli Credential's password. + type: str + username: + description: Cli Credential's username. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery CreateCLICredentials + description: Complete reference of the CreateCLICredentials API. + link: https://developer.cisco.com/docs/dna-center/#!create-cli-credentials +- name: Cisco DNA Center documentation for Discovery UpdateCLICredentials + description: Complete reference of the UpdateCLICredentials API. + link: https://developer.cisco.com/docs/dna-center/#!update-cli-credentials +notes: + - SDK Method used are + discovery.Discovery.create_cli_credentials, + discovery.Discovery.update_cli_credentials, + + - Paths used are + post /dna/intent/api/v1/global-credential/cli, + put /dna/intent/api/v1/global-credential/cli, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.cli_credential: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + comments: string + credentialType: string + description: string + enablePassword: string + id: string + instanceTenantId: string + instanceUuid: string + password: string + username: string + +- name: Create + cisco.dnac.cli_credential: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + comments: string + credentialType: string + description: string + enablePassword: string + id: string + instanceTenantId: string + instanceUuid: string + password: string + username: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/client_detail_info.py b/ansible_collections/cisco/dnac/plugins/modules/client_detail_info.py new file mode 100644 index 000000000..a823da7b5 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/client_detail_info.py @@ -0,0 +1,196 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: client_detail_info +short_description: Information module for Client Detail +description: +- Get all Client Detail. +- Returns detailed Client information retrieved by Mac Address for any given point of time. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + timestamp: + description: + - Timestamp query parameter. Epoch time(in milliseconds) when the Client health data is required. + type: str + macAddress: + description: + - MacAddress query parameter. MAC Address of the client. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Clients GetClientDetail + description: Complete reference of the GetClientDetail API. + link: https://developer.cisco.com/docs/dna-center/#!get-client-detail +notes: + - SDK Method used are + clients.Clients.get_client_detail, + + - Paths used are + get /dna/intent/api/v1/client-detail, + +""" + +EXAMPLES = r""" +- name: Get all Client Detail + cisco.dnac.client_detail_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + timestamp: string + macAddress: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "detail": { + "id": "string", + "connectionStatus": "string", + "hostType": "string", + "userId": {}, + "hostName": "string", + "hostOs": {}, + "hostVersion": {}, + "subType": "string", + "lastUpdated": 0, + "healthScore": [ + { + "healthType": "string", + "reason": "string", + "score": 0 + } + ], + "hostMac": "string", + "hostIpV4": "string", + "hostIpV6": [ + "string" + ], + "authType": "string", + "vlanId": 0, + "vnid": 0, + "ssid": "string", + "frequency": "string", + "channel": "string", + "apGroup": {}, + "location": {}, + "clientConnection": "string", + "connectedDevice": [ + {} + ], + "issueCount": 0, + "rssi": "string", + "avgRssi": {}, + "snr": "string", + "avgSnr": {}, + "dataRate": "string", + "txBytes": "string", + "rxBytes": "string", + "dnsSuccess": {}, + "dnsFailure": {}, + "onboarding": { + "averageRunDuration": {}, + "maxRunDuration": {}, + "averageAssocDuration": {}, + "maxAssocDuration": {}, + "averageAuthDuration": {}, + "maxAuthDuration": {}, + "averageDhcpDuration": {}, + "maxDhcpDuration": {}, + "aaaServerIp": "string", + "dhcpServerIp": {}, + "authDoneTime": {}, + "assocDoneTime": {}, + "dhcpDoneTime": {}, + "assocRootcauseList": [ + {} + ], + "aaaRootcauseList": [ + {} + ], + "dhcpRootcauseList": [ + {} + ], + "otherRootcauseList": [ + {} + ] + }, + "clientType": "string", + "onboardingTime": {}, + "port": {}, + "iosCapable": true + }, + "connectionInfo": { + "hostType": "string", + "nwDeviceName": "string", + "nwDeviceMac": "string", + "protocol": "string", + "band": "string", + "spatialStream": "string", + "channel": "string", + "channelWidth": "string", + "wmm": "string", + "uapsd": "string", + "timestamp": 0 + }, + "topology": { + "nodes": [ + { + "role": "string", + "name": "string", + "id": "string", + "description": "string", + "deviceType": "string", + "platformId": {}, + "family": {}, + "ip": "string", + "softwareVersion": {}, + "userId": {}, + "nodeType": "string", + "radioFrequency": {}, + "clients": {}, + "count": {}, + "healthScore": 0, + "level": 0, + "fabricGroup": {}, + "connectedDevice": {} + } + ], + "links": [ + { + "source": "string", + "linkStatus": "string", + "label": [ + "string" + ], + "target": "string", + "id": {}, + "portUtilization": {} + } + ] + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/client_enrichment_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/client_enrichment_details_info.py new file mode 100644 index 000000000..da1fd47d2 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/client_enrichment_details_info.py @@ -0,0 +1,230 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: client_enrichment_details_info +short_description: Information module for Client Enrichment Details +description: +- Get all Client Enrichment Details. +- > + Enriches a given network End User context a network user-id or end user's device Mac Address with details about + the user, the devices that the user is connected to and the assurance issues that the user is impacted by. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Clients GetClientEnrichmentDetails + description: Complete reference of the GetClientEnrichmentDetails API. + link: https://developer.cisco.com/docs/dna-center/#!get-client-enrichment-details +notes: + - SDK Method used are + clients.Clients.get_client_enrichment_details, + + - Paths used are + get /dna/intent/api/v1/client-enrichment-details, + +""" + +EXAMPLES = r""" +- name: Get all Client Enrichment Details + cisco.dnac.client_enrichment_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "userDetails": { + "id": "string", + "connectionStatus": "string", + "hostType": "string", + "userId": "string", + "hostName": {}, + "hostOs": {}, + "hostVersion": {}, + "subType": {}, + "lastUpdated": 0, + "healthScore": [ + { + "healthType": "string", + "reason": "string", + "score": 0 + } + ], + "hostMac": "string", + "hostIpV4": "string", + "hostIpV6": [ + {} + ], + "authType": {}, + "vlanId": "string", + "ssid": {}, + "location": {}, + "clientConnection": "string", + "connectedDevice": [ + {} + ], + "issueCount": 0, + "rssi": {}, + "snr": {}, + "dataRate": {}, + "port": {} + }, + "connectedDevice": [ + { + "deviceDetails": { + "family": "string", + "type": "string", + "location": {}, + "errorCode": "string", + "macAddress": "string", + "role": "string", + "apManagerInterfaceIp": "string", + "associatedWlcIp": "string", + "bootDateTime": {}, + "collectionStatus": "string", + "interfaceCount": {}, + "lineCardCount": {}, + "lineCardId": {}, + "managementIpAddress": "string", + "memorySize": "string", + "platformId": "string", + "reachabilityFailureReason": "string", + "reachabilityStatus": "string", + "snmpContact": "string", + "snmpLocation": "string", + "tunnelUdpPort": "string", + "waasDeviceMode": {}, + "series": "string", + "inventoryStatusDetail": "string", + "collectionInterval": "string", + "serialNumber": "string", + "softwareVersion": "string", + "roleSource": "string", + "hostname": "string", + "upTime": "string", + "lastUpdateTime": 0, + "errorDescription": {}, + "locationName": {}, + "tagCount": "string", + "lastUpdated": "string", + "instanceUuid": "string", + "id": "string", + "neighborTopology": [ + { + "nodes": [ + { + "role": "string", + "name": "string", + "id": "string", + "description": "string", + "deviceType": {}, + "platformId": {}, + "family": {}, + "ip": {}, + "softwareVersion": {}, + "userId": {}, + "nodeType": {}, + "radioFrequency": {}, + "clients": 0, + "count": {}, + "healthScore": {}, + "level": 0, + "fabricGroup": {} + } + ], + "links": [ + { + "source": "string", + "linkStatus": "string", + "label": [ + {} + ], + "target": "string", + "id": {}, + "portUtilization": {} + } + ] + } + ], + "cisco360view": "string" + } + } + ], + "issueDetails": { + "issue": [ + { + "issueId": "string", + "issueSource": "string", + "issueCategory": "string", + "issueName": "string", + "issueDescription": "string", + "issueEntity": "string", + "issueEntityValue": "string", + "issueSeverity": "string", + "issuePriority": "string", + "issueSummary": "string", + "issueTimestamp": 0, + "suggestedActions": [ + { + "message": "string", + "steps": [ + {} + ] + } + ], + "impactedHosts": [ + { + "hostType": "string", + "hostName": "string", + "hostOs": "string", + "ssid": "string", + "connectedInterface": "string", + "macAddress": "string", + "failedAttempts": 0, + "location": { + "siteId": "string", + "siteType": "string", + "area": "string", + "building": "string", + "floor": {}, + "apsImpacted": [ + {} + ] + }, + "timestamp": 0 + } + ] + } + ] + } + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/client_health_info.py b/ansible_collections/cisco/dnac/plugins/modules/client_health_info.py new file mode 100644 index 000000000..2def53c98 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/client_health_info.py @@ -0,0 +1,109 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: client_health_info +short_description: Information module for Client Health +description: +- Get all Client Health. +- Returns Overall Client Health information by Client type Wired and Wireless for any given point of time. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + timestamp: + description: + - Timestamp query parameter. Epoch time(in milliseconds) when the Client health data is required. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Clients GetOverallClientHealth + description: Complete reference of the GetOverallClientHealth API. + link: https://developer.cisco.com/docs/dna-center/#!get-overall-client-health +notes: + - SDK Method used are + clients.Clients.get_overall_client_health, + + - Paths used are + get /dna/intent/api/v1/client-health, + +""" + +EXAMPLES = r""" +- name: Get all Client Health + cisco.dnac.client_health_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + timestamp: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "siteId": "string", + "scoreDetail": [ + { + "scoreCategory": { + "scoreCategory": "string", + "value": "string" + }, + "scoreValue": 0, + "clientCount": 0, + "clientUniqueCount": 0, + "starttime": 0, + "endtime": 0, + "scoreList": [ + { + "scoreCategory": { + "scoreCategory": "string", + "value": "string" + }, + "scoreValue": 0, + "clientCount": 0, + "clientUniqueCount": 0, + "starttime": 0, + "endtime": 0, + "scoreList": [ + { + "scoreCategory": { + "scoreCategory": "string", + "value": "string" + }, + "scoreValue": 0, + "clientCount": 0, + "clientUniqueCount": {}, + "starttime": 0, + "endtime": 0 + } + ] + } + ] + } + ] + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/client_proximity_info.py b/ansible_collections/cisco/dnac/plugins/modules/client_proximity_info.py new file mode 100644 index 000000000..d65c51e09 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/client_proximity_info.py @@ -0,0 +1,87 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: client_proximity_info +short_description: Information module for Client Proximity +description: +- Get all Client Proximity. +- > + This intent API will provide client proximity information for a specific wireless user. Proximity is defined as + presence on the same floor at the same time as the specified wireless user. The Proximity workflow requires the + subscription to the following event via the Event Notification workflow prior to making this API call NETWORK- + CLIENTS-3-506 - Client Proximity Report. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + username: + description: + - Username query parameter. Wireless client username for which proximity information is required. + type: str + number_days: + description: + - > + Number_days query parameter. Number of days to track proximity until current date. Defaults and maximum up + to 14 days. + type: int + time_resolution: + description: + - > + Time_resolution query parameter. Time interval (in minutes) to measure proximity. Defaults to 15 minutes + with a minimum 5 minutes. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Clients ClientProximity + description: Complete reference of the ClientProximity API. + link: https://developer.cisco.com/docs/dna-center/#!client-proximity +notes: + - SDK Method used are + clients.Clients.client_proximity, + + - Paths used are + get /dna/intent/api/v1/client-proximity, + +""" + +EXAMPLES = r""" +- name: Get all Client Proximity + cisco.dnac.client_proximity_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + username: string + number_days: 0 + time_resolution: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/command_runner_run_command.py b/ansible_collections/cisco/dnac/plugins/modules/command_runner_run_command.py new file mode 100644 index 000000000..34222b28f --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/command_runner_run_command.py @@ -0,0 +1,85 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: command_runner_run_command +short_description: Resource module for Command Runner Run Command +description: +- Manage operation create of the resource Command Runner Run Command. +- Submit request for read-only CLIs. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + commands: + description: Command Runner Run Command's commands. + elements: str + type: list + description: + description: Command Runner Run Command's description. + type: str + deviceUuids: + description: Command Runner Run Command's deviceUuids. + elements: str + type: list + name: + description: Command Runner Run Command's name. + type: str + timeout: + description: Command Runner Run Command's timeout. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Command Runner RunReadOnlyCommandsOnDevicesToGetTheirRealTimeConfiguration + description: Complete reference of the RunReadOnlyCommandsOnDevicesToGetTheirRealTimeConfiguration API. + link: https://developer.cisco.com/docs/dna-center/#!run-read-only-commands-on-devices-to-get-their-real-time-configuration +notes: + - SDK Method used are + command_runner.CommandRunner.run_read_only_commands_on_devices, + + - Paths used are + post /dna/intent/api/v1/network-device-poller/cli/read-request, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.command_runner_run_command: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + commands: + - string + description: string + deviceUuids: + - string + name: string + timeout: 0 + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/compliance_check_run.py b/ansible_collections/cisco/dnac/plugins/modules/compliance_check_run.py new file mode 100644 index 000000000..6d9a5c6bc --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/compliance_check_run.py @@ -0,0 +1,77 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: compliance_check_run +short_description: Resource module for Compliance Check Run +description: +- Manage operation create of the resource Compliance Check Run. +- Run compliance check for devices. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + categories: + description: Compliance Check Run's categories. + elements: str + type: list + deviceUuids: + description: Compliance Check Run's deviceUuids. + elements: str + type: list + triggerFull: + description: TriggerFull flag. + type: bool +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Compliance RunCompliance + description: Complete reference of the RunCompliance API. + link: https://developer.cisco.com/docs/dna-center/#!run-compliance +notes: + - SDK Method used are + compliance.Compliance.run_compliance, + + - Paths used are + post /dna/intent/api/v1/compliance/, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.compliance_check_run: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + categories: + - string + deviceUuids: + - string + triggerFull: true + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": { + "taskId": "string", + "url": "string" + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/compliance_device_by_id_info.py b/ansible_collections/cisco/dnac/plugins/modules/compliance_device_by_id_info.py new file mode 100644 index 000000000..92e2f73bb --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/compliance_device_by_id_info.py @@ -0,0 +1,143 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: compliance_device_by_id_info +short_description: Information module for Compliance Device By Id +description: +- Get all Compliance Device By Id. +- Return compliance detailed report for a device. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceUuid: + description: + - DeviceUuid path parameter. + type: str + category: + description: + - Category query parameter. ComplianceCategory can have any value among 'INTENT', 'RUNNING_CONFIG'. + type: str + complianceType: + description: + - > + ComplianceType query parameter. ComplianceType can have any value among 'NETWORK_DESIGN', 'NETWORK_PROFILE', + 'FABRIC', 'POLICY', 'RUNNING_CONFIG'. + type: str + diffList: + description: + - DiffList query parameter. Diff list pass true to fetch the diff list. + type: bool + key: + description: + - Key query parameter. Extended attribute key. + type: str + value: + description: + - Value query parameter. Extended attribute value. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Compliance ComplianceDetailsOfDevice + description: Complete reference of the ComplianceDetailsOfDevice API. + link: https://developer.cisco.com/docs/dna-center/#!compliance-details-of-device +notes: + - SDK Method used are + compliance.Compliance.compliance_details_of_device, + + - Paths used are + get /dna/intent/api/v1/compliance/{deviceUuid}/detail, + +""" + +EXAMPLES = r""" +- name: Get all Compliance Device By Id + cisco.dnac.compliance_device_by_id_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + category: string + complianceType: string + diffList: True + key: string + value: string + deviceUuid: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "deviceUuid": "string", + "version": "string", + "response": [ + { + "displayName": "string", + "complianceType": "string", + "lastSyncTime": 0, + "additionalDataURL": "string", + "sourceInfoList": [ + { + "count": 0, + "displayName": "string", + "diffList": [ + { + "displayName": "string", + "moveFromPath": "string", + "op": "string", + "configuredValue": "string", + "intendedValue": "string", + "path": "string", + "businessKey": "string", + "extendedAttributes": "string" + } + ], + "sourceEnum": "string", + "licenseAppName": "string", + "provisioningArea": "string", + "networkProfileName": "string", + "nameWithBusinessKey": "string", + "appName": "string", + "name": "string", + "type": "string", + "businessKey": { + "otherAttributes": { + "cfsAttributes": "string", + "name": "string" + }, + "resourceName": "string", + "businessKeyAttributes": "string" + } + } + ], + "deviceUuid": "string", + "message": "string", + "state": "string", + "status": "string", + "category": "string", + "lastUpdateTime": 0 + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/compliance_device_details_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/compliance_device_details_count_info.py new file mode 100644 index 000000000..2bc29a305 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/compliance_device_details_count_info.py @@ -0,0 +1,77 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: compliance_device_details_count_info +short_description: Information module for Compliance Device Details Count +description: +- Get all Compliance Device Details Count. +- Return Compliance Count Detail. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + complianceType: + description: + - > + ComplianceType query parameter. ComplianceType can have any value among 'NETWORK_PROFILE', 'IMAGE', + 'APPLICATION_VISIBILITY', 'FABRIC', 'PSIRT', 'RUNNING_CONFIG', 'WORKFLOW'. + type: str + complianceStatus: + description: + - > + ComplianceStatus query parameter. Compliance status can have value among 'COMPLIANT', 'NON_COMPLIANT', + 'IN_PROGRESS', 'NOT_AVAILABLE', 'NOT_APPLICABLE', 'ERROR'. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Compliance GetComplianceDetailCount + description: Complete reference of the GetComplianceDetailCount API. + link: https://developer.cisco.com/docs/dna-center/#!get-compliance-detail-count +notes: + - SDK Method used are + compliance.Compliance.get_compliance_detail_count, + + - Paths used are + get /dna/intent/api/v1/compliance/detail/count, + +""" + +EXAMPLES = r""" +- name: Get all Compliance Device Details Count + cisco.dnac.compliance_device_details_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + complianceType: string + complianceStatus: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/compliance_device_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/compliance_device_details_info.py new file mode 100644 index 000000000..9eb00777b --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/compliance_device_details_info.py @@ -0,0 +1,103 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: compliance_device_details_info +short_description: Information module for Compliance Device Details +description: +- Get all Compliance Device Details. +- Return Compliance Detail. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + complianceType: + description: + - > + ComplianceType query parameter. ComplianceType can have any value among 'NETWORK_PROFILE', 'IMAGE', + 'APPLICATION_VISIBILITY', 'FABRIC', 'PSIRT', 'RUNNING_CONFIG', 'WORKFLOW'. + type: str + complianceStatus: + description: + - > + ComplianceStatus query parameter. Compliance status can have value among 'COMPLIANT', 'NON_COMPLIANT', + 'IN_PROGRESS', 'NOT_AVAILABLE', 'NOT_APPLICABLE', 'ERROR'. + type: str + deviceUuid: + description: + - DeviceUuid query parameter. Comma separated deviceUuids. + type: str + offset: + description: + - Offset query parameter. Offset/starting row. + type: int + limit: + description: + - Limit query parameter. Number of records to be retrieved. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Compliance GetComplianceDetail + description: Complete reference of the GetComplianceDetail API. + link: https://developer.cisco.com/docs/dna-center/#!get-compliance-detail +notes: + - SDK Method used are + compliance.Compliance.get_compliance_detail, + + - Paths used are + get /dna/intent/api/v1/compliance/detail, + +""" + +EXAMPLES = r""" +- name: Get all Compliance Device Details + cisco.dnac.compliance_device_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + complianceType: string + complianceStatus: string + deviceUuid: string + offset: 0 + limit: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": [ + { + "complianceType": "string", + "lastSyncTime": 0, + "deviceUuid": "string", + "displayName": "string", + "status": "string", + "category": "string", + "lastUpdateTime": 0, + "state": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/compliance_device_info.py b/ansible_collections/cisco/dnac/plugins/modules/compliance_device_info.py new file mode 100644 index 000000000..d256f41d8 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/compliance_device_info.py @@ -0,0 +1,111 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: compliance_device_info +short_description: Information module for Compliance Device +description: +- Get all Compliance Device. +- Get Compliance Device by id. +- Return compliance status of a device. +- Return compliance status of devices. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + complianceStatus: + description: + - > + ComplianceStatus query parameter. Compliance status can be have value among + 'COMPLIANT','NON_COMPLIANT','IN_PROGRESS', 'ERROR'. + type: str + deviceUuid: + description: + - DeviceUuid query parameter. Comma separated deviceUuids. + type: str + offset: + description: + - Offset query parameter. Offset/starting row. + type: int + limit: + description: + - Limit query parameter. Number of records to be retrieved. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Compliance DeviceComplianceStatus + description: Complete reference of the DeviceComplianceStatus API. + link: https://developer.cisco.com/docs/dna-center/#!device-compliance-status +- name: Cisco DNA Center documentation for Compliance GetComplianceStatus + description: Complete reference of the GetComplianceStatus API. + link: https://developer.cisco.com/docs/dna-center/#!get-compliance-status +notes: + - SDK Method used are + compliance.Compliance.device_compliance_status, + compliance.Compliance.get_compliance_status, + + - Paths used are + get /dna/intent/api/v1/compliance, + get /dna/intent/api/v1/compliance/{deviceUuid}, + +""" + +EXAMPLES = r""" +- name: Get all Compliance Device + cisco.dnac.compliance_device_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + complianceStatus: string + deviceUuid: string + offset: 0 + limit: 0 + register: result + +- name: Get Compliance Device by id + cisco.dnac.compliance_device_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceUuid: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": { + "deviceUuid": "string", + "complianceStatus": "string", + "message": "string", + "scheduleTime": 0, + "lastUpdateTime": 0 + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/compliance_device_status_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/compliance_device_status_count_info.py new file mode 100644 index 000000000..ef33aae08 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/compliance_device_status_count_info.py @@ -0,0 +1,70 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: compliance_device_status_count_info +short_description: Information module for Compliance Device Status Count +description: +- Get all Compliance Device Status Count. +- Return Compliance Status Count. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + complianceStatus: + description: + - > + ComplianceStatus query parameter. Compliance status can have value among 'COMPLIANT', 'NON_COMPLIANT', + 'IN_PROGRESS', 'NOT_AVAILABLE', 'NOT_APPLICABLE', 'ERROR'. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Compliance GetComplianceStatusCount + description: Complete reference of the GetComplianceStatusCount API. + link: https://developer.cisco.com/docs/dna-center/#!get-compliance-status-count +notes: + - SDK Method used are + compliance.Compliance.get_compliance_status_count, + + - Paths used are + get /dna/intent/api/v1/compliance/count, + +""" + +EXAMPLES = r""" +- name: Get all Compliance Device Status Count + cisco.dnac.compliance_device_status_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + complianceStatus: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/configuration_template.py b/ansible_collections/cisco/dnac/plugins/modules/configuration_template.py new file mode 100644 index 000000000..35dc21ac5 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/configuration_template.py @@ -0,0 +1,730 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: configuration_template +short_description: Resource module for Configuration Template +description: +- Manage operations update and delete of the resource Configuration Template. +- Deletes the template by its id. +- API to update a template. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + author: + description: Author of template. + type: str + composite: + description: Is it composite template. + type: bool + containingTemplates: + description: Configuration Template's containingTemplates. + elements: dict + suboptions: + composite: + description: Is it composite template. + type: bool + description: + description: Description of template. + type: str + deviceTypes: + description: Configuration Template's deviceTypes. + elements: dict + suboptions: + productFamily: + description: Device family. + type: str + productSeries: + description: Device series. + type: str + productType: + description: Device type. + type: str + type: list + id: + description: UUID of template. + type: str + language: + description: Template language (JINJA or VELOCITY). + type: str + name: + description: Name of template. + type: str + projectName: + description: Project name. + type: str + rollbackTemplateParams: + description: Configuration Template's rollbackTemplateParams. + elements: dict + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template's range. + elements: dict + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + required: + description: Is param required. + type: bool + selection: + description: Configuration Template's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + tags: + description: Configuration Template's tags. + elements: dict + suboptions: + id: + description: UUID of tag. + type: str + name: + description: Name of tag. + type: str + type: list + templateContent: + description: Template content. + type: str + templateParams: + description: Configuration Template's templateParams. + elements: dict + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template's range. + elements: dict + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + required: + description: Is param required. + type: bool + selection: + description: Configuration Template's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + version: + description: Current version of template. + type: str + type: list + createTime: + description: Create time of template. + type: int + customParamsOrder: + description: Custom Params Order. + type: bool + description: + description: Description of template. + type: str + deviceTypes: + description: Configuration Template's deviceTypes. + elements: dict + suboptions: + productFamily: + description: Device family. + type: str + productSeries: + description: Device series. + type: str + productType: + description: Device type. + type: str + type: list + failurePolicy: + description: Define failure policy if template provisioning fails. + type: str + id: + description: UUID of template. + type: str + language: + description: Template language (JINJA or VELOCITY). + type: str + lastUpdateTime: + description: Update time of template. + type: int + latestVersionTime: + description: Latest versioned template time. + type: int + name: + description: Name of template. + type: str + parentTemplateId: + description: Parent templateID. + type: str + projectId: + description: Project UUID. + type: str + projectName: + description: Project name. + type: str + rollbackTemplateContent: + description: Rollback template content. + type: str + rollbackTemplateParams: + description: Configuration Template's rollbackTemplateParams. + elements: dict + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template's range. + elements: dict + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + required: + description: Is param required. + type: bool + selection: + description: Configuration Template's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + softwareType: + description: Applicable device software type. + type: str + softwareVariant: + description: Applicable device software variant. + type: str + softwareVersion: + description: Applicable device software version. + type: str + tags: + description: Configuration Template's tags. + elements: dict + suboptions: + id: + description: UUID of tag. + type: str + name: + description: Name of tag. + type: str + type: list + templateContent: + description: Template content. + type: str + templateId: + description: TemplateId path parameter. TemplateId(UUID) of template to be deleted. + type: str + templateParams: + description: Configuration Template's templateParams. + elements: dict + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template's range. + elements: dict + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + required: + description: Is param required. + type: bool + selection: + description: Configuration Template's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + validationErrors: + description: Configuration Template's validationErrors. + suboptions: + rollbackTemplateErrors: + description: Validation or design conflicts errors of rollback template. + type: dict + templateErrors: + description: Validation or design conflicts errors. + type: dict + templateId: + description: UUID of template. + type: str + templateVersion: + description: Current version of template. + type: str + type: dict + version: + description: Current version of template. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Templates DeletesTheTemplate + description: Complete reference of the DeletesTheTemplate API. + link: https://developer.cisco.com/docs/dna-center/#!deletes-the-template +- name: Cisco DNA Center documentation for Configuration Templates UpdateTemplate + description: Complete reference of the UpdateTemplate API. + link: https://developer.cisco.com/docs/dna-center/#!update-template +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.deletes_the_template, + configuration_templates.ConfigurationTemplates.update_template, + + - Paths used are + delete /dna/intent/api/v1/template-programmer/template/{templateId}, + put /dna/intent/api/v1/template-programmer/template, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.configuration_template: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + author: string + composite: true + containingTemplates: + - composite: true + description: string + deviceTypes: + - productFamily: string + productSeries: string + productType: string + id: string + language: string + name: string + projectName: string + rollbackTemplateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + tags: + - id: string + name: string + templateContent: string + templateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + version: string + createTime: 0 + customParamsOrder: true + description: string + deviceTypes: + - productFamily: string + productSeries: string + productType: string + failurePolicy: string + id: string + language: string + lastUpdateTime: 0 + latestVersionTime: 0 + name: string + parentTemplateId: string + projectId: string + projectName: string + rollbackTemplateContent: string + rollbackTemplateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + softwareType: string + softwareVariant: string + softwareVersion: string + tags: + - id: string + name: string + templateContent: string + templateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + validationErrors: + rollbackTemplateErrors: {} + templateErrors: {} + templateId: string + templateVersion: string + version: string + +- name: Delete by id + cisco.dnac.configuration_template: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + templateId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/configuration_template_clone.py b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_clone.py new file mode 100644 index 000000000..be0a5c1cb --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_clone.py @@ -0,0 +1,75 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: configuration_template_clone +short_description: Resource module for Configuration Template Clone +description: +- Manage operation create of the resource Configuration Template Clone. +- API to clone template. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + name: + description: Name path parameter. Template name to clone template(Name should be + different than existing template name within same project). + type: str + projectId: + description: ProjectId query parameter. UUID of the project in which the template + needs to be created. + type: str + templateId: + description: TemplateId path parameter. UUID of the template to clone it. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Templates CreatesACloneOfTheGivenTemplate + description: Complete reference of the CreatesACloneOfTheGivenTemplate API. + link: https://developer.cisco.com/docs/dna-center/#!creates-a-clone-of-the-given-template +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.clone_given_template, + + - Paths used are + post /dna/intent/api/v1/template-programmer/clone/name/{name}/project/{projectId}/template/{templateId}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.configuration_template_clone: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + name: string + projectId: string + templateId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/configuration_template_create.py b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_create.py new file mode 100644 index 000000000..4bb6a9a7b --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_create.py @@ -0,0 +1,708 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: configuration_template_create +short_description: Resource module for Configuration Template Create +description: +- Manage operation create of the resource Configuration Template Create. +- API to create a template by project id. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + author: + description: Author of template. + type: str + composite: + description: Is it composite template. + type: bool + containingTemplates: + description: Configuration Template Create's containingTemplates. + elements: dict + suboptions: + composite: + description: Is it composite template. + type: bool + description: + description: Description of template. + type: str + deviceTypes: + description: Configuration Template Create's deviceTypes. + elements: dict + suboptions: + productFamily: + description: Device family. + type: str + productSeries: + description: Device series. + type: str + productType: + description: Device type. + type: str + type: list + id: + description: UUID of template. + type: str + language: + description: Template language (JINJA or VELOCITY). + type: str + name: + description: Name of template. + type: str + projectName: + description: Project name. + type: str + rollbackTemplateParams: + description: Configuration Template Create's rollbackTemplateParams. + elements: dict + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template Create's range. + elements: dict + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + required: + description: Is param required. + type: bool + selection: + description: Configuration Template Create's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + tags: + description: Configuration Template Create's tags. + elements: dict + suboptions: + id: + description: UUID of tag. + type: str + name: + description: Name of tag. + type: str + type: list + templateContent: + description: Template content. + type: str + templateParams: + description: Configuration Template Create's templateParams. + elements: dict + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template Create's range. + elements: dict + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + required: + description: Is param required. + type: bool + selection: + description: Configuration Template Create's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + version: + description: Current version of template. + type: str + type: list + createTime: + description: Create time of template. + type: int + customParamsOrder: + description: Custom Params Order. + type: bool + description: + description: Description of template. + type: str + deviceTypes: + description: Configuration Template Create's deviceTypes. + elements: dict + suboptions: + productFamily: + description: Device family. + type: str + productSeries: + description: Device series. + type: str + productType: + description: Device type. + type: str + type: list + failurePolicy: + description: Define failure policy if template provisioning fails. + type: str + id: + description: UUID of template. + type: str + language: + description: Template language (JINJA or VELOCITY). + type: str + lastUpdateTime: + description: Update time of template. + type: int + latestVersionTime: + description: Latest versioned template time. + type: int + name: + description: Name of template. + type: str + parentTemplateId: + description: Parent templateID. + type: str + projectId: + description: Project UUID. + type: str + projectName: + description: Project name. + type: str + rollbackTemplateContent: + description: Rollback template content. + type: str + rollbackTemplateParams: + description: Configuration Template Create's rollbackTemplateParams. + elements: dict + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template Create's range. + elements: dict + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + required: + description: Is param required. + type: bool + selection: + description: Configuration Template Create's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + softwareType: + description: Applicable device software type. + type: str + softwareVariant: + description: Applicable device software variant. + type: str + softwareVersion: + description: Applicable device software version. + type: str + tags: + description: Configuration Template Create's tags. + elements: dict + suboptions: + id: + description: UUID of tag. + type: str + name: + description: Name of tag. + type: str + type: list + templateContent: + description: Template content. + type: str + templateParams: + description: Configuration Template Create's templateParams. + elements: dict + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template Create's range. + elements: dict + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + required: + description: Is param required. + type: bool + selection: + description: Configuration Template Create's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + validationErrors: + description: Configuration Template Create's validationErrors. + suboptions: + rollbackTemplateErrors: + description: Validation or design conflicts errors of rollback template. + type: dict + templateErrors: + description: Validation or design conflicts errors. + type: dict + templateId: + description: UUID of template. + type: str + templateVersion: + description: Current version of template. + type: str + type: dict + version: + description: Current version of template. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Templates CreateTemplate + description: Complete reference of the CreateTemplate API. + link: https://developer.cisco.com/docs/dna-center/#!create-template +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.create_template, + + - Paths used are + post /dna/intent/api/v1/template-programmer/project/{projectId}/template, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.configuration_template_create: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + author: string + composite: true + containingTemplates: + - composite: true + description: string + deviceTypes: + - productFamily: string + productSeries: string + productType: string + id: string + language: string + name: string + projectName: string + rollbackTemplateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + tags: + - id: string + name: string + templateContent: string + templateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + version: string + createTime: 0 + customParamsOrder: true + description: string + deviceTypes: + - productFamily: string + productSeries: string + productType: string + failurePolicy: string + id: string + language: string + lastUpdateTime: 0 + latestVersionTime: 0 + name: string + parentTemplateId: string + projectId: string + projectName: string + rollbackTemplateContent: string + rollbackTemplateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + softwareType: string + softwareVariant: string + softwareVersion: string + tags: + - id: string + name: string + templateContent: string + templateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + validationErrors: + rollbackTemplateErrors: {} + templateErrors: {} + templateId: string + templateVersion: string + version: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/configuration_template_deploy.py b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_deploy.py new file mode 100644 index 000000000..537fa850c --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_deploy.py @@ -0,0 +1,130 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: configuration_template_deploy +short_description: Resource module for Configuration Template Deploy +description: +- Manage operation create of the resource Configuration Template Deploy. +- API to deploy a template. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + forcePushTemplate: + description: ForcePushTemplate flag. + type: bool + isComposite: + description: Composite template flag. + type: bool + mainTemplateId: + description: Main template UUID of versioned template. + type: str + memberTemplateDeploymentInfo: + description: MemberTemplateDeploymentInfo. + type: str + targetInfo: + description: Configuration Template Deploy's targetInfo. + elements: dict + suboptions: + hostName: + description: Hostname of device is required if targetType is MANAGED_DEVICE_HOSTNAME. + type: str + id: + description: UUID of target is required if targetType is MANAGED_DEVICE_UUID. + type: str + params: + description: Template params/values to be provisioned. + type: dict + resourceParams: + description: Resource params to be provisioned. + type: dict + type: + description: Target type of device. + type: str + versionedTemplateId: + description: Versioned templateUUID to be provisioned. + type: str + type: list + templateId: + description: UUID of template to be provisioned. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Templates DeployTemplate + description: Complete reference of the DeployTemplate API. + link: https://developer.cisco.com/docs/dna-center/#!deploy-template +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.deploy_template, + + - Paths used are + post /dna/intent/api/v1/template-programmer/template/deploy, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.configuration_template_deploy: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + forcePushTemplate: true + isComposite: true + mainTemplateId: string + memberTemplateDeploymentInfo: string + targetInfo: + - hostName: string + id: string + params: {} + resourceParams: {} + type: string + versionedTemplateId: string + templateId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "deploymentId": "string", + "deploymentName": "string", + "devices": [ + { + "detailedStatusMessage": "string", + "deviceId": "string", + "duration": "string", + "endTime": "string", + "identifier": "string", + "ipAddress": "string", + "name": "string", + "startTime": "string", + "status": "string", + "targetType": "string" + } + ], + "duration": "string", + "endTime": "string", + "projectName": "string", + "startTime": "string", + "status": "string", + "statusMessage": "string", + "templateName": "string", + "templateVersion": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/configuration_template_deploy_status_info.py b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_deploy_status_info.py new file mode 100644 index 000000000..21fd83a51 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_deploy_status_info.py @@ -0,0 +1,90 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: configuration_template_deploy_status_info +short_description: Information module for Configuration Template Deploy Status +description: +- Get Configuration Template Deploy Status by id. +- API to retrieve the status of template deployment. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deploymentId: + description: + - DeploymentId path parameter. UUID of deployment to retrieve template deployment status. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Templates StatusOfTemplateDeployment + description: Complete reference of the StatusOfTemplateDeployment API. + link: https://developer.cisco.com/docs/dna-center/#!status-of-template-deployment +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.get_template_deployment_status, + + - Paths used are + get /dna/intent/api/v1/template-programmer/template/deploy/status/{deploymentId}, + +""" + +EXAMPLES = r""" +- name: Get Configuration Template Deploy Status by id + cisco.dnac.configuration_template_deploy_status_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deploymentId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "deploymentId": "string", + "deploymentName": "string", + "devices": [ + { + "detailedStatusMessage": "string", + "deviceId": "string", + "duration": "string", + "endTime": "string", + "identifier": "string", + "ipAddress": "string", + "name": "string", + "startTime": "string", + "status": "string", + "targetType": "string" + } + ], + "duration": "string", + "endTime": "string", + "projectName": "string", + "startTime": "string", + "status": "string", + "statusMessage": "string", + "templateName": "string", + "templateVersion": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/configuration_template_deploy_v2.py b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_deploy_v2.py new file mode 100644 index 000000000..399441706 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_deploy_v2.py @@ -0,0 +1,111 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: configuration_template_deploy_v2 +short_description: Resource module for Configuration Template Deploy V2 +description: +- Manage operation create of the resource Configuration Template Deploy V2. +- V2 API to deploy a template. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + forcePushTemplate: + description: ForcePushTemplate flag. + type: bool + isComposite: + description: Composite template flag. + type: bool + mainTemplateId: + description: Main template UUID of versioned template. + type: str + memberTemplateDeploymentInfo: + description: MemberTemplateDeploymentInfo. + type: str + targetInfo: + description: Configuration Template Deploy V2's targetInfo. + elements: dict + suboptions: + hostName: + description: Hostname of device is required if targetType is MANAGED_DEVICE_HOSTNAME. + type: str + id: + description: UUID of target is required if targetType is MANAGED_DEVICE_UUID. + type: str + params: + description: Template params/values to be provisioned. + type: dict + resourceParams: + description: Resource params to be provisioned. + type: dict + type: + description: Target type of device. + type: str + versionedTemplateId: + description: Versioned templateUUID to be provisioned. + type: str + type: list + templateId: + description: UUID of template to be provisioned. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Templates DeployTemplateV2 + description: Complete reference of the DeployTemplateV2 API. + link: https://developer.cisco.com/docs/dna-center/#!deploy-template-v-2 +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.deploy_template_v2, + + - Paths used are + post /dna/intent/api/v2/template-programmer/template/deploy, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.configuration_template_deploy_v2: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + forcePushTemplate: true + isComposite: true + mainTemplateId: string + memberTemplateDeploymentInfo: string + targetInfo: + - hostName: string + id: string + params: {} + resourceParams: {} + type: string + versionedTemplateId: string + templateId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/configuration_template_export_project.py b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_export_project.py new file mode 100644 index 000000000..377f4fbeb --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_export_project.py @@ -0,0 +1,67 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: configuration_template_export_project +short_description: Resource module for Configuration Template Export Project +description: +- Manage operation create of the resource Configuration Template Export Project. +- Exports the projects for given projectNames. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + payload: + description: Configuration Template Export Project's payload. + elements: dict + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Templates ExportsTheProjectsForAGivenCriteria + description: Complete reference of the ExportsTheProjectsForAGivenCriteria API. + link: https://developer.cisco.com/docs/dna-center/#!exports-the-projects-for-a-given-criteria +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.export_projects, + + - Paths used are + post /dna/intent/api/v1/template-programmer/project/name/exportprojects, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.configuration_template_export_project: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + payload: + - {} + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/configuration_template_export_template.py b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_export_template.py new file mode 100644 index 000000000..df4a58323 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_export_template.py @@ -0,0 +1,67 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: configuration_template_export_template +short_description: Resource module for Configuration Template Export Template +description: +- Manage operation create of the resource Configuration Template Export Template. +- Exports the templates for given templateIds. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + payload: + description: Configuration Template Export Template's payload. + elements: dict + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Templates ExportsTheTemplatesForAGivenCriteria + description: Complete reference of the ExportsTheTemplatesForAGivenCriteria API. + link: https://developer.cisco.com/docs/dna-center/#!exports-the-templates-for-a-given-criteria +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.export_templates, + + - Paths used are + post /dna/intent/api/v1/template-programmer/template/exporttemplates, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.configuration_template_export_template: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + payload: + - {} + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/configuration_template_import_project.py b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_import_project.py new file mode 100644 index 000000000..284665863 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_import_project.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: configuration_template_import_project +short_description: Resource module for Configuration Template Import Project +description: +- Manage operation create of the resource Configuration Template Import Project. +- Imports the Projects provided in the DTO. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + doVersion: + description: DoVersion query parameter. If this flag is true then it creates a new + version of the template with the imported contents in case if the templates already + exists. " If this flag is false and if template already exists, then operation + fails with 'Template already exists' error. + type: bool +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Templates ImportsTheProjectsProvided + description: Complete reference of the ImportsTheProjectsProvided API. + link: https://developer.cisco.com/docs/dna-center/#!imports-the-projects-provided +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.imports_the_projects_provided, + + - Paths used are + post /dna/intent/api/v1/template-programmer/project/importprojects, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.configuration_template_import_project: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + doVersion: true + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/configuration_template_import_template.py b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_import_template.py new file mode 100644 index 000000000..fc612c50f --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_import_template.py @@ -0,0 +1,726 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: configuration_template_import_template +short_description: Resource module for Configuration Template Import Template +description: +- Manage operation create of the resource Configuration Template Import Template. +- Imports the templates provided in the DTO by project Name. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + doVersion: + description: DoVersion query parameter. If this flag is true then it creates a new + version of the template with the imported contents in case if the templates already + exists. " If this flag is false and if template already exists, then operation + fails with 'Template already exists' error. + type: bool + payload: + description: Configuration Template Import Template's payload. + elements: dict + suboptions: + author: + description: Author of template. + type: str + composite: + description: Is it composite template. + type: bool + containingTemplates: + description: Configuration Template Import Template's containingTemplates. + elements: dict + suboptions: + composite: + description: Is it composite template. + type: bool + description: + description: Description of template. + type: str + deviceTypes: + description: Configuration Template Import Template's deviceTypes. + elements: dict + suboptions: + productFamily: + description: Device family. + type: str + productSeries: + description: Device series. + type: str + productType: + description: Device type. + type: str + type: list + id: + description: UUID of template. + type: str + language: + description: Template language (JINJA or VELOCITY). + type: str + name: + description: Name of template. + type: str + projectName: + description: Project name. + type: str + rollbackTemplateParams: + description: Configuration Template Import Template's rollbackTemplateParams. + elements: dict + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template Import Template's range. + elements: dict + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + required: + description: Is param required. + type: bool + selection: + description: Configuration Template Import Template's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + tags: + description: Configuration Template Import Template's tags. + elements: dict + suboptions: + id: + description: UUID of tag. + type: str + name: + description: Name of tag. + type: str + type: list + templateContent: + description: Template content. + type: str + templateParams: + description: Configuration Template Import Template's templateParams. + elements: dict + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template Import Template's range. + elements: dict + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + required: + description: Is param required. + type: bool + selection: + description: Configuration Template Import Template's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + version: + description: Current version of template. + type: str + type: list + createTime: + description: Create time of template. + type: int + customParamsOrder: + description: Custom Params Order. + type: bool + description: + description: Description of template. + type: str + deviceTypes: + description: Configuration Template Import Template's deviceTypes. + elements: dict + suboptions: + productFamily: + description: Device family. + type: str + productSeries: + description: Device series. + type: str + productType: + description: Device type. + type: str + type: list + failurePolicy: + description: Define failure policy if template provisioning fails. + type: str + id: + description: UUID of template. + type: str + language: + description: Template language (JINJA or VELOCITY). + type: str + lastUpdateTime: + description: Update time of template. + type: int + latestVersionTime: + description: Latest versioned template time. + type: int + name: + description: Name of template. + type: str + parentTemplateId: + description: Parent templateID. + type: str + projectId: + description: Project UUID. + type: str + projectName: + description: Project name. + type: str + rollbackTemplateContent: + description: Rollback template content. + type: str + rollbackTemplateParams: + description: Configuration Template Import Template's rollbackTemplateParams. + elements: dict + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template Import Template's range. + elements: dict + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + required: + description: Is param required. + type: bool + selection: + description: Configuration Template Import Template's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + softwareType: + description: Applicable device software type. + type: str + softwareVariant: + description: Applicable device software variant. + type: str + softwareVersion: + description: Applicable device software version. + type: str + tags: + description: Configuration Template Import Template's tags. + elements: dict + suboptions: + id: + description: UUID of tag. + type: str + name: + description: Name of tag. + type: str + type: list + templateContent: + description: Template content. + type: str + templateParams: + description: Configuration Template Import Template's templateParams. + elements: dict + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template Import Template's range. + elements: dict + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + required: + description: Is param required. + type: bool + selection: + description: Configuration Template Import Template's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + validationErrors: + description: Configuration Template Import Template's validationErrors. + suboptions: + rollbackTemplateErrors: + description: Validation or design conflicts errors of rollback template. + type: dict + templateErrors: + description: Validation or design conflicts errors. + type: dict + templateId: + description: UUID of template. + type: str + templateVersion: + description: Current version of template. + type: str + type: dict + version: + description: Current version of template. + type: str + type: list + projectName: + description: ProjectName path parameter. Project name to create template under the + project. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Templates ImportsTheTemplatesProvided + description: Complete reference of the ImportsTheTemplatesProvided API. + link: https://developer.cisco.com/docs/dna-center/#!imports-the-templates-provided +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.imports_the_templates_provided, + + - Paths used are + post /dna/intent/api/v1/template-programmer/project/name/{projectName}/template/importtemplates, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.configuration_template_import_template: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + doVersion: true + payload: + - author: string + composite: true + containingTemplates: + - composite: true + description: string + deviceTypes: + - productFamily: string + productSeries: string + productType: string + id: string + language: string + name: string + projectName: string + rollbackTemplateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + tags: + - id: string + name: string + templateContent: string + templateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + version: string + createTime: 0 + customParamsOrder: true + description: string + deviceTypes: + - productFamily: string + productSeries: string + productType: string + failurePolicy: string + id: string + language: string + lastUpdateTime: 0 + latestVersionTime: 0 + name: string + parentTemplateId: string + projectId: string + projectName: string + rollbackTemplateContent: string + rollbackTemplateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + softwareType: string + softwareVariant: string + softwareVersion: string + tags: + - id: string + name: string + templateContent: string + templateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + validationErrors: + rollbackTemplateErrors: {} + templateErrors: {} + templateId: string + templateVersion: string + version: string + projectName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/configuration_template_info.py b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_info.py new file mode 100644 index 000000000..993d2e0b5 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_info.py @@ -0,0 +1,351 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: configuration_template_info +short_description: Information module for Configuration Template +description: +- Get all Configuration Template. +- Get Configuration Template by id. +- Details of the template by its id. +- List the templates available. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + projectId: + description: + - ProjectId query parameter. Filter template(s) based on project UUID. + type: str + softwareType: + description: + - SoftwareType query parameter. Filter template(s) based software type. + type: str + softwareVersion: + description: + - SoftwareVersion query parameter. Filter template(s) based softwareVersion. + type: str + productFamily: + description: + - ProductFamily query parameter. Filter template(s) based on device family. + type: str + productSeries: + description: + - ProductSeries query parameter. Filter template(s) based on device series. + type: str + productType: + description: + - ProductType query parameter. Filter template(s) based on device type. + type: str + filterConflictingTemplates: + description: + - FilterConflictingTemplates query parameter. Filter template(s) based on confliting templates. + type: bool + tags: + description: + - Tags query parameter. Filter template(s) based on tags. + elements: str + type: list + projectNames: + description: + - ProjectNames query parameter. Filter template(s) based on project names. + elements: str + type: list + unCommitted: + description: + - UnCommitted query parameter. Filter template(s) based on template commited or not. + type: bool + sortOrder: + description: + - SortOrder query parameter. Sort Order Ascending (asc) or Descending (des). + type: str + templateId: + description: + - TemplateId path parameter. TemplateId(UUID) to get details of the template. + type: str + latestVersion: + description: + - LatestVersion query parameter. LatestVersion flag to get the latest versioned template. + type: bool +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Templates GetsDetailsOfAGivenTemplate + description: Complete reference of the GetsDetailsOfAGivenTemplate API. + link: https://developer.cisco.com/docs/dna-center/#!gets-details-of-a-given-template +- name: Cisco DNA Center documentation for Configuration Templates GetsTheTemplatesAvailable + description: Complete reference of the GetsTheTemplatesAvailable API. + link: https://developer.cisco.com/docs/dna-center/#!gets-the-templates-available +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.get_template_details, + configuration_templates.ConfigurationTemplates.gets_the_templates_available, + + - Paths used are + get /dna/intent/api/v1/template-programmer/template, + get /dna/intent/api/v1/template-programmer/template/{templateId}, + +""" + +EXAMPLES = r""" +- name: Get all Configuration Template + cisco.dnac.configuration_template_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + projectId: string + softwareType: string + softwareVersion: string + productFamily: string + productSeries: string + productType: string + filterConflictingTemplates: True + tags: [] + projectNames: [] + unCommitted: True + sortOrder: string + register: result + +- name: Get Configuration Template by id + cisco.dnac.configuration_template_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + latestVersion: True + templateId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "tags": [ + { + "id": "string", + "name": "string" + } + ], + "author": "string", + "composite": true, + "containingTemplates": [ + { + "tags": [ + { + "id": "string", + "name": "string" + } + ], + "composite": true, + "description": "string", + "deviceTypes": [ + { + "productFamily": "string", + "productSeries": "string", + "productType": "string" + } + ], + "id": "string", + "language": "string", + "name": "string", + "projectName": "string", + "rollbackTemplateParams": [ + { + "binding": "string", + "customOrder": 0, + "dataType": "string", + "defaultValue": "string", + "description": "string", + "displayName": "string", + "group": "string", + "id": "string", + "instructionText": "string", + "key": "string", + "notParam": true, + "order": 0, + "paramArray": true, + "parameterName": "string", + "provider": "string", + "range": [ + { + "id": "string", + "maxValue": 0, + "minValue": 0 + } + ], + "required": true, + "selection": { + "defaultSelectedValues": [ + "string" + ], + "id": "string", + "selectionType": "string", + "selectionValues": {} + } + } + ], + "templateContent": "string", + "templateParams": [ + { + "binding": "string", + "customOrder": 0, + "dataType": "string", + "defaultValue": "string", + "description": "string", + "displayName": "string", + "group": "string", + "id": "string", + "instructionText": "string", + "key": "string", + "notParam": true, + "order": 0, + "paramArray": true, + "parameterName": "string", + "provider": "string", + "range": [ + { + "id": "string", + "maxValue": 0, + "minValue": 0 + } + ], + "required": true, + "selection": { + "defaultSelectedValues": [ + "string" + ], + "id": "string", + "selectionType": "string", + "selectionValues": {} + } + } + ], + "version": "string" + } + ], + "createTime": 0, + "customParamsOrder": true, + "description": "string", + "deviceTypes": [ + { + "productFamily": "string", + "productSeries": "string", + "productType": "string" + } + ], + "failurePolicy": "string", + "id": "string", + "language": "string", + "lastUpdateTime": 0, + "latestVersionTime": 0, + "name": "string", + "parentTemplateId": "string", + "projectId": "string", + "projectName": "string", + "rollbackTemplateContent": "string", + "rollbackTemplateParams": [ + { + "binding": "string", + "customOrder": 0, + "dataType": "string", + "defaultValue": "string", + "description": "string", + "displayName": "string", + "group": "string", + "id": "string", + "instructionText": "string", + "key": "string", + "notParam": true, + "order": 0, + "paramArray": true, + "parameterName": "string", + "provider": "string", + "range": [ + { + "id": "string", + "maxValue": 0, + "minValue": 0 + } + ], + "required": true, + "selection": { + "defaultSelectedValues": [ + "string" + ], + "id": "string", + "selectionType": "string", + "selectionValues": {} + } + } + ], + "softwareType": "string", + "softwareVariant": "string", + "softwareVersion": "string", + "templateContent": "string", + "templateParams": [ + { + "binding": "string", + "customOrder": 0, + "dataType": "string", + "defaultValue": "string", + "description": "string", + "displayName": "string", + "group": "string", + "id": "string", + "instructionText": "string", + "key": "string", + "notParam": true, + "order": 0, + "paramArray": true, + "parameterName": "string", + "provider": "string", + "range": [ + { + "id": "string", + "maxValue": 0, + "minValue": 0 + } + ], + "required": true, + "selection": { + "defaultSelectedValues": [ + "string" + ], + "id": "string", + "selectionType": "string", + "selectionValues": {} + } + } + ], + "validationErrors": { + "rollbackTemplateErrors": {}, + "templateErrors": {}, + "templateId": "string", + "templateVersion": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/configuration_template_project.py b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_project.py new file mode 100644 index 000000000..518ac61f9 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_project.py @@ -0,0 +1,958 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: configuration_template_project +short_description: Resource module for Configuration Template Project +description: +- Manage operations create, update and delete of the resource Configuration Template Project. +- This API is used to create a new project. +- Deletes the project by its id. +- This API is used to update an existing project. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + createTime: + description: Create time of project. + type: int + description: + description: Description of project. + type: str + id: + description: UUID of project. + type: str + lastUpdateTime: + description: Update time of project. + type: int + name: + description: Name of project. + type: str + projectId: + description: ProjectId path parameter. ProjectId(UUID) of project to be deleted. + type: str + tags: + description: Configuration Template Project's tags. + elements: dict + suboptions: + id: + description: UUID of tag. + type: str + name: + description: Name of tag. + type: str + type: list + templates: + description: List of templates within the project. + elements: dict + suboptions: + author: + description: Author of template. + type: str + composite: + description: Is it composite template. + type: bool + containingTemplates: + description: Configuration Template Project's containingTemplates. + elements: dict + suboptions: + composite: + description: Is it composite template. + type: bool + description: + description: Description of template. + type: str + deviceTypes: + description: Configuration Template Project's deviceTypes. + elements: dict + suboptions: + productFamily: + description: Device family. + type: str + productSeries: + description: Device series. + type: str + productType: + description: Device type. + type: str + type: list + id: + description: UUID of template. + type: str + language: + description: Template language (JINJA or VELOCITY). + type: str + name: + description: Name of template. + type: str + projectName: + description: Project name. + type: str + rollbackTemplateParams: + description: Configuration Template Project's rollbackTemplateParams. + elements: dict + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template Project's range. + elements: dict + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + required: + description: Is param required. + type: bool + selection: + description: Configuration Template Project's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + tags: + description: Configuration Template Project's tags. + elements: dict + suboptions: + id: + description: UUID of tag. + type: str + name: + description: Name of tag. + type: str + type: list + templateContent: + description: Template content. + type: str + templateParams: + description: Configuration Template Project's templateParams. + elements: dict + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template Project's range. + elements: dict + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + required: + description: Is param required. + type: bool + selection: + description: Configuration Template Project's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + version: + description: Current version of template. + type: str + type: list + createTime: + description: Create time of template. + type: int + customParamsOrder: + description: Custom Params Order. + type: bool + description: + description: Description of template. + type: str + deviceTypes: + description: Configuration Template Project's deviceTypes. + elements: dict + suboptions: + productFamily: + description: Device family. + type: str + productSeries: + description: Device series. + type: str + productType: + description: Device type. + type: str + type: list + failurePolicy: + description: Define failure policy if template provisioning fails. + type: str + id: + description: UUID of template. + type: str + language: + description: Template language (JINJA or VELOCITY). + type: str + lastUpdateTime: + description: Update time of template. + type: int + latestVersionTime: + description: Latest versioned template time. + type: int + name: + description: Name of template. + type: str + parentTemplateId: + description: Parent templateID. + type: str + projectId: + description: Project UUID. + type: str + projectName: + description: Project name. + type: str + rollbackTemplateContent: + description: Rollback template content. + type: str + rollbackTemplateParams: + description: Configuration Template Project's rollbackTemplateParams. + elements: dict + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template Project's range. + elements: dict + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + required: + description: Is param required. + type: bool + selection: + description: Configuration Template Project's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + softwareType: + description: Applicable device software type. + type: str + softwareVariant: + description: Applicable device software variant. + type: str + softwareVersion: + description: Applicable device software version. + type: str + tags: + description: Configuration Template Project's tags. + elements: dict + suboptions: + id: + description: UUID of tag. + type: str + name: + description: Name of tag. + type: str + type: list + templateContent: + description: Template content. + type: str + templateParams: + description: Configuration Template Project's templateParams. + elements: dict + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template Project's range. + elements: dict + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + required: + description: Is param required. + type: bool + selection: + description: Configuration Template Project's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + validationErrors: + description: Configuration Template Project's validationErrors. + suboptions: + rollbackTemplateErrors: + description: Validation or design conflicts errors of rollback template. + elements: dict + type: list + templateErrors: + description: Validation or design conflicts errors. + elements: dict + type: list + templateId: + description: UUID of template. + type: str + templateVersion: + description: Current version of template. + type: str + type: dict + version: + description: Current version of template. + type: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Templates CreateProject + description: Complete reference of the CreateProject API. + link: https://developer.cisco.com/docs/dna-center/#!create-project +- name: Cisco DNA Center documentation for Configuration Templates DeletesTheProject + description: Complete reference of the DeletesTheProject API. + link: https://developer.cisco.com/docs/dna-center/#!deletes-the-project +- name: Cisco DNA Center documentation for Configuration Templates UpdateProject + description: Complete reference of the UpdateProject API. + link: https://developer.cisco.com/docs/dna-center/#!update-project +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.create_project, + configuration_templates.ConfigurationTemplates.deletes_the_project, + configuration_templates.ConfigurationTemplates.update_project, + + - Paths used are + post /dna/intent/api/v1/template-programmer/project, + delete /dna/intent/api/v1/template-programmer/project/{projectId}, + put /dna/intent/api/v1/template-programmer/project, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.configuration_template_project: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + createTime: 0 + description: string + id: string + lastUpdateTime: 0 + name: string + tags: + - id: string + name: string + templates: + - author: string + composite: true + containingTemplates: + - composite: true + description: string + deviceTypes: + - productFamily: string + productSeries: string + productType: string + id: string + language: string + name: string + projectName: string + rollbackTemplateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + tags: + - id: string + name: string + templateContent: string + templateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + version: string + createTime: 0 + customParamsOrder: true + description: string + deviceTypes: + - productFamily: string + productSeries: string + productType: string + failurePolicy: string + id: string + language: string + lastUpdateTime: 0 + latestVersionTime: 0 + name: string + parentTemplateId: string + projectId: string + projectName: string + rollbackTemplateContent: string + rollbackTemplateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + softwareType: string + softwareVariant: string + softwareVersion: string + tags: + - id: string + name: string + templateContent: string + templateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + validationErrors: + rollbackTemplateErrors: + - {} + templateErrors: + - {} + templateId: string + templateVersion: string + version: string + +- name: Update all + cisco.dnac.configuration_template_project: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + createTime: 0 + description: string + id: string + lastUpdateTime: 0 + name: string + tags: + - id: string + name: string + templates: + - author: string + composite: true + containingTemplates: + - composite: true + description: string + deviceTypes: + - productFamily: string + productSeries: string + productType: string + id: string + language: string + name: string + projectName: string + rollbackTemplateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + tags: + - id: string + name: string + templateContent: string + templateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + version: string + createTime: 0 + customParamsOrder: true + description: string + deviceTypes: + - productFamily: string + productSeries: string + productType: string + failurePolicy: string + id: string + language: string + lastUpdateTime: 0 + latestVersionTime: 0 + name: string + parentTemplateId: string + projectId: string + projectName: string + rollbackTemplateContent: string + rollbackTemplateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + softwareType: string + softwareVariant: string + softwareVersion: string + tags: + - id: string + name: string + templateContent: string + templateParams: + - binding: string + customOrder: 0 + dataType: string + defaultValue: string + description: string + displayName: string + group: string + id: string + instructionText: string + key: string + notParam: true + order: 0 + paramArray: true + parameterName: string + provider: string + range: + - id: string + maxValue: 0 + minValue: 0 + required: true + selection: + defaultSelectedValues: + - string + id: string + selectionType: string + selectionValues: {} + validationErrors: + rollbackTemplateErrors: + - {} + templateErrors: + - {} + templateId: string + templateVersion: string + version: string + +- name: Delete by id + cisco.dnac.configuration_template_project: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + projectId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/configuration_template_project_info.py b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_project_info.py new file mode 100644 index 000000000..d5d60407f --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_project_info.py @@ -0,0 +1,314 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: configuration_template_project_info +short_description: Information module for Configuration Template Project +description: +- Get all Configuration Template Project. +- Get Configuration Template Project by id. +- Get the details of the given project by its id. +- List the projects. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + name: + description: + - Name query parameter. Name of project to be searched. + type: str + sortOrder: + description: + - SortOrder query parameter. Sort Order Ascending (asc) or Descending (des). + type: str + projectId: + description: + - ProjectId path parameter. ProjectId(UUID) of project to get project details. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Templates GetsAListOfProjects + description: Complete reference of the GetsAListOfProjects API. + link: https://developer.cisco.com/docs/dna-center/#!gets-a-list-of-projects +- name: Cisco DNA Center documentation for Configuration Templates GetsTheDetailsOfAGivenProject + description: Complete reference of the GetsTheDetailsOfAGivenProject API. + link: https://developer.cisco.com/docs/dna-center/#!gets-the-details-of-a-given-project +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.get_project_details, + configuration_templates.ConfigurationTemplates.get_projects, + + - Paths used are + get /dna/intent/api/v1/template-programmer/project, + get /dna/intent/api/v1/template-programmer/project/{projectId}, + +""" + +EXAMPLES = r""" +- name: Get all Configuration Template Project + cisco.dnac.configuration_template_project_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + name: string + sortOrder: string + register: result + +- name: Get Configuration Template Project by id + cisco.dnac.configuration_template_project_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + projectId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "tags": [ + { + "id": "string", + "name": "string" + } + ], + "createTime": 0, + "description": "string", + "id": "string", + "lastUpdateTime": 0, + "name": "string", + "templates": [ + { + "tags": [ + { + "id": "string", + "name": "string" + } + ], + "author": "string", + "composite": true, + "containingTemplates": [ + { + "tags": [ + { + "id": "string", + "name": "string" + } + ], + "composite": true, + "description": "string", + "deviceTypes": [ + { + "productFamily": "string", + "productSeries": "string", + "productType": "string" + } + ], + "id": "string", + "language": "string", + "name": "string", + "projectName": "string", + "rollbackTemplateParams": [ + { + "binding": "string", + "customOrder": 0, + "dataType": "string", + "defaultValue": "string", + "description": "string", + "displayName": "string", + "group": "string", + "id": "string", + "instructionText": "string", + "key": "string", + "notParam": true, + "order": 0, + "paramArray": true, + "parameterName": "string", + "provider": "string", + "range": [ + { + "id": "string", + "maxValue": 0, + "minValue": 0 + } + ], + "required": true, + "selection": { + "defaultSelectedValues": [ + "string" + ], + "id": "string", + "selectionType": "string", + "selectionValues": {} + } + } + ], + "templateContent": "string", + "templateParams": [ + { + "binding": "string", + "customOrder": 0, + "dataType": "string", + "defaultValue": "string", + "description": "string", + "displayName": "string", + "group": "string", + "id": "string", + "instructionText": "string", + "key": "string", + "notParam": true, + "order": 0, + "paramArray": true, + "parameterName": "string", + "provider": "string", + "range": [ + { + "id": "string", + "maxValue": 0, + "minValue": 0 + } + ], + "required": true, + "selection": { + "defaultSelectedValues": [ + "string" + ], + "id": "string", + "selectionType": "string", + "selectionValues": {} + } + } + ], + "version": "string" + } + ], + "createTime": 0, + "customParamsOrder": true, + "description": "string", + "deviceTypes": [ + { + "productFamily": "string", + "productSeries": "string", + "productType": "string" + } + ], + "failurePolicy": "string", + "id": "string", + "language": "string", + "lastUpdateTime": 0, + "latestVersionTime": 0, + "name": "string", + "parentTemplateId": "string", + "projectId": "string", + "projectName": "string", + "rollbackTemplateContent": "string", + "rollbackTemplateParams": [ + { + "binding": "string", + "customOrder": 0, + "dataType": "string", + "defaultValue": "string", + "description": "string", + "displayName": "string", + "group": "string", + "id": "string", + "instructionText": "string", + "key": "string", + "notParam": true, + "order": 0, + "paramArray": true, + "parameterName": "string", + "provider": "string", + "range": [ + { + "id": "string", + "maxValue": 0, + "minValue": 0 + } + ], + "required": true, + "selection": { + "defaultSelectedValues": [ + "string" + ], + "id": "string", + "selectionType": "string", + "selectionValues": {} + } + } + ], + "softwareType": "string", + "softwareVariant": "string", + "softwareVersion": "string", + "templateContent": "string", + "templateParams": [ + { + "binding": "string", + "customOrder": 0, + "dataType": "string", + "defaultValue": "string", + "description": "string", + "displayName": "string", + "group": "string", + "id": "string", + "instructionText": "string", + "key": "string", + "notParam": true, + "order": 0, + "paramArray": true, + "parameterName": "string", + "provider": "string", + "range": [ + { + "id": "string", + "maxValue": 0, + "minValue": 0 + } + ], + "required": true, + "selection": { + "defaultSelectedValues": [ + "string" + ], + "id": "string", + "selectionType": "string", + "selectionValues": {} + } + } + ], + "validationErrors": { + "rollbackTemplateErrors": {}, + "templateErrors": {}, + "templateId": "string", + "templateVersion": "string" + }, + "version": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/configuration_template_version_create.py b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_version_create.py new file mode 100644 index 000000000..b3210a7c4 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_version_create.py @@ -0,0 +1,69 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: configuration_template_version_create +short_description: Resource module for Configuration Template Version Create +description: +- Manage operation create of the resource Configuration Template Version Create. +- API to version the current contents of the template. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + comments: + description: Template version comments. + type: str + templateId: + description: UUID of template. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Templates VersionTemplate + description: Complete reference of the VersionTemplate API. + link: https://developer.cisco.com/docs/dna-center/#!version-template +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.version_template, + + - Paths used are + post /dna/intent/api/v1/template-programmer/template/version, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.configuration_template_version_create: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + comments: string + templateId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/configuration_template_version_info.py b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_version_info.py new file mode 100644 index 000000000..0f6956651 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/configuration_template_version_info.py @@ -0,0 +1,84 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: configuration_template_version_info +short_description: Information module for Configuration Template Version +description: +- Get Configuration Template Version by id. +- Get all the versions of template by its id. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + templateId: + description: + - TemplateId path parameter. TemplateId(UUID) to get list of versioned templates. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Templates GetsAllTheVersionsOfAGivenTemplate + description: Complete reference of the GetsAllTheVersionsOfAGivenTemplate API. + link: https://developer.cisco.com/docs/dna-center/#!gets-all-the-versions-of-a-given-template +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.get_template_versions, + + - Paths used are + get /dna/intent/api/v1/template-programmer/template/version/{templateId}, + +""" + +EXAMPLES = r""" +- name: Get Configuration Template Version by id + cisco.dnac.configuration_template_version_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + templateId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "composite": true, + "name": "string", + "projectId": "string", + "projectName": "string", + "templateId": "string", + "versionsInfo": [ + { + "author": "string", + "description": "string", + "id": "string", + "version": "string", + "versionComment": "string", + "versionTime": 0 + } + ] + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/credential_to_site_by_siteid_create_v2.py b/ansible_collections/cisco/dnac/plugins/modules/credential_to_site_by_siteid_create_v2.py new file mode 100644 index 000000000..44f2a99db --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/credential_to_site_by_siteid_create_v2.py @@ -0,0 +1,89 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: credential_to_site_by_siteid_create_v2 +short_description: Resource module for Credential To Site By Siteid Create V2 +description: +- Manage operation create of the resource Credential To Site By Siteid Create V2. +- API to assign Device Credential to a site. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + cliId: + description: CLI Credential Id. + type: str + httpRead: + description: HTTP(S) Read Credential Id. + type: str + httpWrite: + description: HTTP(S) Write Credential Id. + type: str + siteId: + description: SiteId path parameter. Site Id to assign credential. + type: str + snmpV2ReadId: + description: SNMPv2c Read Credential Id. + type: str + snmpV2WriteId: + description: SNMPv2c Write Credential Id. + type: str + snmpV3Id: + description: SNMPv3 Credential Id. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings AssignDeviceCredentialToSiteV2 + description: Complete reference of the AssignDeviceCredentialToSiteV2 API. + link: https://developer.cisco.com/docs/dna-center/#!assign-device-credential-to-site-v-2 +notes: + - SDK Method used are + network_settings.NetworkSettings.assign_device_credential_to_site_v2, + + - Paths used are + post /dna/intent/api/v2/credential-to-site/{siteId}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.credential_to_site_by_siteid_create_v2: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + cliId: string + httpRead: string + httpWrite: string + siteId: string + snmpV2ReadId: string + snmpV2WriteId: string + snmpV3Id: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_configurations_export.py b/ansible_collections/cisco/dnac/plugins/modules/device_configurations_export.py new file mode 100644 index 000000000..8f761afc2 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_configurations_export.py @@ -0,0 +1,71 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_configurations_export +short_description: Resource module for Device Configurations Export +description: +- Manage operation create of the resource Device Configurations Export. +- Export Device configurations to an encrypted zip file. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + deviceId: + description: Device Id. + elements: str + type: list + password: + description: Password. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Archive ExportDeviceConfigurations + description: Complete reference of the ExportDeviceConfigurations API. + link: https://developer.cisco.com/docs/dna-center/#!export-device-configurations +notes: + - SDK Method used are + configuration_archive.ConfigurationArchive.export_device_configurations, + + - Paths used are + post /dna/intent/api/v1/network-device-archive/cleartext, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.device_configurations_export: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + deviceId: + - string + password: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_credential_create.py b/ansible_collections/cisco/dnac/plugins/modules/device_credential_create.py new file mode 100644 index 000000000..d5732808b --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_credential_create.py @@ -0,0 +1,192 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_credential_create +short_description: Resource module for Device Credential Create +description: +- Manage operation create of the resource Device Credential Create. +- API to create device credentials. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + settings: + description: Device Credential Create's settings. + suboptions: + cliCredential: + description: Device Credential Create's cliCredential. + elements: dict + suboptions: + description: + description: Name or description for CLI credential. + type: str + enablePassword: + description: Enable password for CLI credential. + type: str + password: + description: Password for CLI credential. + type: str + username: + description: User name for CLI credential. + type: str + type: list + httpsRead: + description: Device Credential Create's httpsRead. + elements: dict + suboptions: + name: + description: Name or description of http read credential. + type: str + password: + description: Password for http read credential. + type: str + port: + description: Port for http read credential. + type: int + username: + description: User name of the http read credential. + type: str + type: list + httpsWrite: + description: Device Credential Create's httpsWrite. + elements: dict + suboptions: + name: + description: Name or description of http write credential. + type: str + password: + description: Password for http write credential. + type: str + port: + description: Port for http write credential. + type: int + username: + description: User name of the http write credential. + type: str + type: list + snmpV2cRead: + description: Device Credential Create's snmpV2cRead. + elements: dict + suboptions: + description: + description: Description for snmp v2 read. + type: str + readCommunity: + description: Ready community for snmp v2 read credential. + type: str + type: list + snmpV2cWrite: + description: Device Credential Create's snmpV2cWrite. + elements: dict + suboptions: + description: + description: Description for snmp v2 write. + type: str + writeCommunity: + description: Write community for snmp v2 write credential. + type: str + type: list + snmpV3: + description: Device Credential Create's snmpV3. + elements: dict + suboptions: + authPassword: + description: Authentication password for snmpv3 credential. + type: str + authType: + description: Authentication type for snmpv3 credential. + type: str + description: + description: Name or description for SNMPV3 credential. + type: str + privacyPassword: + description: Privacy password for snmpv3 credential. + type: str + privacyType: + description: Privacy type for snmpv3 credential. + type: str + snmpMode: + description: Mode for snmpv3 credential. + type: str + username: + description: User name for SNMPv3 credential. + type: str + type: list + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings CreateDeviceCredentials + description: Complete reference of the CreateDeviceCredentials API. + link: https://developer.cisco.com/docs/dna-center/#!create-device-credentials +notes: + - SDK Method used are + network_settings.NetworkSettings.create_device_credentials, + + - Paths used are + post /dna/intent/api/v1/device-credential, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.device_credential_create: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + settings: + cliCredential: + - description: string + enablePassword: string + password: string + username: string + httpsRead: + - name: string + password: string + port: 0 + username: string + httpsWrite: + - name: string + password: string + port: 0 + username: string + snmpV2cRead: + - description: string + readCommunity: string + snmpV2cWrite: + - description: string + writeCommunity: string + snmpV3: + - authPassword: string + authType: string + description: string + privacyPassword: string + privacyType: string + snmpMode: string + username: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_credential_delete.py b/ansible_collections/cisco/dnac/plugins/modules/device_credential_delete.py new file mode 100644 index 000000000..42cd7bf9a --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_credential_delete.py @@ -0,0 +1,63 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_credential_delete +short_description: Resource module for Device Credential Delete +description: +- Manage operation delete of the resource Device Credential Delete. +- Delete device credential. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + id: + description: Id path parameter. Global credential id. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings DeleteDeviceCredential + description: Complete reference of the DeleteDeviceCredential API. + link: https://developer.cisco.com/docs/dna-center/#!delete-device-credential +notes: + - SDK Method used are + network_settings.NetworkSettings.delete_device_credential, + + - Paths used are + delete /dna/intent/api/v1/device-credential/{id}, + +""" + +EXAMPLES = r""" +- name: Delete by id + cisco.dnac.device_credential_delete: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + id: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_credential_info.py b/ansible_collections/cisco/dnac/plugins/modules/device_credential_info.py new file mode 100644 index 000000000..184d82056 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_credential_info.py @@ -0,0 +1,145 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_credential_info +short_description: Information module for Device Credential +description: +- Get all Device Credential. +- API to get device credential details. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + siteId: + description: + - SiteId query parameter. Site id to retrieve the credential details associated with the site. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings GetDeviceCredentialDetails + description: Complete reference of the GetDeviceCredentialDetails API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-credential-details +notes: + - SDK Method used are + network_settings.NetworkSettings.get_device_credential_details, + + - Paths used are + get /dna/intent/api/v1/device-credential, + +""" + +EXAMPLES = r""" +- name: Get all Device Credential + cisco.dnac.device_credential_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + siteId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "snmp_v3": [ + { + "username": "string", + "authPassword": "string", + "authType": "string", + "privacyPassword": "string", + "privacyType": "string", + "snmpMode": "string", + "comments": "string", + "description": "string", + "credentialType": "string", + "instanceUuid": "string", + "instanceTenantId": "string", + "id": "string" + } + ], + "http_read": [ + { + "secure": "string", + "username": "string", + "password": "string", + "port": "string", + "comments": "string", + "description": "string", + "credentialType": "string", + "instanceUuid": "string", + "instanceTenantId": "string", + "id": "string" + } + ], + "http_write": [ + { + "secure": "string", + "username": "string", + "password": "string", + "port": "string", + "comments": "string", + "description": "string", + "credentialType": "string", + "instanceUuid": "string", + "instanceTenantId": "string", + "id": "string" + } + ], + "snmp_v2_write": [ + { + "writeCommunity": "string", + "comments": "string", + "description": "string", + "credentialType": "string", + "instanceUuid": "string", + "instanceTenantId": "string", + "id": "string" + } + ], + "snmp_v2_read": [ + { + "readCommunity": "string", + "comments": "string", + "description": "string", + "credentialType": "string", + "instanceUuid": "string", + "instanceTenantId": "string", + "id": "string" + } + ], + "cli": [ + { + "username": "string", + "enablePassword": "string", + "password": "string", + "comments": "string", + "description": "string", + "credentialType": "string", + "instanceUuid": "string", + "instanceTenantId": "string", + "id": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_credential_update.py b/ansible_collections/cisco/dnac/plugins/modules/device_credential_update.py new file mode 100644 index 000000000..f17c18fbd --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_credential_update.py @@ -0,0 +1,210 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_credential_update +short_description: Resource module for Device Credential Update +description: +- Manage operation update of the resource Device Credential Update. +- API to update device credentials. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + settings: + description: Device Credential Update's settings. + suboptions: + cliCredential: + description: Device Credential Update's cliCredential. + suboptions: + description: + description: Description. + type: str + enablePassword: + description: Enable Password. + type: str + id: + description: Id. + type: str + password: + description: Password. + type: str + username: + description: Username. + type: str + type: dict + httpsRead: + description: Device Credential Update's httpsRead. + suboptions: + id: + description: Id. + type: str + name: + description: Name. + type: str + password: + description: Password. + type: str + port: + description: Port. + type: str + username: + description: Username. + type: str + type: dict + httpsWrite: + description: Device Credential Update's httpsWrite. + suboptions: + id: + description: Id. + type: str + name: + description: Name. + type: str + password: + description: Password. + type: str + port: + description: Port. + type: str + username: + description: Username. + type: str + type: dict + snmpV2cRead: + description: Device Credential Update's snmpV2cRead. + suboptions: + description: + description: Description. + type: str + id: + description: Id. + type: str + readCommunity: + description: Read Community. + type: str + type: dict + snmpV2cWrite: + description: Device Credential Update's snmpV2cWrite. + suboptions: + description: + description: Description. + type: str + id: + description: Id. + type: str + writeCommunity: + description: Write Community. + type: str + type: dict + snmpV3: + description: Device Credential Update's snmpV3. + suboptions: + authPassword: + description: Auth Password. + type: str + authType: + description: Auth Type. + type: str + description: + description: Description. + type: str + id: + description: Id. + type: str + privacyPassword: + description: Privacy Password. + type: str + privacyType: + description: Privacy Type. + type: str + snmpMode: + description: Snmp Mode. + type: str + username: + description: Username. + type: str + type: dict + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings UpdateDeviceCredentials + description: Complete reference of the UpdateDeviceCredentials API. + link: https://developer.cisco.com/docs/dna-center/#!update-device-credentials +notes: + - SDK Method used are + network_settings.NetworkSettings.update_device_credentials, + + - Paths used are + put /dna/intent/api/v1/device-credential, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.device_credential_update: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + settings: + cliCredential: + description: string + enablePassword: string + id: string + password: string + username: string + httpsRead: + id: string + name: string + password: string + port: string + username: string + httpsWrite: + id: string + name: string + password: string + port: string + username: string + snmpV2cRead: + description: string + id: string + readCommunity: string + snmpV2cWrite: + description: string + id: string + writeCommunity: string + snmpV3: + authPassword: string + authType: string + description: string + id: string + privacyPassword: string + privacyType: string + snmpMode: string + username: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/device_details_info.py new file mode 100644 index 000000000..108be2c42 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_details_info.py @@ -0,0 +1,120 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_details_info +short_description: Information module for Device Details +description: +- Get all Device Details. +- Returns detailed Network Device information retrieved by Mac Address, Device Name or UUID for any given point of time. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + timestamp: + description: + - Timestamp query parameter. Epoch time(in milliseconds) when the device data is required. + type: str + searchBy: + description: + - SearchBy query parameter. MAC Address or Device Name value or UUID of the network device. + type: str + identifier: + description: + - Identifier query parameter. One of keywords macAddress or uuid or nwDeviceName. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetDeviceDetail + description: Complete reference of the GetDeviceDetail API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-detail +notes: + - SDK Method used are + devices.Devices.get_device_detail, + + - Paths used are + get /dna/intent/api/v1/device-detail, + +""" + +EXAMPLES = r""" +- name: Get all Device Details + cisco.dnac.device_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + timestamp: string + searchBy: string + identifier: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "HALastResetReason": "string", + "managementIpAddr": "string", + "HAPrimaryPowerStatus": "string", + "redundancyMode": "string", + "communicationState": "string", + "nwDeviceName": "string", + "redundancyUnit": "string", + "platformId": "string", + "redundancyPeerState": "string", + "nwDeviceId": "string", + "redundancyState": "string", + "nwDeviceRole": "string", + "nwDeviceFamily": "string", + "macAddress": "string", + "collectionStatus": "string", + "deviceSeries": "string", + "osType": "string", + "clientCount": "string", + "HASecondaryPowerStatus": "string", + "softwareVersion": "string", + "nwDeviceType": "string", + "overallHealth": 0, + "memoryScore": 0, + "cpuScore": 0, + "noiseScore": 0, + "utilizationScore": 0, + "airQualityScore": 0, + "interferenceScore": 0, + "wqeScore": 0, + "freeMbufScore": 0, + "packetPoolScore": 0, + "freeTimerScore": 0, + "memory": "string", + "cpu": "string", + "noise": "string", + "utilization": "string", + "airQuality": "string", + "interference": "string", + "wqe": "string", + "freeMbuf": "string", + "packetPool": "string", + "freeTimer": "string", + "location": "string", + "timestamp": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_enrichment_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/device_enrichment_details_info.py new file mode 100644 index 000000000..c0be8c613 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_enrichment_details_info.py @@ -0,0 +1,143 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_enrichment_details_info +short_description: Information module for Device Enrichment Details +description: +- Get all Device Enrichment Details. +- > + Enriches a given network device context device id or device Mac Address or device management IP address with + details about the device and neighbor topology. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetDeviceEnrichmentDetails + description: Complete reference of the GetDeviceEnrichmentDetails API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-enrichment-details +notes: + - SDK Method used are + devices.Devices.get_device_enrichment_details, + + - Paths used are + get /dna/intent/api/v1/device-enrichment-details, + +""" + +EXAMPLES = r""" +- name: Get all Device Enrichment Details + cisco.dnac.device_enrichment_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "deviceDetails": { + "family": "string", + "type": "string", + "location": {}, + "errorCode": "string", + "macAddress": "string", + "role": "string", + "apManagerInterfaceIp": "string", + "associatedWlcIp": "string", + "bootDateTime": "string", + "collectionStatus": "string", + "interfaceCount": "string", + "lineCardCount": "string", + "lineCardId": "string", + "managementIpAddress": "string", + "memorySize": "string", + "platformId": "string", + "reachabilityFailureReason": "string", + "reachabilityStatus": "string", + "snmpContact": "string", + "snmpLocation": "string", + "tunnelUdpPort": {}, + "waasDeviceMode": {}, + "series": "string", + "inventoryStatusDetail": "string", + "collectionInterval": "string", + "serialNumber": "string", + "softwareVersion": "string", + "roleSource": "string", + "hostname": "string", + "upTime": "string", + "lastUpdateTime": 0, + "errorDescription": "string", + "locationName": {}, + "tagCount": "string", + "lastUpdated": "string", + "instanceUuid": "string", + "id": "string", + "neighborTopology": [ + { + "nodes": [ + { + "role": "string", + "name": "string", + "id": "string", + "description": "string", + "deviceType": "string", + "platformId": "string", + "family": "string", + "ip": "string", + "softwareVersion": "string", + "userId": {}, + "nodeType": "string", + "radioFrequency": {}, + "clients": {}, + "count": {}, + "healthScore": 0, + "level": 0, + "fabricGroup": {}, + "connectedDevice": {} + } + ], + "links": [ + { + "source": "string", + "linkStatus": "string", + "label": [ + {} + ], + "target": "string", + "id": {}, + "portUtilization": {} + } + ] + } + ] + } + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_family_identifiers_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/device_family_identifiers_details_info.py new file mode 100644 index 000000000..515a0d94a --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_family_identifiers_details_info.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_family_identifiers_details_info +short_description: Information module for Device Family Identifiers Details +description: +- Get all Device Family Identifiers Details. +- API to get Device Family Identifiers for all Device Families that can be used for tagging an image golden. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Software Image Management (SWIM) GetDeviceFamilyIdentifiers + description: Complete reference of the GetDeviceFamilyIdentifiers API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-family-identifiers +notes: + - SDK Method used are + software_image_management_swim.SoftwareImageManagementSwim.get_device_family_identifiers, + + - Paths used are + get /dna/intent/api/v1/image/importation/device-family-identifiers, + +""" + +EXAMPLES = r""" +- name: Get all Device Family Identifiers Details + cisco.dnac.device_family_identifiers_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": [ + { + "deviceFamily": "string", + "deviceFamilyIdentifier": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_health_info.py b/ansible_collections/cisco/dnac/plugins/modules/device_health_info.py new file mode 100644 index 000000000..9b329a7ab --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_health_info.py @@ -0,0 +1,149 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_health_info +short_description: Information module for Device Health +description: +- Get all Device Health. +- > + Intent API for accessing DNA Assurance Device object for generating reports, creating dashboards or creating + additional value added services. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceRole: + description: + - DeviceRole query parameter. The device role (One of CORE, ACCESS, DISTRIBUTION, ROUTER, WLC, AP). + type: str + siteId: + description: + - SiteId query parameter. Assurance site UUID value. + type: str + health: + description: + - Health query parameter. The device overall health (One of POOR, FAIR, GOOD). + type: str + startTime: + description: + - StartTime query parameter. UTC epoch time in milliseconds. + type: int + endTime: + description: + - EndTime query parameter. UTC epoch time in miliseconds. + type: int + limit: + description: + - Limit query parameter. Max number of device entries in the response (default to 50. Max at 1000). + type: int + offset: + description: + - Offset query parameter. The offset of the first device in the returned data. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices Devices + description: Complete reference of the Devices API. + link: https://developer.cisco.com/docs/dna-center/#!api-devices-devices +notes: + - SDK Method used are + devices.Devices.devices, + + - Paths used are + get /dna/intent/api/v1/device-health, + +""" + +EXAMPLES = r""" +- name: Get all Device Health + cisco.dnac.device_health_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceRole: string + siteId: string + health: string + startTime: 0 + endTime: 0 + limit: 0 + offset: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "totalCount": 0, + "response": [ + { + "name": "string", + "model": "string", + "osVersion": "string", + "ipAddress": "string", + "overallHealth": 0, + "issueCount": 0, + "location": "string", + "deviceFamily": "string", + "deviceType": "string", + "macAddress": "string", + "interfaceLinkErrHealth": 0, + "cpuUlitilization": 0, + "cpuHealth": 0, + "memoryUtilizationHealth": 0, + "memoryUtilization": 0, + "interDeviceLinkAvailHealth": 0, + "reachabilityHealth": "string", + "clientCount": { + "radio0": 0, + "radio1": 0, + "Ghz24": 0, + "Ghz50": 0 + }, + "interferenceHealth": { + "radio0": 0, + "radio1": 0, + "Ghz24": 0, + "Ghz50": 0 + }, + "noiseHealth": { + "radio1": 0, + "Ghz50": 0 + }, + "airQualityHealth": { + "radio0": 0, + "radio1": 0, + "Ghz24": 0, + "Ghz50": 0 + }, + "utilizationHealth": { + "radio0": 0, + "radio1": 0, + "Ghz24": 0, + "Ghz50": 0 + } + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_interface_by_ip_info.py b/ansible_collections/cisco/dnac/plugins/modules/device_interface_by_ip_info.py new file mode 100644 index 000000000..7d5d984f5 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_interface_by_ip_info.py @@ -0,0 +1,101 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_interface_by_ip_info +short_description: Information module for Device Interface By Ip +description: +- Get Device Interface By Ip by id. +- Returns list of interfaces for specified device management IP address. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + ipAddress: + description: + - IpAddress path parameter. IP address of the interface. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetInterfaceByIP + description: Complete reference of the GetInterfaceByIP API. + link: https://developer.cisco.com/docs/dna-center/#!get-interface-by-ip +notes: + - SDK Method used are + devices.Devices.get_interface_by_ip, + + - Paths used are + get /dna/intent/api/v1/interface/ip-address/{ipAddress}, + +""" + +EXAMPLES = r""" +- name: Get Device Interface By Ip by id + cisco.dnac.device_interface_by_ip_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + ipAddress: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "adminStatus": "string", + "className": "string", + "description": "string", + "deviceId": "string", + "duplex": "string", + "id": "string", + "ifIndex": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "interfaceType": "string", + "ipv4Address": "string", + "ipv4Mask": "string", + "isisSupport": "string", + "lastUpdated": "string", + "macAddress": "string", + "mappedPhysicalInterfaceId": "string", + "mappedPhysicalInterfaceName": "string", + "mediaType": "string", + "nativeVlanId": "string", + "ospfSupport": "string", + "pid": "string", + "portMode": "string", + "portName": "string", + "portType": "string", + "serialNo": "string", + "series": "string", + "speed": "string", + "status": "string", + "vlanId": "string", + "voiceVlan": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_interface_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/device_interface_count_info.py new file mode 100644 index 000000000..24e0290a6 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_interface_count_info.py @@ -0,0 +1,63 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_interface_count_info +short_description: Information module for Device Interface Count +description: +- Get all Device Interface Count. +- Returns the count of interfaces for all devices. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetDeviceInterfaceCount + description: Complete reference of the GetDeviceInterfaceCount API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-interface-count +notes: + - SDK Method used are + devices.Devices.get_device_interface_count, + + - Paths used are + get /dna/intent/api/v1/interface/count, + +""" + +EXAMPLES = r""" +- name: Get all Device Interface Count + cisco.dnac.device_interface_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_interface_info.py b/ansible_collections/cisco/dnac/plugins/modules/device_interface_info.py new file mode 100644 index 000000000..5f484a520 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_interface_info.py @@ -0,0 +1,138 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_interface_info +short_description: Information module for Device Interface +description: +- Get all Device Interface. +- Get Device Interface by id. +- Returns all available interfaces. This endpoint can return a maximum of 500 interfaces. +- Returns the interface for the given interface ID. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + offset: + description: + - Offset query parameter. + type: int + limit: + description: + - Limit query parameter. + type: int + lastInputTime: + description: + - LastInputTime query parameter. Last Input Time. + type: str + lastOutputTime: + description: + - LastOutputTime query parameter. Last Output Time. + type: str + id: + description: + - Id path parameter. Interface ID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetAllInterfaces + description: Complete reference of the GetAllInterfaces API. + link: https://developer.cisco.com/docs/dna-center/#!get-all-interfaces +- name: Cisco DNA Center documentation for Devices GetInterfaceById + description: Complete reference of the GetInterfaceById API. + link: https://developer.cisco.com/docs/dna-center/#!get-interface-by-id +notes: + - SDK Method used are + devices.Devices.get_all_interfaces, + devices.Devices.get_interface_by_id, + + - Paths used are + get /dna/intent/api/v1/interface, + get /dna/intent/api/v1/interface/{id}, + +""" + +EXAMPLES = r""" +- name: Get all Device Interface + cisco.dnac.device_interface_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + offset: 0 + limit: 0 + lastInputTime: string + lastOutputTime: string + register: result + +- name: Get Device Interface by id + cisco.dnac.device_interface_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "adminStatus": "string", + "className": "string", + "description": "string", + "deviceId": "string", + "duplex": "string", + "id": "string", + "ifIndex": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "interfaceType": "string", + "ipv4Address": "string", + "ipv4Mask": "string", + "isisSupport": "string", + "lastUpdated": "string", + "macAddress": "string", + "mappedPhysicalInterfaceId": "string", + "mappedPhysicalInterfaceName": "string", + "mediaType": "string", + "nativeVlanId": "string", + "ospfSupport": "string", + "pid": "string", + "portMode": "string", + "portName": "string", + "portType": "string", + "serialNo": "string", + "series": "string", + "speed": "string", + "status": "string", + "vlanId": "string", + "voiceVlan": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_interface_isis_info.py b/ansible_collections/cisco/dnac/plugins/modules/device_interface_isis_info.py new file mode 100644 index 000000000..242344a18 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_interface_isis_info.py @@ -0,0 +1,96 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_interface_isis_info +short_description: Information module for Device Interface Isis +description: +- Get all Device Interface Isis. +- Returns the interfaces that has ISIS enabled. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetISISInterfaces + description: Complete reference of the GetISISInterfaces API. + link: https://developer.cisco.com/docs/dna-center/#!get-isis-interfaces +notes: + - SDK Method used are + devices.Devices.get_isis_interfaces, + + - Paths used are + get /dna/intent/api/v1/interface/isis, + +""" + +EXAMPLES = r""" +- name: Get all Device Interface Isis + cisco.dnac.device_interface_isis_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "adminStatus": "string", + "className": "string", + "description": "string", + "deviceId": "string", + "duplex": "string", + "id": "string", + "ifIndex": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "interfaceType": "string", + "ipv4Address": "string", + "ipv4Mask": "string", + "isisSupport": "string", + "lastUpdated": "string", + "macAddress": "string", + "mappedPhysicalInterfaceId": "string", + "mappedPhysicalInterfaceName": "string", + "mediaType": "string", + "nativeVlanId": "string", + "ospfSupport": "string", + "pid": "string", + "portMode": "string", + "portName": "string", + "portType": "string", + "serialNo": "string", + "series": "string", + "speed": "string", + "status": "string", + "vlanId": "string", + "voiceVlan": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_interface_ospf_info.py b/ansible_collections/cisco/dnac/plugins/modules/device_interface_ospf_info.py new file mode 100644 index 000000000..759f4584a --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_interface_ospf_info.py @@ -0,0 +1,96 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_interface_ospf_info +short_description: Information module for Device Interface Ospf +description: +- Get all Device Interface Ospf. +- Returns the interfaces that has OSPF enabled. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetOSPFInterfaces + description: Complete reference of the GetOSPFInterfaces API. + link: https://developer.cisco.com/docs/dna-center/#!get-ospf-interfaces +notes: + - SDK Method used are + devices.Devices.get_ospf_interfaces, + + - Paths used are + get /dna/intent/api/v1/interface/ospf, + +""" + +EXAMPLES = r""" +- name: Get all Device Interface Ospf + cisco.dnac.device_interface_ospf_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "adminStatus": "string", + "className": "string", + "description": "string", + "deviceId": "string", + "duplex": "string", + "id": "string", + "ifIndex": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "interfaceType": "string", + "ipv4Address": "string", + "ipv4Mask": "string", + "isisSupport": "string", + "lastUpdated": "string", + "macAddress": "string", + "mappedPhysicalInterfaceId": "string", + "mappedPhysicalInterfaceName": "string", + "mediaType": "string", + "nativeVlanId": "string", + "ospfSupport": "string", + "pid": "string", + "portMode": "string", + "portName": "string", + "portType": "string", + "serialNo": "string", + "series": "string", + "speed": "string", + "status": "string", + "vlanId": "string", + "voiceVlan": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_reboot_apreboot.py b/ansible_collections/cisco/dnac/plugins/modules/device_reboot_apreboot.py new file mode 100644 index 000000000..78a33dfd4 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_reboot_apreboot.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_reboot_apreboot +short_description: Resource module for Device Reboot Apreboot +description: +- Manage operation create of the resource Device Reboot Apreboot. +- Users can reboot multiple access points up-to 200 at a time using this API. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + apMacAddresses: + description: The ethernet MAC address of the access point. + elements: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless RebootAccessPoints + description: Complete reference of the RebootAccessPoints API. + link: https://developer.cisco.com/docs/dna-center/#!reboot-access-points +notes: + - SDK Method used are + wireless.Wireless.reboot_access_points, + + - Paths used are + post /dna/intent/api/v1/device-reboot/apreboot, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.device_reboot_apreboot: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + apMacAddresses: + - string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_reboot_apreboot_info.py b/ansible_collections/cisco/dnac/plugins/modules/device_reboot_apreboot_info.py new file mode 100644 index 000000000..09203ba5e --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_reboot_apreboot_info.py @@ -0,0 +1,77 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_reboot_apreboot_info +short_description: Information module for Device Reboot Apreboot +description: +- Get all Device Reboot Apreboot. +- Users can query the access point reboot status using this intent API. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + parentTaskId: + description: + - ParentTaskId query parameter. Task id of ap reboot request. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless GetAccessPointRebootTaskResult + description: Complete reference of the GetAccessPointRebootTaskResult API. + link: https://developer.cisco.com/docs/dna-center/#!get-access-point-reboot-task-result +notes: + - SDK Method used are + wireless.Wireless.get_access_point_reboot_task_result, + + - Paths used are + get /dna/intent/api/v1/device-reboot/apreboot/status, + +""" + +EXAMPLES = r""" +- name: Get all Device Reboot Apreboot + cisco.dnac.device_reboot_apreboot_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + parentTaskId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "wlcIP": "string", + "apList": [ + { + "apName": "string", + "rebootStatus": "string", + "failureReason": {} + } + ] + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_replacement.py b/ansible_collections/cisco/dnac/plugins/modules/device_replacement.py new file mode 100644 index 000000000..e6ec8cbdc --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_replacement.py @@ -0,0 +1,156 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_replacement +short_description: Resource module for Device Replacement +description: +- Manage operations create and update of the resource Device Replacement. +- Marks device for replacement. +- UnMarks device for replacement. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + payload: + description: Device Replacement's payload. + elements: dict + suboptions: + creationTime: + description: Device Replacement's creationTime. + type: int + family: + description: Device Replacement's family. + type: str + faultyDeviceId: + description: Device Replacement's faultyDeviceId. + type: str + faultyDeviceName: + description: Device Replacement's faultyDeviceName. + type: str + faultyDevicePlatform: + description: Device Replacement's faultyDevicePlatform. + type: str + faultyDeviceSerialNumber: + description: Device Replacement's faultyDeviceSerialNumber. + type: str + id: + description: Device Replacement's id. + type: str + neighbourDeviceId: + description: Device Replacement's neighbourDeviceId. + type: str + networkReadinessTaskId: + description: Device Replacement's networkReadinessTaskId. + type: str + replacementDevicePlatform: + description: Device Replacement's replacementDevicePlatform. + type: str + replacementDeviceSerialNumber: + description: Device Replacement's replacementDeviceSerialNumber. + type: str + replacementStatus: + description: Device Replacement's replacementStatus. + type: str + replacementTime: + description: Device Replacement's replacementTime. + type: int + workflowId: + description: Device Replacement's workflowId. + type: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Replacement MarkDeviceForReplacement + description: Complete reference of the MarkDeviceForReplacement API. + link: https://developer.cisco.com/docs/dna-center/#!mark-device-for-replacement +- name: Cisco DNA Center documentation for Device Replacement UnMarkDeviceForReplacement + description: Complete reference of the UnMarkDeviceForReplacement API. + link: https://developer.cisco.com/docs/dna-center/#!un-mark-device-for-replacement +notes: + - SDK Method used are + device_replacement.DeviceReplacement.mark_device_for_replacement, + device_replacement.DeviceReplacement.unmark_device_for_replacement, + + - Paths used are + post /dna/intent/api/v1/device-replacement, + put /dna/intent/api/v1/device-replacement, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.device_replacement: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - creationTime: 0 + family: string + faultyDeviceId: string + faultyDeviceName: string + faultyDevicePlatform: string + faultyDeviceSerialNumber: string + id: string + neighbourDeviceId: string + networkReadinessTaskId: string + replacementDevicePlatform: string + replacementDeviceSerialNumber: string + replacementStatus: string + replacementTime: 0 + workflowId: string + +- name: Create + cisco.dnac.device_replacement: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - creationTime: 0 + family: string + faultyDeviceId: string + faultyDeviceName: string + faultyDevicePlatform: string + faultyDeviceSerialNumber: string + id: string + neighbourDeviceId: string + networkReadinessTaskId: string + replacementDevicePlatform: string + replacementDeviceSerialNumber: string + replacementStatus: string + replacementTime: 0 + workflowId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_replacement_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/device_replacement_count_info.py new file mode 100644 index 000000000..c15cf18df --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_replacement_count_info.py @@ -0,0 +1,71 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_replacement_count_info +short_description: Information module for Device Replacement Count +description: +- Get all Device Replacement Count. +- Get replacement devices count. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + replacementStatus: + description: + - > + ReplacementStatus query parameter. Device Replacement status listREADY-FOR-REPLACEMENT, REPLACEMENT-IN- + PROGRESS, REPLACEMENT-SCHEDULED, REPLACED, ERROR. + elements: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Replacement ReturnReplacementDevicesCount + description: Complete reference of the ReturnReplacementDevicesCount API. + link: https://developer.cisco.com/docs/dna-center/#!return-replacement-devices-count +notes: + - SDK Method used are + device_replacement.DeviceReplacement.return_replacement_devices_count, + + - Paths used are + get /dna/intent/api/v1/device-replacement/count, + +""" + +EXAMPLES = r""" +- name: Get all Device Replacement Count + cisco.dnac.device_replacement_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + replacementStatus: [] + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_replacement_deploy.py b/ansible_collections/cisco/dnac/plugins/modules/device_replacement_deploy.py new file mode 100644 index 000000000..14f591d2d --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_replacement_deploy.py @@ -0,0 +1,71 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_replacement_deploy +short_description: Resource module for Device Replacement Deploy +description: +- Manage operation create of the resource Device Replacement Deploy. +- > + API to trigger RMA workflow that will replace faulty device with replacement device with same configuration and + images. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + faultyDeviceSerialNumber: + description: Device Replacement Deploy's faultyDeviceSerialNumber. + type: str + replacementDeviceSerialNumber: + description: Device Replacement Deploy's replacementDeviceSerialNumber. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Replacement DeployDeviceReplacementWorkflow + description: Complete reference of the DeployDeviceReplacementWorkflow API. + link: https://developer.cisco.com/docs/dna-center/#!deploy-device-replacement-workflow +notes: + - SDK Method used are + device_replacement.DeviceReplacement.deploy_device_replacement_workflow, + + - Paths used are + post /dna/intent/api/v1/device-replacement/workflow, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.device_replacement_deploy: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + faultyDeviceSerialNumber: string + replacementDeviceSerialNumber: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/device_replacement_info.py b/ansible_collections/cisco/dnac/plugins/modules/device_replacement_info.py new file mode 100644 index 000000000..91977952a --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/device_replacement_info.py @@ -0,0 +1,142 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: device_replacement_info +short_description: Information module for Device Replacement +description: +- Get all Device Replacement. +- > + Get list of replacement devices with replacement details and it can filter replacement devices based on Faulty + Device Name,Faulty Device Platform, Replacement Device Platform, Faulty Device Serial Number,Replacement Device + Serial Number, Device Replacement status, Product Family. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + faultyDeviceName: + description: + - FaultyDeviceName query parameter. Faulty Device Name. + type: str + faultyDevicePlatform: + description: + - FaultyDevicePlatform query parameter. Faulty Device Platform. + type: str + replacementDevicePlatform: + description: + - ReplacementDevicePlatform query parameter. Replacement Device Platform. + type: str + faultyDeviceSerialNumber: + description: + - FaultyDeviceSerialNumber query parameter. Faulty Device Serial Number. + type: str + replacementDeviceSerialNumber: + description: + - ReplacementDeviceSerialNumber query parameter. Replacement Device Serial Number. + type: str + replacementStatus: + description: + - > + ReplacementStatus query parameter. Device Replacement status READY-FOR-REPLACEMENT, REPLACEMENT-IN-PROGRESS, + REPLACEMENT-SCHEDULED, REPLACED, ERROR, NETWORK_READINESS_REQUESTED, NETWORK_READINESS_FAILED. + elements: str + type: list + family: + description: + - Family query parameter. List of familiesRouters, Switches and Hubs, AP. + elements: str + type: list + sortBy: + description: + - SortBy query parameter. SortBy this field. SortBy is mandatory when order is used. + type: str + sortOrder: + description: + - SortOrder query parameter. Order on displayNameASC,DESC. + type: str + offset: + description: + - Offset query parameter. + type: int + limit: + description: + - Limit query parameter. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Replacement ReturnListOfReplacementDevicesWithReplacementDetails + description: Complete reference of the ReturnListOfReplacementDevicesWithReplacementDetails API. + link: https://developer.cisco.com/docs/dna-center/#!return-list-of-replacement-devices-with-replacement-details +notes: + - SDK Method used are + device_replacement.DeviceReplacement.return_replacement_devices_with_details, + + - Paths used are + get /dna/intent/api/v1/device-replacement, + +""" + +EXAMPLES = r""" +- name: Get all Device Replacement + cisco.dnac.device_replacement_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + faultyDeviceName: string + faultyDevicePlatform: string + replacementDevicePlatform: string + faultyDeviceSerialNumber: string + replacementDeviceSerialNumber: string + replacementStatus: [] + family: [] + sortBy: string + sortOrder: string + offset: 0 + limit: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "creationTime": 0, + "family": "string", + "faultyDeviceId": "string", + "faultyDeviceName": "string", + "faultyDevicePlatform": "string", + "faultyDeviceSerialNumber": "string", + "id": "string", + "neighbourDeviceId": "string", + "networkReadinessTaskId": "string", + "replacementDevicePlatform": "string", + "replacementDeviceSerialNumber": "string", + "replacementStatus": "string", + "replacementTime": 0, + "workflowId": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/disassociate_site_to_network_profile.py b/ansible_collections/cisco/dnac/plugins/modules/disassociate_site_to_network_profile.py new file mode 100644 index 000000000..de80f579b --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/disassociate_site_to_network_profile.py @@ -0,0 +1,69 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: disassociate_site_to_network_profile +short_description: Resource module for Disassociate Site To Network Profile +description: +- Manage operation delete of the resource Disassociate Site To Network Profile. +- Disassociate a Site from a Network Profile. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + networkProfileId: + description: NetworkProfileId path parameter. Network-Profile Id to be associated. + type: str + siteId: + description: SiteId path parameter. Site Id to be associated. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Site Design Disassociate + description: Complete reference of the Disassociate API. + link: https://developer.cisco.com/docs/dna-center/#!disassociate +notes: + - SDK Method used are + site_design.SiteDesign.disassociate, + + - Paths used are + delete /dna/intent/api/v1/networkprofile/{networkProfileId}/site/{siteId}, + +""" + +EXAMPLES = r""" +- name: Delete by id + cisco.dnac.disassociate_site_to_network_profile: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + networkProfileId: string + siteId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": { + "taskId": "string", + "url": "string" + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/disasterrecovery_system_operationstatus_info.py b/ansible_collections/cisco/dnac/plugins/modules/disasterrecovery_system_operationstatus_info.py new file mode 100644 index 000000000..8e05a778e --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/disasterrecovery_system_operationstatus_info.py @@ -0,0 +1,90 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: disasterrecovery_system_operationstatus_info +short_description: Information module for Disasterrecovery System Operationstatus +description: +- Get all Disasterrecovery System Operationstatus. +- Returns the status of Disaster Recovery operation performed on the system. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +notes: + - SDK Method used are + disaster_recovery.DisasterRecovery.disaster_recovery_operational_status, + + - Paths used are + get /dna/intent/api/v1/disasterrecovery/system/operationstatus, + +""" + +EXAMPLES = r""" +- name: Get all Disasterrecovery System Operationstatus + cisco.dnac.disasterrecovery_system_operationstatus_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: + custom: value + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "severity": "string", + "status": "string", + "initiated_by": "string", + "ipconfig": [ + { + "interface": "string", + "vip": "string", + "ip": "string" + } + ], + "tasks": [ + { + "status": "string", + "ipconfig": [ + { + "interface": "string", + "vip": "string", + "ip": "string" + } + ], + "title": "string", + "site": "string", + "startTimestamp": "string", + "message": "string", + "endTimestamp": "string" + } + ], + "title": "string", + "site": "string", + "startTimestamp": "string", + "message": "string", + "endTimestamp": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/disasterrecovery_system_status_info.py b/ansible_collections/cisco/dnac/plugins/modules/disasterrecovery_system_status_info.py new file mode 100644 index 000000000..40356c0f7 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/disasterrecovery_system_status_info.py @@ -0,0 +1,143 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: disasterrecovery_system_status_info +short_description: Information module for Disasterrecovery System Status +description: +- Get all Disasterrecovery System Status. +- Detailed and Summarized status of DR components (Active, Standby and Witness system's health). +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +notes: + - SDK Method used are + disaster_recovery.DisasterRecovery.disaster_recovery_status, + + - Paths used are + get /dna/intent/api/v1/disasterrecovery/system/status, + +""" + +EXAMPLES = r""" +- name: Get all Disasterrecovery System Status + cisco.dnac.disasterrecovery_system_status_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: + custom: value + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "ipconfig": [ + { + "interface": "string", + "vip": true, + "ip": "string" + } + ], + "site": "string", + "main": { + "ipconfig": [ + { + "interface": "string", + "vip": true, + "ip": "string" + } + ], + "state": "string", + "nodes": [ + { + "hostname": "string", + "state": "string", + "ipaddresses": [ + { + "interface": "string", + "vip": true, + "ip": "string" + } + ] + } + ] + }, + "recovery": { + "ipconfig": [ + { + "interface": "string", + "vip": true, + "ip": "string" + } + ], + "state": "string", + "nodes": [ + { + "hostname": "string", + "state": "string", + "ipconfig": [ + { + "interface": "string", + "vip": true, + "ip": "string" + } + ] + } + ] + }, + "witness": { + "ipconfig": [ + { + "interface": "string", + "vip": true, + "ip": "string" + } + ], + "state": "string", + "nodes": [ + { + "hostname": "string", + "state": "string", + "ipconfig": [ + { + "interface": "string", + "vip": true, + "ip": "string" + } + ] + } + ] + }, + "state": "string", + "ipsec-tunnel": [ + { + "side_a": "string", + "side_b": "string", + "status": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/discovery.py b/ansible_collections/cisco/dnac/plugins/modules/discovery.py new file mode 100644 index 000000000..10e7e37a9 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/discovery.py @@ -0,0 +1,405 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: discovery +short_description: Resource module for Discovery +description: +- Manage operations create, update and delete of the resource Discovery. +- Initiates discovery with the given parameters. +- Stops all the discoveries and removes them. +- > + Stops the discovery for the given Discovery ID and removes it. Discovery ID can be obtained using the "Get + Discoveries by range" API. +- Stops or starts an existing discovery. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + attributeInfo: + description: Discovery's attributeInfo. + type: dict + cdpLevel: + description: Discovery's cdpLevel. + type: int + deviceIds: + description: Discovery's deviceIds. + type: str + discoveryCondition: + description: Discovery's discoveryCondition. + type: str + discoveryStatus: + description: Discovery's discoveryStatus. + type: str + discoveryType: + description: Discovery's discoveryType. + type: str + enablePasswordList: + description: Discovery's enablePasswordList. + type: str + globalCredentialIdList: + description: Discovery's globalCredentialIdList. + elements: str + type: list + httpReadCredential: + description: Discovery's httpReadCredential. + suboptions: + comments: + description: Discovery's comments. + type: str + credentialType: + description: Discovery's credentialType. + type: str + description: + description: Discovery's description. + type: str + id: + description: Discovery's id. + type: str + instanceTenantId: + description: Discovery's instanceTenantId. + type: str + instanceUuid: + description: Discovery's instanceUuid. + type: str + password: + description: Discovery's password. + type: str + port: + description: Discovery's port. + type: int + secure: + description: Secure flag. + type: bool + username: + description: Discovery's username. + type: str + type: dict + httpWriteCredential: + description: Discovery's httpWriteCredential. + suboptions: + comments: + description: Discovery's comments. + type: str + credentialType: + description: Discovery's credentialType. + type: str + description: + description: Discovery's description. + type: str + id: + description: Discovery's id. + type: str + instanceTenantId: + description: Discovery's instanceTenantId. + type: str + instanceUuid: + description: Discovery's instanceUuid. + type: str + password: + description: Discovery's password. + type: str + port: + description: Discovery's port. + type: int + secure: + description: Secure flag. + type: bool + username: + description: Discovery's username. + type: str + type: dict + id: + description: Discovery's id. + type: str + ipAddressList: + description: Discovery's ipAddressList. + type: str + ipFilterList: + description: Discovery's ipFilterList. + type: str + isAutoCdp: + description: IsAutoCdp flag. + type: bool + lldpLevel: + description: Discovery's lldpLevel. + type: int + name: + description: Discovery's name. + type: str + netconfPort: + description: Discovery's netconfPort. + type: str + numDevices: + description: Discovery's numDevices. + type: int + parentDiscoveryId: + description: Discovery's parentDiscoveryId. + type: str + passwordList: + description: Discovery's passwordList. + type: str + preferredMgmtIPMethod: + description: Discovery's preferredMgmtIPMethod. + type: str + protocolOrder: + description: Discovery's protocolOrder. + type: str + retry: + description: Number of times to try establishing connection to device. + type: int + retryCount: + description: Discovery's retryCount. + type: int + snmpAuthPassphrase: + description: Discovery's snmpAuthPassphrase. + type: str + snmpAuthProtocol: + description: Discovery's snmpAuthProtocol. + type: str + snmpMode: + description: Discovery's snmpMode. + type: str + snmpPrivPassphrase: + description: Discovery's snmpPrivPassphrase. + type: str + snmpPrivProtocol: + description: Discovery's snmpPrivProtocol. + type: str + snmpROCommunity: + description: Snmp RO community of the devices to be discovered. + type: str + snmpROCommunityDesc: + description: Description for Snmp RO community. + type: str + snmpRWCommunity: + description: Snmp RW community of the devices to be discovered. + type: str + snmpRWCommunityDesc: + description: Description for Snmp RW community. + type: str + snmpRoCommunity: + description: Discovery's snmpRoCommunity. + type: str + snmpRoCommunityDesc: + description: Discovery's snmpRoCommunityDesc. + type: str + snmpRwCommunity: + description: Discovery's snmpRwCommunity. + type: str + snmpRwCommunityDesc: + description: Discovery's snmpRwCommunityDesc. + type: str + snmpUserName: + description: Discovery's snmpUserName. + type: str + snmpVersion: + description: Version of SNMP. V2 or v3. + type: str + timeOut: + description: Discovery's timeOut. + type: int + timeout: + description: Time to wait for device response in seconds. + type: int + updateMgmtIp: + description: UpdateMgmtIp flag. + type: bool + userNameList: + description: Discovery's userNameList. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery StartDiscovery + description: Complete reference of the StartDiscovery API. + link: https://developer.cisco.com/docs/dna-center/#!start-discovery +- name: Cisco DNA Center documentation for Discovery DeleteAllDiscovery + description: Complete reference of the DeleteAllDiscovery API. + link: https://developer.cisco.com/docs/dna-center/#!delete-all-discovery +- name: Cisco DNA Center documentation for Discovery DeleteDiscoveryById + description: Complete reference of the DeleteDiscoveryById API. + link: https://developer.cisco.com/docs/dna-center/#!delete-discovery-by-id +- name: Cisco DNA Center documentation for Discovery UpdatesAnExistingDiscoveryBySpecifiedId + description: Complete reference of the UpdatesAnExistingDiscoveryBySpecifiedId API. + link: https://developer.cisco.com/docs/dna-center/#!updates-an-existing-discovery-by-specified-id +notes: + - SDK Method used are + discovery.Discovery.delete_discovery_by_id, + discovery.Discovery.start_discovery, + discovery.Discovery.updates_discovery_by_id, + + - Paths used are + post /dna/intent/api/v1/discovery, + delete /dna/intent/api/v1/discovery, + delete /dna/intent/api/v1/discovery/{id}, + put /dna/intent/api/v1/discovery, + +""" + +EXAMPLES = r""" +- name: Delete all + cisco.dnac.discovery: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + +- name: Update all + cisco.dnac.discovery: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + attributeInfo: {} + cdpLevel: 0 + deviceIds: string + discoveryCondition: string + discoveryStatus: string + discoveryType: string + enablePasswordList: string + globalCredentialIdList: + - string + httpReadCredential: + comments: string + credentialType: string + description: string + id: string + instanceTenantId: string + instanceUuid: string + password: string + port: 0 + secure: true + username: string + httpWriteCredential: + comments: string + credentialType: string + description: string + id: string + instanceTenantId: string + instanceUuid: string + password: string + port: 0 + secure: true + username: string + id: string + ipAddressList: string + ipFilterList: string + isAutoCdp: true + lldpLevel: 0 + name: string + netconfPort: string + numDevices: 0 + parentDiscoveryId: string + passwordList: string + preferredMgmtIPMethod: string + protocolOrder: string + retryCount: 0 + snmpAuthPassphrase: string + snmpAuthProtocol: string + snmpMode: string + snmpPrivPassphrase: string + snmpPrivProtocol: string + snmpRoCommunity: string + snmpRoCommunityDesc: string + snmpRwCommunity: string + snmpRwCommunityDesc: string + snmpUserName: string + timeOut: 0 + updateMgmtIp: true + userNameList: string + +- name: Create + cisco.dnac.discovery: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + cdpLevel: 0 + discoveryType: string + enablePasswordList: + - string + globalCredentialIdList: + - string + httpReadCredential: + password: string + port: 0 + secure: true + username: string + httpWriteCredential: + password: string + port: 0 + secure: true + username: string + ipAddressList: string + ipFilterList: + - string + lldpLevel: 0 + name: string + netconfPort: string + passwordList: + - string + preferredMgmtIPMethod: string + protocolOrder: string + retry: 0 + snmpAuthPassphrase: string + snmpAuthProtocol: string + snmpMode: string + snmpPrivPassphrase: string + snmpPrivProtocol: string + snmpROCommunity: string + snmpROCommunityDesc: string + snmpRWCommunity: string + snmpRWCommunityDesc: string + snmpUserName: string + snmpVersion: string + timeout: 0 + userNameList: + - string + +- name: Delete by id + cisco.dnac.discovery: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + id: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/discovery_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/discovery_count_info.py new file mode 100644 index 000000000..6622742f7 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/discovery_count_info.py @@ -0,0 +1,63 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: discovery_count_info +short_description: Information module for Discovery Count +description: +- Get all Discovery Count. +- Returns the count of all available discovery jobs. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery GetCountOfAllDiscoveryJobs + description: Complete reference of the GetCountOfAllDiscoveryJobs API. + link: https://developer.cisco.com/docs/dna-center/#!get-count-of-all-discovery-jobs +notes: + - SDK Method used are + discovery.Discovery.get_count_of_all_discovery_jobs, + + - Paths used are + get /dna/intent/api/v1/discovery/count, + +""" + +EXAMPLES = r""" +- name: Get all Discovery Count + cisco.dnac.discovery_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/discovery_device_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/discovery_device_count_info.py new file mode 100644 index 000000000..b258a513d --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/discovery_device_count_info.py @@ -0,0 +1,75 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: discovery_device_count_info +short_description: Information module for Discovery Device Count +description: +- Get all Discovery Device Count. +- > + Returns the count of network devices discovered in the given discovery. Discovery ID can be obtained using the + "Get Discoveries by range" API. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + id: + description: + - Id path parameter. Discovery ID. + type: str + taskId: + description: + - TaskId query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery GetDevicesDiscoveredById + description: Complete reference of the GetDevicesDiscoveredById API. + link: https://developer.cisco.com/docs/dna-center/#!get-devices-discovered-by-id +notes: + - SDK Method used are + discovery.Discovery.get_devices_discovered_by_id, + + - Paths used are + get /dna/intent/api/v1/discovery/{id}/network-device/count, + +""" + +EXAMPLES = r""" +- name: Get all Discovery Device Count + cisco.dnac.discovery_device_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + taskId: string + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/discovery_device_info.py b/ansible_collections/cisco/dnac/plugins/modules/discovery_device_info.py new file mode 100644 index 000000000..345000ca0 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/discovery_device_info.py @@ -0,0 +1,124 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: discovery_device_info +short_description: Information module for Discovery Device +description: +- Get all Discovery Device. +- > + Returns the network devices discovered for the given Discovery ID. Discovery ID can be obtained using the "Get + Discoveries by range" API. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + id: + description: + - Id path parameter. Discovery ID. + type: str + taskId: + description: + - TaskId query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery GetDiscoveredNetworkDevicesByDiscoveryId + description: Complete reference of the GetDiscoveredNetworkDevicesByDiscoveryId API. + link: https://developer.cisco.com/docs/dna-center/#!get-discovered-network-devices-by-discovery-id +notes: + - SDK Method used are + discovery.Discovery.get_discovered_network_devices_by_discovery_id, + + - Paths used are + get /dna/intent/api/v1/discovery/{id}/network-device, + +""" + +EXAMPLES = r""" +- name: Get all Discovery Device + cisco.dnac.discovery_device_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + taskId: string + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "anchorWlcForAp": "string", + "authModelId": "string", + "avgUpdateFrequency": 0, + "bootDateTime": "string", + "cliStatus": "string", + "duplicateDeviceId": "string", + "errorCode": "string", + "errorDescription": "string", + "family": "string", + "hostname": "string", + "httpStatus": "string", + "id": "string", + "imageName": "string", + "ingressQueueConfig": "string", + "interfaceCount": "string", + "inventoryCollectionStatus": "string", + "inventoryReachabilityStatus": "string", + "lastUpdated": "string", + "lineCardCount": "string", + "lineCardId": "string", + "location": "string", + "locationName": "string", + "macAddress": "string", + "managementIpAddress": "string", + "memorySize": "string", + "netconfStatus": "string", + "numUpdates": 0, + "pingStatus": "string", + "platformId": "string", + "portRange": "string", + "qosStatus": "string", + "reachabilityFailureReason": "string", + "reachabilityStatus": "string", + "role": "string", + "roleSource": "string", + "serialNumber": "string", + "snmpContact": "string", + "snmpLocation": "string", + "snmpStatus": "string", + "softwareVersion": "string", + "tag": "string", + "tagCount": 0, + "type": "string", + "upTime": "string", + "vendor": "string", + "wlcApDeviceStatus": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/discovery_device_range_info.py b/ansible_collections/cisco/dnac/plugins/modules/discovery_device_range_info.py new file mode 100644 index 000000000..47dcb0871 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/discovery_device_range_info.py @@ -0,0 +1,134 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: discovery_device_range_info +short_description: Information module for Discovery Device Range +description: +- Get all Discovery Device Range. +- > + Returns the network devices discovered for the given discovery and for the given range. The maximum number of + records that can be retrieved is 500. Discovery ID can be obtained using the "Get Discoveries by range" API. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + id: + description: + - Id path parameter. Discovery ID. + type: str + startIndex: + description: + - StartIndex path parameter. Start index. + type: int + recordsToReturn: + description: + - RecordsToReturn path parameter. Number of records to return. + type: int + taskId: + description: + - TaskId query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery GetDiscoveredDevicesByRange + description: Complete reference of the GetDiscoveredDevicesByRange API. + link: https://developer.cisco.com/docs/dna-center/#!get-discovered-devices-by-range +notes: + - SDK Method used are + discovery.Discovery.get_discovered_devices_by_range, + + - Paths used are + get /dna/intent/api/v1/discovery/{id}/network-device/{startIndex}/{recordsToReturn}, + +""" + +EXAMPLES = r""" +- name: Get all Discovery Device Range + cisco.dnac.discovery_device_range_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + taskId: string + id: string + startIndex: 0 + recordsToReturn: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "anchorWlcForAp": "string", + "authModelId": "string", + "avgUpdateFrequency": 0, + "bootDateTime": "string", + "cliStatus": "string", + "duplicateDeviceId": "string", + "errorCode": "string", + "errorDescription": "string", + "family": "string", + "hostname": "string", + "httpStatus": "string", + "id": "string", + "imageName": "string", + "ingressQueueConfig": "string", + "interfaceCount": "string", + "inventoryCollectionStatus": "string", + "inventoryReachabilityStatus": "string", + "lastUpdated": "string", + "lineCardCount": "string", + "lineCardId": "string", + "location": "string", + "locationName": "string", + "macAddress": "string", + "managementIpAddress": "string", + "memorySize": "string", + "netconfStatus": "string", + "numUpdates": 0, + "pingStatus": "string", + "platformId": "string", + "portRange": "string", + "qosStatus": "string", + "reachabilityFailureReason": "string", + "reachabilityStatus": "string", + "role": "string", + "roleSource": "string", + "serialNumber": "string", + "snmpContact": "string", + "snmpLocation": "string", + "snmpStatus": "string", + "softwareVersion": "string", + "tag": "string", + "tagCount": 0, + "type": "string", + "upTime": "string", + "vendor": "string", + "wlcApDeviceStatus": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/discovery_info.py b/ansible_collections/cisco/dnac/plugins/modules/discovery_info.py new file mode 100644 index 000000000..689226938 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/discovery_info.py @@ -0,0 +1,129 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: discovery_info +short_description: Information module for Discovery +description: +- Get Discovery by id. +- Returns discovery by Discovery ID. Discovery ID can be obtained using the "Get Discoveries by range" API. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + id: + description: + - Id path parameter. Discovery ID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery GetDiscoveryById + description: Complete reference of the GetDiscoveryById API. + link: https://developer.cisco.com/docs/dna-center/#!get-discovery-by-id +notes: + - SDK Method used are + discovery.Discovery.get_discovery_by_id, + + - Paths used are + get /dna/intent/api/v1/discovery/{id}, + +""" + +EXAMPLES = r""" +- name: Get Discovery by id + cisco.dnac.discovery_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "attributeInfo": {}, + "cdpLevel": 0, + "deviceIds": "string", + "discoveryCondition": "string", + "discoveryStatus": "string", + "discoveryType": "string", + "enablePasswordList": "string", + "globalCredentialIdList": [ + "string" + ], + "httpReadCredential": { + "comments": "string", + "credentialType": "string", + "description": "string", + "id": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "password": "string", + "port": 0, + "secure": true, + "username": "string" + }, + "httpWriteCredential": { + "comments": "string", + "credentialType": "string", + "description": "string", + "id": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "password": "string", + "port": 0, + "secure": true, + "username": "string" + }, + "id": "string", + "ipAddressList": "string", + "ipFilterList": "string", + "isAutoCdp": true, + "lldpLevel": 0, + "name": "string", + "netconfPort": "string", + "numDevices": 0, + "parentDiscoveryId": "string", + "passwordList": "string", + "preferredMgmtIPMethod": "string", + "protocolOrder": "string", + "retryCount": 0, + "snmpAuthPassphrase": "string", + "snmpAuthProtocol": "string", + "snmpMode": "string", + "snmpPrivPassphrase": "string", + "snmpPrivProtocol": "string", + "snmpRoCommunity": "string", + "snmpRoCommunityDesc": "string", + "snmpRwCommunity": "string", + "snmpRwCommunityDesc": "string", + "snmpUserName": "string", + "timeOut": 0, + "updateMgmtIp": true, + "userNameList": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/discovery_job_info.py b/ansible_collections/cisco/dnac/plugins/modules/discovery_job_info.py new file mode 100644 index 000000000..202f57c80 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/discovery_job_info.py @@ -0,0 +1,131 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: discovery_job_info +short_description: Information module for Discovery Job +description: +- Get all Discovery Job. +- Get Discovery Job by id. +- > + Returns the list of discovery jobs for the given Discovery ID. The results can be optionally filtered based on IP. + Discovery ID can be obtained using the "Get Discoveries by range" API. +- Returns the list of discovery jobs for the given IP. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + offset: + description: + - Offset query parameter. + type: int + limit: + description: + - Limit query parameter. + type: int + ipAddress: + description: + - IpAddress query parameter. + type: str + name: + description: + - Name query parameter. + type: str + id: + description: + - Id path parameter. Discovery ID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery GetDiscoveryJobsByIP + description: Complete reference of the GetDiscoveryJobsByIP API. + link: https://developer.cisco.com/docs/dna-center/#!get-discovery-jobs-by-ip +- name: Cisco DNA Center documentation for Discovery GetListOfDiscoveriesByDiscoveryId + description: Complete reference of the GetListOfDiscoveriesByDiscoveryId API. + link: https://developer.cisco.com/docs/dna-center/#!get-list-of-discoveries-by-discovery-id +notes: + - SDK Method used are + discovery.Discovery.get_discovery_jobs_by_ip, + discovery.Discovery.get_list_of_discoveries_by_discovery_id, + + - Paths used are + get /dna/intent/api/v1/discovery/job, + get /dna/intent/api/v1/discovery/{id}/job, + +""" + +EXAMPLES = r""" +- name: Get all Discovery Job + cisco.dnac.discovery_job_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + offset: 0 + limit: 0 + ipAddress: string + name: string + register: result + +- name: Get Discovery Job by id + cisco.dnac.discovery_job_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + offset: 0 + limit: 0 + ipAddress: string + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "attributeInfo": {}, + "cliStatus": "string", + "discoveryStatus": "string", + "endTime": "string", + "httpStatus": "string", + "id": "string", + "inventoryCollectionStatus": "string", + "inventoryReachabilityStatus": "string", + "ipAddress": "string", + "jobStatus": "string", + "name": "string", + "netconfStatus": "string", + "pingStatus": "string", + "snmpStatus": "string", + "startTime": "string", + "taskId": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/discovery_range_delete.py b/ansible_collections/cisco/dnac/plugins/modules/discovery_range_delete.py new file mode 100644 index 000000000..07c380a17 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/discovery_range_delete.py @@ -0,0 +1,69 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: discovery_range_delete +short_description: Resource module for Discovery Range Delete +description: +- Manage operation delete of the resource Discovery Range Delete. +- Stops discovery for the given range and removes them. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + recordsToDelete: + description: RecordsToDelete path parameter. Number of records to delete. + type: int + startIndex: + description: StartIndex path parameter. Start index. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery DeleteDiscoveryBySpecifiedRange + description: Complete reference of the DeleteDiscoveryBySpecifiedRange API. + link: https://developer.cisco.com/docs/dna-center/#!delete-discovery-by-specified-range +notes: + - SDK Method used are + discovery.Discovery.delete_discovery_by_specified_range, + + - Paths used are + delete /dna/intent/api/v1/discovery/{startIndex}/{recordsToDelete}, + +""" + +EXAMPLES = r""" +- name: Delete all + cisco.dnac.discovery_range_delete: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + recordsToDelete: 0 + startIndex: 0 + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/discovery_range_info.py b/ansible_collections/cisco/dnac/plugins/modules/discovery_range_info.py new file mode 100644 index 000000000..c08902f8b --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/discovery_range_info.py @@ -0,0 +1,136 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: discovery_range_info +short_description: Information module for Discovery Range +description: +- Get all Discovery Range. +- Returns the discovery by specified range. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + startIndex: + description: + - StartIndex path parameter. Start index. + type: int + recordsToReturn: + description: + - RecordsToReturn path parameter. Number of records to return. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery GetDiscoveriesByRange + description: Complete reference of the GetDiscoveriesByRange API. + link: https://developer.cisco.com/docs/dna-center/#!get-discoveries-by-range +notes: + - SDK Method used are + discovery.Discovery.get_discoveries_by_range, + + - Paths used are + get /dna/intent/api/v1/discovery/{startIndex}/{recordsToReturn}, + +""" + +EXAMPLES = r""" +- name: Get all Discovery Range + cisco.dnac.discovery_range_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + startIndex: 0 + recordsToReturn: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "attributeInfo": {}, + "cdpLevel": 0, + "deviceIds": "string", + "discoveryCondition": "string", + "discoveryStatus": "string", + "discoveryType": "string", + "enablePasswordList": "string", + "globalCredentialIdList": [ + "string" + ], + "httpReadCredential": { + "comments": "string", + "credentialType": "string", + "description": "string", + "id": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "password": "string", + "port": 0, + "secure": true, + "username": "string" + }, + "httpWriteCredential": { + "comments": "string", + "credentialType": "string", + "description": "string", + "id": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "password": "string", + "port": 0, + "secure": true, + "username": "string" + }, + "id": "string", + "ipAddressList": "string", + "ipFilterList": "string", + "isAutoCdp": true, + "lldpLevel": 0, + "name": "string", + "netconfPort": "string", + "numDevices": 0, + "parentDiscoveryId": "string", + "passwordList": "string", + "preferredMgmtIPMethod": "string", + "protocolOrder": "string", + "retryCount": 0, + "snmpAuthPassphrase": "string", + "snmpAuthProtocol": "string", + "snmpMode": "string", + "snmpPrivPassphrase": "string", + "snmpPrivProtocol": "string", + "snmpRoCommunity": "string", + "snmpRoCommunityDesc": "string", + "snmpRwCommunity": "string", + "snmpRwCommunityDesc": "string", + "snmpUserName": "string", + "timeOut": 0, + "updateMgmtIp": true, + "userNameList": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/discovery_summary_info.py b/ansible_collections/cisco/dnac/plugins/modules/discovery_summary_info.py new file mode 100644 index 000000000..bd8e6dcf6 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/discovery_summary_info.py @@ -0,0 +1,121 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: discovery_summary_info +short_description: Information module for Discovery Summary +description: +- Get all Discovery Summary. +- > + Returns the network devices from a discovery job based on given filters. Discovery ID can be obtained using the + "Get Discoveries by range" API. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + id: + description: + - Id path parameter. Discovery ID. + type: str + taskId: + description: + - TaskId query parameter. + type: str + sortBy: + description: + - SortBy query parameter. + type: str + sortOrder: + description: + - SortOrder query parameter. + type: str + ipAddress: + description: + - IpAddress query parameter. + elements: str + type: list + pingStatus: + description: + - PingStatus query parameter. + elements: str + type: list + snmpStatus: + description: + - SnmpStatus query parameter. + elements: str + type: list + cliStatus: + description: + - CliStatus query parameter. + elements: str + type: list + netconfStatus: + description: + - NetconfStatus query parameter. + elements: str + type: list + httpStatus: + description: + - HttpStatus query parameter. + elements: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery GetNetworkDevicesFromDiscovery + description: Complete reference of the GetNetworkDevicesFromDiscovery API. + link: https://developer.cisco.com/docs/dna-center/#!get-network-devices-from-discovery +notes: + - SDK Method used are + discovery.Discovery.get_network_devices_from_discovery, + + - Paths used are + get /dna/intent/api/v1/discovery/{id}/summary, + +""" + +EXAMPLES = r""" +- name: Get all Discovery Summary + cisco.dnac.discovery_summary_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + taskId: string + sortBy: string + sortOrder: string + ipAddress: [] + pingStatus: [] + snmpStatus: [] + cliStatus: [] + netconfStatus: [] + httpStatus: [] + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/dna_command_runner_keywords_info.py b/ansible_collections/cisco/dnac/plugins/modules/dna_command_runner_keywords_info.py new file mode 100644 index 000000000..dee8c3ff2 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/dna_command_runner_keywords_info.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: dna_command_runner_keywords_info +short_description: Information module for Dna Command Runner Keywords +description: +- Get all Dna Command Runner Keywords. +- Get valid keywords. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Command Runner GetAllKeywordsOfCLIsAcceptedByCommandRunner + description: Complete reference of the GetAllKeywordsOfCLIsAcceptedByCommandRunner API. + link: https://developer.cisco.com/docs/dna-center/#!get-all-keywords-of-cl-is-accepted-by-command-runner +notes: + - SDK Method used are + command_runner.CommandRunner.get_all_keywords_of_clis_accepted, + + - Paths used are + get /dna/intent/api/v1/network-device-poller/cli/legit-reads, + +""" + +EXAMPLES = r""" +- name: Get all Dna Command Runner Keywords + cisco.dnac.dna_command_runner_keywords_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + "string" + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/dnac_packages_info.py b/ansible_collections/cisco/dnac/plugins/modules/dnac_packages_info.py new file mode 100644 index 000000000..2d0a0e0dd --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/dnac_packages_info.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: dnac_packages_info +short_description: Information module for Dnac Packages +description: +- Get all Dnac Packages. +- Provides information such as name, version of packages installed on the DNA center. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Platform CiscoDNACenterPackagesSummary + description: Complete reference of the CiscoDNACenterPackagesSummary API. + link: https://developer.cisco.com/docs/dna-center/#!cisco-dna-center-packages-summary +notes: + - SDK Method used are + platform.Platform.cisco_dna_center_packages_summary, + + - Paths used are + get /dna/intent/api/v1/dnac-packages, + +""" + +EXAMPLES = r""" +- name: Get all Dnac Packages + cisco.dnac.dnac_packages_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "name": "string", + "version": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/dnacaap_management_execution_status_info.py b/ansible_collections/cisco/dnac/plugins/modules/dnacaap_management_execution_status_info.py new file mode 100644 index 000000000..1afb01dff --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/dnacaap_management_execution_status_info.py @@ -0,0 +1,77 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: dnacaap_management_execution_status_info +short_description: Information module for Dnacaap Management Execution Status +description: +- Get Dnacaap Management Execution Status by id. +- Retrieves the execution details of a Business API. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + executionId: + description: + - ExecutionId path parameter. Execution Id of API. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Task GetBusinessAPIExecutionDetails + description: Complete reference of the GetBusinessAPIExecutionDetails API. + link: https://developer.cisco.com/docs/dna-center/#!get-business-api-execution-details +notes: + - SDK Method used are + task.Task.get_business_api_execution_details, + + - Paths used are + get /dna/intent/api/v1/dnacaap/management/execution-status/{executionId}, + +""" + +EXAMPLES = r""" +- name: Get Dnacaap Management Execution Status by id + cisco.dnac.dnacaap_management_execution_status_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + executionId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "bapiKey": "string", + "bapiName": "string", + "bapiExecutionId": "string", + "startTime": "string", + "startTimeEpoch": 0, + "endTime": "string", + "endTimeEpoch": 0, + "timeDuration": 0, + "status": "string", + "bapiError": "string", + "runtimeInstanceId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/endpoint_analytics_profiling_rules.py b/ansible_collections/cisco/dnac/plugins/modules/endpoint_analytics_profiling_rules.py new file mode 100644 index 000000000..38e2f47ec --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/endpoint_analytics_profiling_rules.py @@ -0,0 +1,244 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: endpoint_analytics_profiling_rules +short_description: Resource module for Endpoint Analytics Profiling Rules +description: +- Manage operations create, update and delete of the resource Endpoint Analytics Profiling Rules. +- Creates profiling rule from the request body. +- Deletes the profiling rule for the given 'ruleId'. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + clusterId: + description: Unique identifier for ML cluster. Only applicable for 'ML Rule'. + type: str + conditionGroups: + description: Endpoint Analytics Profiling Rules's conditionGroups. + suboptions: + condition: + description: Endpoint Analytics Profiling Rules's condition. + suboptions: + attribute: + description: Endpoint Analytics Profiling Rules's attribute. + type: str + attributeDictionary: + description: Endpoint Analytics Profiling Rules's attributeDictionary. + type: str + operator: + description: Endpoint Analytics Profiling Rules's operator. + type: str + value: + description: Endpoint Analytics Profiling Rules's value. + type: str + type: dict + conditionGroup: + description: Endpoint Analytics Profiling Rules's conditionGroup. + elements: dict + type: list + operator: + description: Endpoint Analytics Profiling Rules's operator. + type: str + type: + description: Endpoint Analytics Profiling Rules's type. + type: str + type: dict + isDeleted: + description: Flag to indicate whether the rule was deleted. + type: bool + lastModifiedBy: + description: User that last modified the rule. It is read-only, and is ignored if + provided as part of input request. + type: str + lastModifiedOn: + description: Timestamp (in epoch milliseconds) of last modification. It is read-only, + and is ignored if provided as part of input request. + type: int + pluginId: + description: Plugin for the rule. Only applicable for 'Cisco Default' rules. + type: str + rejected: + description: Flag to indicate whether rule has been rejected by user or not. Only + applicable for 'ML Rule'. + type: bool + result: + description: Endpoint Analytics Profiling Rules's result. + suboptions: + deviceType: + description: List of device types determined by the current rule. + elements: str + type: list + hardwareManufacturer: + description: List of hardware manufacturers determined by the current rule. + elements: str + type: list + hardwareModel: + description: List of hardware models determined by the current rule. + elements: str + type: list + operatingSystem: + description: List of operating systems determined by the current rule. + elements: str + type: list + type: dict + ruleId: + description: Unique identifier for the rule. This is normally generated by the system, + and client does not need to provide it for rules that need to be newly created. + type: str + ruleName: + description: Human readable name for the rule. + type: str + rulePriority: + description: Priority for the rule. + type: int + ruleType: + description: Type of the rule. Allowed values are 'Cisco Default - Static', 'Cisco + Default - Dynamic', 'Custom Rule', 'ML Rule'. + type: str + ruleVersion: + description: Version of the rule. + type: int + sourcePriority: + description: Source priority for the rule. + type: int + usedAttributes: + description: List of attributes used in the rule. Only applicable for 'Cisco Default' + rules. + elements: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +notes: + - SDK Method used are + policy.Policy.create_a_profiling_rule, + policy.Policy.delete_an_existing_profiling_rule, + policy.Policy.update_an_existing_profiling_rule, + + - Paths used are + post /dna/intent/api/v1/endpoint-analytics/profiling-rules, + delete /dna/intent/api/v1/endpoint-analytics/profiling-rules/{ruleId}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.endpoint_analytics_profiling_rules: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + clusterId: string + conditionGroups: + condition: + attribute: string + attributeDictionary: string + operator: string + value: string + conditionGroup: + - {} + operator: string + type: string + isDeleted: true + lastModifiedBy: string + lastModifiedOn: 0 + pluginId: string + rejected: true + result: + deviceType: + - string + hardwareManufacturer: + - string + hardwareModel: + - string + operatingSystem: + - string + ruleId: string + ruleName: string + rulePriority: 0 + ruleType: string + ruleVersion: 0 + sourcePriority: 0 + usedAttributes: + - string + +- name: Update by id + cisco.dnac.endpoint_analytics_profiling_rules: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + clusterId: string + conditionGroups: + condition: + attribute: string + attributeDictionary: string + operator: string + value: string + conditionGroup: + - {} + operator: string + type: string + isDeleted: true + lastModifiedBy: string + lastModifiedOn: 0 + pluginId: string + rejected: true + result: + deviceType: + - string + hardwareManufacturer: + - string + hardwareModel: + - string + operatingSystem: + - string + ruleId: string + ruleName: string + rulePriority: 0 + ruleType: string + ruleVersion: 0 + sourcePriority: 0 + usedAttributes: + - string + +- name: Delete by id + cisco.dnac.endpoint_analytics_profiling_rules: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + ruleId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "id": "string", + "link": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/endpoint_analytics_profiling_rules_info.py b/ansible_collections/cisco/dnac/plugins/modules/endpoint_analytics_profiling_rules_info.py new file mode 100644 index 000000000..9c42ee1ea --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/endpoint_analytics_profiling_rules_info.py @@ -0,0 +1,162 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: endpoint_analytics_profiling_rules_info +short_description: Information module for Endpoint Analytics Profiling Rules +description: +- Get all Endpoint Analytics Profiling Rules. +- Get Endpoint Analytics Profiling Rules by id. +- Fetches details of the profiling rule for the given 'ruleId'. +- This API fetches the list of profiling rules. It can be used to show profiling rules in client applications, or export those from an environment. + 'POST /profiling-rules/bulk' API can be used to import such exported rules into another environment. + If this API is used to export rules to be imported into another Cisco DNA Center system, then ensure that 'includeDeleted' parameter is 'true', + so that deleted rules get synchronized correctly. + Use query parameters to filter the data, as required. If no filter is provided, then it will include only rules of type 'Custom Rule' in the response. + By default, the response is limited to 500 records. Use 'limit' parameter to fetch higher number of records, if required. + 'GET /profiling-rules/count' API can be used to find out the total number of rules in the system. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + ruleType: + description: + - RuleType query parameter. Use comma-separated list of rule types to filter the data. Defaults to 'Custom Rule'. + type: str + includeDeleted: + description: + - IncludeDeleted query parameter. Flag to indicate whether deleted rules should be part of the records fetched. + type: bool + limit: + description: + - > + Limit query parameter. Maximum number of records to be fetched. If not provided, 500 records will be fetched + by default. To fetch all the records in the system, provide a large value for this parameter. + type: int + offset: + description: + - Offset query parameter. Record offset to start data fetch at. Offset starts at zero. + type: int + sortBy: + description: + - > + SortBy query parameter. Name of the column to sort the results on. Please note that fetch might take more + time if sorting is requested. + type: str + order: + description: + - Order query parameter. Order to be used for sorting. + type: str + ruleId: + description: + - RuleId path parameter. Unique rule identifier. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +notes: + - SDK Method used are + policy.Policy.get_details_of_a_single_profiling_rule, + policy.Policy.get_list_of_profiling_rules, + + - Paths used are + get /dna/intent/api/v1/endpoint-analytics/profiling-rules, + get /dna/intent/api/v1/endpoint-analytics/profiling-rules/{ruleId}, + +""" + +EXAMPLES = r""" +- name: Get all Endpoint Analytics Profiling Rules + cisco.dnac.endpoint_analytics_profiling_rules_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: + custom: value + ruleType: string + includeDeleted: True + limit: 0 + offset: 0 + sortBy: string + order: string + register: result + +- name: Get Endpoint Analytics Profiling Rules by id + cisco.dnac.endpoint_analytics_profiling_rules_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: + custom: value + ruleId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "ruleId": "string", + "ruleName": "string", + "ruleType": "string", + "ruleVersion": 0, + "rulePriority": 0, + "sourcePriority": 0, + "isDeleted": true, + "lastModifiedBy": "string", + "lastModifiedOn": 0, + "pluginId": "string", + "clusterId": "string", + "rejected": true, + "result": { + "deviceType": [ + "string" + ], + "hardwareManufacturer": [ + "string" + ], + "hardwareModel": [ + "string" + ], + "operatingSystem": [ + "string" + ] + }, + "conditionGroups": { + "type": "string", + "condition": { + "attribute": "string", + "operator": "string", + "value": "string", + "attributeDictionary": "string" + }, + "operator": "string", + "conditionGroup": [ + {} + ] + }, + "usedAttributes": [ + "string" + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/eox_status_device_info.py b/ansible_collections/cisco/dnac/plugins/modules/eox_status_device_info.py new file mode 100644 index 000000000..6843843e8 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/eox_status_device_info.py @@ -0,0 +1,115 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: eox_status_device_info +short_description: Information module for Eox Status Device +description: +- Get all Eox Status Device. +- Get Eox Status Device by id. +- Retrieves EoX details for a device. +- Retrieves EoX status for all devices in the network. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceId: + description: + - DeviceId path parameter. Device instance UUID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for EoX GetEoXDetailsPerDevice + description: Complete reference of the GetEoXDetailsPerDevice API. + link: https://developer.cisco.com/docs/dna-center/#!get-eo-x-details-per-device +- name: Cisco DNA Center documentation for EoX GetEoXStatusForAllDevices + description: Complete reference of the GetEoXStatusForAllDevices API. + link: https://developer.cisco.com/docs/dna-center/#!get-eo-x-status-for-all-devices +notes: + - SDK Method used are + eo_x.EoX.get_eo_x_details_per_device, + eo_x.EoX.get_eo_x_status_for_all_devices, + + - Paths used are + get /dna/intent/api/v1/eox-status/device, + get /dna/intent/api/v1/eox-status/device/{deviceId}, + +""" + +EXAMPLES = r""" +- name: Get all Eox Status Device + cisco.dnac.eox_status_device_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +- name: Get Eox Status Device by id + cisco.dnac.eox_status_device_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "deviceId": "string", + "alertCount": 0, + "eoxDetails": [ + { + "bulletinHeadline": "string", + "bulletinNumber": "string", + "bulletinURL": "string", + "endOfHardwareNewServiceAttachmentDate": 0, + "endOfHardwareServiceContractRenewalDate": 0, + "endOfLastHardwareShipDate": 0, + "endOfLifeDate": 0, + "endOfLifeExternalAnnouncementDate": 0, + "endOfSaleDate": 0, + "endOfSignatureReleasesDate": 0, + "endOfSoftwareVulnerabilityOrSecuritySupportDate": 0, + "endOfSoftwareVulnerabilityOrSecuritySupportDateHw": 0, + "endOfSoftwareMaintenanceReleasesDate": 0, + "eoxAlertType": "string", + "lastDateOfSupport": 0, + "name": "string" + } + ], + "scanStatus": "string", + "comments": [ + {} + ], + "lastScanTime": 0 + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/eox_status_summary_info.py b/ansible_collections/cisco/dnac/plugins/modules/eox_status_summary_info.py new file mode 100644 index 000000000..0ec817750 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/eox_status_summary_info.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: eox_status_summary_info +short_description: Information module for Eox Status Summary +description: +- Get all Eox Status Summary. +- Retrieves EoX summary for all devices in the network. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for EoX GetEoXSummary + description: Complete reference of the GetEoXSummary API. + link: https://developer.cisco.com/docs/dna-center/#!get-eo-x-summary +notes: + - SDK Method used are + eo_x.EoX.get_eo_x_summary, + + - Paths used are + get /dna/intent/api/v1/eox-status/summary, + +""" + +EXAMPLES = r""" +- name: Get all Eox Status Summary + cisco.dnac.eox_status_summary_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "hardwareCount": 0, + "softwareCount": 0, + "moduleCount": 0, + "totalCount": 0 + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_api_status_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_api_status_info.py new file mode 100644 index 000000000..4ddaaca0a --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_api_status_info.py @@ -0,0 +1,69 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_api_status_info +short_description: Information module for Event Api Status +description: +- Get Event Api Status by id. +- Get the Status of events API calls with provided executionId as mandatory path parameter. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + executionId: + description: + - ExecutionId path parameter. Execution ID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management GetStatusAPIForEvents + description: Complete reference of the GetStatusAPIForEvents API. + link: https://developer.cisco.com/docs/dna-center/#!get-status-api-for-events +notes: + - SDK Method used are + event_management.EventManagement.get_status_api_for_events, + + - Paths used are + get /dna/intent/api/v1/event/api-status/{executionId}, + +""" + +EXAMPLES = r""" +- name: Get Event Api Status by id + cisco.dnac.event_api_status_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + executionId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "errorMessage": {}, + "apiStatus": "string", + "statusMessage": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_artifact_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_artifact_count_info.py new file mode 100644 index 000000000..f34e77fe8 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_artifact_count_info.py @@ -0,0 +1,62 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_artifact_count_info +short_description: Information module for Event Artifact Count +description: +- Get all Event Artifact Count. +- Get the count of registered event artifacts with provided eventIds or tags as mandatory. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management EventArtifactCount + description: Complete reference of the EventArtifactCount API. + link: https://developer.cisco.com/docs/dna-center/#!event-artifact-count +notes: + - SDK Method used are + event_management.EventManagement.eventartifact_count, + + - Paths used are + get /dna/system/api/v1/event/artifact/count, + +""" + +EXAMPLES = r""" +- name: Get all Event Artifact Count + cisco.dnac.event_artifact_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_artifact_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_artifact_info.py new file mode 100644 index 000000000..6e4f14b6a --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_artifact_info.py @@ -0,0 +1,134 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_artifact_info +short_description: Information module for Event Artifact +description: +- Get all Event Artifact. +- Gets the list of artifacts based on provided offset and limit. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + eventIds: + description: + - EventIds query parameter. List of eventIds. + type: str + tags: + description: + - Tags query parameter. Tags defined. + type: str + offset: + description: + - Offset query parameter. Record start offset. + type: int + limit: + description: + - Limit query parameter. # of records to return in result set. + type: int + sortBy: + description: + - SortBy query parameter. Sort by field. + type: str + order: + description: + - Order query parameter. Sorting order (asc/desc). + type: str + search: + description: + - Search query parameter. Findd matches in name, description, eventId, type, category. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management GetEventArtifacts + description: Complete reference of the GetEventArtifacts API. + link: https://developer.cisco.com/docs/dna-center/#!get-event-artifacts +notes: + - SDK Method used are + event_management.EventManagement.get_eventartifacts, + + - Paths used are + get /dna/system/api/v1/event/artifact, + +""" + +EXAMPLES = r""" +- name: Get all Event Artifact + cisco.dnac.event_artifact_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + eventIds: string + tags: string + offset: 0 + limit: 0 + sortBy: string + order: string + search: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "version": "string", + "artifactId": "string", + "namespace": "string", + "name": "string", + "description": "string", + "domain": "string", + "subDomain": "string", + "tags": [ + "string" + ], + "isTemplateEnabled": true, + "ciscoDNAEventLink": "string", + "note": "string", + "isPrivate": true, + "eventPayload": { + "eventId": "string", + "version": "string", + "category": "string", + "type": "string", + "source": "string", + "severity": "string", + "details": { + "device_ip": "string", + "message": "string" + }, + "additionalDetails": {} + }, + "eventTemplates": [ + {} + ], + "isTenantAware": true, + "supportedConnectorTypes": [ + "string" + ], + "tenantId": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_config_connector_types_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_config_connector_types_info.py new file mode 100644 index 000000000..8c0958e7e --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_config_connector_types_info.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_config_connector_types_info +short_description: Information module for Event Config Connector Types +description: +- Get all Event Config Connector Types. +- Get the list of connector types. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management GetConnectorTypes + description: Complete reference of the GetConnectorTypes API. + link: https://developer.cisco.com/docs/dna-center/#!get-connector-types +notes: + - SDK Method used are + event_management.EventManagement.get_connector_types, + + - Paths used are + get /dna/system/api/v1/event/config/connector-types, + +""" + +EXAMPLES = r""" +- name: Get all Event Config Connector Types + cisco.dnac.event_config_connector_types_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "connectorType": "string", + "displayName": "string", + "isDefaultSupported": true, + "isCustomConnector": true + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_count_info.py new file mode 100644 index 000000000..131712342 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_count_info.py @@ -0,0 +1,72 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_count_info +short_description: Information module for Event Count +description: +- Get all Event Count. +- Get the count of registered events with provided eventIds or tags as mandatory. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + eventId: + description: + - EventId query parameter. The registered EventId should be provided. + type: str + tags: + description: + - Tags query parameter. The registered Tags should be provided. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management CountOfEvents + description: Complete reference of the CountOfEvents API. + link: https://developer.cisco.com/docs/dna-center/#!count-of-events +notes: + - SDK Method used are + event_management.EventManagement.count_of_events, + + - Paths used are + get /dna/intent/api/v1/events/count, + +""" + +EXAMPLES = r""" +- name: Get all Event Count + cisco.dnac.event_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + eventId: string + tags: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_email_config.py b/ansible_collections/cisco/dnac/plugins/modules/event_email_config.py new file mode 100644 index 000000000..3b9de49a1 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_email_config.py @@ -0,0 +1,147 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_email_config +short_description: Resource module for Event Email Config +description: +- Manage operations create and update of the resource Event Email Config. +- Create Email Destination. +- Update Email Destination. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + emailConfigId: + description: Required only for update email configuration. + type: str + fromEmail: + description: From Email. + type: str + primarySMTPConfig: + description: Event Email Config's primarySMTPConfig. + suboptions: + hostName: + description: Host Name. + type: str + password: + description: Password. + type: str + port: + description: Port. + type: str + userName: + description: User Name. + type: str + type: dict + secondarySMTPConfig: + description: Event Email Config's secondarySMTPConfig. + suboptions: + hostName: + description: Host Name. + type: str + password: + description: Password. + type: str + port: + description: Port. + type: str + userName: + description: User Name. + type: str + type: dict + subject: + description: Subject. + type: str + toEmail: + description: To Email. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management CreateEmailDestination + description: Complete reference of the CreateEmailDestination API. + link: https://developer.cisco.com/docs/dna-center/#!create-email-destination +- name: Cisco DNA Center documentation for Event Management UpdateEmailDestination + description: Complete reference of the UpdateEmailDestination API. + link: https://developer.cisco.com/docs/dna-center/#!update-email-destination +notes: + - SDK Method used are + event_management.EventManagement.create_email_destination, + event_management.EventManagement.update_email_destination, + + - Paths used are + post /dna/intent/api/v1/event/email-config, + put /dna/intent/api/v1/event/email-config, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.event_email_config: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + emailConfigId: string + fromEmail: string + primarySMTPConfig: + hostName: string + password: string + port: string + userName: string + secondarySMTPConfig: + hostName: string + password: string + port: string + userName: string + subject: string + toEmail: string + +- name: Create + cisco.dnac.event_email_config: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + emailConfigId: string + fromEmail: string + primarySMTPConfig: + hostName: string + password: string + port: string + userName: string + secondarySMTPConfig: + hostName: string + password: string + port: string + userName: string + subject: string + toEmail: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "statusUri": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_email_config_create.py b/ansible_collections/cisco/dnac/plugins/modules/event_email_config_create.py new file mode 100644 index 000000000..b207dde21 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_email_config_create.py @@ -0,0 +1,115 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_email_config_create +short_description: Resource module for Event Email Config Create +description: +- Manage operation create of the resource Event Email Config Create. +- Create Email Destination. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + emailConfigId: + description: Required only for update email configuration. + type: str + fromEmail: + description: From Email. + type: str + primarySMTPConfig: + description: Event Email Config Create's primarySMTPConfig. + suboptions: + hostName: + description: Host Name. + type: str + password: + description: Password. + type: str + port: + description: Port. + type: str + userName: + description: User Name. + type: str + type: dict + secondarySMTPConfig: + description: Event Email Config Create's secondarySMTPConfig. + suboptions: + hostName: + description: Host Name. + type: str + password: + description: Password. + type: str + port: + description: Port. + type: str + userName: + description: User Name. + type: str + type: dict + subject: + description: Subject. + type: str + toEmail: + description: To Email. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management CreateEmailDestination + description: Complete reference of the CreateEmailDestination API. + link: https://developer.cisco.com/docs/dna-center/#!create-email-destination +notes: + - SDK Method used are + event_management.EventManagement.create_email_destination, + + - Paths used are + post /dna/intent/api/v1/event/email-config, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.event_email_config_create: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + emailConfigId: string + fromEmail: string + primarySMTPConfig: + hostName: string + password: string + port: string + userName: string + secondarySMTPConfig: + hostName: string + password: string + port: string + userName: string + subject: string + toEmail: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "statusUri": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_email_config_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_email_config_info.py new file mode 100644 index 000000000..6aa855855 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_email_config_info.py @@ -0,0 +1,84 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_email_config_info +short_description: Information module for Event Email Config +description: +- Get all Event Email Config. +- Get Email Destination. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management GetEmailDestination + description: Complete reference of the GetEmailDestination API. + link: https://developer.cisco.com/docs/dna-center/#!get-email-destination +notes: + - SDK Method used are + event_management.EventManagement.get_email_destination, + + - Paths used are + get /dna/intent/api/v1/event/email-config, + +""" + +EXAMPLES = r""" +- name: Get all Event Email Config + cisco.dnac.event_email_config_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "emailConfigId": "string", + "primarySMTPConfig": { + "hostName": "string", + "port": "string", + "userName": "string", + "password": "string", + "security": "string" + }, + "secondarySMTPConfig": { + "hostName": "string", + "port": "string", + "userName": "string", + "password": "string", + "security": "string" + }, + "fromEmail": "string", + "toEmail": "string", + "subject": "string", + "version": "string", + "tenantId": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_email_config_update.py b/ansible_collections/cisco/dnac/plugins/modules/event_email_config_update.py new file mode 100644 index 000000000..2234ae907 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_email_config_update.py @@ -0,0 +1,115 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_email_config_update +short_description: Resource module for Event Email Config Update +description: +- Manage operation update of the resource Event Email Config Update. +- Update Email Destination. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + emailConfigId: + description: Required only for update email configuration. + type: str + fromEmail: + description: From Email. + type: str + primarySMTPConfig: + description: Event Email Config Update's primarySMTPConfig. + suboptions: + hostName: + description: Host Name. + type: str + password: + description: Password. + type: str + port: + description: Port. + type: str + userName: + description: User Name. + type: str + type: dict + secondarySMTPConfig: + description: Event Email Config Update's secondarySMTPConfig. + suboptions: + hostName: + description: Host Name. + type: str + password: + description: Password. + type: str + port: + description: Port. + type: str + userName: + description: User Name. + type: str + type: dict + subject: + description: Subject. + type: str + toEmail: + description: To Email. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management UpdateEmailDestination + description: Complete reference of the UpdateEmailDestination API. + link: https://developer.cisco.com/docs/dna-center/#!update-email-destination +notes: + - SDK Method used are + event_management.EventManagement.update_email_destination, + + - Paths used are + put /dna/intent/api/v1/event/email-config, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.event_email_config_update: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + emailConfigId: string + fromEmail: string + primarySMTPConfig: + hostName: string + password: string + port: string + userName: string + secondarySMTPConfig: + hostName: string + password: string + port: string + userName: string + subject: string + toEmail: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "statusUri": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_info.py new file mode 100644 index 000000000..ac34fbf25 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_info.py @@ -0,0 +1,111 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_info +short_description: Information module for Event +description: +- Get all Event. +- Gets the list of registered Events with provided eventIds or tags as mandatory. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + eventId: + description: + - EventId query parameter. The registered EventId should be provided. + type: str + tags: + description: + - Tags query parameter. The registered Tags should be provided. + type: str + offset: + description: + - Offset query parameter. The number of Registries to offset in the resultset whose default value 0. + type: int + limit: + description: + - Limit query parameter. The number of Registries to limit in the resultset whose default value 10. + type: int + sortBy: + description: + - SortBy query parameter. SortBy field name. + type: str + order: + description: + - Order query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management GetEvents + description: Complete reference of the GetEvents API. + link: https://developer.cisco.com/docs/dna-center/#!get-events +notes: + - SDK Method used are + event_management.EventManagement.get_events, + + - Paths used are + get /dna/intent/api/v1/events, + +""" + +EXAMPLES = r""" +- name: Get all Event + cisco.dnac.event_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + eventId: string + tags: string + offset: 0 + limit: 0 + sortBy: string + order: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "eventId": "string", + "nameSpace": "string", + "name": "string", + "description": "string", + "version": "string", + "category": "string", + "domain": "string", + "subDomain": "string", + "type": "string", + "tags": [ + "string" + ], + "severity": 0, + "details": {}, + "subscriptionTypes": [ + "string" + ] + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_series_audit_logs_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_series_audit_logs_info.py new file mode 100644 index 000000000..dbb7b5320 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_series_audit_logs_info.py @@ -0,0 +1,219 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_series_audit_logs_info +short_description: Information module for Event Series Audit Logs +description: +- Get all Event Series Audit Logs. +- Get Audit Log Event instances from the Event-Hub. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + parentInstanceId: + description: + - ParentInstanceId query parameter. Parent Audit Log record's instanceID. + type: str + instanceId: + description: + - InstanceId query parameter. InstanceID of the Audit Log. + type: str + name: + description: + - Name query parameter. Audit Log notification event name. + type: str + eventId: + description: + - EventId query parameter. Audit Log notification's event ID. + type: str + category: + description: + - > + Category query parameter. Audit Log notification's event category. Supported values INFO, WARN, ERROR, + ALERT, TASK_PROGRESS, TASK_FAILURE, TASK_COMPLETE, COMMAND, QUERY, CONVERSATION. + type: str + severity: + description: + - Severity query parameter. Audit Log notification's event severity. Supported values 1, 2, 3, 4, 5. + type: str + domain: + description: + - Domain query parameter. Audit Log notification's event domain. + type: str + subDomain: + description: + - SubDomain query parameter. Audit Log notification's event sub-domain. + type: str + source: + description: + - Source query parameter. Audit Log notification's event source. + type: str + userId: + description: + - UserId query parameter. Audit Log notification's event userId. + type: str + context: + description: + - Context query parameter. Audit Log notification's event correlationId. + type: str + eventHierarchy: + description: + - > + EventHierarchy query parameter. Audit Log notification's event eventHierarchy. Example "US.CA.San Jose" OR + "US.CA" OR "CA.San Jose" - Delimiter for hierarchy separation is ".". + type: str + siteId: + description: + - SiteId query parameter. Audit Log notification's siteId. + type: str + deviceId: + description: + - DeviceId query parameter. Audit Log notification's deviceId. + type: str + isSystemEvents: + description: + - IsSystemEvents query parameter. Parameter to filter system generated audit-logs. + type: bool + description: + description: + - > + Description query parameter. String full/partial search - (Provided input string is case insensitively + matched for records). + type: str + offset: + description: + - Offset query parameter. Position of a particular Audit Log record in the data. + type: int + limit: + description: + - Limit query parameter. Number of Audit Log records to be returned per page. + type: int + startTime: + description: + - > + StartTime query parameter. Start Time in milliseconds since Epoch Eg. 1597950637211 (when provided endTime + is mandatory). + type: int + endTime: + description: + - > + EndTime query parameter. End Time in milliseconds since Epoch Eg. 1597961437211 (when provided startTime is + mandatory). + type: int + sortBy: + description: + - > + SortBy query parameter. Sort the Audit Logs by certain fields. Supported values are event notification + header attributes. + type: str + order: + description: + - > + Order query parameter. Order of the sorted Audit Log records. Default value is desc by timestamp. Supported + values asc, desc. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management GetAuditLogRecords + description: Complete reference of the GetAuditLogRecords API. + link: https://developer.cisco.com/docs/dna-center/#!get-audit-log-records +notes: + - SDK Method used are + event_management.EventManagement.get_auditlog_records, + + - Paths used are + get /dna/data/api/v1/event/event-series/audit-logs, + +""" + +EXAMPLES = r""" +- name: Get all Event Series Audit Logs + cisco.dnac.event_series_audit_logs_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + parentInstanceId: string + instanceId: string + name: string + eventId: string + category: string + severity: string + domain: string + subDomain: string + source: string + userId: string + context: string + eventHierarchy: string + siteId: string + deviceId: string + isSystemEvents: True + description: string + offset: 0 + limit: 0 + startTime: 0 + endTime: 0 + sortBy: string + order: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "version": "string", + "instanceId": "string", + "eventId": "string", + "namespace": "string", + "name": "string", + "description": "string", + "type": "string", + "category": "string", + "domain": "string", + "subDomain": "string", + "severity": 0, + "source": "string", + "timestamp": 0, + "tags": [ + {} + ], + "details": {}, + "ciscoDnaEventLink": "string", + "note": "string", + "tntId": "string", + "context": "string", + "userId": "string", + "i18n": "string", + "eventHierarchy": "string", + "message": "string", + "messageParams": "string", + "additionalDetails": {}, + "parentInstanceId": "string", + "network": "string", + "childCount": 0, + "tenantId": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_series_audit_logs_parent_records_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_series_audit_logs_parent_records_info.py new file mode 100644 index 000000000..6f6a2b616 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_series_audit_logs_parent_records_info.py @@ -0,0 +1,214 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_series_audit_logs_parent_records_info +short_description: Information module for Event Series Audit Logs Parent Records +description: +- Get all Event Series Audit Logs Parent Records. +- Get Parent Audit Log Event instances from the Event-Hub. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + instanceId: + description: + - InstanceId query parameter. InstanceID of the Audit Log. + type: str + name: + description: + - Name query parameter. Audit Log notification event name. + type: str + eventId: + description: + - EventId query parameter. Audit Log notification's event ID. + type: str + category: + description: + - > + Category query parameter. Audit Log notification's event category. Supported values INFO, WARN, ERROR, + ALERT, TASK_PROGRESS, TASK_FAILURE, TASK_COMPLETE, COMMAND, QUERY, CONVERSATION. + type: str + severity: + description: + - Severity query parameter. Audit Log notification's event severity. Supported values 1, 2, 3, 4, 5. + type: str + domain: + description: + - Domain query parameter. Audit Log notification's event domain. + type: str + subDomain: + description: + - SubDomain query parameter. Audit Log notification's event sub-domain. + type: str + source: + description: + - Source query parameter. Audit Log notification's event source. + type: str + userId: + description: + - UserId query parameter. Audit Log notification's event userId. + type: str + context: + description: + - Context query parameter. Audit Log notification's event correlationId. + type: str + eventHierarchy: + description: + - > + EventHierarchy query parameter. Audit Log notification's event eventHierarchy. Example "US.CA.San Jose" OR + "US.CA" OR "CA.San Jose" - Delimiter for hierarchy separation is ".". + type: str + siteId: + description: + - SiteId query parameter. Audit Log notification's siteId. + type: str + deviceId: + description: + - DeviceId query parameter. Audit Log notification's deviceId. + type: str + isSystemEvents: + description: + - IsSystemEvents query parameter. Parameter to filter system generated audit-logs. + type: bool + description: + description: + - > + Description query parameter. String full/partial search - (Provided input string is case insensitively + matched for records). + type: str + offset: + description: + - Offset query parameter. Position of a particular Audit Log record in the data. + type: int + limit: + description: + - Limit query parameter. Number of Audit Log records to be returned per page. + type: int + startTime: + description: + - > + StartTime query parameter. Start Time in milliseconds since Epoch Eg. 1597950637211 (when provided endTime + is mandatory). + type: int + endTime: + description: + - > + EndTime query parameter. End Time in milliseconds since Epoch Eg. 1597961437211 (when provided startTime is + mandatory). + type: int + sortBy: + description: + - > + SortBy query parameter. Sort the Audit Logs by certain fields. Supported values are event notification + header attributes. + type: str + order: + description: + - > + Order query parameter. Order of the sorted Audit Log records. Default value is desc by timestamp. Supported + values asc, desc. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management GetAuditLogParentRecords + description: Complete reference of the GetAuditLogParentRecords API. + link: https://developer.cisco.com/docs/dna-center/#!get-audit-log-parent-records +notes: + - SDK Method used are + event_management.EventManagement.get_auditlog_parent_records, + + - Paths used are + get /dna/data/api/v1/event/event-series/audit-log/parent-records, + +""" + +EXAMPLES = r""" +- name: Get all Event Series Audit Logs Parent Records + cisco.dnac.event_series_audit_logs_parent_records_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + instanceId: string + name: string + eventId: string + category: string + severity: string + domain: string + subDomain: string + source: string + userId: string + context: string + eventHierarchy: string + siteId: string + deviceId: string + isSystemEvents: True + description: string + offset: 0 + limit: 0 + startTime: 0 + endTime: 0 + sortBy: string + order: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "version": "string", + "instanceId": "string", + "eventId": "string", + "namespace": "string", + "name": "string", + "description": "string", + "type": "string", + "category": "string", + "domain": "string", + "subDomain": "string", + "severity": 0, + "source": "string", + "timestamp": 0, + "tags": [ + {} + ], + "details": {}, + "ciscoDnaEventLink": "string", + "note": "string", + "tntId": "string", + "context": "string", + "userId": "string", + "i18n": "string", + "eventHierarchy": "string", + "message": "string", + "messageParams": "string", + "additionalDetails": {}, + "parentInstanceId": "string", + "network": "string", + "childCount": 0, + "tenantId": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_series_audit_logs_summary_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_series_audit_logs_summary_info.py new file mode 100644 index 000000000..ee2063fa0 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_series_audit_logs_summary_info.py @@ -0,0 +1,172 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_series_audit_logs_summary_info +short_description: Information module for Event Series Audit Logs Summary +description: +- Get all Event Series Audit Logs Summary. +- Get Audit Log Summary from the Event-Hub. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + parentInstanceId: + description: + - ParentInstanceId query parameter. Parent Audit Log record's instanceID. + type: str + isParentOnly: + description: + - IsParentOnly query parameter. Parameter to filter parent only audit-logs. + type: bool + instanceId: + description: + - InstanceId query parameter. InstanceID of the Audit Log. + type: str + name: + description: + - Name query parameter. Audit Log notification event name. + type: str + eventId: + description: + - EventId query parameter. Audit Log notification's event ID. + type: str + category: + description: + - > + Category query parameter. Audit Log notification's event category. Supported values INFO, WARN, ERROR, + ALERT, TASK_PROGRESS, TASK_FAILURE, TASK_COMPLETE, COMMAND, QUERY, CONVERSATION. + type: str + severity: + description: + - Severity query parameter. Audit Log notification's event severity. Supported values 1, 2, 3, 4, 5. + type: str + domain: + description: + - Domain query parameter. Audit Log notification's event domain. + type: str + subDomain: + description: + - SubDomain query parameter. Audit Log notification's event sub-domain. + type: str + source: + description: + - Source query parameter. Audit Log notification's event source. + type: str + userId: + description: + - UserId query parameter. Audit Log notification's event userId. + type: str + context: + description: + - Context query parameter. Audit Log notification's event correlationId. + type: str + eventHierarchy: + description: + - > + EventHierarchy query parameter. Audit Log notification's event eventHierarchy. Example "US.CA.San Jose" OR + "US.CA" OR "CA.San Jose" - Delimiter for hierarchy separation is ".". + type: str + siteId: + description: + - SiteId query parameter. Audit Log notification's siteId. + type: str + deviceId: + description: + - DeviceId query parameter. Audit Log notification's deviceId. + type: str + isSystemEvents: + description: + - IsSystemEvents query parameter. Parameter to filter system generated audit-logs. + type: bool + description: + description: + - > + Description query parameter. String full/partial search - (Provided input string is case insensitively + matched for records). + type: str + startTime: + description: + - > + StartTime query parameter. Start Time in milliseconds since Epoch Eg. 1597950637211 (when provided endTime + is mandatory). + type: int + endTime: + description: + - > + EndTime query parameter. End Time in milliseconds since Epoch Eg. 1597961437211 (when provided startTime is + mandatory). + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management GetAuditLogSummary + description: Complete reference of the GetAuditLogSummary API. + link: https://developer.cisco.com/docs/dna-center/#!get-audit-log-summary +notes: + - SDK Method used are + event_management.EventManagement.get_auditlog_summary, + + - Paths used are + get /dna/data/api/v1/event/event-series/audit-log/summary, + +""" + +EXAMPLES = r""" +- name: Get all Event Series Audit Logs Summary + cisco.dnac.event_series_audit_logs_summary_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + parentInstanceId: string + isParentOnly: True + instanceId: string + name: string + eventId: string + category: string + severity: string + domain: string + subDomain: string + source: string + userId: string + context: string + eventHierarchy: string + siteId: string + deviceId: string + isSystemEvents: True + description: string + startTime: 0 + endTime: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "count": 0, + "maxTimestamp": 0, + "minTimestamp": 0 + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_series_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_series_count_info.py new file mode 100644 index 000000000..6fd07cf4a --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_series_count_info.py @@ -0,0 +1,105 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_series_count_info +short_description: Information module for Event Series Count +description: +- Get all Event Series Count. +- Get the Count of Published Notifications. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + eventIds: + description: + - EventIds query parameter. The registered EventId should be provided. + type: str + startTime: + description: + - StartTime query parameter. Start Time in milliseconds. + type: int + endTime: + description: + - EndTime query parameter. End Time in milliseconds. + type: int + category: + description: + - Category query parameter. + type: str + type: + description: + - Type query parameter. + type: str + severity: + description: + - Severity query parameter. + type: str + domain: + description: + - Domain query parameter. + type: str + subDomain: + description: + - SubDomain query parameter. Sub Domain. + type: str + source: + description: + - Source query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management CountOfNotifications + description: Complete reference of the CountOfNotifications API. + link: https://developer.cisco.com/docs/dna-center/#!count-of-notifications +notes: + - SDK Method used are + event_management.EventManagement.count_of_notifications, + + - Paths used are + get /dna/intent/api/v1/event/event-series/count, + +""" + +EXAMPLES = r""" +- name: Get all Event Series Count + cisco.dnac.event_series_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + eventIds: string + startTime: 0 + endTime: 0 + category: string + type: string + severity: string + domain: string + subDomain: string + source: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: str + sample: > + "string" +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_series_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_series_info.py new file mode 100644 index 000000000..523e5a708 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_series_info.py @@ -0,0 +1,163 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_series_info +short_description: Information module for Event Series +description: +- Get all Event Series. +- Get the list of Published Notifications. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + eventIds: + description: + - EventIds query parameter. The registered EventId should be provided. + type: str + startTime: + description: + - StartTime query parameter. Start Time in milliseconds. + type: int + endTime: + description: + - EndTime query parameter. End Time in milliseconds. + type: int + category: + description: + - Category query parameter. + type: str + type: + description: + - Type query parameter. + type: str + severity: + description: + - Severity query parameter. + type: str + domain: + description: + - Domain query parameter. + type: str + subDomain: + description: + - SubDomain query parameter. Sub Domain. + type: str + source: + description: + - Source query parameter. + type: str + offset: + description: + - Offset query parameter. Start Offset. + type: int + limit: + description: + - Limit query parameter. # of records. + type: int + sortBy: + description: + - SortBy query parameter. Sort By column. + type: str + order: + description: + - Order query parameter. Ascending/Descending order asc/desc. + type: str + tags: + description: + - Tags query parameter. + type: str + namespace: + description: + - Namespace query parameter. + type: str + siteId: + description: + - SiteId query parameter. Site Id. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management GetNotifications + description: Complete reference of the GetNotifications API. + link: https://developer.cisco.com/docs/dna-center/#!get-notifications +notes: + - SDK Method used are + event_management.EventManagement.get_notifications, + + - Paths used are + get /dna/intent/api/v1/event/event-series, + +""" + +EXAMPLES = r""" +- name: Get all Event Series + cisco.dnac.event_series_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + eventIds: string + startTime: 0 + endTime: 0 + category: string + type: string + severity: string + domain: string + subDomain: string + source: string + offset: 0 + limit: 0 + sortBy: string + order: string + tags: string + namespace: string + siteId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "eventId": "string", + "instanceId": "string", + "namespace": "string", + "name": "string", + "description": "string", + "version": "string", + "category": "string", + "domain": "string", + "subDomain": "string", + "type": "string", + "severity": "string", + "source": "string", + "timestamp": "string", + "details": "string", + "eventHierarchy": "string", + "network": { + "siteId": "string", + "deviceId": "string" + } + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_snmp_config_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_snmp_config_info.py new file mode 100644 index 000000000..6ae23c7f3 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_snmp_config_info.py @@ -0,0 +1,111 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_snmp_config_info +short_description: Information module for Event Snmp Config +description: +- Get all Event Snmp Config. +- Get SNMP Destination. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + configId: + description: + - ConfigId query parameter. List of SNMP configurations. + type: str + offset: + description: + - Offset query parameter. The number of SNMP configuration's to offset in the resultset whose default value 0. + type: int + limit: + description: + - Limit query parameter. The number of SNMP configuration's to limit in the resultset whose default value 10. + type: int + sortBy: + description: + - SortBy query parameter. SortBy field name. + type: str + order: + description: + - Order query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management GetSNMPDestination + description: Complete reference of the GetSNMPDestination API. + link: https://developer.cisco.com/docs/dna-center/#!get-snmp-destination +notes: + - SDK Method used are + event_management.EventManagement.get_snmp_destination, + + - Paths used are + get /dna/intent/api/v1/event/snmp-config, + +""" + +EXAMPLES = r""" +- name: Get all Event Snmp Config + cisco.dnac.event_snmp_config_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + configId: string + offset: 0 + limit: 0 + sortBy: string + order: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "errorMessage": { + "errors": [ + "string" + ] + }, + "apiStatus": "string", + "statusMessage": [ + { + "version": "string", + "tenantId": "string", + "configId": "string", + "name": "string", + "description": "string", + "ipAddress": "string", + "port": 0, + "snmpVersion": "string", + "community": "string", + "userName": "string", + "snmpMode": "string", + "snmpAuthType": "string", + "authPassword": "string", + "snmpPrivacyType": "string", + "privacyPassword": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_subscription.py b/ansible_collections/cisco/dnac/plugins/modules/event_subscription.py new file mode 100644 index 000000000..38c2899ae --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_subscription.py @@ -0,0 +1,220 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_subscription +short_description: Resource module for Event Subscription +description: +- Manage operations create, update and delete of the resource Event Subscription. +- Subscribe SubscriptionEndpoint to list of registered events Deprecated . +- Delete EventSubscriptions. +- Update SubscriptionEndpoint to list of registered events Deprecated . +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + payload: + description: Event Subscription's payload. + elements: dict + suboptions: + description: + description: Description. + type: str + filter: + description: Event Subscription's filter. + suboptions: + categories: + description: Categories. + elements: str + type: list + domainsSubdomains: + description: Event Subscription's domainsSubdomains. + elements: dict + suboptions: + domain: + description: Domain. + type: str + subDomains: + description: Sub Domains. + elements: str + type: list + type: list + eventIds: + description: Event Ids (Comma separated event ids). + elements: str + type: list + severities: + description: Severities. + elements: str + type: list + siteIds: + description: Site Ids. + elements: str + type: list + sources: + description: Sources. + elements: str + type: list + types: + description: Types. + elements: str + type: list + type: dict + name: + description: Name. + type: str + subscriptionEndpoints: + description: Event Subscription's subscriptionEndpoints. + elements: dict + suboptions: + instanceId: + description: (From Get Rest/Webhook Subscription Details --> pick instanceId). + type: str + subscriptionDetails: + description: Event Subscription's subscriptionDetails. + suboptions: + connectorType: + description: Connector Type (Must be REST). + type: str + type: dict + type: list + subscriptionId: + description: Subscription Id (Unique UUID). + type: str + version: + description: Version. + type: str + type: list + subscriptions: + description: Subscriptions query parameter. List of EventSubscriptionId's for removal. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management CreateEventSubscriptions + description: Complete reference of the CreateEventSubscriptions API. + link: https://developer.cisco.com/docs/dna-center/#!create-event-subscriptions +- name: Cisco DNA Center documentation for Event Management DeleteEventSubscriptions + description: Complete reference of the DeleteEventSubscriptions API. + link: https://developer.cisco.com/docs/dna-center/#!delete-event-subscriptions +- name: Cisco DNA Center documentation for Event Management UpdateEventSubscriptions + description: Complete reference of the UpdateEventSubscriptions API. + link: https://developer.cisco.com/docs/dna-center/#!update-event-subscriptions +notes: + - SDK Method used are + event_management.EventManagement.create_event_subscriptions, + event_management.EventManagement.delete_event_subscriptions, + event_management.EventManagement.update_event_subscriptions, + + - Paths used are + post /dna/intent/api/v1/event/subscription, + delete /dna/intent/api/v1/event/subscription, + put /dna/intent/api/v1/event/subscription, + +""" + +EXAMPLES = r""" +- name: Delete all + cisco.dnac.event_subscription: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + subscriptions: string + +- name: Update all + cisco.dnac.event_subscription: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - description: string + filter: + categories: + - string + domainsSubdomains: + - domain: string + subDomains: + - string + eventIds: + - string + severities: + - string + siteIds: + - string + sources: + - string + types: + - string + name: string + subscriptionEndpoints: + - instanceId: string + subscriptionDetails: + connectorType: string + subscriptionId: string + version: string + +- name: Create + cisco.dnac.event_subscription: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - description: string + filter: + categories: + - string + domainsSubdomains: + - domain: string + subDomains: + - string + eventIds: + - string + severities: + - string + siteIds: + - string + sources: + - string + types: + - string + name: string + subscriptionEndpoints: + - instanceId: string + subscriptionDetails: + connectorType: string + subscriptionId: string + version: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "statusUri": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_subscription_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_count_info.py new file mode 100644 index 000000000..e9eb3e432 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_count_info.py @@ -0,0 +1,67 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_subscription_count_info +short_description: Information module for Event Subscription Count +description: +- Get all Event Subscription Count. +- Returns the Count of EventSubscriptions. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + eventIds: + description: + - EventIds query parameter. List of subscriptions related to the respective eventIds. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management CountOfEventSubscriptions + description: Complete reference of the CountOfEventSubscriptions API. + link: https://developer.cisco.com/docs/dna-center/#!count-of-event-subscriptions +notes: + - SDK Method used are + event_management.EventManagement.count_of_event_subscriptions, + + - Paths used are + get /dna/intent/api/v1/event/subscription/count, + +""" + +EXAMPLES = r""" +- name: Get all Event Subscription Count + cisco.dnac.event_subscription_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + eventIds: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_subscription_details_email_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_details_email_info.py new file mode 100644 index 000000000..7109b1ac1 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_details_email_info.py @@ -0,0 +1,103 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_subscription_details_email_info +short_description: Information module for Event Subscription Details Email +description: +- Get all Event Subscription Details Email. +- Gets the list of subscription details for specified connectorType. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + name: + description: + - Name query parameter. Name of the specific configuration. + type: str + instanceId: + description: + - InstanceId query parameter. Instance Id of the specific configuration. + type: str + offset: + description: + - Offset query parameter. The number of Email Subscription detail's to offset in the resultset whose default value 0. + type: int + limit: + description: + - Limit query parameter. The number of Email Subscription detail's to limit in the resultset whose default value 10. + type: int + sortBy: + description: + - SortBy query parameter. SortBy field name. + type: str + order: + description: + - Order query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management GetEmailSubscriptionDetails + description: Complete reference of the GetEmailSubscriptionDetails API. + link: https://developer.cisco.com/docs/dna-center/#!get-email-subscription-details +notes: + - SDK Method used are + event_management.EventManagement.get_email_subscription_details, + + - Paths used are + get /dna/intent/api/v1/event/subscription-details/email, + +""" + +EXAMPLES = r""" +- name: Get all Event Subscription Details Email + cisco.dnac.event_subscription_details_email_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + name: string + instanceId: string + offset: 0 + limit: 0 + sortBy: string + order: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "instanceId": "string", + "name": "string", + "description": "string", + "connectorType": "string", + "fromEmailAddress": "string", + "toEmailAddresses": [ + "string" + ], + "subject": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_subscription_details_rest_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_details_rest_info.py new file mode 100644 index 000000000..cde6348bf --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_details_rest_info.py @@ -0,0 +1,117 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_subscription_details_rest_info +short_description: Information module for Event Subscription Details Rest +description: +- Get all Event Subscription Details Rest. +- Gets the list of subscription details for specified connectorType. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + name: + description: + - Name query parameter. Name of the specific configuration. + type: str + instanceId: + description: + - InstanceId query parameter. Instance Id of the specific configuration. + type: str + offset: + description: + - > + Offset query parameter. The number of Rest/Webhook Subscription detail's to offset in the resultset whose + default value 0. + type: int + limit: + description: + - > + Limit query parameter. The number of Rest/Webhook Subscription detail's to limit in the resultset whose + default value 10. + type: int + sortBy: + description: + - SortBy query parameter. SortBy field name. + type: str + order: + description: + - Order query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management GetRestWebhookSubscriptionDetails + description: Complete reference of the GetRestWebhookSubscriptionDetails API. + link: https://developer.cisco.com/docs/dna-center/#!get-rest-webhook-subscription-details +notes: + - SDK Method used are + event_management.EventManagement.get_rest_webhook_subscription_details, + + - Paths used are + get /dna/intent/api/v1/event/subscription-details/rest, + +""" + +EXAMPLES = r""" +- name: Get all Event Subscription Details Rest + cisco.dnac.event_subscription_details_rest_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + name: string + instanceId: string + offset: 0 + limit: 0 + sortBy: string + order: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "instanceId": "string", + "name": "string", + "description": "string", + "connectorType": "string", + "url": "string", + "method": "string", + "trustCert": "string", + "headers": [ + { + "name": "string", + "value": "string" + } + ], + "queryParams": [ + "string" + ], + "pathParams": [ + "string" + ] + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_subscription_details_syslog_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_details_syslog_info.py new file mode 100644 index 000000000..2d3676759 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_details_syslog_info.py @@ -0,0 +1,108 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_subscription_details_syslog_info +short_description: Information module for Event Subscription Details Syslog +description: +- Get all Event Subscription Details Syslog. +- Gets the list of subscription details for specified connectorType. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + name: + description: + - Name query parameter. Name of the specific configuration. + type: str + instanceId: + description: + - InstanceId query parameter. Instance Id of the specific configuration. + type: str + offset: + description: + - > + Offset query parameter. The number of Syslog Subscription detail's to offset in the resultset whose default + value 0. + type: int + limit: + description: + - Limit query parameter. The number of Syslog Subscription detail's to limit in the resultset whose default value 10. + type: int + sortBy: + description: + - SortBy query parameter. SortBy field name. + type: str + order: + description: + - Order query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management GetSyslogSubscriptionDetails + description: Complete reference of the GetSyslogSubscriptionDetails API. + link: https://developer.cisco.com/docs/dna-center/#!get-syslog-subscription-details +notes: + - SDK Method used are + event_management.EventManagement.get_syslog_subscription_details, + + - Paths used are + get /dna/intent/api/v1/event/subscription-details/syslog, + +""" + +EXAMPLES = r""" +- name: Get all Event Subscription Details Syslog + cisco.dnac.event_subscription_details_syslog_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + name: string + instanceId: string + offset: 0 + limit: 0 + sortBy: string + order: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "instanceId": "string", + "name": "string", + "description": "string", + "connectorType": "string", + "syslogConfig": { + "configId": "string", + "name": "string", + "description": "string", + "host": "string", + "port": "string", + "protocol": "string" + } + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_subscription_email.py b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_email.py new file mode 100644 index 000000000..56b82b4a8 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_email.py @@ -0,0 +1,227 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_subscription_email +short_description: Resource module for Event Subscription Email +description: +- Manage operations create and update of the resource Event Subscription Email. +- Create Email Subscription Endpoint for list of registered events. +- Update Email Subscription Endpoint for list of registered events. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + payload: + description: Event Subscription Email's payload. + elements: dict + suboptions: + description: + description: Description. + type: str + filter: + description: Event Subscription Email's filter. + suboptions: + categories: + description: Categories. + elements: str + type: list + domainsSubdomains: + description: Event Subscription Email's domainsSubdomains. + elements: dict + suboptions: + domain: + description: Domain. + type: str + subDomains: + description: Sub Domains. + elements: str + type: list + type: list + eventIds: + description: Event Ids. + elements: str + type: list + severities: + description: Severities. + elements: int + type: list + siteIds: + description: Site Ids. + elements: str + type: list + sources: + description: Sources. + elements: str + type: list + types: + description: Types. + elements: str + type: list + type: dict + name: + description: Name. + type: str + subscriptionEndpoints: + description: Event Subscription Email's subscriptionEndpoints. + elements: dict + suboptions: + instanceId: + description: (From Get Email Subscription Details --> pick InstanceId). + type: str + subscriptionDetails: + description: Event Subscription Email's subscriptionDetails. + suboptions: + connectorType: + description: Connector Type (Must be EMAIL). + type: str + description: + description: Description. + type: str + fromEmailAddress: + description: Senders Email Address. + type: str + name: + description: Name. + type: str + subject: + description: Email Subject. + type: str + toEmailAddresses: + description: Recipient's Email Addresses (Comma separated). + elements: str + type: list + type: dict + type: list + subscriptionId: + description: Subscription Id (Unique UUID). + type: str + version: + description: Version. + type: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management CreateEmailEventSubscription + description: Complete reference of the CreateEmailEventSubscription API. + link: https://developer.cisco.com/docs/dna-center/#!create-email-event-subscription +- name: Cisco DNA Center documentation for Event Management UpdateEmailEventSubscription + description: Complete reference of the UpdateEmailEventSubscription API. + link: https://developer.cisco.com/docs/dna-center/#!update-email-event-subscription +notes: + - SDK Method used are + event_management.EventManagement.create_email_event_subscription, + event_management.EventManagement.update_email_event_subscription, + + - Paths used are + post /dna/intent/api/v1/event/subscription/email, + put /dna/intent/api/v1/event/subscription/email, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.event_subscription_email: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - description: string + filter: + categories: + - string + domainsSubdomains: + - domain: string + subDomains: + - string + eventIds: + - string + severities: + - 0 + siteIds: + - string + sources: + - string + types: + - string + name: string + subscriptionEndpoints: + - instanceId: string + subscriptionDetails: + connectorType: string + description: string + fromEmailAddress: string + name: string + subject: string + toEmailAddresses: + - string + subscriptionId: string + version: string + +- name: Update all + cisco.dnac.event_subscription_email: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - description: string + filter: + categories: + - string + domainsSubdomains: + - domain: string + subDomains: + - string + eventIds: + - string + severities: + - 0 + siteIds: + - string + sources: + - string + types: + - string + name: string + subscriptionEndpoints: + - instanceId: string + subscriptionDetails: + connectorType: string + description: string + fromEmailAddress: string + name: string + subject: string + toEmailAddresses: + - string + subscriptionId: string + version: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "statusUri": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_subscription_email_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_email_info.py new file mode 100644 index 000000000..5d20ef478 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_email_info.py @@ -0,0 +1,170 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_subscription_email_info +short_description: Information module for Event Subscription Email +description: +- Get all Event Subscription Email. +- Gets the list of email Subscriptions's based on provided query params. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + eventIds: + description: + - > + EventIds query parameter. List of email subscriptions related to the respective eventIds (Comma separated + event ids). + type: str + offset: + description: + - Offset query parameter. The number of Subscriptions's to offset in the resultset whose default value 0. + type: int + limit: + description: + - Limit query parameter. The number of Subscriptions's to limit in the resultset whose default value 10. + type: int + sortBy: + description: + - SortBy query parameter. SortBy field name. + type: str + order: + description: + - Order query parameter. + type: str + domain: + description: + - Domain query parameter. List of email subscriptions related to the respective domain. + type: str + subDomain: + description: + - SubDomain query parameter. List of email subscriptions related to the respective sub-domain. + type: str + category: + description: + - Category query parameter. List of email subscriptions related to the respective category. + type: str + type: + description: + - Type query parameter. List of email subscriptions related to the respective type. + type: str + name: + description: + - Name query parameter. List of email subscriptions related to the respective name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management GetEmailEventSubscriptions + description: Complete reference of the GetEmailEventSubscriptions API. + link: https://developer.cisco.com/docs/dna-center/#!get-email-event-subscriptions +notes: + - SDK Method used are + event_management.EventManagement.get_email_event_subscriptions, + + - Paths used are + get /dna/intent/api/v1/event/subscription/email, + +""" + +EXAMPLES = r""" +- name: Get all Event Subscription Email + cisco.dnac.event_subscription_email_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + eventIds: string + offset: 0 + limit: 0 + sortBy: string + order: string + domain: string + subDomain: string + category: string + type: string + name: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "version": "string", + "subscriptionId": "string", + "name": "string", + "description": "string", + "subscriptionEndpoints": [ + { + "instanceId": "string", + "subscriptionDetails": { + "connectorType": "string", + "instanceId": "string", + "name": "string", + "description": "string", + "fromEmailAddress": "string", + "toEmailAddresses": [ + "string" + ], + "subject": "string" + }, + "connectorType": "string" + } + ], + "filter": { + "eventIds": [ + "string" + ], + "others": [ + "string" + ], + "domainsSubdomains": [ + { + "domain": "string", + "subDomains": [ + "string" + ] + } + ], + "types": [ + "string" + ], + "categories": [ + "string" + ], + "severities": [ + "string" + ], + "sources": [ + "string" + ], + "siteIds": [ + "string" + ] + }, + "isPrivate": true, + "tenantId": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_subscription_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_info.py new file mode 100644 index 000000000..7655d9676 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_info.py @@ -0,0 +1,161 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_subscription_info +short_description: Information module for Event Subscription +description: +- Get all Event Subscription. +- Gets the list of Subscriptions's based on provided offset and limit Deprecated . +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + eventIds: + description: + - EventIds query parameter. List of subscriptions related to the respective eventIds. + type: str + offset: + description: + - Offset query parameter. The number of Subscriptions's to offset in the resultset whose default value 0. + type: int + limit: + description: + - Limit query parameter. The number of Subscriptions's to limit in the resultset whose default value 10. + type: int + sortBy: + description: + - SortBy query parameter. SortBy field name. + type: str + order: + description: + - Order query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management GetEventSubscriptions + description: Complete reference of the GetEventSubscriptions API. + link: https://developer.cisco.com/docs/dna-center/#!get-event-subscriptions +notes: + - SDK Method used are + event_management.EventManagement.get_event_subscriptions, + + - Paths used are + get /dna/intent/api/v1/event/subscription, + +""" + +EXAMPLES = r""" +- name: Get all Event Subscription + cisco.dnac.event_subscription_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + eventIds: string + offset: 0 + limit: 0 + sortBy: string + order: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "version": "string", + "subscriptionId": "string", + "name": "string", + "description": "string", + "subscriptionEndpoints": [ + { + "instanceId": "string", + "subscriptionDetails": { + "connectorType": "string", + "instanceId": "string", + "name": "string", + "description": "string", + "url": "string", + "basePath": "string", + "resource": "string", + "method": "string", + "trustCert": true, + "headers": [ + { + "string": "string" + } + ], + "queryParams": [ + { + "string": "string" + } + ], + "pathParams": [ + { + "string": "string" + } + ], + "body": "string", + "connectTimeout": 0, + "readTimeout": 0 + }, + "connectorType": "string" + } + ], + "filter": { + "eventIds": [ + "string" + ], + "others": [ + "string" + ], + "domainsSubdomains": [ + { + "domain": "string", + "subDomains": [ + "string" + ] + } + ], + "types": [ + "string" + ], + "categories": [ + "string" + ], + "severities": [ + "string" + ], + "sources": [ + "string" + ], + "siteIds": [ + "string" + ] + }, + "isPrivate": true, + "tenantId": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_subscription_rest.py b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_rest.py new file mode 100644 index 000000000..acfc5f9e4 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_rest.py @@ -0,0 +1,199 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_subscription_rest +short_description: Resource module for Event Subscription Rest +description: +- Manage operations create and update of the resource Event Subscription Rest. +- Create Rest/Webhook Subscription Endpoint for list of registered events. +- Update Rest/Webhook Subscription Endpoint for list of registered events. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + payload: + description: Event Subscription Rest's payload. + elements: dict + suboptions: + description: + description: Description. + type: str + filter: + description: Event Subscription Rest's filter. + suboptions: + categories: + description: Categories. + elements: str + type: list + domainsSubdomains: + description: Event Subscription Rest's domainsSubdomains. + elements: dict + suboptions: + domain: + description: Domain. + type: str + subDomains: + description: Sub Domains. + elements: str + type: list + type: list + eventIds: + description: Event Ids (Comma separated event ids). + elements: str + type: list + severities: + description: Severities. + elements: str + type: list + siteIds: + description: Site Ids. + elements: str + type: list + sources: + description: Sources. + elements: str + type: list + types: + description: Types. + elements: str + type: list + type: dict + name: + description: Name. + type: str + subscriptionEndpoints: + description: Event Subscription Rest's subscriptionEndpoints. + elements: dict + suboptions: + instanceId: + description: (From Get Rest/Webhook Subscription Details --> pick instanceId). + type: str + subscriptionDetails: + description: Event Subscription Rest's subscriptionDetails. + suboptions: + connectorType: + description: Connector Type (Must be REST). + type: str + type: dict + type: list + subscriptionId: + description: Subscription Id (Unique UUID). + type: str + version: + description: Version. + type: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management CreateRestWebhookEventSubscription + description: Complete reference of the CreateRestWebhookEventSubscription API. + link: https://developer.cisco.com/docs/dna-center/#!create-rest-webhook-event-subscription +- name: Cisco DNA Center documentation for Event Management UpdateRestWebhookEventSubscription + description: Complete reference of the UpdateRestWebhookEventSubscription API. + link: https://developer.cisco.com/docs/dna-center/#!update-rest-webhook-event-subscription +notes: + - SDK Method used are + event_management.EventManagement.create_rest_webhook_event_subscription, + event_management.EventManagement.update_rest_webhook_event_subscription, + + - Paths used are + post /dna/intent/api/v1/event/subscription/rest, + put /dna/intent/api/v1/event/subscription/rest, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.event_subscription_rest: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - description: string + filter: + categories: + - string + domainsSubdomains: + - domain: string + subDomains: + - string + eventIds: + - string + severities: + - string + siteIds: + - string + sources: + - string + types: + - string + name: string + subscriptionEndpoints: + - instanceId: string + subscriptionDetails: + connectorType: string + subscriptionId: string + version: string + +- name: Update all + cisco.dnac.event_subscription_rest: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - description: string + filter: + categories: + - string + domainsSubdomains: + - domain: string + subDomains: + - string + eventIds: + - string + severities: + - string + siteIds: + - string + sources: + - string + types: + - string + name: string + subscriptionEndpoints: + - instanceId: string + subscriptionDetails: + connectorType: string + subscriptionId: string + version: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "statusUri": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_subscription_rest_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_rest_info.py new file mode 100644 index 000000000..a26bf7473 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_rest_info.py @@ -0,0 +1,186 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_subscription_rest_info +short_description: Information module for Event Subscription Rest +description: +- Get all Event Subscription Rest. +- Gets the list of Rest/Webhook Subscriptions's based on provided query params. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + eventIds: + description: + - EventIds query parameter. List of subscriptions related to the respective eventIds (Comma separated event ids). + type: str + offset: + description: + - Offset query parameter. The number of Subscriptions's to offset in the resultset whose default value 0. + type: int + limit: + description: + - Limit query parameter. The number of Subscriptions's to limit in the resultset whose default value 10. + type: int + sortBy: + description: + - SortBy query parameter. SortBy field name. + type: str + order: + description: + - Order query parameter. + type: str + domain: + description: + - Domain query parameter. List of subscriptions related to the respective domain. + type: str + subDomain: + description: + - SubDomain query parameter. List of subscriptions related to the respective sub-domain. + type: str + category: + description: + - Category query parameter. List of subscriptions related to the respective category. + type: str + type: + description: + - Type query parameter. List of subscriptions related to the respective type. + type: str + name: + description: + - Name query parameter. List of subscriptions related to the respective name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management GetRestWebhookEventSubscriptions + description: Complete reference of the GetRestWebhookEventSubscriptions API. + link: https://developer.cisco.com/docs/dna-center/#!get-rest-webhook-event-subscriptions +notes: + - SDK Method used are + event_management.EventManagement.get_rest_webhook_event_subscriptions, + + - Paths used are + get /dna/intent/api/v1/event/subscription/rest, + +""" + +EXAMPLES = r""" +- name: Get all Event Subscription Rest + cisco.dnac.event_subscription_rest_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + eventIds: string + offset: 0 + limit: 0 + sortBy: string + order: string + domain: string + subDomain: string + category: string + type: string + name: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "version": "string", + "subscriptionId": "string", + "name": "string", + "description": "string", + "subscriptionEndpoints": [ + { + "instanceId": "string", + "subscriptionDetails": { + "connectorType": "string", + "instanceId": "string", + "name": "string", + "description": "string", + "url": "string", + "basePath": "string", + "resource": "string", + "method": "string", + "trustCert": "string", + "headers": [ + { + "string": "string" + } + ], + "queryParams": [ + { + "string": "string" + } + ], + "pathParams": [ + { + "string": "string" + } + ], + "body": "string", + "connectTimeout": "string", + "readTimeout": "string" + }, + "connectorType": "string" + } + ], + "filter": { + "eventIds": [ + "string" + ], + "others": [ + "string" + ], + "domainsSubdomains": [ + { + "domain": "string", + "subDomains": [ + "string" + ] + } + ], + "types": [ + "string" + ], + "categories": [ + "string" + ], + "severities": [ + "string" + ], + "sources": [ + "string" + ], + "siteIds": [ + "string" + ] + }, + "isPrivate": "string", + "tenantId": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_subscription_syslog.py b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_syslog.py new file mode 100644 index 000000000..802664038 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_syslog.py @@ -0,0 +1,199 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_subscription_syslog +short_description: Resource module for Event Subscription Syslog +description: +- Manage operations create and update of the resource Event Subscription Syslog. +- Create Syslog Subscription Endpoint for list of registered events. +- Update Syslog Subscription Endpoint for list of registered events. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + payload: + description: Event Subscription Syslog's payload. + elements: dict + suboptions: + description: + description: Description. + type: str + filter: + description: Event Subscription Syslog's filter. + suboptions: + categories: + description: Categories. + elements: str + type: list + domainsSubdomains: + description: Event Subscription Syslog's domainsSubdomains. + elements: dict + suboptions: + domain: + description: Domain. + type: str + subDomains: + description: Sub Domains. + elements: str + type: list + type: list + eventIds: + description: Event Ids (Comma separated event ids). + elements: str + type: list + severities: + description: Severities. + elements: str + type: list + siteIds: + description: Site Ids. + elements: str + type: list + sources: + description: Sources. + elements: str + type: list + types: + description: Types. + elements: str + type: list + type: dict + name: + description: Name. + type: str + subscriptionEndpoints: + description: Event Subscription Syslog's subscriptionEndpoints. + elements: dict + suboptions: + instanceId: + description: (From Get Syslog Subscription Details --> pick instanceId). + type: str + subscriptionDetails: + description: Event Subscription Syslog's subscriptionDetails. + suboptions: + connectorType: + description: Connector Type (Must be SYSLOG). + type: str + type: dict + type: list + subscriptionId: + description: Subscription Id (Unique UUID). + type: str + version: + description: Version. + type: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management CreateSyslogEventSubscription + description: Complete reference of the CreateSyslogEventSubscription API. + link: https://developer.cisco.com/docs/dna-center/#!create-syslog-event-subscription +- name: Cisco DNA Center documentation for Event Management UpdateSyslogEventSubscription + description: Complete reference of the UpdateSyslogEventSubscription API. + link: https://developer.cisco.com/docs/dna-center/#!update-syslog-event-subscription +notes: + - SDK Method used are + event_management.EventManagement.create_syslog_event_subscription, + event_management.EventManagement.update_syslog_event_subscription, + + - Paths used are + post /dna/intent/api/v1/event/subscription/syslog, + put /dna/intent/api/v1/event/subscription/syslog, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.event_subscription_syslog: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - description: string + filter: + categories: + - string + domainsSubdomains: + - domain: string + subDomains: + - string + eventIds: + - string + severities: + - string + siteIds: + - string + sources: + - string + types: + - string + name: string + subscriptionEndpoints: + - instanceId: string + subscriptionDetails: + connectorType: string + subscriptionId: string + version: string + +- name: Create + cisco.dnac.event_subscription_syslog: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - description: string + filter: + categories: + - string + domainsSubdomains: + - domain: string + subDomains: + - string + eventIds: + - string + severities: + - string + siteIds: + - string + sources: + - string + types: + - string + name: string + subscriptionEndpoints: + - instanceId: string + subscriptionDetails: + connectorType: string + subscriptionId: string + version: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "statusUri": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_subscription_syslog_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_syslog_info.py new file mode 100644 index 000000000..dcd077007 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_subscription_syslog_info.py @@ -0,0 +1,172 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_subscription_syslog_info +short_description: Information module for Event Subscription Syslog +description: +- Get all Event Subscription Syslog. +- Gets the list of Syslog Subscriptions's based on provided offset and limit. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + eventIds: + description: + - EventIds query parameter. List of subscriptions related to the respective eventIds (Comma separated event ids). + type: str + offset: + description: + - Offset query parameter. The number of Subscriptions's to offset in the resultset whose default value 0. + type: int + limit: + description: + - Limit query parameter. The number of Subscriptions's to limit in the resultset whose default value 10. + type: int + sortBy: + description: + - SortBy query parameter. SortBy field name. + type: str + order: + description: + - Order query parameter. + type: str + domain: + description: + - Domain query parameter. List of subscriptions related to the respective domain. + type: str + subDomain: + description: + - SubDomain query parameter. List of subscriptions related to the respective sub-domain. + type: str + category: + description: + - Category query parameter. List of subscriptions related to the respective category. + type: str + type: + description: + - Type query parameter. List of subscriptions related to the respective type. + type: str + name: + description: + - Name query parameter. List of subscriptions related to the respective name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management GetSyslogEventSubscriptions + description: Complete reference of the GetSyslogEventSubscriptions API. + link: https://developer.cisco.com/docs/dna-center/#!get-syslog-event-subscriptions +notes: + - SDK Method used are + event_management.EventManagement.get_syslog_event_subscriptions, + + - Paths used are + get /dna/intent/api/v1/event/subscription/syslog, + +""" + +EXAMPLES = r""" +- name: Get all Event Subscription Syslog + cisco.dnac.event_subscription_syslog_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + eventIds: string + offset: 0 + limit: 0 + sortBy: string + order: string + domain: string + subDomain: string + category: string + type: string + name: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "version": "string", + "subscriptionId": "string", + "name": "string", + "description": "string", + "subscriptionEndpoints": [ + { + "instanceId": "string", + "subscriptionDetails": { + "connectorType": "string", + "instanceId": "string", + "name": "string", + "description": "string", + "syslogConfig": { + "version": "string", + "tenantId": "string", + "configId": "string", + "name": "string", + "description": "string", + "host": "string", + "port": 0 + } + }, + "connectorType": "string" + } + ], + "filter": { + "eventIds": [ + "string" + ], + "others": [ + "string" + ], + "domainsSubdomains": [ + { + "domain": "string", + "subDomains": [ + "string" + ] + } + ], + "types": [ + "string" + ], + "categories": [ + "string" + ], + "severities": [ + {} + ], + "sources": [ + "string" + ], + "siteIds": [ + "string" + ] + }, + "isPrivate": true, + "tenantId": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_syslog_config.py b/ansible_collections/cisco/dnac/plugins/modules/event_syslog_config.py new file mode 100644 index 000000000..a59316f39 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_syslog_config.py @@ -0,0 +1,111 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_syslog_config +short_description: Resource module for Event Syslog Config +description: +- Manage operations create and update of the resource Event Syslog Config. +- Create Syslog Destination. +- Update Syslog Destination. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + configId: + description: Required only for update syslog configuration. + type: str + description: + description: Description. + type: str + host: + description: Host. + type: str + name: + description: Name. + type: str + port: + description: Port. + type: str + protocol: + description: Protocol. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management CreateSyslogDestination + description: Complete reference of the CreateSyslogDestination API. + link: https://developer.cisco.com/docs/dna-center/#!create-syslog-destination +- name: Cisco DNA Center documentation for Event Management UpdateSyslogDestination + description: Complete reference of the UpdateSyslogDestination API. + link: https://developer.cisco.com/docs/dna-center/#!update-syslog-destination +notes: + - SDK Method used are + event_management.EventManagement.create_syslog_destination, + event_management.EventManagement.update_syslog_destination, + + - Paths used are + post /dna/intent/api/v1/event/syslog-config, + put /dna/intent/api/v1/event/syslog-config, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.event_syslog_config: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + configId: string + description: string + host: string + name: string + port: string + protocol: string + +- name: Create + cisco.dnac.event_syslog_config: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + configId: string + description: string + host: string + name: string + port: string + protocol: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "errorMessage": { + "errors": [ + "string" + ] + }, + "apiStatus": "string", + "statusMessage": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_syslog_config_info.py b/ansible_collections/cisco/dnac/plugins/modules/event_syslog_config_info.py new file mode 100644 index 000000000..2c2617128 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_syslog_config_info.py @@ -0,0 +1,114 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_syslog_config_info +short_description: Information module for Event Syslog Config +description: +- Get all Event Syslog Config. +- Get Syslog Destination. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + configId: + description: + - ConfigId query parameter. Config id of syslog server. + type: str + name: + description: + - Name query parameter. Name of syslog server. + type: str + protocol: + description: + - Protocol query parameter. Protocol of syslog server. + type: str + offset: + description: + - Offset query parameter. The number of syslog configuration's to offset in the resultset whose default value 0. + type: int + limit: + description: + - Limit query parameter. The number of syslog configuration's to limit in the resultset whose default value 10. + type: int + sortBy: + description: + - SortBy query parameter. SortBy field name. + type: str + order: + description: + - Order query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management GetSyslogDestination + description: Complete reference of the GetSyslogDestination API. + link: https://developer.cisco.com/docs/dna-center/#!get-syslog-destination +notes: + - SDK Method used are + event_management.EventManagement.get_syslog_destination, + + - Paths used are + get /dna/intent/api/v1/event/syslog-config, + +""" + +EXAMPLES = r""" +- name: Get all Event Syslog Config + cisco.dnac.event_syslog_config_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + configId: string + name: string + protocol: string + offset: 0 + limit: 0 + sortBy: string + order: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "errorMessage": { + "errors": [ + "string" + ] + }, + "apiStatus": "string", + "statusMessage": [ + { + "version": "string", + "tenantId": "string", + "configId": "string", + "name": "string", + "description": "string", + "host": "string", + "port": 0, + "protocol": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_webhook_create.py b/ansible_collections/cisco/dnac/plugins/modules/event_webhook_create.py new file mode 100644 index 000000000..b9c585ee9 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_webhook_create.py @@ -0,0 +1,109 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_webhook_create +short_description: Resource module for Event Webhook Create +description: +- Manage operation create of the resource Event Webhook Create. +- Create Webhook Destination. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + description: + description: Description. + type: str + headers: + description: Event Webhook Create's headers. + elements: dict + suboptions: + defaultValue: + description: Default Value. + type: str + encrypt: + description: Encrypt. + type: bool + name: + description: Name. + type: str + value: + description: Value. + type: str + type: list + method: + description: Method. + type: str + name: + description: Name. + type: str + trustCert: + description: Trust Cert. + type: bool + url: + description: Url. + type: str + webhookId: + description: Required only for update webhook configuration. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management CreateWebhookDestination + description: Complete reference of the CreateWebhookDestination API. + link: https://developer.cisco.com/docs/dna-center/#!create-webhook-destination +notes: + - SDK Method used are + event_management.EventManagement.create_webhook_destination, + + - Paths used are + post /dna/intent/api/v1/event/webhook, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.event_webhook_create: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + description: string + headers: + - defaultValue: string + encrypt: true + name: string + value: string + method: string + name: string + trustCert: true + url: string + webhookId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "errorMessage": { + "errors": [ + "string" + ] + }, + "apiStatus": "string", + "statusMessage": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/event_webhook_update.py b/ansible_collections/cisco/dnac/plugins/modules/event_webhook_update.py new file mode 100644 index 000000000..91d70839b --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/event_webhook_update.py @@ -0,0 +1,109 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: event_webhook_update +short_description: Resource module for Event Webhook Update +description: +- Manage operation update of the resource Event Webhook Update. +- Update Webhook Destination. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + description: + description: Description. + type: str + headers: + description: Event Webhook Update's headers. + elements: dict + suboptions: + defaultValue: + description: Default Value. + type: str + encrypt: + description: Encrypt. + type: bool + name: + description: Name. + type: str + value: + description: Value. + type: str + type: list + method: + description: Method. + type: str + name: + description: Name. + type: str + trustCert: + description: Trust Cert. + type: bool + url: + description: Url. + type: str + webhookId: + description: Required only for update webhook configuration. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management UpdateWebhookDestination + description: Complete reference of the UpdateWebhookDestination API. + link: https://developer.cisco.com/docs/dna-center/#!update-webhook-destination +notes: + - SDK Method used are + event_management.EventManagement.update_webhook_destination, + + - Paths used are + put /dna/intent/api/v1/event/webhook, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.event_webhook_update: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + description: string + headers: + - defaultValue: string + encrypt: true + name: string + value: string + method: string + name: string + trustCert: true + url: string + webhookId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "errorMessage": { + "errors": [ + "string" + ] + }, + "apiStatus": "string", + "statusMessage": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/execute_suggested_actions_commands.py b/ansible_collections/cisco/dnac/plugins/modules/execute_suggested_actions_commands.py new file mode 100644 index 000000000..51df59677 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/execute_suggested_actions_commands.py @@ -0,0 +1,77 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: execute_suggested_actions_commands +short_description: Resource module for Execute Suggested Actions Commands +description: +- Manage operation create of the resource Execute Suggested Actions Commands. +- > + This API triggers the execution of the suggested actions for an issue, given the Issue Id. It will return an + execution Id. At the completion of the execution, the output of the commands associated with the suggested actions + will be provided. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + entity_type: + description: Commands provided as part of the suggested actions for an issue can + be executed based on issue id. The value here must be issue_id. + type: str + entity_value: + description: Contains the actual value for the entity type that has been defined. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Issues ExecuteSuggestedActionsCommands + description: Complete reference of the ExecuteSuggestedActionsCommands API. + link: https://developer.cisco.com/docs/dna-center/#!execute-suggested-actions-commands +notes: + - SDK Method used are + issues.Issues.execute_suggested_actions_commands, + + - Paths used are + post /dna/intent/api/v1/execute-suggested-actions-commands, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.execute_suggested_actions_commands: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + entity_type: string + entity_value: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + sample: > + [ + { + "actionInfo": "string", + "stepsCount": 0, + "entityId": "string", + "hostname": "string", + "stepsDescription": "string", + "command": "string", + "commandOutput": {} + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/file_import.py b/ansible_collections/cisco/dnac/plugins/modules/file_import.py new file mode 100644 index 000000000..f82598e0c --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/file_import.py @@ -0,0 +1,63 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: file_import +short_description: Resource module for File Import +description: +- Manage operation create of the resource File Import. +- Uploads a new file within a specific nameSpace. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + filePath: + description: File absolute path. + type: str + nameSpace: + description: NameSpace path parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for File UploadFile + description: Complete reference of the UploadFile API. + link: https://developer.cisco.com/docs/dna-center/#!upload-file +notes: + - SDK Method used are + file.File.upload_file, + + - Paths used are + post /dna/intent/api/v1/file/{nameSpace}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.file_import: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + filePath: /tmp/uploads/Test-242.bin + nameSpace: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + {} +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/file_info.py b/ansible_collections/cisco/dnac/plugins/modules/file_info.py new file mode 100644 index 000000000..bf07d1072 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/file_info.py @@ -0,0 +1,85 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: file_info +short_description: Information module for File +description: +- Get File by id. +- Downloads a file specified by fileId. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + fileId: + description: + - FileId path parameter. File Identification number. + type: str + dirPath: + description: + - Directory absolute path. Defaults to the current working directory. + type: str + saveFile: + description: + - Enable or disable automatic file creation of raw response. + type: bool + filename: + description: + - The filename used to save the download file. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for File DownloadAFileByFileId + description: Complete reference of the DownloadAFileByFileId API. + link: https://developer.cisco.com/docs/dna-center/#!download-a-file-by-file-id +notes: + - SDK Method used are + file.File.download_a_file_by_fileid, + + - Paths used are + get /dna/intent/api/v1/file/{fileId}, + +""" + +EXAMPLES = r""" +- name: Get File by id + cisco.dnac.file_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + fileId: string + dirPath: /tmp/downloads/Test-242.bin + saveFile: true + filename: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "data": "filecontent", + "filename": "filename", + "dirpath": "download/directory", + "path": "download/directory/filename" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/file_namespace_files_info.py b/ansible_collections/cisco/dnac/plugins/modules/file_namespace_files_info.py new file mode 100644 index 000000000..e28b10c8f --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/file_namespace_files_info.py @@ -0,0 +1,85 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: file_namespace_files_info +short_description: Information module for File Namespace Files +description: +- Get File Namespace Files by name. +- Returns list of files under a specific namespace. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + nameSpace: + description: + - NameSpace path parameter. A listing of fileId's. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for File GetListOfFiles + description: Complete reference of the GetListOfFiles API. + link: https://developer.cisco.com/docs/dna-center/#!get-list-of-files +notes: + - SDK Method used are + file.File.get_list_of_files, + + - Paths used are + get /dna/intent/api/v1/file/namespace/{nameSpace}, + +""" + +EXAMPLES = r""" +- name: Get File Namespace Files by name + cisco.dnac.file_namespace_files_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + nameSpace: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "attributeInfo": {}, + "downloadPath": "string", + "encrypted": true, + "fileFormat": "string", + "fileSize": "string", + "id": "string", + "md5Checksum": "string", + "name": "string", + "nameSpace": "string", + "sftpServerList": [ + {} + ], + "sha1Checksum": "string", + "taskId": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/file_namespaces_info.py b/ansible_collections/cisco/dnac/plugins/modules/file_namespaces_info.py new file mode 100644 index 000000000..a0fc5682f --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/file_namespaces_info.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: file_namespaces_info +short_description: Information module for File Namespaces +description: +- Get all File Namespaces. +- Returns list of available namespaces. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for File GetListOfAvailableNamespaces + description: Complete reference of the GetListOfAvailableNamespaces API. + link: https://developer.cisco.com/docs/dna-center/#!get-list-of-available-namespaces +notes: + - SDK Method used are + file.File.get_list_of_available_namespaces, + + - Paths used are + get /dna/intent/api/v1/file/namespace, + +""" + +EXAMPLES = r""" +- name: Get all File Namespaces + cisco.dnac.file_namespaces_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + "string" + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/global_credential_delete.py b/ansible_collections/cisco/dnac/plugins/modules/global_credential_delete.py new file mode 100644 index 000000000..13c9630c3 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/global_credential_delete.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: global_credential_delete +short_description: Resource module for Global Credential Delete +description: +- Manage operation delete of the resource Global Credential Delete. +- Deletes global credential for the given ID. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + globalCredentialId: + description: GlobalCredentialId path parameter. ID of global-credential. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery DeleteGlobalCredentialsById + description: Complete reference of the DeleteGlobalCredentialsById API. + link: https://developer.cisco.com/docs/dna-center/#!delete-global-credentials-by-id +notes: + - SDK Method used are + discovery.Discovery.delete_global_credentials_by_id, + + - Paths used are + delete /dna/intent/api/v1/global-credential/{globalCredentialId}, + +""" + +EXAMPLES = r""" +- name: Delete by id + cisco.dnac.global_credential_delete: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + globalCredentialId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/global_credential_info.py b/ansible_collections/cisco/dnac/plugins/modules/global_credential_info.py new file mode 100644 index 000000000..4fe317b6f --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/global_credential_info.py @@ -0,0 +1,104 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: global_credential_info +short_description: Information module for Global Credential +description: +- Get all Global Credential. +- Get Global Credential by id. +- Returns global credential for the given credential sub type. +- Returns the credential sub type for the given Id. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + credentialSubType: + description: + - > + CredentialSubType query parameter. Credential type as CLI / SNMPV2_READ_COMMUNITY / SNMPV2_WRITE_COMMUNITY / + SNMPV3 / HTTP_WRITE / HTTP_READ / NETCONF. + type: str + sortBy: + description: + - SortBy query parameter. + type: str + order: + description: + - Order query parameter. + type: str + id: + description: + - Id path parameter. Global Credential ID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery GetCredentialSubTypeByCredentialId + description: Complete reference of the GetCredentialSubTypeByCredentialId API. + link: https://developer.cisco.com/docs/dna-center/#!get-credential-sub-type-by-credential-id +- name: Cisco DNA Center documentation for Discovery GetGlobalCredentials + description: Complete reference of the GetGlobalCredentials API. + link: https://developer.cisco.com/docs/dna-center/#!get-global-credentials +notes: + - SDK Method used are + discovery.Discovery.get_credential_sub_type_by_credential_id, + discovery.Discovery.get_global_credentials, + + - Paths used are + get /dna/intent/api/v1/global-credential, + get /dna/intent/api/v1/global-credential/{id}, + +""" + +EXAMPLES = r""" +- name: Get all Global Credential + cisco.dnac.global_credential_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + credentialSubType: string + sortBy: string + order: string + register: result + +- name: Get Global Credential by id + cisco.dnac.global_credential_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": "string", + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/global_credential_update.py b/ansible_collections/cisco/dnac/plugins/modules/global_credential_update.py new file mode 100644 index 000000000..127504846 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/global_credential_update.py @@ -0,0 +1,71 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: global_credential_update +short_description: Resource module for Global Credential Update +description: +- Manage operation update of the resource Global Credential Update. +- Update global credential for network devices in sites. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + globalCredentialId: + description: GlobalCredentialId path parameter. Global credential Uuid. + type: str + siteUuids: + description: Global Credential Update's siteUuids. + elements: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery UpdateGlobalCredentials + description: Complete reference of the UpdateGlobalCredentials API. + link: https://developer.cisco.com/docs/dna-center/#!update-global-credentials +notes: + - SDK Method used are + discovery.Discovery.update_global_credentials, + + - Paths used are + put /dna/intent/api/v1/global-credential/{globalCredentialId}, + +""" + +EXAMPLES = r""" +- name: Update by id + cisco.dnac.global_credential_update: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + globalCredentialId: string + siteUuids: + - string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/global_credential_v2.py b/ansible_collections/cisco/dnac/plugins/modules/global_credential_v2.py new file mode 100644 index 000000000..0679fed86 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/global_credential_v2.py @@ -0,0 +1,279 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: global_credential_v2 +short_description: Resource module for Global Credential V2 +description: +- Manage operations create, update and delete of the resource Global Credential V2. +- > + API to create new global credentials. Multiple credentials of various types can be passed at once. Please refer + sample Request Body for more information. +- Delete a global credential. Only 'id' of the credential has to be passed. +- > + API to update device credentials. Multiple credentials can be passed at once, but only a single credential of a + given type can be passed at once. Please refer sample Request Body for more information. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + cliCredential: + description: Global Credential V2's cliCredential. + suboptions: + description: + description: Description. + type: str + enablePassword: + description: Enable Password. + type: str + id: + description: Id. + type: str + password: + description: Password. + type: str + username: + description: Username. + type: str + type: dict + httpsRead: + description: Global Credential V2's httpsRead. + suboptions: + id: + description: Id. + type: str + name: + description: Name. + type: str + password: + description: Password. + type: str + port: + description: Port. + type: int + username: + description: Username. + type: str + type: dict + httpsWrite: + description: Global Credential V2's httpsWrite. + suboptions: + id: + description: Id. + type: str + name: + description: Name. + type: str + password: + description: Password. + type: str + port: + description: Port. + type: int + username: + description: Username. + type: str + type: dict + id: + description: Id path parameter. Global Credential id. + type: str + snmpV2cRead: + description: Global Credential V2's snmpV2cRead. + suboptions: + description: + description: Description. + type: str + id: + description: Id. + type: str + readCommunity: + description: Read Community. + type: str + type: dict + snmpV2cWrite: + description: Global Credential V2's snmpV2cWrite. + suboptions: + description: + description: Description. + type: str + id: + description: Id. + type: str + writeCommunity: + description: Write Community. + type: str + type: dict + snmpV3: + description: Global Credential V2's snmpV3. + suboptions: + authPassword: + description: Auth Password. + type: str + authType: + description: Auth Type. + type: str + description: + description: Description. + type: str + id: + description: Id. + type: str + privacyPassword: + description: Privacy Password. + type: str + privacyType: + description: Privacy Type. + type: str + snmpMode: + description: Snmp Mode. + type: str + username: + description: Username. + type: str + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery CreateGlobalCredentialsV2 + description: Complete reference of the CreateGlobalCredentialsV2 API. + link: https://developer.cisco.com/docs/dna-center/#!create-global-credentials-v-2 +- name: Cisco DNA Center documentation for Discovery DeleteGlobalCredentialV2 + description: Complete reference of the DeleteGlobalCredentialV2 API. + link: https://developer.cisco.com/docs/dna-center/#!delete-global-credential-v-2 +- name: Cisco DNA Center documentation for Discovery UpdateGlobalCredentialsV2 + description: Complete reference of the UpdateGlobalCredentialsV2 API. + link: https://developer.cisco.com/docs/dna-center/#!update-global-credentials-v-2 +notes: + - SDK Method used are + discovery.Discovery.create_global_credentials_v2, + discovery.Discovery.delete_global_credential_v2, + discovery.Discovery.update_global_credentials_v2, + + - Paths used are + post /dna/intent/api/v2/global-credential, + delete /dna/intent/api/v2/global-credential/{id}, + put /dna/intent/api/v2/global-credential, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.global_credential_v2: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + cliCredential: + description: string + enablePassword: string + id: string + password: string + username: string + httpsRead: + id: string + name: string + password: string + port: 0 + username: string + httpsWrite: + id: string + name: string + password: string + port: 0 + username: string + snmpV2cRead: + description: string + id: string + readCommunity: string + snmpV2cWrite: + description: string + id: string + writeCommunity: string + snmpV3: + authPassword: string + authType: string + description: string + id: string + privacyPassword: string + privacyType: string + snmpMode: string + username: string + +- name: Create + cisco.dnac.global_credential_v2: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + cliCredential: + - description: string + enablePassword: string + password: string + username: string + httpsRead: + - name: string + password: string + port: 0 + username: string + httpsWrite: + - name: string + password: string + port: 0 + username: string + snmpV2cRead: + - description: string + readCommunity: string + snmpV2cWrite: + - description: string + writeCommunity: string + snmpV3: + - authPassword: string + authType: string + description: string + privacyPassword: string + privacyType: string + snmpMode: string + username: string + +- name: Delete by id + cisco.dnac.global_credential_v2: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + id: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/global_credential_v2_info.py b/ansible_collections/cisco/dnac/plugins/modules/global_credential_v2_info.py new file mode 100644 index 000000000..c746964cb --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/global_credential_v2_info.py @@ -0,0 +1,145 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: global_credential_v2_info +short_description: Information module for Global Credential V2 +description: +- Get all Global Credential V2. +- > + API to get device credentials' details. It fetches all global credentials of all types at once, without the need + to pass any input parameters. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery GetAllGlobalCredentialsV2 + description: Complete reference of the GetAllGlobalCredentialsV2 API. + link: https://developer.cisco.com/docs/dna-center/#!get-all-global-credentials-v-2 +notes: + - SDK Method used are + discovery.Discovery.get_all_global_credentials_v2, + + - Paths used are + get /dna/intent/api/v2/global-credential, + +""" + +EXAMPLES = r""" +- name: Get all Global Credential V2 + cisco.dnac.global_credential_v2_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "cliCredential": [ + { + "password": "string", + "username": "string", + "enablePassword": "string", + "description": "string", + "comments": "string", + "credentialType": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "id": "string" + } + ], + "snmpV2cRead": [ + { + "readCommunity": "string", + "description": "string", + "comments": "string", + "credentialType": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "id": "string" + } + ], + "snmpV2cWrite": [ + { + "writeCommunity": "string", + "description": "string", + "comments": "string", + "credentialType": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "id": "string" + } + ], + "httpsRead": [ + { + "password": "string", + "port": 0, + "username": "string", + "secure": true, + "description": "string", + "comments": "string", + "credentialType": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "id": "string" + } + ], + "httpsWrite": [ + { + "password": "string", + "port": 0, + "username": "string", + "secure": true, + "description": "string", + "comments": "string", + "credentialType": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "id": "string" + } + ], + "snmpV3": [ + { + "username": "string", + "authPassword": "string", + "authType": "string", + "privacyPassword": "string", + "privacyType": "string", + "snmpMode": "string", + "description": "string", + "comments": "string", + "credentialType": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "id": "string" + } + ] + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/global_pool.py b/ansible_collections/cisco/dnac/plugins/modules/global_pool.py new file mode 100644 index 000000000..3c94f9c58 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/global_pool.py @@ -0,0 +1,144 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: global_pool +short_description: Resource module for Global Pool +description: +- Manage operations create, update and delete of the resource Global Pool. +- API to create global pool. +- API to delete global IP pool. +- API to update global pool. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + id: + description: Id path parameter. Global pool id. + type: str + settings: + description: Global Pool's settings. + suboptions: + ippool: + description: Global Pool's ippool. + elements: dict + suboptions: + dhcpServerIps: + description: Dhcp Server Ips. + elements: str + type: list + dnsServerIps: + description: Dns Server Ips. + elements: str + type: list + gateway: + description: Gateway. + type: str + id: + description: Id. + type: str + ipPoolName: + description: Ip Pool Name. + type: str + type: list + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings CreateGlobalPool + description: Complete reference of the CreateGlobalPool API. + link: https://developer.cisco.com/docs/dna-center/#!create-global-pool +- name: Cisco DNA Center documentation for Network Settings DeleteGlobalIPPool + description: Complete reference of the DeleteGlobalIPPool API. + link: https://developer.cisco.com/docs/dna-center/#!delete-global-ip-pool +- name: Cisco DNA Center documentation for Network Settings UpdateGlobalPool + description: Complete reference of the UpdateGlobalPool API. + link: https://developer.cisco.com/docs/dna-center/#!update-global-pool +notes: + - SDK Method used are + network_settings.NetworkSettings.create_global_pool, + network_settings.NetworkSettings.delete_global_ip_pool, + network_settings.NetworkSettings.update_global_pool, + + - Paths used are + post /dna/intent/api/v1/global-pool, + delete /dna/intent/api/v1/global-pool/{id}, + put /dna/intent/api/v1/global-pool, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.global_pool: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + settings: + ippool: + - dhcpServerIps: + - string + dnsServerIps: + - string + gateway: string + id: string + ipPoolName: string + +- name: Create + cisco.dnac.global_pool: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + settings: + ippool: + - IpAddressSpace: string + dhcpServerIps: + - string + dnsServerIps: + - string + gateway: string + ipPoolCidr: string + ipPoolName: string + type: string + +- name: Delete by id + cisco.dnac.global_pool: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + id: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/global_pool_info.py b/ansible_collections/cisco/dnac/plugins/modules/global_pool_info.py new file mode 100644 index 000000000..ed95446be --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/global_pool_info.py @@ -0,0 +1,107 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: global_pool_info +short_description: Information module for Global Pool +description: +- Get all Global Pool. +- API to get global pool. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + offset: + description: + - Offset query parameter. Offset/starting row. + type: int + limit: + description: + - Limit query parameter. No of Global Pools to be retrieved. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings GetGlobalPool + description: Complete reference of the GetGlobalPool API. + link: https://developer.cisco.com/docs/dna-center/#!get-global-pool +notes: + - SDK Method used are + network_settings.NetworkSettings.get_global_pool, + + - Paths used are + get /dna/intent/api/v1/global-pool, + +""" + +EXAMPLES = r""" +- name: Get all Global Pool + cisco.dnac.global_pool_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + offset: 0 + limit: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "ipPoolName": "string", + "dhcpServerIps": [ + "string" + ], + "gateways": [ + "string" + ], + "createTime": "string", + "lastUpdateTime": "string", + "totalIpAddressCount": "string", + "usedIpAddressCount": "string", + "parentUuid": "string", + "owner": "string", + "shared": "string", + "overlapping": "string", + "configureExternalDhcp": "string", + "usedPercentage": "string", + "clientOptions": {}, + "dnsServerIps": [ + "string" + ], + "context": [ + { + "owner": "string", + "contextKey": "string", + "contextValue": "string" + } + ], + "ipv6": "string", + "id": "string", + "ipPoolCidr": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/golden_image_create.py b/ansible_collections/cisco/dnac/plugins/modules/golden_image_create.py new file mode 100644 index 000000000..1f176f172 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/golden_image_create.py @@ -0,0 +1,78 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: golden_image_create +short_description: Resource module for Golden Image Create +description: +- Manage operation create of the resource Golden Image Create. +- Golden Tag image. Set siteId as -1 for Global site. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + deviceFamilyIdentifier: + description: Device Family Identifier e.g. 277696480-283933147, 277696480. + type: str + deviceRole: + description: Device Role. Permissible Values ALL, UNKNOWN, ACCESS, BORDER ROUTER, + DISTRIBUTION and CORE. + type: str + imageId: + description: ImageId in uuid format. + type: str + siteId: + description: SiteId in uuid format. For Global Site "-1" to be used. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Software Image Management (SWIM) TagAsGoldenImage + description: Complete reference of the TagAsGoldenImage API. + link: https://developer.cisco.com/docs/dna-center/#!tag-as-golden-image +notes: + - SDK Method used are + software_image_management_swim.SoftwareImageManagementSwim.tag_as_golden_image, + + - Paths used are + post /dna/intent/api/v1/image/importation/golden, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.golden_image_create: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + deviceFamilyIdentifier: string + deviceRole: string + imageId: string + siteId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": { + "url": "string", + "taskId": "string" + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/golden_tag_image_delete.py b/ansible_collections/cisco/dnac/plugins/modules/golden_tag_image_delete.py new file mode 100644 index 000000000..8191e4915 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/golden_tag_image_delete.py @@ -0,0 +1,80 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: golden_tag_image_delete +short_description: Resource module for Golden Tag Image Delete +description: +- Manage operation delete of the resource Golden Tag Image Delete. +- Remove golden tag. Set siteId as -1 for Global site. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + deviceFamilyIdentifier: + description: DeviceFamilyIdentifier path parameter. Device family identifier e.g. + 277696480-283933147, e.g. 277696480. + type: str + deviceRole: + description: DeviceRole path parameter. Device Role. Permissible Values ALL, UNKNOWN, + ACCESS, BORDER ROUTER, DISTRIBUTION and CORE. + type: str + imageId: + description: ImageId path parameter. Image Id in uuid format. + type: str + siteId: + description: SiteId path parameter. Site Id in uuid format. Set siteId as -1 for + Global site. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Software Image Management (SWIM) RemoveGoldenTagForImage + description: Complete reference of the RemoveGoldenTagForImage API. + link: https://developer.cisco.com/docs/dna-center/#!remove-golden-tag-for-image +notes: + - SDK Method used are + software_image_management_swim.SoftwareImageManagementSwim.remove_golden_tag_for_image, + + - Paths used are + delete /dna/intent/api/v1/image/importation/golden/site/{siteId}/family/{deviceFamilyIdentifier}/role/{deviceRole}/image/{imageId}, + +""" + +EXAMPLES = r""" +- name: Delete by id + cisco.dnac.golden_tag_image_delete: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + deviceFamilyIdentifier: string + deviceRole: string + imageId: string + siteId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": { + "url": "string", + "taskId": "string" + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/golden_tag_image_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/golden_tag_image_details_info.py new file mode 100644 index 000000000..9d41a7610 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/golden_tag_image_details_info.py @@ -0,0 +1,90 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: golden_tag_image_details_info +short_description: Information module for Golden Tag Image Details +description: +- Get Golden Tag Image Details by id. +- Get golden tag status of an image. Set siteId as -1 for Global site. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + siteId: + description: + - SiteId path parameter. Site Id in uuid format. Set siteId as -1 for Global site. + type: str + deviceFamilyIdentifier: + description: + - DeviceFamilyIdentifier path parameter. Device family identifier e.g. 277696480-283933147, e.g. 277696480. + type: str + deviceRole: + description: + - > + DeviceRole path parameter. Device Role. Permissible Values ALL, UNKNOWN, ACCESS, BORDER ROUTER, DISTRIBUTION + and CORE. + type: str + imageId: + description: + - ImageId path parameter. Image Id in uuid format. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Software Image Management (SWIM) GetGoldenTagStatusOfAnImage + description: Complete reference of the GetGoldenTagStatusOfAnImage API. + link: https://developer.cisco.com/docs/dna-center/#!get-golden-tag-status-of-an-image +notes: + - SDK Method used are + software_image_management_swim.SoftwareImageManagementSwim.get_golden_tag_status_of_an_image, + + - Paths used are + get /dna/intent/api/v1/image/importation/golden/site/{siteId}/family/{deviceFamilyIdentifier}/role/{deviceRole}/image/{imageId}, + +""" + +EXAMPLES = r""" +- name: Get Golden Tag Image Details by id + cisco.dnac.golden_tag_image_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + siteId: string + deviceFamilyIdentifier: string + deviceRole: string + imageId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": { + "deviceRole": "string", + "taggedGolden": true, + "inheritedSiteName": "string", + "inheritedSiteId": "string" + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/http_read_credential.py b/ansible_collections/cisco/dnac/plugins/modules/http_read_credential.py new file mode 100644 index 000000000..63c19d5c4 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/http_read_credential.py @@ -0,0 +1,129 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: http_read_credential +short_description: Resource module for Http Read Credential +description: +- Manage operations create and update of the resource Http Read Credential. +- Adds HTTP read credentials. +- Updates global HTTP Read credential. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + comments: + description: Http Read Credential's comments. + type: str + credentialType: + description: Http Read Credential's credentialType. + type: str + description: + description: Http Read Credential's description. + type: str + id: + description: Http Read Credential's id. + type: str + instanceTenantId: + description: Http Read Credential's instanceTenantId. + type: str + instanceUuid: + description: Http Read Credential's instanceUuid. + type: str + password: + description: Http Read Credential's password. + type: str + port: + description: Http Read Credential's port. + type: int + secure: + description: Secure flag. + type: bool + username: + description: Http Read Credential's username. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery CreateHTTPReadCredentials + description: Complete reference of the CreateHTTPReadCredentials API. + link: https://developer.cisco.com/docs/dna-center/#!create-http-read-credentials +- name: Cisco DNA Center documentation for Discovery UpdateHTTPReadCredential + description: Complete reference of the UpdateHTTPReadCredential API. + link: https://developer.cisco.com/docs/dna-center/#!update-http-read-credential +notes: + - SDK Method used are + discovery.Discovery.create_http_read_credentials, + discovery.Discovery.update_http_read_credential, + + - Paths used are + post /dna/intent/api/v1/global-credential/http-read, + put /dna/intent/api/v1/global-credential/http-read, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.http_read_credential: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + comments: string + credentialType: string + description: string + id: string + instanceTenantId: string + instanceUuid: string + password: string + port: 0 + secure: true + username: string + +- name: Update all + cisco.dnac.http_read_credential: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + comments: string + credentialType: string + description: string + id: string + instanceTenantId: string + instanceUuid: string + password: string + port: 0 + secure: true + username: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/http_write_credential.py b/ansible_collections/cisco/dnac/plugins/modules/http_write_credential.py new file mode 100644 index 000000000..2db38bb61 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/http_write_credential.py @@ -0,0 +1,129 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: http_write_credential +short_description: Resource module for Http Write Credential +description: +- Manage operations create and update of the resource Http Write Credential. +- Adds global HTTP write credentials. +- Updates global HTTP write credentials. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + comments: + description: Http Write Credential's comments. + type: str + credentialType: + description: Http Write Credential's credentialType. + type: str + description: + description: Http Write Credential's description. + type: str + id: + description: Http Write Credential's id. + type: str + instanceTenantId: + description: Http Write Credential's instanceTenantId. + type: str + instanceUuid: + description: Http Write Credential's instanceUuid. + type: str + password: + description: Http Write Credential's password. + type: str + port: + description: Http Write Credential's port. + type: int + secure: + description: Secure flag. + type: bool + username: + description: Http Write Credential's username. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery CreateHTTPWriteCredentials + description: Complete reference of the CreateHTTPWriteCredentials API. + link: https://developer.cisco.com/docs/dna-center/#!create-http-write-credentials +- name: Cisco DNA Center documentation for Discovery UpdateHTTPWriteCredentials + description: Complete reference of the UpdateHTTPWriteCredentials API. + link: https://developer.cisco.com/docs/dna-center/#!update-http-write-credentials +notes: + - SDK Method used are + discovery.Discovery.create_http_write_credentials, + discovery.Discovery.update_http_write_credentials, + + - Paths used are + post /dna/intent/api/v1/global-credential/http-write, + put /dna/intent/api/v1/global-credential/http-write, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.http_write_credential: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + comments: string + credentialType: string + description: string + id: string + instanceTenantId: string + instanceUuid: string + password: string + port: 0 + secure: true + username: string + +- name: Create + cisco.dnac.http_write_credential: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + comments: string + credentialType: string + description: string + id: string + instanceTenantId: string + instanceUuid: string + password: string + port: 0 + secure: true + username: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/integration_settings_instances_itsm.py b/ansible_collections/cisco/dnac/plugins/modules/integration_settings_instances_itsm.py new file mode 100644 index 000000000..1bc569d9f --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/integration_settings_instances_itsm.py @@ -0,0 +1,160 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: integration_settings_instances_itsm +short_description: Resource module for Integration Settings Instances Itsm +description: +- Manage operations create, update and delete of the resource Integration Settings Instances Itsm. +- Creates ITSM Integration setting. +- Deletes the ITSM Integration setting. +- Updates the ITSM Integration setting. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + data: + description: Integration Settings Instances Itsm's data. + suboptions: + ConnectionSettings: + description: Integration Settings Instances Itsm's ConnectionSettings. + suboptions: + Auth_Password: + description: Auth Password. + type: str + Auth_UserName: + description: Auth User Name. + type: str + Url: + description: Url. + type: str + type: dict + type: dict + description: + description: Description of the setting instance. + type: str + dypName: + description: It should be ServiceNowConnection. + type: str + instanceId: + description: InstanceId path parameter. Instance Id of the Integration setting instance. + type: str + name: + description: Name of the setting instance. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for ITSM Integration CreateITSMIntegrationSetting + description: Complete reference of the CreateITSMIntegrationSetting API. + link: https://developer.cisco.com/docs/dna-center/#!create-itsm-integration-setting +- name: Cisco DNA Center documentation for ITSM Integration DeleteITSMIntegrationSetting + description: Complete reference of the DeleteITSMIntegrationSetting API. + link: https://developer.cisco.com/docs/dna-center/#!delete-itsm-integration-setting +- name: Cisco DNA Center documentation for ITSM Integration UpdateITSMIntegrationSetting + description: Complete reference of the UpdateITSMIntegrationSetting API. + link: https://developer.cisco.com/docs/dna-center/#!update-itsm-integration-setting +notes: + - SDK Method used are + itsm_integration.ItsmIntegration.create_itsm_integration_setting, + itsm_integration.ItsmIntegration.delete_itsm_integration_setting, + itsm_integration.ItsmIntegration.update_itsm_integration_setting, + + - Paths used are + post /dna/intent/api/v1/integration-settings/instances/itsm, + delete /dna/intent/api/v1/integration-settings/instances/itsm/{instanceId}, + put /dna/intent/api/v1/integration-settings/instances/itsm/{instanceId}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.integration_settings_instances_itsm: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + data: + ConnectionSettings: + Auth_Password: string + Auth_UserName: string + Url: string + description: string + dypName: string + name: string + +- name: Update by id + cisco.dnac.integration_settings_instances_itsm: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + data: + ConnectionSettings: + Auth_Password: string + Auth_UserName: string + Url: string + description: string + dypName: string + instanceId: string + name: string + +- name: Delete by id + cisco.dnac.integration_settings_instances_itsm: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + instanceId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "id": "string", + "dypId": "string", + "dypName": "string", + "name": "string", + "uniqueKey": "string", + "dypMajorVersion": 0, + "description": "string", + "data": { + "ConnectionSettings": { + "Url": "string", + "Auth_UserName": "string", + "Auth_Password": "string" + } + }, + "createdDate": 0, + "createdBy": "string", + "updatedBy": "string", + "softwareVersionLog": [ + {} + ], + "schemaVersion": 0, + "tenantId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/integration_settings_instances_itsm_info.py b/ansible_collections/cisco/dnac/plugins/modules/integration_settings_instances_itsm_info.py new file mode 100644 index 000000000..fc6a5de7a --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/integration_settings_instances_itsm_info.py @@ -0,0 +1,84 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: integration_settings_instances_itsm_info +short_description: Information module for Integration Settings Instances Itsm +description: +- Get Integration Settings Instances Itsm by id. +- Fetches ITSM Integration setting by ID. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + instanceId: + description: + - InstanceId path parameter. Instance Id of the Integration setting instance. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for ITSM Integration GetITSMIntegrationSettingById + description: Complete reference of the GetITSMIntegrationSettingById API. + link: https://developer.cisco.com/docs/dna-center/#!get-itsm-integration-setting-by-id +notes: + - SDK Method used are + itsm_integration.ItsmIntegration.get_itsm_integration_setting_by_id, + + - Paths used are + get /dna/intent/api/v1/integration-settings/instances/itsm/{instanceId}, + +""" + +EXAMPLES = r""" +- name: Get Integration Settings Instances Itsm by id + cisco.dnac.integration_settings_instances_itsm_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + instanceId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "_id": "string", + "id": "string", + "dypId": "string", + "dypName": "string", + "dypMajorVersion": 0, + "name": "string", + "uniqueKey": "string", + "description": "string", + "data": { + "ConnectionSettings": { + "Url": "string", + "Auth_UserName": "string", + "Auth_Password": "string" + } + }, + "updatedDate": 0, + "updatedBy": "string", + "tenantId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/interface_info.py b/ansible_collections/cisco/dnac/plugins/modules/interface_info.py new file mode 100644 index 000000000..02d4dd14e --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/interface_info.py @@ -0,0 +1,124 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: interface_info +short_description: Information module for Interface +description: +- Get all Interface. +- Get list of all properties & operations valid for an interface. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + interfaceUuid: + description: + - InterfaceUuid path parameter. Interface ID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices LegitOperationsForInterface + description: Complete reference of the LegitOperationsForInterface API. + link: https://developer.cisco.com/docs/dna-center/#!legit-operations-for-interface +notes: + - SDK Method used are + devices.Devices.legit_operations_for_interface, + + - Paths used are + get /dna/intent/api/v1/interface/{interfaceUuid}/legit-operation, + +""" + +EXAMPLES = r""" +- name: Get all Interface + cisco.dnac.interface_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + interfaceUuid: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "type": "string", + "properties": { + "interfaceUuid": { + "type": "string" + }, + "properties": { + "type": "string", + "items": [ + { + "type": "string", + "properties": { + "name": { + "type": "string" + }, + "applicable": { + "type": "string" + }, + "failureReason": { + "type": "string" + } + }, + "required": [ + "string" + ] + } + ] + }, + "operations": { + "type": "string", + "items": [ + { + "type": "string", + "properties": { + "name": { + "type": "string" + }, + "applicable": { + "type": "string" + }, + "failureReason": { + "type": "string" + } + }, + "required": [ + "string" + ] + } + ] + } + }, + "required": [ + "string" + ] + }, + "version": { + "type": "string" + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/interface_network_device_detail_info.py b/ansible_collections/cisco/dnac/plugins/modules/interface_network_device_detail_info.py new file mode 100644 index 000000000..344f22a2f --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/interface_network_device_detail_info.py @@ -0,0 +1,104 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: interface_network_device_detail_info +short_description: Information module for Interface Network Device Detail +description: +- Get all Interface Network Device Detail. +- Returns interface by specified device Id and interface name. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceId: + description: + - DeviceId path parameter. Device ID. + type: str + name: + description: + - Name query parameter. Interface name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetInterfaceDetailsByDeviceIdAndInterfaceName + description: Complete reference of the GetInterfaceDetailsByDeviceIdAndInterfaceName API. + link: https://developer.cisco.com/docs/dna-center/#!get-interface-details-by-device-id-and-interface-name +notes: + - SDK Method used are + devices.Devices.get_interface_details, + + - Paths used are + get /dna/intent/api/v1/interface/network-device/{deviceId}/interface-name, + +""" + +EXAMPLES = r""" +- name: Get all Interface Network Device Detail + cisco.dnac.interface_network_device_detail_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + name: string + deviceId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "adminStatus": "string", + "className": "string", + "description": "string", + "deviceId": "string", + "duplex": "string", + "id": "string", + "ifIndex": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "interfaceType": "string", + "ipv4Address": "string", + "ipv4Mask": "string", + "isisSupport": "string", + "lastUpdated": "string", + "macAddress": "string", + "mappedPhysicalInterfaceId": "string", + "mappedPhysicalInterfaceName": "string", + "mediaType": "string", + "nativeVlanId": "string", + "ospfSupport": "string", + "pid": "string", + "portMode": "string", + "portName": "string", + "portType": "string", + "serialNo": "string", + "series": "string", + "speed": "string", + "status": "string", + "vlanId": "string", + "voiceVlan": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/interface_network_device_info.py b/ansible_collections/cisco/dnac/plugins/modules/interface_network_device_info.py new file mode 100644 index 000000000..8fdc0e226 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/interface_network_device_info.py @@ -0,0 +1,101 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: interface_network_device_info +short_description: Information module for Interface Network Device +description: +- Get Interface Network Device by id. +- Returns list of interfaces by specified device. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceId: + description: + - DeviceId path parameter. Device ID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetInterfaceInfoById + description: Complete reference of the GetInterfaceInfoById API. + link: https://developer.cisco.com/docs/dna-center/#!get-interface-info-by-id +notes: + - SDK Method used are + devices.Devices.get_interface_info_by_id, + + - Paths used are + get /dna/intent/api/v1/interface/network-device/{deviceId}, + +""" + +EXAMPLES = r""" +- name: Get Interface Network Device by id + cisco.dnac.interface_network_device_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "adminStatus": "string", + "className": "string", + "description": "string", + "deviceId": "string", + "duplex": "string", + "id": "string", + "ifIndex": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "interfaceType": "string", + "ipv4Address": "string", + "ipv4Mask": "string", + "isisSupport": "string", + "lastUpdated": "string", + "macAddress": "string", + "mappedPhysicalInterfaceId": "string", + "mappedPhysicalInterfaceName": "string", + "mediaType": "string", + "nativeVlanId": "string", + "ospfSupport": "string", + "pid": "string", + "portMode": "string", + "portName": "string", + "portType": "string", + "serialNo": "string", + "series": "string", + "speed": "string", + "status": "string", + "vlanId": "string", + "voiceVlan": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/interface_network_device_range_info.py b/ansible_collections/cisco/dnac/plugins/modules/interface_network_device_range_info.py new file mode 100644 index 000000000..0a3f1448b --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/interface_network_device_range_info.py @@ -0,0 +1,111 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: interface_network_device_range_info +short_description: Information module for Interface Network Device Range +description: +- Get all Interface Network Device Range. +- Returns the list of interfaces for the device for the specified range. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceId: + description: + - DeviceId path parameter. Device ID. + type: str + startIndex: + description: + - StartIndex path parameter. Start index. + type: int + recordsToReturn: + description: + - RecordsToReturn path parameter. Number of records to return. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetDeviceInterfacesBySpecifiedRange + description: Complete reference of the GetDeviceInterfacesBySpecifiedRange API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-interfaces-by-specified-range +notes: + - SDK Method used are + devices.Devices.get_device_interfaces_by_specified_range, + + - Paths used are + get /dna/intent/api/v1/interface/network-device/{deviceId}/{startIndex}/{recordsToReturn}, + +""" + +EXAMPLES = r""" +- name: Get all Interface Network Device Range + cisco.dnac.interface_network_device_range_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceId: string + startIndex: 0 + recordsToReturn: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "adminStatus": "string", + "className": "string", + "description": "string", + "deviceId": "string", + "duplex": "string", + "id": "string", + "ifIndex": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "interfaceType": "string", + "ipv4Address": "string", + "ipv4Mask": "string", + "isisSupport": "string", + "lastUpdated": "string", + "macAddress": "string", + "mappedPhysicalInterfaceId": "string", + "mappedPhysicalInterfaceName": "string", + "mediaType": "string", + "nativeVlanId": "string", + "ospfSupport": "string", + "pid": "string", + "portMode": "string", + "portName": "string", + "portType": "string", + "serialNo": "string", + "series": "string", + "speed": "string", + "status": "string", + "vlanId": "string", + "voiceVlan": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/interface_operation_create.py b/ansible_collections/cisco/dnac/plugins/modules/interface_operation_create.py new file mode 100644 index 000000000..98995c1dc --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/interface_operation_create.py @@ -0,0 +1,81 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: interface_operation_create +short_description: Resource module for Interface Operation Create +description: +- Manage operation create of the resource Interface Operation Create. +- > + Clear mac-address on an individual port. In request body, operation needs to be specified as 'ClearMacAddress'. In + the future more possible operations will be added to this API. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + deploymentMode: + description: DeploymentMode query parameter. Preview/Deploy 'Preview' means the + configuration is not pushed to the device. 'Deploy' makes the configuration pushed + to the device. + type: str + interfaceUuid: + description: InterfaceUuid path parameter. Interface Id. + type: str + operation: + description: Operation. + type: str + payload: + description: Payload. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices ClearMacAddressTable + description: Complete reference of the ClearMacAddressTable API. + link: https://developer.cisco.com/docs/dna-center/#!clear-mac-address-table +notes: + - SDK Method used are + devices.Devices.clear_mac_address_table, + + - Paths used are + post /dna/intent/api/v1/interface/{interfaceUuid}/operation, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.interface_operation_create: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + deploymentMode: string + interfaceUuid: string + operation: string + payload: {} + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/interface_update.py b/ansible_collections/cisco/dnac/plugins/modules/interface_update.py new file mode 100644 index 000000000..20d7435e4 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/interface_update.py @@ -0,0 +1,101 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: interface_update +short_description: Resource module for Interface Update +description: +- Manage operation update of the resource Interface Update. +- > + Add/Update Interface description, VLAN membership, Voice VLAN and change Interface admin status 'UP'/'DOWN' from + Request body. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + adminStatus: + description: Admin Status. + type: str + deploymentMode: + description: DeploymentMode query parameter. Preview/Deploy 'Preview' means the + configuration is not pushed to the device. 'Deploy' makes the configuration pushed + to the device. + type: str + description: + description: Description. + type: str + interfaceUuid: + description: InterfaceUuid path parameter. Interface ID. + type: str + vlanId: + description: Vlan Id. + type: int + voiceVlanId: + description: Voice Vlan Id. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices UpdateInterfaceDetails + description: Complete reference of the UpdateInterfaceDetails API. + link: https://developer.cisco.com/docs/dna-center/#!update-interface-details +notes: + - SDK Method used are + devices.Devices.update_interface_details, + + - Paths used are + put /dna/intent/api/v1/interface/{interfaceUuid}, + +""" + +EXAMPLES = r""" +- name: Update by id + cisco.dnac.interface_update: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + adminStatus: string + deploymentMode: string + description: string + interfaceUuid: string + vlanId: 0 + voiceVlanId: 0 + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "type": "string", + "properties": { + "taskId": { + "type": "string" + }, + "url": { + "type": "string" + } + }, + "required": [ + "string" + ] + }, + "version": { + "type": "string" + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/issues_enrichment_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/issues_enrichment_details_info.py new file mode 100644 index 000000000..e81d3f2d9 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/issues_enrichment_details_info.py @@ -0,0 +1,89 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: issues_enrichment_details_info +short_description: Information module for Issues Enrichment Details +description: +- Get all Issues Enrichment Details. +- > + Enriches a given network issue context an issue id or end user's Mac Address with details about the issues, + impacted hosts and suggested actions for remediation. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Issues GetIssueEnrichmentDetails + description: Complete reference of the GetIssueEnrichmentDetails API. + link: https://developer.cisco.com/docs/dna-center/#!get-issue-enrichment-details +notes: + - SDK Method used are + issues.Issues.get_issue_enrichment_details, + + - Paths used are + get /dna/intent/api/v1/issue-enrichment-details, + +""" + +EXAMPLES = r""" +- name: Get all Issues Enrichment Details + cisco.dnac.issues_enrichment_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "issue": [ + { + "issueId": "string", + "issueSource": "string", + "issueCategory": "string", + "issueName": "string", + "issueDescription": "string", + "issueEntity": "string", + "issueEntityValue": "string", + "issueSeverity": "string", + "issuePriority": "string", + "issueSummary": "string", + "issueTimestamp": 0, + "suggestedActions": [ + { + "message": "string", + "steps": [ + {} + ] + } + ], + "impactedHosts": [ + {} + ] + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/issues_info.py b/ansible_collections/cisco/dnac/plugins/modules/issues_info.py new file mode 100644 index 000000000..b94e0f1cf --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/issues_info.py @@ -0,0 +1,125 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: issues_info +short_description: Information module for Issues +description: +- Get all Issues. +- > + Intent API to get a list of global issues, issues for a specific device, or issue for a specific client device's + MAC address. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + startTime: + description: + - StartTime query parameter. Starting epoch time in milliseconds of query time window. + type: int + endTime: + description: + - EndTime query parameter. Ending epoch time in milliseconds of query time window. + type: int + siteId: + description: + - SiteId query parameter. Assurance UUID value of the site in the issue content. + type: str + deviceId: + description: + - DeviceId query parameter. Assurance UUID value of the device in the issue content. + type: str + macAddress: + description: + - MacAddress query parameter. Client's device MAC address of the issue (format xx xx xx xx xx xx). + type: str + priority: + description: + - > + Priority query parameter. The issue's priority value (One of P1, P2, P3, or P4)(Use only when macAddress and + deviceId are not provided). + type: str + aiDriven: + description: + - > + AiDriven query parameter. The issue's AI driven value (Yes or No)(Use only when macAddress and deviceId are + not provided). + type: str + issueStatus: + description: + - IssueStatus query parameter. The issue's status value (One of ACTIVE, IGNORED, RESOLVED). + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Issues Issues + description: Complete reference of the Issues API. + link: https://developer.cisco.com/docs/dna-center/#!issues-issues +notes: + - SDK Method used are + issues.Issues.issues, + + - Paths used are + get /dna/intent/api/v1/issues, + +""" + +EXAMPLES = r""" +- name: Get all Issues + cisco.dnac.issues_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + startTime: 0 + endTime: 0 + siteId: string + deviceId: string + macAddress: string + priority: string + aiDriven: string + issueStatus: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "totalCount": 0, + "response": [ + { + "issueId": "string", + "name": "string", + "siteId": "string", + "deviceId": "string", + "deviceRole": "string", + "aiDriven": true, + "clientMac": "string", + "issue_occurence_count": 0, + "status": "string", + "priority": "string", + "category": "string", + "last_occurence_time": 0 + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/itsm_cmdb_sync_status_info.py b/ansible_collections/cisco/dnac/plugins/modules/itsm_cmdb_sync_status_info.py new file mode 100644 index 000000000..ba5721124 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/itsm_cmdb_sync_status_info.py @@ -0,0 +1,91 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: itsm_cmdb_sync_status_info +short_description: Information module for Itsm Cmdb Sync Status +description: +- Get all Itsm Cmdb Sync Status. +- > + This API allows to retrieve the detail of CMDB sync status.It accepts two query parameter "status","date".The + supported values for status field are "Success","Failed","Unknown" and date field should be in "YYYY-MM-DD" + format. By default all the cmdb sync status will be send as response and based on the query parameter filtered + detail will be send as response. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + status: + description: + - > + Status query parameter. Supported values are "Success","Failed" and "Unknown". Providing other values will + result in all the available sync job status. + type: str + date: + description: + - Date query parameter. Provide date in "YYYY-MM-DD" format. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for ITSM GetCMDBSyncStatus + description: Complete reference of the GetCMDBSyncStatus API. + link: https://developer.cisco.com/docs/dna-center/#!get-cmdb-sync-status +notes: + - SDK Method used are + itsm.Itsm.get_cmdb_sync_status, + + - Paths used are + get /dna/intent/api/v1/cmdb-sync/detail, + +""" + +EXAMPLES = r""" +- name: Get all Itsm Cmdb Sync Status + cisco.dnac.itsm_cmdb_sync_status_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + status: string + date: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "successCount": "string", + "failureCount": "string", + "devices": [ + { + "deviceId": "string", + "status": "string" + } + ], + "unknownErrorCount": "string", + "message": "string", + "syncTime": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/itsm_integration_events_failed_info.py b/ansible_collections/cisco/dnac/plugins/modules/itsm_integration_events_failed_info.py new file mode 100644 index 000000000..b02e8dc1d --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/itsm_integration_events_failed_info.py @@ -0,0 +1,86 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: itsm_integration_events_failed_info +short_description: Information module for Itsm Integration Events Failed +description: +- Get all Itsm Integration Events Failed. +- Used to retrieve the list of integration events that failed to create tickets in ITSM. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + instanceId: + description: + - InstanceId query parameter. Instance Id of the failed event as in the Runtime Dashboard. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for ITSM GetFailedITSMEvents + description: Complete reference of the GetFailedITSMEvents API. + link: https://developer.cisco.com/docs/dna-center/#!get-failed-itsm-events +notes: + - SDK Method used are + itsm.Itsm.get_failed_itsm_events, + + - Paths used are + get /dna/intent/api/v1/integration/events, + +""" + +EXAMPLES = r""" +- name: Get all Itsm Integration Events Failed + cisco.dnac.itsm_integration_events_failed_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + instanceId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "instanceId": "string", + "eventId": "string", + "name": "string", + "type": "string", + "category": "string", + "domain": "string", + "subDomain": "string", + "severity": "string", + "source": "string", + "timestamp": 0, + "enrichmentInfo": { + "eventStatus": "string", + "errorCode": "string", + "errorDescription": "string", + "responseReceivedFromITSMSystem": {} + }, + "description": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/itsm_integration_events_retry.py b/ansible_collections/cisco/dnac/plugins/modules/itsm_integration_events_retry.py new file mode 100644 index 000000000..201f6891d --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/itsm_integration_events_retry.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: itsm_integration_events_retry +short_description: Resource module for Itsm Integration Events Retry +description: +- Manage operation create of the resource Itsm Integration Events Retry. +- > + Allows retry of multiple failed ITSM event instances. The retry request payload can be given as a list of strings + "instance1","instance2","instance3",.. A minimum of one instance Id is mandatory. The list of failed event + instance Ids can be retrieved using the 'Get Failed ITSM Events' API in the 'instanceId' attribute. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + payload: + description: Itsm Integration Events Retry's payload. + elements: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for ITSM RetryIntegrationEvents + description: Complete reference of the RetryIntegrationEvents API. + link: https://developer.cisco.com/docs/dna-center/#!retry-integration-events +notes: + - SDK Method used are + itsm.Itsm.retry_integration_events, + + - Paths used are + post /dna/intent/api/v1/integration/events, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.itsm_integration_events_retry: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + payload: + - string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/lan_automation_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/lan_automation_count_info.py new file mode 100644 index 000000000..d172a752c --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/lan_automation_count_info.py @@ -0,0 +1,62 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: lan_automation_count_info +short_description: Information module for Lan Automation Count +description: +- Get all Lan Automation Count. +- Invoke this API to get the total count of LAN Automation sessions. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for LAN Automation LANAutomationSessionCount + description: Complete reference of the LANAutomationSessionCount API. + link: https://developer.cisco.com/docs/dna-center/#!l-an-automation-session-count +notes: + - SDK Method used are + lan_automation.LanAutomation.lan_automation_session_count, + + - Paths used are + get /dna/intent/api/v1/lan-automation/count, + +""" + +EXAMPLES = r""" +- name: Get all Lan Automation Count + cisco.dnac.lan_automation_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "sessionCount": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/lan_automation_create.py b/ansible_collections/cisco/dnac/plugins/modules/lan_automation_create.py new file mode 100644 index 000000000..e87775b94 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/lan_automation_create.py @@ -0,0 +1,121 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: lan_automation_create +short_description: Resource module for Lan Automation Create +description: +- Manage operation create of the resource Lan Automation Create. +- Invoke this API to start LAN Automation for the given site. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + payload: + description: Lan Automation Create's payload. + elements: dict + suboptions: + discoveredDeviceSiteNameHierarchy: + description: Discovered device site name. + type: str + hostNameFileId: + description: Use /dna/intent/api/v1/file/namespace/nw_orch api to get the file + id for the already uploaded file in nw_orch namespace. + type: str + hostNamePrefix: + description: Host name prefix which shall be assigned to the discovered device. + type: str + ipPools: + description: Lan Automation Create's ipPools. + elements: dict + suboptions: + ipPoolName: + description: Name of the IP pool. + type: str + ipPoolRole: + description: Role of the IP pool. Supported roles are MAIN_POOL and PHYSICAL_LINK_POOL. + type: str + type: list + isisDomainPwd: + description: IS-IS domain password in plain text. + type: str + mulitcastEnabled: + description: To enable underlay native multicast. + type: bool + peerDeviceManagmentIPAddress: + description: Peer seed management IP address. + type: str + primaryDeviceInterfaceNames: + description: The list of interfaces on primary seed via which the discovered + devices are connected. + elements: str + type: list + primaryDeviceManagmentIPAddress: + description: Primary seed management IP address. + type: str + redistributeIsisToBgp: + description: Advertise LAN Automation summary route into BGP. + type: bool + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for LAN Automation LANAutomationStart + description: Complete reference of the LANAutomationStart API. + link: https://developer.cisco.com/docs/dna-center/#!l-an-automation-start +notes: + - SDK Method used are + lan_automation.LanAutomation.lan_automation_start, + + - Paths used are + post /dna/intent/api/v1/lan-automation, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.lan_automation_create: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + payload: + - discoveredDeviceSiteNameHierarchy: string + hostNameFileId: string + hostNamePrefix: string + ipPools: + - ipPoolName: string + ipPoolRole: string + isisDomainPwd: string + mulitcastEnabled: true + peerDeviceManagmentIPAddress: string + primaryDeviceInterfaceNames: + - string + primaryDeviceManagmentIPAddress: string + redistributeIsisToBgp: true + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "message": "string", + "id": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/lan_automation_delete.py b/ansible_collections/cisco/dnac/plugins/modules/lan_automation_delete.py new file mode 100644 index 000000000..d4a8a6651 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/lan_automation_delete.py @@ -0,0 +1,66 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: lan_automation_delete +short_description: Resource module for Lan Automation Delete +description: +- Manage operation delete of the resource Lan Automation Delete. +- Invoke this API to stop LAN Automation for the given site. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + id: + description: Id path parameter. LAN Automation id can be obtained from /dna/intent/api/v1/lan-automation/status. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for LAN Automation LANAutomationStop + description: Complete reference of the LANAutomationStop API. + link: https://developer.cisco.com/docs/dna-center/#!l-an-automation-stop +notes: + - SDK Method used are + lan_automation.LanAutomation.lan_automation_stop, + + - Paths used are + delete /dna/intent/api/v1/lan-automation/{id}, + +""" + +EXAMPLES = r""" +- name: Delete by id + cisco.dnac.lan_automation_delete: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + id: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "errorCode": "string", + "message": "string", + "detail": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/lan_automation_log_by_serial_number_info.py b/ansible_collections/cisco/dnac/plugins/modules/lan_automation_log_by_serial_number_info.py new file mode 100644 index 000000000..c81f24292 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/lan_automation_log_by_serial_number_info.py @@ -0,0 +1,95 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: lan_automation_log_by_serial_number_info +short_description: Information module for Lan Automation Log By Serial Number +description: +- Get Lan Automation Log By Serial Number by id. +- > + Invoke this API to get the LAN Automation session logs for individual devices based on the given LAN Automation + session id and device serial number. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + id: + description: + - Id path parameter. LAN Automation session identifier. + type: str + serialNumber: + description: + - SerialNumber path parameter. Device serial number. + type: str + logLevel: + description: + - > + LogLevel query parameter. Supported levels are ERROR, INFO, WARNING, TRACE, CONFIG and ALL. Specifying ALL + will display device specific logs with the exception of CONFIG logs. In order to view CONFIG logs along with + the remaining logs, please leave the query parameter blank. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for LAN Automation LANAutomationLogsForIndividualDevices + description: Complete reference of the LANAutomationLogsForIndividualDevices API. + link: https://developer.cisco.com/docs/dna-center/#!l-an-automation-logs-for-individual-devices +notes: + - SDK Method used are + lan_automation.LanAutomation.lan_automation_logs_for_individual_devices, + + - Paths used are + get /dna/intent/api/v1/lan-automation/log/{id}/{serialNumber}, + +""" + +EXAMPLES = r""" +- name: Get Lan Automation Log By Serial Number by id + cisco.dnac.lan_automation_log_by_serial_number_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + logLevel: string + id: string + serialNumber: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "nwOrchId": "string", + "logs": [ + { + "logLevel": "string", + "timeStamp": "string", + "record": "string" + } + ], + "serialNumber": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/lan_automation_log_info.py b/ansible_collections/cisco/dnac/plugins/modules/lan_automation_log_info.py new file mode 100644 index 000000000..ede147df9 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/lan_automation_log_info.py @@ -0,0 +1,109 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: lan_automation_log_info +short_description: Information module for Lan Automation Log +description: +- Get all Lan Automation Log. +- Get Lan Automation Log by id. +- Invoke this API to get the LAN Automation session logs based on the given LAN Automation session id. +- Invoke this API to get the LAN Automation session logs. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + offset: + description: + - Offset query parameter. Starting index of the LAN Automation session. Minimum value is 1. + type: int + limit: + description: + - Limit query parameter. Number of LAN Automation sessions to be retrieved. Limit value can range between 1 to 10. + type: int + id: + description: + - Id path parameter. LAN Automation session identifier. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for LAN Automation LANAutomationLog + description: Complete reference of the LANAutomationLog API. + link: https://developer.cisco.com/docs/dna-center/#!l-an-automation-log +- name: Cisco DNA Center documentation for LAN Automation LANAutomationLogById + description: Complete reference of the LANAutomationLogById API. + link: https://developer.cisco.com/docs/dna-center/#!l-an-automation-log-by-id +notes: + - SDK Method used are + lan_automation.LanAutomation.lan_automation_log, + lan_automation.LanAutomation.lan_automation_log_by_id, + + - Paths used are + get /dna/intent/api/v1/lan-automation/log, + get /dna/intent/api/v1/lan-automation/log/{id}, + +""" + +EXAMPLES = r""" +- name: Get all Lan Automation Log + cisco.dnac.lan_automation_log_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + offset: 0 + limit: 0 + register: result + +- name: Get Lan Automation Log by id + cisco.dnac.lan_automation_log_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "nwOrchId": "string", + "entry": [ + { + "logLevel": "string", + "timeStamp": "string", + "record": "string", + "deviceId": "string" + } + ] + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/lan_automation_status_info.py b/ansible_collections/cisco/dnac/plugins/modules/lan_automation_status_info.py new file mode 100644 index 000000000..62ad0a371 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/lan_automation_status_info.py @@ -0,0 +1,128 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: lan_automation_status_info +short_description: Information module for Lan Automation Status +description: +- Get all Lan Automation Status. +- Get Lan Automation Status by id. +- Invoke this API to get the LAN Automation session status based on the given Lan Automation session id. +- Invoke this API to get the LAN Automation session status. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + offset: + description: + - Offset query parameter. Starting index of the LAN Automation session. Minimum value is 1. + type: int + limit: + description: + - Limit query parameter. Number of LAN Automation sessions to be retrieved. Limit value can range between 1 to 10. + type: int + id: + description: + - Id path parameter. LAN Automation session identifier. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for LAN Automation LANAutomationStatus + description: Complete reference of the LANAutomationStatus API. + link: https://developer.cisco.com/docs/dna-center/#!l-an-automation-status +- name: Cisco DNA Center documentation for LAN Automation LANAutomationStatusById + description: Complete reference of the LANAutomationStatusById API. + link: https://developer.cisco.com/docs/dna-center/#!l-an-automation-status-by-id +notes: + - SDK Method used are + lan_automation.LanAutomation.lan_automation_status, + lan_automation.LanAutomation.lan_automation_status_by_id, + + - Paths used are + get /dna/intent/api/v1/lan-automation/status, + get /dna/intent/api/v1/lan-automation/status/{id}, + +""" + +EXAMPLES = r""" +- name: Get all Lan Automation Status + cisco.dnac.lan_automation_status_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + offset: 0 + limit: 0 + register: result + +- name: Get Lan Automation Status by id + cisco.dnac.lan_automation_status_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "id": "string", + "discoveredDeviceSiteNameHierarchy": "string", + "primaryDeviceManagmentIPAddress": "string", + "ipPoolList": [ + { + "ipPoolName": "string", + "ipPoolRole": "string" + } + ], + "primaryDeviceInterfaceNames": [ + "string" + ], + "status": "string", + "action": "string", + "creationTime": "string", + "multicastEnabled": true, + "peerDeviceManagmentIPAddress": "string", + "discoveredDeviceList": [ + { + "name": "string", + "serialNumber": "string", + "state": "string", + "ipAddressInUseList": [ + "string" + ] + } + ], + "redistributeIsisToBgp": true + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/license_device_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/license_device_count_info.py new file mode 100644 index 000000000..efee0085a --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/license_device_count_info.py @@ -0,0 +1,88 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: license_device_count_info +short_description: Information module for License Device Count +description: +- Get all License Device Count. +- Get total number of managed devices. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + device_type: + description: + - Device_type query parameter. Type of device. + type: str + registration_status: + description: + - Registration_status query parameter. Smart license registration status of device. + type: str + dna_level: + description: + - Dna_level query parameter. Device Cisco DNA License Level. + type: str + virtual_account_name: + description: + - Virtual_account_name query parameter. Virtual account name. + type: str + smart_account_id: + description: + - Smart_account_id query parameter. Smart account id. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Licenses DeviceCountDetails2 + description: Complete reference of the DeviceCountDetails2 API. + link: https://developer.cisco.com/docs/dna-center/#!device-count-details-2 +notes: + - SDK Method used are + licenses.Licenses.device_count_details2, + + - Paths used are + get /dna/intent/api/v1/licenses/device/count, + +""" + +EXAMPLES = r""" +- name: Get all License Device Count + cisco.dnac.license_device_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + device_type: string + registration_status: string + dna_level: string + virtual_account_name: string + smart_account_id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/license_device_deregistration.py b/ansible_collections/cisco/dnac/plugins/modules/license_device_deregistration.py new file mode 100644 index 000000000..aeceb3470 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/license_device_deregistration.py @@ -0,0 +1,66 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: license_device_deregistration +short_description: Resource module for License Device Deregistration +description: +- Manage operation update of the resource License Device Deregistration. +- Deregister devices from CSSM Cisco Smart Software Manager . +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + device_uuids: + description: Comma separated device ids. + elements: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Licenses DeviceDeregistration2 + description: Complete reference of the DeviceDeregistration2 API. + link: https://developer.cisco.com/docs/dna-center/#!device-deregistration-2 +notes: + - SDK Method used are + licenses.Licenses.device_deregistration2, + + - Paths used are + put /dna/intent/api/v1/licenses/smartAccount/virtualAccount/deregister, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.license_device_deregistration: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + device_uuids: + - string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/license_device_license_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/license_device_license_details_info.py new file mode 100644 index 000000000..5410196ca --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/license_device_license_details_info.py @@ -0,0 +1,123 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: license_device_license_details_info +short_description: Information module for License Device License Details +description: +- Get all License Device License Details. +- Get detailed license information of a device. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + device_uuid: + description: + - Device_uuid path parameter. Id of device. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Licenses DeviceLicenseDetails2 + description: Complete reference of the DeviceLicenseDetails2 API. + link: https://developer.cisco.com/docs/dna-center/#!device-license-details-2 +notes: + - SDK Method used are + licenses.Licenses.device_license_details2, + + - Paths used are + get /dna/intent/api/v1/licenses/device/{device_uuid}/details, + +""" + +EXAMPLES = r""" +- name: Get all License Device License Details + cisco.dnac.license_device_license_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + device_uuid: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "device_uuid": "string", + "site": "string", + "model": "string", + "license_mode": "string", + "is_license_expired": true, + "software_version": "string", + "network_license": "string", + "evaluation_license_expiry": "string", + "device_name": "string", + "device_type": "string", + "dna_level": "string", + "virtual_account_name": "string", + "ip_address": "string", + "mac_address": "string", + "sntc_status": "string", + "feature_license": [ + "string" + ], + "has_sup_cards": true, + "udi": "string", + "stacked_devices": [ + { + "mac_address": "string", + "id": "string", + "role": "string", + "serial_number": "string" + } + ], + "is_stacked_device": true, + "access_points": [ + { + "ap_type": "string", + "count": "string" + } + ], + "chassis_details": { + "board_serial_number": "string", + "modules": [ + { + "module_type": "string", + "module_name": "string", + "serial_number": "string", + "id": "string" + } + ], + "supervisor_cards": [ + { + "serial_number": "string", + "supervisor_card_type": "string", + "status": "string" + } + ], + "port": 0 + } + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/license_device_license_summary_info.py b/ansible_collections/cisco/dnac/plugins/modules/license_device_license_summary_info.py new file mode 100644 index 000000000..ae872d095 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/license_device_license_summary_info.py @@ -0,0 +1,149 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: license_device_license_summary_info +short_description: Information module for License Device License Summary +description: +- Get all License Device License Summary. +- Show license summary of devices. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + page_number: + description: + - Page_number query parameter. Page number of response. + type: int + order: + description: + - Order query parameter. Sorting order. + type: str + sort_by: + description: + - Sort_by query parameter. Sort result by field. + type: str + dna_level: + description: + - Dna_level query parameter. Device Cisco DNA license level. + type: str + device_type: + description: + - Device_type query parameter. Type of device. + type: str + limit: + description: + - Limit query parameter. + type: int + registration_status: + description: + - Registration_status query parameter. Smart license registration status of device. + type: str + virtual_account_name: + description: + - Virtual_account_name query parameter. Name of virtual account. + type: str + smart_account_id: + description: + - Smart_account_id query parameter. Id of smart account. + type: int + device_uuid: + description: + - Device_uuid query parameter. Id of device. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Licenses DeviceLicenseSummary2 + description: Complete reference of the DeviceLicenseSummary2 API. + link: https://developer.cisco.com/docs/dna-center/#!device-license-summary-2 +notes: + - SDK Method used are + licenses.Licenses.device_license_summary2, + + - Paths used are + get /dna/intent/api/v1/licenses/device/summary, + +""" + +EXAMPLES = r""" +- name: Get all License Device License Summary + cisco.dnac.license_device_license_summary_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + page_number: 0 + order: string + sort_by: string + dna_level: string + device_type: string + limit: 0 + registration_status: string + virtual_account_name: string + smart_account_id: 0 + device_uuid: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "authorization_status": "string", + "last_updated_time": "string", + "is_performance_allowed": true, + "sle_auth_code": "string", + "throughput_level": "string", + "hsec_status": "string", + "device_uuid": "string", + "site": "string", + "total_access_point_count": 0, + "model": "string", + "is_wireless_capable": true, + "registration_status": "string", + "sle_state": "string", + "performance_license": "string", + "license_mode": "string", + "is_license_expired": true, + "software_version": "string", + "reservation_status": "string", + "is_wireless": true, + "network_license": "string", + "evaluation_license_expiry": "string", + "wireless_capable_network_license": "string", + "device_name": "string", + "device_type": "string", + "dna_level": "string", + "virtual_account_name": "string", + "last_successful_rum_usage_upload_time": "string", + "ip_address": "string", + "wireless_capable_dna_license": "string", + "mac_address": "string", + "customer_tag1": "string", + "customer_tag2": "string", + "customer_tag3": "string", + "customer_tag4": "string", + "smart_account_name": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/license_device_registration.py b/ansible_collections/cisco/dnac/plugins/modules/license_device_registration.py new file mode 100644 index 000000000..6d7f5b955 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/license_device_registration.py @@ -0,0 +1,70 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: license_device_registration +short_description: Resource module for License Device Registration +description: +- Manage operation update of the resource License Device Registration. +- Register devices in CSSM Cisco Smart Software Manager . +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + device_uuids: + description: Comma separated device ids. + elements: str + type: list + virtual_account_name: + description: Virtual_account_name path parameter. Name of virtual account. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Licenses DeviceRegistration2 + description: Complete reference of the DeviceRegistration2 API. + link: https://developer.cisco.com/docs/dna-center/#!device-registration-2 +notes: + - SDK Method used are + licenses.Licenses.device_registration2, + + - Paths used are + put /dna/intent/api/v1/licenses/smartAccount/virtualAccount/{virtual_account_name}/register, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.license_device_registration: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + device_uuids: + - string + virtual_account_name: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/license_smart_account_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/license_smart_account_details_info.py new file mode 100644 index 000000000..b70fa56c0 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/license_smart_account_details_info.py @@ -0,0 +1,70 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: license_smart_account_details_info +short_description: Information module for License Smart Account Details +description: +- Get all License Smart Account Details. +- Get detail of all smart accounts. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Licenses SmartAccountDetails + description: Complete reference of the SmartAccountDetails API. + link: https://developer.cisco.com/docs/dna-center/#!smart-account-details +notes: + - SDK Method used are + licenses.Licenses.smart_account_details, + + - Paths used are + get /dna/intent/api/v1/licenses/smartAccounts, + +""" + +EXAMPLES = r""" +- name: Get all License Smart Account Details + cisco.dnac.license_smart_account_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "name": "string", + "id": "string", + "domain": "string", + "is_active_smart_account": true + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/license_term_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/license_term_details_info.py new file mode 100644 index 000000000..bdf26471d --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/license_term_details_info.py @@ -0,0 +1,89 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: license_term_details_info +short_description: Information module for License Term Details +description: +- Get License Term Details by name. +- Get license term details. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + smart_account_id: + description: + - Smart_account_id path parameter. Id of smart account. + type: str + virtual_account_name: + description: + - > + Virtual_account_name path parameter. Name of virtual account. Putting "All" will give license term detail + for all virtual accounts. + type: str + device_type: + description: + - Device_type query parameter. Type of device like router, switch, wireless or ise. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Licenses LicenseTermDetails2 + description: Complete reference of the LicenseTermDetails2 API. + link: https://developer.cisco.com/docs/dna-center/#!license-term-details-2 +notes: + - SDK Method used are + licenses.Licenses.license_term_details2, + + - Paths used are + get /dna/intent/api/v1/licenses/term/smartAccount/{smart_account_id}/virtualAccount/{virtual_account_name}, + +""" + +EXAMPLES = r""" +- name: Get License Term Details by name + cisco.dnac.license_term_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + device_type: string + smart_account_id: string + virtual_account_name: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "license_details": [ + { + "model": "string", + "virtual_account_name": "string", + "license_term_start_date": "string", + "license_term_end_date": "string", + "dna_level": "string", + "purchased_dna_license_count": "string", + "is_license_expired": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/license_usage_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/license_usage_details_info.py new file mode 100644 index 000000000..d315848c9 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/license_usage_details_info.py @@ -0,0 +1,114 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: license_usage_details_info +short_description: Information module for License Usage Details +description: +- Get License Usage Details by name. +- Get count of purchased and in use Cisco DNA and Network licenses. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + smart_account_id: + description: + - Smart_account_id path parameter. Id of smart account. + type: str + virtual_account_name: + description: + - > + Virtual_account_name path parameter. Name of virtual account. Putting "All" will give license term detail + for all virtual accounts. + type: str + device_type: + description: + - Device_type query parameter. Type of device like router, switch, wireless or ise. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Licenses LicenseUsageDetails2 + description: Complete reference of the LicenseUsageDetails2 API. + link: https://developer.cisco.com/docs/dna-center/#!license-usage-details-2 +notes: + - SDK Method used are + licenses.Licenses.license_usage_details2, + + - Paths used are + get /dna/intent/api/v1/licenses/usage/smartAccount/{smart_account_id}/virtualAccount/{virtual_account_name}, + +""" + +EXAMPLES = r""" +- name: Get License Usage Details by name + cisco.dnac.license_usage_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + device_type: string + smart_account_id: string + virtual_account_name: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "purchased_dna_license": { + "total_license_count": 0, + "license_count_by_type": [ + { + "license_type": "string", + "license_count": 0 + } + ] + }, + "purchased_network_license": { + "total_license_count": 0, + "license_count_by_type": [ + { + "license_type": "string", + "license_count": 0 + } + ] + }, + "used_dna_license": { + "total_license_count": 0, + "license_count_by_type": [ + { + "license_type": "string", + "license_count": 0 + } + ] + }, + "used_network_license": { + "total_license_count": 0, + "license_count_by_type": [ + { + "license_type": "string", + "license_count": 0 + } + ] + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/license_virtual_account_change.py b/ansible_collections/cisco/dnac/plugins/modules/license_virtual_account_change.py new file mode 100644 index 000000000..9e647aefc --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/license_virtual_account_change.py @@ -0,0 +1,74 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: license_virtual_account_change +short_description: Resource module for License Virtual Account Change +description: +- Manage operation create of the resource License Virtual Account Change. +- Transfer devices from one virtual account to another within same smart account. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + device_uuids: + description: Comma separated device ids. + elements: str + type: list + smart_account_id: + description: Smart_account_id path parameter. Id of smart account. + type: str + virtual_account_name: + description: Virtual_account_name path parameter. Name of target virtual account. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Licenses ChangeVirtualAccount2 + description: Complete reference of the ChangeVirtualAccount2 API. + link: https://developer.cisco.com/docs/dna-center/#!change-virtual-account-2 +notes: + - SDK Method used are + licenses.Licenses.change_virtual_account2, + + - Paths used are + post /dna/intent/api/v1/licenses/smartAccount/{smart_account_id}/virtualAccount/{virtual_account_name}/device/transfer, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.license_virtual_account_change: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + device_uuids: + - string + smart_account_id: string + virtual_account_name: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/license_virtual_account_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/license_virtual_account_details_info.py new file mode 100644 index 000000000..476f58758 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/license_virtual_account_details_info.py @@ -0,0 +1,74 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: license_virtual_account_details_info +short_description: Information module for License Virtual Account Details +description: +- Get all License Virtual Account Details. +- Get virtual account details of a smart account. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + smart_account_id: + description: + - Smart_account_id path parameter. Id of smart account. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Licenses VirtualAccountDetails2 + description: Complete reference of the VirtualAccountDetails2 API. + link: https://developer.cisco.com/docs/dna-center/#!virtual-account-details-2 +notes: + - SDK Method used are + licenses.Licenses.virtual_account_details2, + + - Paths used are + get /dna/intent/api/v1/licenses/smartAccount/{smart_account_id}/virtualAccounts, + +""" + +EXAMPLES = r""" +- name: Get all License Virtual Account Details + cisco.dnac.license_virtual_account_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + smart_account_id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "smart_account_id": "string", + "smart_account_name": "string", + "virtual_account_details": [ + { + "virtual_account_id": "string", + "virtual_account_name": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/netconf_credential.py b/ansible_collections/cisco/dnac/plugins/modules/netconf_credential.py new file mode 100644 index 000000000..a8cec0942 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/netconf_credential.py @@ -0,0 +1,115 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: netconf_credential +short_description: Resource module for Netconf Credential +description: +- Manage operations create and update of the resource Netconf Credential. +- Adds global netconf credentials. +- Updates global netconf credentials. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + comments: + description: Netconf Credential's comments. + type: str + credentialType: + description: Netconf Credential's credentialType. + type: str + description: + description: Netconf Credential's description. + type: str + id: + description: Netconf Credential's id. + type: str + instanceTenantId: + description: Netconf Credential's instanceTenantId. + type: str + instanceUuid: + description: Netconf Credential's instanceUuid. + type: str + netconfPort: + description: Netconf Credential's netconfPort. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery CreateNetconfCredentials + description: Complete reference of the CreateNetconfCredentials API. + link: https://developer.cisco.com/docs/dna-center/#!create-netconf-credentials +- name: Cisco DNA Center documentation for Discovery UpdateNetconfCredentials + description: Complete reference of the UpdateNetconfCredentials API. + link: https://developer.cisco.com/docs/dna-center/#!update-netconf-credentials +notes: + - SDK Method used are + discovery.Discovery.create_netconf_credentials, + discovery.Discovery.update_netconf_credentials, + + - Paths used are + post /dna/intent/api/v1/global-credential/netconf, + put /dna/intent/api/v1/global-credential/netconf, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.netconf_credential: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + comments: string + credentialType: string + description: string + id: string + instanceTenantId: string + instanceUuid: string + netconfPort: string + +- name: Create + cisco.dnac.netconf_credential: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - comments: string + credentialType: string + description: string + id: string + instanceTenantId: string + instanceUuid: string + netconfPort: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_create.py b/ansible_collections/cisco/dnac/plugins/modules/network_create.py new file mode 100644 index 000000000..9c7abda29 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_create.py @@ -0,0 +1,214 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_create +short_description: Resource module for Network Create +description: +- Manage operation create of the resource Network Create. +- > + API to create a network for DHCP, Syslog, SNMP, NTP, Network AAA, Client and EndPoint AAA, and/or DNS center + server settings. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + settings: + description: Network Create's settings. + suboptions: + clientAndEndpoint_aaa: + description: Network Create's clientAndEndpoint_aaa. + suboptions: + ipAddress: + description: IP address for ISE serve (eg 1.1.1.4). + type: str + network: + description: IP address for AAA or ISE server (eg 2.2.2.1). + type: str + protocol: + description: Protocol for AAA or ISE serve (eg RADIUS). + type: str + servers: + description: Server type AAA or ISE server (eg AAA). + type: str + sharedSecret: + description: Shared secret for ISE server. + type: str + type: dict + dhcpServer: + description: DHCP Server IP (eg 1.1.1.1). + elements: str + type: list + dnsServer: + description: Network Create's dnsServer. + suboptions: + domainName: + description: Domain Name of DHCP (eg; cisco). + type: str + primaryIpAddress: + description: Primary IP Address for DHCP (eg 2.2.2.2). + type: str + secondaryIpAddress: + description: Secondary IP Address for DHCP (eg 3.3.3.3). + type: str + type: dict + messageOfTheday: + description: Network Create's messageOfTheday. + suboptions: + bannerMessage: + description: Massage for Banner message (eg; Good day). + type: str + retainExistingBanner: + description: Retain existing Banner Message (eg "true" or "false"). + type: str + type: dict + netflowcollector: + description: Network Create's netflowcollector. + suboptions: + ipAddress: + description: IP Address for NetFlow collector (eg 3.3.3.1). + type: str + port: + description: Port for NetFlow Collector (eg; 443). + type: int + type: dict + network_aaa: + description: Network Create's network_aaa. + suboptions: + ipAddress: + description: IP address for AAA and ISE server (eg 1.1.1.1). + type: str + network: + description: IP Address for AAA or ISE server (eg 2.2.2.2). + type: str + protocol: + description: Protocol for AAA or ISE serve (eg RADIUS). + type: str + servers: + description: Server type for AAA Network (eg AAA). + type: str + sharedSecret: + description: Shared secret for ISE Server. + type: str + type: dict + ntpServer: + description: IP address for NTP server (eg 1.1.1.2). + elements: str + type: list + snmpServer: + description: Network Create's snmpServer. + suboptions: + configureDnacIP: + description: Configuration DNAC IP for SNMP Server (eg true). + type: bool + ipAddresses: + description: IP Address for SNMP Server (eg 4.4.4.1). + elements: str + type: list + type: dict + syslogServer: + description: Network Create's syslogServer. + suboptions: + configureDnacIP: + description: Configuration DNAC IP for syslog server (eg true). + type: bool + ipAddresses: + description: IP Address for syslog server (eg 4.4.4.4). + elements: str + type: list + type: dict + timezone: + description: Input for time zone (eg Africa/Abidjan). + type: str + type: dict + siteId: + description: SiteId path parameter. Site id to which site details to associate with + the network settings. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings CreateNetwork + description: Complete reference of the CreateNetwork API. + link: https://developer.cisco.com/docs/dna-center/#!create-network +notes: + - SDK Method used are + network_settings.NetworkSettings.create_network, + + - Paths used are + post /dna/intent/api/v1/network/{siteId}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.network_create: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: '{{my_headers | from_json}}' + settings: + clientAndEndpoint_aaa: + ipAddress: string + network: string + protocol: string + servers: string + sharedSecret: string + dhcpServer: + - string + dnsServer: + domainName: string + primaryIpAddress: string + secondaryIpAddress: string + messageOfTheday: + bannerMessage: string + retainExistingBanner: string + netflowcollector: + ipAddress: string + port: 0 + network_aaa: + ipAddress: string + network: string + protocol: string + servers: string + sharedSecret: string + ntpServer: + - string + snmpServer: + configureDnacIP: true + ipAddresses: + - string + syslogServer: + configureDnacIP: true + ipAddresses: + - string + timezone: string + siteId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device.py b/ansible_collections/cisco/dnac/plugins/modules/network_device.py new file mode 100644 index 000000000..e103dbbf1 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device.py @@ -0,0 +1,259 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device +short_description: Resource module for Network Device +description: +- Manage operations create, update and delete of the resource Network Device. +- Adds the device with given credential. +- Deletes the network device for the given Id. +- Sync the devices provided as input. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + cleanConfig: + description: CleanConfig query parameter. + type: bool + version_added: 4.0.0 + cliTransport: + description: Network Device's cliTransport. + type: str + computeDevice: + description: ComputeDevice flag. + type: bool + enablePassword: + description: Network Device's enablePassword. + type: str + extendedDiscoveryInfo: + description: Network Device's extendedDiscoveryInfo. + type: str + httpPassword: + description: Network Device's httpPassword. + type: str + httpPort: + description: Network Device's httpPort. + type: str + httpSecure: + description: HttpSecure flag. + type: bool + httpUserName: + description: Network Device's httpUserName. + type: str + id: + description: Id path parameter. Device ID. + type: str + ipAddress: + description: Network Device's ipAddress. + elements: str + type: list + merakiOrgId: + description: Network Device's merakiOrgId. + elements: str + type: list + netconfPort: + description: Network Device's netconfPort. + type: str + password: + description: Network Device's password. + type: str + serialNumber: + description: Network Device's serialNumber. + type: str + snmpAuthPassphrase: + description: Network Device's snmpAuthPassphrase. + type: str + snmpAuthProtocol: + description: Network Device's snmpAuthProtocol. + type: str + snmpMode: + description: Network Device's snmpMode. + type: str + snmpPrivPassphrase: + description: Network Device's snmpPrivPassphrase. + type: str + snmpPrivProtocol: + description: Network Device's snmpPrivProtocol. + type: str + snmpROCommunity: + description: Network Device's snmpROCommunity. + type: str + snmpRWCommunity: + description: Network Device's snmpRWCommunity. + type: str + snmpRetry: + description: Network Device's snmpRetry. + type: int + snmpTimeout: + description: Network Device's snmpTimeout. + type: int + snmpUserName: + description: Network Device's snmpUserName. + type: str + snmpVersion: + description: Network Device's snmpVersion. + type: str + type: + description: Network Device's type. + type: str + updateMgmtIPaddressList: + description: Network Device's updateMgmtIPaddressList. + elements: dict + suboptions: + existMgmtIpAddress: + description: Network Device's existMgmtIpAddress. + type: str + newMgmtIpAddress: + description: Network Device's newMgmtIpAddress. + type: str + type: list + userName: + description: Network Device's userName. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices AddDevice2 + description: Complete reference of the AddDevice2 API. + link: https://developer.cisco.com/docs/dna-center/#!add-device +- name: Cisco DNA Center documentation for Devices DeleteDeviceById + description: Complete reference of the DeleteDeviceById API. + link: https://developer.cisco.com/docs/dna-center/#!delete-device-by-id +- name: Cisco DNA Center documentation for Devices SyncDevices2 + description: Complete reference of the SyncDevices2 API. + link: https://developer.cisco.com/docs/dna-center/#!sync-devices +notes: + - SDK Method used are + devices.Devices.add_device, + devices.Devices.delete_device_by_id, + devices.Devices.sync_devices, + + - Paths used are + post /dna/intent/api/v1/network-device, + delete /dna/intent/api/v1/network-device/{id}, + put /dna/intent/api/v1/network-device, + + - Removed 'managementIpAddress' options in v4.3.0. +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.network_device: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + cliTransport: string + computeDevice: true + enablePassword: string + extendedDiscoveryInfo: string + httpPassword: string + httpPort: string + httpSecure: true + httpUserName: string + ipAddress: + - string + merakiOrgId: + - string + netconfPort: string + password: string + serialNumber: string + snmpAuthPassphrase: string + snmpAuthProtocol: string + snmpMode: string + snmpPrivPassphrase: string + snmpPrivProtocol: string + snmpROCommunity: string + snmpRWCommunity: string + snmpRetry: 0 + snmpTimeout: 0 + snmpUserName: string + snmpVersion: string + type: string + updateMgmtIPaddressList: + - existMgmtIpAddress: string + newMgmtIpAddress: string + userName: string + +- name: Update all + cisco.dnac.network_device: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + cliTransport: string + computeDevice: true + enablePassword: string + extendedDiscoveryInfo: string + httpPassword: string + httpPort: string + httpSecure: true + httpUserName: string + ipAddress: + - string + merakiOrgId: + - string + netconfPort: string + password: string + serialNumber: string + snmpAuthPassphrase: string + snmpAuthProtocol: string + snmpMode: string + snmpPrivPassphrase: string + snmpPrivProtocol: string + snmpROCommunity: string + snmpRWCommunity: string + snmpRetry: 0 + snmpTimeout: 0 + snmpUserName: string + snmpVersion: string + type: string + updateMgmtIPaddressList: + - existMgmtIpAddress: string + newMgmtIpAddress: string + userName: string + +- name: Delete by id + cisco.dnac.network_device: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + cleanConfig: true + id: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_by_ip_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_by_ip_info.py new file mode 100644 index 000000000..151347c57 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_by_ip_info.py @@ -0,0 +1,108 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_by_ip_info +short_description: Information module for Network Device By Ip +description: +- Get Network Device By Ip by id. +- Returns the network device by specified IP address. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + ipAddress: + description: + - IpAddress path parameter. Device IP address. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetNetworkDeviceByIP + description: Complete reference of the GetNetworkDeviceByIP API. + link: https://developer.cisco.com/docs/dna-center/#!get-network-device-by-ip +notes: + - SDK Method used are + devices.Devices.get_network_device_by_ip, + + - Paths used are + get /dna/intent/api/v1/network-device/ip-address/{ipAddress}, + +""" + +EXAMPLES = r""" +- name: Get Network Device By Ip by id + cisco.dnac.network_device_by_ip_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + ipAddress: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "apManagerInterfaceIp": "string", + "associatedWlcIp": "string", + "bootDateTime": "string", + "collectionInterval": "string", + "collectionStatus": "string", + "errorCode": "string", + "errorDescription": "string", + "family": "string", + "hostname": "string", + "id": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "interfaceCount": "string", + "inventoryStatusDetail": "string", + "lastUpdateTime": 0, + "lastUpdated": "string", + "lineCardCount": "string", + "lineCardId": "string", + "location": "string", + "locationName": "string", + "macAddress": "string", + "managementIpAddress": "string", + "memorySize": "string", + "platformId": "string", + "reachabilityFailureReason": "string", + "reachabilityStatus": "string", + "role": "string", + "roleSource": "string", + "serialNumber": "string", + "series": "string", + "snmpContact": "string", + "snmpLocation": "string", + "softwareType": "string", + "softwareVersion": "string", + "tagCount": "string", + "tunnelUdpPort": "string", + "type": "string", + "upTime": "string", + "waasDeviceMode": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_by_serial_number_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_by_serial_number_info.py new file mode 100644 index 000000000..4248aee8c --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_by_serial_number_info.py @@ -0,0 +1,108 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_by_serial_number_info +short_description: Information module for Network Device By Serial Number +description: +- Get Network Device By Serial Number by id. +- Returns the network device if the given serial number matches with any of the serial numbers collected. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + serialNumber: + description: + - SerialNumber path parameter. Device serial number. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetDeviceBySerialNumber + description: Complete reference of the GetDeviceBySerialNumber API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-by-serial-number +notes: + - SDK Method used are + devices.Devices.get_device_by_serial_number, + + - Paths used are + get /dna/intent/api/v1/network-device/serial-number/{serialNumber}, + +""" + +EXAMPLES = r""" +- name: Get Network Device By Serial Number by id + cisco.dnac.network_device_by_serial_number_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + serialNumber: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "apManagerInterfaceIp": "string", + "associatedWlcIp": "string", + "bootDateTime": "string", + "collectionInterval": "string", + "collectionStatus": "string", + "errorCode": "string", + "errorDescription": "string", + "family": "string", + "hostname": "string", + "id": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "interfaceCount": "string", + "inventoryStatusDetail": "string", + "lastUpdateTime": 0, + "lastUpdated": "string", + "lineCardCount": "string", + "lineCardId": "string", + "location": "string", + "locationName": "string", + "macAddress": "string", + "managementIpAddress": "string", + "memorySize": "string", + "platformId": "string", + "reachabilityFailureReason": "string", + "reachabilityStatus": "string", + "role": "string", + "roleSource": "string", + "serialNumber": "string", + "series": "string", + "snmpContact": "string", + "snmpLocation": "string", + "softwareType": "string", + "softwareVersion": "string", + "tagCount": "string", + "tunnelUdpPort": "string", + "type": "string", + "upTime": "string", + "waasDeviceMode": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_chassis_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_chassis_details_info.py new file mode 100644 index 000000000..6d540eae8 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_chassis_details_info.py @@ -0,0 +1,85 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_chassis_details_info +short_description: Information module for Network Device Chassis Details +description: +- Get all Network Device Chassis Details. +- Returns chassis details for given device ID. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceId: + description: + - DeviceId path parameter. Device ID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetChassisDetailsForDevice + description: Complete reference of the GetChassisDetailsForDevice API. + link: https://developer.cisco.com/docs/dna-center/#!get-chassis-details-for-device +notes: + - SDK Method used are + devices.Devices.get_chassis_details_for_device, + + - Paths used are + get /dna/intent/api/v1/network-device/{deviceId}/chassis, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Chassis Details + cisco.dnac.network_device_chassis_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "assemblyNumber": "string", + "assemblyRevision": "string", + "containmentEntity": "string", + "description": "string", + "entityPhysicalIndex": "string", + "hardwareVersion": "string", + "instanceUuid": "string", + "isFieldReplaceable": "string", + "isReportingAlarmsAllowed": "string", + "manufacturer": "string", + "name": "string", + "partNumber": "string", + "serialNumber": "string", + "vendorEquipmentType": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_config_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_config_count_info.py new file mode 100644 index 000000000..e2b2a2449 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_config_count_info.py @@ -0,0 +1,63 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_config_count_info +short_description: Information module for Network Device Config Count +description: +- Get all Network Device Config Count. +- Returns the count of device configs. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetDeviceConfigCount + description: Complete reference of the GetDeviceConfigCount API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-config-count +notes: + - SDK Method used are + devices.Devices.get_device_config_count, + + - Paths used are + get /dna/intent/api/v1/network-device/config/count, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Config Count + cisco.dnac.network_device_config_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_config_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_config_info.py new file mode 100644 index 000000000..b2832bb77 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_config_info.py @@ -0,0 +1,87 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_config_info +short_description: Information module for Network Device Config +description: +- Get all Network Device Config. +- Get Network Device Config by id. +- Returns the config for all devices. +- Returns the device config by specified device ID. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + networkDeviceId: + description: + - NetworkDeviceId path parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetDeviceConfigById + description: Complete reference of the GetDeviceConfigById API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-config-by-id +- name: Cisco DNA Center documentation for Devices GetDeviceConfigForAllDevices + description: Complete reference of the GetDeviceConfigForAllDevices API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-config-for-all-devices +notes: + - SDK Method used are + devices.Devices.get_device_config_by_id, + devices.Devices.get_device_config_for_all_devices, + + - Paths used are + get /dna/intent/api/v1/network-device/config, + get /dna/intent/api/v1/network-device/{networkDeviceId}/config, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Config + cisco.dnac.network_device_config_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +- name: Get Network Device Config by id + cisco.dnac.network_device_config_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + networkDeviceId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": "string", + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_count_info.py new file mode 100644 index 000000000..3a865dacb --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_count_info.py @@ -0,0 +1,89 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_count_info +short_description: Information module for Network Device Count +description: +- Get all Network Device Count. +- Get Network Device Count by id. +- > + Returns the count of network devices based on the filter criteria by management IP address, mac address, hostname + and location name. +- Returns the interface count for the given device. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceId: + description: + - DeviceId path parameter. Device ID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetDeviceCount2 + description: Complete reference of the GetDeviceCount2 API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-count +- name: Cisco DNA Center documentation for Devices GetDeviceInterfaceCount2 + description: Complete reference of the GetDeviceInterfaceCount2 API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-interface-count-2 +notes: + - SDK Method used are + devices.Devices.get_device_count, + devices.Devices.get_device_interface_count_by_id, + + - Paths used are + get /dna/intent/api/v1/interface/network-device/{deviceId}/count, + get /dna/intent/api/v1/network-device/count, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Count + cisco.dnac.network_device_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +- name: Get Network Device Count by id + cisco.dnac.network_device_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_custom_prompt.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_custom_prompt.py new file mode 100644 index 000000000..ab60bde8b --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_custom_prompt.py @@ -0,0 +1,71 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_custom_prompt +short_description: Resource module for Network Device Custom Prompt +description: +- Manage operation create of the resource Network Device Custom Prompt. +- > + Save custom prompt added by user in Cisco DNA Center. API will always override the existing prompts. User should + provide all the custom prompt in case of any update. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + passwordPrompt: + description: Password Prompt. + type: str + usernamePrompt: + description: Username Prompt. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for System Settings CustomPromptPOSTAPI + description: Complete reference of the CustomPromptPOSTAPI API. + link: https://developer.cisco.com/docs/dna-center/#!custom-prompt-postapi +notes: + - SDK Method used are + system_settings.SystemSettings.custom_prompt_post_api, + + - Paths used are + post /dna/intent/api/v1/network-device/custom-prompt, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.network_device_custom_prompt: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + passwordPrompt: string + usernamePrompt: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_custom_prompt_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_custom_prompt_info.py new file mode 100644 index 000000000..96a9c74bc --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_custom_prompt_info.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_custom_prompt_info +short_description: Information module for Network Device Custom Prompt Info +description: +- Get all Network Device Custom Prompt Info. +- Returns supported custom prompts by Cisco DNA Center. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for System Settings CustomPromptSupportGETAPI + description: Complete reference of the CustomPromptSupportGETAPI API. + link: https://developer.cisco.com/docs/dna-center/#!custom-prompt-support-getapi +notes: + - SDK Method used are + system_settings.SystemSettings.custom_prompt_support_get_api, + + - Paths used are + get /dna/intent/api/v1/network-device/custom-prompt, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Custom Prompt Info + cisco.dnac.network_device_custom_prompt_info_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "customUsernamePrompt": "string", + "customPasswordPrompt": "string", + "defaultUsernamePrompt": "string", + "defaultPasswordPrompt": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_equipment_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_equipment_info.py new file mode 100644 index 000000000..0e5cd5c64 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_equipment_info.py @@ -0,0 +1,85 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_equipment_info +short_description: Information module for Network Device Equipment +description: +- Get all Network Device Equipment. +- Return PowerSupply/ Fan details for the Given device. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceUuid: + description: + - DeviceUuid path parameter. + type: str + type: + description: + - > + Type query parameter. Type value can be PowerSupply, Fan, Chassis, Backplane, Module, PROCESSOR, Other, SFP. + If no type is mentioned, All equipments are fetched for the device. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices ReturnPowerSupplyFanDetailsForTheGivenDevice + description: Complete reference of the ReturnPowerSupplyFanDetailsForTheGivenDevice API. + link: https://developer.cisco.com/docs/dna-center/#!return-power-supply-fan-details-for-the-given-device +notes: + - SDK Method used are + devices.Devices.return_power_supply_fan_details_for_the_given_device, + + - Paths used are + get /dna/intent/api/v1/network-device/{deviceUuid}/equipment, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Equipment + cisco.dnac.network_device_equipment_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + type: string + deviceUuid: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "operationalStateCode": "string", + "productId": "string", + "serialNumber": "string", + "vendorEquipmentType": "string", + "description": "string", + "instanceUuid": "string", + "name": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_export.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_export.py new file mode 100644 index 000000000..93bb723e6 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_export.py @@ -0,0 +1,85 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_export +short_description: Resource module for Network Device Export +description: +- Manage operation create of the resource Network Device Export. +- Exports the selected network device to a file. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + deviceUuids: + description: Network Device Export's deviceUuids. + elements: str + type: list + id: + description: Network Device Export's id. + type: str + operationEnum: + description: Network Device Export's operationEnum. + type: str + parameters: + description: Network Device Export's parameters. + elements: str + type: list + password: + description: Network Device Export's password. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices ExportDeviceList + description: Complete reference of the ExportDeviceList API. + link: https://developer.cisco.com/docs/dna-center/#!export-device-list +notes: + - SDK Method used are + devices.Devices.export_device_list, + + - Paths used are + post /dna/intent/api/v1/network-device/file, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.network_device_export: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + deviceUuids: + - string + id: string + operationEnum: string + parameters: + - string + password: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_functional_capability_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_functional_capability_info.py new file mode 100644 index 000000000..60d2c04b2 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_functional_capability_info.py @@ -0,0 +1,113 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_functional_capability_info +short_description: Information module for Network Device Functional Capability +description: +- Get all Network Device Functional Capability. +- Get Network Device Functional Capability by id. +- Returns functional capability with given Id. +- Returns the functional-capability for given devices. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceId: + description: + - > + DeviceId query parameter. Accepts comma separated deviceid's and return list of functional-capabilities for + the given id's. If invalid or not-found id's are provided, null entry will be returned in the list. + type: str + functionName: + description: + - FunctionName query parameter. + elements: str + type: list + id: + description: + - Id path parameter. Functional Capability UUID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetFunctionalCapabilityById + description: Complete reference of the GetFunctionalCapabilityById API. + link: https://developer.cisco.com/docs/dna-center/#!get-functional-capability-by-id +- name: Cisco DNA Center documentation for Devices GetFunctionalCapabilityForDevices + description: Complete reference of the GetFunctionalCapabilityForDevices API. + link: https://developer.cisco.com/docs/dna-center/#!get-functional-capability-for-devices +notes: + - SDK Method used are + devices.Devices.get_functional_capability_by_id, + devices.Devices.get_functional_capability_for_devices, + + - Paths used are + get /dna/intent/api/v1/network-device/functional-capability, + get /dna/intent/api/v1/network-device/functional-capability/{id}, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Functional Capability + cisco.dnac.network_device_functional_capability_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceId: string + functionName: [] + register: result + +- name: Get Network Device Functional Capability by id + cisco.dnac.network_device_functional_capability_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "attributeInfo": {}, + "functionDetails": [ + { + "attributeInfo": {}, + "id": "string", + "propertyName": "string", + "stringValue": "string" + } + ], + "functionName": "string", + "functionOpState": "string", + "id": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_global_polling_interval_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_global_polling_interval_info.py new file mode 100644 index 000000000..4d1df2f6e --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_global_polling_interval_info.py @@ -0,0 +1,63 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_global_polling_interval_info +short_description: Information module for Network Device Global Polling Interval +description: +- Get all Network Device Global Polling Interval. +- Returns polling interval of all devices. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetPollingIntervalForAllDevices + description: Complete reference of the GetPollingIntervalForAllDevices API. + link: https://developer.cisco.com/docs/dna-center/#!get-polling-interval-for-all-devices +notes: + - SDK Method used are + devices.Devices.get_polling_interval_for_all_devices, + + - Paths used are + get /dna/intent/api/v1/network-device/collection-schedule/global, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Global Polling Interval + cisco.dnac.network_device_global_polling_interval_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_info.py new file mode 100644 index 000000000..49d427c07 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_info.py @@ -0,0 +1,325 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_info +short_description: Information module for Network Device +description: +- Get all Network Device. +- Get Network Device by id. +- Returns list of network devices based on filter criteria such as management IP address, mac address, hostname, etc. +- Returns the network device details for the given device ID. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + hostname: + description: + - Hostname query parameter. + elements: str + type: list + managementIpAddress: + description: + - ManagementIpAddress query parameter. + elements: str + type: list + macAddress: + description: + - MacAddress query parameter. + elements: str + type: list + locationName: + description: + - LocationName query parameter. + elements: str + type: list + serialNumber: + description: + - SerialNumber query parameter. + elements: str + type: list + location: + description: + - Location query parameter. + elements: str + type: list + family: + description: + - Family query parameter. + elements: str + type: list + type: + description: + - Type query parameter. + elements: str + type: list + series: + description: + - Series query parameter. + elements: str + type: list + collectionStatus: + description: + - CollectionStatus query parameter. + elements: str + type: list + collectionInterval: + description: + - CollectionInterval query parameter. + elements: str + type: list + notSyncedForMinutes: + description: + - NotSyncedForMinutes query parameter. + elements: str + type: list + errorCode: + description: + - ErrorCode query parameter. + elements: str + type: list + errorDescription: + description: + - ErrorDescription query parameter. + elements: str + type: list + softwareVersion: + description: + - SoftwareVersion query parameter. + elements: str + type: list + softwareType: + description: + - SoftwareType query parameter. + elements: str + type: list + platformId: + description: + - PlatformId query parameter. + elements: str + type: list + role: + description: + - Role query parameter. + elements: str + type: list + reachabilityStatus: + description: + - ReachabilityStatus query parameter. + elements: str + type: list + upTime: + description: + - UpTime query parameter. + elements: str + type: list + associatedWlcIp: + description: + - AssociatedWlcIp query parameter. + elements: str + type: list + license_name: + description: + - License.name query parameter. + elements: str + type: list + license_type: + description: + - License.type query parameter. + elements: str + type: list + license_status: + description: + - License.status query parameter. + elements: str + type: list + module_name: + description: + - Module+name query parameter. + elements: str + type: list + module_equpimenttype: + description: + - Module+equpimenttype query parameter. + elements: str + type: list + module_servicestate: + description: + - Module+servicestate query parameter. + elements: str + type: list + module_vendorequipmenttype: + description: + - Module+vendorequipmenttype query parameter. + elements: str + type: list + module_partnumber: + description: + - Module+partnumber query parameter. + elements: str + type: list + module_operationstatecode: + description: + - Module+operationstatecode query parameter. + elements: str + type: list + id: + description: + - > + Id query parameter. Accepts comma separated ids and return list of network-devices for the given ids. If + invalid or not-found ids are provided, null entry will be returned in the list. + type: str + deviceSupportLevel: + description: + - DeviceSupportLevel query parameter. + type: str + offset: + description: + - Offset query parameter. Offset >= 1 X gives results from Xth device onwards. + type: int + limit: + description: + - Limit query parameter. 1 <= limit <= 500 max. No. Of devices to be returned in the result. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetDeviceByID + description: Complete reference of the GetDeviceByID API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-by-id +- name: Cisco DNA Center documentation for Devices GetDeviceList + description: Complete reference of the GetDeviceList API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-list +notes: + - SDK Method used are + devices.Devices.get_device_by_id, + devices.Devices.get_device_list, + + - Paths used are + get /dna/intent/api/v1/network-device, + get /dna/intent/api/v1/network-device/{id}, + +""" + +EXAMPLES = r""" +- name: Get all Network Device + cisco.dnac.network_device_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + hostname: [] + managementIpAddress: [] + macAddress: [] + locationName: [] + serialNumber: [] + location: [] + family: [] + type: [] + series: [] + collectionStatus: [] + collectionInterval: [] + notSyncedForMinutes: [] + errorCode: [] + errorDescription: [] + softwareVersion: [] + softwareType: [] + platformId: [] + role: [] + reachabilityStatus: [] + upTime: [] + associatedWlcIp: [] + license_name: [] + license_type: [] + license_status: [] + module_name: [] + module_equpimenttype: [] + module_servicestate: [] + module_vendorequipmenttype: [] + module_partnumber: [] + module_operationstatecode: [] + id: string + deviceSupportLevel: string + offset: 0 + limit: 0 + register: result + +- name: Get Network Device by id + cisco.dnac.network_device_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "apManagerInterfaceIp": "string", + "associatedWlcIp": "string", + "bootDateTime": "string", + "collectionInterval": "string", + "collectionStatus": "string", + "errorCode": "string", + "errorDescription": "string", + "family": "string", + "hostname": "string", + "id": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "interfaceCount": "string", + "inventoryStatusDetail": "string", + "lastUpdateTime": 0, + "lastUpdated": "string", + "lineCardCount": "string", + "lineCardId": "string", + "location": "string", + "locationName": "string", + "macAddress": "string", + "managementIpAddress": "string", + "memorySize": "string", + "platformId": "string", + "reachabilityFailureReason": "string", + "reachabilityStatus": "string", + "role": "string", + "roleSource": "string", + "serialNumber": "string", + "series": "string", + "snmpContact": "string", + "snmpLocation": "string", + "softwareType": "string", + "softwareVersion": "string", + "tagCount": "string", + "tunnelUdpPort": "string", + "type": "string", + "upTime": "string", + "waasDeviceMode": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_interface_neighbor_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_interface_neighbor_info.py new file mode 100644 index 000000000..9b34f8a98 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_interface_neighbor_info.py @@ -0,0 +1,79 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_interface_neighbor_info +short_description: Information module for Network Device Interface Neighbor +description: +- Get all Network Device Interface Neighbor. +- Get connected device detail for given deviceUuid and interfaceUuid. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceUuid: + description: + - DeviceUuid path parameter. Instanceuuid of Device. + type: str + interfaceUuid: + description: + - InterfaceUuid path parameter. Instanceuuid of interface. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetConnectedDeviceDetail + description: Complete reference of the GetConnectedDeviceDetail API. + link: https://developer.cisco.com/docs/dna-center/#!get-connected-device-detail +notes: + - SDK Method used are + devices.Devices.get_connected_device_detail, + + - Paths used are + get /dna/intent/api/v1/network-device/{deviceUuid}/interface/{interfaceUuid}/neighbor, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Interface Neighbor + cisco.dnac.network_device_interface_neighbor_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceUuid: string + interfaceUuid: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "neighborDevice": "string", + "neighborPort": "string", + "capabilities": [ + "string" + ] + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_interface_poe_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_interface_poe_info.py new file mode 100644 index 000000000..3da01e141 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_interface_poe_info.py @@ -0,0 +1,85 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_interface_poe_info +short_description: Information module for Network Device Interface Poe +description: +- Get all Network Device Interface Poe. +- > + Returns POE interface details for the device, where deviceuuid is mandatory & accepts comma seperated interface + names which is optional and returns information for that particular interfaces where operStatus = + operationalStatus . +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceUuid: + description: + - DeviceUuid path parameter. Uuid of the device. + type: str + interfaceNameList: + description: + - InterfaceNameList query parameter. Comma seperated interface names. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices ReturnsPOEInterfaceDetailsForTheDevice + description: Complete reference of the ReturnsPOEInterfaceDetailsForTheDevice API. + link: https://developer.cisco.com/docs/dna-center/#!returns-poe-interface-details-for-the-device +notes: + - SDK Method used are + devices.Devices.poe_interface_details, + + - Paths used are + get /dna/intent/api/v1/network-device/{deviceUuid}/interface/poe-detail, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Interface Poe + cisco.dnac.network_device_interface_poe_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + interfaceNameList: string + deviceUuid: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": [ + { + "adminStatus": "string", + "operStatus": "string", + "interfaceName": "string", + "maxPortPower": "string", + "allocatedPower": "string", + "portPowerDrawn": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_inventory_insight_link_mismatch_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_inventory_insight_link_mismatch_info.py new file mode 100644 index 000000000..23f7c6c57 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_inventory_insight_link_mismatch_info.py @@ -0,0 +1,127 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_inventory_insight_link_mismatch_info +short_description: Information module for Network Device Inventory Insight Link Mismatch +description: +- Get all Network Device Inventory Insight Link Mismatch. +- Find all devices with link mismatch speed / vlan . +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + siteId: + description: + - SiteId path parameter. + type: str + offset: + description: + - Offset query parameter. Row Number. Default value is 1. + type: int + limit: + description: + - Limit query parameter. Default value is 500. + type: int + category: + description: + - Category query parameter. Links mismatch category. Value can be speed-duplex or vlan. + type: str + sortBy: + description: + - SortBy query parameter. Sort By. + type: str + order: + description: + - Order query parameter. Order. Value can be asc or desc. Default value is asc. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices InventoryInsightDeviceLinkMismatchAPI + description: Complete reference of the InventoryInsightDeviceLinkMismatchAPI API. + link: https://developer.cisco.com/docs/dna-center/#!inventory-insight-device-link-mismatch-api +notes: + - SDK Method used are + devices.Devices.inventory_insight_device_link_mismatch, + + - Paths used are + get /dna/intent/api/v1/network-device/insight/{siteId}/device-link, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Inventory Insight Link Mismatch + cisco.dnac.network_device_inventory_insight_link_mismatch_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + offset: 0 + limit: 0 + category: string + sortBy: string + order: string + siteId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "endPortAllowedVlanIds": "string", + "endPortNativeVlanId": "string", + "startPortAllowedVlanIds": "string", + "startPortNativeVlanId": "string", + "linkStatus": "string", + "endDeviceHostName": "string", + "endDeviceId": "string", + "endDeviceIpAddress": "string", + "endPortAddress": "string", + "endPortDuplex": "string", + "endPortId": "string", + "endPortMask": "string", + "endPortName": "string", + "endPortPepId": "string", + "endPortSpeed": "string", + "startDeviceHostName": "string", + "startDeviceId": "string", + "startDeviceIpAddress": "string", + "startPortAddress": "string", + "startPortDuplex": "string", + "startPortId": "string", + "startPortMask": "string", + "startPortName": "string", + "startPortPepId": "string", + "startPortSpeed": "string", + "lastUpdated": "string", + "numUpdates": 0, + "avgUpdateFrequency": 0, + "type": "string", + "instanceUuid": "string", + "instanceTenantId": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_lexicographically_sorted_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_lexicographically_sorted_info.py new file mode 100644 index 000000000..04e1ebfce --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_lexicographically_sorted_info.py @@ -0,0 +1,175 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_lexicographically_sorted_info +short_description: Information module for Network Device Lexicographically Sorted +description: +- Get all Network Device Lexicographically Sorted. +- Returns the list of values of the first given required parameter. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + vrfName: + description: + - VrfName query parameter. + type: str + managementIpAddress: + description: + - ManagementIpAddress query parameter. + type: str + hostname: + description: + - Hostname query parameter. + type: str + macAddress: + description: + - MacAddress query parameter. + type: str + family: + description: + - Family query parameter. + type: str + collectionStatus: + description: + - CollectionStatus query parameter. + type: str + collectionInterval: + description: + - CollectionInterval query parameter. + type: str + softwareVersion: + description: + - SoftwareVersion query parameter. + type: str + softwareType: + description: + - SoftwareType query parameter. + type: str + reachabilityStatus: + description: + - ReachabilityStatus query parameter. + type: str + reachabilityFailureReason: + description: + - ReachabilityFailureReason query parameter. + type: str + errorCode: + description: + - ErrorCode query parameter. + type: str + platformId: + description: + - PlatformId query parameter. + type: str + series: + description: + - Series query parameter. + type: str + type: + description: + - Type query parameter. + type: str + serialNumber: + description: + - SerialNumber query parameter. + type: str + upTime: + description: + - UpTime query parameter. + type: str + role: + description: + - Role query parameter. + type: str + roleSource: + description: + - RoleSource query parameter. + type: str + associatedWlcIp: + description: + - AssociatedWlcIp query parameter. + type: str + offset: + description: + - Offset query parameter. + type: int + limit: + description: + - Limit query parameter. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetDeviceValuesThatMatchFullyOrPartiallyAnAttribute + description: Complete reference of the GetDeviceValuesThatMatchFullyOrPartiallyAnAttribute API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-values-that-match-fully-or-partially-an-attribute +notes: + - SDK Method used are + devices.Devices.get_device_values_that_match_fully_or_partially_an_attribute, + + - Paths used are + get /dna/intent/api/v1/network-device/autocomplete, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Lexicographically Sorted + cisco.dnac.network_device_lexicographically_sorted_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + vrfName: string + managementIpAddress: string + hostname: string + macAddress: string + family: string + collectionStatus: string + collectionInterval: string + softwareVersion: string + softwareType: string + reachabilityStatus: string + reachabilityFailureReason: string + errorCode: string + platformId: string + series: string + type: string + serialNumber: string + upTime: string + role: string + roleSource: string + associatedWlcIp: string + offset: 0 + limit: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + "string" + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_linecard_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_linecard_details_info.py new file mode 100644 index 000000000..a2267a752 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_linecard_details_info.py @@ -0,0 +1,75 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_linecard_details_info +short_description: Information module for Network Device Linecard Details +description: +- Get all Network Device Linecard Details. +- Get line card detail for a given deviceuuid. Response will contain serial no, part no, switch no and slot no. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceUuid: + description: + - DeviceUuid path parameter. Instanceuuid of device. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetLinecardDetails + description: Complete reference of the GetLinecardDetails API. + link: https://developer.cisco.com/docs/dna-center/#!get-linecard-details +notes: + - SDK Method used are + devices.Devices.get_linecard_details, + + - Paths used are + get /dna/intent/api/v1/network-device/{deviceUuid}/line-card, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Linecard Details + cisco.dnac.network_device_linecard_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceUuid: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "serialno": "string", + "partno": "string", + "switchno": "string", + "slotno": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_meraki_organization_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_meraki_organization_info.py new file mode 100644 index 000000000..a9bde346e --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_meraki_organization_info.py @@ -0,0 +1,70 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_meraki_organization_info +short_description: Information module for Network Device Meraki Organization +description: +- Get all Network Device Meraki Organization. +- Returns list of organizations for meraki dashboard. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + id: + description: + - Id path parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetOrganizationListForMeraki + description: Complete reference of the GetOrganizationListForMeraki API. + link: https://developer.cisco.com/docs/dna-center/#!get-organization-list-for-meraki +notes: + - SDK Method used are + devices.Devices.get_organization_list_for_meraki, + + - Paths used are + get /dna/intent/api/v1/network-device/{id}/meraki-organization, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Meraki Organization + cisco.dnac.network_device_meraki_organization_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + "string" + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_module_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_module_count_info.py new file mode 100644 index 000000000..6bddca67e --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_module_count_info.py @@ -0,0 +1,92 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_module_count_info +short_description: Information module for Network Device Module Count +description: +- Get all Network Device Module Count. +- Returns Module Count. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceId: + description: + - DeviceId query parameter. + type: str + nameList: + description: + - NameList query parameter. + elements: str + type: list + vendorEquipmentTypeList: + description: + - VendorEquipmentTypeList query parameter. + elements: str + type: list + partNumberList: + description: + - PartNumberList query parameter. + elements: str + type: list + operationalStateCodeList: + description: + - OperationalStateCodeList query parameter. + elements: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetModuleCount + description: Complete reference of the GetModuleCount API. + link: https://developer.cisco.com/docs/dna-center/#!get-module-count +notes: + - SDK Method used are + devices.Devices.get_module_count, + + - Paths used are + get /dna/intent/api/v1/network-device/module/count, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Module Count + cisco.dnac.network_device_module_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceId: string + nameList: [] + vendorEquipmentTypeList: [] + partNumberList: [] + operationalStateCodeList: [] + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_module_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_module_info.py new file mode 100644 index 000000000..d9924fc15 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_module_info.py @@ -0,0 +1,143 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_module_info +short_description: Information module for Network Device Module +description: +- Get all Network Device Module. +- Get Network Device Module by id. +- Returns Module info by 'module id'. +- Returns modules by specified device id. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceId: + description: + - DeviceId query parameter. + type: str + limit: + description: + - Limit query parameter. + type: int + offset: + description: + - Offset query parameter. + type: int + nameList: + description: + - NameList query parameter. + elements: str + type: list + vendorEquipmentTypeList: + description: + - VendorEquipmentTypeList query parameter. + elements: str + type: list + partNumberList: + description: + - PartNumberList query parameter. + elements: str + type: list + operationalStateCodeList: + description: + - OperationalStateCodeList query parameter. + elements: str + type: list + id: + description: + - Id path parameter. Module id. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetModuleInfoById + description: Complete reference of the GetModuleInfoById API. + link: https://developer.cisco.com/docs/dna-center/#!get-module-info-by-id +- name: Cisco DNA Center documentation for Devices GetModules + description: Complete reference of the GetModules API. + link: https://developer.cisco.com/docs/dna-center/#!get-modules +notes: + - SDK Method used are + devices.Devices.get_module_info_by_id, + devices.Devices.get_modules, + + - Paths used are + get /dna/intent/api/v1/network-device/module, + get /dna/intent/api/v1/network-device/module/{id}, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Module + cisco.dnac.network_device_module_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceId: string + limit: 0 + offset: 0 + nameList: [] + vendorEquipmentTypeList: [] + partNumberList: [] + operationalStateCodeList: [] + register: result + +- name: Get Network Device Module by id + cisco.dnac.network_device_module_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "assemblyNumber": "string", + "assemblyRevision": "string", + "attributeInfo": {}, + "containmentEntity": "string", + "description": "string", + "entityPhysicalIndex": "string", + "id": "string", + "isFieldReplaceable": "string", + "isReportingAlarmsAllowed": "string", + "manufacturer": "string", + "moduleIndex": 0, + "name": "string", + "operationalStateCode": "string", + "partNumber": "string", + "serialNumber": "string", + "vendorEquipmentType": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_poe_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_poe_info.py new file mode 100644 index 000000000..ca99bdd37 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_poe_info.py @@ -0,0 +1,72 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_poe_info +short_description: Information module for Network Device Poe +description: +- Get all Network Device Poe. +- Returns POE details for device. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceUuid: + description: + - DeviceUuid path parameter. Uuid of the device. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices POEDetails + description: Complete reference of the POEDetails API. + link: https://developer.cisco.com/docs/dna-center/#!p-oe-details +notes: + - SDK Method used are + devices.Devices.poe_details, + + - Paths used are + get /dna/intent/api/v1/network-device/{deviceUuid}/poe, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Poe + cisco.dnac.network_device_poe_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceUuid: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "powerAllocated": "string", + "powerConsumed": "string", + "powerRemaining": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_polling_interval_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_polling_interval_info.py new file mode 100644 index 000000000..36bfbce02 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_polling_interval_info.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_polling_interval_info +short_description: Information module for Network Device Polling Interval +description: +- Get all Network Device Polling Interval. +- Returns polling interval by device id. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + id: + description: + - Id path parameter. Device ID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetPollingIntervalById + description: Complete reference of the GetPollingIntervalById API. + link: https://developer.cisco.com/docs/dna-center/#!get-polling-interval-by-id +notes: + - SDK Method used are + devices.Devices.get_polling_interval_by_id, + + - Paths used are + get /dna/intent/api/v1/network-device/{id}/collection-schedule, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Polling Interval + cisco.dnac.network_device_polling_interval_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_range_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_range_info.py new file mode 100644 index 000000000..2aa2f9e80 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_range_info.py @@ -0,0 +1,117 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_range_info +short_description: Information module for Network Device Range +description: +- Get all Network Device Range. +- > + Returns the list of network devices for the given pagination range. The maximum number of records that can be + retrieved is 500. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + startIndex: + description: + - StartIndex path parameter. Start index >=1. + type: int + recordsToReturn: + description: + - RecordsToReturn path parameter. Number of records to return 1<= recordsToReturn <= 500. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetNetworkDeviceByPaginationRange + description: Complete reference of the GetNetworkDeviceByPaginationRange API. + link: https://developer.cisco.com/docs/dna-center/#!get-network-device-by-pagination-range +notes: + - SDK Method used are + devices.Devices.get_network_device_by_pagination_range, + + - Paths used are + get /dna/intent/api/v1/network-device/{startIndex}/{recordsToReturn}, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Range + cisco.dnac.network_device_range_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + startIndex: 0 + recordsToReturn: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "apManagerInterfaceIp": "string", + "associatedWlcIp": "string", + "bootDateTime": "string", + "collectionInterval": "string", + "collectionStatus": "string", + "errorCode": "string", + "errorDescription": "string", + "family": "string", + "hostname": "string", + "id": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "interfaceCount": "string", + "inventoryStatusDetail": "string", + "lastUpdateTime": 0, + "lastUpdated": "string", + "lineCardCount": "string", + "lineCardId": "string", + "location": "string", + "locationName": "string", + "macAddress": "string", + "managementIpAddress": "string", + "memorySize": "string", + "platformId": "string", + "reachabilityFailureReason": "string", + "reachabilityStatus": "string", + "role": "string", + "roleSource": "string", + "serialNumber": "string", + "series": "string", + "snmpContact": "string", + "snmpLocation": "string", + "softwareType": "string", + "softwareVersion": "string", + "tagCount": "string", + "tunnelUdpPort": "string", + "type": "string", + "upTime": "string", + "waasDeviceMode": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_register_for_wsa_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_register_for_wsa_info.py new file mode 100644 index 000000000..7997fa15f --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_register_for_wsa_info.py @@ -0,0 +1,81 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_register_for_wsa_info +short_description: Information module for Network Device Register For Wsa +description: +- Get all Network Device Register For Wsa. +- > + It fetches devices which are registered to receive WSA notifications. The device serial number and/or MAC address + are required to be provided as query parameters. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + serialNumber: + description: + - SerialNumber query parameter. Serial number of the device. + type: str + macaddress: + description: + - Macaddress query parameter. Mac addres of the device. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetDevicesRegisteredForWSANotification + description: Complete reference of the GetDevicesRegisteredForWSANotification API. + link: https://developer.cisco.com/docs/dna-center/#!get-devices-registered-for-wsa-notification +notes: + - SDK Method used are + devices.Devices.get_devices_registered_for_wsa_notification, + + - Paths used are + get /dna/intent/api/v1/network-device/tenantinfo/macaddress, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Register For Wsa + cisco.dnac.network_device_register_for_wsa_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + serialNumber: string + macaddress: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "macAddress": "string", + "modelNumber": "string", + "name": "string", + "serialNumber": "string", + "tenantId": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_stack_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_stack_details_info.py new file mode 100644 index 000000000..4f8912bc9 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_stack_details_info.py @@ -0,0 +1,132 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_stack_details_info +short_description: Information module for Network Device Stack Details +description: +- Get all Network Device Stack Details. +- Retrieves complete stack details for given device ID. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceId: + description: + - DeviceId path parameter. Device ID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetStackDetailsForDevice + description: Complete reference of the GetStackDetailsForDevice API. + link: https://developer.cisco.com/docs/dna-center/#!get-stack-details-for-device +notes: + - SDK Method used are + devices.Devices.get_stack_details_for_device, + + - Paths used are + get /dna/intent/api/v1/network-device/{deviceId}/stack, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Stack Details + cisco.dnac.network_device_stack_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "deviceId": "string", + "stackPortInfo": [ + { + "isSynchOk": "string", + "linkActive": true, + "linkOk": true, + "name": "string", + "neighborPort": "string", + "nrLinkOkChanges": 0, + "stackCableLengthInfo": "string", + "stackPortOperStatusInfo": "string", + "switchPort": "string" + } + ], + "stackSwitchInfo": [ + { + "entPhysicalIndex": "string", + "hwPriority": 0, + "macAddress": "string", + "numNextReload": 0, + "platformId": "string", + "role": "string", + "serialNumber": "string", + "softwareImage": "string", + "stackMemberNumber": 0, + "state": "string", + "switchPriority": 0 + } + ], + "svlSwitchInfo": [ + { + "dadProtocol": "string", + "dadRecoveryReloadEnabled": true, + "domainNumber": 0, + "inDadRecoveryMode": true, + "swVirtualStatus": "string", + "switchMembers": [ + { + "bandwidth": "string", + "svlMemberEndPoints": [ + { + "svlMemberEndPointPorts": [ + { + "svlProtocolStatus": "string", + "swLocalInterface": "string", + "swRemoteInterface": "string" + } + ], + "svlNumber": 0, + "svlStatus": "string" + } + ], + "svlMemberNumber": 0, + "svlMemberPepSettings": [ + { + "dadEnabled": true, + "dadInterfaceName": "string" + } + ] + } + ] + } + ] + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_summary_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_summary_info.py new file mode 100644 index 000000000..4aa0c2940 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_summary_info.py @@ -0,0 +1,72 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_summary_info +short_description: Information module for Network Device Summary +description: +- Get all Network Device Summary. +- Returns brief summary of device info such as hostname, management IP address for the given device Id. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + id: + description: + - Id path parameter. Device ID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetDeviceSummary + description: Complete reference of the GetDeviceSummary API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-summary +notes: + - SDK Method used are + devices.Devices.get_device_summary, + + - Paths used are + get /dna/intent/api/v1/network-device/{id}/brief, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Summary + cisco.dnac.network_device_summary_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "id": "string", + "role": "string", + "roleSource": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_supervisor_card_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_supervisor_card_details_info.py new file mode 100644 index 000000000..f4547f295 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_supervisor_card_details_info.py @@ -0,0 +1,75 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_supervisor_card_details_info +short_description: Information module for Network Device Supervisor Card Details +description: +- Get all Network Device Supervisor Card Details. +- Get supervisor card detail for a given deviceuuid. Response will contain serial no, part no, switch no and slot no. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceUuid: + description: + - DeviceUuid path parameter. Instanceuuid of device. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetSupervisorCardDetail + description: Complete reference of the GetSupervisorCardDetail API. + link: https://developer.cisco.com/docs/dna-center/#!get-supervisor-card-detail +notes: + - SDK Method used are + devices.Devices.get_supervisor_card_detail, + + - Paths used are + get /dna/intent/api/v1/network-device/{deviceUuid}/supervisor-card, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Supervisor Card Details + cisco.dnac.network_device_supervisor_card_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceUuid: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "serialno": "string", + "partno": "string", + "switchno": "string", + "slotno": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_sync.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_sync.py new file mode 100644 index 000000000..255d81e12 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_sync.py @@ -0,0 +1,74 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_sync +short_description: Resource module for Network Device Sync +description: +- Manage operation update of the resource Network Device Sync. +- > + Synchronizes the devices. If forceSync param is false default then the sync would run in normal priority thread. + If forceSync param is true then the sync would run in high priority thread if available, else the sync will fail. + Result can be seen in the child task of each device. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + forceSync: + description: ForceSync query parameter. + type: bool + payload: + description: Network Device Sync's payload. + elements: dict + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices SyncDevices + description: Complete reference of the SyncDevices API. + link: https://developer.cisco.com/docs/dna-center/#!sync-devices-2 +notes: + - SDK Method used are + devices.Devices.sync_devices_using_forcesync, + + - Paths used are + put /dna/intent/api/v1/network-device/sync, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.network_device_sync: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + forceSync: true + payload: + - {} + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_update_role.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_update_role.py new file mode 100644 index 000000000..16972e2ee --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_update_role.py @@ -0,0 +1,73 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_update_role +short_description: Resource module for Network Device Update Role +description: +- Manage operation update of the resource Network Device Update Role. +- Updates the role of the device as access, core, distribution, border router. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + id: + description: Network Device Update Role's id. + type: str + role: + description: Network Device Update Role's role. + type: str + roleSource: + description: Network Device Update Role's roleSource. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices UpdateDeviceRole + description: Complete reference of the UpdateDeviceRole API. + link: https://developer.cisco.com/docs/dna-center/#!update-device-role +notes: + - SDK Method used are + devices.Devices.update_device_role, + + - Paths used are + put /dna/intent/api/v1/network-device/brief, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.network_device_update_role: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + id: string + role: string + roleSource: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_user_defined_field.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_user_defined_field.py new file mode 100644 index 000000000..b350e69dd --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_user_defined_field.py @@ -0,0 +1,111 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_user_defined_field +short_description: Resource module for Network Device User Defined Field +description: +- Manage operations create, update and delete of the resource Network Device User Defined Field. +- Creates a new global User Defined Field, which can be assigned to devices. +- Deletes an existing Global User-Defined-Field using it's id. +- Updates an existing global User Defined Field, using it's id. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + description: + description: Description of UDF. + type: str + id: + description: Id path parameter. UDF id. + type: str + name: + description: Name of UDF. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices CreateUserDefinedField + description: Complete reference of the CreateUserDefinedField API. + link: https://developer.cisco.com/docs/dna-center/#!create-user-defined-field +- name: Cisco DNA Center documentation for Devices DeleteUserDefinedField + description: Complete reference of the DeleteUserDefinedField API. + link: https://developer.cisco.com/docs/dna-center/#!delete-user-defined-field +- name: Cisco DNA Center documentation for Devices UpdateUserDefinedField + description: Complete reference of the UpdateUserDefinedField API. + link: https://developer.cisco.com/docs/dna-center/#!update-user-defined-field +notes: + - SDK Method used are + devices.Devices.create_user_defined_field, + devices.Devices.delete_user_defined_field, + devices.Devices.update_user_defined_field, + + - Paths used are + post /dna/intent/api/v1/network-device/user-defined-field, + delete /dna/intent/api/v1/network-device/user-defined-field/{id}, + put /dna/intent/api/v1/network-device/user-defined-field/{id}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.network_device_user_defined_field: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + description: string + name: string + +- name: Update by id + cisco.dnac.network_device_user_defined_field: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + description: string + id: string + name: string + +- name: Delete by id + cisco.dnac.network_device_user_defined_field: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + id: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_user_defined_field_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_user_defined_field_info.py new file mode 100644 index 000000000..d72f5955e --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_user_defined_field_info.py @@ -0,0 +1,81 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_user_defined_field_info +short_description: Information module for Network Device User Defined Field +description: +- Get all Network Device User Defined Field. +- > + Gets existing global User Defined Fields. If no input is given, it fetches ALL the Global UDFs. Filter/search is + supported either by UDF Ids or by UDF names, but not both. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + id: + description: + - Id query parameter. Comma-seperated id(s) used for search/filtering. + type: str + name: + description: + - Name query parameter. Comma-seperated name(s) used for search/filtering. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetAllUserDefinedFields + description: Complete reference of the GetAllUserDefinedFields API. + link: https://developer.cisco.com/docs/dna-center/#!get-all-user-defined-fields +notes: + - SDK Method used are + devices.Devices.get_all_user_defined_fields, + + - Paths used are + get /dna/intent/api/v1/network-device/user-defined-field, + +""" + +EXAMPLES = r""" +- name: Get all Network Device User Defined Field + cisco.dnac.network_device_user_defined_field_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + id: string + name: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "id": "string", + "name": "string", + "description": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_vlan_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_vlan_info.py new file mode 100644 index 000000000..d236beee3 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_vlan_info.py @@ -0,0 +1,84 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_vlan_info +short_description: Information module for Network Device Vlan +description: +- Get all Network Device Vlan. +- Returns Device Interface VLANs. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + id: + description: + - Id path parameter. + type: str + interfaceType: + description: + - InterfaceType query parameter. Vlan assocaited with sub-interface. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetDeviceInterfaceVLANs + description: Complete reference of the GetDeviceInterfaceVLANs API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-interface-vla-ns +notes: + - SDK Method used are + devices.Devices.get_device_interface_vlans, + + - Paths used are + get /dna/intent/api/v1/network-device/{id}/vlan, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Vlan + cisco.dnac.network_device_vlan_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + interfaceType: string + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "interfaceName": "string", + "ipAddress": "string", + "mask": 0, + "networkAddress": "string", + "numberOfIPs": 0, + "prefix": "string", + "vlanNumber": 0, + "vlanType": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_wireless_lan_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_wireless_lan_info.py new file mode 100644 index 000000000..29615e66d --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_wireless_lan_info.py @@ -0,0 +1,83 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_wireless_lan_info +short_description: Information module for Network Device Wireless Lan +description: +- Get all Network Device Wireless Lan. +- Returns the wireless lan controller info with given device ID. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + id: + description: + - Id path parameter. Device ID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetWirelessLanControllerDetailsById + description: Complete reference of the GetWirelessLanControllerDetailsById API. + link: https://developer.cisco.com/docs/dna-center/#!get-wireless-lan-controller-details-by-id +notes: + - SDK Method used are + devices.Devices.get_wireless_lan_controller_details_by_id, + + - Paths used are + get /dna/intent/api/v1/network-device/{id}/wireless-info, + +""" + +EXAMPLES = r""" +- name: Get all Network Device Wireless Lan + cisco.dnac.network_device_wireless_lan_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "adminEnabledPorts": [ + 0 + ], + "apGroupName": "string", + "deviceId": "string", + "ethMacAddress": "string", + "flexGroupName": "string", + "id": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "lagModeEnabled": true, + "netconfEnabled": true, + "wirelessLicenseInfo": "string", + "wirelessPackageInstalled": true + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_device_with_snmp_v3_des_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_device_with_snmp_v3_des_info.py new file mode 100644 index 000000000..4fd5157c5 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_device_with_snmp_v3_des_info.py @@ -0,0 +1,101 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_device_with_snmp_v3_des_info +short_description: Information module for Network Device With Snmp V3 Des +description: +- Get all Network Device With Snmp V3 Des. +- > + Returns devices added to Cisco DNA center with snmp v3 DES, where siteId is mandatory & accepts offset, limit, + sortby, order which are optional. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + siteId: + description: + - SiteId path parameter. + type: str + offset: + description: + - Offset query parameter. Row Number. Default value is 1. + type: int + limit: + description: + - Limit query parameter. Default value is 500. + type: int + sortBy: + description: + - SortBy query parameter. Sort By. + type: str + order: + description: + - Order query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices ReturnsDevicesAddedToCiscoDNACenterWithSnmpV3DES + description: Complete reference of the ReturnsDevicesAddedToCiscoDNACenterWithSnmpV3DES API. + link: https://developer.cisco.com/docs/dna-center/#!returns-devices-added-to-cisco-dna-center-with-snmp-v-3-des +notes: + - SDK Method used are + devices.Devices.get_devices_with_snmpv3_des, + + - Paths used are + get /dna/intent/api/v1/network-device/insight/{siteId}/insecure-connection, + +""" + +EXAMPLES = r""" +- name: Get all Network Device With Snmp V3 Des + cisco.dnac.network_device_with_snmp_v3_des_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + offset: 0 + limit: 0 + sortBy: string + order: string + siteId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "id": "string", + "managementIpAddress": "string", + "hostname": "string", + "type": "string", + "family": "string", + "lastUpdated": "string", + "upTime": "string", + "reachabilityStatus": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_info.py new file mode 100644 index 000000000..682a9b5b1 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_info.py @@ -0,0 +1,88 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_info +short_description: Information module for Network +description: +- Get all Network. +- API to get DHCP and DNS center server details. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + siteId: + description: + - SiteId query parameter. Site id to get the network settings associated with the site. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings GetNetwork + description: Complete reference of the GetNetwork API. + link: https://developer.cisco.com/docs/dna-center/#!get-network +notes: + - SDK Method used are + network_settings.NetworkSettings.get_network, + + - Paths used are + get /dna/intent/api/v1/network, + +""" + +EXAMPLES = r""" +- name: Get all Network + cisco.dnac.network_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + siteId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "instanceType": "string", + "instanceUuid": "string", + "namespace": "string", + "type": "string", + "key": "string", + "version": 0, + "value": [ + { + "ipAddresses": [ + "string" + ], + "configureDnacIP": true + } + ], + "groupUuid": "string", + "inheritedGroupUuid": "string", + "inheritedGroupName": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_update.py b/ansible_collections/cisco/dnac/plugins/modules/network_update.py new file mode 100644 index 000000000..be67025b8 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_update.py @@ -0,0 +1,210 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_update +short_description: Resource module for Network Update +description: +- Manage operation update of the resource Network Update. +- > + API to update network settings for DHCP, Syslog, SNMP, NTP, Network AAA, Client and EndPoint AAA, and/or DNS + server settings. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + settings: + description: Network Update's settings. + suboptions: + clientAndEndpoint_aaa: + description: Network Update's clientAndEndpoint_aaa. + suboptions: + ipAddress: + description: IP address for ISE serve (eg 1.1.1.4). + type: str + network: + description: IP address for AAA or ISE server (eg 2.2.2.1). + type: str + protocol: + description: Protocol for AAA or ISE serve (eg RADIUS). + type: str + servers: + description: Server type AAA or ISE server (eg AAA). + type: str + sharedSecret: + description: Shared secret for ISE server. + type: str + type: dict + dhcpServer: + description: DHCP Server IP (eg 1.1.1.1). + elements: str + type: list + dnsServer: + description: Network Update's dnsServer. + suboptions: + domainName: + description: Domain Name of DHCP (eg; cisco). + type: str + primaryIpAddress: + description: Primary IP Address for DHCP (eg 2.2.2.2). + type: str + secondaryIpAddress: + description: Secondary IP Address for DHCP (eg 3.3.3.3). + type: str + type: dict + messageOfTheday: + description: Network Update's messageOfTheday. + suboptions: + bannerMessage: + description: Massage for Banner message (eg; Good day). + type: str + retainExistingBanner: + description: Retain existing Banner Message (eg "true" or "false"). + type: str + type: dict + netflowcollector: + description: Network Update's netflowcollector. + suboptions: + ipAddress: + description: IP Address for NetFlow collector (eg 3.3.3.1). + type: str + port: + description: Port for NetFlow Collector (eg; 443). + type: int + type: dict + network_aaa: + description: Network Update's network_aaa. + suboptions: + ipAddress: + description: IP address for AAA and ISE server (eg 1.1.1.1). + type: str + network: + description: IP Address for AAA or ISE server (eg 2.2.2.2). + type: str + protocol: + description: Protocol for AAA or ISE serve (eg RADIUS). + type: str + servers: + description: Server type for AAA Network (eg AAA). + type: str + sharedSecret: + description: Shared secret for ISE Server. + type: str + type: dict + ntpServer: + description: IP address for NTP server (eg 1.1.1.2). + elements: str + type: list + snmpServer: + description: Network Update's snmpServer. + suboptions: + configureDnacIP: + description: Configuration DNAC IP for SNMP Server (eg true). + type: bool + ipAddresses: + description: IP Address for SNMP Server (eg 4.4.4.1). + elements: str + type: list + type: dict + syslogServer: + description: Network Update's syslogServer. + suboptions: + configureDnacIP: + description: Configuration DNAC IP for syslog server (eg true). + type: bool + ipAddresses: + description: IP Address for syslog server (eg 4.4.4.4). + elements: str + type: list + type: dict + timezone: + description: Input for time zone (eg Africa/Abidjan). + type: str + type: dict + siteId: + description: SiteId path parameter. Site id to update the network settings which + is associated with the site. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings UpdateNetwork + description: Complete reference of the UpdateNetwork API. + link: https://developer.cisco.com/docs/dna-center/#!update-network +notes: + - SDK Method used are + network_settings.NetworkSettings.update_network, + + - Paths used are + put /dna/intent/api/v1/network/{siteId}, + +""" + +EXAMPLES = r""" +- name: Update by id + cisco.dnac.network_update: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + settings: + clientAndEndpoint_aaa: + ipAddress: string + network: string + protocol: string + servers: string + sharedSecret: string + dhcpServer: + - string + dnsServer: + domainName: string + primaryIpAddress: string + secondaryIpAddress: string + messageOfTheday: + bannerMessage: string + retainExistingBanner: string + netflowcollector: + ipAddress: string + port: 0 + network_aaa: + ipAddress: string + network: string + protocol: string + servers: string + sharedSecret: string + ntpServer: + - string + snmpServer: + configureDnacIP: true + ipAddresses: + - string + syslogServer: + configureDnacIP: true + ipAddresses: + - string + timezone: string + siteId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_v2.py b/ansible_collections/cisco/dnac/plugins/modules/network_v2.py new file mode 100644 index 000000000..14ca5c286 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_v2.py @@ -0,0 +1,266 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_v2 +short_description: Resource module for Network V2 +description: +- Manage operations create and update of the resource Network V2. +- > + API to create network settings for DHCP, Syslog, SNMP, NTP, Network AAA, Client and Endpoint AAA, and/or DNS + center server settings. +- > + API to update network settings for DHCP, Syslog, SNMP, NTP, Network AAA, Client and Endpoint AAA, and/or DNS + center server settings. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + settings: + description: Network V2's settings. + suboptions: + clientAndEndpoint_aaa: + description: Network V2's clientAndEndpoint_aaa. + suboptions: + ipAddress: + description: IP address for ISE serve (eg 1.1.1.4). + type: str + network: + description: IP address for AAA or ISE server (eg 2.2.2.1). + type: str + protocol: + description: Protocol for AAA or ISE serve (eg RADIUS). + type: str + servers: + description: Server type AAA or ISE server (eg AAA). + type: str + sharedSecret: + description: Shared secret for ISE server. + type: str + type: dict + dhcpServer: + description: DHCP Server IP (eg 1.1.1.1). + elements: str + type: list + dnsServer: + description: Network V2's dnsServer. + suboptions: + domainName: + description: Domain Name of DHCP (eg; cisco). + type: str + primaryIpAddress: + description: Primary IP Address for DHCP (eg 2.2.2.2). + type: str + secondaryIpAddress: + description: Secondary IP Address for DHCP (eg 3.3.3.3). + type: str + type: dict + messageOfTheday: + description: Network V2's messageOfTheday. + suboptions: + bannerMessage: + description: Massage for Banner message (eg; Good day). + type: str + retainExistingBanner: + description: Retain existing Banner Message (eg "true" or "false"). + type: str + type: dict + netflowcollector: + description: Network V2's netflowcollector. + suboptions: + ipAddress: + description: IP Address for NetFlow collector (eg 3.3.3.1). + type: str + port: + description: Port for NetFlow Collector (eg; 443). + type: int + type: dict + network_aaa: + description: Network V2's network_aaa. + suboptions: + ipAddress: + description: IP address for AAA and ISE server (eg 1.1.1.1). + type: str + network: + description: IP Address for AAA or ISE server (eg 2.2.2.2). + type: str + protocol: + description: Protocol for AAA or ISE serve (eg RADIUS). + type: str + servers: + description: Server type for AAA Network (eg AAA). + type: str + sharedSecret: + description: Shared secret for ISE Server. + type: str + type: dict + ntpServer: + description: IP address for NTP server (eg 1.1.1.2). + elements: str + type: list + snmpServer: + description: Network V2's snmpServer. + suboptions: + configureDnacIP: + description: Configuration DNAC IP for SNMP Server (eg true). + type: bool + ipAddresses: + description: IP Address for SNMP Server (eg 4.4.4.1). + elements: str + type: list + type: dict + syslogServer: + description: Network V2's syslogServer. + suboptions: + configureDnacIP: + description: Configuration DNAC IP for syslog server (eg true). + type: bool + ipAddresses: + description: IP Address for syslog server (eg 4.4.4.4). + elements: str + type: list + type: dict + timezone: + description: Input for time zone (eg Africa/Abidjan). + type: str + type: dict + siteId: + description: SiteId path parameter. Site Id to which site details to associate with + the network settings. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings CreateNetworkV2 + description: Complete reference of the CreateNetworkV2 API. + link: https://developer.cisco.com/docs/dna-center/#!create-network-v-2 +- name: Cisco DNA Center documentation for Network Settings UpdateNetworkV2 + description: Complete reference of the UpdateNetworkV2 API. + link: https://developer.cisco.com/docs/dna-center/#!update-network-v-2 +notes: + - SDK Method used are + network_settings.NetworkSettings.create_network_v2, + network_settings.NetworkSettings.update_network_v2, + + - Paths used are + post /dna/intent/api/v2/network/{siteId}, + put /dna/intent/api/v2/network/{siteId}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.network_v2: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + settings: + clientAndEndpoint_aaa: + ipAddress: string + network: string + protocol: string + servers: string + sharedSecret: string + dhcpServer: + - string + dnsServer: + domainName: string + primaryIpAddress: string + secondaryIpAddress: string + messageOfTheday: + bannerMessage: string + retainExistingBanner: string + netflowcollector: + ipAddress: string + port: 0 + network_aaa: + ipAddress: string + network: string + protocol: string + servers: string + sharedSecret: string + ntpServer: + - string + snmpServer: + configureDnacIP: true + ipAddresses: + - string + syslogServer: + configureDnacIP: true + ipAddresses: + - string + timezone: string + siteId: string + +- name: Update by id + cisco.dnac.network_v2: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + settings: + clientAndEndpoint_aaa: + ipAddress: string + network: string + protocol: string + servers: string + sharedSecret: string + dhcpServer: + - string + dnsServer: + domainName: string + primaryIpAddress: string + secondaryIpAddress: string + messageOfTheday: + bannerMessage: string + retainExistingBanner: string + netflowcollector: + ipAddress: string + port: 0 + network_aaa: + ipAddress: string + network: string + protocol: string + servers: string + sharedSecret: string + ntpServer: + - string + snmpServer: + configureDnacIP: true + ipAddresses: + - string + syslogServer: + configureDnacIP: true + ipAddresses: + - string + timezone: string + siteId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "taskId": "string", + "url": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/network_v2_info.py b/ansible_collections/cisco/dnac/plugins/modules/network_v2_info.py new file mode 100644 index 000000000..f3b03cb76 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/network_v2_info.py @@ -0,0 +1,81 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: network_v2_info +short_description: Information module for Network V2 +description: +- Get all Network V2. +- API to get SNMP, NTP, Network AAA, Client and Endpoint AAA, and/or DNS center server settings. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + siteId: + description: + - SiteId query parameter. Site Id to get the network settings associated with the site. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings GetNetworkV2 + description: Complete reference of the GetNetworkV2 API. + link: https://developer.cisco.com/docs/dna-center/#!get-network-v-2 +notes: + - SDK Method used are + network_settings.NetworkSettings.get_network_v2, + + - Paths used are + get /dna/intent/api/v2/network, + +""" + +EXAMPLES = r""" +- name: Get all Network V2 + cisco.dnac.network_v2_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + siteId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "instanceType": "string", + "instanceUuid": "string", + "namespace": "string", + "type": "string", + "key": "string", + "version": 0, + "value": [ + "string" + ], + "groupUuid": "string", + "inheritedGroupUuid": "string", + "inheritedGroupName": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/nfv_profile.py b/ansible_collections/cisco/dnac/plugins/modules/nfv_profile.py new file mode 100644 index 000000000..409c937d4 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/nfv_profile.py @@ -0,0 +1,288 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: nfv_profile +short_description: Resource module for Nfv Profile +description: +- Manage operations create, update and delete of the resource Nfv Profile. +- API to create network profile for different NFV topologies. +- API to delete nfv network profile. +- API to update a NFV Network profile. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + device: + description: Nfv Profile's device. + elements: dict + suboptions: + customNetworks: + description: Nfv Profile's customNetworks. + elements: dict + suboptions: + connectionType: + description: Type of network connection from custom network (eg lan). + type: str + networkName: + description: Name of custom network (eg cust-1). + type: str + servicesToConnect: + description: Nfv Profile's servicesToConnect. + elements: dict + suboptions: + serviceName: + description: Name of service to be connected to the custom network (eg + router-1). + type: str + type: list + vlanId: + description: Vlan id for the custom network(eg 4000). + type: int + vlanMode: + description: Network mode (eg Access or Trunk). + type: str + type: list + customTemplate: + description: Nfv Profile's customTemplate. + elements: dict + suboptions: + deviceType: + description: Type of the device(eg Cisco 5400 Enterprise Network Compute + System). + type: str + template: + description: Name of the template(eg NFVIS template). + type: str + templateType: + description: Name of the template type to which template is associated (eg + Cloud DayN Templates). + type: str + type: list + deviceTag: + description: Device Tag name(eg dev1). + type: str + deviceType: + description: Name of the device used in creating nfv profile. + type: str + directInternetAccessForFirewall: + description: Direct internet access value should be boolean (eg false or true). + type: bool + serviceProviderProfile: + description: Nfv Profile's serviceProviderProfile. + elements: dict + suboptions: + connect: + description: Connection of service provider and device value should be boolean + (eg true). + type: bool + connectDefaultGatewayOnWan: + description: Connect default gateway connect value as boolean (eg true). + type: bool + linkType: + description: Name of connection type(eg GigabitEthernet). + type: str + serviceProvider: + description: Name of the service provider(eg Airtel). + type: str + type: list + services: + description: Nfv Profile's services. + elements: dict + suboptions: + firewallMode: + description: Firewall mode details example (routed, transparent). + type: str + imageName: + description: Service image name (eg isrv-universalk9.16.12.01a.tar.gz). + type: str + profileType: + description: Profile type of service (eg ISRv-mini). + type: str + serviceName: + description: Name of the service (eg Router-1). + type: str + serviceType: + description: Service type (eg ISRV). + type: str + vNicMapping: + description: Nfv Profile's vNicMapping. + elements: dict + suboptions: + assignIpAddressToNetwork: + description: Assign ip address to network (eg true or false). + type: str + networkType: + description: Type of connection (eg wan, lan or internal). + type: str + type: list + type: list + vlanForL2: + description: Nfv Profile's vlanForL2. + elements: dict + suboptions: + vlanDescription: + description: Vlan description(eg Access 4018). + type: str + vlanId: + description: Vlan id (eg 4018). + type: int + vlanType: + description: Vlan type(eg Access or Trunk). + type: str + type: list + type: list + id: + description: Id path parameter. Id of the NFV profile to be updated. + type: str + name: + description: Name query parameter. Name of the profile to be updated. + type: str + profileName: + description: Name of the profile to create NFV profile. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Site Design CreateNFVProfile + description: Complete reference of the CreateNFVProfile API. + link: https://developer.cisco.com/docs/dna-center/#!create-nfv-profile +- name: Cisco DNA Center documentation for Site Design DeleteNFVProfile + description: Complete reference of the DeleteNFVProfile API. + link: https://developer.cisco.com/docs/dna-center/#!delete-nfv-profile +- name: Cisco DNA Center documentation for Site Design UpdateNFVProfile + description: Complete reference of the UpdateNFVProfile API. + link: https://developer.cisco.com/docs/dna-center/#!update-nfv-profile +notes: + - SDK Method used are + site_design.SiteDesign.create_nfv_profile, + site_design.SiteDesign.delete_nfv_profile, + site_design.SiteDesign.update_nfv_profile, + + - Paths used are + post /dna/intent/api/v1/nfv/network-profile, + delete /dna/intent/api/v1/nfv/network-profile/{id}, + put /dna/intent/api/v1/nfv/network-profile/{id}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.nfv_profile: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + device: + - customNetworks: + - connectionType: string + networkName: string + servicesToConnect: + - serviceName: string + vlanId: 0 + vlanMode: string + customTemplate: + - deviceType: string + template: string + templateType: string + deviceTag: string + deviceType: string + directInternetAccessForFirewall: true + serviceProviderProfile: + - connect: true + connectDefaultGatewayOnWan: true + linkType: string + serviceProvider: string + services: + - firewallMode: string + imageName: string + profileType: string + serviceName: string + serviceType: string + vNicMapping: + - assignIpAddressToNetwork: string + networkType: string + vlanForL2: + - vlanDescription: string + vlanId: 0 + vlanType: string + profileName: string + +- name: Update by id + cisco.dnac.nfv_profile: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + device: + - currentDeviceTag: string + customNetworks: + - connectionType: string + networkName: string + servicesToConnect: + - serviceName: string + vlanId: 0 + vlanMode: string + customTemplate: + - deviceType: string + template: string + templateType: string + deviceTag: string + directInternetAccessForFirewall: true + services: + - firewallMode: string + imageName: string + profileType: string + serviceName: string + serviceType: string + vNicMapping: + - assignIpAddressToNetwork: string + networkType: string + vlanForL2: + - vlanDescription: string + vlanId: 0 + vlanType: string + id: string + name: string + +- name: Delete by id + cisco.dnac.nfv_profile: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + id: string + name: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/nfv_profile_info.py b/ansible_collections/cisco/dnac/plugins/modules/nfv_profile_info.py new file mode 100644 index 000000000..946879359 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/nfv_profile_info.py @@ -0,0 +1,144 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: nfv_profile_info +short_description: Information module for Nfv Profile +description: +- Get Nfv Profile by id. +- API to get NFV network profile. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + id: + description: + - Id path parameter. ID of network profile to retrieve. + type: str + offset: + description: + - Offset query parameter. Offset/starting row. + type: int + limit: + description: + - Limit query parameter. Number of profile to be retrieved. + type: int + name: + description: + - Name query parameter. Name of network profile to be retrieved. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Site Design GetNFVProfile + description: Complete reference of the GetNFVProfile API. + link: https://developer.cisco.com/docs/dna-center/#!get-nfv-profile +notes: + - SDK Method used are + site_design.SiteDesign.get_nfv_profile, + + - Paths used are + get /dna/intent/api/v1/nfv/network-profile/{id}, + +""" + +EXAMPLES = r""" +- name: Get Nfv Profile by id + cisco.dnac.nfv_profile_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + offset: 0 + limit: 0 + name: string + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "profileName": "string", + "id": "string", + "device": [ + { + "deviceType": "string", + "deviceTag": "string", + "serviceProviderProfile": [ + { + "linkType": "string", + "connect": true, + "connectDefaultGatewayOnWan": true, + "serviceProvider": "string" + } + ], + "directInternetAccessForFirewall": true, + "services": [ + { + "serviceType": "string", + "profileType": "string", + "serviceName": "string", + "imageName": "string", + "vNicMapping": [ + { + "networkType": "string", + "assignIpAddressToNetwork": true + } + ], + "firewallMode": "string" + } + ], + "customNetworks": [ + { + "networkName": "string", + "servicesToConnect": [ + { + "serviceName": "string" + } + ], + "connectionType": "string", + "vlanMode": "string", + "vlanId": "string" + } + ], + "vlanForL2": [ + { + "vlanType": "string", + "vlanId": "string", + "vlanDescription": "string" + } + ], + "customTemplate": [ + { + "deviceType": "string", + "template": "string", + "templateType": "string" + } + ] + } + ] + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/nfv_provision.py b/ansible_collections/cisco/dnac/plugins/modules/nfv_provision.py new file mode 100644 index 000000000..23f4269f0 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/nfv_provision.py @@ -0,0 +1,521 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: nfv_provision +short_description: Resource module for Nfv Provision +description: +- Manage operation create of the resource Nfv Provision. +- Design and Provision single/multi NFV device with given site/area/building/floor . +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + provisioning: + description: Nfv Provision's provisioning. + elements: dict + suboptions: + device: + description: Nfv Provision's device. + elements: dict + suboptions: + customNetworks: + description: Nfv Provision's customNetworks. + elements: dict + suboptions: + ipAddressPool: + description: IP address pool of sub pool (eg 175.175.140.1). + type: str + name: + description: Name of custom network (eg cust-1). + type: str + port: + description: Port for custom network (eg 443). + type: str + type: list + deviceSerialNumber: + description: Serial number of device (eg FGL210710QY). + type: str + ip: + description: IP address of the device (eg 172.20.126.90). + type: str + serviceProviders: + description: Nfv Provision's serviceProviders. + elements: dict + suboptions: + serviceProvider: + description: Name of the service provider (eg Airtel). + type: str + wanInterface: + description: Nfv Provision's wanInterface. + suboptions: + bandwidth: + description: Bandwidth limit (eg 100). + type: str + gateway: + description: Gateway (eg 175.175.190.1). + type: str + interfaceName: + description: Name of the interface (eg GE0-0). + type: str + ipAddress: + description: IP address (eg 175.175.190.205). + type: str + subnetmask: + description: Subnet mask (eg 255.255.255.0). + type: str + type: dict + type: list + services: + description: Nfv Provision's services. + elements: dict + suboptions: + adminPasswordHash: + description: Admin password hash. + type: str + centralManagerIP: + description: WAAS Package needs to be installed to populate Central + Manager IP automatically. + type: str + centralRegistrationKey: + description: Central registration key. + type: str + commonKey: + description: Common key. + type: str + disk: + description: Name of disk type (eg internal). + type: str + mode: + description: Mode of firewall (eg transparent). + type: str + systemIp: + description: System IP. + type: str + type: + description: Type of service (eg ISR). + type: str + type: list + subPools: + description: Nfv Provision's subPools. + elements: dict + suboptions: + gateway: + description: IP address for gate way (eg 175.175.140.1). + type: str + ipSubnet: + description: IP pool cidir (eg 175.175.140.0). + type: str + name: + description: Name of the ip sub pool (eg; Lan-65). + type: str + parentPoolName: + description: Name of parent pool (global pool name). + type: str + type: + description: Tyep of ip sub pool (eg Lan). + type: str + type: list + tagName: + description: Name of device tag (eg dev1). + type: str + templateParam: + description: Nfv Provision's templateParam. + suboptions: + asav: + description: Nfv Provision's asav. + suboptions: + var1: + description: Variable for asav template (eg "test" "Hello asav"). + type: str + type: dict + nfvis: + description: Nfv Provision's nfvis. + suboptions: + var1: + description: Variable for nfvis template (eg "test" "Hello nfvis"). + type: str + type: dict + type: dict + vlan: + description: Nfv Provision's vlan. + elements: dict + suboptions: + id: + description: Vlan id(e .4018). + type: str + interfaces: + description: Interface (eg GigabitEathernet1/0). + type: str + network: + description: Network name to connect (eg lan-net). + type: str + type: + description: Vlan type(eg. Access or Trunk). + type: str + type: list + type: list + site: + description: Nfv Provision's site. + suboptions: + area: + description: Nfv Provision's area. + suboptions: + name: + description: Name of the area (eg Area1). + type: str + parentName: + description: Parent name of the area to be created. + type: str + type: dict + building: + description: Nfv Provision's building. + suboptions: + address: + description: Address of the building to be created. + type: str + latitude: + description: Latitude coordinate of the building (eg 37.338). + type: int + longitude: + description: Longitude coordinate of the building (eg -121.832). + type: int + name: + description: Name of the building (eg building1). + type: str + parentName: + description: Address of the building to be created. + type: str + type: dict + floor: + description: Nfv Provision's floor. + suboptions: + height: + description: Height of the floor (eg 15). + type: int + length: + description: Length of the floor (eg 100). + type: int + name: + description: Name of the floor (eg floor-1). + type: str + parentName: + description: Parent name of the floor to be created. + type: str + rfModel: + description: Type of floor (eg Cubes And Walled Offices). + type: str + width: + description: Width of the floor (eg 100). + type: int + type: dict + siteProfileName: + description: Name of site profile to be provision with device. + type: str + type: dict + type: list + siteProfile: + description: Nfv Provision's siteProfile. + elements: dict + suboptions: + device: + description: Nfv Provision's device. + elements: dict + suboptions: + customNetworks: + description: Nfv Provision's customNetworks. + elements: dict + suboptions: + connectionType: + description: Type of network connection from custom network (eg lan). + type: str + name: + description: Name of custom network (eg cust-1). + type: str + networkMode: + description: Network mode (eg Access or Trunk). + type: str + servicesToConnect: + description: Nfv Provision's servicesToConnect. + elements: dict + suboptions: + service: + description: Name of service to be connected to the custom network + (eg router-1). + type: str + type: list + vlan: + description: Vlan id for the custom network(eg 4000). + type: str + type: list + customServices: + description: Nfv Provision's customServices. + elements: dict + suboptions: + applicationType: + description: Application type of custom service (eg LINUX). + type: str + imageName: + description: Image name of custom service (eg redhat7.tar.gz.tar.gz). + type: str + name: + description: Name of custom service (eg LINUX-1). + type: str + profile: + description: Profile type of service (eg rhel7-medium). + type: str + topology: + description: Nfv Provision's topology. + suboptions: + assignIp: + description: Assign ip to network (eg true). + type: str + name: + description: Name of connection from custom service(eg wan-net). + type: str + type: + description: Type of connection from custom service (eg wan, lan + or internal). + type: str + type: dict + type: list + customTemplate: + description: Nfv Provision's customTemplate. + elements: dict + suboptions: + deviceType: + description: Type of the device(eg NFVIS). + type: str + template: + description: Name of the template(eg NFVIS template). + type: str + type: list + deviceType: + description: Name of the device used in creating nfv profile(eg ENCS5400). + type: str + dia: + description: Direct internet access value should be boolean (eg false). + type: bool + serviceProviders: + description: Nfv Provision's serviceProviders. + elements: dict + suboptions: + connect: + description: Connection of service provider and device value should + be boolean (eg true). + type: bool + defaultGateway: + description: Default gateway connect value as boolean (eg true). + type: bool + linkType: + description: Name of connection type(eg GigabitEthernet). + type: str + serviceProvider: + description: Name of the service provider(eg Airtel). + type: str + type: list + services: + description: Nfv Provision's services. + elements: dict + suboptions: + imageName: + description: Name of image (eg isrv-universalk9.16.06.02.tar.gz). + type: str + mode: + description: Mode of firewall (eg routed, transparent). + type: str + name: + description: Name of the service (eg isrv). + type: str + profile: + description: Profile type of service (eg ISRv-mini). + type: str + topology: + description: Nfv Provision's topology. + suboptions: + assignIp: + description: Assign ip address to network (eg true). + type: str + name: + description: Name of connection (eg wan-net). + type: str + type: + description: Type of connection (eg wan, lan or internal). + type: str + type: dict + type: + description: Service type (eg ISRV). + type: str + type: list + tagName: + description: Device Tag name(eg dev1). + type: str + vlan: + description: Nfv Provision's vlan. + elements: dict + suboptions: + id: + description: Vlan id(eg.4018). + type: str + type: + description: Vlan type(eg. Access or Trunk). + type: str + type: list + type: list + siteProfileName: + description: Name of the profile to create site profile profile( eg profile-1). + type: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Site Design ProvisionNFV + description: Complete reference of the ProvisionNFV API. + link: https://developer.cisco.com/docs/dna-center/#!provision-nfv +notes: + - SDK Method used are + site_design.SiteDesign.provision_nfv, + + - Paths used are + post /dna/intent/api/v1/business/nfv, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.nfv_provision: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: '{{my_headers | from_json}}' + provisioning: + - device: + - customNetworks: + - ipAddressPool: string + name: string + port: string + deviceSerialNumber: string + ip: string + serviceProviders: + - serviceProvider: string + wanInterface: + bandwidth: string + gateway: string + interfaceName: string + ipAddress: string + subnetmask: string + services: + - adminPasswordHash: string + centralManagerIP: string + centralRegistrationKey: string + commonKey: string + disk: string + mode: string + systemIp: string + type: string + subPools: + - gateway: string + ipSubnet: string + name: string + parentPoolName: string + type: string + tagName: string + templateParam: + asav: + var1: string + nfvis: + var1: string + vlan: + - id: string + interfaces: string + network: string + type: string + site: + area: + name: string + parentName: string + building: + address: string + latitude: 0 + longitude: 0 + name: string + parentName: string + floor: + height: 0 + length: 0 + name: string + parentName: string + rfModel: string + width: 0 + siteProfileName: string + siteProfile: + - device: + - customNetworks: + - connectionType: string + name: string + networkMode: string + servicesToConnect: + - service: string + vlan: string + customServices: + - applicationType: string + imageName: string + name: string + profile: string + topology: + assignIp: string + name: string + type: string + customTemplate: + - deviceType: string + template: string + deviceType: string + dia: true + serviceProviders: + - connect: true + defaultGateway: true + linkType: string + serviceProvider: string + services: + - imageName: string + mode: string + name: string + profile: string + topology: + assignIp: string + name: string + type: string + type: string + tagName: string + vlan: + - id: string + type: string + siteProfileName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/nfv_provision_detail_info.py b/ansible_collections/cisco/dnac/plugins/modules/nfv_provision_detail_info.py new file mode 100644 index 000000000..8ad7287ad --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/nfv_provision_detail_info.py @@ -0,0 +1,91 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: nfv_provision_detail_info +short_description: Information module for Nfv Provision Detail +description: +- Get all Nfv Provision Detail. +- Returns provisioning device information for the specified IP address. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceIp: + description: + - DeviceIp query parameter. Device to which the provisioning detail has to be retrieved. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Site Design GetDeviceDetailsByIP + description: Complete reference of the GetDeviceDetailsByIP API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-details-by-ip +notes: + - SDK Method used are + site_design.SiteDesign.get_device_details_by_ip, + + - Paths used are + get /dna/intent/api/v1/business/nfv/provisioningDetail, + +""" + +EXAMPLES = r""" +- name: Get all Nfv Provision Detail + cisco.dnac.nfv_provision_detail_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceIp: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "startTime": "string", + "endTime": "string", + "duration": "string", + "statusMessage": "string", + "status": "string", + "taskNodes": [ + { + "startTime": "string", + "endTime": "string", + "duration": "string", + "status": "string", + "nextTask": "string", + "name": "string", + "target": "string", + "statusMessage": "string", + "payload": "string", + "provisionedNames": {}, + "errorPayload": {}, + "parentTask": {}, + "cliTemplateUserMessageDTO": {}, + "stepRan": "string" + } + ], + "topology": "string", + "beginStep": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/nfv_provision_details.py b/ansible_collections/cisco/dnac/plugins/modules/nfv_provision_details.py new file mode 100644 index 000000000..6f8bc7308 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/nfv_provision_details.py @@ -0,0 +1,67 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: nfv_provision_details +short_description: Resource module for Nfv Provision Details +description: +- Manage operation create of the resource Nfv Provision Details. +- Checks the provisioning detail of an ENCS device including log information. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + device_ip: + description: Device Ip. + type: str + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Site Design NFVProvisioningDetail + description: Complete reference of the NFVProvisioningDetail API. + link: https://developer.cisco.com/docs/dna-center/#!n-fv-provisioning-detail +notes: + - SDK Method used are + site_design.SiteDesign.nfv_provisioning_detail, + + - Paths used are + post /dna/intent/api/v1/nfv-provision-detail, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.nfv_provision_details: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + device_ip: string + headers: '{{my_headers | from_json}}' + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/path_trace.py b/ansible_collections/cisco/dnac/plugins/modules/path_trace.py new file mode 100644 index 000000000..a2b5519a6 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/path_trace.py @@ -0,0 +1,121 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: path_trace +short_description: Resource module for Path Trace +description: +- Manage operations create and delete of the resource Path Trace. +- > + Initiates a new flow analysis with periodic refresh and stat collection options. Returns a request id and a task + id to get results and follow progress. +- Deletes a flow analysis request by its id. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + controlPath: + description: Control path tracing. + type: bool + destIP: + description: Destination IP address. + type: str + destPort: + description: Destination Port. + type: str + flowAnalysisId: + description: FlowAnalysisId path parameter. Flow analysis request id. + type: str + inclusions: + description: Subset of {INTERFACE-STATS, QOS-STATS, DEVICE-STATS, PERFORMANCE-STATS, + ACL-TRACE}. + elements: str + type: list + periodicRefresh: + description: Periodic refresh of path for every 30 sec. + type: bool + protocol: + description: Protocol. + type: str + sourceIP: + description: Source IP address. + type: str + sourcePort: + description: Source Port. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Path Trace InitiateANewPathtrace + description: Complete reference of the InitiateANewPathtrace API. + link: https://developer.cisco.com/docs/dna-center/#!initiate-a-new-pathtrace +- name: Cisco DNA Center documentation for Path Trace DeletesPathtraceById + description: Complete reference of the DeletesPathtraceById API. + link: https://developer.cisco.com/docs/dna-center/#!deletes-pathtrace-by-id +notes: + - SDK Method used are + path_trace.PathTrace.deletes_pathtrace_by_id, + path_trace.PathTrace.initiate_a_new_pathtrace, + + - Paths used are + post /dna/intent/api/v1/flow-analysis, + delete /dna/intent/api/v1/flow-analysis/{flowAnalysisId}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.path_trace: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + controlPath: true + destIP: string + destPort: string + inclusions: + - string + periodicRefresh: true + protocol: string + sourceIP: string + sourcePort: string + +- name: Delete by id + cisco.dnac.path_trace: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + flowAnalysisId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "flowAnalysisId": "string", + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/path_trace_info.py b/ansible_collections/cisco/dnac/plugins/modules/path_trace_info.py new file mode 100644 index 000000000..a160114ef --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/path_trace_info.py @@ -0,0 +1,1076 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: path_trace_info +short_description: Information module for Path Trace +description: +- Get all Path Trace. +- Get Path Trace by id. +- Returns a summary of all flow analyses stored. Results can be filtered by specified parameters. +- Returns result of a previously requested flow analysis by its Flow Analysis id. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + periodicRefresh: + description: + - PeriodicRefresh query parameter. Is analysis periodically refreshed?. + type: bool + sourceIP: + description: + - SourceIP query parameter. Source IP address. + type: str + destIP: + description: + - DestIP query parameter. Destination IP adress. + type: str + sourcePort: + description: + - SourcePort query parameter. Source port. + type: str + destPort: + description: + - DestPort query parameter. Destination port. + type: str + gtCreateTime: + description: + - GtCreateTime query parameter. Analyses requested after this time. + type: str + ltCreateTime: + description: + - LtCreateTime query parameter. Analyses requested before this time. + type: str + protocol: + description: + - Protocol query parameter. + type: str + status: + description: + - Status query parameter. + type: str + taskId: + description: + - TaskId query parameter. Task ID. + type: str + lastUpdateTime: + description: + - LastUpdateTime query parameter. Last update time. + type: str + limit: + description: + - Limit query parameter. Number of resources returned. + type: int + offset: + description: + - Offset query parameter. Start index of resources returned (1-based). + type: int + order: + description: + - Order query parameter. Order by this field. + type: str + sortBy: + description: + - SortBy query parameter. Sort by this field. + type: str + flowAnalysisId: + description: + - FlowAnalysisId path parameter. Flow analysis request id. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Path Trace RetrievesPreviousPathtrace + description: Complete reference of the RetrievesPreviousPathtrace API. + link: https://developer.cisco.com/docs/dna-center/#!retrieves-previous-pathtrace +- name: Cisco DNA Center documentation for Path Trace RetrivesAllPreviousPathtracesSummary + description: Complete reference of the RetrivesAllPreviousPathtracesSummary API. + link: https://developer.cisco.com/docs/dna-center/#!retrives-all-previous-pathtraces-summary +notes: + - SDK Method used are + path_trace.PathTrace.retrieves_previous_pathtrace, + path_trace.PathTrace.retrives_all_previous_pathtraces_summary, + + - Paths used are + get /dna/intent/api/v1/flow-analysis, + get /dna/intent/api/v1/flow-analysis/{flowAnalysisId}, + +""" + +EXAMPLES = r""" +- name: Get all Path Trace + cisco.dnac.path_trace_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + periodicRefresh: True + sourceIP: string + destIP: string + sourcePort: string + destPort: string + gtCreateTime: string + ltCreateTime: string + protocol: string + status: string + taskId: string + lastUpdateTime: string + limit: 0 + offset: 0 + order: string + sortBy: string + register: result + +- name: Get Path Trace by id + cisco.dnac.path_trace_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + flowAnalysisId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "detailedStatus": { + "aclTraceCalculation": "string", + "aclTraceCalculationFailureReason": "string" + }, + "lastUpdate": "string", + "networkElements": [ + { + "accuracyList": [ + { + "percent": 0, + "reason": "string" + } + ], + "detailedStatus": { + "aclTraceCalculation": "string", + "aclTraceCalculationFailureReason": "string" + }, + "deviceStatistics": { + "cpuStatistics": { + "fiveMinUsageInPercentage": 0, + "fiveSecsUsageInPercentage": 0, + "oneMinUsageInPercentage": 0, + "refreshedAt": 0 + }, + "memoryStatistics": { + "memoryUsage": 0, + "refreshedAt": 0, + "totalMemory": 0 + } + }, + "deviceStatsCollection": "string", + "deviceStatsCollectionFailureReason": "string", + "egressPhysicalInterface": { + "aclAnalysis": { + "aclName": "string", + "matchingAces": [ + { + "ace": "string", + "matchingPorts": [ + { + "ports": [ + { + "destPorts": [ + "string" + ], + "sourcePorts": [ + "string" + ] + } + ], + "protocol": "string" + } + ], + "result": "string" + } + ], + "result": "string" + }, + "id": "string", + "interfaceStatistics": { + "adminStatus": "string", + "inputPackets": 0, + "inputQueueCount": 0, + "inputQueueDrops": 0, + "inputQueueFlushes": 0, + "inputQueueMaxDepth": 0, + "inputRatebps": 0, + "operationalStatus": "string", + "outputDrop": 0, + "outputPackets": 0, + "outputQueueCount": 0, + "outputQueueDepth": 0, + "outputRatebps": 0, + "refreshedAt": 0 + }, + "interfaceStatsCollection": "string", + "interfaceStatsCollectionFailureReason": "string", + "name": "string", + "pathOverlayInfo": [ + { + "controlPlane": "string", + "dataPacketEncapsulation": "string", + "destIp": "string", + "destPort": "string", + "protocol": "string", + "sourceIp": "string", + "sourcePort": "string", + "vxlanInfo": { + "dscp": "string", + "vnid": "string" + } + } + ], + "qosStatistics": [ + { + "classMapName": "string", + "dropRate": 0, + "numBytes": 0, + "numPackets": 0, + "offeredRate": 0, + "queueBandwidthbps": "string", + "queueDepth": 0, + "queueNoBufferDrops": 0, + "queueTotalDrops": 0, + "refreshedAt": 0 + } + ], + "qosStatsCollection": "string", + "qosStatsCollectionFailureReason": "string", + "usedVlan": "string", + "vrfName": "string" + }, + "egressVirtualInterface": { + "aclAnalysis": { + "aclName": "string", + "matchingAces": [ + { + "ace": "string", + "matchingPorts": [ + { + "ports": [ + { + "destPorts": [ + "string" + ], + "sourcePorts": [ + "string" + ] + } + ], + "protocol": "string" + } + ], + "result": "string" + } + ], + "result": "string" + }, + "id": "string", + "interfaceStatistics": { + "adminStatus": "string", + "inputPackets": 0, + "inputQueueCount": 0, + "inputQueueDrops": 0, + "inputQueueFlushes": 0, + "inputQueueMaxDepth": 0, + "inputRatebps": 0, + "operationalStatus": "string", + "outputDrop": 0, + "outputPackets": 0, + "outputQueueCount": 0, + "outputQueueDepth": 0, + "outputRatebps": 0, + "refreshedAt": 0 + }, + "interfaceStatsCollection": "string", + "interfaceStatsCollectionFailureReason": "string", + "name": "string", + "pathOverlayInfo": [ + { + "controlPlane": "string", + "dataPacketEncapsulation": "string", + "destIp": "string", + "destPort": "string", + "protocol": "string", + "sourceIp": "string", + "sourcePort": "string", + "vxlanInfo": { + "dscp": "string", + "vnid": "string" + } + } + ], + "qosStatistics": [ + { + "classMapName": "string", + "dropRate": 0, + "numBytes": 0, + "numPackets": 0, + "offeredRate": 0, + "queueBandwidthbps": "string", + "queueDepth": 0, + "queueNoBufferDrops": 0, + "queueTotalDrops": 0, + "refreshedAt": 0 + } + ], + "qosStatsCollection": "string", + "qosStatsCollectionFailureReason": "string", + "usedVlan": "string", + "vrfName": "string" + }, + "flexConnect": { + "authentication": "string", + "dataSwitching": "string", + "egressAclAnalysis": { + "aclName": "string", + "matchingAces": [ + { + "ace": "string", + "matchingPorts": [ + { + "ports": [ + { + "destPorts": [ + "string" + ], + "sourcePorts": [ + "string" + ] + } + ], + "protocol": "string" + } + ], + "result": "string" + } + ], + "result": "string" + }, + "ingressAclAnalysis": { + "aclName": "string", + "matchingAces": [ + { + "ace": "string", + "matchingPorts": [ + { + "ports": [ + { + "destPorts": [ + "string" + ], + "sourcePorts": [ + "string" + ] + } + ], + "protocol": "string" + } + ], + "result": "string" + } + ], + "result": "string" + }, + "wirelessLanControllerId": "string", + "wirelessLanControllerName": "string" + }, + "id": "string", + "ingressPhysicalInterface": { + "aclAnalysis": { + "aclName": "string", + "matchingAces": [ + { + "ace": "string", + "matchingPorts": [ + { + "ports": [ + { + "destPorts": [ + "string" + ], + "sourcePorts": [ + "string" + ] + } + ], + "protocol": "string" + } + ], + "result": "string" + } + ], + "result": "string" + }, + "id": "string", + "interfaceStatistics": { + "adminStatus": "string", + "inputPackets": 0, + "inputQueueCount": 0, + "inputQueueDrops": 0, + "inputQueueFlushes": 0, + "inputQueueMaxDepth": 0, + "inputRatebps": 0, + "operationalStatus": "string", + "outputDrop": 0, + "outputPackets": 0, + "outputQueueCount": 0, + "outputQueueDepth": 0, + "outputRatebps": 0, + "refreshedAt": 0 + }, + "interfaceStatsCollection": "string", + "interfaceStatsCollectionFailureReason": "string", + "name": "string", + "pathOverlayInfo": [ + { + "controlPlane": "string", + "dataPacketEncapsulation": "string", + "destIp": "string", + "destPort": "string", + "protocol": "string", + "sourceIp": "string", + "sourcePort": "string", + "vxlanInfo": { + "dscp": "string", + "vnid": "string" + } + } + ], + "qosStatistics": [ + { + "classMapName": "string", + "dropRate": 0, + "numBytes": 0, + "numPackets": 0, + "offeredRate": 0, + "queueBandwidthbps": "string", + "queueDepth": 0, + "queueNoBufferDrops": 0, + "queueTotalDrops": 0, + "refreshedAt": 0 + } + ], + "qosStatsCollection": "string", + "qosStatsCollectionFailureReason": "string", + "usedVlan": "string", + "vrfName": "string" + }, + "ingressVirtualInterface": { + "aclAnalysis": { + "aclName": "string", + "matchingAces": [ + { + "ace": "string", + "matchingPorts": [ + { + "ports": [ + { + "destPorts": [ + "string" + ], + "sourcePorts": [ + "string" + ] + } + ], + "protocol": "string" + } + ], + "result": "string" + } + ], + "result": "string" + }, + "id": "string", + "interfaceStatistics": { + "adminStatus": "string", + "inputPackets": 0, + "inputQueueCount": 0, + "inputQueueDrops": 0, + "inputQueueFlushes": 0, + "inputQueueMaxDepth": 0, + "inputRatebps": 0, + "operationalStatus": "string", + "outputDrop": 0, + "outputPackets": 0, + "outputQueueCount": 0, + "outputQueueDepth": 0, + "outputRatebps": 0, + "refreshedAt": 0 + }, + "interfaceStatsCollection": "string", + "interfaceStatsCollectionFailureReason": "string", + "name": "string", + "pathOverlayInfo": [ + { + "controlPlane": "string", + "dataPacketEncapsulation": "string", + "destIp": "string", + "destPort": "string", + "protocol": "string", + "sourceIp": "string", + "sourcePort": "string", + "vxlanInfo": { + "dscp": "string", + "vnid": "string" + } + } + ], + "qosStatistics": [ + { + "classMapName": "string", + "dropRate": 0, + "numBytes": 0, + "numPackets": 0, + "offeredRate": 0, + "queueBandwidthbps": "string", + "queueDepth": 0, + "queueNoBufferDrops": 0, + "queueTotalDrops": 0, + "refreshedAt": 0 + } + ], + "qosStatsCollection": "string", + "qosStatsCollectionFailureReason": "string", + "usedVlan": "string", + "vrfName": "string" + }, + "ip": "string", + "linkInformationSource": "string", + "name": "string", + "perfMonCollection": "string", + "perfMonCollectionFailureReason": "string", + "perfMonStatistics": [ + { + "byteRate": 0, + "destIpAddress": "string", + "destPort": "string", + "inputInterface": "string", + "ipv4DSCP": "string", + "ipv4TTL": 0, + "outputInterface": "string", + "packetBytes": 0, + "packetCount": 0, + "packetLoss": 0, + "packetLossPercentage": 0, + "protocol": "string", + "refreshedAt": 0, + "rtpJitterMax": 0, + "rtpJitterMean": 0, + "rtpJitterMin": 0, + "sourceIpAddress": "string", + "sourcePort": "string" + } + ], + "role": "string", + "ssid": "string", + "tunnels": [ + "string" + ], + "type": "string", + "wlanId": "string" + } + ], + "networkElementsInfo": [ + { + "accuracyList": [ + { + "percent": 0, + "reason": "string" + } + ], + "detailedStatus": { + "aclTraceCalculation": "string", + "aclTraceCalculationFailureReason": "string" + }, + "deviceStatistics": { + "cpuStatistics": { + "fiveMinUsageInPercentage": 0, + "fiveSecsUsageInPercentage": 0, + "oneMinUsageInPercentage": 0, + "refreshedAt": 0 + }, + "memoryStatistics": { + "memoryUsage": 0, + "refreshedAt": 0, + "totalMemory": 0 + } + }, + "deviceStatsCollection": "string", + "deviceStatsCollectionFailureReason": "string", + "egressInterface": { + "physicalInterface": { + "aclAnalysis": { + "aclName": "string", + "matchingAces": [ + { + "ace": "string", + "matchingPorts": [ + { + "ports": [ + { + "destPorts": [ + "string" + ], + "sourcePorts": [ + "string" + ] + } + ], + "protocol": "string" + } + ], + "result": "string" + } + ], + "result": "string" + }, + "id": "string", + "interfaceStatistics": { + "adminStatus": "string", + "inputPackets": 0, + "inputQueueCount": 0, + "inputQueueDrops": 0, + "inputQueueFlushes": 0, + "inputQueueMaxDepth": 0, + "inputRatebps": 0, + "operationalStatus": "string", + "outputDrop": 0, + "outputPackets": 0, + "outputQueueCount": 0, + "outputQueueDepth": 0, + "outputRatebps": 0, + "refreshedAt": 0 + }, + "interfaceStatsCollection": "string", + "interfaceStatsCollectionFailureReason": "string", + "name": "string", + "pathOverlayInfo": [ + { + "controlPlane": "string", + "dataPacketEncapsulation": "string", + "destIp": "string", + "destPort": "string", + "protocol": "string", + "sourceIp": "string", + "sourcePort": "string", + "vxlanInfo": { + "dscp": "string", + "vnid": "string" + } + } + ], + "qosStatistics": [ + { + "classMapName": "string", + "dropRate": 0, + "numBytes": 0, + "numPackets": 0, + "offeredRate": 0, + "queueBandwidthbps": "string", + "queueDepth": 0, + "queueNoBufferDrops": 0, + "queueTotalDrops": 0, + "refreshedAt": 0 + } + ], + "qosStatsCollection": "string", + "qosStatsCollectionFailureReason": "string", + "usedVlan": "string", + "vrfName": "string" + }, + "virtualInterface": [ + { + "aclAnalysis": { + "aclName": "string", + "matchingAces": [ + { + "ace": "string", + "matchingPorts": [ + { + "ports": [ + { + "destPorts": [ + "string" + ], + "sourcePorts": [ + "string" + ] + } + ], + "protocol": "string" + } + ], + "result": "string" + } + ], + "result": "string" + }, + "id": "string", + "interfaceStatistics": { + "adminStatus": "string", + "inputPackets": 0, + "inputQueueCount": 0, + "inputQueueDrops": 0, + "inputQueueFlushes": 0, + "inputQueueMaxDepth": 0, + "inputRatebps": 0, + "operationalStatus": "string", + "outputDrop": 0, + "outputPackets": 0, + "outputQueueCount": 0, + "outputQueueDepth": 0, + "outputRatebps": 0, + "refreshedAt": 0 + }, + "interfaceStatsCollection": "string", + "interfaceStatsCollectionFailureReason": "string", + "name": "string", + "pathOverlayInfo": [ + { + "controlPlane": "string", + "dataPacketEncapsulation": "string", + "destIp": "string", + "destPort": "string", + "protocol": "string", + "sourceIp": "string", + "sourcePort": "string", + "vxlanInfo": { + "dscp": "string", + "vnid": "string" + } + } + ], + "qosStatistics": [ + { + "classMapName": "string", + "dropRate": 0, + "numBytes": 0, + "numPackets": 0, + "offeredRate": 0, + "queueBandwidthbps": "string", + "queueDepth": 0, + "queueNoBufferDrops": 0, + "queueTotalDrops": 0, + "refreshedAt": 0 + } + ], + "qosStatsCollection": "string", + "qosStatsCollectionFailureReason": "string", + "usedVlan": "string", + "vrfName": "string" + } + ] + }, + "flexConnect": { + "authentication": "string", + "dataSwitching": "string", + "egressAclAnalysis": { + "aclName": "string", + "matchingAces": [ + { + "ace": "string", + "matchingPorts": [ + { + "ports": [ + { + "destPorts": [ + "string" + ], + "sourcePorts": [ + "string" + ] + } + ], + "protocol": "string" + } + ], + "result": "string" + } + ], + "result": "string" + }, + "ingressAclAnalysis": { + "aclName": "string", + "matchingAces": [ + { + "ace": "string", + "matchingPorts": [ + { + "ports": [ + { + "destPorts": [ + "string" + ], + "sourcePorts": [ + "string" + ] + } + ], + "protocol": "string" + } + ], + "result": "string" + } + ], + "result": "string" + }, + "wirelessLanControllerId": "string", + "wirelessLanControllerName": "string" + }, + "id": "string", + "ingressInterface": { + "physicalInterface": { + "aclAnalysis": { + "aclName": "string", + "matchingAces": [ + { + "ace": "string", + "matchingPorts": [ + { + "ports": [ + { + "destPorts": [ + "string" + ], + "sourcePorts": [ + "string" + ] + } + ], + "protocol": "string" + } + ], + "result": "string" + } + ], + "result": "string" + }, + "id": "string", + "interfaceStatistics": { + "adminStatus": "string", + "inputPackets": 0, + "inputQueueCount": 0, + "inputQueueDrops": 0, + "inputQueueFlushes": 0, + "inputQueueMaxDepth": 0, + "inputRatebps": 0, + "operationalStatus": "string", + "outputDrop": 0, + "outputPackets": 0, + "outputQueueCount": 0, + "outputQueueDepth": 0, + "outputRatebps": 0, + "refreshedAt": 0 + }, + "interfaceStatsCollection": "string", + "interfaceStatsCollectionFailureReason": "string", + "name": "string", + "pathOverlayInfo": [ + { + "controlPlane": "string", + "dataPacketEncapsulation": "string", + "destIp": "string", + "destPort": "string", + "protocol": "string", + "sourceIp": "string", + "sourcePort": "string", + "vxlanInfo": { + "dscp": "string", + "vnid": "string" + } + } + ], + "qosStatistics": [ + { + "classMapName": "string", + "dropRate": 0, + "numBytes": 0, + "numPackets": 0, + "offeredRate": 0, + "queueBandwidthbps": "string", + "queueDepth": 0, + "queueNoBufferDrops": 0, + "queueTotalDrops": 0, + "refreshedAt": 0 + } + ], + "qosStatsCollection": "string", + "qosStatsCollectionFailureReason": "string", + "usedVlan": "string", + "vrfName": "string" + }, + "virtualInterface": [ + { + "aclAnalysis": { + "aclName": "string", + "matchingAces": [ + { + "ace": "string", + "matchingPorts": [ + { + "ports": [ + { + "destPorts": [ + "string" + ], + "sourcePorts": [ + "string" + ] + } + ], + "protocol": "string" + } + ], + "result": "string" + } + ], + "result": "string" + }, + "id": "string", + "interfaceStatistics": { + "adminStatus": "string", + "inputPackets": 0, + "inputQueueCount": 0, + "inputQueueDrops": 0, + "inputQueueFlushes": 0, + "inputQueueMaxDepth": 0, + "inputRatebps": 0, + "operationalStatus": "string", + "outputDrop": 0, + "outputPackets": 0, + "outputQueueCount": 0, + "outputQueueDepth": 0, + "outputRatebps": 0, + "refreshedAt": 0 + }, + "interfaceStatsCollection": "string", + "interfaceStatsCollectionFailureReason": "string", + "name": "string", + "pathOverlayInfo": [ + { + "controlPlane": "string", + "dataPacketEncapsulation": "string", + "destIp": "string", + "destPort": "string", + "protocol": "string", + "sourceIp": "string", + "sourcePort": "string", + "vxlanInfo": { + "dscp": "string", + "vnid": "string" + } + } + ], + "qosStatistics": [ + { + "classMapName": "string", + "dropRate": 0, + "numBytes": 0, + "numPackets": 0, + "offeredRate": 0, + "queueBandwidthbps": "string", + "queueDepth": 0, + "queueNoBufferDrops": 0, + "queueTotalDrops": 0, + "refreshedAt": 0 + } + ], + "qosStatsCollection": "string", + "qosStatsCollectionFailureReason": "string", + "usedVlan": "string", + "vrfName": "string" + } + ] + }, + "ip": "string", + "linkInformationSource": "string", + "name": "string", + "perfMonCollection": "string", + "perfMonCollectionFailureReason": "string", + "perfMonitorStatistics": [ + { + "byteRate": 0, + "destIpAddress": "string", + "destPort": "string", + "inputInterface": "string", + "ipv4DSCP": "string", + "ipv4TTL": 0, + "outputInterface": "string", + "packetBytes": 0, + "packetCount": 0, + "packetLoss": 0, + "packetLossPercentage": 0, + "protocol": "string", + "refreshedAt": 0, + "rtpJitterMax": 0, + "rtpJitterMean": 0, + "rtpJitterMin": 0, + "sourceIpAddress": "string", + "sourcePort": "string" + } + ], + "role": "string", + "ssid": "string", + "tunnels": [ + "string" + ], + "type": "string", + "wlanId": "string" + } + ], + "properties": [ + "string" + ], + "request": { + "controlPath": true, + "createTime": 0, + "destIP": "string", + "destPort": "string", + "failureReason": "string", + "id": "string", + "inclusions": [ + "string" + ], + "lastUpdateTime": 0, + "periodicRefresh": true, + "protocol": "string", + "sourceIP": "string", + "sourcePort": "string", + "status": "string" + } + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/planned_access_points_info.py b/ansible_collections/cisco/dnac/plugins/modules/planned_access_points_info.py new file mode 100644 index 000000000..df323c577 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/planned_access_points_info.py @@ -0,0 +1,129 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: planned_access_points_info +short_description: Information module for Planned Access Points +description: +- Get all Planned Access Points. +- Provides a list of Planned Access Points for the Floor it is requested for. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + floorId: + description: + - FloorId path parameter. Floor Id. + type: str + limit: + description: + - Limit query parameter. + type: int + offset: + description: + - Offset query parameter. + type: int + radios: + description: + - Radios query parameter. Inlcude planned radio details. + type: bool +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Devices GetPlannedAccessPointsForFloor + description: Complete reference of the GetPlannedAccessPointsForFloor API. + link: https://developer.cisco.com/docs/dna-center/#!get-planned-access-points-for-floor +notes: + - SDK Method used are + devices.Devices.get_planned_access_points_for_floor, + + - Paths used are + get /dna/intent/api/v1/floors/{floorId}/planned-access-points, + +""" + +EXAMPLES = r""" +- name: Get all Planned Access Points + cisco.dnac.planned_access_points_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + limit: 0 + offset: 0 + radios: True + floorId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "attributes": { + "id": 0, + "instanceUuid": "string", + "name": "string", + "typeString": "string", + "domain": "string", + "heirarchyName": "string", + "source": "string", + "createDate": 0, + "macaddress": {} + }, + "location": {}, + "position": { + "x": 0, + "y": 0, + "z": 0 + }, + "radioCount": 0, + "radios": [ + { + "attributes": { + "id": 0, + "instanceUuid": "string", + "slotId": 0, + "ifTypeString": "string", + "ifTypeSubband": "string", + "channel": {}, + "channelString": {}, + "ifMode": "string" + }, + "antenna": { + "name": "string", + "type": "string", + "mode": "string", + "azimuthAngle": 0, + "elevationAngle": 0, + "gain": 0 + }, + "isSensor": true + } + ], + "isSensor": true + } + ], + "version": 0, + "total": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/platform_nodes_configuration_summary_info.py b/ansible_collections/cisco/dnac/plugins/modules/platform_nodes_configuration_summary_info.py new file mode 100644 index 000000000..9e4bad79e --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/platform_nodes_configuration_summary_info.py @@ -0,0 +1,118 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: platform_nodes_configuration_summary_info +short_description: Information module for Platform Nodes Configuration Summary +description: +- Get all Platform Nodes Configuration Summary. +- > + Provides details about the current Cisco DNA Center node configuration, such as API version, node name, NTP + server, intracluster link, LACP mode, network static routes, DNS server, subnet mask, host IP, default gateway, + and interface information. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Platform Configuration CiscoDNACenterNodesConfigurationSummary + description: Complete reference of the CiscoDNACenterNodesConfigurationSummary API. + link: https://developer.cisco.com/docs/dna-center/#!cisco-dna-center-nodes-configuration-summary +notes: + - SDK Method used are + platform_configuration.PlatformConfiguration.nodes_configuration_summary, + + - Paths used are + get /dna/intent/api/v1/nodes-config, + +""" + +EXAMPLES = r""" +- name: Get all Platform Nodes Configuration Summary + cisco.dnac.platform_nodes_configuration_summary_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": { + "nodes": [ + { + "ntp": { + "servers": [ + "string" + ] + }, + "network": [ + { + "intra_cluster_link": true, + "lacp_mode": true, + "inet": { + "routes": [ + {} + ], + "gateway": "string", + "dns_servers": [ + {} + ], + "netmask": "string", + "host_ip": "string" + }, + "interface": "string", + "inet6": { + "host_ip": "string", + "netmask": "string" + }, + "lacp_supported": true, + "slave": [ + "string" + ] + } + ], + "proxy": { + "https_proxy": "string", + "no_proxy": [ + "string" + ], + "https_proxy_username": "string", + "http_proxy": "string", + "https_proxy_password": "string" + }, + "platform": { + "vendor": "string", + "product": "string", + "serial": "string" + }, + "id": "string", + "name": "string" + } + ] + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/platform_release_summary_info.py b/ansible_collections/cisco/dnac/plugins/modules/platform_release_summary_info.py new file mode 100644 index 000000000..7af697e95 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/platform_release_summary_info.py @@ -0,0 +1,79 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: platform_release_summary_info +short_description: Information module for Platform Release Summary +description: +- Get all Platform Release Summary. +- > + Provides information such as API version, mandatory core packages for installation or upgrade, optional packages, + Cisco DNA Center name and version, supported direct updates, and tenant ID. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Platform Configuration CiscoDNACenterReleaseSummary + description: Complete reference of the CiscoDNACenterReleaseSummary API. + link: https://developer.cisco.com/docs/dna-center/#!cisco-dna-center-release-summary +notes: + - SDK Method used are + platform_configuration.PlatformConfiguration.release_summary, + + - Paths used are + get /dna/intent/api/v1/dnac-release, + +""" + +EXAMPLES = r""" +- name: Get all Platform Release Summary + cisco.dnac.platform_release_summary_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": { + "corePackages": [ + "string" + ], + "packages": [ + "string" + ], + "name": "string", + "installedVersion": "string", + "systemVersion": "string", + "supportedDirectUpdates": [ + {} + ], + "tenantId": "string" + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_device.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_device.py new file mode 100644 index 000000000..0f6a736a5 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_device.py @@ -0,0 +1,1747 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_device +short_description: Resource module for Pnp Device +description: +- Manage operations create, update and delete of the resource Pnp Device. +- Adds a device to the PnP database. +- Deletes specified device from PnP database. +- Updates device details specified by device id in PnP database. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + _id: + description: Pnp Device's _id. + type: str + deviceInfo: + description: Pnp Device's deviceInfo. + suboptions: + aaaCredentials: + description: Pnp Device's aaaCredentials. + suboptions: + password: + description: Pnp Device's password. + type: str + username: + description: Pnp Device's username. + type: str + type: dict + addedOn: + description: Pnp Device's addedOn. + type: int + addnMacAddrs: + description: Pnp Device's addnMacAddrs. + elements: str + type: list + agentType: + description: Pnp Device's agentType. + type: str + authStatus: + description: Pnp Device's authStatus. + type: str + authenticatedSudiSerialNo: + description: Pnp Device's authenticatedSudiSerialNo. + type: str + capabilitiesSupported: + description: Pnp Device's capabilitiesSupported. + elements: str + type: list + cmState: + description: Pnp Device's cmState. + type: str + description: + description: Pnp Device's description. + type: str + deviceSudiSerialNos: + description: Pnp Device's deviceSudiSerialNos. + elements: str + type: list + deviceType: + description: Pnp Device's deviceType. + type: str + featuresSupported: + description: Pnp Device's featuresSupported. + elements: str + type: list + fileSystemList: + description: Pnp Device's fileSystemList. + elements: dict + suboptions: + freespace: + description: Pnp Device's freespace. + type: int + name: + description: Pnp Device's name. + type: str + readable: + description: Readable flag. + type: bool + size: + description: Pnp Device's size. + type: int + type: + description: Pnp Device's type. + type: str + writeable: + description: Writeable flag. + type: bool + type: list + firstContact: + description: Pnp Device's firstContact. + type: int + hostname: + description: Pnp Device's hostname. + type: str + httpHeaders: + description: Pnp Device's httpHeaders. + elements: dict + suboptions: + key: + description: Pnp Device's key. + type: str + value: + description: Pnp Device's value. + type: str + type: list + imageFile: + description: Pnp Device's imageFile. + type: str + imageVersion: + description: Pnp Device's imageVersion. + type: str + ipInterfaces: + description: Pnp Device's ipInterfaces. + elements: dict + suboptions: + ipv4Address: + description: Pnp Device's ipv4Address. + type: dict + ipv6AddressList: + description: Pnp Device's ipv6AddressList. + elements: dict + type: list + macAddress: + description: Pnp Device's macAddress. + type: str + name: + description: Pnp Device's name. + type: str + status: + description: Pnp Device's status. + type: str + type: list + lastContact: + description: Pnp Device's lastContact. + type: int + lastSyncTime: + description: Pnp Device's lastSyncTime. + type: int + lastUpdateOn: + description: Pnp Device's lastUpdateOn. + type: int + location: + description: Pnp Device's location. + suboptions: + address: + description: Pnp Device's address. + type: str + altitude: + description: Pnp Device's altitude. + type: str + latitude: + description: Pnp Device's latitude. + type: str + longitude: + description: Pnp Device's longitude. + type: str + siteId: + description: Pnp Device's siteId. + type: str + type: dict + macAddress: + description: Pnp Device's macAddress. + type: str + mode: + description: Pnp Device's mode. + type: str + name: + description: Pnp Device's name. + type: str + neighborLinks: + description: Pnp Device's neighborLinks. + elements: dict + suboptions: + localInterfaceName: + description: Pnp Device's localInterfaceName. + type: str + localMacAddress: + description: Pnp Device's localMacAddress. + type: str + localShortInterfaceName: + description: Pnp Device's localShortInterfaceName. + type: str + remoteDeviceName: + description: Pnp Device's remoteDeviceName. + type: str + remoteInterfaceName: + description: Pnp Device's remoteInterfaceName. + type: str + remoteMacAddress: + description: Pnp Device's remoteMacAddress. + type: str + remotePlatform: + description: Pnp Device's remotePlatform. + type: str + remoteShortInterfaceName: + description: Pnp Device's remoteShortInterfaceName. + type: str + remoteVersion: + description: Pnp Device's remoteVersion. + type: str + type: list + onbState: + description: Pnp Device's onbState. + type: str + pid: + description: Pnp Device's pid. + type: str + pnpProfileList: + description: Pnp Device's pnpProfileList. + elements: dict + suboptions: + createdBy: + description: Pnp Device's createdBy. + type: str + discoveryCreated: + description: DiscoveryCreated flag. + type: bool + primaryEndpoint: + description: Pnp Device's primaryEndpoint. + suboptions: + certificate: + description: Pnp Device's certificate. + type: str + fqdn: + description: Pnp Device's fqdn. + type: str + ipv4Address: + description: Pnp Device's ipv4Address. + type: dict + ipv6Address: + description: Pnp Device's ipv6Address. + type: dict + port: + description: Pnp Device's port. + type: int + protocol: + description: Pnp Device's protocol. + type: str + type: dict + profileName: + description: Pnp Device's profileName. + type: str + secondaryEndpoint: + description: Pnp Device's secondaryEndpoint. + suboptions: + certificate: + description: Pnp Device's certificate. + type: str + fqdn: + description: Pnp Device's fqdn. + type: str + ipv4Address: + description: Pnp Device's ipv4Address. + type: dict + ipv6Address: + description: Pnp Device's ipv6Address. + type: dict + port: + description: Pnp Device's port. + type: int + protocol: + description: Pnp Device's protocol. + type: str + type: dict + type: list + populateInventory: + description: PopulateInventory flag. + type: bool + preWorkflowCliOuputs: + description: Pnp Device's preWorkflowCliOuputs. + elements: dict + suboptions: + cli: + description: Pnp Device's cli. + type: str + cliOutput: + description: Pnp Device's cliOutput. + type: str + type: list + projectId: + description: Pnp Device's projectId. + type: str + projectName: + description: Pnp Device's projectName. + type: str + reloadRequested: + description: ReloadRequested flag. + type: bool + serialNumber: + description: Pnp Device's serialNumber. + type: str + smartAccountId: + description: Pnp Device's smartAccountId. + type: str + source: + description: Pnp Device's source. + type: str + stack: + description: Stack flag. + type: bool + stackInfo: + description: Pnp Device's stackInfo. + suboptions: + isFullRing: + description: IsFullRing flag. + type: bool + stackMemberList: + description: Pnp Device's stackMemberList. + elements: dict + suboptions: + hardwareVersion: + description: Pnp Device's hardwareVersion. + type: str + licenseLevel: + description: Pnp Device's licenseLevel. + type: str + licenseType: + description: Pnp Device's licenseType. + type: str + macAddress: + description: Pnp Device's macAddress. + type: str + pid: + description: Pnp Device's pid. + type: str + priority: + description: Pnp Device's priority. + type: int + role: + description: Pnp Device's role. + type: str + serialNumber: + description: Pnp Device's serialNumber. + type: str + softwareVersion: + description: Pnp Device's softwareVersion. + type: str + stackNumber: + description: Pnp Device's stackNumber. + type: int + state: + description: Pnp Device's state. + type: str + sudiSerialNumber: + description: Pnp Device's sudiSerialNumber. + type: str + type: list + stackRingProtocol: + description: Pnp Device's stackRingProtocol. + type: str + supportsStackWorkflows: + description: SupportsStackWorkflows flag. + type: bool + totalMemberCount: + description: Pnp Device's totalMemberCount. + type: int + validLicenseLevels: + description: Pnp Device's validLicenseLevels. + elements: str + type: list + type: dict + state: + description: Pnp Device's state. + type: str + sudiRequired: + description: SudiRequired flag. + type: bool + tags: + description: Pnp Device's tags. + type: dict + userSudiSerialNos: + description: Pnp Device's userSudiSerialNos. + elements: str + type: list + virtualAccountId: + description: Pnp Device's virtualAccountId. + type: str + workflowId: + description: Pnp Device's workflowId. + type: str + workflowName: + description: Pnp Device's workflowName. + type: str + type: dict + id: + description: Id path parameter. + type: str + runSummaryList: + description: Pnp Device's runSummaryList. + elements: dict + suboptions: + details: + description: Pnp Device's details. + type: str + errorFlag: + description: ErrorFlag flag. + type: bool + historyTaskInfo: + description: Pnp Device's historyTaskInfo. + suboptions: + addnDetails: + description: Pnp Device's addnDetails. + elements: dict + suboptions: + key: + description: Pnp Device's key. + type: str + value: + description: Pnp Device's value. + type: str + type: list + name: + description: Pnp Device's name. + type: str + timeTaken: + description: Pnp Device's timeTaken. + type: int + type: + description: Pnp Device's type. + type: str + workItemList: + description: Pnp Device's workItemList. + elements: dict + suboptions: + command: + description: Pnp Device's command. + type: str + endTime: + description: Pnp Device's endTime. + type: int + outputStr: + description: Pnp Device's outputStr. + type: str + startTime: + description: Pnp Device's startTime. + type: int + state: + description: Pnp Device's state. + type: str + timeTaken: + description: Pnp Device's timeTaken. + type: int + type: list + type: dict + timestamp: + description: Pnp Device's timestamp. + type: int + type: list + systemResetWorkflow: + description: Pnp Device's systemResetWorkflow. + suboptions: + _id: + description: Pnp Device's _id. + type: str + addToInventory: + description: AddToInventory flag. + type: bool + addedOn: + description: Pnp Device's addedOn. + type: int + configId: + description: Pnp Device's configId. + type: str + currTaskIdx: + description: Pnp Device's currTaskIdx. + type: int + description: + description: Pnp Device's description. + type: str + endTime: + description: Pnp Device's endTime. + type: int + execTime: + description: Pnp Device's execTime. + type: int + imageId: + description: Pnp Device's imageId. + type: str + instanceType: + description: Pnp Device's instanceType. + type: str + lastupdateOn: + description: Pnp Device's lastupdateOn. + type: int + name: + description: Pnp Device's name. + type: str + startTime: + description: Pnp Device's startTime. + type: int + state: + description: Pnp Device's state. + type: str + tasks: + description: Pnp Device's tasks. + elements: dict + suboptions: + currWorkItemIdx: + description: Pnp Device's currWorkItemIdx. + type: int + endTime: + description: Pnp Device's endTime. + type: int + name: + description: Pnp Device's name. + type: str + startTime: + description: Pnp Device's startTime. + type: int + state: + description: Pnp Device's state. + type: str + taskSeqNo: + description: Pnp Device's taskSeqNo. + type: int + timeTaken: + description: Pnp Device's timeTaken. + type: int + type: + description: Pnp Device's type. + type: str + workItemList: + description: Pnp Device's workItemList. + elements: dict + suboptions: + command: + description: Pnp Device's command. + type: str + endTime: + description: Pnp Device's endTime. + type: int + outputStr: + description: Pnp Device's outputStr. + type: str + startTime: + description: Pnp Device's startTime. + type: int + state: + description: Pnp Device's state. + type: str + timeTaken: + description: Pnp Device's timeTaken. + type: int + type: list + type: list + tenantId: + description: Pnp Device's tenantId. + type: str + type: + description: Pnp Device's type. + type: str + useState: + description: Pnp Device's useState. + type: str + version: + description: Pnp Device's version. + type: int + type: dict + systemWorkflow: + description: Pnp Device's systemWorkflow. + suboptions: + _id: + description: Pnp Device's _id. + type: str + addToInventory: + description: AddToInventory flag. + type: bool + addedOn: + description: Pnp Device's addedOn. + type: int + configId: + description: Pnp Device's configId. + type: str + currTaskIdx: + description: Pnp Device's currTaskIdx. + type: int + description: + description: Pnp Device's description. + type: str + endTime: + description: Pnp Device's endTime. + type: int + execTime: + description: Pnp Device's execTime. + type: int + imageId: + description: Pnp Device's imageId. + type: str + instanceType: + description: Pnp Device's instanceType. + type: str + lastupdateOn: + description: Pnp Device's lastupdateOn. + type: int + name: + description: Pnp Device's name. + type: str + startTime: + description: Pnp Device's startTime. + type: int + state: + description: Pnp Device's state. + type: str + tasks: + description: Pnp Device's tasks. + elements: dict + suboptions: + currWorkItemIdx: + description: Pnp Device's currWorkItemIdx. + type: int + endTime: + description: Pnp Device's endTime. + type: int + name: + description: Pnp Device's name. + type: str + startTime: + description: Pnp Device's startTime. + type: int + state: + description: Pnp Device's state. + type: str + taskSeqNo: + description: Pnp Device's taskSeqNo. + type: int + timeTaken: + description: Pnp Device's timeTaken. + type: int + type: + description: Pnp Device's type. + type: str + workItemList: + description: Pnp Device's workItemList. + elements: dict + suboptions: + command: + description: Pnp Device's command. + type: str + endTime: + description: Pnp Device's endTime. + type: int + outputStr: + description: Pnp Device's outputStr. + type: str + startTime: + description: Pnp Device's startTime. + type: int + state: + description: Pnp Device's state. + type: str + timeTaken: + description: Pnp Device's timeTaken. + type: int + type: list + type: list + tenantId: + description: Pnp Device's tenantId. + type: str + type: + description: Pnp Device's type. + type: str + useState: + description: Pnp Device's useState. + type: str + version: + description: Pnp Device's version. + type: int + type: dict + tenantId: + description: Pnp Device's tenantId. + type: str + version: + description: Pnp Device's version. + type: int + workflow: + description: Pnp Device's workflow. + suboptions: + _id: + description: Pnp Device's _id. + type: str + addToInventory: + description: AddToInventory flag. + type: bool + addedOn: + description: Pnp Device's addedOn. + type: int + configId: + description: Pnp Device's configId. + type: str + currTaskIdx: + description: Pnp Device's currTaskIdx. + type: int + description: + description: Pnp Device's description. + type: str + endTime: + description: Pnp Device's endTime. + type: int + execTime: + description: Pnp Device's execTime. + type: int + imageId: + description: Pnp Device's imageId. + type: str + instanceType: + description: Pnp Device's instanceType. + type: str + lastupdateOn: + description: Pnp Device's lastupdateOn. + type: int + name: + description: Pnp Device's name. + type: str + startTime: + description: Pnp Device's startTime. + type: int + state: + description: Pnp Device's state. + type: str + tasks: + description: Pnp Device's tasks. + elements: dict + suboptions: + currWorkItemIdx: + description: Pnp Device's currWorkItemIdx. + type: int + endTime: + description: Pnp Device's endTime. + type: int + name: + description: Pnp Device's name. + type: str + startTime: + description: Pnp Device's startTime. + type: int + state: + description: Pnp Device's state. + type: str + taskSeqNo: + description: Pnp Device's taskSeqNo. + type: int + timeTaken: + description: Pnp Device's timeTaken. + type: int + type: + description: Pnp Device's type. + type: str + workItemList: + description: Pnp Device's workItemList. + elements: dict + suboptions: + command: + description: Pnp Device's command. + type: str + endTime: + description: Pnp Device's endTime. + type: int + outputStr: + description: Pnp Device's outputStr. + type: str + startTime: + description: Pnp Device's startTime. + type: int + state: + description: Pnp Device's state. + type: str + timeTaken: + description: Pnp Device's timeTaken. + type: int + type: list + type: list + tenantId: + description: Pnp Device's tenantId. + type: str + type: + description: Pnp Device's type. + type: str + useState: + description: Pnp Device's useState. + type: str + version: + description: Pnp Device's version. + type: int + type: dict + workflowParameters: + description: Pnp Device's workflowParameters. + suboptions: + configList: + description: Pnp Device's configList. + elements: dict + suboptions: + configId: + description: Pnp Device's configId. + type: str + configParameters: + description: Pnp Device's configParameters. + elements: dict + suboptions: + key: + description: Pnp Device's key. + type: str + value: + description: Pnp Device's value. + type: str + type: list + type: list + licenseLevel: + description: Pnp Device's licenseLevel. + type: str + licenseType: + description: Pnp Device's licenseType. + type: str + topOfStackSerialNumber: + description: Pnp Device's topOfStackSerialNumber. + type: str + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) AddDevice + description: Complete reference of the AddDevice API. + link: https://developer.cisco.com/docs/dna-center/#!add-device-2 +- name: Cisco DNA Center documentation for Device Onboarding (PnP) DeleteDeviceByIdFromPnP + description: Complete reference of the DeleteDeviceByIdFromPnP API. + link: https://developer.cisco.com/docs/dna-center/#!delete-device-by-id-from-pn-p +- name: Cisco DNA Center documentation for Device Onboarding (PnP) UpdateDevice + description: Complete reference of the UpdateDevice API. + link: https://developer.cisco.com/docs/dna-center/#!update-device +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.add_device, + device_onboarding_pnp.DeviceOnboardingPnp.delete_device_by_id_from_pnp, + device_onboarding_pnp.DeviceOnboardingPnp.update_device, + + - Paths used are + post /dna/intent/api/v1/onboarding/pnp-device, + delete /dna/intent/api/v1/onboarding/pnp-device/{id}, + put /dna/intent/api/v1/onboarding/pnp-device/{id}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.pnp_device: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + _id: string + deviceInfo: + aaaCredentials: + password: string + username: string + addedOn: 0 + addnMacAddrs: + - string + agentType: string + authStatus: string + authenticatedSudiSerialNo: string + capabilitiesSupported: + - string + cmState: string + description: string + deviceSudiSerialNos: + - string + deviceType: string + featuresSupported: + - string + fileSystemList: + - freespace: 0 + name: string + readable: true + size: 0 + type: string + writeable: true + firstContact: 0 + hostname: string + httpHeaders: + - key: string + value: string + imageFile: string + imageVersion: string + ipInterfaces: + - ipv4Address: {} + ipv6AddressList: + - {} + macAddress: string + name: string + status: string + lastContact: 0 + lastSyncTime: 0 + lastUpdateOn: 0 + location: + address: string + altitude: string + latitude: string + longitude: string + siteId: string + macAddress: string + mode: string + name: string + neighborLinks: + - localInterfaceName: string + localMacAddress: string + localShortInterfaceName: string + remoteDeviceName: string + remoteInterfaceName: string + remoteMacAddress: string + remotePlatform: string + remoteShortInterfaceName: string + remoteVersion: string + onbState: string + pid: string + pnpProfileList: + - createdBy: string + discoveryCreated: true + primaryEndpoint: + certificate: string + fqdn: string + ipv4Address: {} + ipv6Address: {} + port: 0 + protocol: string + profileName: string + secondaryEndpoint: + certificate: string + fqdn: string + ipv4Address: {} + ipv6Address: {} + port: 0 + protocol: string + populateInventory: true + preWorkflowCliOuputs: + - cli: string + cliOutput: string + projectId: string + projectName: string + reloadRequested: true + serialNumber: string + smartAccountId: string + source: string + stack: true + stackInfo: + isFullRing: true + stackMemberList: + - hardwareVersion: string + licenseLevel: string + licenseType: string + macAddress: string + pid: string + priority: 0 + role: string + serialNumber: string + softwareVersion: string + stackNumber: 0 + state: string + sudiSerialNumber: string + stackRingProtocol: string + supportsStackWorkflows: true + totalMemberCount: 0 + validLicenseLevels: + - string + state: string + sudiRequired: true + tags: {} + userSudiSerialNos: + - string + virtualAccountId: string + workflowId: string + workflowName: string + runSummaryList: + - details: string + errorFlag: true + historyTaskInfo: + addnDetails: + - key: string + value: string + name: string + timeTaken: 0 + type: string + workItemList: + - command: string + endTime: 0 + outputStr: string + startTime: 0 + state: string + timeTaken: 0 + timestamp: 0 + systemResetWorkflow: + _id: string + addToInventory: true + addedOn: 0 + configId: string + currTaskIdx: 0 + description: string + endTime: 0 + execTime: 0 + imageId: string + instanceType: string + lastupdateOn: 0 + name: string + startTime: 0 + state: string + tasks: + - currWorkItemIdx: 0 + endTime: 0 + name: string + startTime: 0 + state: string + taskSeqNo: 0 + timeTaken: 0 + type: string + workItemList: + - command: string + endTime: 0 + outputStr: string + startTime: 0 + state: string + timeTaken: 0 + tenantId: string + type: string + useState: string + version: 0 + systemWorkflow: + _id: string + addToInventory: true + addedOn: 0 + configId: string + currTaskIdx: 0 + description: string + endTime: 0 + execTime: 0 + imageId: string + instanceType: string + lastupdateOn: 0 + name: string + startTime: 0 + state: string + tasks: + - currWorkItemIdx: 0 + endTime: 0 + name: string + startTime: 0 + state: string + taskSeqNo: 0 + timeTaken: 0 + type: string + workItemList: + - command: string + endTime: 0 + outputStr: string + startTime: 0 + state: string + timeTaken: 0 + tenantId: string + type: string + useState: string + version: 0 + tenantId: string + version: 0 + workflow: + _id: string + addToInventory: true + addedOn: 0 + configId: string + currTaskIdx: 0 + description: string + endTime: 0 + execTime: 0 + imageId: string + instanceType: string + lastupdateOn: 0 + name: string + startTime: 0 + state: string + tasks: + - currWorkItemIdx: 0 + endTime: 0 + name: string + startTime: 0 + state: string + taskSeqNo: 0 + timeTaken: 0 + type: string + workItemList: + - command: string + endTime: 0 + outputStr: string + startTime: 0 + state: string + timeTaken: 0 + tenantId: string + type: string + useState: string + version: 0 + workflowParameters: + configList: + - configId: string + configParameters: + - key: string + value: string + licenseLevel: string + licenseType: string + topOfStackSerialNumber: string + +- name: Update by id + cisco.dnac.pnp_device: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + _id: string + deviceInfo: + aaaCredentials: + password: string + username: string + addedOn: 0 + addnMacAddrs: + - string + agentType: string + authStatus: string + authenticatedSudiSerialNo: string + capabilitiesSupported: + - string + cmState: string + description: string + deviceSudiSerialNos: + - string + deviceType: string + featuresSupported: + - string + fileSystemList: + - freespace: 0 + name: string + readable: true + size: 0 + type: string + writeable: true + firstContact: 0 + hostname: string + httpHeaders: + - key: string + value: string + imageFile: string + imageVersion: string + ipInterfaces: + - ipv4Address: {} + ipv6AddressList: + - {} + macAddress: string + name: string + status: string + lastContact: 0 + lastSyncTime: 0 + lastUpdateOn: 0 + location: + address: string + altitude: string + latitude: string + longitude: string + siteId: string + macAddress: string + mode: string + name: string + neighborLinks: + - localInterfaceName: string + localMacAddress: string + localShortInterfaceName: string + remoteDeviceName: string + remoteInterfaceName: string + remoteMacAddress: string + remotePlatform: string + remoteShortInterfaceName: string + remoteVersion: string + onbState: string + pid: string + pnpProfileList: + - createdBy: string + discoveryCreated: true + primaryEndpoint: + certificate: string + fqdn: string + ipv4Address: {} + ipv6Address: {} + port: 0 + protocol: string + profileName: string + secondaryEndpoint: + certificate: string + fqdn: string + ipv4Address: {} + ipv6Address: {} + port: 0 + protocol: string + populateInventory: true + preWorkflowCliOuputs: + - cli: string + cliOutput: string + projectId: string + projectName: string + reloadRequested: true + serialNumber: string + smartAccountId: string + source: string + stack: true + stackInfo: + isFullRing: true + stackMemberList: + - hardwareVersion: string + licenseLevel: string + licenseType: string + macAddress: string + pid: string + priority: 0 + role: string + serialNumber: string + softwareVersion: string + stackNumber: 0 + state: string + sudiSerialNumber: string + stackRingProtocol: string + supportsStackWorkflows: true + totalMemberCount: 0 + validLicenseLevels: + - string + state: string + sudiRequired: true + tags: {} + userSudiSerialNos: + - string + virtualAccountId: string + workflowId: string + workflowName: string + id: string + runSummaryList: + - details: string + errorFlag: true + historyTaskInfo: + addnDetails: + - key: string + value: string + name: string + timeTaken: 0 + type: string + workItemList: + - command: string + endTime: 0 + outputStr: string + startTime: 0 + state: string + timeTaken: 0 + timestamp: 0 + systemResetWorkflow: + _id: string + addToInventory: true + addedOn: 0 + configId: string + currTaskIdx: 0 + description: string + endTime: 0 + execTime: 0 + imageId: string + instanceType: string + lastupdateOn: 0 + name: string + startTime: 0 + state: string + tasks: + - currWorkItemIdx: 0 + endTime: 0 + name: string + startTime: 0 + state: string + taskSeqNo: 0 + timeTaken: 0 + type: string + workItemList: + - command: string + endTime: 0 + outputStr: string + startTime: 0 + state: string + timeTaken: 0 + tenantId: string + type: string + useState: string + version: 0 + systemWorkflow: + _id: string + addToInventory: true + addedOn: 0 + configId: string + currTaskIdx: 0 + description: string + endTime: 0 + execTime: 0 + imageId: string + instanceType: string + lastupdateOn: 0 + name: string + startTime: 0 + state: string + tasks: + - currWorkItemIdx: 0 + endTime: 0 + name: string + startTime: 0 + state: string + taskSeqNo: 0 + timeTaken: 0 + type: string + workItemList: + - command: string + endTime: 0 + outputStr: string + startTime: 0 + state: string + timeTaken: 0 + tenantId: string + type: string + useState: string + version: 0 + tenantId: string + version: 0 + workflow: + _id: string + addToInventory: true + addedOn: 0 + configId: string + currTaskIdx: 0 + description: string + endTime: 0 + execTime: 0 + imageId: string + instanceType: string + lastupdateOn: 0 + name: string + startTime: 0 + state: string + tasks: + - currWorkItemIdx: 0 + endTime: 0 + name: string + startTime: 0 + state: string + taskSeqNo: 0 + timeTaken: 0 + type: string + workItemList: + - command: string + endTime: 0 + outputStr: string + startTime: 0 + state: string + timeTaken: 0 + tenantId: string + type: string + useState: string + version: 0 + workflowParameters: + configList: + - configId: string + configParameters: + - key: string + value: string + licenseLevel: string + licenseType: string + topOfStackSerialNumber: string + +- name: Delete by id + cisco.dnac.pnp_device: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + id: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "_id": "string", + "deviceInfo": { + "source": "string", + "serialNumber": "string", + "stack": true, + "mode": "string", + "state": "string", + "location": { + "siteId": "string", + "address": "string", + "latitude": "string", + "longitude": "string", + "altitude": "string" + }, + "description": "string", + "onbState": "string", + "authenticatedMicNumber": "string", + "authenticatedSudiSerialNo": "string", + "capabilitiesSupported": [ + "string" + ], + "featuresSupported": [ + "string" + ], + "cmState": "string", + "firstContact": 0, + "lastContact": 0, + "macAddress": "string", + "pid": "string", + "deviceSudiSerialNos": [ + "string" + ], + "lastUpdateOn": 0, + "workflowId": "string", + "workflowName": "string", + "projectId": "string", + "projectName": "string", + "deviceType": "string", + "agentType": "string", + "imageVersion": "string", + "fileSystemList": [ + { + "type": "string", + "writeable": true, + "freespace": 0, + "name": "string", + "readable": true, + "size": 0 + } + ], + "pnpProfileList": [ + { + "profileName": "string", + "discoveryCreated": true, + "createdBy": "string", + "primaryEndpoint": { + "port": 0, + "protocol": "string", + "ipv4Address": {}, + "ipv6Address": {}, + "fqdn": "string", + "certificate": "string" + }, + "secondaryEndpoint": { + "port": 0, + "protocol": "string", + "ipv4Address": {}, + "ipv6Address": {}, + "fqdn": "string", + "certificate": "string" + } + } + ], + "imageFile": "string", + "httpHeaders": [ + { + "key": "string", + "value": "string" + } + ], + "neighborLinks": [ + { + "localInterfaceName": "string", + "localShortInterfaceName": "string", + "localMacAddress": "string", + "remoteInterfaceName": "string", + "remoteShortInterfaceName": "string", + "remoteMacAddress": "string", + "remoteDeviceName": "string", + "remotePlatform": "string", + "remoteVersion": "string" + } + ], + "lastSyncTime": 0, + "ipInterfaces": [ + { + "status": "string", + "macAddress": "string", + "ipv4Address": {}, + "ipv6AddressList": [ + {} + ], + "name": "string" + } + ], + "hostname": "string", + "authStatus": "string", + "stackInfo": { + "supportsStackWorkflows": true, + "isFullRing": true, + "stackMemberList": [ + { + "serialNumber": "string", + "state": "string", + "role": "string", + "macAddress": "string", + "pid": "string", + "licenseLevel": "string", + "licenseType": "string", + "sudiSerialNumber": "string", + "hardwareVersion": "string", + "stackNumber": 0, + "softwareVersion": "string", + "priority": 0 + } + ], + "stackRingProtocol": "string", + "validLicenseLevels": [ + "string" + ], + "totalMemberCount": 0 + }, + "reloadRequested": true, + "addedOn": 0, + "siteId": "string", + "aaaCredentials": { + "password": "string", + "username": "string" + }, + "userMicNumbers": [ + "string" + ], + "userSudiSerialNos": [ + "string" + ], + "addnMacAddrs": [ + "string" + ], + "preWorkflowCliOuputs": [ + { + "cli": "string", + "cliOutput": "string" + } + ], + "tags": {}, + "sudiRequired": true, + "smartAccountId": "string", + "virtualAccountId": "string", + "populateInventory": true, + "siteName": "string", + "name": "string" + }, + "systemResetWorkflow": { + "_id": "string", + "state": "string", + "type": "string", + "description": "string", + "lastupdateOn": 0, + "imageId": "string", + "currTaskIdx": 0, + "addedOn": 0, + "tasks": [ + { + "state": "string", + "type": "string", + "currWorkItemIdx": 0, + "taskSeqNo": 0, + "endTime": 0, + "startTime": 0, + "workItemList": [ + { + "state": "string", + "command": "string", + "outputStr": "string", + "endTime": 0, + "startTime": 0, + "timeTaken": 0 + } + ], + "timeTaken": 0, + "name": "string" + } + ], + "addToInventory": true, + "instanceType": "string", + "endTime": 0, + "execTime": 0, + "startTime": 0, + "useState": "string", + "configId": "string", + "name": "string", + "version": 0, + "tenantId": "string" + }, + "systemWorkflow": { + "_id": "string", + "state": "string", + "type": "string", + "description": "string", + "lastupdateOn": 0, + "imageId": "string", + "currTaskIdx": 0, + "addedOn": 0, + "tasks": [ + { + "state": "string", + "type": "string", + "currWorkItemIdx": 0, + "taskSeqNo": 0, + "endTime": 0, + "startTime": 0, + "workItemList": [ + { + "state": "string", + "command": "string", + "outputStr": "string", + "endTime": 0, + "startTime": 0, + "timeTaken": 0 + } + ], + "timeTaken": 0, + "name": "string" + } + ], + "addToInventory": true, + "instanceType": "string", + "endTime": 0, + "execTime": 0, + "startTime": 0, + "useState": "string", + "configId": "string", + "name": "string", + "version": 0, + "tenantId": "string" + }, + "workflow": { + "_id": "string", + "state": "string", + "type": "string", + "description": "string", + "lastupdateOn": 0, + "imageId": "string", + "currTaskIdx": 0, + "addedOn": 0, + "tasks": [ + { + "state": "string", + "type": "string", + "currWorkItemIdx": 0, + "taskSeqNo": 0, + "endTime": 0, + "startTime": 0, + "workItemList": [ + { + "state": "string", + "command": "string", + "outputStr": "string", + "endTime": 0, + "startTime": 0, + "timeTaken": 0 + } + ], + "timeTaken": 0, + "name": "string" + } + ], + "addToInventory": true, + "instanceType": "string", + "endTime": 0, + "execTime": 0, + "startTime": 0, + "useState": "string", + "configId": "string", + "name": "string", + "version": 0, + "tenantId": "string" + }, + "runSummaryList": [ + { + "details": "string", + "historyTaskInfo": { + "type": "string", + "workItemList": [ + { + "state": "string", + "command": "string", + "outputStr": "string", + "endTime": 0, + "startTime": 0, + "timeTaken": 0 + } + ], + "timeTaken": 0, + "addnDetails": [ + { + "key": "string", + "value": "string" + } + ], + "name": "string" + }, + "errorFlag": true, + "timestamp": 0 + } + ], + "workflowParameters": { + "topOfStackSerialNumber": "string", + "licenseLevel": "string", + "licenseType": "string", + "configList": [ + { + "configParameters": [ + { + "key": "string", + "value": "string" + } + ], + "configId": "string" + } + ] + }, + "dayZeroConfig": { + "config": "string" + }, + "dayZeroConfigPreview": {}, + "version": 0, + "tenantId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_device_authorize.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_authorize.py new file mode 100644 index 000000000..c6aa96590 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_authorize.py @@ -0,0 +1,70 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_device_authorize +short_description: Resource module for Pnp Device Authorize +description: +- Manage operation create of the resource Pnp Device Authorize. +- Authorizes one of more devices. A device can only be authorized if Authorization is set in Device Settings. +version_added: '6.5.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + deviceIdList: + description: Device Id List. + elements: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for AuthorizeDevice + description: Complete reference of the AuthorizeDevice API. + link: https://developer.cisco.com/docs/dna-center/#!authorize-device +notes: + - SDK Method used are + ..authorize_device, + + - Paths used are + post /api/v1/onboarding/pnp-device/authorize, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.pnp_device_authorize: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + deviceIdList: + - string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "jsonResponse": { + "empty": true + }, + "message": "string", + "statusCode": 0, + "jsonArrayResponse": [ + "string" + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_device_claim.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_claim.py new file mode 100644 index 000000000..3a6c668f5 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_claim.py @@ -0,0 +1,140 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_device_claim +short_description: Resource module for Pnp Device Claim +description: +- Manage operation create of the resource Pnp Device Claim. +- Claims one of more devices with specified workflow. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + configFileUrl: + description: Pnp Device Claim's configFileUrl. + type: str + configId: + description: Pnp Device Claim's configId. + type: str + deviceClaimList: + description: Pnp Device Claim's deviceClaimList. + elements: dict + suboptions: + configList: + description: Pnp Device Claim's configList. + elements: dict + suboptions: + configId: + description: Pnp Device Claim's configId. + type: str + configParameters: + description: Pnp Device Claim's configParameters. + elements: dict + suboptions: + key: + description: Pnp Device Claim's key. + type: str + value: + description: Pnp Device Claim's value. + type: str + type: list + type: list + deviceId: + description: Pnp Device Claim's deviceId. + type: str + licenseLevel: + description: Pnp Device Claim's licenseLevel. + type: str + licenseType: + description: Pnp Device Claim's licenseType. + type: str + topOfStackSerialNumber: + description: Pnp Device Claim's topOfStackSerialNumber. + type: str + type: list + fileServiceId: + description: Pnp Device Claim's fileServiceId. + type: str + imageId: + description: Pnp Device Claim's imageId. + type: str + imageUrl: + description: Pnp Device Claim's imageUrl. + type: str + populateInventory: + description: PopulateInventory flag. + type: bool + projectId: + description: Pnp Device Claim's projectId. + type: str + workflowId: + description: Pnp Device Claim's workflowId. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) ClaimDevice + description: Complete reference of the ClaimDevice API. + link: https://developer.cisco.com/docs/dna-center/#!claim-device +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.claim_device, + + - Paths used are + post /dna/intent/api/v1/onboarding/pnp-device/claim, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.pnp_device_claim: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + configFileUrl: string + configId: string + deviceClaimList: + - configList: + - configId: string + configParameters: + - key: string + value: string + deviceId: string + licenseLevel: string + licenseType: string + topOfStackSerialNumber: string + fileServiceId: string + imageId: string + imageUrl: string + populateInventory: true + projectId: string + workflowId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "jsonArrayResponse": [ + {} + ], + "jsonResponse": {}, + "message": "string", + "statusCode": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_device_claim_to_site.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_claim_to_site.py new file mode 100644 index 000000000..397dc9f95 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_claim_to_site.py @@ -0,0 +1,139 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_device_claim_to_site +short_description: Resource module for Pnp Device Claim To Site +description: +- Manage operation create of the resource Pnp Device Claim To Site. +- Claim a device based on DNA-C Site-based design process. Some required parameters differ based on device platform. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + configInfo: + description: Pnp Device Claim To Site's configInfo. + elements: dict + suboptions: + configId: + description: Config Id. + type: str + configParameters: + description: Pnp Device Claim To Site's configParameters. + suboptions: + key: + description: Key. + type: str + value: + description: Value. + type: str + type: dict + type: list + version_added: 4.2.0 + deviceId: + description: Device Id. + type: str + gateway: + description: For CatalystWLC/MobilityExpress. + type: str + version_added: 6.4.0 + imageInfo: + description: Pnp Device Claim To Site's imageInfo. + suboptions: + imageId: + description: Image Id. + type: str + skip: + description: Skip. + type: bool + type: dict + version_added: 4.2.0 + interfaceName: + description: For Catalyst 9800 WLC. + type: str + rfProfile: + description: For Access Points. + type: str + version_added: 6.1.0 + sensorProfile: + description: For Sensors. + type: str + siteId: + description: Site Id. + type: str + staticIP: + description: For CatalystWLC/MobilityExpress. + type: str + version_added: 6.4.0 + subnetMask: + description: For CatalystWLC/MobilityExpress. + type: str + type: + description: Type. + type: str + vlanID: + description: For Catalyst 9800 WLC. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) ClaimADeviceToASite + description: Complete reference of the ClaimADeviceToASite API. + link: https://developer.cisco.com/docs/dna-center/#!claim-a-device-to-a-site +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.claim_a_device_to_a_site, + + - Paths used are + post /dna/intent/api/v1/onboarding/pnp-device/site-claim, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.pnp_device_claim_to_site: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + configInfo: + - configId: string + configParameters: + key: string + value: string + deviceId: string + gateway: string + imageInfo: + imageId: string + skip: true + interfaceName: string + rfProfile: string + sensorProfile: string + siteId: string + staticIP: string + subnetMask: string + type: string + vlanID: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": "string", + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_device_config_preview.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_config_preview.py new file mode 100644 index 000000000..7007ba3bb --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_config_preview.py @@ -0,0 +1,81 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_device_config_preview +short_description: Resource module for Pnp Device Config Preview +description: +- Manage operation create of the resource Pnp Device Config Preview. +- Triggers a preview for site-based Day 0 Configuration. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + deviceId: + description: Pnp Device Config Preview's deviceId. + type: str + siteId: + description: Pnp Device Config Preview's siteId. + type: str + type: + description: Pnp Device Config Preview's type. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) PreviewConfig + description: Complete reference of the PreviewConfig API. + link: https://developer.cisco.com/docs/dna-center/#!preview-config +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.preview_config, + + - Paths used are + post /dna/intent/api/v1/onboarding/pnp-device/site-config-preview, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.pnp_device_config_preview: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + deviceId: string + siteId: string + type: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "complete": true, + "config": "string", + "error": true, + "errorMessage": "string", + "expiredTime": 0, + "rfProfile": "string", + "sensorProfile": "string", + "siteId": "string", + "startTime": 0, + "taskId": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_device_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_count_info.py new file mode 100644 index 000000000..5b98a91e5 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_count_info.py @@ -0,0 +1,145 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_device_count_info +short_description: Information module for Pnp Device Count +description: +- Get all Pnp Device Count. +- Returns the device count based on filter criteria. This is useful for pagination. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + serialNumber: + description: + - SerialNumber query parameter. Device Serial Number. + elements: str + type: list + state_: + description: + - State query parameter. Device State. + elements: str + type: list + onbState: + description: + - OnbState query parameter. Device Onboarding State. + elements: str + type: list + cmState: + description: + - CmState query parameter. Device Connection Manager State. + elements: str + type: list + name: + description: + - Name query parameter. Device Name. + elements: str + type: list + pid: + description: + - Pid query parameter. Device ProductId. + elements: str + type: list + source: + description: + - Source query parameter. Device Source. + elements: str + type: list + projectId: + description: + - ProjectId query parameter. Device Project Id. + elements: str + type: list + workflowId: + description: + - WorkflowId query parameter. Device Workflow Id. + elements: str + type: list + projectName: + description: + - ProjectName query parameter. Device Project Name. + elements: str + type: list + workflowName: + description: + - WorkflowName query parameter. Device Workflow Name. + elements: str + type: list + smartAccountId: + description: + - SmartAccountId query parameter. Device Smart Account. + elements: str + type: list + virtualAccountId: + description: + - VirtualAccountId query parameter. Device Virtual Account. + elements: str + type: list + lastContact: + description: + - LastContact query parameter. Device Has Contacted lastContact > 0. + type: bool +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) GetDeviceCount + description: Complete reference of the GetDeviceCount API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-count-2 +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.get_device_count, + + - Paths used are + get /dna/intent/api/v1/onboarding/pnp-device/count, + +""" + +EXAMPLES = r""" +- name: Get all Pnp Device Count + cisco.dnac.pnp_device_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + serialNumber: [] + state_: [] + onbState: [] + cmState: [] + name: [] + pid: [] + source: [] + projectId: [] + workflowId: [] + projectName: [] + workflowName: [] + smartAccountId: [] + virtualAccountId: [] + lastContact: True + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_device_history_info.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_history_info.py new file mode 100644 index 000000000..662cc694b --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_history_info.py @@ -0,0 +1,106 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_device_history_info +short_description: Information module for Pnp Device History +description: +- Get all Pnp Device History. +- Returns history for a specific device. Serial number is a required parameter. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + serialNumber: + description: + - SerialNumber query parameter. Device Serial Number. + type: str + sort: + description: + - Sort query parameter. Comma seperated list of fields to sort on. + elements: str + type: list + sortOrder: + description: + - SortOrder query parameter. Sort Order Ascending (asc) or Descending (des). + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) GetDeviceHistory + description: Complete reference of the GetDeviceHistory API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-history +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.get_device_history, + + - Paths used are + get /dna/intent/api/v1/onboarding/pnp-device/history, + +""" + +EXAMPLES = r""" +- name: Get all Pnp Device History + cisco.dnac.pnp_device_history_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + serialNumber: string + sort: [] + sortOrder: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "timestamp": 0, + "details": "string", + "historyTaskInfo": { + "name": "string", + "type": "string", + "timeTaken": 0, + "workItemList": [ + { + "state": "string", + "command": "string", + "startTime": 0, + "endTime": 0, + "timeTaken": 0, + "outputStr": "string" + } + ], + "addnDetails": [ + { + "key": "string", + "value": "string" + } + ] + }, + "errorFlag": true + } + ], + "statusCode": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_device_import.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_import.py new file mode 100644 index 000000000..78ff2aada --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_import.py @@ -0,0 +1,1470 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_device_import +short_description: Resource module for Pnp Device Import +description: +- Manage operation create of the resource Pnp Device Import. +- Add devices to PnP in bulk. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + payload: + description: Pnp Device Import's payload. + elements: dict + suboptions: + _id: + description: Pnp Device Import's _id. + type: str + deviceInfo: + description: Pnp Device Import's deviceInfo. + suboptions: + aaaCredentials: + description: Pnp Device Import's aaaCredentials. + suboptions: + password: + description: Pnp Device Import's password. + type: str + username: + description: Pnp Device Import's username. + type: str + type: dict + addedOn: + description: Pnp Device Import's addedOn. + type: int + addnMacAddrs: + description: Pnp Device Import's addnMacAddrs. + elements: str + type: list + agentType: + description: Pnp Device Import's agentType. + type: str + authStatus: + description: Pnp Device Import's authStatus. + type: str + authenticatedSudiSerialNo: + description: Pnp Device Import's authenticatedSudiSerialNo. + type: str + capabilitiesSupported: + description: Pnp Device Import's capabilitiesSupported. + elements: str + type: list + cmState: + description: Pnp Device Import's cmState. + type: str + description: + description: Pnp Device Import's description. + type: str + deviceSudiSerialNos: + description: Pnp Device Import's deviceSudiSerialNos. + elements: str + type: list + deviceType: + description: Pnp Device Import's deviceType. + type: str + featuresSupported: + description: Pnp Device Import's featuresSupported. + elements: str + type: list + fileSystemList: + description: Pnp Device Import's fileSystemList. + elements: dict + suboptions: + freespace: + description: Pnp Device Import's freespace. + type: int + name: + description: Pnp Device Import's name. + type: str + readable: + description: Readable flag. + type: bool + size: + description: Pnp Device Import's size. + type: int + type: + description: Pnp Device Import's type. + type: str + writeable: + description: Writeable flag. + type: bool + type: list + firstContact: + description: Pnp Device Import's firstContact. + type: int + hostname: + description: Pnp Device Import's hostname. + type: str + httpHeaders: + description: Pnp Device Import's httpHeaders. + elements: dict + suboptions: + key: + description: Pnp Device Import's key. + type: str + value: + description: Pnp Device Import's value. + type: str + type: list + imageFile: + description: Pnp Device Import's imageFile. + type: str + imageVersion: + description: Pnp Device Import's imageVersion. + type: str + ipInterfaces: + description: Pnp Device Import's ipInterfaces. + elements: dict + suboptions: + ipv4Address: + description: Pnp Device Import's ipv4Address. + type: dict + ipv6AddressList: + description: Pnp Device Import's ipv6AddressList. + elements: dict + type: list + macAddress: + description: Pnp Device Import's macAddress. + type: str + name: + description: Pnp Device Import's name. + type: str + status: + description: Pnp Device Import's status. + type: str + type: list + lastContact: + description: Pnp Device Import's lastContact. + type: int + lastSyncTime: + description: Pnp Device Import's lastSyncTime. + type: int + lastUpdateOn: + description: Pnp Device Import's lastUpdateOn. + type: int + location: + description: Pnp Device Import's location. + suboptions: + address: + description: Pnp Device Import's address. + type: str + altitude: + description: Pnp Device Import's altitude. + type: str + latitude: + description: Pnp Device Import's latitude. + type: str + longitude: + description: Pnp Device Import's longitude. + type: str + siteId: + description: Pnp Device Import's siteId. + type: str + type: dict + macAddress: + description: Pnp Device Import's macAddress. + type: str + mode: + description: Pnp Device Import's mode. + type: str + name: + description: Pnp Device Import's name. + type: str + neighborLinks: + description: Pnp Device Import's neighborLinks. + elements: dict + suboptions: + localInterfaceName: + description: Pnp Device Import's localInterfaceName. + type: str + localMacAddress: + description: Pnp Device Import's localMacAddress. + type: str + localShortInterfaceName: + description: Pnp Device Import's localShortInterfaceName. + type: str + remoteDeviceName: + description: Pnp Device Import's remoteDeviceName. + type: str + remoteInterfaceName: + description: Pnp Device Import's remoteInterfaceName. + type: str + remoteMacAddress: + description: Pnp Device Import's remoteMacAddress. + type: str + remotePlatform: + description: Pnp Device Import's remotePlatform. + type: str + remoteShortInterfaceName: + description: Pnp Device Import's remoteShortInterfaceName. + type: str + remoteVersion: + description: Pnp Device Import's remoteVersion. + type: str + type: list + onbState: + description: Pnp Device Import's onbState. + type: str + pid: + description: Pnp Device Import's pid. + type: str + pnpProfileList: + description: Pnp Device Import's pnpProfileList. + elements: dict + suboptions: + createdBy: + description: Pnp Device Import's createdBy. + type: str + discoveryCreated: + description: DiscoveryCreated flag. + type: bool + primaryEndpoint: + description: Pnp Device Import's primaryEndpoint. + suboptions: + certificate: + description: Pnp Device Import's certificate. + type: str + fqdn: + description: Pnp Device Import's fqdn. + type: str + ipv4Address: + description: Pnp Device Import's ipv4Address. + type: dict + ipv6Address: + description: Pnp Device Import's ipv6Address. + type: dict + port: + description: Pnp Device Import's port. + type: int + protocol: + description: Pnp Device Import's protocol. + type: str + type: dict + profileName: + description: Pnp Device Import's profileName. + type: str + secondaryEndpoint: + description: Pnp Device Import's secondaryEndpoint. + suboptions: + certificate: + description: Pnp Device Import's certificate. + type: str + fqdn: + description: Pnp Device Import's fqdn. + type: str + ipv4Address: + description: Pnp Device Import's ipv4Address. + type: dict + ipv6Address: + description: Pnp Device Import's ipv6Address. + type: dict + port: + description: Pnp Device Import's port. + type: int + protocol: + description: Pnp Device Import's protocol. + type: str + type: dict + type: list + populateInventory: + description: PopulateInventory flag. + type: bool + preWorkflowCliOuputs: + description: Pnp Device Import's preWorkflowCliOuputs. + elements: dict + suboptions: + cli: + description: Pnp Device Import's cli. + type: str + cliOutput: + description: Pnp Device Import's cliOutput. + type: str + type: list + projectId: + description: Pnp Device Import's projectId. + type: str + projectName: + description: Pnp Device Import's projectName. + type: str + reloadRequested: + description: ReloadRequested flag. + type: bool + serialNumber: + description: Pnp Device Import's serialNumber. + type: str + smartAccountId: + description: Pnp Device Import's smartAccountId. + type: str + source: + description: Pnp Device Import's source. + type: str + stack: + description: Stack flag. + type: bool + stackInfo: + description: Pnp Device Import's stackInfo. + suboptions: + isFullRing: + description: IsFullRing flag. + type: bool + stackMemberList: + description: Pnp Device Import's stackMemberList. + elements: dict + suboptions: + hardwareVersion: + description: Pnp Device Import's hardwareVersion. + type: str + licenseLevel: + description: Pnp Device Import's licenseLevel. + type: str + licenseType: + description: Pnp Device Import's licenseType. + type: str + macAddress: + description: Pnp Device Import's macAddress. + type: str + pid: + description: Pnp Device Import's pid. + type: str + priority: + description: Pnp Device Import's priority. + type: int + role: + description: Pnp Device Import's role. + type: str + serialNumber: + description: Pnp Device Import's serialNumber. + type: str + softwareVersion: + description: Pnp Device Import's softwareVersion. + type: str + stackNumber: + description: Pnp Device Import's stackNumber. + type: int + state: + description: Pnp Device Import's state. + type: str + sudiSerialNumber: + description: Pnp Device Import's sudiSerialNumber. + type: str + type: list + stackRingProtocol: + description: Pnp Device Import's stackRingProtocol. + type: str + supportsStackWorkflows: + description: SupportsStackWorkflows flag. + type: bool + totalMemberCount: + description: Pnp Device Import's totalMemberCount. + type: int + validLicenseLevels: + description: Pnp Device Import's validLicenseLevels. + elements: str + type: list + type: dict + state: + description: Pnp Device Import's state. + type: str + sudiRequired: + description: SudiRequired flag. + type: bool + tags: + description: Pnp Device Import's tags. + type: dict + userSudiSerialNos: + description: Pnp Device Import's userSudiSerialNos. + elements: str + type: list + virtualAccountId: + description: Pnp Device Import's virtualAccountId. + type: str + workflowId: + description: Pnp Device Import's workflowId. + type: str + workflowName: + description: Pnp Device Import's workflowName. + type: str + type: dict + runSummaryList: + description: Pnp Device Import's runSummaryList. + elements: dict + suboptions: + details: + description: Pnp Device Import's details. + type: str + errorFlag: + description: ErrorFlag flag. + type: bool + historyTaskInfo: + description: Pnp Device Import's historyTaskInfo. + suboptions: + addnDetails: + description: Pnp Device Import's addnDetails. + elements: dict + suboptions: + key: + description: Pnp Device Import's key. + type: str + value: + description: Pnp Device Import's value. + type: str + type: list + name: + description: Pnp Device Import's name. + type: str + timeTaken: + description: Pnp Device Import's timeTaken. + type: int + type: + description: Pnp Device Import's type. + type: str + workItemList: + description: Pnp Device Import's workItemList. + elements: dict + suboptions: + command: + description: Pnp Device Import's command. + type: str + endTime: + description: Pnp Device Import's endTime. + type: int + outputStr: + description: Pnp Device Import's outputStr. + type: str + startTime: + description: Pnp Device Import's startTime. + type: int + state: + description: Pnp Device Import's state. + type: str + timeTaken: + description: Pnp Device Import's timeTaken. + type: int + type: list + type: dict + timestamp: + description: Pnp Device Import's timestamp. + type: int + type: list + systemResetWorkflow: + description: Pnp Device Import's systemResetWorkflow. + suboptions: + _id: + description: Pnp Device Import's _id. + type: str + addToInventory: + description: AddToInventory flag. + type: bool + addedOn: + description: Pnp Device Import's addedOn. + type: int + configId: + description: Pnp Device Import's configId. + type: str + currTaskIdx: + description: Pnp Device Import's currTaskIdx. + type: int + description: + description: Pnp Device Import's description. + type: str + endTime: + description: Pnp Device Import's endTime. + type: int + execTime: + description: Pnp Device Import's execTime. + type: int + imageId: + description: Pnp Device Import's imageId. + type: str + instanceType: + description: Pnp Device Import's instanceType. + type: str + lastupdateOn: + description: Pnp Device Import's lastupdateOn. + type: int + name: + description: Pnp Device Import's name. + type: str + startTime: + description: Pnp Device Import's startTime. + type: int + state: + description: Pnp Device Import's state. + type: str + tasks: + description: Pnp Device Import's tasks. + elements: dict + suboptions: + currWorkItemIdx: + description: Pnp Device Import's currWorkItemIdx. + type: int + endTime: + description: Pnp Device Import's endTime. + type: int + name: + description: Pnp Device Import's name. + type: str + startTime: + description: Pnp Device Import's startTime. + type: int + state: + description: Pnp Device Import's state. + type: str + taskSeqNo: + description: Pnp Device Import's taskSeqNo. + type: int + timeTaken: + description: Pnp Device Import's timeTaken. + type: int + type: + description: Pnp Device Import's type. + type: str + workItemList: + description: Pnp Device Import's workItemList. + elements: dict + suboptions: + command: + description: Pnp Device Import's command. + type: str + endTime: + description: Pnp Device Import's endTime. + type: int + outputStr: + description: Pnp Device Import's outputStr. + type: str + startTime: + description: Pnp Device Import's startTime. + type: int + state: + description: Pnp Device Import's state. + type: str + timeTaken: + description: Pnp Device Import's timeTaken. + type: int + type: list + type: list + tenantId: + description: Pnp Device Import's tenantId. + type: str + type: + description: Pnp Device Import's type. + type: str + useState: + description: Pnp Device Import's useState. + type: str + version: + description: Pnp Device Import's version. + type: int + type: dict + systemWorkflow: + description: Pnp Device Import's systemWorkflow. + suboptions: + _id: + description: Pnp Device Import's _id. + type: str + addToInventory: + description: AddToInventory flag. + type: bool + addedOn: + description: Pnp Device Import's addedOn. + type: int + configId: + description: Pnp Device Import's configId. + type: str + currTaskIdx: + description: Pnp Device Import's currTaskIdx. + type: int + description: + description: Pnp Device Import's description. + type: str + endTime: + description: Pnp Device Import's endTime. + type: int + execTime: + description: Pnp Device Import's execTime. + type: int + imageId: + description: Pnp Device Import's imageId. + type: str + instanceType: + description: Pnp Device Import's instanceType. + type: str + lastupdateOn: + description: Pnp Device Import's lastupdateOn. + type: int + name: + description: Pnp Device Import's name. + type: str + startTime: + description: Pnp Device Import's startTime. + type: int + state: + description: Pnp Device Import's state. + type: str + tasks: + description: Pnp Device Import's tasks. + elements: dict + suboptions: + currWorkItemIdx: + description: Pnp Device Import's currWorkItemIdx. + type: int + endTime: + description: Pnp Device Import's endTime. + type: int + name: + description: Pnp Device Import's name. + type: str + startTime: + description: Pnp Device Import's startTime. + type: int + state: + description: Pnp Device Import's state. + type: str + taskSeqNo: + description: Pnp Device Import's taskSeqNo. + type: int + timeTaken: + description: Pnp Device Import's timeTaken. + type: int + type: + description: Pnp Device Import's type. + type: str + workItemList: + description: Pnp Device Import's workItemList. + elements: dict + suboptions: + command: + description: Pnp Device Import's command. + type: str + endTime: + description: Pnp Device Import's endTime. + type: int + outputStr: + description: Pnp Device Import's outputStr. + type: str + startTime: + description: Pnp Device Import's startTime. + type: int + state: + description: Pnp Device Import's state. + type: str + timeTaken: + description: Pnp Device Import's timeTaken. + type: int + type: list + type: list + tenantId: + description: Pnp Device Import's tenantId. + type: str + type: + description: Pnp Device Import's type. + type: str + useState: + description: Pnp Device Import's useState. + type: str + version: + description: Pnp Device Import's version. + type: int + type: dict + tenantId: + description: Pnp Device Import's tenantId. + type: str + version: + description: Pnp Device Import's version. + type: int + workflow: + description: Pnp Device Import's workflow. + suboptions: + _id: + description: Pnp Device Import's _id. + type: str + addToInventory: + description: AddToInventory flag. + type: bool + addedOn: + description: Pnp Device Import's addedOn. + type: int + configId: + description: Pnp Device Import's configId. + type: str + currTaskIdx: + description: Pnp Device Import's currTaskIdx. + type: int + description: + description: Pnp Device Import's description. + type: str + endTime: + description: Pnp Device Import's endTime. + type: int + execTime: + description: Pnp Device Import's execTime. + type: int + imageId: + description: Pnp Device Import's imageId. + type: str + instanceType: + description: Pnp Device Import's instanceType. + type: str + lastupdateOn: + description: Pnp Device Import's lastupdateOn. + type: int + name: + description: Pnp Device Import's name. + type: str + startTime: + description: Pnp Device Import's startTime. + type: int + state: + description: Pnp Device Import's state. + type: str + tasks: + description: Pnp Device Import's tasks. + elements: dict + suboptions: + currWorkItemIdx: + description: Pnp Device Import's currWorkItemIdx. + type: int + endTime: + description: Pnp Device Import's endTime. + type: int + name: + description: Pnp Device Import's name. + type: str + startTime: + description: Pnp Device Import's startTime. + type: int + state: + description: Pnp Device Import's state. + type: str + taskSeqNo: + description: Pnp Device Import's taskSeqNo. + type: int + timeTaken: + description: Pnp Device Import's timeTaken. + type: int + type: + description: Pnp Device Import's type. + type: str + workItemList: + description: Pnp Device Import's workItemList. + elements: dict + suboptions: + command: + description: Pnp Device Import's command. + type: str + endTime: + description: Pnp Device Import's endTime. + type: int + outputStr: + description: Pnp Device Import's outputStr. + type: str + startTime: + description: Pnp Device Import's startTime. + type: int + state: + description: Pnp Device Import's state. + type: str + timeTaken: + description: Pnp Device Import's timeTaken. + type: int + type: list + type: list + tenantId: + description: Pnp Device Import's tenantId. + type: str + type: + description: Pnp Device Import's type. + type: str + useState: + description: Pnp Device Import's useState. + type: str + version: + description: Pnp Device Import's version. + type: int + type: dict + workflowParameters: + description: Pnp Device Import's workflowParameters. + suboptions: + configList: + description: Pnp Device Import's configList. + elements: dict + suboptions: + configId: + description: Pnp Device Import's configId. + type: str + configParameters: + description: Pnp Device Import's configParameters. + elements: dict + suboptions: + key: + description: Pnp Device Import's key. + type: str + value: + description: Pnp Device Import's value. + type: str + type: list + type: list + licenseLevel: + description: Pnp Device Import's licenseLevel. + type: str + licenseType: + description: Pnp Device Import's licenseType. + type: str + topOfStackSerialNumber: + description: Pnp Device Import's topOfStackSerialNumber. + type: str + type: dict + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) ImportDevicesInBulk + description: Complete reference of the ImportDevicesInBulk API. + link: https://developer.cisco.com/docs/dna-center/#!import-devices-in-bulk +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.import_devices_in_bulk, + + - Paths used are + post /dna/intent/api/v1/onboarding/pnp-device/import, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.pnp_device_import: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + payload: + - _id: string + deviceInfo: + aaaCredentials: + password: string + username: string + addedOn: 0 + addnMacAddrs: + - string + agentType: string + authStatus: string + authenticatedSudiSerialNo: string + capabilitiesSupported: + - string + cmState: string + description: string + deviceSudiSerialNos: + - string + deviceType: string + featuresSupported: + - string + fileSystemList: + - freespace: 0 + name: string + readable: true + size: 0 + type: string + writeable: true + firstContact: 0 + hostname: string + httpHeaders: + - key: string + value: string + imageFile: string + imageVersion: string + ipInterfaces: + - ipv4Address: {} + ipv6AddressList: + - {} + macAddress: string + name: string + status: string + lastContact: 0 + lastSyncTime: 0 + lastUpdateOn: 0 + location: + address: string + altitude: string + latitude: string + longitude: string + siteId: string + macAddress: string + mode: string + name: string + neighborLinks: + - localInterfaceName: string + localMacAddress: string + localShortInterfaceName: string + remoteDeviceName: string + remoteInterfaceName: string + remoteMacAddress: string + remotePlatform: string + remoteShortInterfaceName: string + remoteVersion: string + onbState: string + pid: string + pnpProfileList: + - createdBy: string + discoveryCreated: true + primaryEndpoint: + certificate: string + fqdn: string + ipv4Address: {} + ipv6Address: {} + port: 0 + protocol: string + profileName: string + secondaryEndpoint: + certificate: string + fqdn: string + ipv4Address: {} + ipv6Address: {} + port: 0 + protocol: string + populateInventory: true + preWorkflowCliOuputs: + - cli: string + cliOutput: string + projectId: string + projectName: string + reloadRequested: true + serialNumber: string + smartAccountId: string + source: string + stack: true + stackInfo: + isFullRing: true + stackMemberList: + - hardwareVersion: string + licenseLevel: string + licenseType: string + macAddress: string + pid: string + priority: 0 + role: string + serialNumber: string + softwareVersion: string + stackNumber: 0 + state: string + sudiSerialNumber: string + stackRingProtocol: string + supportsStackWorkflows: true + totalMemberCount: 0 + validLicenseLevels: + - string + state: string + sudiRequired: true + tags: {} + userSudiSerialNos: + - string + virtualAccountId: string + workflowId: string + workflowName: string + runSummaryList: + - details: string + errorFlag: true + historyTaskInfo: + addnDetails: + - key: string + value: string + name: string + timeTaken: 0 + type: string + workItemList: + - command: string + endTime: 0 + outputStr: string + startTime: 0 + state: string + timeTaken: 0 + timestamp: 0 + systemResetWorkflow: + _id: string + addToInventory: true + addedOn: 0 + configId: string + currTaskIdx: 0 + description: string + endTime: 0 + execTime: 0 + imageId: string + instanceType: string + lastupdateOn: 0 + name: string + startTime: 0 + state: string + tasks: + - currWorkItemIdx: 0 + endTime: 0 + name: string + startTime: 0 + state: string + taskSeqNo: 0 + timeTaken: 0 + type: string + workItemList: + - command: string + endTime: 0 + outputStr: string + startTime: 0 + state: string + timeTaken: 0 + tenantId: string + type: string + useState: string + version: 0 + systemWorkflow: + _id: string + addToInventory: true + addedOn: 0 + configId: string + currTaskIdx: 0 + description: string + endTime: 0 + execTime: 0 + imageId: string + instanceType: string + lastupdateOn: 0 + name: string + startTime: 0 + state: string + tasks: + - currWorkItemIdx: 0 + endTime: 0 + name: string + startTime: 0 + state: string + taskSeqNo: 0 + timeTaken: 0 + type: string + workItemList: + - command: string + endTime: 0 + outputStr: string + startTime: 0 + state: string + timeTaken: 0 + tenantId: string + type: string + useState: string + version: 0 + tenantId: string + version: 0 + workflow: + _id: string + addToInventory: true + addedOn: 0 + configId: string + currTaskIdx: 0 + description: string + endTime: 0 + execTime: 0 + imageId: string + instanceType: string + lastupdateOn: 0 + name: string + startTime: 0 + state: string + tasks: + - currWorkItemIdx: 0 + endTime: 0 + name: string + startTime: 0 + state: string + taskSeqNo: 0 + timeTaken: 0 + type: string + workItemList: + - command: string + endTime: 0 + outputStr: string + startTime: 0 + state: string + timeTaken: 0 + tenantId: string + type: string + useState: string + version: 0 + workflowParameters: + configList: + - configId: string + configParameters: + - key: string + value: string + licenseLevel: string + licenseType: string + topOfStackSerialNumber: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "successList": [ + { + "_id": "string", + "id": "string", + "deviceInfo": { + "source": "string", + "serialNumber": "string", + "stack": true, + "mode": "string", + "state": "string", + "location": { + "siteId": "string", + "address": "string", + "latitude": "string", + "longitude": "string", + "altitude": "string" + }, + "description": "string", + "onbState": "string", + "authenticatedMicNumber": "string", + "authenticatedSudiSerialNo": "string", + "capabilitiesSupported": [ + "string" + ], + "featuresSupported": [ + "string" + ], + "cmState": "string", + "firstContact": 0, + "lastContact": 0, + "macAddress": "string", + "pid": "string", + "deviceSudiSerialNos": [ + "string" + ], + "lastUpdateOn": 0, + "workflowId": "string", + "workflowName": "string", + "projectId": "string", + "projectName": "string", + "deviceType": "string", + "agentType": "string", + "imageVersion": "string", + "fileSystemList": [ + { + "type": "string", + "writeable": true, + "freespace": 0, + "name": "string", + "readable": true, + "size": 0 + } + ], + "pnpProfileList": [ + { + "profileName": "string", + "discoveryCreated": true, + "createdBy": "string", + "primaryEndpoint": { + "port": 0, + "protocol": "string", + "ipv4Address": {}, + "ipv6Address": {}, + "fqdn": "string", + "certificate": "string" + }, + "secondaryEndpoint": { + "port": 0, + "protocol": "string", + "ipv4Address": {}, + "ipv6Address": {}, + "fqdn": "string", + "certificate": "string" + } + } + ], + "imageFile": "string", + "httpHeaders": [ + { + "key": "string", + "value": "string" + } + ], + "neighborLinks": [ + { + "localInterfaceName": "string", + "localShortInterfaceName": "string", + "localMacAddress": "string", + "remoteInterfaceName": "string", + "remoteShortInterfaceName": "string", + "remoteMacAddress": "string", + "remoteDeviceName": "string", + "remotePlatform": "string", + "remoteVersion": "string" + } + ], + "lastSyncTime": 0, + "ipInterfaces": [ + { + "status": "string", + "macAddress": "string", + "ipv4Address": {}, + "ipv6AddressList": [ + {} + ], + "name": "string" + } + ], + "hostname": "string", + "authStatus": "string", + "stackInfo": { + "supportsStackWorkflows": true, + "isFullRing": true, + "stackMemberList": [ + { + "serialNumber": "string", + "state": "string", + "role": "string", + "macAddress": "string", + "pid": "string", + "licenseLevel": "string", + "licenseType": "string", + "sudiSerialNumber": "string", + "hardwareVersion": "string", + "stackNumber": 0, + "softwareVersion": "string", + "priority": 0 + } + ], + "stackRingProtocol": "string", + "validLicenseLevels": [ + "string" + ], + "totalMemberCount": 0 + }, + "reloadRequested": true, + "addedOn": 0, + "siteId": "string", + "aaaCredentials": { + "password": "string", + "username": "string" + }, + "userMicNumbers": [ + "string" + ], + "userSudiSerialNos": [ + "string" + ], + "addnMacAddrs": [ + "string" + ], + "preWorkflowCliOuputs": [ + { + "cli": "string", + "cliOutput": "string" + } + ], + "tags": {}, + "sudiRequired": true, + "smartAccountId": "string", + "virtualAccountId": "string", + "populateInventory": true, + "siteName": "string", + "name": "string" + }, + "systemResetWorkflow": { + "_id": "string", + "state": "string", + "type": "string", + "description": "string", + "lastupdateOn": 0, + "imageId": "string", + "currTaskIdx": 0, + "addedOn": 0, + "tasks": [ + { + "state": "string", + "type": "string", + "currWorkItemIdx": 0, + "taskSeqNo": 0, + "endTime": 0, + "startTime": 0, + "workItemList": [ + { + "state": "string", + "command": "string", + "outputStr": "string", + "endTime": 0, + "startTime": 0, + "timeTaken": 0 + } + ], + "timeTaken": 0, + "name": "string" + } + ], + "addToInventory": true, + "instanceType": "string", + "endTime": 0, + "execTime": 0, + "startTime": 0, + "useState": "string", + "configId": "string", + "name": "string", + "version": 0, + "tenantId": "string" + }, + "systemWorkflow": { + "_id": "string", + "state": "string", + "type": "string", + "description": "string", + "lastupdateOn": 0, + "imageId": "string", + "currTaskIdx": 0, + "addedOn": 0, + "tasks": [ + { + "state": "string", + "type": "string", + "currWorkItemIdx": 0, + "taskSeqNo": 0, + "endTime": 0, + "startTime": 0, + "workItemList": [ + { + "state": "string", + "command": "string", + "outputStr": "string", + "endTime": 0, + "startTime": 0, + "timeTaken": 0 + } + ], + "timeTaken": 0, + "name": "string" + } + ], + "addToInventory": true, + "instanceType": "string", + "endTime": 0, + "execTime": 0, + "startTime": 0, + "useState": "string", + "configId": "string", + "name": "string", + "version": 0, + "tenantId": "string" + }, + "workflow": { + "_id": "string", + "state": "string", + "type": "string", + "description": "string", + "lastupdateOn": 0, + "imageId": "string", + "currTaskIdx": 0, + "addedOn": 0, + "tasks": [ + { + "state": "string", + "type": "string", + "currWorkItemIdx": 0, + "taskSeqNo": 0, + "endTime": 0, + "startTime": 0, + "workItemList": [ + { + "state": "string", + "command": "string", + "outputStr": "string", + "endTime": 0, + "startTime": 0, + "timeTaken": 0 + } + ], + "timeTaken": 0, + "name": "string" + } + ], + "addToInventory": true, + "instanceType": "string", + "endTime": 0, + "execTime": 0, + "startTime": 0, + "useState": "string", + "configId": "string", + "name": "string", + "version": 0, + "tenantId": "string" + }, + "runSummaryList": [ + { + "details": "string", + "historyTaskInfo": { + "type": "string", + "workItemList": [ + { + "state": "string", + "command": "string", + "outputStr": "string", + "endTime": 0, + "startTime": 0, + "timeTaken": 0 + } + ], + "timeTaken": 0, + "addnDetails": [ + { + "key": "string", + "value": "string" + } + ], + "name": "string" + }, + "errorFlag": true, + "timestamp": 0 + } + ], + "workflowParameters": { + "topOfStackSerialNumber": "string", + "licenseLevel": "string", + "licenseType": "string", + "configList": [ + { + "configParameters": [ + { + "key": "string", + "value": "string" + } + ], + "configId": "string" + } + ] + }, + "dayZeroConfig": { + "config": "string" + }, + "dayZeroConfigPreview": {}, + "version": 0, + "tenantId": "string" + } + ], + "failureList": [ + { + "index": 0, + "serialNum": "string", + "id": "string", + "msg": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_device_info.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_info.py new file mode 100644 index 000000000..3f0b11bee --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_info.py @@ -0,0 +1,544 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_device_info +short_description: Information module for Pnp Device +description: +- Get all Pnp Device. +- Get Pnp Device by id. +- Returns device details specified by device id. +- > + Returns list of devices based on filter crieteria. If a limit is not specified, it will default to return 50 + devices. Pagination and sorting are also supported by this endpoint. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + limit: + description: + - Limit query parameter. Limits number of results. + type: int + offset: + description: + - Offset query parameter. Index of first result. + type: int + sort: + description: + - Sort query parameter. Comma seperated list of fields to sort on. + elements: str + type: list + sortOrder: + description: + - SortOrder query parameter. Sort Order Ascending (asc) or Descending (des). + type: str + serialNumber: + description: + - SerialNumber query parameter. Device Serial Number. + elements: str + type: list + state_: + description: + - State query parameter. Device State. + elements: str + type: list + onbState: + description: + - OnbState query parameter. Device Onboarding State. + elements: str + type: list + cmState: + description: + - CmState query parameter. Device Connection Manager State. + elements: str + type: list + name: + description: + - Name query parameter. Device Name. + elements: str + type: list + pid: + description: + - Pid query parameter. Device ProductId. + elements: str + type: list + source: + description: + - Source query parameter. Device Source. + elements: str + type: list + projectId: + description: + - ProjectId query parameter. Device Project Id. + elements: str + type: list + workflowId: + description: + - WorkflowId query parameter. Device Workflow Id. + elements: str + type: list + projectName: + description: + - ProjectName query parameter. Device Project Name. + elements: str + type: list + workflowName: + description: + - WorkflowName query parameter. Device Workflow Name. + elements: str + type: list + smartAccountId: + description: + - SmartAccountId query parameter. Device Smart Account. + elements: str + type: list + virtualAccountId: + description: + - VirtualAccountId query parameter. Device Virtual Account. + elements: str + type: list + lastContact: + description: + - LastContact query parameter. Device Has Contacted lastContact > 0. + type: bool + macAddress: + description: + - MacAddress query parameter. Device Mac Address. + type: str + hostname: + description: + - Hostname query parameter. Device Hostname. + type: str + siteName: + description: + - SiteName query parameter. Device Site Name. + type: str + id: + description: + - Id path parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) GetDeviceById + description: Complete reference of the GetDeviceById API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-by-id +- name: Cisco DNA Center documentation for Device Onboarding (PnP) GetDeviceList2 + description: Complete reference of the GetDeviceList2 API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-list-2 +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.get_device_by_id, + device_onboarding_pnp.DeviceOnboardingPnp.get_device_list, + + - Paths used are + get /dna/intent/api/v1/onboarding/pnp-device, + get /dna/intent/api/v1/onboarding/pnp-device/{id}, + +""" + +EXAMPLES = r""" +- name: Get all Pnp Device + cisco.dnac.pnp_device_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + limit: 0 + offset: 0 + sort: [] + sortOrder: string + serialNumber: [] + state_: [] + onbState: [] + cmState: [] + name: [] + pid: [] + source: [] + projectId: [] + workflowId: [] + projectName: [] + workflowName: [] + smartAccountId: [] + virtualAccountId: [] + lastContact: True + macAddress: string + hostname: string + siteName: string + register: result + +- name: Get Pnp Device by id + cisco.dnac.pnp_device_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "_id": "string", + "deviceInfo": { + "source": "string", + "serialNumber": "string", + "stack": true, + "mode": "string", + "state": "string", + "location": { + "siteId": "string", + "address": "string", + "latitude": "string", + "longitude": "string", + "altitude": "string" + }, + "description": "string", + "onbState": "string", + "authenticatedMicNumber": "string", + "authenticatedSudiSerialNo": "string", + "capabilitiesSupported": [ + "string" + ], + "featuresSupported": [ + "string" + ], + "cmState": "string", + "firstContact": 0, + "lastContact": 0, + "macAddress": "string", + "pid": "string", + "deviceSudiSerialNos": [ + "string" + ], + "lastUpdateOn": 0, + "workflowId": "string", + "workflowName": "string", + "projectId": "string", + "projectName": "string", + "deviceType": "string", + "agentType": "string", + "imageVersion": "string", + "fileSystemList": [ + { + "type": "string", + "writeable": true, + "freespace": 0, + "name": "string", + "readable": true, + "size": 0 + } + ], + "pnpProfileList": [ + { + "profileName": "string", + "discoveryCreated": true, + "createdBy": "string", + "primaryEndpoint": { + "port": 0, + "protocol": "string", + "ipv4Address": {}, + "ipv6Address": {}, + "fqdn": "string", + "certificate": "string" + }, + "secondaryEndpoint": { + "port": 0, + "protocol": "string", + "ipv4Address": {}, + "ipv6Address": {}, + "fqdn": "string", + "certificate": "string" + } + } + ], + "imageFile": "string", + "httpHeaders": [ + { + "key": "string", + "value": "string" + } + ], + "neighborLinks": [ + { + "localInterfaceName": "string", + "localShortInterfaceName": "string", + "localMacAddress": "string", + "remoteInterfaceName": "string", + "remoteShortInterfaceName": "string", + "remoteMacAddress": "string", + "remoteDeviceName": "string", + "remotePlatform": "string", + "remoteVersion": "string" + } + ], + "lastSyncTime": 0, + "ipInterfaces": [ + { + "status": "string", + "macAddress": "string", + "ipv4Address": {}, + "ipv6AddressList": [ + {} + ], + "name": "string" + } + ], + "hostname": "string", + "authStatus": "string", + "stackInfo": { + "supportsStackWorkflows": true, + "isFullRing": true, + "stackMemberList": [ + { + "serialNumber": "string", + "state": "string", + "role": "string", + "macAddress": "string", + "pid": "string", + "licenseLevel": "string", + "licenseType": "string", + "sudiSerialNumber": "string", + "hardwareVersion": "string", + "stackNumber": 0, + "softwareVersion": "string", + "priority": 0 + } + ], + "stackRingProtocol": "string", + "validLicenseLevels": [ + "string" + ], + "totalMemberCount": 0 + }, + "reloadRequested": true, + "addedOn": 0, + "siteId": "string", + "aaaCredentials": { + "password": "string", + "username": "string" + }, + "userMicNumbers": [ + "string" + ], + "userSudiSerialNos": [ + "string" + ], + "addnMacAddrs": [ + "string" + ], + "preWorkflowCliOuputs": [ + { + "cli": "string", + "cliOutput": "string" + } + ], + "tags": {}, + "sudiRequired": true, + "smartAccountId": "string", + "virtualAccountId": "string", + "populateInventory": true, + "siteName": "string", + "name": "string" + }, + "systemResetWorkflow": { + "_id": "string", + "state": "string", + "type": "string", + "description": "string", + "lastupdateOn": 0, + "imageId": "string", + "currTaskIdx": 0, + "addedOn": 0, + "tasks": [ + { + "state": "string", + "type": "string", + "currWorkItemIdx": 0, + "taskSeqNo": 0, + "endTime": 0, + "startTime": 0, + "workItemList": [ + { + "state": "string", + "command": "string", + "outputStr": "string", + "endTime": 0, + "startTime": 0, + "timeTaken": 0 + } + ], + "timeTaken": 0, + "name": "string" + } + ], + "addToInventory": true, + "instanceType": "string", + "endTime": 0, + "execTime": 0, + "startTime": 0, + "useState": "string", + "configId": "string", + "name": "string", + "version": 0, + "tenantId": "string" + }, + "systemWorkflow": { + "_id": "string", + "state": "string", + "type": "string", + "description": "string", + "lastupdateOn": 0, + "imageId": "string", + "currTaskIdx": 0, + "addedOn": 0, + "tasks": [ + { + "state": "string", + "type": "string", + "currWorkItemIdx": 0, + "taskSeqNo": 0, + "endTime": 0, + "startTime": 0, + "workItemList": [ + { + "state": "string", + "command": "string", + "outputStr": "string", + "endTime": 0, + "startTime": 0, + "timeTaken": 0 + } + ], + "timeTaken": 0, + "name": "string" + } + ], + "addToInventory": true, + "instanceType": "string", + "endTime": 0, + "execTime": 0, + "startTime": 0, + "useState": "string", + "configId": "string", + "name": "string", + "version": 0, + "tenantId": "string" + }, + "workflow": { + "_id": "string", + "state": "string", + "type": "string", + "description": "string", + "lastupdateOn": 0, + "imageId": "string", + "currTaskIdx": 0, + "addedOn": 0, + "tasks": [ + { + "state": "string", + "type": "string", + "currWorkItemIdx": 0, + "taskSeqNo": 0, + "endTime": 0, + "startTime": 0, + "workItemList": [ + { + "state": "string", + "command": "string", + "outputStr": "string", + "endTime": 0, + "startTime": 0, + "timeTaken": 0 + } + ], + "timeTaken": 0, + "name": "string" + } + ], + "addToInventory": true, + "instanceType": "string", + "endTime": 0, + "execTime": 0, + "startTime": 0, + "useState": "string", + "configId": "string", + "name": "string", + "version": 0, + "tenantId": "string" + }, + "runSummaryList": [ + { + "details": "string", + "historyTaskInfo": { + "type": "string", + "workItemList": [ + { + "state": "string", + "command": "string", + "outputStr": "string", + "endTime": 0, + "startTime": 0, + "timeTaken": 0 + } + ], + "timeTaken": 0, + "addnDetails": [ + { + "key": "string", + "value": "string" + } + ], + "name": "string" + }, + "errorFlag": true, + "timestamp": 0 + } + ], + "workflowParameters": { + "topOfStackSerialNumber": "string", + "licenseLevel": "string", + "licenseType": "string", + "configList": [ + { + "configParameters": [ + { + "key": "string", + "value": "string" + } + ], + "configId": "string" + } + ] + }, + "dayZeroConfig": { + "config": "string" + }, + "dayZeroConfigPreview": {}, + "version": 0, + "tenantId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_device_reset.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_reset.py new file mode 100644 index 000000000..97d079c49 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_reset.py @@ -0,0 +1,116 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_device_reset +short_description: Resource module for Pnp Device Reset +description: +- Manage operation create of the resource Pnp Device Reset. +- Recovers a device from a Workflow Execution Error state. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + deviceResetList: + description: Pnp Device Reset's deviceResetList. + elements: dict + suboptions: + configList: + description: Pnp Device Reset's configList. + elements: dict + suboptions: + configId: + description: Pnp Device Reset's configId. + type: str + configParameters: + description: Pnp Device Reset's configParameters. + elements: dict + suboptions: + key: + description: Pnp Device Reset's key. + type: str + value: + description: Pnp Device Reset's value. + type: str + type: list + type: list + deviceId: + description: Pnp Device Reset's deviceId. + type: str + licenseLevel: + description: Pnp Device Reset's licenseLevel. + type: str + licenseType: + description: Pnp Device Reset's licenseType. + type: str + topOfStackSerialNumber: + description: Pnp Device Reset's topOfStackSerialNumber. + type: str + type: list + projectId: + description: Pnp Device Reset's projectId. + type: str + workflowId: + description: Pnp Device Reset's workflowId. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) ResetDevice + description: Complete reference of the ResetDevice API. + link: https://developer.cisco.com/docs/dna-center/#!reset-device +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.reset_device, + + - Paths used are + post /dna/intent/api/v1/onboarding/pnp-device/reset, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.pnp_device_reset: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + deviceResetList: + - configList: + - configId: string + configParameters: + - key: string + value: string + deviceId: string + licenseLevel: string + licenseType: string + topOfStackSerialNumber: string + projectId: string + workflowId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "jsonArrayResponse": [ + {} + ], + "jsonResponse": {}, + "message": "string", + "statusCode": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_device_unclaim.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_unclaim.py new file mode 100644 index 000000000..a1212a688 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_device_unclaim.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_device_unclaim +short_description: Resource module for Pnp Device Unclaim +description: +- Manage operation create of the resource Pnp Device Unclaim. +- Un-Claims one of more devices with specified workflow. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + deviceIdList: + description: Pnp Device Unclaim's deviceIdList. + elements: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) UnClaimDevice + description: Complete reference of the UnClaimDevice API. + link: https://developer.cisco.com/docs/dna-center/#!un-claim-device +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.un_claim_device, + + - Paths used are + post /dna/intent/api/v1/onboarding/pnp-device/unclaim, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.pnp_device_unclaim: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + deviceIdList: + - string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "jsonArrayResponse": [ + {} + ], + "jsonResponse": {}, + "message": "string", + "statusCode": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_global_settings.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_global_settings.py new file mode 100644 index 000000000..fa5ff41b8 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_global_settings.py @@ -0,0 +1,305 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_global_settings +short_description: Resource module for Pnp Global Settings +description: +- Manage operation update of the resource Pnp Global Settings. +- Updates the user's list of global PnP settings. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + _id: + description: Pnp Global Settings's _id. + type: str + aaaCredentials: + description: Pnp Global Settings's aaaCredentials. + suboptions: + password: + description: Pnp Global Settings's password. + type: str + username: + description: Pnp Global Settings's username. + type: str + type: dict + acceptEula: + description: AcceptEula flag. + type: bool + defaultProfile: + description: Pnp Global Settings's defaultProfile. + suboptions: + cert: + description: Pnp Global Settings's cert. + type: str + fqdnAddresses: + description: Pnp Global Settings's fqdnAddresses. + elements: str + type: list + ipAddresses: + description: Pnp Global Settings's ipAddresses. + elements: str + type: list + port: + description: Pnp Global Settings's port. + type: int + proxy: + description: Proxy flag. + type: bool + type: dict + savaMappingList: + description: Pnp Global Settings's savaMappingList. + elements: dict + suboptions: + autoSyncPeriod: + description: Pnp Global Settings's autoSyncPeriod. + type: int + ccoUser: + description: Pnp Global Settings's ccoUser. + type: str + expiry: + description: Pnp Global Settings's expiry. + type: int + lastSync: + description: Pnp Global Settings's lastSync. + type: int + profile: + description: Pnp Global Settings's profile. + suboptions: + addressFqdn: + description: Pnp Global Settings's addressFqdn. + type: str + addressIpV4: + description: Pnp Global Settings's addressIpV4. + type: str + cert: + description: Pnp Global Settings's cert. + type: str + makeDefault: + description: MakeDefault flag. + type: bool + name: + description: Pnp Global Settings's name. + type: str + port: + description: Pnp Global Settings's port. + type: int + profileId: + description: Pnp Global Settings's profileId. + type: str + proxy: + description: Proxy flag. + type: bool + type: dict + smartAccountId: + description: Pnp Global Settings's smartAccountId. + type: str + syncResult: + description: Pnp Global Settings's syncResult. + suboptions: + syncList: + description: Pnp Global Settings's syncList. + elements: dict + suboptions: + deviceSnList: + description: Pnp Global Settings's deviceSnList. + elements: str + type: list + syncType: + description: Pnp Global Settings's syncType. + type: str + type: list + syncMsg: + description: Pnp Global Settings's syncMsg. + type: str + type: dict + syncResultStr: + description: Pnp Global Settings's syncResultStr. + type: str + syncStartTime: + description: Pnp Global Settings's syncStartTime. + type: int + syncStatus: + description: Pnp Global Settings's syncStatus. + type: str + tenantId: + description: Pnp Global Settings's tenantId. + type: str + token: + description: Pnp Global Settings's token. + type: str + virtualAccountId: + description: Pnp Global Settings's virtualAccountId. + type: str + type: list + taskTimeOuts: + description: Pnp Global Settings's taskTimeOuts. + suboptions: + configTimeOut: + description: Pnp Global Settings's configTimeOut. + type: int + generalTimeOut: + description: Pnp Global Settings's generalTimeOut. + type: int + imageDownloadTimeOut: + description: Pnp Global Settings's imageDownloadTimeOut. + type: int + type: dict + tenantId: + description: Pnp Global Settings's tenantId. + type: str + version: + description: Pnp Global Settings's version. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) UpdatePnPGlobalSettings + description: Complete reference of the UpdatePnPGlobalSettings API. + link: https://developer.cisco.com/docs/dna-center/#!update-pn-p-global-settings +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.update_pnp_global_settings, + + - Paths used are + put /dna/intent/api/v1/onboarding/pnp-settings, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.pnp_global_settings: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + _id: string + aaaCredentials: + password: string + username: string + acceptEula: true + defaultProfile: + cert: string + fqdnAddresses: + - string + ipAddresses: + - string + port: 0 + proxy: true + savaMappingList: + - autoSyncPeriod: 0 + ccoUser: string + expiry: 0 + lastSync: 0 + profile: + addressFqdn: string + addressIpV4: string + cert: string + makeDefault: true + name: string + port: 0 + profileId: string + proxy: true + smartAccountId: string + syncResult: + syncList: + - deviceSnList: + - string + syncType: string + syncMsg: string + syncResultStr: string + syncStartTime: 0 + syncStatus: string + tenantId: string + token: string + virtualAccountId: string + taskTimeOuts: + configTimeOut: 0 + generalTimeOut: 0 + imageDownloadTimeOut: 0 + tenantId: string + version: 0 + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "savaMappingList": [ + { + "syncStatus": "string", + "syncStartTime": 0, + "syncResult": { + "syncList": [ + { + "syncType": "string", + "deviceSnList": [ + "string" + ] + } + ], + "syncMsg": "string" + }, + "lastSync": 0, + "tenantId": "string", + "profile": { + "port": 0, + "addressIpV4": "string", + "addressFqdn": "string", + "profileId": "string", + "proxy": true, + "makeDefault": true, + "cert": "string", + "name": "string" + }, + "token": "string", + "expiry": 0, + "ccoUser": "string", + "smartAccountId": "string", + "virtualAccountId": "string", + "autoSyncPeriod": 0, + "syncResultStr": "string" + } + ], + "taskTimeOuts": { + "imageDownloadTimeOut": 0, + "configTimeOut": 0, + "generalTimeOut": 0 + }, + "tenantId": "string", + "aaaCredentials": { + "password": "string", + "username": "string" + }, + "defaultProfile": { + "fqdnAddresses": [ + "string" + ], + "proxy": true, + "cert": "string", + "ipAddresses": [ + "string" + ], + "port": 0 + }, + "acceptEula": true, + "id": "string", + "_id": "string", + "version": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_global_settings_info.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_global_settings_info.py new file mode 100644 index 000000000..9347be595 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_global_settings_info.py @@ -0,0 +1,122 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_global_settings_info +short_description: Information module for Pnp Global Settings +description: +- Get all Pnp Global Settings. +- Returns global PnP settings of the user. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) GetPnPGlobalSettings + description: Complete reference of the GetPnPGlobalSettings API. + link: https://developer.cisco.com/docs/dna-center/#!get-pn-p-global-settings +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.get_pnp_global_settings, + + - Paths used are + get /dna/intent/api/v1/onboarding/pnp-settings, + +""" + +EXAMPLES = r""" +- name: Get all Pnp Global Settings + cisco.dnac.pnp_global_settings_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "savaMappingList": [ + { + "syncStatus": "string", + "syncStartTime": 0, + "syncResult": { + "syncList": [ + { + "syncType": "string", + "deviceSnList": [ + "string" + ] + } + ], + "syncMsg": "string" + }, + "lastSync": 0, + "tenantId": "string", + "profile": { + "port": 0, + "addressIpV4": "string", + "addressFqdn": "string", + "profileId": "string", + "proxy": true, + "makeDefault": true, + "cert": "string", + "name": "string" + }, + "token": "string", + "expiry": 0, + "ccoUser": "string", + "smartAccountId": "string", + "virtualAccountId": "string", + "autoSyncPeriod": 0, + "syncResultStr": "string" + } + ], + "taskTimeOuts": { + "imageDownloadTimeOut": 0, + "configTimeOut": 0, + "generalTimeOut": 0 + }, + "tenantId": "string", + "aaaCredentials": { + "password": "string", + "username": "string" + }, + "defaultProfile": { + "fqdnAddresses": [ + "string" + ], + "proxy": true, + "cert": "string", + "ipAddresses": [ + "string" + ], + "port": 0 + }, + "acceptEula": true, + "id": "string", + "_id": "string", + "version": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_intent.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_intent.py new file mode 100644 index 000000000..02c89721a --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_intent.py @@ -0,0 +1,955 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2022, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +__author__ = ("Madhan Sankaranarayanan, Rishita Chowdhary") + +DOCUMENTATION = r""" +--- +module: pnp_intent +short_description: Resource module for Site and PnP related functions +description: +- Manage operations add device, claim device and unclaim device of Onboarding Configuration(PnP) resource +- API to add device to pnp inventory and claim it to a site. +- API to delete device from the pnp inventory. +version_added: '6.6.0' +extends_documentation_fragment: + - cisco.dnac.intent_params +author: Madhan Sankaranarayanan (@madhansansel) + Rishita Chowdhary (@rishitachowdhary) +options: + state: + description: The state of DNAC after module completion. + type: str + choices: [ merged, deleted ] + default: merged + config: + description: + - List of details of device being managed. + type: list + elements: dict + required: true + suboptions: + template_name: + description: Name of template to be configured on the device. + type: str + image_name: + description: Name of image to be configured on the device + type: str + golden_image: + description: Is the image to be condifgured tagged as golden image + type: bool + site_name: + description: Name of the site for which device will be claimed. + type: str + deviceInfo: + description: Pnp Device's deviceInfo. + type: dict + suboptions: + aaaCredentials: + description: Pnp Device's aaaCredentials. + type: dict + suboptions: + password: + description: Pnp Device's password. + type: str + username: + description: Pnp Device's username. + type: str + addedOn: + description: Pnp Device's addedOn. + type: int + addnMacAddrs: + description: Pnp Device's addnMacAddrs. + elements: str + type: list + agentType: + description: Pnp Device's agentType. + type: str + authStatus: + description: Pnp Device's authStatus. + type: str + authenticatedSudiSerialNo: + description: Pnp Device's authenticatedSudiSerialNo. + type: str + capabilitiesSupported: + description: Pnp Device's capabilitiesSupported. + elements: str + type: list + cmState: + description: Pnp Device's cmState. + type: str + description: + description: Pnp Device's description. + type: str + deviceSudiSerialNos: + description: Pnp Device's deviceSudiSerialNos. + elements: str + type: list + deviceType: + description: Pnp Device's deviceType. + type: str + featuresSupported: + description: Pnp Device's featuresSupported. + elements: str + type: list + fileSystemList: + description: Pnp Device's fileSystemList. + type: list + elements: dict + suboptions: + freespace: + description: Pnp Device's freespace. + type: int + name: + description: Pnp Device's name. + type: str + readable: + description: Readable flag. + type: bool + size: + description: Pnp Device's size. + type: int + type: + description: Pnp Device's type. + type: str + writeable: + description: Writeable flag. + type: bool + firstContact: + description: Pnp Device's firstContact. + type: int + hostname: + description: Pnp Device's hostname. + type: str + httpHeaders: + description: Pnp Device's httpHeaders. + type: list + elements: dict + suboptions: + key: + description: Pnp Device's key. + type: str + value: + description: Pnp Device's value. + type: str + imageFile: + description: Pnp Device's imageFile. + type: str + imageVersion: + description: Pnp Device's imageVersion. + type: str + ipInterfaces: + description: Pnp Device's ipInterfaces. + elements: dict + type: list + suboptions: + ipv4Address: + description: Pnp Device's ipv4Address. + type: dict + ipv6AddressList: + description: Pnp Device's ipv6AddressList. + elements: dict + type: list + macAddress: + description: Pnp Device's macAddress. + type: str + name: + description: Pnp Device's name. + type: str + status: + description: Pnp Device's status. + type: str + lastContact: + description: Pnp Device's lastContact. + type: int + lastSyncTime: + description: Pnp Device's lastSyncTime. + type: int + lastUpdateOn: + description: Pnp Device's lastUpdateOn. + type: int + location: + description: Pnp Device's location. + type: dict + suboptions: + address: + description: Pnp Device's address. + type: str + altitude: + description: Pnp Device's altitude. + type: str + latitude: + description: Pnp Device's latitude. + type: str + longitude: + description: Pnp Device's longitude. + type: str + siteId: + description: Pnp Device's siteId. + type: str + macAddress: + description: Pnp Device's macAddress. + type: str + mode: + description: Pnp Device's mode. + type: str + name: + description: Pnp Device's name. + type: str + neighborLinks: + description: Pnp Device's neighborLinks. + type: list + elements: dict + suboptions: + localInterfaceName: + description: Pnp Device's localInterfaceName. + type: str + localMacAddress: + description: Pnp Device's localMacAddress. + type: str + localShortInterfaceName: + description: Pnp Device's localShortInterfaceName. + type: str + remoteDeviceName: + description: Pnp Device's remoteDeviceName. + type: str + remoteInterfaceName: + description: Pnp Device's remoteInterfaceName. + type: str + remoteMacAddress: + description: Pnp Device's remoteMacAddress. + type: str + remotePlatform: + description: Pnp Device's remotePlatform. + type: str + remoteShortInterfaceName: + description: Pnp Device's remoteShortInterfaceName. + type: str + remoteVersion: + description: Pnp Device's remoteVersion. + type: str + onbState: + description: Pnp Device's onbState. + type: str + pid: + description: Pnp Device's pid. + type: str + pnpProfileList: + description: Pnp Device's pnpProfileList. + type: list + elements: dict + suboptions: + createdBy: + description: Pnp Device's createdBy. + type: str + discoveryCreated: + description: DiscoveryCreated flag. + type: bool + primaryEndpoint: + description: Pnp Device's primaryEndpoint. + type: dict + suboptions: + certificate: + description: Pnp Device's certificate. + type: str + fqdn: + description: Pnp Device's fqdn. + type: str + ipv4Address: + description: Pnp Device's ipv4Address. + type: dict + ipv6Address: + description: Pnp Device's ipv6Address. + type: dict + port: + description: Pnp Device's port. + type: int + protocol: + description: Pnp Device's protocol. + type: str + profileName: + description: Pnp Device's profileName. + type: str + secondaryEndpoint: + description: Pnp Device's secondaryEndpoint. + type: dict + suboptions: + certificate: + description: Pnp Device's certificate. + type: str + fqdn: + description: Pnp Device's fqdn. + type: str + ipv4Address: + description: Pnp Device's ipv4Address. + type: dict + ipv6Address: + description: Pnp Device's ipv6Address. + type: dict + port: + description: Pnp Device's port. + type: int + protocol: + description: Pnp Device's protocol. + type: str + populateInventory: + description: PopulateInventory flag. + type: bool + preWorkflowCliOuputs: + description: Pnp Device's preWorkflowCliOuputs. + type: list + elements: dict + suboptions: + cli: + description: Pnp Device's cli. + type: str + cliOutput: + description: Pnp Device's cliOutput. + type: str + projectId: + description: Pnp Device's projectId. + type: str + projectName: + description: Pnp Device's projectName. + type: str + reloadRequested: + description: ReloadRequested flag. + type: bool + serialNumber: + description: Pnp Device's serialNumber. + type: str + smartAccountId: + description: Pnp Device's smartAccountId. + type: str + source: + description: Pnp Device's source. + type: str + stack: + description: Stack flag. + type: bool + stackInfo: + description: Pnp Device's stackInfo. + type: dict + suboptions: + isFullRing: + description: IsFullRing flag. + type: bool + stackMemberList: + description: Pnp Device's stackMemberList. + type: list + elements: dict + suboptions: + hardwareVersion: + description: Pnp Device's hardwareVersion. + type: str + licenseLevel: + description: Pnp Device's licenseLevel. + type: str + licenseType: + description: Pnp Device's licenseType. + type: str + macAddress: + description: Pnp Device's macAddress. + type: str + pid: + description: Pnp Device's pid. + type: str + priority: + description: Pnp Device's priority. + type: int + role: + description: Pnp Device's role. + type: str + serialNumber: + description: Pnp Device's serialNumber. + type: str + softwareVersion: + description: Pnp Device's softwareVersion. + type: str + stackNumber: + description: Pnp Device's stackNumber. + type: int + state: + description: Pnp Device's state. + type: str + sudiSerialNumber: + description: Pnp Device's sudiSerialNumber. + type: str + stackRingProtocol: + description: Pnp Device's stackRingProtocol. + type: str + supportsStackWorkflows: + description: SupportsStackWorkflows flag. + type: bool + totalMemberCount: + description: Pnp Device's totalMemberCount. + type: int + validLicenseLevels: + description: Pnp Device's validLicenseLevels. + type: str + state: + description: Pnp Device's state. + type: str + sudiRequired: + description: SudiRequired flag. + type: bool + tags: + description: Pnp Device's tags. + type: dict + userSudiSerialNos: + description: Pnp Device's userSudiSerialNos. + elements: str + type: list + virtualAccountId: + description: Pnp Device's virtualAccountId. + type: str + workflowId: + description: Pnp Device's workflowId. + type: str + workflowName: + description: Pnp Device's workflowName. + type: str + +requirements: +- dnacentersdk == 2.4.5 +- python >= 3.5 +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.add_device, + device_onboarding_pnp.DeviceOnboardingPnp.claim_a_device_to_a_site, + device_onboarding_pnp.DeviceOnboardingPnp.delete_device_by_id_from_pnp, + + - Paths used are + post /dna/intent/api/v1/onboarding/pnp-device + post /dna/intent/api/v1/onboarding/pnp-device/site-claim + post /dna/intent/api/v1/onboarding/pnp-device/{id} + +""" + +EXAMPLES = r""" +- name: Add a new device and claim the device + cisco.dnac.pnp_intent: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + dnac_log: True + state: merged + config: + template_name: string + image_name: string + site_name: string + deviceInfo: + aaaCredentials: + password: string + username: string + addedOn: 0 + addnMacAddrs: + - string + agentType: string + authStatus: string + authenticatedSudiSerialNo: string + capabilitiesSupported: + - string + cmState: string + description: string + deviceSudiSerialNos: + - string + deviceType: string + featuresSupported: + - string + fileSystemList: + - freespace: 0 + name: string + readable: true + size: 0 + type: string + writeable: true + firstContact: 0 + hostname: string + httpHeaders: + - key: string + value: string + imageFile: string + imageVersion: string + ipInterfaces: + - ipv4Address: {} + ipv6AddressList: + - {} + macAddress: string + name: string + status: string + lastContact: 0 + lastSyncTime: 0 + lastUpdateOn: 0 + location: + address: string + altitude: string + latitude: string + longitude: string + siteId: string + macAddress: string + mode: string + name: string + neighborLinks: + - localInterfaceName: string + localMacAddress: string + localShortInterfaceName: string + remoteDeviceName: string + remoteInterfaceName: string + remoteMacAddress: string + remotePlatform: string + remoteShortInterfaceName: string + remoteVersion: string + onbState: string + pid: string + pnpProfileList: + - createdBy: string + discoveryCreated: true + primaryEndpoint: + certificate: string + fqdn: string + ipv4Address: {} + ipv6Address: {} + port: 0 + protocol: string + profileName: string + secondaryEndpoint: + certificate: string + fqdn: string + ipv4Address: {} + ipv6Address: {} + port: 0 + protocol: string + populateInventory: true + preWorkflowCliOuputs: + - cli: string + cliOutput: string + projectId: string + projectName: string + reloadRequested: true + serialNumber: string + smartAccountId: string + source: string + stack: true + stackInfo: + isFullRing: true + stackMemberList: + - hardwareVersion: string + licenseLevel: string + licenseType: string + macAddress: string + pid: string + priority: 0 + role: string + serialNumber: string + softwareVersion: string + stackNumber: 0 + state: string + sudiSerialNumber: string + stackRingProtocol: string + supportsStackWorkflows: true + totalMemberCount: 0 + validLicenseLevels: string + state: string + sudiRequired: true + tags: {} + userSudiSerialNos: + - string + virtualAccountId: string + workflowId: string + workflowName: string +""" + +RETURN = r""" +#Case_1: When the device is claimed successfully. +response_1: + description: A dictionary with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": + { + "response": String, + "version": String + }, + "msg": String + } + +#Case_2: Given site/image/template/project not found or Device is not found for deletion +response_2: + description: A list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + sample: > + { + "response": [], + "msg": String + } + +#Case_3: Error while deleting/claiming a device +response_3: + description: A string with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": String, + "msg": String + } +""" + +import copy +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DNACSDK, + validate_list_of_dicts, + log, + get_dict_result, +) + + +class DnacPnp: + def __init__(self, module): + self.module = module + self.params = module.params + self.config = copy.deepcopy(module.params.get("config")) + self.have = [] + self.want = [] + self.diff = [] + self.validated = [] + dnac_params = self.get_dnac_params(self.params) + log(str(dnac_params)) + self.dnac = DNACSDK(params=dnac_params) + self.log = dnac_params.get("dnac_log") + + self.result = dict(changed=False, diff=[], response=[], warnings=[]) + + def get_state(self): + return self.params.get("state") + + def validate_input(self): + pnp_spec = dict( + template_name=dict(required=True, type='str'), + project_name=dict(required=False, type='str', default="Onboarding Configuration"), + site_name=dict(required=True, type='str'), + image_name=dict(required=True, type='str'), + golden_image=dict(required=False, type='bool'), + deviceInfo=dict(required=True, type='dict'), + pnp_type=dict(required=False, type=str, default="Default") + ) + + if self.config: + msg = None + + # Validate template params + if self.log: + log(str(self.config)) + valid_pnp, invalid_params = validate_list_of_dicts( + self.config, pnp_spec + ) + + if invalid_params: + msg = "Invalid parameters in playbook: {0}".format( + "\n".join(invalid_params) + ) + self.module.fail_json(msg=msg) + + self.validated = valid_pnp + + if self.log: + log(str(valid_pnp)) + log(str(self.validated)) + + def get_dnac_params(self, params): + dnac_params = dict( + dnac_host=params.get("dnac_host"), + dnac_port=params.get("dnac_port"), + dnac_username=params.get("dnac_username"), + dnac_password=params.get("dnac_password"), + dnac_verify=params.get("dnac_verify"), + dnac_debug=params.get("dnac_debug"), + dnac_log=params.get("dnac_log") + ) + return dnac_params + + def site_exists(self): + site_exists = False + site_id = None + response = None + try: + response = self.dnac._exec( + family="sites", + function='get_site', + params={"name": self.want.get("site_name")}, + ) + except Exception as e: + self.module.fail_json(msg="Site not found", response=[]) + + if response: + if self.log: + log(str(response)) + + site = response.get("response") + site_id = site[0].get("id") + site_exists = True + + return (site_exists, site_id) + + def get_pnp_params(self, params): + pnp_params = {} + pnp_params['_id'] = params.get('_id') + pnp_params['deviceInfo'] = params.get('deviceInfo') + pnp_params['runSummaryList'] = params.get('runSummaryList') + pnp_params['systemResetWorkflow'] = params.get('systemResetWorkflow') + pnp_params['systemWorkflow'] = params.get('systemWorkflow') + pnp_params['tenantId'] = params.get('tenantId') + pnp_params['version'] = params.get('device_version') + pnp_params['workflow'] = params.get('workflow') + pnp_params['workflowParameters'] = params.get('workflowParameters') + + return pnp_params + + def get_image_params(self, params): + image_params = dict( + image_name=params.get("image_name"), + is_tagged_golden=params.get("golden_image"), + ) + + return image_params + + def get_claim_params(self): + imageinfo = dict( + imageId=self.have.get("image_id") + ) + configinfo = dict( + configId=self.have.get("template_id"), + configParameters=[dict( + key="", + value="" + )] + ) + claim_params = dict( + deviceId=self.have.get("device_id"), + siteId=self.have.get("site_id"), + type=self.want.get("pnp_type"), + hostname=self.want.get("hostname"), + imageInfo=imageinfo, + configInfo=configinfo, + ) + + return claim_params + + def get_have(self): + have = {} + + if self.params.get("state") == "merged": + # check if given image exists, if exists store image_id + image_response = self.dnac._exec( + family="software_image_management_swim", + function='get_software_image_details', + params=self.want.get("image_params"), + ) + + if self.log: + log(str(image_response)) + + image_list = image_response.get("response") + + if len(image_list) == 1: + have["image_id"] = image_list[0].get("imageUuid") + if self.log: + log("Image Id: " + str(have["image_id"])) + else: + self.module.fail_json(msg="Image not found", response=[]) + + # check if given template exists, if exists store template id + template_list = self.dnac._exec( + family="configuration_templates", + function='gets_the_templates_available', + params={"project_names": self.want.get("project_name")}, + ) + + if self.log: + log(str(template_list)) + + if template_list and isinstance(template_list, list): + # API execution error returns a dict + template_details = get_dict_result(template_list, 'name', self.want.get("template_name")) + if template_details: + have["template_id"] = template_details.get("templateId") + + if self.log: + log("Template Id: " + str(have["template_id"])) + else: + self.module.fail_json(msg="Template not found", response=[]) + else: + self.module.fail_json(msg="Project Not Found", response=[]) + + # check if given site exits, if exists store current site info + site_name = self.want.get("site_name") + + site_exists = False + (site_exists, site_id) = self.site_exists() + + if site_exists: + have["site_id"] = site_id + if self.log: + log("Site Exists: " + str(site_exists) + "\n Site_id:" + str(site_id)) + log("Site Name:" + str(site_name)) + + # check if given device exists in pnp inventory, store device Id + device_response = self.dnac._exec( + family="device_onboarding_pnp", + function='get_device_list', + params={"serial_number": self.want.get("serial_number")} + ) + + if self.log: + log(str(device_response)) + + if device_response and (len(device_response) == 1): + have["device_id"] = device_response[0].get("id") + have["device_found"] = True + + if self.log: + log("Device Id: " + str(have["device_id"])) + else: + have["device_found"] = False + + self.have = have + + def get_want(self): + for params in self.validated: + want = dict( + image_params=self.get_image_params(params), + pnp_params=self.get_pnp_params(params), + pnp_type=params.get("pnp_type"), + site_name=params.get("site_name"), + serial_number=params.get("deviceInfo").get("serialNumber"), + hostname=params.get("deviceInfo").get("hostname"), + project_name=params.get("project_name"), + template_name=params.get("template_name") + ) + + self.want = want + + def get_diff_merge(self): + + # if given device doesnot exist then add it to pnp database and get the device id + if not self.have.get("device_found"): + log("Adding device to pnp database") + response = self.dnac._exec( + family="device_onboarding_pnp", + function="add_device", + params=self.want.get("pnp_params"), + op_modifies=True, + ) + self.have["device_id"] = response.get("id") + + if self.log: + log(str(response)) + log(self.have.get("device_id")) + + claim_params = self.get_claim_params() + claim_response = self.dnac._exec( + family="device_onboarding_pnp", + function='claim_a_device_to_a_site', + op_modifies=True, + params=claim_params, + ) + + if self.log: + log(str(claim_response)) + + if claim_response.get("response") == "Device Claimed": + self.result['changed'] = True + self.result['msg'] = "Device Claimed Successfully" + self.result['response'] = claim_response + self.result['diff'] = self.validated + else: + self.module.fail_json(msg="Device Claim Failed", response=claim_response) + + def get_diff_delete(self): + if self.have.get("device_found"): + + try: + response = self.dnac._exec( + family="device_onboarding_pnp", + function="delete_device_by_id_from_pnp", + op_modifies=True, + params={"id": self.have.get("device_id")}, + ) + + if self.log: + log(str(response)) + + if response.get("deviceInfo").get("state") == "Deleted": + self.result['changed'] = True + self.result['response'] = response + self.result['diff'] = self.validated + self.result['msg'] = "Device Deleted Successfully" + else: + self.result['response'] = response + self.result['msg'] = "Error while deleting the device" + + except Exception as errorstr: + response = str(errorstr) + msg = "Device Deletion Failed" + self.module.fail_json(msg=msg, response=response) + + else: + self.module.fail_json(msg="Device Not Found", response=[]) + + +def main(): + """ main entry point for module execution + """ + + element_spec = dict( + dnac_host=dict(required=True, type='str'), + dnac_port=dict(type='str', default='443'), + dnac_username=dict(type='str', default='admin', aliases=["user"]), + dnac_password=dict(type='str', no_log=True), + dnac_verify=dict(type='bool', default='True'), + dnac_version=dict(type="str", default="2.2.3.3"), + dnac_debug=dict(type='bool', default=False), + dnac_log=dict(type='bool', default=False), + validate_response_schema=dict(type="bool", default=True), + config=dict(required=True, type='list', elements='dict'), + state=dict( + default='merged', + choices=['merged', 'deleted'] + ) + ) + + module = AnsibleModule(argument_spec=element_spec, + supports_check_mode=False) + dnac_pnp = DnacPnp(module) + dnac_pnp.validate_input() + state = dnac_pnp.get_state() + + dnac_pnp.get_want() + dnac_pnp.get_have() + + if state == "merged": + dnac_pnp.get_diff_merge() + + elif state == "deleted": + dnac_pnp.get_diff_delete() + + module.exit_json(**dnac_pnp.result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_server_profile_update.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_server_profile_update.py new file mode 100644 index 000000000..b6528b96b --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_server_profile_update.py @@ -0,0 +1,196 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_server_profile_update +short_description: Resource module for Pnp Server Profile Update +description: +- Manage operation update of the resource Pnp Server Profile Update. +- > + Updates the PnP Server profile in a registered Virtual Account in the PnP database. The response payload returns + the updated smart & virtual account info. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + autoSyncPeriod: + description: Pnp Server Profile Update's autoSyncPeriod. + type: int + ccoUser: + description: Pnp Server Profile Update's ccoUser. + type: str + expiry: + description: Pnp Server Profile Update's expiry. + type: int + lastSync: + description: Pnp Server Profile Update's lastSync. + type: int + profile: + description: Pnp Server Profile Update's profile. + suboptions: + addressFqdn: + description: Pnp Server Profile Update's addressFqdn. + type: str + addressIpV4: + description: Pnp Server Profile Update's addressIpV4. + type: str + cert: + description: Pnp Server Profile Update's cert. + type: str + makeDefault: + description: MakeDefault flag. + type: bool + name: + description: Pnp Server Profile Update's name. + type: str + port: + description: Pnp Server Profile Update's port. + type: int + profileId: + description: Pnp Server Profile Update's profileId. + type: str + proxy: + description: Proxy flag. + type: bool + type: dict + smartAccountId: + description: Pnp Server Profile Update's smartAccountId. + type: str + syncResult: + description: Pnp Server Profile Update's syncResult. + suboptions: + syncList: + description: Pnp Server Profile Update's syncList. + elements: dict + suboptions: + deviceSnList: + description: Pnp Server Profile Update's deviceSnList. + elements: str + type: list + syncType: + description: Pnp Server Profile Update's syncType. + type: str + type: list + syncMsg: + description: Pnp Server Profile Update's syncMsg. + type: str + type: dict + syncResultStr: + description: Pnp Server Profile Update's syncResultStr. + type: str + syncStartTime: + description: Pnp Server Profile Update's syncStartTime. + type: int + syncStatus: + description: Pnp Server Profile Update's syncStatus. + type: str + tenantId: + description: Pnp Server Profile Update's tenantId. + type: str + token: + description: Pnp Server Profile Update's token. + type: str + virtualAccountId: + description: Pnp Server Profile Update's virtualAccountId. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) UpdatePnPServerProfile + description: Complete reference of the UpdatePnPServerProfile API. + link: https://developer.cisco.com/docs/dna-center/#!update-pn-p-server-profile +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.update_pnp_server_profile, + + - Paths used are + put /dna/intent/api/v1/onboarding/pnp-settings/savacct, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.pnp_server_profile_update: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + autoSyncPeriod: 0 + ccoUser: string + expiry: 0 + lastSync: 0 + profile: + addressFqdn: string + addressIpV4: string + cert: string + makeDefault: true + name: string + port: 0 + profileId: string + proxy: true + smartAccountId: string + syncResult: + syncList: + - deviceSnList: + - string + syncType: string + syncMsg: string + syncResultStr: string + syncStartTime: 0 + syncStatus: string + tenantId: string + token: string + virtualAccountId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "virtualAccountId": "string", + "autoSyncPeriod": 0, + "syncResultStr": "string", + "profile": { + "proxy": true, + "makeDefault": true, + "port": 0, + "profileId": "string", + "name": "string", + "addressIpV4": "string", + "cert": "string", + "addressFqdn": "string" + }, + "ccoUser": "string", + "syncResult": { + "syncList": [ + { + "syncType": "string", + "deviceSnList": [ + "string" + ] + } + ], + "syncMsg": "string" + }, + "token": "string", + "syncStartTime": 0, + "lastSync": 0, + "tenantId": "string", + "smartAccountId": "string", + "expiry": 0, + "syncStatus": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_smart_account_domains_info.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_smart_account_domains_info.py new file mode 100644 index 000000000..6f57ce11d --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_smart_account_domains_info.py @@ -0,0 +1,63 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_smart_account_domains_info +short_description: Information module for Pnp Smart Account Domains +description: +- Get all Pnp Smart Account Domains. +- Returns the list of Smart Account domains. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) GetSmartAccountList + description: Complete reference of the GetSmartAccountList API. + link: https://developer.cisco.com/docs/dna-center/#!get-smart-account-list +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.get_smart_account_list, + + - Paths used are + get /dna/intent/api/v1/onboarding/pnp-settings/sacct, + +""" + +EXAMPLES = r""" +- name: Get all Pnp Smart Account Domains + cisco.dnac.pnp_smart_account_domains_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: str + sample: > + [ + "string" + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_account_add.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_account_add.py new file mode 100644 index 000000000..0f8140822 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_account_add.py @@ -0,0 +1,197 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_virtual_account_add +short_description: Resource module for Pnp Virtual Account Add +description: +- Manage operation create of the resource Pnp Virtual Account Add. +- > + Registers a Smart Account, Virtual Account and the relevant server profile info with the PnP System & database. + The devices present in the registered virtual account are synced with the PnP database as well. The response + payload returns the new profile. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + autoSyncPeriod: + description: Pnp Virtual Account Add's autoSyncPeriod. + type: int + ccoUser: + description: Pnp Virtual Account Add's ccoUser. + type: str + expiry: + description: Pnp Virtual Account Add's expiry. + type: int + lastSync: + description: Pnp Virtual Account Add's lastSync. + type: int + profile: + description: Pnp Virtual Account Add's profile. + suboptions: + addressFqdn: + description: Pnp Virtual Account Add's addressFqdn. + type: str + addressIpV4: + description: Pnp Virtual Account Add's addressIpV4. + type: str + cert: + description: Pnp Virtual Account Add's cert. + type: str + makeDefault: + description: MakeDefault flag. + type: bool + name: + description: Pnp Virtual Account Add's name. + type: str + port: + description: Pnp Virtual Account Add's port. + type: int + profileId: + description: Pnp Virtual Account Add's profileId. + type: str + proxy: + description: Proxy flag. + type: bool + type: dict + smartAccountId: + description: Pnp Virtual Account Add's smartAccountId. + type: str + syncResult: + description: Pnp Virtual Account Add's syncResult. + suboptions: + syncList: + description: Pnp Virtual Account Add's syncList. + elements: dict + suboptions: + deviceSnList: + description: Pnp Virtual Account Add's deviceSnList. + elements: str + type: list + syncType: + description: Pnp Virtual Account Add's syncType. + type: str + type: list + syncMsg: + description: Pnp Virtual Account Add's syncMsg. + type: str + type: dict + syncResultStr: + description: Pnp Virtual Account Add's syncResultStr. + type: str + syncStartTime: + description: Pnp Virtual Account Add's syncStartTime. + type: int + syncStatus: + description: Pnp Virtual Account Add's syncStatus. + type: str + tenantId: + description: Pnp Virtual Account Add's tenantId. + type: str + token: + description: Pnp Virtual Account Add's token. + type: str + virtualAccountId: + description: Pnp Virtual Account Add's virtualAccountId. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) AddVirtualAccount + description: Complete reference of the AddVirtualAccount API. + link: https://developer.cisco.com/docs/dna-center/#!add-virtual-account +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.add_virtual_account, + + - Paths used are + post /dna/intent/api/v1/onboarding/pnp-settings/savacct, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.pnp_virtual_account_add: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + autoSyncPeriod: 0 + ccoUser: string + expiry: 0 + lastSync: 0 + profile: + addressFqdn: string + addressIpV4: string + cert: string + makeDefault: true + name: string + port: 0 + profileId: string + proxy: true + smartAccountId: string + syncResult: + syncList: + - deviceSnList: + - string + syncType: string + syncMsg: string + syncResultStr: string + syncStartTime: 0 + syncStatus: string + tenantId: string + token: string + virtualAccountId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "virtualAccountId": "string", + "autoSyncPeriod": 0, + "syncResultStr": "string", + "profile": { + "proxy": true, + "makeDefault": true, + "port": 0, + "profileId": "string", + "name": "string", + "addressIpV4": "string", + "cert": "string", + "addressFqdn": "string" + }, + "ccoUser": "string", + "syncResult": { + "syncList": [ + { + "syncType": "string", + "deviceSnList": [ + "string" + ] + } + ], + "syncMsg": "string" + }, + "token": "string", + "syncStartTime": 0, + "lastSync": 0, + "tenantId": "string", + "smartAccountId": "string", + "expiry": 0, + "syncStatus": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_account_deregister.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_account_deregister.py new file mode 100644 index 000000000..8f0d9d432 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_account_deregister.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_virtual_account_deregister +short_description: Resource module for Pnp Virtual Account Deregister +description: +- Manage operation delete of the resource Pnp Virtual Account Deregister. +- > + Deregisters the specified smart account & virtual account info and the associated device information from the PnP + System & database. The devices associated with the deregistered virtual account are removed from the PnP database + as well. The response payload contains the deregistered smart & virtual account information. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + domain: + description: Domain query parameter. Smart Account Domain. + type: str + name: + description: Name query parameter. Virtual Account Name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) DeregisterVirtualAccount + description: Complete reference of the DeregisterVirtualAccount API. + link: https://developer.cisco.com/docs/dna-center/#!deregister-virtual-account +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.deregister_virtual_account, + + - Paths used are + delete /dna/intent/api/v1/onboarding/pnp-settings/vacct, + +""" + +EXAMPLES = r""" +- name: Delete all + cisco.dnac.pnp_virtual_account_deregister: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + domain: string + name: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "virtualAccountId": "string", + "autoSyncPeriod": 0, + "syncResultStr": "string", + "profile": { + "proxy": true, + "makeDefault": true, + "port": 0, + "profileId": "string", + "name": "string", + "addressIpV4": "string", + "cert": "string", + "addressFqdn": "string" + }, + "ccoUser": "string", + "syncResult": { + "syncList": [ + { + "syncType": "string", + "deviceSnList": [ + "string" + ] + } + ], + "syncMsg": "string" + }, + "token": "string", + "syncStartTime": 0, + "lastSync": 0, + "tenantId": "string", + "smartAccountId": "string", + "expiry": 0, + "syncStatus": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_account_devices_sync.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_account_devices_sync.py new file mode 100644 index 000000000..6a1c0da09 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_account_devices_sync.py @@ -0,0 +1,196 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_virtual_account_devices_sync +short_description: Resource module for Pnp Virtual Account Devices Sync +description: +- Manage operation create of the resource Pnp Virtual Account Devices Sync. +- > + Synchronizes the device info from the given smart account & virtual account with the PnP database. The response + payload returns a list of synced devices. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + autoSyncPeriod: + description: Pnp Virtual Account Devices Sync's autoSyncPeriod. + type: int + ccoUser: + description: Pnp Virtual Account Devices Sync's ccoUser. + type: str + expiry: + description: Pnp Virtual Account Devices Sync's expiry. + type: int + lastSync: + description: Pnp Virtual Account Devices Sync's lastSync. + type: int + profile: + description: Pnp Virtual Account Devices Sync's profile. + suboptions: + addressFqdn: + description: Pnp Virtual Account Devices Sync's addressFqdn. + type: str + addressIpV4: + description: Pnp Virtual Account Devices Sync's addressIpV4. + type: str + cert: + description: Pnp Virtual Account Devices Sync's cert. + type: str + makeDefault: + description: MakeDefault flag. + type: bool + name: + description: Pnp Virtual Account Devices Sync's name. + type: str + port: + description: Pnp Virtual Account Devices Sync's port. + type: int + profileId: + description: Pnp Virtual Account Devices Sync's profileId. + type: str + proxy: + description: Proxy flag. + type: bool + type: dict + smartAccountId: + description: Pnp Virtual Account Devices Sync's smartAccountId. + type: str + syncResult: + description: Pnp Virtual Account Devices Sync's syncResult. + suboptions: + syncList: + description: Pnp Virtual Account Devices Sync's syncList. + elements: dict + suboptions: + deviceSnList: + description: Pnp Virtual Account Devices Sync's deviceSnList. + elements: str + type: list + syncType: + description: Pnp Virtual Account Devices Sync's syncType. + type: str + type: list + syncMsg: + description: Pnp Virtual Account Devices Sync's syncMsg. + type: str + type: dict + syncResultStr: + description: Pnp Virtual Account Devices Sync's syncResultStr. + type: str + syncStartTime: + description: Pnp Virtual Account Devices Sync's syncStartTime. + type: int + syncStatus: + description: Pnp Virtual Account Devices Sync's syncStatus. + type: str + tenantId: + description: Pnp Virtual Account Devices Sync's tenantId. + type: str + token: + description: Pnp Virtual Account Devices Sync's token. + type: str + virtualAccountId: + description: Pnp Virtual Account Devices Sync's virtualAccountId. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) SyncVirtualAccountDevices + description: Complete reference of the SyncVirtualAccountDevices API. + link: https://developer.cisco.com/docs/dna-center/#!sync-virtual-account-devices +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.sync_virtual_account_devices, + + - Paths used are + post /dna/intent/api/v1/onboarding/pnp-device/vacct-sync, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.pnp_virtual_account_devices_sync: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + autoSyncPeriod: 0 + ccoUser: string + expiry: 0 + lastSync: 0 + profile: + addressFqdn: string + addressIpV4: string + cert: string + makeDefault: true + name: string + port: 0 + profileId: string + proxy: true + smartAccountId: string + syncResult: + syncList: + - deviceSnList: + - string + syncType: string + syncMsg: string + syncResultStr: string + syncStartTime: 0 + syncStatus: string + tenantId: string + token: string + virtualAccountId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "virtualAccountId": "string", + "autoSyncPeriod": 0, + "syncResultStr": "string", + "profile": { + "proxy": true, + "makeDefault": true, + "port": 0, + "profileId": "string", + "name": "string", + "addressIpV4": "string", + "cert": "string", + "addressFqdn": "string" + }, + "ccoUser": "string", + "syncResult": { + "syncList": [ + { + "syncType": "string", + "deviceSnList": [ + "string" + ] + } + ], + "syncMsg": "string" + }, + "token": "string", + "syncStartTime": 0, + "lastSync": 0, + "tenantId": "string", + "smartAccountId": "string", + "expiry": 0, + "syncStatus": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_account_sync_result_info.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_account_sync_result_info.py new file mode 100644 index 000000000..e3c37abe0 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_account_sync_result_info.py @@ -0,0 +1,103 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_virtual_account_sync_result_info +short_description: Information module for Pnp Virtual Account Sync Result +description: +- Get all Pnp Virtual Account Sync Result. +- Returns the summary of devices synced from the given smart account & virtual account with PnP. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + domain: + description: + - Domain path parameter. Smart Account Domain. + type: str + name: + description: + - Name path parameter. Virtual Account Name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) GetSyncResultForVirtualAccount + description: Complete reference of the GetSyncResultForVirtualAccount API. + link: https://developer.cisco.com/docs/dna-center/#!get-sync-result-for-virtual-account +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.get_sync_result_for_virtual_account, + + - Paths used are + get /dna/intent/api/v1/onboarding/pnp-device/sacct/{domain}/vacct/{name}/sync-result, + +""" + +EXAMPLES = r""" +- name: Get all Pnp Virtual Account Sync Result + cisco.dnac.pnp_virtual_account_sync_result_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + domain: string + name: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "virtualAccountId": "string", + "autoSyncPeriod": 0, + "syncResultStr": "string", + "profile": { + "proxy": true, + "makeDefault": true, + "port": 0, + "profileId": "string", + "name": "string", + "addressIpV4": "string", + "cert": "string", + "addressFqdn": "string" + }, + "ccoUser": "string", + "syncResult": { + "syncList": [ + { + "syncType": "string", + "deviceSnList": [ + "string" + ] + } + ], + "syncMsg": "string" + }, + "token": "string", + "syncStartTime": 0, + "lastSync": 0, + "tenantId": "string", + "smartAccountId": "string", + "expiry": 0, + "syncStatus": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_accounts_info.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_accounts_info.py new file mode 100644 index 000000000..40ed3ac75 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_virtual_accounts_info.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_virtual_accounts_info +short_description: Information module for Pnp Virtual Accounts +description: +- Get all Pnp Virtual Accounts. +- Returns list of virtual accounts associated with the specified smart account. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + domain: + description: + - Domain path parameter. Smart Account Domain. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) GetVirtualAccountList + description: Complete reference of the GetVirtualAccountList API. + link: https://developer.cisco.com/docs/dna-center/#!get-virtual-account-list +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.get_virtual_account_list, + + - Paths used are + get /dna/intent/api/v1/onboarding/pnp-settings/sacct/{domain}/vacct, + +""" + +EXAMPLES = r""" +- name: Get all Pnp Virtual Accounts + cisco.dnac.pnp_virtual_accounts_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + domain: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: str + sample: > + [ + "string" + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_workflow.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_workflow.py new file mode 100644 index 000000000..5a5850959 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_workflow.py @@ -0,0 +1,310 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_workflow +short_description: Resource module for Pnp Workflow +description: +- Manage operations create, update and delete of the resource Pnp Workflow. +- Adds a PnP Workflow along with the relevant tasks in the workflow into the PnP database. +- Deletes a workflow specified by id. +- Updates an existing workflow. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + _id: + description: Pnp Workflow's _id. + type: str + addToInventory: + description: AddToInventory flag. + type: bool + addedOn: + description: Pnp Workflow's addedOn. + type: int + configId: + description: Pnp Workflow's configId. + type: str + currTaskIdx: + description: Pnp Workflow's currTaskIdx. + type: int + description: + description: Pnp Workflow's description. + type: str + endTime: + description: Pnp Workflow's endTime. + type: int + execTime: + description: Pnp Workflow's execTime. + type: int + id: + description: Id path parameter. + type: str + imageId: + description: Pnp Workflow's imageId. + type: str + instanceType: + description: Pnp Workflow's instanceType. + type: str + lastupdateOn: + description: Pnp Workflow's lastupdateOn. + type: int + name: + description: Pnp Workflow's name. + type: str + startTime: + description: Pnp Workflow's startTime. + type: int + state_: + description: Pnp Workflow's state. + type: str + tasks: + description: Pnp Workflow's tasks. + elements: dict + suboptions: + currWorkItemIdx: + description: Pnp Workflow's currWorkItemIdx. + type: int + endTime: + description: Pnp Workflow's endTime. + type: int + name: + description: Pnp Workflow's name. + type: str + startTime: + description: Pnp Workflow's startTime. + type: int + state: + description: Pnp Workflow's state. + type: str + taskSeqNo: + description: Pnp Workflow's taskSeqNo. + type: int + timeTaken: + description: Pnp Workflow's timeTaken. + type: int + type: + description: Pnp Workflow's type. + type: str + workItemList: + description: Pnp Workflow's workItemList. + elements: dict + suboptions: + command: + description: Pnp Workflow's command. + type: str + endTime: + description: Pnp Workflow's endTime. + type: int + outputStr: + description: Pnp Workflow's outputStr. + type: str + startTime: + description: Pnp Workflow's startTime. + type: int + state: + description: Pnp Workflow's state. + type: str + timeTaken: + description: Pnp Workflow's timeTaken. + type: int + type: list + type: list + tenantId: + description: Pnp Workflow's tenantId. + type: str + type: + description: Pnp Workflow's type. + type: str + useState: + description: Pnp Workflow's useState. + type: str + version: + description: Pnp Workflow's version. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) AddAWorkflow + description: Complete reference of the AddAWorkflow API. + link: https://developer.cisco.com/docs/dna-center/#!add-a-workflow +- name: Cisco DNA Center documentation for Device Onboarding (PnP) DeleteWorkflowById + description: Complete reference of the DeleteWorkflowById API. + link: https://developer.cisco.com/docs/dna-center/#!delete-workflow-by-id +- name: Cisco DNA Center documentation for Device Onboarding (PnP) UpdateWorkflow + description: Complete reference of the UpdateWorkflow API. + link: https://developer.cisco.com/docs/dna-center/#!update-workflow +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.add_a_workflow, + device_onboarding_pnp.DeviceOnboardingPnp.delete_workflow_by_id, + device_onboarding_pnp.DeviceOnboardingPnp.update_workflow, + + - Paths used are + post /dna/intent/api/v1/onboarding/pnp-workflow, + delete /dna/intent/api/v1/onboarding/pnp-workflow/{id}, + put /dna/intent/api/v1/onboarding/pnp-workflow/{id}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.pnp_workflow: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + _id: string + addToInventory: true + addedOn: 0 + configId: string + currTaskIdx: 0 + description: string + endTime: 0 + execTime: 0 + imageId: string + instanceType: string + lastupdateOn: 0 + name: string + startTime: 0 + state_: string + tasks: + - currWorkItemIdx: 0 + endTime: 0 + name: string + startTime: 0 + state: string + taskSeqNo: 0 + timeTaken: 0 + type: string + workItemList: + - command: string + endTime: 0 + outputStr: string + startTime: 0 + state: string + timeTaken: 0 + tenantId: string + type: string + useState: string + version: 0 + +- name: Delete by id + cisco.dnac.pnp_workflow: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + id: string + +- name: Update by id + cisco.dnac.pnp_workflow: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + _id: string + addToInventory: true + addedOn: 0 + configId: string + currTaskIdx: 0 + description: string + endTime: 0 + execTime: 0 + id: string + imageId: string + instanceType: string + lastupdateOn: 0 + name: string + startTime: 0 + state_: string + tasks: + - currWorkItemIdx: 0 + endTime: 0 + name: string + startTime: 0 + state: string + taskSeqNo: 0 + timeTaken: 0 + type: string + workItemList: + - command: string + endTime: 0 + outputStr: string + startTime: 0 + state: string + timeTaken: 0 + tenantId: string + type: string + useState: string + version: 0 + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "_id": "string", + "state": "string", + "type": "string", + "description": "string", + "lastupdateOn": 0, + "imageId": "string", + "currTaskIdx": 0, + "addedOn": 0, + "tasks": [ + { + "state": "string", + "type": "string", + "currWorkItemIdx": 0, + "taskSeqNo": 0, + "endTime": 0, + "startTime": 0, + "workItemList": [ + { + "state": "string", + "command": "string", + "outputStr": "string", + "endTime": 0, + "startTime": 0, + "timeTaken": 0 + } + ], + "timeTaken": 0, + "name": "string" + } + ], + "addToInventory": true, + "instanceType": "string", + "endTime": 0, + "execTime": 0, + "startTime": 0, + "useState": "string", + "configId": "string", + "name": "string", + "version": 0, + "tenantId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_workflow_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_workflow_count_info.py new file mode 100644 index 000000000..215330a78 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_workflow_count_info.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_workflow_count_info +short_description: Information module for Pnp Workflow Count +description: +- Get all Pnp Workflow Count. +- Returns the workflow count. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + name: + description: + - Name query parameter. Workflow Name. + elements: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) GetWorkflowCount + description: Complete reference of the GetWorkflowCount API. + link: https://developer.cisco.com/docs/dna-center/#!get-workflow-count +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.get_workflow_count, + + - Paths used are + get /dna/intent/api/v1/onboarding/pnp-workflow/count, + +""" + +EXAMPLES = r""" +- name: Get all Pnp Workflow Count + cisco.dnac.pnp_workflow_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + name: [] + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/pnp_workflow_info.py b/ansible_collections/cisco/dnac/plugins/modules/pnp_workflow_info.py new file mode 100644 index 000000000..7a00e17bc --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/pnp_workflow_info.py @@ -0,0 +1,160 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: pnp_workflow_info +short_description: Information module for Pnp Workflow +description: +- Get all Pnp Workflow. +- Get Pnp Workflow by id. +- Returns a workflow specified by id. +- > + Returns the list of workflows based on filter criteria. If a limit is not specified, it will default to return 50 + workflows. Pagination and sorting are also supported by this endpoint. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + limit: + description: + - Limit query parameter. Limits number of results. + type: int + offset: + description: + - Offset query parameter. Index of first result. + type: int + sort: + description: + - Sort query parameter. Comma seperated lost of fields to sort on. + elements: str + type: list + sortOrder: + description: + - SortOrder query parameter. Sort Order Ascending (asc) or Descending (des). + type: str + type: + description: + - Type query parameter. Workflow Type. + elements: str + type: list + name: + description: + - Name query parameter. Workflow Name. + elements: str + type: list + id: + description: + - Id path parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Device Onboarding (PnP) GetWorkflowById + description: Complete reference of the GetWorkflowById API. + link: https://developer.cisco.com/docs/dna-center/#!get-workflow-by-id +- name: Cisco DNA Center documentation for Device Onboarding (PnP) GetWorkflows + description: Complete reference of the GetWorkflows API. + link: https://developer.cisco.com/docs/dna-center/#!get-workflows +notes: + - SDK Method used are + device_onboarding_pnp.DeviceOnboardingPnp.get_workflow_by_id, + device_onboarding_pnp.DeviceOnboardingPnp.get_workflows, + + - Paths used are + get /dna/intent/api/v1/onboarding/pnp-workflow, + get /dna/intent/api/v1/onboarding/pnp-workflow/{id}, + +""" + +EXAMPLES = r""" +- name: Get all Pnp Workflow + cisco.dnac.pnp_workflow_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + limit: 0 + offset: 0 + sort: [] + sortOrder: string + type: [] + name: [] + register: result + +- name: Get Pnp Workflow by id + cisco.dnac.pnp_workflow_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "_id": "string", + "state": "string", + "type": "string", + "description": "string", + "lastupdateOn": 0, + "imageId": "string", + "currTaskIdx": 0, + "addedOn": 0, + "tasks": [ + { + "state": "string", + "type": "string", + "currWorkItemIdx": 0, + "taskSeqNo": 0, + "endTime": 0, + "startTime": 0, + "workItemList": [ + { + "state": "string", + "command": "string", + "outputStr": "string", + "endTime": 0, + "startTime": 0, + "timeTaken": 0 + } + ], + "timeTaken": 0, + "name": "string" + } + ], + "addToInventory": true, + "instanceType": "string", + "endTime": 0, + "execTime": 0, + "startTime": 0, + "useState": "string", + "configId": "string", + "name": "string", + "version": 0, + "tenantId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/profiling_rules_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/profiling_rules_count_info.py new file mode 100644 index 000000000..a3181b3c6 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/profiling_rules_count_info.py @@ -0,0 +1,70 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: profiling_rules_count_info +short_description: Information module for Profiling Rules Count +description: +- Get all Profiling Rules Count. +- This API fetches the count of profiling rules based on the filter values provided in the query parameters. + The filter parameters are same as that of 'GET /profiling-rules' API, excluding the pagination and sort parameters. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + ruleType: + description: + - RuleType query parameter. Use comma-separated list of rule types to filter the data. Defaults to 'Custom Rule'. + type: str + includeDeleted: + description: + - IncludeDeleted query parameter. Flag to indicate whether deleted rules should be part of the records fetched. + type: bool +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +notes: + - SDK Method used are + policy.Policy.get_count_of_profiling_rules, + + - Paths used are + get /dna/intent/api/v1/endpoint-analytics/profiling-rules/count, + +""" + +EXAMPLES = r""" +- name: Get all Profiling Rules Count + cisco.dnac.profiling_rules_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: + custom: value + ruleType: string + includeDeleted: True + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "count": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/profiling_rules_in_bulk_create.py b/ansible_collections/cisco/dnac/plugins/modules/profiling_rules_in_bulk_create.py new file mode 100644 index 000000000..8e5b49c2d --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/profiling_rules_in_bulk_create.py @@ -0,0 +1,189 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: profiling_rules_in_bulk_create +short_description: Resource module for Profiling Rules In Bulk Create +description: +- Manage operation create of the resource Profiling Rules In Bulk Create. +- This API imports the given list of profiling rules. For each record, + 1) If 'ruleType' for a record is not 'Custom Rule', then it is rejected. + 2) If 'ruleId' is provided in the input record, +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + profilingRules: + description: Profiling Rules In Bulk Create's profilingRules. + elements: dict + suboptions: + clusterId: + description: Unique identifier for ML cluster. Only applicable for 'ML Rule'. + type: str + conditionGroups: + description: Profiling Rules In Bulk Create's conditionGroups. + suboptions: + condition: + description: Profiling Rules In Bulk Create's condition. + suboptions: + attribute: + description: Profiling Rules In Bulk Create's attribute. + type: str + attributeDictionary: + description: Profiling Rules In Bulk Create's attributeDictionary. + type: str + operator: + description: Profiling Rules In Bulk Create's operator. + type: str + value: + description: Profiling Rules In Bulk Create's value. + type: str + type: dict + conditionGroup: + description: Profiling Rules In Bulk Create's conditionGroup. + elements: dict + type: list + operator: + description: Profiling Rules In Bulk Create's operator. + type: str + type: + description: Profiling Rules In Bulk Create's type. + type: str + type: dict + isDeleted: + description: Flag to indicate whether the rule was deleted. + type: bool + lastModifiedBy: + description: User that last modified the rule. It is read-only, and is ignored + if provided as part of input request. + type: str + lastModifiedOn: + description: Timestamp (in epoch milliseconds) of last modification. It is read-only, + and is ignored if provided as part of input request. + type: int + pluginId: + description: Plugin for the rule. Only applicable for 'Cisco Default' rules. + type: str + rejected: + description: Flag to indicate whether rule has been rejected by user or not. + Only applicable for 'ML Rule'. + type: bool + result: + description: Profiling Rules In Bulk Create's result. + suboptions: + deviceType: + description: List of device types determined by the current rule. + elements: str + type: list + hardwareManufacturer: + description: List of hardware manufacturers determined by the current rule. + elements: str + type: list + hardwareModel: + description: List of hardware models determined by the current rule. + elements: str + type: list + operatingSystem: + description: List of operating systems determined by the current rule. + elements: str + type: list + type: dict + ruleId: + description: Unique identifier for the rule. This is normally generated by the + system, and client does not need to provide it for rules that need to be newly + created. + type: str + ruleName: + description: Human readable name for the rule. + type: str + rulePriority: + description: Priority for the rule. + type: int + ruleType: + description: Type of the rule. Allowed values are 'Cisco Default - Static', + 'Cisco Default - Dynamic', 'Custom Rule', 'ML Rule'. + type: str + ruleVersion: + description: Version of the rule. + type: int + sourcePriority: + description: Source priority for the rule. + type: int + usedAttributes: + description: List of attributes used in the rule. Only applicable for 'Cisco + Default' rules. + elements: str + type: list + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +notes: + - SDK Method used are + policy.Policy.import_profiling_rules_in_bulk, + + - Paths used are + post /dna/intent/api/v1/endpoint-analytics/profiling-rules/bulk, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.profiling_rules_in_bulk_create: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + profilingRules: + - clusterId: string + conditionGroups: + condition: + attribute: string + attributeDictionary: string + operator: string + value: string + conditionGroup: + - {} + operator: string + type: string + isDeleted: true + lastModifiedBy: string + lastModifiedOn: 0 + pluginId: string + rejected: true + result: + deviceType: + - string + hardwareManufacturer: + - string + hardwareModel: + - string + operatingSystem: + - string + ruleId: string + ruleName: string + rulePriority: 0 + ruleType: string + ruleVersion: 0 + sourcePriority: 0 + usedAttributes: + - string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + {} +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/projects_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/projects_details_info.py new file mode 100644 index 000000000..704c881e2 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/projects_details_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: projects_details_info +short_description: Information module for Projects Details +description: +- Get all Projects Details. +- Get projects details. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + id: + description: + - Id query parameter. Id of project to be searched. + type: str + name: + description: + - Name query parameter. Name of project to be searched. + type: str + offset: + description: + - Offset query parameter. Index of first result. + type: int + limit: + description: + - Limit query parameter. Limits number of results. + type: int + sortOrder: + description: + - SortOrder query parameter. Sort Order Ascending (asc) or Descending (dsc). + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Templates GetProjectsDetails + description: Complete reference of the GetProjectsDetails API. + link: https://developer.cisco.com/docs/dna-center/#!get-project-s-details +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.get_projects_details, + + - Paths used are + get /dna/intent/api/v2/template-programmer/project, + +""" + +EXAMPLES = r""" +- name: Get all Projects Details + cisco.dnac.projects_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + id: string + name: string + offset: 0 + limit: 0 + sortOrder: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "createTime": 0, + "description": "string", + "id": "string", + "isDeletable": true, + "lastUpdateTime": 0, + "name": "string", + "tags": [ + { + "id": "string", + "name": "string" + } + ], + "templates": {} + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/qos_device_interface.py b/ansible_collections/cisco/dnac/plugins/modules/qos_device_interface.py new file mode 100644 index 000000000..2c7881cb7 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/qos_device_interface.py @@ -0,0 +1,176 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: qos_device_interface +short_description: Resource module for Qos Device Interface +description: +- Manage operations create, update and delete of the resource Qos Device Interface. +- > + Create qos device interface infos associate with network device id to allow the user to mark specific interfaces + as WAN, to associate WAN interfaces with specific SP Profile and to be able to define a shaper on WAN interfaces. +- Delete all qos device interface infos associate with network device id. +- Update existing qos device interface infos associate with network device id. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + id: + description: Id path parameter. Id of the qos device info, this object holds all + qos device interface infos associate with network device id. + type: str + payload: + description: Qos Device Interface's payload. + elements: dict + suboptions: + excludedInterfaces: + description: Excluded interfaces ids. + elements: str + type: list + id: + description: Id of Qos device info. + type: str + name: + description: Device name. + type: str + networkDeviceId: + description: Network device id. + type: str + qosDeviceInterfaceInfo: + description: Qos Device Interface's qosDeviceInterfaceInfo. + elements: dict + suboptions: + dmvpnRemoteSitesBw: + description: Dmvpn remote sites bandwidth. + elements: int + type: list + instanceId: + description: Instance id. + type: int + interfaceId: + description: Interface id. + type: str + interfaceName: + description: Interface name. + type: str + label: + description: SP Profile name. + type: str + role: + description: Interface role. + type: str + uploadBW: + description: Upload bandwidth. + type: int + type: list + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Application Policy CreateQosDeviceInterfaceInfo + description: Complete reference of the CreateQosDeviceInterfaceInfo API. + link: https://developer.cisco.com/docs/dna-center/#!create-qos-device-interface-info +- name: Cisco DNA Center documentation for Application Policy DeleteQosDeviceInterfaceInfo + description: Complete reference of the DeleteQosDeviceInterfaceInfo API. + link: https://developer.cisco.com/docs/dna-center/#!delete-qos-device-interface-info +- name: Cisco DNA Center documentation for Application Policy UpdateQosDeviceInterfaceInfo + description: Complete reference of the UpdateQosDeviceInterfaceInfo API. + link: https://developer.cisco.com/docs/dna-center/#!update-qos-device-interface-info +notes: + - SDK Method used are + application_policy.ApplicationPolicy.create_qos_device_interface_info, + application_policy.ApplicationPolicy.delete_qos_device_interface_info, + application_policy.ApplicationPolicy.update_qos_device_interface_info, + + - Paths used are + post /dna/intent/api/v1/qos-device-interface-info, + delete /dna/intent/api/v1/qos-device-interface-info/{id}, + put /dna/intent/api/v1/qos-device-interface-info, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.qos_device_interface: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - excludedInterfaces: + - string + id: string + name: string + networkDeviceId: string + qosDeviceInterfaceInfo: + - dmvpnRemoteSitesBw: + - 0 + instanceId: 0 + interfaceId: string + interfaceName: string + label: string + role: string + uploadBW: 0 + +- name: Create + cisco.dnac.qos_device_interface: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - excludedInterfaces: + - string + name: string + networkDeviceId: string + qosDeviceInterfaceInfo: + - dmvpnRemoteSitesBw: + - 0 + interfaceId: string + interfaceName: string + label: string + role: string + uploadBW: 0 + +- name: Delete by id + cisco.dnac.qos_device_interface: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + id: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/qos_device_interface_info.py b/ansible_collections/cisco/dnac/plugins/modules/qos_device_interface_info.py new file mode 100644 index 000000000..98f070c58 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/qos_device_interface_info.py @@ -0,0 +1,121 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: qos_device_interface_info +short_description: Information module for Qos Device Interface +description: +- Get all Qos Device Interface. +- Get all or by network device id, existing qos device interface infos. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + networkDeviceId: + description: + - NetworkDeviceId query parameter. Network device id. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Application Policy GetQosDeviceInterfaceInfo + description: Complete reference of the GetQosDeviceInterfaceInfo API. + link: https://developer.cisco.com/docs/dna-center/#!get-qos-device-interface-info +notes: + - SDK Method used are + application_policy.ApplicationPolicy.get_qos_device_interface_info, + + - Paths used are + get /dna/intent/api/v1/qos-device-interface-info, + +""" + +EXAMPLES = r""" +- name: Get all Qos Device Interface + cisco.dnac.qos_device_interface_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + networkDeviceId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "createTime": 0, + "deployed": true, + "isSeeded": true, + "isStale": true, + "lastUpdateTime": 0, + "name": "string", + "namespace": "string", + "provisioningState": "string", + "qualifier": "string", + "resourceVersion": 0, + "targetIdList": [ + {} + ], + "type": "string", + "cfsChangeInfo": [ + {} + ], + "customProvisions": [ + {} + ], + "excludedInterfaces": [ + "string" + ], + "isExcluded": true, + "networkDeviceId": "string", + "qosDeviceInterfaceInfo": [ + { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceCreatedOn": 0, + "instanceUpdatedOn": 0, + "instanceVersion": 0, + "dmvpnRemoteSitesBw": [ + 0 + ], + "downloadBW": 0, + "interfaceId": "string", + "interfaceName": "string", + "label": "string", + "role": "string", + "uploadBW": 0 + } + ] + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/qos_device_interface_info_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/qos_device_interface_info_count_info.py new file mode 100644 index 000000000..fd872ab6e --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/qos_device_interface_info_count_info.py @@ -0,0 +1,63 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: qos_device_interface_info_count_info +short_description: Information module for Qos Device Interface Info Count +description: +- Get all Qos Device Interface Info Count. +- Get the number of all existing qos device interface infos group by network device id. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Application Policy GetQosDeviceInterfaceInfoCount + description: Complete reference of the GetQosDeviceInterfaceInfoCount API. + link: https://developer.cisco.com/docs/dna-center/#!get-qos-device-interface-info-count +notes: + - SDK Method used are + application_policy.ApplicationPolicy.get_qos_device_interface_info_count, + + - Paths used are + get /dna/intent/api/v1/qos-device-interface-info-count, + +""" + +EXAMPLES = r""" +- name: Get all Qos Device Interface Info Count + cisco.dnac.qos_device_interface_info_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/reports.py b/ansible_collections/cisco/dnac/plugins/modules/reports.py new file mode 100644 index 000000000..039746e73 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/reports.py @@ -0,0 +1,244 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: reports +short_description: Resource module for Reports +description: +- Manage operations create and delete of the resource Reports. +- > + Create/Schedule a report configuration. Use "Get view details for a given view group & view" API to get the + metadata required to configure a report. +- Delete a scheduled report configuration. Deletes the report executions also. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + deliveries: + description: Array of available delivery channels. + elements: dict + type: list + name: + description: Report name. + type: str + reportId: + description: ReportId path parameter. ReportId of report. + type: str + schedule: + description: Reports's schedule. + type: dict + tags: + description: Array of tags for report. + elements: str + type: list + view: + description: Reports's view. + suboptions: + fieldGroups: + description: Reports's fieldGroups. + elements: dict + suboptions: + fieldGroupDisplayName: + description: Field group label/displayname for user. + type: str + fieldGroupName: + description: Field group name. + type: str + fields: + description: Reports's fields. + elements: dict + suboptions: + displayName: + description: Field label/displayname. + type: str + name: + description: Field name. + type: str + type: list + type: list + filters: + description: Reports's filters. + elements: dict + suboptions: + displayName: + description: Filter label/displayname. + type: str + name: + description: Filter name. + type: str + type: + description: Filter type. + type: str + value: + description: Value of filter. Data type is based on the filter type. Use + the filter definitions from the view to fetch the options for a filter. + type: dict + type: list + format: + description: Reports's format. + suboptions: + formatType: + description: Format type of report. + type: str + name: + description: Format name of report. + type: str + type: dict + name: + description: View name. + type: str + viewId: + description: View Id. + type: str + type: dict + viewGroupId: + description: ViewGroupId of the viewgroup for the report. + type: str + viewGroupVersion: + description: Version of viewgroup for the report. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Reports CreateOrScheduleAReport + description: Complete reference of the CreateOrScheduleAReport API. + link: https://developer.cisco.com/docs/dna-center/#!create-or-schedule-a-report +- name: Cisco DNA Center documentation for Reports DeleteAScheduledReport + description: Complete reference of the DeleteAScheduledReport API. + link: https://developer.cisco.com/docs/dna-center/#!delete-a-scheduled-report +notes: + - SDK Method used are + reports.Reports.create_or_schedule_a_report, + reports.Reports.delete_a_scheduled_report, + + - Paths used are + post /dna/intent/api/v1/data/reports, + delete /dna/intent/api/v1/data/reports/{reportId}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.reports: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + deliveries: + - {} + name: string + schedule: {} + tags: + - string + view: + fieldGroups: + - fieldGroupDisplayName: string + fieldGroupName: string + fields: + - displayName: string + name: string + filters: + - displayName: string + name: string + type: string + value: {} + format: + formatType: string + name: string + name: string + viewId: string + viewGroupId: string + viewGroupVersion: string + +- name: Delete by id + cisco.dnac.reports: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + reportId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "tags": [ + "string" + ], + "dataCategory": "string", + "deliveries": [ + {} + ], + "executionCount": 0, + "executions": [ + { + "endTime": 0, + "errors": [ + "string" + ], + "executionId": "string", + "processStatus": "string", + "requestStatus": "string", + "startTime": 0, + "warnings": [ + "string" + ] + } + ], + "name": "string", + "reportId": "string", + "reportWasExecuted": true, + "schedule": {}, + "view": { + "fieldGroups": [ + { + "fieldGroupDisplayName": "string", + "fieldGroupName": "string", + "fields": [ + { + "displayName": "string", + "name": "string" + } + ] + } + ], + "filters": [ + { + "displayName": "string", + "name": "string", + "type": "string", + "value": {} + } + ], + "format": { + "formatType": "string", + "name": "string" + }, + "name": "string", + "viewId": "string", + "description": "string", + "viewInfo": "string" + }, + "viewGroupId": "string", + "viewGroupVersion": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/reports_executions_info.py b/ansible_collections/cisco/dnac/plugins/modules/reports_executions_info.py new file mode 100644 index 000000000..2002682db --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/reports_executions_info.py @@ -0,0 +1,109 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: reports_executions_info +short_description: Information module for Reports Executions +description: +- Get all Reports Executions. +- Get Reports Executions by id. +- Get details of all executions for a given report. +- > + Returns report content. Save the response to a file by converting the response data as a blob and setting the file + format available from content-disposition response header. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + reportId: + description: + - ReportId path parameter. ReportId of report. + type: str + executionId: + description: + - ExecutionId path parameter. ExecutionId of report execution. + type: str + dirPath: + description: + - Directory absolute path. Defaults to the current working directory. + type: str + saveFile: + description: + - Enable or disable automatic file creation of raw response. + type: bool + filename: + description: + - The filename used to save the download file. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Reports DownloadReportContent + description: Complete reference of the DownloadReportContent API. + link: https://developer.cisco.com/docs/dna-center/#!download-report-content +- name: Cisco DNA Center documentation for Reports GetAllExecutionDetailsForAGivenReport + description: Complete reference of the GetAllExecutionDetailsForAGivenReport API. + link: https://developer.cisco.com/docs/dna-center/#!get-all-execution-details-for-a-given-report +notes: + - SDK Method used are + reports.Reports.download_report_content, + reports.Reports.get_all_execution_details_for_a_given_report, + + - Paths used are + get /dna/intent/api/v1/data/reports/{reportId}/executions, + get /dna/intent/api/v1/data/reports/{reportId}/executions/{executionId}, + +""" + +EXAMPLES = r""" +- name: Get all Reports Executions + cisco.dnac.reports_executions_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + reportId: string + register: result + +- name: Get Reports Executions by id + cisco.dnac.reports_executions_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + reportId: string + executionId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "data": "filecontent", + "filename": "filename", + "dirpath": "download/directory", + "path": "download/directory/filename" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/reports_info.py b/ansible_collections/cisco/dnac/plugins/modules/reports_info.py new file mode 100644 index 000000000..963b6bb16 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/reports_info.py @@ -0,0 +1,155 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: reports_info +short_description: Information module for Reports +description: +- Get all Reports. +- Get Reports by id. +- Get list of scheduled report configurations. +- Get scheduled report configuration by reportId. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + viewGroupId: + description: + - ViewGroupId query parameter. ViewGroupId of viewgroup for report. + type: str + viewId: + description: + - ViewId query parameter. ViewId of view for report. + type: str + reportId: + description: + - ReportId path parameter. ReportId of report. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Reports GetAScheduledReport + description: Complete reference of the GetAScheduledReport API. + link: https://developer.cisco.com/docs/dna-center/#!get-a-scheduled-report +- name: Cisco DNA Center documentation for Reports GetListOfScheduledReports + description: Complete reference of the GetListOfScheduledReports API. + link: https://developer.cisco.com/docs/dna-center/#!get-list-of-scheduled-reports +notes: + - SDK Method used are + reports.Reports.get_a_scheduled_report, + reports.Reports.get_list_of_scheduled_reports, + + - Paths used are + get /dna/intent/api/v1/data/reports, + get /dna/intent/api/v1/data/reports/{reportId}, + +""" + +EXAMPLES = r""" +- name: Get all Reports + cisco.dnac.reports_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + viewGroupId: string + viewId: string + register: result + +- name: Get Reports by id + cisco.dnac.reports_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + reportId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "tags": [ + "string" + ], + "dataCategory": "string", + "deliveries": [ + {} + ], + "executionCount": 0, + "executions": [ + { + "endTime": 0, + "errors": [ + "string" + ], + "executionId": "string", + "processStatus": "string", + "requestStatus": "string", + "startTime": 0, + "warnings": [ + "string" + ] + } + ], + "name": "string", + "reportId": "string", + "reportWasExecuted": true, + "schedule": {}, + "view": { + "fieldGroups": [ + { + "fieldGroupDisplayName": "string", + "fieldGroupName": "string", + "fields": [ + { + "displayName": "string", + "name": "string" + } + ] + } + ], + "filters": [ + { + "displayName": "string", + "name": "string", + "type": "string", + "value": {} + } + ], + "format": { + "formatType": "string", + "name": "string", + "default": true + }, + "name": "string", + "viewId": "string", + "description": "string", + "viewInfo": "string" + }, + "viewGroupId": "string", + "viewGroupVersion": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/reports_view_group_info.py b/ansible_collections/cisco/dnac/plugins/modules/reports_view_group_info.py new file mode 100644 index 000000000..71fd405a9 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/reports_view_group_info.py @@ -0,0 +1,95 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: reports_view_group_info +short_description: Information module for Reports View Group +description: +- Get all Reports View Group. +- Get Reports View Group by id. +- Gives a list of summary of all view groups. +- > + Gives a list of summary of all views in a viewgroup. Use "Get all view groups" API to get the viewGroupIds + required as a query param for this API for available viewgroups. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + viewGroupId: + description: + - ViewGroupId path parameter. ViewGroupId of viewgroup. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Reports GetAllViewGroups + description: Complete reference of the GetAllViewGroups API. + link: https://developer.cisco.com/docs/dna-center/#!get-all-view-groups +- name: Cisco DNA Center documentation for Reports GetViewsForAGivenViewGroup + description: Complete reference of the GetViewsForAGivenViewGroup API. + link: https://developer.cisco.com/docs/dna-center/#!get-views-for-a-given-view-group +notes: + - SDK Method used are + reports.Reports.get_all_view_groups, + reports.Reports.get_views_for_a_given_view_group, + + - Paths used are + get /dna/intent/api/v1/data/view-groups, + get /dna/intent/api/v1/data/view-groups/{viewGroupId}, + +""" + +EXAMPLES = r""" +- name: Get all Reports View Group + cisco.dnac.reports_view_group_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +- name: Get Reports View Group by id + cisco.dnac.reports_view_group_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + viewGroupId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "viewGroupId": "string", + "views": [ + { + "description": "string", + "viewId": "string", + "viewName": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/reports_view_group_view_info.py b/ansible_collections/cisco/dnac/plugins/modules/reports_view_group_view_info.py new file mode 100644 index 000000000..791e4a0d6 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/reports_view_group_view_info.py @@ -0,0 +1,138 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: reports_view_group_view_info +short_description: Information module for Reports View Group View +description: +- Get Reports View Group View by id. +- > + Gives complete information of the view that is required to configure a report. Use "Get views for a given view + group" API to get the viewIds required as a query param for this API for available views. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + viewGroupId: + description: + - ViewGroupId path parameter. ViewGroupId of viewgroup. + type: str + viewId: + description: + - ViewId path parameter. View id of view. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Reports GetViewDetailsForAGivenViewGroup_View + description: Complete reference of the GetViewDetailsForAGivenViewGroup_View API. + link: https://developer.cisco.com/docs/dna-center/#!get-view-details-for-a-given-view-group-view +notes: + - SDK Method used are + reports.Reports.get_view_details_for_a_given_view_group_and_view, + + - Paths used are + get /dna/intent/api/v1/data/view-groups/{viewGroupId}/views/{viewId}, + +""" + +EXAMPLES = r""" +- name: Get Reports View Group View by id + cisco.dnac.reports_view_group_view_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + viewGroupId: string + viewId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "deliveries": [ + { + "type": "string", + "default": true + } + ], + "description": "string", + "fieldGroups": [ + { + "fieldGroupDisplayName": "string", + "fieldGroupName": "string", + "fields": [ + { + "displayName": "string", + "name": "string" + } + ], + "tableId": "string" + } + ], + "filters": [ + { + "additionalInfo": {}, + "cacheFilter": true, + "dataType": "string", + "displayName": "string", + "filterSource": { + "dataSource": {}, + "displayValuePath": "string", + "rootPath": "string", + "valuePath": "string" + }, + "name": "string", + "required": true, + "timeOptions": [ + { + "info": "string", + "maxValue": 0, + "minValue": 0, + "name": "string", + "value": "string" + } + ], + "type": "string" + } + ], + "formats": [ + { + "format": "string", + "name": "string", + "default": true, + "template": { + "jsTemplateId": "string" + } + } + ], + "schedules": [ + { + "type": "string", + "default": true + } + ], + "viewId": "string", + "viewInfo": "string", + "viewName": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool.py b/ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool.py new file mode 100644 index 000000000..8d0d75295 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool.py @@ -0,0 +1,215 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: reserve_ip_subpool +short_description: Resource module for Reserve Ip Subpool +description: +- Manage operations create, update and delete of the resource Reserve Ip Subpool. +- API to reserve an ip subpool from the global pool. +- API to delete the reserved ip subpool. +- API to update ip subpool from the global pool. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + id: + description: Id path parameter. Id of reserve ip subpool to be deleted. + type: str + ipv4DhcpServers: + description: IPv4 input for dhcp server ip example 1.1.1.1. + elements: str + type: list + ipv4DnsServers: + description: IPv4 input for dns server ip example 4.4.4.4. + elements: str + type: list + ipv4GateWay: + description: Gateway ip address details, example 175.175.0.1. + type: str + version_added: 4.0.0 + ipv4GlobalPool: + description: IP v4 Global pool address with cidr, example 175.175.0.0/16. + type: str + ipv4Prefix: + description: IPv4 prefix value is true, the ip4 prefix length input field is enabled + , if it is false ipv4 total Host input is enable. + type: bool + ipv4PrefixLength: + description: The ipv4 prefix length is required when ipv4prefix value is true. + type: int + ipv4Subnet: + description: IPv4 Subnet address, example 175.175.0.0. + type: str + ipv4TotalHost: + description: IPv4 total host is required when ipv4prefix value is false. + type: int + ipv6AddressSpace: + description: If the value is false only ipv4 input are required, otherwise both + ipv6 and ipv4 are required. + type: bool + ipv6DhcpServers: + description: IPv6 format dhcp server as input example 2001 db8 1234. + elements: str + type: list + ipv6DnsServers: + description: IPv6 format dns server input example 2001 db8 1234. + elements: str + type: list + ipv6GateWay: + description: Gateway ip address details, example 2001 db8 85a3 0 100 1. + type: str + ipv6GlobalPool: + description: IPv6 Global pool address with cidr this is required when Ipv6AddressSpace + value is true, example 2001 db8 85a3 /64. + type: str + ipv6Prefix: + description: Ipv6 prefix value is true, the ip6 prefix length input field is enabled + , if it is false ipv6 total Host input is enable. + type: bool + ipv6PrefixLength: + description: IPv6 prefix length is required when the ipv6prefix value is true. + type: int + ipv6Subnet: + description: IPv6 Subnet address, example 2001 db8 85a3 0 100. + type: str + ipv6TotalHost: + description: IPv6 total host is required when ipv6prefix value is false. + type: int + name: + description: Name of the reserve ip sub pool. + type: str + siteId: + description: SiteId path parameter. Site id to reserve the ip sub pool. + type: str + slaacSupport: + description: Slaac Support. + type: bool + type: + description: Type of the reserve ip sub pool. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings ReserveIPSubpool + description: Complete reference of the ReserveIPSubpool API. + link: https://developer.cisco.com/docs/dna-center/#!reserve-ip-subpool +- name: Cisco DNA Center documentation for Network Settings ReleaseReserveIPSubpool + description: Complete reference of the ReleaseReserveIPSubpool API. + link: https://developer.cisco.com/docs/dna-center/#!release-reserve-ip-subpool +- name: Cisco DNA Center documentation for Network Settings UpdateReserveIPSubpool + description: Complete reference of the UpdateReserveIPSubpool API. + link: https://developer.cisco.com/docs/dna-center/#!update-reserve-ip-subpool +notes: + - SDK Method used are + network_settings.NetworkSettings.release_reserve_ip_subpool, + network_settings.NetworkSettings.reserve_ip_subpool, + network_settings.NetworkSettings.update_reserve_ip_subpool, + + - Paths used are + post /dna/intent/api/v1/reserve-ip-subpool/{siteId}, + delete /dna/intent/api/v1/reserve-ip-subpool/{id}, + put /dna/intent/api/v1/reserve-ip-subpool/{siteId}, + +""" + +EXAMPLES = r""" +- name: Delete by id + cisco.dnac.reserve_ip_subpool: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + id: string + +- name: Create + cisco.dnac.reserve_ip_subpool: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + ipv4DhcpServers: + - string + ipv4DnsServers: + - string + ipv4GateWay: string + ipv4GlobalPool: string + ipv4Prefix: true + ipv4PrefixLength: 0 + ipv4Subnet: string + ipv4TotalHost: 0 + ipv6AddressSpace: true + ipv6DhcpServers: + - string + ipv6DnsServers: + - string + ipv6GateWay: string + ipv6GlobalPool: string + ipv6Prefix: true + ipv6PrefixLength: 0 + ipv6Subnet: string + ipv6TotalHost: 0 + name: string + siteId: string + slaacSupport: true + type: string + +- name: Update by id + cisco.dnac.reserve_ip_subpool: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + id: string + ipv4DhcpServers: + - string + ipv4DnsServers: + - string + ipv4GateWay: string + ipv6AddressSpace: true + ipv6DhcpServers: + - string + ipv6DnsServers: + - string + ipv6GateWay: string + ipv6GlobalPool: string + ipv6Prefix: true + ipv6PrefixLength: 0 + ipv6Subnet: string + ipv6TotalHost: 0 + name: string + siteId: string + slaacSupport: true + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool_create.py b/ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool_create.py new file mode 100644 index 000000000..ad78c5f91 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool_create.py @@ -0,0 +1,155 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: reserve_ip_subpool_create +short_description: Resource module for Reserve Ip Subpool Create +description: +- Manage operation create of the resource Reserve Ip Subpool Create. +- API to reserve an ip subpool from the global pool. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + ipv4DhcpServers: + description: IPv4 input for dhcp server ip example 1.1.1.1. + elements: str + type: list + ipv4DnsServers: + description: IPv4 input for dns server ip example 4.4.4.4. + elements: str + type: list + ipv4GateWay: + description: Gateway ip address details, example 175.175.0.1. + type: str + ipv4GlobalPool: + description: IP v4 Global pool address with cidr, example 175.175.0.0/16. + type: str + ipv4Prefix: + description: IPv4 prefix value is true, the ip4 prefix length input field is enabled + , if it is false ipv4 total Host input is enable. + type: bool + ipv4PrefixLength: + description: The ipv4 prefix length is required when ipv4prefix value is true. + type: int + ipv4Subnet: + description: IPv4 Subnet address, example 175.175.0.0. + type: str + ipv4TotalHost: + description: IPv4 total host is required when ipv4prefix value is false. + type: int + ipv6AddressSpace: + description: If the value is false only ipv4 input are required, otherwise both + ipv6 and ipv4 are required. + type: bool + ipv6DhcpServers: + description: IPv6 format dhcp server as input example 2001 db8 1234. + elements: str + type: list + ipv6DnsServers: + description: IPv6 format dns server input example 2001 db8 1234. + elements: str + type: list + ipv6GateWay: + description: Gateway ip address details, example 2001 db8 85a3 0 100 1. + type: str + ipv6GlobalPool: + description: IPv6 Global pool address with cidr this is required when Ipv6AddressSpace + value is true, example 2001 db8 85a3 /64. + type: str + ipv6Prefix: + description: Ipv6 prefix value is true, the ip6 prefix length input field is enabled + , if it is false ipv6 total Host input is enable. + type: bool + ipv6PrefixLength: + description: IPv6 prefix length is required when the ipv6prefix value is true. + type: int + ipv6Subnet: + description: IPv6 Subnet address, example 2001 db8 85a3 0 100. + type: str + ipv6TotalHost: + description: IPv6 total host is required when ipv6prefix value is false. + type: int + name: + description: Name of the reserve ip sub pool. + type: str + siteId: + description: SiteId path parameter. Site id to reserve the ip sub pool. + type: str + slaacSupport: + description: Slaac Support. + type: bool + type: + description: Type of the reserve ip sub pool. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings ReserveIPSubpool + description: Complete reference of the ReserveIPSubpool API. + link: https://developer.cisco.com/docs/dna-center/#!reserve-ip-subpool +notes: + - SDK Method used are + network_settings.NetworkSettings.reserve_ip_subpool, + + - Paths used are + post /dna/intent/api/v1/reserve-ip-subpool/{siteId}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.reserve_ip_subpool_create: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + ipv4DhcpServers: + - string + ipv4DnsServers: + - string + ipv4GateWay: string + ipv4GlobalPool: string + ipv4Prefix: true + ipv4PrefixLength: 0 + ipv4Subnet: string + ipv4TotalHost: 0 + ipv6AddressSpace: true + ipv6DhcpServers: + - string + ipv6DnsServers: + - string + ipv6GateWay: string + ipv6GlobalPool: string + ipv6Prefix: true + ipv6PrefixLength: 0 + ipv6Subnet: string + ipv6TotalHost: 0 + name: string + siteId: string + slaacSupport: true + type: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool_delete.py b/ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool_delete.py new file mode 100644 index 000000000..d4471c2a9 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool_delete.py @@ -0,0 +1,63 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: reserve_ip_subpool_delete +short_description: Resource module for Reserve Ip Subpool Delete +description: +- Manage operation delete of the resource Reserve Ip Subpool Delete. +- API to delete the reserved ip subpool. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + id: + description: Id path parameter. Id of reserve ip subpool to be deleted. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings ReleaseReserveIPSubpool + description: Complete reference of the ReleaseReserveIPSubpool API. + link: https://developer.cisco.com/docs/dna-center/#!release-reserve-ip-subpool +notes: + - SDK Method used are + network_settings.NetworkSettings.release_reserve_ip_subpool, + + - Paths used are + delete /dna/intent/api/v1/reserve-ip-subpool/{id}, + +""" + +EXAMPLES = r""" +- name: Delete by id + cisco.dnac.reserve_ip_subpool_delete: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + id: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool_info.py b/ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool_info.py new file mode 100644 index 000000000..ab1a52955 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool_info.py @@ -0,0 +1,123 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: reserve_ip_subpool_info +short_description: Information module for Reserve Ip Subpool +description: +- Get all Reserve Ip Subpool. +- API to get the ip subpool info. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + siteId: + description: + - SiteId query parameter. Site id to get the reserve ip associated with the site. + type: str + offset: + description: + - Offset query parameter. Offset/starting row. + type: int + limit: + description: + - Limit query parameter. No of Global Pools to be retrieved. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings GetReserveIPSubpool + description: Complete reference of the GetReserveIPSubpool API. + link: https://developer.cisco.com/docs/dna-center/#!get-reserve-ip-subpool +notes: + - SDK Method used are + network_settings.NetworkSettings.get_reserve_ip_subpool, + + - Paths used are + get /dna/intent/api/v1/reserve-ip-subpool, + +""" + +EXAMPLES = r""" +- name: Get all Reserve Ip Subpool + cisco.dnac.reserve_ip_subpool_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + siteId: string + offset: 0 + limit: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "id": "string", + "groupName": "string", + "ipPools": [ + { + "ipPoolName": "string", + "dhcpServerIps": [ + {} + ], + "gateways": [ + "string" + ], + "createTime": 0, + "lastUpdateTime": 0, + "totalIpAddressCount": 0, + "usedIpAddressCount": 0, + "parentUuid": "string", + "owner": "string", + "shared": true, + "overlapping": true, + "configureExternalDhcp": true, + "usedPercentage": "string", + "clientOptions": {}, + "groupUuid": "string", + "dnsServerIps": [ + {} + ], + "context": [ + { + "owner": "string", + "contextKey": "string", + "contextValue": "string" + } + ], + "ipv6": true, + "id": "string", + "ipPoolCidr": "string" + } + ], + "siteId": "string", + "siteHierarchy": "string", + "type": "string", + "groupOwner": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool_update.py b/ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool_update.py new file mode 100644 index 000000000..3e960395f --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/reserve_ip_subpool_update.py @@ -0,0 +1,137 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: reserve_ip_subpool_update +short_description: Resource module for Reserve Ip Subpool Update +description: +- Manage operation update of the resource Reserve Ip Subpool Update. +- API to update ip subpool from the global pool. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + id: + description: Id query parameter. Id of subpool to be associated with the site. + type: str + ipv4DhcpServers: + description: IPv4 input for dhcp server ip example 1.1.1.1. + elements: str + type: list + ipv4DnsServers: + description: IPv4 input for dns server ip example 4.4.4.4. + elements: str + type: list + ipv4GateWay: + description: Ipv4 Gate Way. + type: str + ipv6AddressSpace: + description: If the value is false only ipv4 input are required, otherwise both + ipv6 and ipv4 are required. + type: bool + ipv6DhcpServers: + description: IPv6 format dhcp server as input example 2001 db8 1234. + elements: str + type: list + ipv6DnsServers: + description: IPv6 format dns server input example 2001 db8 1234. + elements: str + type: list + ipv6GateWay: + description: Gateway ip address details, example 2001 db8 85a3 0 100 1. + type: str + ipv6GlobalPool: + description: IP v6 Global pool address with cidr this is required when Ipv6AddressSpace + value is true, example 2001 db8 85a3 /64. + type: str + ipv6Prefix: + description: IPv6 prefix value is true, the ip6 prefix length input field is enabled + , if it is false ipv6 total Host input is enable. + type: bool + ipv6PrefixLength: + description: IPv6 prefix length is required when the ipv6prefix value is true. + type: int + ipv6Subnet: + description: IPv6 Subnet address, example 2001 db8 85a3 0 100. + type: str + ipv6TotalHost: + description: IPv6 total host is required when ipv6prefix value is false. + type: int + name: + description: Name of the reserve ip sub pool. + type: str + siteId: + description: SiteId path parameter. Site id of site to update sub pool. + type: str + slaacSupport: + description: Slaac Support. + type: bool +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings UpdateReserveIPSubpool + description: Complete reference of the UpdateReserveIPSubpool API. + link: https://developer.cisco.com/docs/dna-center/#!update-reserve-ip-subpool +notes: + - SDK Method used are + network_settings.NetworkSettings.update_reserve_ip_subpool, + + - Paths used are + put /dna/intent/api/v1/reserve-ip-subpool/{siteId}, + + - > + Removed 'type', 'ipv4GlobalPool', 'ipv4Prefix', 'ipv4PrefixLength', 'ipv4Subnet' and 'ipv4TotalHost' options + in v4.3.0. +""" + +EXAMPLES = r""" +- name: Update by id + cisco.dnac.reserve_ip_subpool_update: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + id: string + ipv4DhcpServers: + - string + ipv4DnsServers: + - string + ipv4GateWay: string + ipv6AddressSpace: true + ipv6DhcpServers: + - string + ipv6DnsServers: + - string + ipv6GateWay: string + ipv6GlobalPool: string + ipv6Prefix: true + ipv6PrefixLength: 0 + ipv6Subnet: string + ipv6TotalHost: 0 + name: string + siteId: string + slaacSupport: true + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/role_permissions_info.py b/ansible_collections/cisco/dnac/plugins/modules/role_permissions_info.py new file mode 100644 index 000000000..53d7a9b3a --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/role_permissions_info.py @@ -0,0 +1,69 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: role_permissions_info +short_description: Information module for Role Permissions +description: +- Get all Role Permissions. +- Get permissions for a role from Cisco DNA Center System. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for User and Roles GetPermissionsAPI + description: Complete reference of the GetPermissionsAPI API. + link: https://developer.cisco.com/docs/dna-center/#!get-permissions-api +notes: + - SDK Method used are + userand_roles.UserandRoles.get_permissions_ap_i, + + - Paths used are + get /dna/system/api/v1/role/permissions, + +""" + +EXAMPLES = r""" +- name: Get all Role Permissions + cisco.dnac.role_permissions_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "resource-types": [ + { + "type": "string", + "displayName": "string", + "description": "string", + "defaultPermission": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/roles_info.py b/ansible_collections/cisco/dnac/plugins/modules/roles_info.py new file mode 100644 index 000000000..279f9ed10 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/roles_info.py @@ -0,0 +1,82 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: roles_info +short_description: Information module for Roles +description: +- Get all Roles. +- Get all roles for the Cisco DNA Center system. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for User and Roles GetRolesAPI + description: Complete reference of the GetRolesAPI API. + link: https://developer.cisco.com/docs/dna-center/#!get-roles-api +notes: + - SDK Method used are + userand_roles.UserandRoles.get_roles_ap_i, + + - Paths used are + get /dna/system/api/v1/roles, + +""" + +EXAMPLES = r""" +- name: Get all Roles + cisco.dnac.roles_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "roles": [ + { + "resourceTypes": [ + { + "operations": [ + "string" + ], + "type": "string" + } + ], + "meta": { + "createdBy": "string", + "created": "string", + "lastModified": "string" + }, + "roleId": "string", + "name": "string", + "description": "string", + "type": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/sda_count_info.py new file mode 100644 index 000000000..a80b1d359 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_count_info.py @@ -0,0 +1,64 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_count_info +short_description: Information module for Sda Count +description: +- Get all Sda Count. +- Get SDA Fabric Count. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +notes: + - SDK Method used are + sda.Sda.get_sda_fabric_count, + + - Paths used are + get /dna/intent/api/v1/business/sda/fabric/count, + +""" + +EXAMPLES = r""" +- name: Get all Sda Count + cisco.dnac.sda_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: + custom: value + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "status": "string", + "description": "string", + "fabricCount": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_device_info.py b/ansible_collections/cisco/dnac/plugins/modules/sda_device_info.py new file mode 100644 index 000000000..db40c572b --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_device_info.py @@ -0,0 +1,74 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_device_info +short_description: Information module for Sda Device +description: +- Get all Sda Device. +- Get device info from SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceManagementIpAddress: + description: + - DeviceManagementIpAddress query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA GetDeviceInfoFromSDAFabric + description: Complete reference of the GetDeviceInfoFromSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-info-from-sda-fabric +notes: + - SDK Method used are + sda.Sda.get_device_info, + + - Paths used are + get /dna/intent/api/v1/business/sda/device, + +""" + +EXAMPLES = r""" +- name: Get all Sda Device + cisco.dnac.sda_device_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceManagementIpAddress: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "name": "string", + "roles": [ + "string" + ], + "deviceManagementIpAddress": "string", + "siteHierarchy": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_device_role_info.py b/ansible_collections/cisco/dnac/plugins/modules/sda_device_role_info.py new file mode 100644 index 000000000..2a857d803 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_device_role_info.py @@ -0,0 +1,74 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_device_role_info +short_description: Information module for Sda Device Role +description: +- Get all Sda Device Role. +- Get device role in SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceManagementIpAddress: + description: + - DeviceManagementIpAddress query parameter. Device Management IP Address. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA GetDeviceRoleInSDAFabric + description: Complete reference of the GetDeviceRoleInSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!get-device-role-in-sda-fabric +notes: + - SDK Method used are + sda.Sda.get_device_role_in_sda_fabric, + + - Paths used are + get /dna/intent/api/v1/business/sda/device/role, + +""" + +EXAMPLES = r""" +- name: Get all Sda Device Role + cisco.dnac.sda_device_role_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceManagementIpAddress: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "status": "string", + "description": "string", + "roles": [ + "string" + ] + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_fabric.py b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric.py new file mode 100644 index 000000000..158e6f1e6 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric.py @@ -0,0 +1,78 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_fabric +short_description: Resource module for Sda Fabric +description: +- Manage operations create and delete of the resource Sda Fabric. +- Add SDA Fabric. +- Delete SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + fabricName: + description: FabricName query parameter. Fabric Name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +notes: + - SDK Method used are + sda.Sda.add_fabric, + sda.Sda.delete_sda_fabric, + + - Paths used are + post /dna/intent/api/v1/business/sda/fabric, + delete /dna/intent/api/v1/business/sda/fabric, + +""" + +EXAMPLES = r""" +- name: Delete all + cisco.dnac.sda_fabric: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + fabricName: string + +- name: Create + cisco.dnac.sda_fabric: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + fabricName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "taskId": "string", + "taskStatusUrl": "string", + "executionStatusUrl": "string", + "executionId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_authentication_profile.py b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_authentication_profile.py new file mode 100644 index 000000000..51b32887b --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_authentication_profile.py @@ -0,0 +1,123 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_fabric_authentication_profile +short_description: Resource module for Sda Fabric Authentication Profile +description: +- Manage operations create, update and delete of the resource Sda Fabric Authentication Profile. +- Add default authentication template in SDA Fabric. +- Delete default authentication profile in SDA Fabric. +- Update default authentication profile in SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + payload: + description: Sda Fabric Authentication Profile's payload. + elements: dict + suboptions: + authenticateTemplateName: + description: Authenticate Template Name. + type: str + version_added: 4.0.0 + siteNameHierarchy: + description: Path of sda Fabric Site. + type: str + type: list + siteNameHierarchy: + description: SiteNameHierarchy query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA AddDefaultAuthenticationTemplateInSDAFabric + description: Complete reference of the AddDefaultAuthenticationTemplateInSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!add-default-authentication-template-in-sda-fabric +- name: Cisco DNA Center documentation for SDA DeleteDefaultAuthenticationProfileFromSDAFabric + description: Complete reference of the DeleteDefaultAuthenticationProfileFromSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!delete-default-authentication-profile-from-sda-fabric +- name: Cisco DNA Center documentation for SDA UpdateDefaultAuthenticationProfileInSDAFabric + description: Complete reference of the UpdateDefaultAuthenticationProfileInSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!update-default-authentication-profile-in-sda-fabric +notes: + - SDK Method used are + sda.Sda.add_default_authentication_profile, + sda.Sda.delete_default_authentication_profile, + sda.Sda.update_default_authentication_profile, + + - Paths used are + post /dna/intent/api/v1/business/sda/authentication-profile, + delete /dna/intent/api/v1/business/sda/authentication-profile, + put /dna/intent/api/v1/business/sda/authentication-profile, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.sda_fabric_authentication_profile: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - authenticateTemplateName: string + siteNameHierarchy: string + +- name: Update all + cisco.dnac.sda_fabric_authentication_profile: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - authenticateTemplateName: string + authenticationOrder: string + dot1xToMabFallbackTimeout: string + numberOfHosts: string + siteNameHierarchy: string + wakeOnLan: true + +- name: Delete all + cisco.dnac.sda_fabric_authentication_profile: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + siteNameHierarchy: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "taskId": "string", + "taskStatusUrl": "string", + "executionStatusUrl": "string", + "executionId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_authentication_profile_info.py b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_authentication_profile_info.py new file mode 100644 index 000000000..7d810bb81 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_authentication_profile_info.py @@ -0,0 +1,83 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_fabric_authentication_profile_info +short_description: Information module for Sda Fabric Authentication Profile +description: +- Get all Sda Fabric Authentication Profile. +- Get default authentication profile from SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + siteNameHierarchy: + description: + - SiteNameHierarchy query parameter. + type: str + authenticateTemplateName: + version_added: "4.0.0" + description: + - AuthenticateTemplateName query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA GetDefaultAuthenticationProfileFromSDAFabric + description: Complete reference of the GetDefaultAuthenticationProfileFromSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!get-default-authentication-profile-from-sda-fabric +notes: + - SDK Method used are + sda.Sda.get_default_authentication_profile, + + - Paths used are + get /dna/intent/api/v1/business/sda/authentication-profile, + +""" + +EXAMPLES = r""" +- name: Get all Sda Fabric Authentication Profile + cisco.dnac.sda_fabric_authentication_profile_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + siteNameHierarchy: string + authenticateTemplateName: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "siteNameHierarchy": "string", + "authenticateTemplateName": "string", + "authenticationOrder": "string", + "dot1xToMabFallbackTimeout": "string", + "wakeOnLan": true, + "numberOfHosts": "string", + "status": "string", + "description": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_border_device.py b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_border_device.py new file mode 100644 index 000000000..960e9d7cd --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_border_device.py @@ -0,0 +1,213 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_fabric_border_device +short_description: Resource module for Sda Fabric Border Device +description: +- Manage operations create and delete of the resource Sda Fabric Border Device. +- Add border device in SDA Fabric. +- Delete border device from SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + deviceManagementIpAddress: + description: DeviceManagementIpAddress query parameter. + type: str + version_added: 4.0.0 + payload: + description: Sda Fabric Border Device's payload. + elements: dict + suboptions: + borderPriority: + description: Border priority associated with a given device. Allowed range for + Border Priority is 1-9. A lower value indicates higher priority. E.g., a priority + of 1 takes precedence over 5. Default priority would be set to 10. + type: str + borderSessionType: + description: Border Session Type. + type: str + version_added: 4.0.0 + borderWithExternalConnectivity: + description: Border With External Connectivity (Note True for transit and False + for non-transit border). + type: bool + connectedToInternet: + description: Connected to Internet. + type: bool + version_added: 4.0.0 + deviceManagementIpAddress: + description: Management Ip Address of the provisioned Device. + type: str + version_added: 4.0.0 + deviceRole: + description: Supported Device Roles in SD-Access fabric. Allowed roles are "Border_Node","Control_Plane_Nod... + E.g. "Border_Node" or "Border_Node", "Control_Plane_Node" or "Border_Node", + "Control_Plane_Node","Edge_Node". + elements: str + type: list + externalConnectivityIpPoolName: + description: External Connectivity IpPool Name. + type: str + version_added: 4.0.0 + externalConnectivitySettings: + description: Sda Fabric Border Device's externalConnectivitySettings. + elements: dict + suboptions: + externalAutonomouSystemNumber: + description: External Autonomous System Number peer (e.g.,1-65535). + type: str + version_added: 4.0.0 + interfaceDescription: + description: Interface Description. + type: str + interfaceName: + description: Interface Name. + type: str + version_added: 4.0.0 + l2Handoff: + description: Sda Fabric Border Device's l2Handoff. + elements: dict + suboptions: + virtualNetworkName: + description: Virtual Network Name, that is associated to Fabric Site. + type: str + version_added: 4.0.0 + vlanName: + description: Vlan Name of L2 Handoff. + type: str + type: list + l3Handoff: + description: Sda Fabric Border Device's l3Handoff. + elements: dict + suboptions: + virtualNetwork: + description: Sda Fabric Border Device's virtualNetwork. + suboptions: + virtualNetworkName: + description: Virtual Network Name, that is associated to Fabric + Site. + type: str + version_added: 4.0.0 + vlanId: + description: Vlan Id (e.g.,2-4096 except for reserved VLANs (1002-1005, + 2046, 4095)). + type: str + version_added: 4.0.0 + type: dict + version_added: 4.0.0 + type: list + version_added: 4.0.0 + type: list + version_added: 4.0.0 + externalDomainRoutingProtocolName: + description: External Domain Routing Protocol Name. + type: str + internalAutonomouSystemNumber: + description: Internal Autonomouns System Number (e.g.,1-65535). + type: str + routeDistributionProtocol: + description: Route Distribution Protocol for Control Plane Device. Allowed values + are "LISP_BGP" or "LISP_PUB_SUB". Default value is "LISP_BGP". + type: str + sdaTransitNetworkName: + description: SD-Access Transit Network Name. + type: str + siteNameHierarchy: + description: Site Name Hierarchy of provisioned Device(site should be part of + Fabric Site). + type: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA AddBorderDeviceInSDAFabric + description: Complete reference of the AddBorderDeviceInSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!add-border-device-in-sda-fabric +- name: Cisco DNA Center documentation for SDA DeleteBorderDeviceFromSDAFabric + description: Complete reference of the DeleteBorderDeviceFromSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!delete-border-device-from-sda-fabric +notes: + - SDK Method used are + sda.Sda.adds_border_device, + sda.Sda.deletes_border_device, + + - Paths used are + post /dna/intent/api/v1/business/sda/border-device, + delete /dna/intent/api/v1/business/sda/border-device, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.sda_fabric_border_device: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - borderPriority: string + borderSessionType: string + borderWithExternalConnectivity: true + connectedToInternet: true + deviceManagementIpAddress: string + deviceRole: + - string + externalConnectivityIpPoolName: string + externalConnectivitySettings: + - externalAutonomouSystemNumber: string + interfaceDescription: string + interfaceName: string + l2Handoff: + - virtualNetworkName: string + vlanName: string + l3Handoff: + - virtualNetwork: + virtualNetworkName: string + vlanId: string + externalDomainRoutingProtocolName: string + internalAutonomouSystemNumber: string + routeDistributionProtocol: string + sdaTransitNetworkName: string + siteNameHierarchy: string + +- name: Delete all + cisco.dnac.sda_fabric_border_device: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + deviceManagementIpAddress: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "taskId": "string", + "taskStatusUrl": "string", + "executionStatusUrl": "string", + "executionId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_border_device_info.py b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_border_device_info.py new file mode 100644 index 000000000..329040201 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_border_device_info.py @@ -0,0 +1,239 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_fabric_border_device_info +short_description: Information module for Sda Fabric Border Device +description: +- Get all Sda Fabric Border Device. +- Get border device detail from SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceManagementIpAddress: + version_added: "4.0.0" + description: + - DeviceManagementIpAddress query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA GetBorderDeviceDetailFromSDAFabric + description: Complete reference of the GetBorderDeviceDetailFromSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!get-border-device-detail-from-sda-fabric +notes: + - SDK Method used are + sda.Sda.gets_border_device_detail, + + - Paths used are + get /dna/intent/api/v1/business/sda/border-device, + +""" + +EXAMPLES = r""" +- name: Get all Sda Fabric Border Device + cisco.dnac.sda_fabric_border_device_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceManagementIpAddress: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "payload": { + "id": "string", + "instanceId": 0, + "authEntityId": 0, + "displayName": "string", + "authEntityClass": 0, + "instanceTenantId": "string", + "deployPending": "string", + "instanceVersion": 0, + "createTime": 0, + "deployed": true, + "isSeeded": true, + "isStale": true, + "lastUpdateTime": 0, + "name": "string", + "namespace": "string", + "provisioningState": "string", + "resourceVersion": 0, + "targetIdList": [ + {} + ], + "type": "string", + "cfsChangeInfo": [ + {} + ], + "customProvisions": [ + {} + ], + "configs": [ + {} + ], + "managedSites": [ + {} + ], + "networkDeviceId": "string", + "roles": [ + "string" + ], + "saveWanConnectivityDetailsOnly": true, + "siteId": "string", + "akcSettingsCfs": [ + {} + ], + "deviceInterfaceInfo": [ + {} + ], + "deviceSettings": { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceTenantId": "string", + "deployPending": "string", + "instanceVersion": 0, + "connectedTo": [ + {} + ], + "cpu": 0, + "dhcpEnabled": true, + "externalConnectivityIpPool": "string", + "externalDomainRoutingProtocol": "string", + "internalDomainProtocolNumber": "string", + "memory": 0, + "nodeType": [ + "string" + ], + "storage": 0, + "extConnectivitySettings": [ + { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceTenantId": "string", + "deployPending": "string", + "instanceVersion": 0, + "externalDomainProtocolNumber": "string", + "interfaceUuid": "string", + "policyPropagationEnabled": true, + "policySgtTag": 0, + "l2Handoff": [ + {} + ], + "l3Handoff": [ + { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceTenantId": "string", + "deployPending": "string", + "instanceVersion": 0, + "localIpAddress": "string", + "remoteIpAddress": "string", + "vlanId": 0, + "virtualNetwork": { + "idRef": "string" + } + } + ] + } + ] + }, + "networkWideSettings": { + "id": "string", + "instanceId": 0, + "displayName": "string", + "instanceTenantId": "string", + "deployPending": "string", + "instanceVersion": 0, + "aaa": [ + {} + ], + "cmx": [ + {} + ], + "dhcp": [ + { + "id": "string", + "ipAddress": { + "id": "string", + "paddedAddress": "string", + "addressType": "string", + "address": "string" + } + } + ], + "dns": [ + { + "id": "string", + "domainName": "string", + "ip": { + "id": "string", + "paddedAddress": "string", + "addressType": "string", + "address": "string" + } + } + ], + "ldap": [ + {} + ], + "nativeVlan": [ + {} + ], + "netflow": [ + {} + ], + "ntp": [ + {} + ], + "snmp": [ + {} + ], + "syslogs": [ + {} + ] + }, + "otherDevice": [ + {} + ], + "transitNetworks": [ + { + "idRef": "string" + } + ], + "virtualNetwork": [ + {} + ], + "wlan": [ + {} + ] + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_control_plane_device.py b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_control_plane_device.py new file mode 100644 index 000000000..2f7189b35 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_control_plane_device.py @@ -0,0 +1,97 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_fabric_control_plane_device +short_description: Resource module for Sda Fabric Control Plane Device +description: +- Manage operations create and delete of the resource Sda Fabric Control Plane Device. +- Add control plane device in SDA Fabric. +- Delete control plane device in SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + deviceManagementIpAddress: + description: DeviceManagementIpAddress query parameter. + type: str + version_added: 4.0.0 + routeDistributionProtocol: + description: Route Distribution Protocol for Control Plane Device. Allowed values + are "LISP_BGP" or "LISP_PUB_SUB". Default value is "LISP_BGP". + type: str + siteNameHierarchy: + description: SiteNameHierarchy of the Provisioned Device(site should be part of + Fabric Site). + type: str + version_added: 4.0.0 +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA AddControlPlaneDeviceInSDAFabric + description: Complete reference of the AddControlPlaneDeviceInSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!add-control-plane-device-in-sda-fabric +- name: Cisco DNA Center documentation for SDA DeleteControlPlaneDeviceInSDAFabric + description: Complete reference of the DeleteControlPlaneDeviceInSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!delete-control-plane-device-in-sda-fabric +notes: + - SDK Method used are + sda.Sda.add_control_plane_device, + sda.Sda.delete_control_plane_device, + + - Paths used are + post /dna/intent/api/v1/business/sda/control-plane-device, + delete /dna/intent/api/v1/business/sda/control-plane-device, + +""" + +EXAMPLES = r""" +- name: Delete all + cisco.dnac.sda_fabric_control_plane_device: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + deviceManagementIpAddress: string + +- name: Create + cisco.dnac.sda_fabric_control_plane_device: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + deviceManagementIpAddress: string + routeDistributionProtocol: string + siteNameHierarchy: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "taskId": "string", + "taskStatusUrl": "string", + "executionStatusUrl": "string", + "executionId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_control_plane_device_info.py b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_control_plane_device_info.py new file mode 100644 index 000000000..837a4d543 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_control_plane_device_info.py @@ -0,0 +1,74 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_fabric_control_plane_device_info +short_description: Information module for Sda Fabric Control Plane Device +description: +- Get all Sda Fabric Control Plane Device. +- Get control plane device from SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceManagementIpAddress: + version_added: "4.0.0" + description: + - DeviceManagementIpAddress query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA GetControlPlaneDeviceFromSDAFabric + description: Complete reference of the GetControlPlaneDeviceFromSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!get-control-plane-device-from-sda-fabric +notes: + - SDK Method used are + sda.Sda.get_control_plane_device, + + - Paths used are + get /dna/intent/api/v1/business/sda/control-plane-device, + +""" + +EXAMPLES = r""" +- name: Get all Sda Fabric Control Plane Device + cisco.dnac.sda_fabric_control_plane_device_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceManagementIpAddress: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "deviceManagementIpAddress": "string", + "deviceName": "string", + "roles": "string", + "siteNameHierarchy": "string", + "routeDistributionProtocol": "string", + "status": "string", + "description": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_edge_device.py b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_edge_device.py new file mode 100644 index 000000000..800ca6d3c --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_edge_device.py @@ -0,0 +1,91 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_fabric_edge_device +short_description: Resource module for Sda Fabric Edge Device +description: +- Manage operations create and delete of the resource Sda Fabric Edge Device. +- Add edge device in SDA Fabric. +- Delete edge device from SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + deviceManagementIpAddress: + description: Management Ip Address of the Device which is provisioned successfully. + type: str + siteNameHierarchy: + description: SiteNameHierarchy of the Provisioned Device(site should be part of + Fabric Site). + type: str + version_added: 4.0.0 +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA AddEdgeDeviceInSDAFabric + description: Complete reference of the AddEdgeDeviceInSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!add-edge-device-in-sda-fabric +- name: Cisco DNA Center documentation for SDA DeleteEdgeDeviceFromSDAFabric + description: Complete reference of the DeleteEdgeDeviceFromSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!delete-edge-device-from-sda-fabric +notes: + - SDK Method used are + sda.Sda.add_edge_device, + sda.Sda.delete_edge_device, + + - Paths used are + post /dna/intent/api/v1/business/sda/edge-device, + delete /dna/intent/api/v1/business/sda/edge-device, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.sda_fabric_edge_device: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + deviceManagementIpAddress: string + siteNameHierarchy: string + +- name: Delete all + cisco.dnac.sda_fabric_edge_device: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + deviceManagementIpAddress: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "taskId": "string", + "taskStatusUrl": "string", + "executionStatusUrl": "string", + "executionId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_edge_device_info.py b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_edge_device_info.py new file mode 100644 index 000000000..7d94ac466 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_edge_device_info.py @@ -0,0 +1,73 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_fabric_edge_device_info +short_description: Information module for Sda Fabric Edge Device +description: +- Get all Sda Fabric Edge Device. +- Get edge device from SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceManagementIpAddress: + description: + - DeviceManagementIpAddress query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA GetEdgeDeviceFromSDAFabric + description: Complete reference of the GetEdgeDeviceFromSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!get-edge-device-from-sda-fabric +notes: + - SDK Method used are + sda.Sda.get_edge_device, + + - Paths used are + get /dna/intent/api/v1/business/sda/edge-device, + +""" + +EXAMPLES = r""" +- name: Get all Sda Fabric Edge Device + cisco.dnac.sda_fabric_edge_device_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceManagementIpAddress: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "deviceManagementIpAddress": "string", + "deviceName": "string", + "roles": "string", + "siteNameHierarchy": "string", + "fabricSiteNameHierarchy": "string", + "status": "string", + "description": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_info.py b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_info.py new file mode 100644 index 000000000..c0e49de7d --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_info.py @@ -0,0 +1,69 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_fabric_info +short_description: Information module for Sda Fabric +description: +- Get all Sda Fabric. +- Get SDA Fabric Info. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + fabricName: + description: + - FabricName query parameter. Fabric Name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +notes: + - SDK Method used are + sda.Sda.get_sda_fabric_info, + + - Paths used are + get /dna/intent/api/v1/business/sda/fabric, + +""" + +EXAMPLES = r""" +- name: Get all Sda Fabric + cisco.dnac.sda_fabric_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: + custom: value + fabricName: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "executionId": "string", + "fabricName": "string", + "fabricType": "string", + "fabricDomainType": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_site.py b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_site.py new file mode 100644 index 000000000..2b7e6f8d4 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_site.py @@ -0,0 +1,97 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_fabric_site +short_description: Resource module for Sda Fabric Site +description: +- Manage operations create and delete of the resource Sda Fabric Site. +- Add Site in SDA Fabric. +- Delete Site from SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + fabricName: + description: Warning - Starting DNA Center 2.2.3.5 release, this field has been + deprecated. SD-Access Fabric does not need it anymore. It will be removed in future + DNA Center releases. + type: str + version_added: 4.0.0 + fabricType: + description: Type of SD-Access Fabric. Allowed values are "FABRIC_SITE" or "FABRIC_ZONE". + Default value is "FABRIC_SITE". + type: str + siteNameHierarchy: + description: SiteNameHierarchy query parameter. Site Name Hierarchy. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA AddSiteInSDAFabric + description: Complete reference of the AddSiteInSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!add-site-in-sda-fabric +- name: Cisco DNA Center documentation for SDA DeleteSiteFromSDAFabric + description: Complete reference of the DeleteSiteFromSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!delete-site-from-sda-fabric +notes: + - SDK Method used are + sda.Sda.add_site, + sda.Sda.delete_site, + + - Paths used are + post /dna/intent/api/v1/business/sda/fabric-site, + delete /dna/intent/api/v1/business/sda/fabric-site, + +""" + +EXAMPLES = r""" +- name: Delete all + cisco.dnac.sda_fabric_site: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + siteNameHierarchy: string + +- name: Create + cisco.dnac.sda_fabric_site: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + fabricName: string + fabricType: string + siteNameHierarchy: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "taskId": "string", + "taskStatusUrl": "string", + "executionStatusUrl": "string", + "executionId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_site_info.py b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_site_info.py new file mode 100644 index 000000000..c0c115828 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_fabric_site_info.py @@ -0,0 +1,72 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_fabric_site_info +short_description: Information module for Sda Fabric Site +description: +- Get all Sda Fabric Site. +- Get Site info from SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + siteNameHierarchy: + description: + - SiteNameHierarchy query parameter. Site Name Hierarchy. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA GetSiteFromSDAFabric + description: Complete reference of the GetSiteFromSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!get-site-from-sda-fabric +notes: + - SDK Method used are + sda.Sda.get_site, + + - Paths used are + get /dna/intent/api/v1/business/sda/fabric-site, + +""" + +EXAMPLES = r""" +- name: Get all Sda Fabric Site + cisco.dnac.sda_fabric_site_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + siteNameHierarchy: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "siteNameHierarchy": "string", + "fabricName": "string", + "fabricType": "string", + "fabricDomainType": "string", + "status": "string", + "description": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_multicast.py b/ansible_collections/cisco/dnac/plugins/modules/sda_multicast.py new file mode 100644 index 000000000..4ee828f02 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_multicast.py @@ -0,0 +1,131 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_multicast +short_description: Resource module for Sda Multicast +description: +- Manage operations create and delete of the resource Sda Multicast. +- Add multicast in SDA fabric. +- Delete multicast from SDA fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + multicastMethod: + description: Multicast Method. + type: str + multicastType: + description: Multicast Type. + type: str + multicastVnInfo: + description: Sda Multicast's multicastVnInfo. + elements: dict + suboptions: + externalRpIpAddress: + description: ExternalRpIpAddress, required if multicastType is asm_with_external_rp. + type: str + internalRpIpAddress: + description: InternalRpIpAddress, required if multicastType is asm_with_internal_rp. + elements: str + type: list + ipPoolName: + description: Ip Pool Name, that is reserved to Fabric Site. + type: str + ssmInfo: + description: Sda Multicast's ssmInfo. + elements: dict + suboptions: + ssmGroupRange: + description: Valid SSM group range ip address(e.g., 230.0.0.0). + type: str + ssmWildcardMask: + description: Valid SSM Wildcard Mask ip address(e.g.,0.255.255.255). + type: str + type: list + virtualNetworkName: + description: Virtual Network Name, that is associated to Fabric Site. + type: str + type: list + siteNameHierarchy: + description: Full path of sda Fabric Site. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA AddMulticastInSDAFabric + description: Complete reference of the AddMulticastInSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!add-multicast-in-sda-fabric +- name: Cisco DNA Center documentation for SDA DeleteMulticastFromSDAFabric + description: Complete reference of the DeleteMulticastFromSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!delete-multicast-from-sda-fabric +notes: + - SDK Method used are + sda.Sda.add_multicast_in_sda_fabric, + sda.Sda.delete_multicast_from_sda_fabric, + + - Paths used are + post /dna/intent/api/v1/business/sda/multicast, + delete /dna/intent/api/v1/business/sda/multicast, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.sda_multicast: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + multicastMethod: string + multicastType: string + multicastVnInfo: + - externalRpIpAddress: string + internalRpIpAddress: + - string + ipPoolName: string + ssmInfo: + - ssmGroupRange: string + ssmWildcardMask: string + virtualNetworkName: string + siteNameHierarchy: string + +- name: Delete all + cisco.dnac.sda_multicast: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + siteNameHierarchy: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "taskId": "string", + "taskStatusUrl": "string", + "executionStatusUrl": "string", + "executionId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_multicast_info.py b/ansible_collections/cisco/dnac/plugins/modules/sda_multicast_info.py new file mode 100644 index 000000000..959c9ed2f --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_multicast_info.py @@ -0,0 +1,86 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_multicast_info +short_description: Information module for Sda Multicast +description: +- Get all Sda Multicast. +- Get multicast details from SDA fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + siteNameHierarchy: + description: + - SiteNameHierarchy query parameter. Fabric site name hierarchy. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA GetMulticastDetailsFromSDAFabric + description: Complete reference of the GetMulticastDetailsFromSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!get-multicast-details-from-sda-fabric +notes: + - SDK Method used are + sda.Sda.get_multicast_details_from_sda_fabric, + + - Paths used are + get /dna/intent/api/v1/business/sda/multicast, + +""" + +EXAMPLES = r""" +- name: Get all Sda Multicast + cisco.dnac.sda_multicast_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + siteNameHierarchy: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "multicastMethod": "string", + "multicastType": "string", + "multicastVnInfo": [ + { + "virtualNetworkName": "string", + "ipPoolName": "string", + "internalRpIpAddress": [ + "string" + ], + "externalRpIpAddress": "string", + "ssmInfo": [ + { + "ssmGroupRange": "string", + "ssmWildcardMask": "string" + } + ] + } + ], + "status": "string", + "description": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_port_assignment_for_access_point.py b/ansible_collections/cisco/dnac/plugins/modules/sda_port_assignment_for_access_point.py new file mode 100644 index 000000000..39b7df6e5 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_port_assignment_for_access_point.py @@ -0,0 +1,111 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_port_assignment_for_access_point +short_description: Resource module for Sda Port Assignment For Access Point +description: +- Manage operations create and delete of the resource Sda Port Assignment For Access Point. +- Add Port assignment for access point in SDA Fabric. +- Delete Port assignment for access point in SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + authenticateTemplateName: + description: Authenticate TemplateName associated to Fabric Site. + type: str + version_added: 4.0.0 + dataIpAddressPoolName: + description: Ip Pool Name, that is assigned to INFRA_VN. + type: str + version_added: 4.0.0 + deviceManagementIpAddress: + description: Management Ip Address of the edge device. + type: str + version_added: 4.0.0 + interfaceDescription: + description: Details or note of interface port assignment. + type: str + version_added: 4.0.0 + interfaceName: + description: Interface Name of the edge device. + type: str + siteNameHierarchy: + description: Path of sda Fabric Site. + type: str + version_added: 4.0.0 +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA AddPortAssignmentForAccessPointInSDAFabric + description: Complete reference of the AddPortAssignmentForAccessPointInSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!add-port-assignment-for-access-point-in-sda-fabric +- name: Cisco DNA Center documentation for SDA DeletePortAssignmentForAccessPointInSDAFabric + description: Complete reference of the DeletePortAssignmentForAccessPointInSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!delete-port-assignment-for-access-point-in-sda-fabric +notes: + - SDK Method used are + sda.Sda.add_port_assignment_for_access_point, + sda.Sda.delete_port_assignment_for_access_point, + + - Paths used are + post /dna/intent/api/v1/business/sda/hostonboarding/access-point, + delete /dna/intent/api/v1/business/sda/hostonboarding/access-point, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.sda_port_assignment_for_access_point: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + authenticateTemplateName: string + dataIpAddressPoolName: string + deviceManagementIpAddress: string + interfaceDescription: string + interfaceName: string + siteNameHierarchy: string + +- name: Delete all + cisco.dnac.sda_port_assignment_for_access_point: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + deviceManagementIpAddress: string + interfaceName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "taskId": "string", + "taskStatusUrl": "string", + "executionStatusUrl": "string", + "executionId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_port_assignment_for_access_point_info.py b/ansible_collections/cisco/dnac/plugins/modules/sda_port_assignment_for_access_point_info.py new file mode 100644 index 000000000..45dc1ea39 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_port_assignment_for_access_point_info.py @@ -0,0 +1,81 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_port_assignment_for_access_point_info +short_description: Information module for Sda Port Assignment For Access Point +description: +- Get all Sda Port Assignment For Access Point. +- Get Port assignment for access point in SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceManagementIpAddress: + version_added: "4.0.0" + description: + - DeviceManagementIpAddress query parameter. + type: str + interfaceName: + description: + - InterfaceName query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA GetPortAssignmentForAccessPointInSDAFabric + description: Complete reference of the GetPortAssignmentForAccessPointInSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!get-port-assignment-for-access-point-in-sda-fabric +notes: + - SDK Method used are + sda.Sda.get_port_assignment_for_access_point, + + - Paths used are + get /dna/intent/api/v1/business/sda/hostonboarding/access-point, + +""" + +EXAMPLES = r""" +- name: Get all Sda Port Assignment For Access Point + cisco.dnac.sda_port_assignment_for_access_point_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceManagementIpAddress: string + interfaceName: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "siteNameHierarchy": "string", + "deviceManagementIpAddress": "string", + "interfaceName": "string", + "dataIpAddressPoolName": "string", + "voiceIpAddressPoolName": "string", + "scalableGroupName": "string", + "authenticateTemplateName": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_port_assignment_for_user_device.py b/ansible_collections/cisco/dnac/plugins/modules/sda_port_assignment_for_user_device.py new file mode 100644 index 000000000..15c389ce6 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_port_assignment_for_user_device.py @@ -0,0 +1,128 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_port_assignment_for_user_device +short_description: Resource module for Sda Port Assignment For User Device +description: +- Manage operations create and delete of the resource Sda Port Assignment For User Device. +- Add Port assignment for user device in SDA Fabric. +- Delete Port assignment for user device in SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + authenticateTemplateName: + description: Authenticate TemplateName associated with siteNameHierarchy. + type: str + version_added: 4.0.0 + dataIpAddressPoolName: + description: Ip Pool Name, that is assigned to virtual network with traffic type + as DATA(can't be empty if voiceIpAddressPoolName is empty). + type: str + version_added: 4.0.0 + deviceManagementIpAddress: + description: DeviceManagementIpAddress query parameter. + type: str + interfaceDescription: + description: User defined text message for port assignment. + type: str + version_added: 4.0.0 + interfaceName: + description: InterfaceName query parameter. + type: str + interfaceNames: + description: List of Interface Names on the Edge Node Device. E.g."GigabitEthernet1/0/3","GigabitEthernet1/0/4". + elements: str + type: list + scalableGroupName: + description: Scalable Group name associated with VN. + type: str + version_added: 4.0.0 + siteNameHierarchy: + description: Complete Path of SD-Access Fabric Site. + type: str + version_added: 4.0.0 + voiceIpAddressPoolName: + description: Ip Pool Name, that is assigned to virtual network with traffic type + as VOICE(can't be empty if dataIpAddressPoolName is empty). + type: str + version_added: 4.0.0 +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA AddPortAssignmentForUserDeviceInSDAFabric + description: Complete reference of the AddPortAssignmentForUserDeviceInSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!add-port-assignment-for-user-device-in-sda-fabric +- name: Cisco DNA Center documentation for SDA DeletePortAssignmentForUserDeviceInSDAFabric + description: Complete reference of the DeletePortAssignmentForUserDeviceInSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!delete-port-assignment-for-user-device-in-sda-fabric +notes: + - SDK Method used are + sda.Sda.add_port_assignment_for_user_device, + sda.Sda.delete_port_assignment_for_user_device, + + - Paths used are + post /dna/intent/api/v1/business/sda/hostonboarding/user-device, + delete /dna/intent/api/v1/business/sda/hostonboarding/user-device, + +""" + +EXAMPLES = r""" +- name: Delete all + cisco.dnac.sda_port_assignment_for_user_device: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + deviceManagementIpAddress: string + interfaceName: string + +- name: Create + cisco.dnac.sda_port_assignment_for_user_device: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + authenticateTemplateName: string + dataIpAddressPoolName: string + deviceManagementIpAddress: string + interfaceDescription: string + interfaceName: string + interfaceNames: + - string + scalableGroupName: string + siteNameHierarchy: string + voiceIpAddressPoolName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "taskId": "string", + "taskStatusUrl": "string", + "executionStatusUrl": "string", + "executionId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_port_assignment_for_user_device_info.py b/ansible_collections/cisco/dnac/plugins/modules/sda_port_assignment_for_user_device_info.py new file mode 100644 index 000000000..e62e9ae3c --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_port_assignment_for_user_device_info.py @@ -0,0 +1,80 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_port_assignment_for_user_device_info +short_description: Information module for Sda Port Assignment For User Device +description: +- Get all Sda Port Assignment For User Device. +- Get Port assignment for user device in SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceManagementIpAddress: + description: + - DeviceManagementIpAddress query parameter. + type: str + interfaceName: + description: + - InterfaceName query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA GetPortAssignmentForUserDeviceInSDAFabric + description: Complete reference of the GetPortAssignmentForUserDeviceInSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!get-port-assignment-for-user-device-in-sda-fabric +notes: + - SDK Method used are + sda.Sda.get_port_assignment_for_user_device, + + - Paths used are + get /dna/intent/api/v1/business/sda/hostonboarding/user-device, + +""" + +EXAMPLES = r""" +- name: Get all Sda Port Assignment For User Device + cisco.dnac.sda_port_assignment_for_user_device_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceManagementIpAddress: string + interfaceName: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "siteNameHierarchy": "string", + "deviceManagementIpAddress": "string", + "interfaceName": "string", + "dataIpAddressPoolName": "string", + "voiceIpAddressPoolName": "string", + "scalableGroupName": "string", + "authenticateTemplateName": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_provision_device.py b/ansible_collections/cisco/dnac/plugins/modules/sda_provision_device.py new file mode 100644 index 000000000..97c12fae0 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_provision_device.py @@ -0,0 +1,109 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_provision_device +short_description: Resource module for Sda Provision Device +description: +- Manage operations create, update and delete of the resource Sda Provision Device. +- Provision Wired Device. +- Delete provisioned Wired Device. +- Re-Provision Wired Device. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + deviceManagementIpAddress: + description: DeviceManagementIpAddress query parameter. Valid IP address of the + device currently provisioned in a fabric site. + type: str + siteNameHierarchy: + description: SiteNameHierarchy of the provisioned device. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA ProvisionWiredDevice + description: Complete reference of the ProvisionWiredDevice API. + link: https://developer.cisco.com/docs/dna-center/#!provision-wired-device +- name: Cisco DNA Center documentation for SDA DeleteProvisionedWiredDevice + description: Complete reference of the DeleteProvisionedWiredDevice API. + link: https://developer.cisco.com/docs/dna-center/#!delete-provisioned-wired-device +- name: Cisco DNA Center documentation for SDA ReProvisionWiredDevice + description: Complete reference of the ReProvisionWiredDevice API. + link: https://developer.cisco.com/docs/dna-center/#!re-provision-wired-device +notes: + - SDK Method used are + sda.Sda.delete_provisioned_wired_device, + sda.Sda.provision_wired_device, + sda.Sda.re_provision_wired_device, + + - Paths used are + post /dna/intent/api/v1/business/sda/provision-device, + delete /dna/intent/api/v1/business/sda/provision-device, + put /dna/intent/api/v1/business/sda/provision-device, + +""" + +EXAMPLES = r""" +- name: Delete all + cisco.dnac.sda_provision_device: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + deviceManagementIpAddress: string + +- name: Update all + cisco.dnac.sda_provision_device: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + deviceManagementIpAddress: string + siteNameHierarchy: string + +- name: Create + cisco.dnac.sda_provision_device: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + deviceManagementIpAddress: string + siteNameHierarchy: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "taskId": "string", + "taskStatusUrl": "string", + "executionStatusUrl": "string", + "executionId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_provision_device_info.py b/ansible_collections/cisco/dnac/plugins/modules/sda_provision_device_info.py new file mode 100644 index 000000000..a57d73303 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_provision_device_info.py @@ -0,0 +1,70 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_provision_device_info +short_description: Information module for Sda Provision Device +description: +- Get all Sda Provision Device. +- Get Provisioned Wired Device. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceManagementIpAddress: + description: + - DeviceManagementIpAddress query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA GetProvisionedWiredDevice + description: Complete reference of the GetProvisionedWiredDevice API. + link: https://developer.cisco.com/docs/dna-center/#!get-provisioned-wired-device +notes: + - SDK Method used are + sda.Sda.get_provisioned_wired_device, + + - Paths used are + get /dna/intent/api/v1/business/sda/provision-device, + +""" + +EXAMPLES = r""" +- name: Get all Sda Provision Device + cisco.dnac.sda_provision_device_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceManagementIpAddress: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "deviceManagementIpAddress": "string", + "siteNameHierarchy": "string", + "status": "string", + "description": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network.py b/ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network.py new file mode 100644 index 000000000..5231d8b95 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network.py @@ -0,0 +1,90 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_virtual_network +short_description: Resource module for Sda Virtual Network +description: +- Manage operations create and delete of the resource Sda Virtual Network. +- Add virtual network VN in SDA Fabric. +- Delete virtual network VN from SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + siteNameHierarchy: + description: SiteNameHierarchy query parameter. + type: str + virtualNetworkName: + description: VirtualNetworkName query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA AddVNInFabric + description: Complete reference of the AddVNInFabric API. + link: https://developer.cisco.com/docs/dna-center/#!add-vn-in-fabric +- name: Cisco DNA Center documentation for SDA DeleteVNFromSDAFabric + description: Complete reference of the DeleteVNFromSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!delete-vn-from-sda-fabric +notes: + - SDK Method used are + sda.Sda.add_vn, + sda.Sda.delete_vn, + + - Paths used are + post /dna/intent/api/v1/business/sda/virtual-network, + delete /dna/intent/api/v1/business/sda/virtual-network, + +""" + +EXAMPLES = r""" +- name: Delete all + cisco.dnac.sda_virtual_network: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + siteNameHierarchy: string + virtualNetworkName: string + +- name: Create + cisco.dnac.sda_virtual_network: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + siteNameHierarchy: string + virtualNetworkName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "taskId": "string", + "taskStatusUrl": "string", + "executionStatusUrl": "string", + "executionId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_info.py b/ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_info.py new file mode 100644 index 000000000..073937177 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_info.py @@ -0,0 +1,78 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_virtual_network_info +short_description: Information module for Sda Virtual Network +description: +- Get all Sda Virtual Network. +- Get virtual network VN from SDA Fabric. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + virtualNetworkName: + description: + - VirtualNetworkName query parameter. + type: str + siteNameHierarchy: + description: + - SiteNameHierarchy query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA GetVNFromSDAFabric + description: Complete reference of the GetVNFromSDAFabric API. + link: https://developer.cisco.com/docs/dna-center/#!get-vn-from-sda-fabric +notes: + - SDK Method used are + sda.Sda.get_vn, + + - Paths used are + get /dna/intent/api/v1/business/sda/virtual-network, + +""" + +EXAMPLES = r""" +- name: Get all Sda Virtual Network + cisco.dnac.sda_virtual_network_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + virtualNetworkName: string + siteNameHierarchy: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "siteNameHierarchy": "string", + "virtualNetworkName": "string", + "fabricName": "string", + "isInfraVN": "string", + "isDefaultVN": "string", + "status": "string", + "description": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_ip_pool.py b/ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_ip_pool.py new file mode 100644 index 000000000..c0242821c --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_ip_pool.py @@ -0,0 +1,164 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_virtual_network_ip_pool +short_description: Resource module for Sda Virtual Network Ip Pool +description: +- Manage operations create and delete of the resource Sda Virtual Network Ip Pool. +- Add IP Pool in SDA Virtual Network. +- Delete IP Pool from SDA Virtual Network. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + autoGenerateVlanName: + description: It will auto generate vlanName, if vlanName is empty(applicable for + L3 and INFRA_VN). + type: bool + ipPoolName: + description: IpPoolName query parameter. + type: str + version_added: 4.0.0 + isBridgeModeVm: + description: Bridge Mode Vm enablement flag (applicable for L3 and L2 and default + value is False ). + type: bool + isCommonPool: + description: Common Pool enablement flag(applicable for L3 and L2 and default value + is False ). + type: bool + isIpDirectedBroadcast: + description: Ip Directed Broadcast enablement flag(applicable for L3 and default + value is False ). + type: bool + isL2FloodingEnabled: + description: Layer2 flooding enablement flag(applicable for L3 , L2 and always true + for L2 and default value is False ). + type: bool + version_added: 4.0.0 + isLayer2Only: + description: Layer2 Only enablement flag and default value is False. + type: bool + isThisCriticalPool: + description: Critical pool enablement flag(applicable for L3 and default value is + False ). + type: bool + version_added: 4.0.0 + isWirelessPool: + description: Wireless Pool enablement flag(applicable for L3 and L2 and default + value is False ). + type: bool + version_added: 4.0.0 + poolType: + description: Pool Type (applicable for INFRA_VN). + type: str + version_added: 4.0.0 + scalableGroupName: + description: Scalable Group Name(applicable for L3). + type: str + version_added: 4.0.0 + siteNameHierarchy: + description: SiteNameHierarchy query parameter. + type: str + version_added: 4.0.0 + trafficType: + description: Traffic type(applicable for L3 and L2). + type: str + version_added: 4.0.0 + virtualNetworkName: + description: VirtualNetworkName query parameter. + type: str + vlanId: + description: Vlan Id(applicable for L3 , L2 and INFRA_VN). + type: str + vlanName: + description: Vlan name represent the segment name, if empty, vlanName would be auto + generated by API. + type: str + version_added: 4.0.0 +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA AddIPPoolInSDAVirtualNetwork + description: Complete reference of the AddIPPoolInSDAVirtualNetwork API. + link: https://developer.cisco.com/docs/dna-center/#!add-ip-pool-in-sda-virtual-network +- name: Cisco DNA Center documentation for SDA DeleteIPPoolFromSDAVirtualNetwork + description: Complete reference of the DeleteIPPoolFromSDAVirtualNetwork API. + link: https://developer.cisco.com/docs/dna-center/#!delete-ip-pool-from-sda-virtual-network +notes: + - SDK Method used are + sda.Sda.add_ip_pool_in_sda_virtual_network, + sda.Sda.delete_ip_pool_from_sda_virtual_network, + + - Paths used are + post /dna/intent/api/v1/business/sda/virtualnetwork/ippool, + delete /dna/intent/api/v1/business/sda/virtualnetwork/ippool, + +""" + +EXAMPLES = r""" +- name: Delete all + cisco.dnac.sda_virtual_network_ip_pool: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + ipPoolName: string + siteNameHierarchy: string + virtualNetworkName: string + +- name: Create + cisco.dnac.sda_virtual_network_ip_pool: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + autoGenerateVlanName: true + ipPoolName: string + isBridgeModeVm: true + isCommonPool: true + isIpDirectedBroadcast: true + isL2FloodingEnabled: true + isLayer2Only: true + isThisCriticalPool: true + isWirelessPool: true + poolType: string + scalableGroupName: string + siteNameHierarchy: string + trafficType: string + virtualNetworkName: string + vlanId: string + vlanName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "taskId": "string", + "taskStatusUrl": "string", + "executionStatusUrl": "string", + "executionId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_ip_pool_info.py b/ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_ip_pool_info.py new file mode 100644 index 000000000..205199cf5 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_ip_pool_info.py @@ -0,0 +1,87 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_virtual_network_ip_pool_info +short_description: Information module for Sda Virtual Network Ip Pool +description: +- Get all Sda Virtual Network Ip Pool. +- Get IP Pool from SDA Virtual Network. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + siteNameHierarchy: + version_added: "4.0.0" + description: + - SiteNameHierarchy query parameter. + type: str + virtualNetworkName: + description: + - VirtualNetworkName query parameter. + type: str + ipPoolName: + version_added: "4.0.0" + description: + - IpPoolName query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA GetIPPoolFromSDAVirtualNetwork + description: Complete reference of the GetIPPoolFromSDAVirtualNetwork API. + link: https://developer.cisco.com/docs/dna-center/#!get-ip-pool-from-sda-virtual-network +notes: + - SDK Method used are + sda.Sda.get_ip_pool_from_sda_virtual_network, + + - Paths used are + get /dna/intent/api/v1/business/sda/virtualnetwork/ippool, + +""" + +EXAMPLES = r""" +- name: Get all Sda Virtual Network Ip Pool + cisco.dnac.sda_virtual_network_ip_pool_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + siteNameHierarchy: string + virtualNetworkName: string + ipPoolName: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "virtualNetworkName": "string", + "ipPoolName": "string", + "authenticationPolicyName": "string", + "trafficType": "string", + "scalableGroupName": "string", + "isL2FloodingEnabled": true, + "isThisCriticalPool": true + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_v2.py b/ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_v2.py new file mode 100644 index 000000000..37e862ae5 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_v2.py @@ -0,0 +1,121 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_virtual_network_v2 +short_description: Resource module for Sda Virtual Network V2 +description: +- Manage operations create, update and delete of the resource Sda Virtual Network V2. +- Add virtual network with scalable groups at global level. +- Delete virtual network with scalable groups. +- Update virtual network with scalable groups. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + isGuestVirtualNetwork: + description: Guest Virtual Network enablement flag, default value is False. + type: bool + scalableGroupNames: + description: Scalable Group to be associated to virtual network. + elements: str + type: list + vManageVpnId: + description: VManage vpn id for SD-WAN. + type: str + virtualNetworkName: + description: Virtual Network Name to be assigned at global level. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA AddVirtualNetworkWithScalableGroups + description: Complete reference of the AddVirtualNetworkWithScalableGroups API. + link: https://developer.cisco.com/docs/dna-center/#!add-virtual-network-with-scalable-groups +- name: Cisco DNA Center documentation for SDA DeleteVirtualNetworkWithScalableGroups + description: Complete reference of the DeleteVirtualNetworkWithScalableGroups API. + link: https://developer.cisco.com/docs/dna-center/#!delete-virtual-network-with-scalable-groups +- name: Cisco DNA Center documentation for SDA UpdateVirtualNetworkWithScalableGroups + description: Complete reference of the UpdateVirtualNetworkWithScalableGroups API. + link: https://developer.cisco.com/docs/dna-center/#!update-virtual-network-with-scalable-groups +notes: + - SDK Method used are + sda.Sda.add_virtual_network_with_scalable_groups, + sda.Sda.delete_virtual_network_with_scalable_groups, + sda.Sda.update_virtual_network_with_scalable_groups, + + - Paths used are + post /dna/intent/api/v1/virtual-network, + delete /dna/intent/api/v1/virtual-network, + put /dna/intent/api/v1/virtual-network, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.sda_virtual_network_v2: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + isGuestVirtualNetwork: true + scalableGroupNames: + - string + vManageVpnId: string + virtualNetworkName: string + +- name: Delete all + cisco.dnac.sda_virtual_network_v2: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + virtualNetworkName: string + +- name: Update all + cisco.dnac.sda_virtual_network_v2: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + isGuestVirtualNetwork: true + scalableGroupNames: + - string + vManageVpnId: string + virtualNetworkName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "taskId": "string", + "taskStatusUrl": "string", + "executionStatusUrl": "string", + "executionId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_v2_info.py b/ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_v2_info.py new file mode 100644 index 000000000..b1b408c08 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sda_virtual_network_v2_info.py @@ -0,0 +1,74 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sda_virtual_network_v2_info +short_description: Information module for Sda Virtual Network V2 +description: +- Get all Sda Virtual Network V2. +- Get virtual network with scalable groups. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + virtualNetworkName: + description: + - VirtualNetworkName query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for SDA GetVirtualNetworkWithScalableGroups + description: Complete reference of the GetVirtualNetworkWithScalableGroups API. + link: https://developer.cisco.com/docs/dna-center/#!get-virtual-network-with-scalable-groups +notes: + - SDK Method used are + sda.Sda.get_virtual_network_with_scalable_groups, + + - Paths used are + get /dna/intent/api/v1/virtual-network, + +""" + +EXAMPLES = r""" +- name: Get all Sda Virtual Network V2 + cisco.dnac.sda_virtual_network_v2_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + virtualNetworkName: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "virtualNetworkName": "string", + "isGuestVirtualNetwork": true, + "scalableGroupNames": [ + "string" + ], + "vManageVpnId": "string", + "status": "string", + "description": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/security_advisories_devices_info.py b/ansible_collections/cisco/dnac/plugins/modules/security_advisories_devices_info.py new file mode 100644 index 000000000..0a0bf0c90 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/security_advisories_devices_info.py @@ -0,0 +1,70 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: security_advisories_devices_info +short_description: Information module for Security Advisories Devices +description: +- Get all Security Advisories Devices. +- Retrieves list of devices for an advisory. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + advisoryId: + description: + - AdvisoryId path parameter. Advisory ID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Security Advisories GetDevicesPerAdvisory + description: Complete reference of the GetDevicesPerAdvisory API. + link: https://developer.cisco.com/docs/dna-center/#!get-devices-per-advisory +notes: + - SDK Method used are + security_advisories.SecurityAdvisories.get_devices_per_advisory, + + - Paths used are + get /dna/intent/api/v1/security-advisory/advisory/{advisoryId}/device, + +""" + +EXAMPLES = r""" +- name: Get all Security Advisories Devices + cisco.dnac.security_advisories_devices_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + advisoryId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + "string" + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/security_advisories_ids_per_device_info.py b/ansible_collections/cisco/dnac/plugins/modules/security_advisories_ids_per_device_info.py new file mode 100644 index 000000000..8bf7638d9 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/security_advisories_ids_per_device_info.py @@ -0,0 +1,75 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: security_advisories_ids_per_device_info +short_description: Information module for Security Advisories Ids Per Device +description: +- Get Security Advisories Ids Per Device by id. +- Retrieves list of advisory IDs for a device. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceId: + description: + - DeviceId path parameter. Device instance UUID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Security Advisories GetAdvisoryIDsPerDevice + description: Complete reference of the GetAdvisoryIDsPerDevice API. + link: https://developer.cisco.com/docs/dna-center/#!get-advisory-i-ds-per-device +notes: + - SDK Method used are + security_advisories.SecurityAdvisories.get_advisory_ids_per_device, + + - Paths used are + get /dna/intent/api/v1/security-advisory/device/{deviceId}, + +""" + +EXAMPLES = r""" +- name: Get Security Advisories Ids Per Device by id + cisco.dnac.security_advisories_ids_per_device_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "deviceId": "string", + "advisoryIds": [ + "string" + ] + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/security_advisories_info.py b/ansible_collections/cisco/dnac/plugins/modules/security_advisories_info.py new file mode 100644 index 000000000..b0b551cd9 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/security_advisories_info.py @@ -0,0 +1,77 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: security_advisories_info +short_description: Information module for Security Advisories +description: +- Get all Security Advisories. +- Retrieves list of advisories on the network. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Security Advisories GetAdvisoriesList + description: Complete reference of the GetAdvisoriesList API. + link: https://developer.cisco.com/docs/dna-center/#!get-advisories-list +notes: + - SDK Method used are + security_advisories.SecurityAdvisories.get_advisories_list, + + - Paths used are + get /dna/intent/api/v1/security-advisory/advisory, + +""" + +EXAMPLES = r""" +- name: Get all Security Advisories + cisco.dnac.security_advisories_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "advisoryId": "string", + "deviceCount": 0, + "hiddenDeviceCount": 0, + "cves": [ + "string" + ], + "publicationUrl": "string", + "sir": "string", + "detectionType": "string", + "defaultDetectionType": "string", + "defaultConfigMatchPattern": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/security_advisories_per_device_info.py b/ansible_collections/cisco/dnac/plugins/modules/security_advisories_per_device_info.py new file mode 100644 index 000000000..54735ee13 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/security_advisories_per_device_info.py @@ -0,0 +1,82 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: security_advisories_per_device_info +short_description: Information module for Security Advisories Per Device +description: +- Get all Security Advisories Per Device. +- Retrieves list of advisories for a device. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + deviceId: + description: + - DeviceId path parameter. Device instance UUID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Security Advisories GetAdvisoriesPerDevice + description: Complete reference of the GetAdvisoriesPerDevice API. + link: https://developer.cisco.com/docs/dna-center/#!get-advisories-per-device +notes: + - SDK Method used are + security_advisories.SecurityAdvisories.get_advisories_per_device, + + - Paths used are + get /dna/intent/api/v1/security-advisory/device/{deviceId}/advisory, + +""" + +EXAMPLES = r""" +- name: Get all Security Advisories Per Device + cisco.dnac.security_advisories_per_device_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + deviceId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "advisoryId": "string", + "deviceCount": 0, + "hiddenDeviceCount": 0, + "cves": [ + "string" + ], + "publicationUrl": "string", + "sir": "string", + "detectionType": "string", + "defaultDetectionType": "string", + "defaultConfigMatchPattern": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/security_advisories_summary_info.py b/ansible_collections/cisco/dnac/plugins/modules/security_advisories_summary_info.py new file mode 100644 index 000000000..4709ca6b9 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/security_advisories_summary_info.py @@ -0,0 +1,94 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: security_advisories_summary_info +short_description: Information module for Security Advisories Summary +description: +- Get all Security Advisories Summary. +- Retrieves summary of advisories on the network. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Security Advisories GetAdvisoriesSummary + description: Complete reference of the GetAdvisoriesSummary API. + link: https://developer.cisco.com/docs/dna-center/#!get-advisories-summary +notes: + - SDK Method used are + security_advisories.SecurityAdvisories.get_advisories_summary, + + - Paths used are + get /dna/intent/api/v1/security-advisory/advisory/aggregate, + +""" + +EXAMPLES = r""" +- name: Get all Security Advisories Summary + cisco.dnac.security_advisories_summary_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "NA": { + "CONFIG": 0, + "VERSION": 0, + "TOTAL": 0 + }, + "INFORMATIONAL": { + "CONFIG": 0, + "VERSION": 0, + "TOTAL": 0 + }, + "LOW": { + "CONFIG": 0, + "VERSION": 0, + "TOTAL": 0 + }, + "MEDIUM": { + "CONFIG": 0, + "VERSION": 0, + "TOTAL": 0 + }, + "HIGH": { + "CONFIG": 0, + "VERSION": 0, + "TOTAL": 0 + }, + "CRITICAL": { + "CONFIG": 0, + "VERSION": 0, + "TOTAL": 0 + } + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sensor.py b/ansible_collections/cisco/dnac/plugins/modules/sensor.py new file mode 100644 index 000000000..4ac0fc8bd --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sensor.py @@ -0,0 +1,262 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sensor +short_description: Resource module for Sensor +description: +- Manage operations create and delete of the resource Sensor. +- Intent API to create a SENSOR test template with a new SSID, existing SSID, or both new and existing SSID. +- Intent API to delete an existing SENSOR test template. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + apCoverage: + description: Sensor's apCoverage. + elements: dict + suboptions: + bands: + description: Bands. + type: str + numberOfApsToTest: + description: Number Of Aps To Test. + type: str + rssiThreshold: + description: Rssi Threshold. + type: str + type: list + connection: + description: Connection. + type: str + modelVersion: + description: Model Version. + type: int + name: + description: Name. + type: str + ssids: + description: Sensor's ssids. + elements: dict + suboptions: + authType: + description: Auth Type. + type: str + categories: + description: Categories. + elements: str + type: list + profileName: + description: Profile Name. + type: str + psk: + description: Psk. + type: str + qosPolicy: + description: Qos Policy. + type: str + ssid: + description: Ssid. + type: str + tests: + description: Sensor's tests. + elements: dict + suboptions: + config: + description: Config. + elements: dict + type: list + name: + description: Name. + type: str + type: list + thirdParty: + description: Sensor's thirdParty. + suboptions: + selected: + description: Selected. + type: bool + type: dict + type: list + templateName: + description: TemplateName query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Sensors CreateSensorTestTemplate + description: Complete reference of the CreateSensorTestTemplate API. + link: https://developer.cisco.com/docs/dna-center/#!create-sensor-test-template +- name: Cisco DNA Center documentation for Sensors DeleteSensorTest + description: Complete reference of the DeleteSensorTest API. + link: https://developer.cisco.com/docs/dna-center/#!delete-sensor-test +notes: + - SDK Method used are + sensors.Sensors.create_sensor_test_template, + sensors.Sensors.delete_sensor_test, + + - Paths used are + post /dna/intent/api/v1/sensor, + delete /dna/intent/api/v1/sensor, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.sensor: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + apCoverage: + - bands: string + numberOfApsToTest: string + rssiThreshold: string + connection: string + modelVersion: 0 + name: string + ssids: + - authType: string + categories: + - string + profileName: string + psk: string + qosPolicy: string + ssid: string + tests: + - config: + - {} + name: string + thirdParty: + selected: true + +- name: Delete all + cisco.dnac.sensor: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + templateName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": { + "_id": "string", + "name": "string", + "version": 0, + "modelVersion": 0, + "startTime": 0, + "lastModifiedTime": 0, + "numAssociatedSensor": 0, + "location": {}, + "siteHierarchy": {}, + "status": "string", + "connection": "string", + "frequency": {}, + "rssiThreshold": 0, + "numNeighborAPThreshold": 0, + "scheduleInDays": 0, + "wlans": [ + {} + ], + "ssids": [ + { + "bands": {}, + "ssid": "string", + "profileName": "string", + "authType": "string", + "authTypeRcvd": {}, + "psk": "string", + "username": {}, + "password": {}, + "eapMethod": {}, + "scep": true, + "authProtocol": {}, + "certfilename": {}, + "certxferprotocol": "string", + "certstatus": "string", + "certpassphrase": {}, + "certdownloadurl": {}, + "numAps": 0, + "numSensors": 0, + "layer3webAuthsecurity": {}, + "layer3webAuthuserName": {}, + "layer3webAuthpassword": {}, + "extWebAuthVirtualIp": {}, + "layer3webAuthEmailAddress": {}, + "qosPolicy": "string", + "extWebAuth": true, + "whiteList": true, + "extWebAuthPortal": {}, + "extWebAuthAccessUrl": {}, + "extWebAuthHtmlTag": [ + {} + ], + "thirdParty": { + "selected": true + }, + "id": 0, + "wlanId": 0, + "wlc": {}, + "validFrom": 0, + "validTo": 0, + "status": "string", + "tests": [ + { + "name": "string", + "config": [ + {} + ] + } + ] + } + ], + "testScheduleMode": "string", + "showWlcUpgradeBanner": true, + "radioAsSensorRemoved": true, + "encryptionMode": "string", + "runNow": "string", + "locationInfoList": [ + {} + ], + "schedule": {}, + "tests": {}, + "sensors": [ + {} + ], + "apCoverage": [ + { + "bands": "string", + "numberOfApsToTest": 0, + "rssiThreshold": 0 + } + ], + "testDurationEstimate": 0, + "testTemplate": true, + "legacyTestSuite": true, + "tenantId": {} + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sensor_info.py b/ansible_collections/cisco/dnac/plugins/modules/sensor_info.py new file mode 100644 index 000000000..20bbeae04 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sensor_info.py @@ -0,0 +1,89 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sensor_info +short_description: Information module for Sensor +description: +- Get all Sensor. +- Intent API to get a list of SENSOR devices. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + siteId: + description: + - SiteId query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Sensors Sensors + description: Complete reference of the Sensors API. + link: https://developer.cisco.com/docs/dna-center/#!sensors-sensors +notes: + - SDK Method used are + sensors.Sensors.sensors, + + - Paths used are + get /dna/intent/api/v1/sensor, + +""" + +EXAMPLES = r""" +- name: Get all Sensor + cisco.dnac.sensor_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + siteId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": [ + { + "name": "string", + "status": "string", + "radioMacAddress": "string", + "ethernetMacAddress": "string", + "location": "string", + "backhaulType": "string", + "serialNumber": "string", + "ipAddress": "string", + "version": "string", + "lastSeen": 0, + "type": "string", + "sshConfig": { + "sshState": "string", + "sshUserName": "string", + "sshPassword": "string", + "enablePassword": "string" + }, + "isLEDEnabled": true + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sensor_test_run.py b/ansible_collections/cisco/dnac/plugins/modules/sensor_test_run.py new file mode 100644 index 000000000..ac13177e0 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sensor_test_run.py @@ -0,0 +1,59 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sensor_test_run +short_description: Resource module for Sensor Test Run +description: +- Manage operation update of the resource Sensor Test Run. +- Intent API to run a deployed SENSOR test. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + templateName: + description: Template Name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Sensors RunNowSensorTest + description: Complete reference of the RunNowSensorTest API. + link: https://developer.cisco.com/docs/dna-center/#!run-now-sensor-test +notes: + - SDK Method used are + sensors.Sensors.run_now_sensor_test, + + - Paths used are + put /dna/intent/api/v1/sensor-run-now, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.sensor_test_run: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + templateName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + {} +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sensor_test_template_duplicate.py b/ansible_collections/cisco/dnac/plugins/modules/sensor_test_template_duplicate.py new file mode 100644 index 000000000..513178c5e --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sensor_test_template_duplicate.py @@ -0,0 +1,191 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sensor_test_template_duplicate +short_description: Resource module for Sensor Test Template Duplicate +description: +- Manage operation update of the resource Sensor Test Template Duplicate. +- Intent API to duplicate an existing SENSOR test template. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + newTemplateName: + description: New Template Name. + type: str + templateName: + description: Template Name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Sensors DuplicateSensorTestTemplate + description: Complete reference of the DuplicateSensorTestTemplate API. + link: https://developer.cisco.com/docs/dna-center/#!duplicate-sensor-test-template +notes: + - SDK Method used are + sensors.Sensors.duplicate_sensor_test_template, + + - Paths used are + put /dna/intent/api/v1/sensorTestTemplate, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.sensor_test_template_duplicate: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + newTemplateName: string + templateName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": { + "_id": "string", + "name": "string", + "version": 0, + "modelVersion": 0, + "startTime": 0, + "lastModifiedTime": 0, + "numAssociatedSensor": 0, + "location": {}, + "siteHierarchy": {}, + "status": "string", + "connection": "string", + "frequency": {}, + "rssiThreshold": 0, + "numNeighborAPThreshold": 0, + "scheduleInDays": 0, + "wlans": [ + {} + ], + "ssids": [ + { + "bands": {}, + "ssid": "string", + "profileName": "string", + "authType": "string", + "authTypeRcvd": {}, + "psk": "string", + "username": {}, + "password": {}, + "eapMethod": {}, + "scep": true, + "authProtocol": {}, + "certfilename": {}, + "certxferprotocol": "string", + "certstatus": "string", + "certpassphrase": {}, + "certdownloadurl": {}, + "numAps": 0, + "numSensors": 0, + "layer3webAuthsecurity": {}, + "layer3webAuthuserName": {}, + "layer3webAuthpassword": {}, + "extWebAuthVirtualIp": {}, + "layer3webAuthEmailAddress": {}, + "qosPolicy": "string", + "extWebAuth": true, + "whiteList": true, + "extWebAuthPortal": {}, + "extWebAuthAccessUrl": {}, + "extWebAuthHtmlTag": [ + {} + ], + "thirdParty": { + "selected": true + }, + "id": 0, + "wlanId": 0, + "wlc": {}, + "validFrom": 0, + "validTo": 0, + "status": "string", + "tests": [ + { + "name": "string", + "config": [ + {} + ] + } + ] + } + ], + "testScheduleMode": "string", + "showWlcUpgradeBanner": true, + "radioAsSensorRemoved": true, + "encryptionMode": "string", + "runNow": "string", + "locationInfoList": [ + { + "locationId": "string", + "locationType": "string", + "allSensors": true, + "siteHierarchy": "string", + "macAddressList": [ + {} + ] + } + ], + "schedule": { + "testScheduleMode": "string", + "scheduleRange": [ + { + "timeRange": [ + { + "from": "string", + "to": "string", + "frequency": { + "value": 0, + "unit": "string" + } + } + ], + "day": "string" + } + ], + "startTime": 0, + "frequency": { + "value": 0, + "unit": "string" + } + }, + "tests": {}, + "sensors": [ + {} + ], + "apCoverage": [ + { + "bands": "string", + "numberOfApsToTest": 0, + "rssiThreshold": 0 + } + ], + "testDurationEstimate": 0, + "testTemplate": true, + "legacyTestSuite": true, + "tenantId": {} + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sensor_test_template_edit.py b/ansible_collections/cisco/dnac/plugins/modules/sensor_test_template_edit.py new file mode 100644 index 000000000..aa993bd10 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sensor_test_template_edit.py @@ -0,0 +1,268 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sensor_test_template_edit +short_description: Resource module for Sensor Test Template Edit +description: +- Manage operation update of the resource Sensor Test Template Edit. +- Intent API to deploy, schedule, or edit and existing SENSOR test template. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + locationInfoList: + description: Sensor Test Template Edit's locationInfoList. + elements: dict + suboptions: + allSensors: + description: All Sensors. + type: bool + locationId: + description: Location Id. + type: str + locationType: + description: Location Type. + type: str + siteHierarchy: + description: Site Hierarchy. + type: str + type: list + schedule: + description: Sensor Test Template Edit's schedule. + suboptions: + frequency: + description: Sensor Test Template Edit's frequency. + suboptions: + unit: + description: Unit. + type: str + value: + description: Value. + type: int + type: dict + scheduleRange: + description: Sensor Test Template Edit's scheduleRange. + elements: dict + suboptions: + day: + description: Day. + type: str + timeRange: + description: Sensor Test Template Edit's timeRange. + elements: dict + suboptions: + frequency: + description: Sensor Test Template Edit's frequency. + suboptions: + unit: + description: Unit. + type: str + value: + description: Value. + type: int + type: dict + from: + description: From. + type: str + to: + description: To. + type: str + type: list + type: list + testScheduleMode: + description: Test Schedule Mode. + type: str + type: dict + templateName: + description: Template Name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Sensors EditSensorTestTemplate + description: Complete reference of the EditSensorTestTemplate API. + link: https://developer.cisco.com/docs/dna-center/#!edit-sensor-test-template +notes: + - SDK Method used are + sensors.Sensors.edit_sensor_test_template, + + - Paths used are + put /dna/intent/api/v1/AssuranceScheduleSensorTest, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.sensor_test_template_edit: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + locationInfoList: + - allSensors: true + locationId: string + locationType: string + siteHierarchy: string + schedule: + frequency: + unit: string + value: 0 + scheduleRange: + - day: string + timeRange: + - frequency: + unit: string + value: 0 + from: string + to: string + testScheduleMode: string + templateName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": { + "_id": "string", + "name": "string", + "version": 0, + "modelVersion": 0, + "startTime": 0, + "lastModifiedTime": 0, + "numAssociatedSensor": 0, + "location": {}, + "siteHierarchy": {}, + "status": "string", + "connection": "string", + "frequency": {}, + "rssiThreshold": 0, + "numNeighborAPThreshold": 0, + "scheduleInDays": 0, + "wlans": [ + {} + ], + "ssids": [ + { + "bands": {}, + "ssid": "string", + "profileName": "string", + "authType": "string", + "authTypeRcvd": {}, + "psk": "string", + "username": {}, + "password": {}, + "eapMethod": {}, + "scep": true, + "authProtocol": {}, + "certfilename": {}, + "certxferprotocol": "string", + "certstatus": "string", + "certpassphrase": {}, + "certdownloadurl": {}, + "numAps": 0, + "numSensors": 0, + "layer3webAuthsecurity": {}, + "layer3webAuthuserName": {}, + "layer3webAuthpassword": {}, + "extWebAuthVirtualIp": {}, + "layer3webAuthEmailAddress": {}, + "qosPolicy": "string", + "extWebAuth": true, + "whiteList": true, + "extWebAuthPortal": {}, + "extWebAuthAccessUrl": {}, + "extWebAuthHtmlTag": [ + {} + ], + "thirdParty": { + "selected": true + }, + "id": 0, + "wlanId": 0, + "wlc": {}, + "validFrom": 0, + "validTo": 0, + "status": "string", + "tests": [ + { + "name": "string", + "config": [ + {} + ] + } + ] + } + ], + "testScheduleMode": "string", + "showWlcUpgradeBanner": true, + "radioAsSensorRemoved": true, + "encryptionMode": "string", + "runNow": "string", + "locationInfoList": [ + { + "locationId": "string", + "locationType": "string", + "allSensors": true, + "siteHierarchy": "string", + "macAddressList": [ + {} + ] + } + ], + "schedule": { + "testScheduleMode": "string", + "scheduleRange": [ + { + "timeRange": [ + { + "from": "string", + "to": "string", + "frequency": { + "value": 0, + "unit": "string" + } + } + ], + "day": "string" + } + ], + "startTime": 0, + "frequency": { + "value": 0, + "unit": "string" + } + }, + "tests": {}, + "sensors": [ + {} + ], + "apCoverage": [ + { + "bands": "string", + "numberOfApsToTest": 0, + "rssiThreshold": 0 + } + ], + "testDurationEstimate": 0, + "testTemplate": true, + "legacyTestSuite": true, + "tenantId": "string" + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/service_provider_create.py b/ansible_collections/cisco/dnac/plugins/modules/service_provider_create.py new file mode 100644 index 000000000..44ef4888b --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/service_provider_create.py @@ -0,0 +1,82 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: service_provider_create +short_description: Resource module for Service Provider Create +description: +- Manage operation create of the resource Service Provider Create. +- API to create Service Provider Profile QOS . +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + settings: + description: Service Provider Create's settings. + suboptions: + qos: + description: Service Provider Create's qos. + elements: dict + suboptions: + model: + description: Model. + type: str + profileName: + description: Profile Name. + type: str + wanProvider: + description: Wan Provider. + type: str + type: list + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings CreateSPProfile + description: Complete reference of the CreateSPProfile API. + link: https://developer.cisco.com/docs/dna-center/#!create-sp-profile +notes: + - SDK Method used are + network_settings.NetworkSettings.create_sp_profile, + + - Paths used are + post /dna/intent/api/v1/service-provider, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.service_provider_create: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + settings: + qos: + - model: string + profileName: string + wanProvider: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/service_provider_info.py b/ansible_collections/cisco/dnac/plugins/modules/service_provider_info.py new file mode 100644 index 000000000..6444f7978 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/service_provider_info.py @@ -0,0 +1,82 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: service_provider_info +short_description: Information module for Service Provider +description: +- Get all Service Provider. +- API to get service provider details QoS . +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings GetServiceProviderDetails + description: Complete reference of the GetServiceProviderDetails API. + link: https://developer.cisco.com/docs/dna-center/#!get-service-provider-details +notes: + - SDK Method used are + network_settings.NetworkSettings.get_service_provider_details, + + - Paths used are + get /dna/intent/api/v1/service-provider, + +""" + +EXAMPLES = r""" +- name: Get all Service Provider + cisco.dnac.service_provider_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "instanceType": "string", + "instanceUuid": "string", + "namespace": "string", + "type": "string", + "key": "string", + "version": "string", + "value": [ + { + "wanProvider": "string", + "spProfileName": "string", + "slaProfileName": "string" + } + ], + "groupUuid": "string", + "inheritedGroupUuid": "string", + "inheritedGroupName": "string" + } + ], + "version": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/service_provider_profile_delete.py b/ansible_collections/cisco/dnac/plugins/modules/service_provider_profile_delete.py new file mode 100644 index 000000000..ec7330c64 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/service_provider_profile_delete.py @@ -0,0 +1,63 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: service_provider_profile_delete +short_description: Resource module for Service Provider Profile Delete +description: +- Manage operation delete of the resource Service Provider Profile Delete. +- API to delete Service Provider Profile QoS . +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + spProfileName: + description: SpProfileName path parameter. Sp profile name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings DeleteSPProfile + description: Complete reference of the DeleteSPProfile API. + link: https://developer.cisco.com/docs/dna-center/#!delete-sp-profile +notes: + - SDK Method used are + network_settings.NetworkSettings.delete_sp_profile, + + - Paths used are + delete /dna/intent/api/v1/sp-profile/{spProfileName}, + +""" + +EXAMPLES = r""" +- name: Delete by name + cisco.dnac.service_provider_profile_delete: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + spProfileName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/service_provider_update.py b/ansible_collections/cisco/dnac/plugins/modules/service_provider_update.py new file mode 100644 index 000000000..f3c9a6d35 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/service_provider_update.py @@ -0,0 +1,86 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: service_provider_update +short_description: Resource module for Service Provider Update +description: +- Manage operation update of the resource Service Provider Update. +- API to update Service Provider Profile QoS . +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + settings: + description: Service Provider Update's settings. + suboptions: + qos: + description: Service Provider Update's qos. + elements: dict + suboptions: + model: + description: Model. + type: str + oldProfileName: + description: Old Profile Name. + type: str + profileName: + description: Profile Name. + type: str + wanProvider: + description: Wan Provider. + type: str + type: list + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings UpdateSPProfile + description: Complete reference of the UpdateSPProfile API. + link: https://developer.cisco.com/docs/dna-center/#!update-sp-profile +notes: + - SDK Method used are + network_settings.NetworkSettings.update_sp_profile, + + - Paths used are + put /dna/intent/api/v1/service-provider, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.service_provider_update: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + settings: + qos: + - model: string + oldProfileName: string + profileName: string + wanProvider: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/service_provider_v2.py b/ansible_collections/cisco/dnac/plugins/modules/service_provider_v2.py new file mode 100644 index 000000000..3a804288f --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/service_provider_v2.py @@ -0,0 +1,108 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: service_provider_v2 +short_description: Resource module for Service Provider V2 +description: +- Manage operations create and update of the resource Service Provider V2. +- API to create Service Provider Profile QOS . +- API to update Service Provider Profile QoS . +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + settings: + description: Service Provider V2's settings. + suboptions: + qos: + description: Service Provider V2's qos. + elements: dict + suboptions: + model: + description: Model. + type: str + profileName: + description: Profile Name. + type: str + wanProvider: + description: Wan Provider. + type: str + type: list + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings CreateSPProfileV2 + description: Complete reference of the CreateSPProfileV2 API. + link: https://developer.cisco.com/docs/dna-center/#!create-sp-profile-v-2 +- name: Cisco DNA Center documentation for Network Settings UpdateSPProfileV2 + description: Complete reference of the UpdateSPProfileV2 API. + link: https://developer.cisco.com/docs/dna-center/#!update-sp-profile-v-2 +notes: + - SDK Method used are + network_settings.NetworkSettings.create_sp_profile_v2, + network_settings.NetworkSettings.update_sp_profile_v2, + + - Paths used are + post /dna/intent/api/v2/service-provider, + put /dna/intent/api/v2/service-provider, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.service_provider_v2: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + settings: + qos: + - model: string + profileName: string + wanProvider: string + +- name: Update all + cisco.dnac.service_provider_v2: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + settings: + qos: + - model: string + oldProfileName: string + profileName: string + wanProvider: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/service_provider_v2_info.py b/ansible_collections/cisco/dnac/plugins/modules/service_provider_v2_info.py new file mode 100644 index 000000000..50635cc29 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/service_provider_v2_info.py @@ -0,0 +1,82 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: service_provider_v2_info +short_description: Information module for Service Provider V2 +description: +- Get all Service Provider V2. +- API to get Service Provider details QoS . +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings GetServiceProviderDetailsV2 + description: Complete reference of the GetServiceProviderDetailsV2 API. + link: https://developer.cisco.com/docs/dna-center/#!get-service-provider-details-v-2 +notes: + - SDK Method used are + network_settings.NetworkSettings.get_service_provider_details_v2, + + - Paths used are + get /dna/intent/api/v2/service-provider, + +""" + +EXAMPLES = r""" +- name: Get all Service Provider V2 + cisco.dnac.service_provider_v2_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "instanceType": "string", + "instanceUuid": "string", + "namespace": "string", + "type": "string", + "key": "string", + "version": 0, + "value": [ + { + "wanProvider": "string", + "spProfileName": "string", + "slaProfileName": "string" + } + ], + "groupUuid": "string", + "inheritedGroupUuid": "string", + "inheritedGroupName": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/site_assign_credential.py b/ansible_collections/cisco/dnac/plugins/modules/site_assign_credential.py new file mode 100644 index 000000000..5cbb53684 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/site_assign_credential.py @@ -0,0 +1,91 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: site_assign_credential +short_description: Resource module for Site Assign Credential +description: +- Manage operation create of the resource Site Assign Credential. +- Assign Device Credential to a site. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + cliId: + description: Cli Id. + type: str + headers: + description: Additional headers. + type: dict + httpRead: + description: Http Read. + type: str + httpWrite: + description: Http Write. + type: str + siteId: + description: SiteId path parameter. Site id to assign credential. + type: str + snmpV2ReadId: + description: Snmp V2 Read Id. + type: str + snmpV2WriteId: + description: Snmp V2 Write Id. + type: str + snmpV3Id: + description: Snmp V3 Id. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings AssignDeviceCredentialToSite + description: Complete reference of the AssignDeviceCredentialToSite API. + link: https://developer.cisco.com/docs/dna-center/#!assign-device-credential-to-site +notes: + - SDK Method used are + network_settings.NetworkSettings.assign_device_credential_to_site, + + - Paths used are + post /dna/intent/api/v1/credential-to-site/{siteId}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.site_assign_credential: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + cliId: string + headers: '{{my_headers | from_json}}' + httpRead: string + httpWrite: string + siteId: string + snmpV2ReadId: string + snmpV2WriteId: string + snmpV3Id: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/site_assign_device.py b/ansible_collections/cisco/dnac/plugins/modules/site_assign_device.py new file mode 100644 index 000000000..d0bdd2268 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/site_assign_device.py @@ -0,0 +1,69 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: site_assign_device +short_description: Resource module for Site Assign Device +description: +- Manage operation create of the resource Site Assign Device. +- Assigns list of devices to a site. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + device: + description: Site Assign Device's device. + elements: dict + suboptions: + ip: + description: Device ip (eg 10.104.240.64). + type: str + type: list + siteId: + description: SiteId path parameter. Site id to which site the device to assign. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +notes: + - SDK Method used are + sites.Sites.assign_device_to_site, + + - Paths used are + post /dna/system/api/v1/site/{siteId}/device, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.site_assign_device: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + device: + - ip: string + siteId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/site_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/site_count_info.py new file mode 100644 index 000000000..85b57d946 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/site_count_info.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: site_count_info +short_description: Information module for Site Count +description: +- Get all Site Count. +- API to get site count. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + siteId: + description: + - SiteId query parameter. Site id to retrieve site count. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Sites GetSiteCount + description: Complete reference of the GetSiteCount API. + link: https://developer.cisco.com/docs/dna-center/#!get-site-count +notes: + - SDK Method used are + sites.Sites.get_site_count, + + - Paths used are + get /dna/intent/api/v1/site/count, + +""" + +EXAMPLES = r""" +- name: Get all Site Count + cisco.dnac.site_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + siteId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/site_create.py b/ansible_collections/cisco/dnac/plugins/modules/site_create.py new file mode 100644 index 000000000..31f357aea --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/site_create.py @@ -0,0 +1,147 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: site_create +short_description: Resource module for Site Create +description: +- Manage operation create of the resource Site Create. +- Creates site with area/building/floor with specified hierarchy. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + site: + description: Site Create's site. + suboptions: + area: + description: Site Create's area. + suboptions: + name: + description: Name of the area (eg Area1). + type: str + parentName: + description: Parent name of the area to be created. + type: str + type: dict + building: + description: Site Create's building. + suboptions: + address: + description: Address of the building to be created. + type: str + country: + description: Country (eg United States). + type: str + latitude: + description: Latitude coordinate of the building (eg 37.338). + type: int + longitude: + description: Longitude coordinate of the building (eg -121.832). + type: int + name: + description: Name of the building (eg building1). + type: str + parentName: + description: Parent name of building to be created. + type: str + type: dict + floor: + description: Site Create's floor. + suboptions: + floorNumber: + description: Floor number. (eg 5). + type: int + height: + description: Height of the floor. Unit of measure is ft. (eg 15). + type: int + length: + description: Length of the floor. Unit of measure is ft. (eg 100). + type: int + name: + description: Name of the floor (eg floor-1). + type: str + parentName: + description: Parent name of the floor to be created. + type: str + rfModel: + description: Type of floor (eg Cubes And Walled Offices0. + type: str + width: + description: Width of the floor. Unit of measure is ft. (eg 100). + type: int + type: dict + type: dict + type: + description: Type of site to create (eg area, building, floor). + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Sites CreateSite + description: Complete reference of the CreateSite API. + link: https://developer.cisco.com/docs/dna-center/#!create-site +notes: + - SDK Method used are + sites.Sites.create_site, + + - Paths used are + post /dna/intent/api/v1/site, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.site_create: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: '{{my_headers | from_json}}' + site: + area: + name: string + parentName: string + building: + address: string + country: string + latitude: 0 + longitude: 0 + name: string + parentName: string + floor: + floorNumber: 0 + height: 0 + length: 0 + name: string + parentName: string + rfModel: string + width: 0 + type: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/site_delete.py b/ansible_collections/cisco/dnac/plugins/modules/site_delete.py new file mode 100644 index 000000000..d36690ef4 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/site_delete.py @@ -0,0 +1,63 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: site_delete +short_description: Resource module for Site Delete +description: +- Manage operation delete of the resource Site Delete. +- Delete site with area/building/floor by siteId. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + siteId: + description: SiteId path parameter. Site id to which site details to be deleted. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Sites DeleteSite + description: Complete reference of the DeleteSite API. + link: https://developer.cisco.com/docs/dna-center/#!delete-site +notes: + - SDK Method used are + sites.Sites.delete_site, + + - Paths used are + delete /dna/intent/api/v1/site/{siteId}, + +""" + +EXAMPLES = r""" +- name: Delete by id + cisco.dnac.site_delete: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + siteId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusURL": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/site_design_floormap.py b/ansible_collections/cisco/dnac/plugins/modules/site_design_floormap.py new file mode 100644 index 000000000..a5f868383 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/site_design_floormap.py @@ -0,0 +1,88 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: site_design_floormap +short_description: Resource module for Site Design Floormap +description: +- Manage operations create, update and delete of the resource Site Design Floormap. +- Service to create a floor map with callback. +- Service to delete an empty floor map with callback. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + floorId: + description: FloorId path parameter. Group ID of floor to be deleted. + type: str + payload: + description: Site Design Floormap's payload + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +notes: + - SDK Method used are + site_design.SiteDesign.create_floormap, + site_design.SiteDesign.delete_floormap, + site_design.SiteDesign.update_floormap, + + - Paths used are + post /dna/intent/api/v1/wireless/floormap, + delete /dna/intent/api/v1/wireless/floormap/{floorId}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.site_design_floormap: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + +- name: Delete by id + cisco.dnac.site_design_floormap: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + floorId: string + +- name: Update by id + cisco.dnac.site_design_floormap: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + floorId: string + payload: + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + {} +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/site_design_floormap_info.py b/ansible_collections/cisco/dnac/plugins/modules/site_design_floormap_info.py new file mode 100644 index 000000000..ee1fa87bf --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/site_design_floormap_info.py @@ -0,0 +1,79 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: site_design_floormap_info +short_description: Information module for Site Design Floormap +description: +- Get all Site Design Floormap. +- Get Site Design Floormap by id. +- List all floor maps. +- List specified floor map(s). +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + floorId: + description: + - FloorId path parameter. Group Id of the specified floormap. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +notes: + - SDK Method used are + site_design.SiteDesign.get_floormap, + site_design.SiteDesign.get_floormaps, + + - Paths used are + get /dna/intent/api/v1/wireless/floormap/all, + get /dna/intent/api/v1/wireless/floormap/{floorId}, + +""" + +EXAMPLES = r""" +- name: Get all Site Design Floormap + cisco.dnac.site_design_floormap_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: + custom: value + register: result + +- name: Get Site Design Floormap by id + cisco.dnac.site_design_floormap_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: + custom: value + floorId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: + - {} +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/site_health_info.py b/ansible_collections/cisco/dnac/plugins/modules/site_health_info.py new file mode 100644 index 000000000..9614b6eb8 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/site_health_info.py @@ -0,0 +1,144 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: site_health_info +short_description: Information module for Site Health +description: +- Get all Site Health. +- Returns Overall Health information for all sites. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + timestamp: + description: + - Timestamp query parameter. Epoch time(in milliseconds) when the Site Hierarchy data is required. + type: str + siteType: + description: + - SiteType query parameter. Type of the site to return. AREA or BUILDING. Default to AREA. + type: str + offset: + description: + - Offset query parameter. The offset value, starting from 1, of the first returned site entry. Default is 1. + type: int + limit: + description: + - Limit query parameter. The max number of sites in the returned data set. Default is 25, and max at 50. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Sites GetSiteHealth + description: Complete reference of the GetSiteHealth API. + link: https://developer.cisco.com/docs/dna-center/#!get-site-health +notes: + - SDK Method used are + sites.Sites.get_site_health, + + - Paths used are + get /dna/intent/api/v1/site-health, + +""" + +EXAMPLES = r""" +- name: Get all Site Health + cisco.dnac.site_health_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + timestamp: string + siteType: string + offset: 0 + limit: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "siteName": "string", + "siteId": "string", + "parentSiteId": "string", + "parentSiteName": "string", + "siteType": "string", + "latitude": 0, + "longitude": 0, + "healthyNetworkDevicePercentage": {}, + "healthyClientsPercentage": {}, + "clientHealthWired": {}, + "clientHealthWireless": {}, + "numberOfClients": {}, + "numberOfNetworkDevice": {}, + "networkHealthAverage": {}, + "networkHealthAccess": {}, + "networkHealthCore": {}, + "networkHealthDistribution": {}, + "networkHealthRouter": {}, + "networkHealthWireless": {}, + "networkHealthOthers": {}, + "numberOfWiredClients": {}, + "numberOfWirelessClients": {}, + "totalNumberOfConnectedWiredClients": {}, + "totalNumberOfActiveWirelessClients": {}, + "wiredGoodClients": {}, + "wirelessGoodClients": {}, + "overallGoodDevices": {}, + "accessGoodCount": {}, + "accessTotalCount": {}, + "coreGoodCount": {}, + "coreTotalCount": {}, + "distributionGoodCount": {}, + "distributionTotalCount": {}, + "routerGoodCount": {}, + "routerTotalCount": {}, + "wirelessDeviceGoodCount": {}, + "wirelessDeviceTotalCount": {}, + "applicationHealth": {}, + "applicationGoodCount": {}, + "applicationTotalCount": {}, + "applicationBytesTotalCount": {}, + "dnacInfo": {}, + "applicationHealthStats": { + "appTotalCount": 0, + "businessRelevantAppCount": { + "poor": 0, + "fair": 0, + "good": 0 + }, + "businessIrrelevantAppCount": { + "poor": 0, + "fair": 0, + "good": 0 + }, + "defaultHealthAppCount": { + "poor": 0, + "fair": 0, + "good": 0 + } + } + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/site_info.py b/ansible_collections/cisco/dnac/plugins/modules/site_info.py new file mode 100644 index 000000000..49bdf393c --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/site_info.py @@ -0,0 +1,98 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: site_info +short_description: Information module for Site +description: +- Get all Site. +- Get site using siteNameHierarchy/siteId/type ,return all sites if these parameters are not given as input. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + name: + description: + - Name query parameter. SiteNameHierarchy (ex global/groupName). + type: str + siteId: + description: + - SiteId query parameter. Site id to which site details to retrieve. + type: str + type: + description: + - Type query parameter. Type (ex area, building, floor). + type: str + offset: + description: + - Offset query parameter. Offset/starting row. The default value is 1. + type: int + limit: + description: + - Limit query parameter. Number of sites to be retrieved. The default value is 500. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Sites GetSite + description: Complete reference of the GetSite API. + link: https://developer.cisco.com/docs/dna-center/#!get-site +notes: + - SDK Method used are + sites.Sites.get_site, + + - Paths used are + get /dna/intent/api/v1/site, + +""" + +EXAMPLES = r""" +- name: Get all Site + cisco.dnac.site_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + name: string + siteId: string + type: string + offset: 0 + limit: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "parentId": "string", + "name": "string", + "additionalInfo": [ + "string" + ], + "siteHierarchy": "string", + "siteNameHierarchy": "string", + "instanceTenantId": "string", + "id": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/site_intent.py b/ansible_collections/cisco/dnac/plugins/modules/site_intent.py new file mode 100644 index 000000000..1ce744693 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/site_intent.py @@ -0,0 +1,592 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2022, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +__author__ = ("Madhan Sankaranarayanan, Rishita Chowdhary") + +DOCUMENTATION = r""" +--- +module: site_intent +short_description: Resource module for Site operations +description: +- Manage operation create, update and delete of the resource Sites. +- Creates site with area/building/floor with specified hierarchy. +- Updates site with area/building/floor with specified hierarchy. +- Deletes site with area/building/floor with specified hierarchy. +version_added: '6.6.0' +extends_documentation_fragment: + - cisco.dnac.intent_params +author: Madhan Sankaranarayanan (@madhansansel) + Rishita Chowdhary (@rishitachowdhary) +options: + state: + description: The state of DNAC after module completion. + type: str + choices: [ merged, deleted ] + default: merged + config: + description: + - List of details of site being managed. + type: list + elements: dict + required: true + suboptions: + type: + description: Type of site to create/update/delete (eg area, building, floor). + type: str + site: + description: Site Details. + type: dict + suboptions: + area: + description: Site Create's area. + type: dict + suboptions: + name: + description: Name of the area (eg Area1). + type: str + parentName: + description: Parent name of the area to be created. + type: str + building: + description: Building Details. + type: dict + suboptions: + address: + description: Address of the building to be created. + type: str + latitude: + description: Latitude coordinate of the building (eg 37.338). + type: int + longitude: + description: Longitude coordinate of the building (eg -121.832). + type: int + name: + description: Name of the building (eg building1). + type: str + parentName: + description: Parent name of building to be created. + type: str + floor: + description: Site Create's floor. + type: dict + suboptions: + height: + description: Height of the floor (eg 15). + type: int + length: + description: Length of the floor (eg 100). + type: int + name: + description: Name of the floor (eg floor-1). + type: str + parentName: + description: Parent name of the floor to be created. + type: str + rfModel: + description: Type of floor. Allowed values are 'Cubes And Walled Offices', + 'Drywall Office Only', 'Indoor High Ceiling', 'Outdoor Open Space'. + type: str + width: + description: Width of the floor (eg 100). + type: int + +requirements: +- dnacentersdk == 2.4.5 +- python >= 3.5 +notes: + - SDK Method used are + sites.Sites.create_site, + sites.Sites.update_site, + sites.Sites.delete_site + + - Paths used are + post /dna/intent/api/v1/site, + put dna/intent/api/v1/site/{siteId}, + delete dna/intent/api/v1/site/{siteId} +""" + +EXAMPLES = r""" +- name: Create a new building site + cisco.dnac.site_intent: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + dnac_log: "{{dnac_log}}" + config: + site: + building: + address: string + latitude: 0 + longitude: 0 + name: string + parentName: string + type: string +""" + +RETURN = r""" +#Case_1: Site is successfully created/updated/deleted +response_1: + description: A dictionary with API execution details as returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": + { + "bapiExecutionId": String, + "bapiKey": String, + "bapiName": String, + "endTime": String, + "endTimeEpoch": 0, + "runtimeInstanceId": String, + "siteId": String, + "startTime": String, + "startTimeEpoch": 0, + "status": String, + "timeDuration": 0 + + }, + "msg": "string" + } + +#Case_2: Site exits and does not need an update +response_2: + description: A dictionary with existing site details. + returned: always + type: dict + sample: > + { + "response": + { + "site": {}, + "siteId": String, + "type": String + }, + "msg": String + } + +#Case_3: Error while creating/updating/deleting site +response_3: + description: A dictionary with API execution details as returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": + { + "bapiError": String, + "bapiExecutionId": String, + "bapiKey": String, + "bapiName": String, + "endTime": String, + "endTimeEpoch": 0, + "runtimeInstanceId": String, + "startTime": String, + "startTimeEpoch": 0, + "status": String, + "timeDuration": 0 + + }, + "msg": "string" + } + +#Case_4: Site not found when atempting to delete site +response_4: + description: A list with the response returned by the Cisco DNAC Python + returned: always + type: list + sample: > + { + "response": [], + "msg": String + } +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DNACSDK, + validate_list_of_dicts, + log, + get_dict_result, + dnac_compare_equality, +) +import copy + +floor_plan = { + '57057': 'CUBES AND WALLED OFFICES', + '57058': 'DRYWELL OFFICE ONLY', + '41541500': 'FREE SPACE', + '57060': 'INDOOR HIGH CEILING', + '57059': 'OUTDOOR OPEN SPACE' +} + + +class DnacSite: + + def __init__(self, module): + self.module = module + self.params = module.params + self.config = copy.deepcopy(module.params.get("config")) + self.have = {} + self.want_create = {} + self.diff_create = [] + self.validated = [] + dnac_params = self.get_dnac_params(self.params) + log(str(dnac_params)) + self.dnac = DNACSDK(params=dnac_params) + self.log = dnac_params.get("dnac_log") + + self.result = dict(changed=False, diff=[], response=[], warnings=[]) + + def get_state(self): + return self.params.get("state") + + def validate_input(self): + temp_spec = dict( + type=dict(required=False, type='str'), + site=dict(required=True, type='dict'), + ) + + if self.config: + msg = None + # Validate site params + valid_temp, invalid_params = validate_list_of_dicts( + self.config, temp_spec + ) + + if invalid_params: + msg = "Invalid parameters in playbook: {0}".format( + "\n".join(invalid_params) + ) + self.module.fail_json(msg=msg) + + self.validated = valid_temp + + if self.log: + log(str(valid_temp)) + log(str(self.validated)) + + def get_dnac_params(self, params): + dnac_params = dict( + dnac_host=params.get("dnac_host"), + dnac_port=params.get("dnac_port"), + dnac_username=params.get("dnac_username"), + dnac_password=params.get("dnac_password"), + dnac_verify=params.get("dnac_verify"), + dnac_debug=params.get("dnac_debug"), + dnac_log=params.get("dnac_log") + ) + return dnac_params + + def get_current_site(self, site): + site_info = {} + + location = get_dict_result(site[0].get("additionalInfo"), 'nameSpace', "Location") + typeinfo = location.get("attributes").get("type") + + if typeinfo == "area": + site_info = dict( + area=dict( + name=site[0].get("name"), + parentName=site[0].get("siteNameHierarchy").split("/" + site[0].get("name"))[0] + ) + ) + + elif typeinfo == "building": + site_info = dict( + building=dict( + name=site[0].get("name"), + parentName=site[0].get("siteNameHierarchy").split("/" + site[0].get("name"))[0], + address=location.get("attributes").get("address", ""), + latitude=location.get("attributes").get("latitude"), + longitude=location.get("attributes").get("longitude"), + ) + ) + + elif typeinfo == "floor": + map_geometry = get_dict_result(site[0].get("additionalInfo"), 'nameSpace', "mapGeometry") + map_summary = get_dict_result(site[0].get("additionalInfo"), 'nameSpace', "mapsSummary") + rf_model = map_summary.get("attributes").get("rfModel") + + site_info = dict( + floor=dict( + name=site[0].get("name"), + parentName=site[0].get("siteNameHierarchy").split("/" + site[0].get("name"))[0], + rfModel=floor_plan.get(rf_model), + width=map_geometry.get("attributes").get("width"), + length=map_geometry.get("attributes").get("length"), + height=map_geometry.get("attributes").get("height") + ) + ) + + current_site = dict( + type=typeinfo, + site=site_info, + siteId=site[0].get("id") + ) + + if self.log: + log(str(current_site)) + + return current_site + + def site_exists(self): + site_exists = False + current_site = {} + response = None + try: + response = self.dnac._exec( + family="sites", + function='get_site', + params={"name": self.want.get("site_name")}, + ) + + except Exception as e: + if self.log: + log("The input site is not valid or site is not present.") + + if response: + if self.log: + log(str(response)) + + response = response.get("response") + current_site = self.get_current_site(response) + site_exists = True + + if self.log: + log(str(self.validated)) + + return (site_exists, current_site) + + def get_site_params(self, params): + site = params.get("site") + typeinfo = params.get("type") + + if typeinfo == "floor": + site["floor"]["rfModel"] = site.get("floor").get("rfModel").upper() + + site_params = dict( + type=typeinfo, + site=site, + ) + + return site_params + + def get_site_name(self, site): + site_type = site.get("type") + parent_name = site.get("site").get(site_type).get("parentName") + name = site.get("site").get(site_type).get("name") + site_name = '/'.join([parent_name, name]) + + if self.log: + log(site_name) + + return site_name + + def site_requires_update(self): + requested_site = self.want.get("site_params") + current_site = self.have.get("current_site") + + if self.log: + log("Current Site: " + str(current_site)) + log("Requested Site: " + str(requested_site)) + + obj_params = [ + ("type", "type"), + ("site", "site") + ] + + return any(not dnac_compare_equality(current_site.get(dnac_param), + requested_site.get(ansible_param)) + for (dnac_param, ansible_param) in obj_params) + + def get_execution_details(self, execid): + response = None + response = self.dnac._exec( + family="task", + function='get_business_api_execution_details', + params={"execution_id": execid} + ) + + if self.log: + log(str(response)) + + if response and isinstance(response, dict): + return response + + def get_have(self): + site_exists = False + current_site = None + have = {} + + # check if given site exits, if exists store current site info + (site_exists, current_site) = self.site_exists() + + if self.log: + log("Site Exists: " + str(site_exists) + "\n Current Site:" + str(current_site)) + + if site_exists: + have["site_id"] = current_site.get("siteId") + have["site_exists"] = site_exists + have["current_site"] = current_site + + self.have = have + + def get_want(self): + want = {} + + for site in self.validated: + want = dict( + site_params=self.get_site_params(site), + site_name=self.get_site_name(site), + ) + + self.want = want + + def get_diff_merge(self): + site_updated = False + site_created = False + + # check if the given site exists and/or needs to be updated/created. + if self.have.get("site_exists"): + if self.site_requires_update(): + # Existing Site requires update + site_params = self.want.get("site_params") + site_params["site_id"] = self.have.get("site_id") + response = self.dnac._exec( + family="sites", + function='update_site', + op_modifies=True, + params=site_params, + ) + site_updated = True + + else: + # Site does not neet update + self.result['response'] = self.have.get("current_site") + self.result['msg'] = "Site does not need update" + self.module.exit_json(**self.result) + + else: + # Creating New Site + response = self.dnac._exec( + family="sites", + function='create_site', + op_modifies=True, + params=self.want.get("site_params"), + ) + + log(str(response)) + site_created = True + + if site_created or site_updated: + if response and isinstance(response, dict): + executionid = response.get("executionId") + while True: + execution_details = self.get_execution_details(executionid) + if execution_details.get("status") == "SUCCESS": + self.result['changed'] = True + self.result['response'] = execution_details + break + + elif execution_details.get("bapiError"): + self.module.fail_json(msg=execution_details.get("bapiError"), + response=execution_details) + break + + if site_updated: + log("Site Updated Successfully") + self.result['msg'] = "Site Updated Successfully" + self.result['response'].update({"siteId": self.have.get("site_id")}) + + else: + # Get the site id of the newly created site. + (site_exists, current_site) = self.site_exists() + + if site_exists: + log("Site Created Successfully") + log("Current site:" + str(current_site)) + self.result['msg'] = "Site Created Successfully" + self.result['response'].update({"siteId": current_site.get('site_id')}) + + def get_diff_delete(self): + site_exists = self.have.get("site_exists") + + if site_exists: + response = self.dnac._exec( + family="sites", + function="delete_site", + params={"site_id": self.have.get("site_id")}, + ) + + if response and isinstance(response, dict): + executionid = response.get("executionId") + while True: + execution_details = self.get_execution_details(executionid) + if execution_details.get("status") == "SUCCESS": + self.result['changed'] = True + self.result['response'] = execution_details + self.result['response'].update({"siteId": self.have.get("site_id")}) + self.result['msg'] = "Site deleted successfully" + break + + elif execution_details.get("bapiError"): + self.module.fail_json(msg=execution_details.get("bapiError"), + response=execution_details) + break + + else: + self.module.fail_json(msg="Site Not Found", response=[]) + + +def main(): + """ main entry point for module execution + """ + + element_spec = dict( + dnac_host=dict(required=True, type='str'), + dnac_port=dict(type='str', default='443'), + dnac_username=dict(type='str', default='admin', aliases=["user"]), + dnac_password=dict(type='str', no_log=True), + dnac_verify=dict(type='bool', default='True'), + dnac_version=dict(type="str", default="2.2.3.3"), + dnac_debug=dict(type='bool', default=False), + dnac_log=dict(type='bool', default=False), + validate_response_schema=dict(type="bool", default=True), + config=dict(required=True, type='list', elements='dict'), + state=dict( + default='merged', + choices=['merged', 'deleted']), + ) + + module = AnsibleModule(argument_spec=element_spec, + supports_check_mode=False) + + dnac_site = DnacSite(module) + dnac_site.validate_input() + state = dnac_site.get_state() + + dnac_site.get_want() + dnac_site.get_have() + + if state == "merged": + dnac_site.get_diff_merge() + + elif state == "deleted": + dnac_site.get_diff_delete() + + module.exit_json(**dnac_site.result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/cisco/dnac/plugins/modules/site_membership_info.py b/ansible_collections/cisco/dnac/plugins/modules/site_membership_info.py new file mode 100644 index 000000000..d38f3844e --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/site_membership_info.py @@ -0,0 +1,101 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: site_membership_info +short_description: Information module for Site Membership +description: +- Get Site Membership by id. +- Getting the site children details and device details. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + siteId: + description: + - SiteId path parameter. Site id to retrieve device associated with the site. + type: str + offset: + description: + - Offset query parameter. Offset/starting row. + type: int + limit: + description: + - Limit query parameter. Number of sites to be retrieved. + type: int + deviceFamily: + description: + - DeviceFamily query parameter. Device family name. + type: str + serialNumber: + description: + - SerialNumber query parameter. Device serial number. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Sites GetMembership + description: Complete reference of the GetMembership API. + link: https://developer.cisco.com/docs/dna-center/#!get-membership +notes: + - SDK Method used are + sites.Sites.get_membership, + + - Paths used are + get /dna/intent/api/v1/membership/{siteId}, + +""" + +EXAMPLES = r""" +- name: Get Site Membership by id + cisco.dnac.site_membership_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + offset: 0 + limit: 0 + deviceFamily: string + serialNumber: string + siteId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "site": { + "response": [ + {} + ], + "version": "string" + }, + "device": [ + { + "response": [ + {} + ], + "version": "string", + "siteId": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/site_update.py b/ansible_collections/cisco/dnac/plugins/modules/site_update.py new file mode 100644 index 000000000..4a97a6ede --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/site_update.py @@ -0,0 +1,153 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: site_update +short_description: Resource module for Site Update +description: +- Manage operation update of the resource Site Update. +- Update site area/building/floor with specified hierarchy and new values. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + site: + description: Site Update's site. + suboptions: + area: + description: Site Update's area. + suboptions: + name: + description: Name. + type: str + parentName: + description: Parent Name. + type: str + type: dict + building: + description: Site Update's building. + suboptions: + address: + description: Address. + type: str + latitude: + description: Latitude. + type: int + longitude: + description: Longitude. + type: int + name: + description: Name. + type: str + parentName: + description: Parent Name. + type: str + type: dict + floor: + description: Site Update's floor. + suboptions: + height: + description: Height. + type: int + length: + description: Length. + type: int + name: + description: Name. + type: str + rfModel: + description: Rf Model. + type: str + width: + description: Width. + type: int + type: dict + type: dict + siteId: + description: SiteId path parameter. Site id to which site details to be updated. + type: str + type: + description: Type. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Sites UpdateSite + description: Complete reference of the UpdateSite API. + link: https://developer.cisco.com/docs/dna-center/#!update-site +notes: + - SDK Method used are + sites.Sites.update_site, + + - Paths used are + put /dna/intent/api/v1/site/{siteId}, + +""" + +EXAMPLES = r""" +- name: Update by id + cisco.dnac.site_update: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: '{{my_headers | from_json}}' + site: + area: + name: string + parentName: string + building: + address: string + latitude: 0 + longitude: 0 + name: string + parentName: string + floor: + height: 0 + length: 0 + name: string + rfModel: string + width: 0 + siteId: string + type: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "result": "string", + "response": { + "endTime": "string", + "version": "string", + "startTime": "string", + "progress": "string", + "data": "string", + "serviceType": "string", + "operationIdList": [ + "string" + ], + "isError": "string", + "rootId": "string", + "instanceTenantId": "string", + "id": "string" + }, + "status": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/snmp_properties.py b/ansible_collections/cisco/dnac/plugins/modules/snmp_properties.py new file mode 100644 index 000000000..0ea733b2a --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/snmp_properties.py @@ -0,0 +1,88 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: snmp_properties +short_description: Resource module for Snmp Properties +description: +- Manage operation create of the resource Snmp Properties. +- Adds SNMP properties. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + payload: + description: Snmp Properties's payload. + elements: dict + suboptions: + id: + description: Snmp Properties's id. + type: str + instanceTenantId: + description: Snmp Properties's instanceTenantId. + type: str + instanceUuid: + description: Snmp Properties's instanceUuid. + type: str + intValue: + description: Snmp Properties's intValue. + type: int + systemPropertyName: + description: Snmp Properties's systemPropertyName. + type: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery CreateUpdateSNMPProperties + description: Complete reference of the CreateUpdateSNMPProperties API. + link: https://developer.cisco.com/docs/dna-center/#!create-update-snmp-properties +notes: + - SDK Method used are + discovery.Discovery.create_update_snmp_properties, + + - Paths used are + post /dna/intent/api/v1/snmp-property, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.snmp_properties: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + payload: + - id: string + instanceTenantId: string + instanceUuid: string + intValue: 0 + systemPropertyName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/snmp_properties_info.py b/ansible_collections/cisco/dnac/plugins/modules/snmp_properties_info.py new file mode 100644 index 000000000..9300eaa86 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/snmp_properties_info.py @@ -0,0 +1,71 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: snmp_properties_info +short_description: Information module for Snmp Properties +description: +- Get all Snmp Properties. +- Returns SNMP properties. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery GetSNMPProperties + description: Complete reference of the GetSNMPProperties API. + link: https://developer.cisco.com/docs/dna-center/#!get-snmp-properties +notes: + - SDK Method used are + discovery.Discovery.get_snmp_properties, + + - Paths used are + get /dna/intent/api/v1/snmp-property, + +""" + +EXAMPLES = r""" +- name: Get all Snmp Properties + cisco.dnac.snmp_properties_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "id": "string", + "instanceTenantId": "string", + "instanceUuid": "string", + "intValue": 0, + "systemPropertyName": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/snmpv2_read_community_credential.py b/ansible_collections/cisco/dnac/plugins/modules/snmpv2_read_community_credential.py new file mode 100644 index 000000000..69da389ea --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/snmpv2_read_community_credential.py @@ -0,0 +1,103 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: snmpv2_read_community_credential +short_description: Resource module for Snmpv2 Read Community Credential +description: +- Manage operations create and update of the resource Snmpv2 Read Community Credential. +- Adds global SNMP read community. +- Updates global SNMP read community. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + comments: + description: Comments to identify the credential. + type: str + credentialType: + description: Credential type to identify the application that uses the credential. + type: str + description: + description: Name/Description of the credential. + type: str + instanceUuid: + description: Snmpv2 Read Community Credential's instanceUuid. + type: str + readCommunity: + description: SNMP read community. NO!$DATA!$ for no value change. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery CreateSNMPReadCommunity + description: Complete reference of the CreateSNMPReadCommunity API. + link: https://developer.cisco.com/docs/dna-center/#!create-snmp-read-community +- name: Cisco DNA Center documentation for Discovery UpdateSNMPReadCommunity + description: Complete reference of the UpdateSNMPReadCommunity API. + link: https://developer.cisco.com/docs/dna-center/#!update-snmp-read-community +notes: + - SDK Method used are + discovery.Discovery.create_snmp_read_community, + discovery.Discovery.update_snmp_read_community, + + - Paths used are + post /dna/intent/api/v1/global-credential/snmpv2-read-community, + put /dna/intent/api/v1/global-credential/snmpv2-read-community, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.snmpv2_read_community_credential: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + comments: string + credentialType: string + description: string + instanceUuid: string + readCommunity: string + +- name: Create + cisco.dnac.snmpv2_read_community_credential: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + comments: string + credentialType: string + description: string + readCommunity: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/snmpv2_write_community_credential.py b/ansible_collections/cisco/dnac/plugins/modules/snmpv2_write_community_credential.py new file mode 100644 index 000000000..2fbfbbc66 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/snmpv2_write_community_credential.py @@ -0,0 +1,103 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: snmpv2_write_community_credential +short_description: Resource module for Snmpv2 Write Community Credential +description: +- Manage operations create and update of the resource Snmpv2 Write Community Credential. +- Adds global SNMP write community. +- Updates global SNMP write community. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + comments: + description: Comments to identify the credential. + type: str + credentialType: + description: Credential type to identify the application that uses the credential. + type: str + description: + description: Name/Description of the credential. + type: str + instanceUuid: + description: Snmpv2 Write Community Credential's instanceUuid. + type: str + writeCommunity: + description: SNMP write community. NO!$DATA!$ for no value change. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery CreateSNMPWriteCommunity + description: Complete reference of the CreateSNMPWriteCommunity API. + link: https://developer.cisco.com/docs/dna-center/#!create-snmp-write-community +- name: Cisco DNA Center documentation for Discovery UpdateSNMPWriteCommunity + description: Complete reference of the UpdateSNMPWriteCommunity API. + link: https://developer.cisco.com/docs/dna-center/#!update-snmp-write-community +notes: + - SDK Method used are + discovery.Discovery.create_snmp_write_community, + discovery.Discovery.update_snmp_write_community, + + - Paths used are + post /dna/intent/api/v1/global-credential/snmpv2-write-community, + put /dna/intent/api/v1/global-credential/snmpv2-write-community, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.snmpv2_write_community_credential: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + comments: string + credentialType: string + description: string + writeCommunity: string + +- name: Update all + cisco.dnac.snmpv2_write_community_credential: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + comments: string + credentialType: string + description: string + instanceUuid: string + writeCommunity: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/snmpv3_credential.py b/ansible_collections/cisco/dnac/plugins/modules/snmpv3_credential.py new file mode 100644 index 000000000..d48c693d5 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/snmpv3_credential.py @@ -0,0 +1,139 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: snmpv3_credential +short_description: Resource module for Snmpv3 Credential +description: +- Manage operations create and update of the resource Snmpv3 Credential. +- Adds global SNMPv3 credentials. +- Updates global SNMPv3 credential. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + authPassword: + description: Snmpv3 Credential's authPassword. + type: str + authType: + description: Snmpv3 Credential's authType. + type: str + comments: + description: Snmpv3 Credential's comments. + type: str + credentialType: + description: Snmpv3 Credential's credentialType. + type: str + description: + description: Snmpv3 Credential's description. + type: str + id: + description: Snmpv3 Credential's id. + type: str + instanceTenantId: + description: Snmpv3 Credential's instanceTenantId. + type: str + instanceUuid: + description: Snmpv3 Credential's instanceUuid. + type: str + privacyPassword: + description: Snmpv3 Credential's privacyPassword. + type: str + privacyType: + description: Snmpv3 Credential's privacyType. + type: str + snmpMode: + description: Snmpv3 Credential's snmpMode. + type: str + username: + description: Snmpv3 Credential's username. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Discovery CreateSNMPv3Credentials + description: Complete reference of the CreateSNMPv3Credentials API. + link: https://developer.cisco.com/docs/dna-center/#!create-snm-pv-3-credentials +- name: Cisco DNA Center documentation for Discovery UpdateSNMPv3Credentials + description: Complete reference of the UpdateSNMPv3Credentials API. + link: https://developer.cisco.com/docs/dna-center/#!update-snm-pv-3-credentials +notes: + - SDK Method used are + discovery.Discovery.create_snmpv3_credentials, + discovery.Discovery.update_snmpv3_credentials, + + - Paths used are + post /dna/intent/api/v1/global-credential/snmpv3, + put /dna/intent/api/v1/global-credential/snmpv3, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.snmpv3_credential: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + authPassword: string + authType: string + comments: string + credentialType: string + description: string + id: string + instanceTenantId: string + instanceUuid: string + privacyPassword: string + privacyType: string + snmpMode: string + username: string + +- name: Create + cisco.dnac.snmpv3_credential: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + authPassword: string + authType: string + comments: string + credentialType: string + description: string + id: string + instanceTenantId: string + instanceUuid: string + privacyPassword: string + privacyType: string + snmpMode: string + username: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/sp_profile_delete_v2.py b/ansible_collections/cisco/dnac/plugins/modules/sp_profile_delete_v2.py new file mode 100644 index 000000000..1022d4de4 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/sp_profile_delete_v2.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: sp_profile_delete_v2 +short_description: Resource module for Sp Profile Delete V2 +description: +- Manage operation delete of the resource Sp Profile Delete V2. +- API to delete Service Provider Profile QoS . +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + spProfileName: + description: SpProfileName path parameter. Sp profile name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Network Settings DeleteSPProfileV2 + description: Complete reference of the DeleteSPProfileV2 API. + link: https://developer.cisco.com/docs/dna-center/#!delete-sp-profile-v-2 +notes: + - SDK Method used are + network_settings.NetworkSettings.delete_sp_profile_v2, + + - Paths used are + delete /dna/intent/api/v2/sp-profile/{spProfileName}, + +""" + +EXAMPLES = r""" +- name: Delete by name + cisco.dnac.sp_profile_delete_v2: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + spProfileName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/swim_image_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/swim_image_details_info.py new file mode 100644 index 000000000..b9ed467ed --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/swim_image_details_info.py @@ -0,0 +1,198 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: swim_image_details_info +short_description: Information module for Swim Image Details +description: +- Get all Swim Image Details. +- Returns software image list based on a filter criteria. For example "filterbyName = cat3k%". +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + imageUuid: + description: + - ImageUuid query parameter. + type: str + name: + description: + - Name query parameter. + type: str + family: + description: + - Family query parameter. + type: str + applicationType: + description: + - ApplicationType query parameter. + type: str + imageIntegrityStatus: + description: + - ImageIntegrityStatus query parameter. ImageIntegrityStatus - FAILURE, UNKNOWN, VERIFIED. + type: str + version: + description: + - Version query parameter. Software Image Version. + type: str + imageSeries: + description: + - ImageSeries query parameter. Image Series. + type: str + imageName: + description: + - ImageName query parameter. Image Name. + type: str + isTaggedGolden: + description: + - IsTaggedGolden query parameter. Is Tagged Golden. + type: bool + isCCORecommended: + description: + - IsCCORecommended query parameter. Is recommended from cisco.com. + type: bool + isCCOLatest: + description: + - IsCCOLatest query parameter. Is latest from cisco.com. + type: bool + createdTime: + description: + - CreatedTime query parameter. Time in milliseconds (epoch format). + type: int + imageSizeGreaterThan: + description: + - ImageSizeGreaterThan query parameter. Size in bytes. + type: int + imageSizeLesserThan: + description: + - ImageSizeLesserThan query parameter. Size in bytes. + type: int + sortBy: + description: + - SortBy query parameter. Sort results by this field. + type: str + sortOrder: + description: + - SortOrder query parameter. Sort order - 'asc' or 'des'. Default is asc. + type: str + limit: + description: + - Limit query parameter. + type: int + offset: + description: + - Offset query parameter. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Software Image Management (SWIM) GetSoftwareImageDetails + description: Complete reference of the GetSoftwareImageDetails API. + link: https://developer.cisco.com/docs/dna-center/#!get-software-image-details +notes: + - SDK Method used are + software_image_management_swim.SoftwareImageManagementSwim.get_software_image_details, + + - Paths used are + get /dna/intent/api/v1/image/importation, + +""" + +EXAMPLES = r""" +- name: Get all Swim Image Details + cisco.dnac.swim_image_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + imageUuid: string + name: string + family: string + applicationType: string + imageIntegrityStatus: string + version: string + imageSeries: string + imageName: string + isTaggedGolden: True + isCCORecommended: True + isCCOLatest: True + createdTime: 0 + imageSizeGreaterThan: 0 + imageSizeLesserThan: 0 + sortBy: string + sortOrder: string + limit: 0 + offset: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "applicableDevicesForImage": [ + { + "mdfId": "string", + "productId": [ + "string" + ], + "productName": "string" + } + ], + "applicationType": "string", + "createdTime": "string", + "extendedAttributes": {}, + "family": "string", + "feature": "string", + "fileServiceId": "string", + "fileSize": "string", + "imageIntegrityStatus": "string", + "imageName": "string", + "imageSeries": [ + "string" + ], + "imageSource": "string", + "imageType": "string", + "imageUuid": "string", + "importSourceType": "string", + "isTaggedGolden": true, + "md5Checksum": "string", + "name": "string", + "profileInfo": [ + { + "description": "string", + "extendedAttributes": {}, + "memory": 0, + "productType": "string", + "profileName": "string", + "shares": 0, + "vCpu": 0 + } + ], + "shaCheckSum": "string", + "vendor": "string", + "version": "string" + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/swim_import_local.py b/ansible_collections/cisco/dnac/plugins/modules/swim_import_local.py new file mode 100644 index 000000000..6ea0d9b9c --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/swim_import_local.py @@ -0,0 +1,84 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: swim_import_local +short_description: Resource module for Swim Import Local +description: +- Manage operation create of the resource Swim Import Local. +- > + Fetches a software image from local file system and uploads to DNA Center. Supported software image files + extensions are bin, img, tar, smu, pie, aes, iso, ova, tar_gz and qcow2. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + filePath: + description: File absolute path. + type: str + isThirdParty: + description: IsThirdParty query parameter. Third party Image check. + type: bool + thirdPartyApplicationType: + description: ThirdPartyApplicationType query parameter. Third Party Application + Type. + type: str + thirdPartyImageFamily: + description: ThirdPartyImageFamily query parameter. Third Party image family. + type: str + thirdPartyVendor: + description: ThirdPartyVendor query parameter. Third Party Vendor. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Software Image Management (SWIM) ImportLocalSoftwareImage + description: Complete reference of the ImportLocalSoftwareImage API. + link: https://developer.cisco.com/docs/dna-center/#!import-local-software-image +notes: + - SDK Method used are + software_image_management_swim.SoftwareImageManagementSwim.import_local_software_image, + + - Paths used are + post /dna/intent/api/v1/image/importation/source/file, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.swim_import_local: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + filePath: /tmp/uploads/Test-242.bin + isThirdParty: true + thirdPartyApplicationType: string + thirdPartyImageFamily: string + thirdPartyVendor: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/swim_import_via_url.py b/ansible_collections/cisco/dnac/plugins/modules/swim_import_via_url.py new file mode 100644 index 000000000..3f86cc047 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/swim_import_via_url.py @@ -0,0 +1,102 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: swim_import_via_url +short_description: Resource module for Swim Import Via Url +description: +- Manage operation create of the resource Swim Import Via Url. +- > + Fetches a software image from remote file system using URL for HTTP/FTP and uploads to DNA Center. Supported image + files extensions are bin, img, tar, smu, pie, aes, iso, ova, tar_gz and qcow2. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + payload: + description: Swim Import Via Url's payload. + elements: dict + suboptions: + applicationType: + description: Swim Import Via Url's applicationType. + type: str + imageFamily: + description: Swim Import Via Url's imageFamily. + type: str + sourceURL: + description: Swim Import Via Url's sourceURL. + type: str + thirdParty: + description: ThirdParty flag. + type: bool + vendor: + description: Swim Import Via Url's vendor. + type: str + type: list + scheduleAt: + description: ScheduleAt query parameter. Epoch Time (The number of milli-seconds + since January 1 1970 UTC) at which the distribution should be scheduled (Optional). + type: str + scheduleDesc: + description: ScheduleDesc query parameter. Custom Description (Optional). + type: str + scheduleOrigin: + description: ScheduleOrigin query parameter. Originator of this call (Optional). + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Software Image Management (SWIM) ImportSoftwareImageViaURL + description: Complete reference of the ImportSoftwareImageViaURL API. + link: https://developer.cisco.com/docs/dna-center/#!import-software-image-via-url +notes: + - SDK Method used are + software_image_management_swim.SoftwareImageManagementSwim.import_software_image_via_url, + + - Paths used are + post /dna/intent/api/v1/image/importation/source/url, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.swim_import_via_url: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + payload: + - applicationType: string + imageFamily: string + sourceURL: string + thirdParty: true + vendor: string + scheduleAt: string + scheduleDesc: string + scheduleOrigin: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/swim_intent.py b/ansible_collections/cisco/dnac/plugins/modules/swim_intent.py new file mode 100644 index 000000000..ca173fb44 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/swim_intent.py @@ -0,0 +1,754 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2022, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +__author__ = ("Madhan Sankaranarayanan, Rishita Chowdhary") + +DOCUMENTATION = r""" +--- +module: swim_intent +short_description: Intent module for SWIM related functions +description: +- Manage operation related to image importation, distribution, activation and tagging image as golden +- API to fetch a software image from remote file system using URL for HTTP/FTP and upload it to DNA Center. + Supported image files extensions are bin, img, tar, smu, pie, aes, iso, ova, tar_gz and qcow2. +- API to fetch a software image from local file system and upload it to DNA Center + Supported image files extensions are bin, img, tar, smu, pie, aes, iso, ova, tar_gz and qcow2. +- API to tag/untag image as golen for a given family of devices +- API to distribute a software image on a given device. Software image must be imported successfully into + DNA Center before it can be distributed. +- API to activate a software image on a given device. Software image must be present in the device flash. +version_added: '6.6.0' +extends_documentation_fragment: + - cisco.dnac.intent_params +author: Madhan Sankaranarayanan (@madhansansel) + Rishita Chowdhary (@rishitachowdhary) +options: + config: + description: List of details of SWIM image being managed + type: list + elements: dict + required: True + suboptions: + importImageDetails: + description: Details of image being imported + type: dict + suboptions: + type: + description: The source of import, supports url import or local import. + type: str + localImageDetails: + description: Details of the local path of the image to be imported. + type: dict + suboptions: + filePath: + description: File absolute path. + type: str + isThirdParty: + description: IsThirdParty query parameter. Third party Image check. + type: bool + thirdPartyApplicationType: + description: ThirdPartyApplicationType query parameter. Third Party Application Type. + type: str + thirdPartyImageFamily: + description: ThirdPartyImageFamily query parameter. Third Party image family. + type: str + thirdPartyVendor: + description: ThirdPartyVendor query parameter. Third Party Vendor. + type: str + urlDetails: + description: URL details for SWIM import + type: dict + suboptions: + payload: + description: Swim Import Via Url's payload. + type: list + elements: dict + suboptions: + applicationType: + description: Swim Import Via Url's applicationType. + type: str + imageFamily: + description: Swim Import Via Url's imageFamily. + type: str + sourceURL: + description: Swim Import Via Url's sourceURL. + type: str + thirdParty: + description: ThirdParty flag. + type: bool + vendor: + description: Swim Import Via Url's vendor. + type: str + scheduleAt: + description: ScheduleAt query parameter. Epoch Time (The number of milli-seconds since + January 1 1970 UTC) at which the distribution should be scheduled (Optional). + type: str + scheduleDesc: + description: ScheduleDesc query parameter. Custom Description (Optional). + type: str + scheduleOrigin: + description: ScheduleOrigin query parameter. Originator of this call (Optional). + type: str + taggingDetails: + description: Details for tagging or untagging an image as golden + type: dict + suboptions: + imageName: + description: SWIM image name which will be tagged or untagged as golden. + type: str + deviceRole: + description: Device Role. Permissible Values ALL, UNKNOWN, ACCESS, BORDER ROUTER, + DISTRIBUTION and CORE. + type: str + deviceFamilyName: + description: Device family name + type: str + siteName: + description: Site name for which SWIM image will be tagged/untagged as golden. + If not provided, SWIM image will be mapped to global site. + type: str + tagging: + description: Booelan value to tag/untag SWIM image as golden + If True then the given image will be tagged as golden. + If False then the given image will be un-tagged as golden. + type: bool + imageDistributionDetails: + description: Details for SWIM image distribution. Device on which the image needs to distributed + can be speciifed using any of the following parameters - deviceSerialNumber, + deviceIPAddress, deviceHostname or deviceMacAddress. + type: dict + suboptions: + imageName: + description: SWIM image's name + type: str + deviceSerialNumber: + description: Device serial number where the image needs to be distributed + type: str + deviceIPAddress: + description: Device IP address where the image needs to be distributed + type: str + deviceHostname: + description: Device hostname where the image needs to be distributed + type: str + deviceMacAddress: + description: Device MAC address where the image needs to be distributed + type: str + imageActivationDetails: + description: Details for SWIM image activation. Device on which the image needs to activated + can be speciifed using any of the following parameters - deviceSerialNumber, + deviceIPAddress, deviceHostname or deviceMacAddress. + type: dict + suboptions: + activateLowerImageVersion: + description: ActivateLowerImageVersion flag. + type: bool + deviceUpgradeMode: + description: Swim Trigger Activation's deviceUpgradeMode. + type: str + distributeIfNeeded: + description: DistributeIfNeeded flag. + type: bool + imageName: + description: SWIM image's name + type: str + deviceSerialNumber: + description: Device serial number where the image needs to be activated + type: str + deviceIPAddress: + description: Device IP address where the image needs to be activated + type: str + deviceHostname: + description: Device hostname where the image needs to be activated + type: str + deviceMacAddress: + description: Device MAC address where the image needs to be activated + type: str + scheduleValidate: + description: ScheduleValidate query parameter. ScheduleValidate, validates data + before schedule (Optional). + type: bool +requirements: +- dnacentersdk == 2.4.5 +- python >= 3.5 +notes: + - SDK Method used are + software_image_management_swim.SoftwareImageManagementSwim.import_software_image_via_url, + software_image_management_swim.SoftwareImageManagementSwim.tag_as_golden_image, + software_image_management_swim.SoftwareImageManagementSwim.trigger_software_image_distribution, + software_image_management_swim.SoftwareImageManagementSwim.trigger_software_image_activation, + + - Paths used are + post /dna/intent/api/v1/image/importation/source/url, + post /dna/intent/api/v1/image/importation/golden, + post /dna/intent/api/v1/image/distribution, + post /dna/intent/api/v1/image/activation/device, + +""" + +EXAMPLES = r""" +- name: Import an image from a URL, tag it as golden and load it on device + cisco.dnac.swim_intent: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + dnac_log: True + config: + - importImageDetails: + type: string + urlDetails: + payload: + - sourceURL: string + isThirdParty: bool + imageFamily: string + vendor: string + applicationType: string + scheduleAt: string + scheduleDesc: string + scheduleOrigin: string + taggingDetails: + imageName: string + deviceRole: string + deviceFamilyName: string + siteName: string + tagging: bool + imageDistributionDetails: + imageName: string + deviceSerialNumber: string + imageActivationDetails: + scheduleValidate: bool + activateLowerImageVersion: bool + distributeIfNeeded: bool + deviceSerialNumber: string + imageName: string +""" + +RETURN = r""" +#Case: SWIM image is successfully imported, tagged as golden, distributed and activated on a device +response: + description: A dictionary with activation details as returned by the DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "additionalStatusURL": String, + "data": String, + "endTime": 0, + "id": String, + "instanceTenantId": String, + "isError": bool, + "lastUpdate": 0, + "progress": String, + "rootId": String, + "serviceType": String, + "startTime": 0, + "version": 0 + }, + "msg": String + } + +""" + +import copy +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DNACSDK, + validate_list_of_dicts, + log, + get_dict_result, +) +from ansible.module_utils.basic import AnsibleModule + + +class DnacSwims: + + def __init__(self, module): + self.module = module + self.params = module.params + self.config = copy.deepcopy(module.params.get("config")) + self.have = {} + self.want_create = {} + self.diff_create = [] + self.validated = [] + dnac_params = self.get_dnac_params(self.params) + log(str(dnac_params)) + self.dnac = DNACSDK(params=dnac_params) + self.log = dnac_params.get("dnac_log") + + self.result = dict(changed=False, diff=[], response=[], warnings=[]) + + def validate_input(self): + temp_spec = dict( + importImageDetails=dict(type='dict'), + taggingDetails=dict(type='dict'), + imageDistributionDetails=dict(type='dict'), + imageActivationDetails=dict(type='dict'), + ) + if self.config: + msg = None + # Validate site params + valid_temp, invalid_params = validate_list_of_dicts( + self.config, temp_spec + ) + if invalid_params: + msg = "Invalid parameters in playbook: {0}".format( + "\n".join(invalid_params) + ) + self.module.fail_json(msg=msg) + + self.validated = valid_temp + if self.log: + log(str(valid_temp)) + log(str(self.validated)) + + def get_dnac_params(self, params): + dnac_params = dict( + dnac_host=params.get("dnac_host"), + dnac_port=params.get("dnac_port"), + dnac_username=params.get("dnac_username"), + dnac_password=params.get("dnac_password"), + dnac_verify=params.get("dnac_verify"), + dnac_debug=params.get("dnac_debug"), + dnac_log=params.get("dnac_log") + ) + return dnac_params + + def get_task_details(self, id): + result = None + response = self.dnac._exec( + family="task", + function='get_task_by_id', + params={"task_id": id}, + ) + if self.log: + log(str(response)) + + if isinstance(response, dict): + result = response.get("response") + + return result + + def site_exists(self): + site_exists = False + site_id = None + response = None + try: + response = self.dnac._exec( + family="sites", + function='get_site', + params={"name": self.want.get("site_name")}, + ) + except Exception as e: + self.module.fail_json(msg="Site not found") + + if response: + if self.log: + log(str(response)) + + site = response.get("response") + site_id = site[0].get("id") + site_exists = True + + return (site_exists, site_id) + + def get_image_id(self, name): + # check if given image exists, if exists store image_id + image_response = self.dnac._exec( + family="software_image_management_swim", + function='get_software_image_details', + params={"image_name": name}, + ) + + if self.log: + log(str(image_response)) + + image_list = image_response.get("response") + if (len(image_list) == 1): + image_id = image_list[0].get("imageUuid") + if self.log: + log("Image Id: " + str(image_id)) + else: + self.module.fail_json(msg="Image not found", response=image_response) + + return image_id + + def get_device_id(self, params): + response = self.dnac._exec( + family="devices", + function='get_device_list', + params=params, + ) + if self.log: + log(str(response)) + + device_list = response.get("response") + if (len(device_list) == 1): + device_id = device_list[0].get("id") + if self.log: + log("Device Id: " + str(device_id)) + else: + self.module.fail_json(msg="Device not found", response=response) + + return device_id + + def get_device_family_identifier(self, family_name): + have = {} + response = self.dnac._exec( + family="software_image_management_swim", + function='get_device_family_identifiers', + ) + if self.log: + log(str(response)) + device_family_db = response.get("response") + if device_family_db: + device_family_details = get_dict_result(device_family_db, 'deviceFamily', family_name) + if device_family_details: + device_family_identifier = device_family_details.get("deviceFamilyIdentifier") + have["device_family_identifier"] = device_family_identifier + if self.log: + log("Family device indentifier:" + str(device_family_identifier)) + else: + self.module.fail_json(msg="Family Device Name not found", response=[]) + self.have.update(have) + + def get_have(self): + if self.want.get("tagging_details"): + have = {} + tagging_details = self.want.get("tagging_details") + if tagging_details.get("imageName"): + image_id = self.get_image_id(tagging_details.get("imageName")) + have["tagging_image_id"] = image_id + + elif self.have.get("imported_image_id"): + have["tagging_image_id"] = self.have.get("imported_image_id") + + else: + self.module.fail_json(msg="Image details for tagging not provided", response=[]) + + # check if given site exists, store siteid + # if not then use global site + site_name = tagging_details.get("siteName") + if site_name: + site_exists = False + (site_exists, site_id) = self.site_exists() + if site_exists: + have["site_id"] = site_id + if self.log: + log("Site Exists: " + str(site_exists) + "\n Site_id:" + str(site_id)) + else: + # For global site, use -1 as siteId + have["site_id"] = "-1" + if self.log: + log("Site Name not given by user. Using global site.") + + self.have.update(have) + # check if given device family name exists, store indentifier value + family_name = tagging_details.get("deviceFamilyName") + self.get_device_family_identifier(family_name) + + if self.want.get("distribution_details"): + have = {} + distribution_details = self.want.get("distribution_details") + # check if image for distributon is available + if distribution_details.get("imageName"): + image_id = self.get_image_id(distribution_details.get("imageName")) + have["distribution_image_id"] = image_id + + elif self.have.get("imported_image_id"): + have["distribution_image_id"] = self.have.get("imported_image_id") + + else: + self.module.fail_json(msg="Image details for distribution not provided", response=[]) + + device_params = dict( + hostname=distribution_details.get("deviceHostname"), + serial_number=distribution_details.get("deviceSerialNumber"), + management_ip_address=distribution_details.get("deviceIpAddress"), + mac_address=distribution_details.get("deviceMacAddress"), + ) + device_id = self.get_device_id(device_params) + have["distribution_device_id"] = device_id + self.have.update(have) + + if self.want.get("activation_details"): + have = {} + activation_details = self.want.get("activation_details") + # check if image for activation is available + if activation_details.get("imageName"): + image_id = self.get_image_id(activation_details.get("imageName")) + have["activation_image_id"] = image_id + + elif self.have.get("imported_image_id"): + have["activation_image_id"] = self.have.get("imported_image_id") + + else: + self.module.fail_json(msg="Image details for activation not provided", response=[]) + + device_params = dict( + hostname=activation_details.get("deviceHostname"), + serial_number=activation_details.get("deviceSerialNumber"), + management_ip_address=activation_details.get("deviceIpAddress"), + mac_address=activation_details.get("deviceMacAddress"), + ) + device_id = self.get_device_id(device_params) + have["activation_device_id"] = device_id + self.have.update(have) + + def get_want(self): + want = {} + for image in self.validated: + if image.get("importImageDetails"): + want["import_image"] = True + want["import_type"] = image.get("importImageDetails").get("type").lower() + if want["import_type"] == "url": + want["url_import_details"] = image.get("importImageDetails").get("urlDetails") + elif want["import_type"] == "local": + want["local_import_details"] = image.get("importImageDetails").get("localImageDetails") + else: + self.module.fail_json(msg="Incorrect import type. Supported Values: local or url") + + want["tagging_details"] = image.get("taggingDetails") + want["distribution_details"] = image.get("imageDistributionDetails") + want["activation_details"] = image.get("imageActivationDetails") + + self.want = want + if self.log: + log(str(self.want)) + + def get_diff_import(self): + if not self.want.get("import_image"): + return + + if self.want.get("import_type") == "url": + image_name = self.want.get("url_import_details").get("payload")[0].get("sourceURL") + url_import_params = dict( + payload=self.want.get("url_import_details").get("payload"), + schedule_at=self.want.get("url_import_details").get("scheduleAt"), + schedule_desc=self.want.get("url_import_details").get("scheduleDesc"), + schedule_origin=self.want.get("url_import_details").get("scheduleOrigin"), + ) + response = self.dnac._exec( + family="software_image_management_swim", + function='import_software_image_via_url', + op_modifies=True, + params=url_import_params, + ) + else: + image_name = self.want.get("local_import_details").get("filePath") + local_import_params = dict( + is_third_party=self.want.get("local_import_details").get("isThirdParty"), + third_party_vendor=self.want.get("local_import_details").get("thirdPartyVendor"), + third_party_image_family=self.want.get("local_import_details").get("thirdPartyImageFamily"), + third_party_application_type=self.want.get("local_import_details").get("thirdPartyApplicationType"), + file_path=self.want.get("local_import_details").get("filePath"), + ) + response = self.dnac._exec( + family="software_image_management_swim", + function='import_local_software_image', + op_modifies=True, + params=local_import_params, + file_paths=[('file_path', 'file')], + ) + + if self.log: + log(str(response)) + + task_details = {} + task_id = response.get("response").get("taskId") + while (True): + task_details = self.get_task_details(task_id) + if task_details and \ + ("completed successfully" in task_details.get("progress").lower()): + self.result['changed'] = True + self.result['msg'] = "Image imported successfully" + break + + if task_details and task_details.get("isError"): + if "Image already exists" in task_details.get("failureReason"): + self.result['msg'] = "Image already exists." + break + else: + self.module.fail_json(msg=task_details.get("failureReason"), + response=task_details) + + self.result['response'] = task_details if task_details else response + if not (self.want.get("tagging_details") or self.want.get("distribution_details") + or self.want.get("activation_details")): + return + # Fetch image_id for the imported image for further use + image_name = image_name.split('/')[-1] + image_id = self.get_image_id(image_name) + self.have["imported_image_id"] = image_id + + def get_diff_tagging(self): + tagging_details = self.want.get("tagging_details") + tag_image_golden = tagging_details.get("tagging") + + if tag_image_golden: + image_params = dict( + imageId=self.have.get("tagging_image_id"), + siteId=self.have.get("site_id"), + deviceFamilyIdentifier=self.have.get("device_family_identifier"), + deviceRole=tagging_details.get("deviceRole") + ) + if self.log: + log("Image params for tagging image as golden:" + str(image_params)) + + response = self.dnac._exec( + family="software_image_management_swim", + function='tag_as_golden_image', + op_modifies=True, + params=image_params + ) + + else: + image_params = dict( + image_id=self.have.get("tagging_image_id"), + site_id=self.have.get("site_id"), + device_family_identifier=self.have.get("device_family_identifier"), + device_role=tagging_details.get("deviceRole") + ) + if self.log: + log("Image params for un-tagging image as golden:" + str(image_params)) + + response = self.dnac._exec( + family="software_image_management_swim", + function='remove_golden_tag_for_image', + op_modifies=True, + params=image_params + ) + + if response: + task_details = {} + task_id = response.get("response").get("taskId") + task_details = self.get_task_details(task_id) + if not task_details.get("isError"): + self.result['changed'] = True + self.result['msg'] = task_details.get("progress") + + self.result['response'] = task_details if task_details else response + + def get_diff_distribution(self): + distribution_details = self.want.get("distribution_details") + distribution_params = dict( + payload=[dict( + deviceUuid=self.have.get("distribution_device_id"), + imageUuid=self.have.get("distribution_image_id") + )] + ) + if self.log: + log("Distribution Params: " + str(distribution_params)) + + response = self.dnac._exec( + family="software_image_management_swim", + function='trigger_software_image_distribution', + op_modifies=True, + params=distribution_params, + ) + if response: + task_details = {} + task_id = response.get("response").get("taskId") + while (True): + task_details = self.get_task_details(task_id) + if not task_details.get("isError") and \ + ("completed successfully" in task_details.get("progress")): + self.result['changed'] = True + self.result['msg'] = "Image Distributed Successfully" + break + + if task_details.get("isError"): + self.module.fail_json(msg="Image Distribution Failed", + response=task_details) + + self.result['response'] = task_details if task_details else response + + def get_diff_activation(self): + activation_details = self.want.get("activation_details") + payload = [dict( + activateLowerImageVersion=activation_details.get("activateLowerImageVersion"), + deviceUpgradeMode=activation_details.get("deviceUpgradeMode"), + distributeIfNeeded=activation_details.get("distributeIfNeeded"), + deviceUuid=self.have.get("activation_device_id"), + imageUuidList=[self.have.get("activation_image_id")] + )] + activation_params = dict( + schedule_validate=activation_details.get("scehduleValidate"), + payload=payload + ) + if self.log: + log("Activation Params: " + str(activation_params)) + + response = self.dnac._exec( + family="software_image_management_swim", + function='trigger_software_image_activation', + op_modifies=True, + params=activation_params, + ) + task_details = {} + task_id = response.get("response").get("taskId") + while (True): + task_details = self.get_task_details(task_id) + if not task_details.get("isError") and \ + ("completed successfully" in task_details.get("progress")): + self.result['changed'] = True + self.result['msg'] = "Image activated successfully" + break + + if task_details.get("isError"): + self.module.fail_json(msg="Image Activation Failed", + response=task_details) + + self.result['response'] = task_details if task_details else response + + def get_diff(self): + if self.want.get("tagging_details"): + self.get_diff_tagging() + + if self.want.get("distribution_details"): + self.get_diff_distribution() + + if self.want.get("activation_details"): + self.get_diff_activation() + + +def main(): + """ main entry point for module execution + """ + + element_spec = dict( + dnac_host=dict(required=True, type='str'), + dnac_port=dict(type='str', default='443'), + dnac_username=dict(type='str', default='admin', aliases=["user"]), + dnac_password=dict(type='str', no_log=True), + dnac_verify=dict(type='bool', default='True'), + dnac_version=dict(type="str", default="2.2.3.3"), + dnac_debug=dict(type='bool', default=False), + dnac_log=dict(type='bool', default=False), + config=dict(required=True, type='list', elements='dict'), + validate_response_schema=dict(type="bool", default=True), + ) + + module = AnsibleModule(argument_spec=element_spec, + supports_check_mode=False) + + dnac_swims = DnacSwims(module) + dnac_swims.validate_input() + dnac_swims.get_want() + dnac_swims.get_diff_import() + dnac_swims.get_have() + dnac_swims.get_diff() + + module.exit_json(**dnac_swims.result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/cisco/dnac/plugins/modules/swim_trigger_activation.py b/ansible_collections/cisco/dnac/plugins/modules/swim_trigger_activation.py new file mode 100644 index 000000000..ec9ca0e5b --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/swim_trigger_activation.py @@ -0,0 +1,104 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: swim_trigger_activation +short_description: Resource module for Swim Trigger Activation +description: +- Manage operation create of the resource Swim Trigger Activation. +- Activates a software image on a given device. Software image must be present in the device flash. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + payload: + description: Swim Trigger Activation's payload. + elements: dict + suboptions: + activateLowerImageVersion: + description: ActivateLowerImageVersion flag. + type: bool + deviceUpgradeMode: + description: Swim Trigger Activation's deviceUpgradeMode. + type: str + deviceUuid: + description: Swim Trigger Activation's deviceUuid. + type: str + distributeIfNeeded: + description: DistributeIfNeeded flag. + type: bool + imageUuidList: + description: Swim Trigger Activation's imageUuidList. + elements: str + type: list + smuImageUuidList: + description: Swim Trigger Activation's smuImageUuidList. + elements: str + type: list + type: list + scheduleValidate: + description: ScheduleValidate query parameter. ScheduleValidate, validates data + before schedule (Optional). + type: bool +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Software Image Management (SWIM) TriggerSoftwareImageActivation + description: Complete reference of the TriggerSoftwareImageActivation API. + link: https://developer.cisco.com/docs/dna-center/#!trigger-software-image-activation +notes: + - SDK Method used are + software_image_management_swim.SoftwareImageManagementSwim.trigger_software_image_activation, + + - Paths used are + post /dna/intent/api/v1/image/activation/device, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.swim_trigger_activation: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: '{{my_headers | from_json}}' + payload: + - activateLowerImageVersion: true + deviceUpgradeMode: string + deviceUuid: string + distributeIfNeeded: true + imageUuidList: + - string + smuImageUuidList: + - string + scheduleValidate: true + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/swim_trigger_distribution.py b/ansible_collections/cisco/dnac/plugins/modules/swim_trigger_distribution.py new file mode 100644 index 000000000..cad143cb4 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/swim_trigger_distribution.py @@ -0,0 +1,77 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: swim_trigger_distribution +short_description: Resource module for Swim Trigger Distribution +description: +- Manage operation create of the resource Swim Trigger Distribution. +- > + Distributes a software image on a given device. Software image must be imported successfully into DNA Center + before it can be distributed. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + payload: + description: Swim Trigger Distribution's payload. + elements: dict + suboptions: + deviceUuid: + description: Swim Trigger Distribution's deviceUuid. + type: str + imageUuid: + description: Swim Trigger Distribution's imageUuid. + type: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Software Image Management (SWIM) TriggerSoftwareImageDistribution + description: Complete reference of the TriggerSoftwareImageDistribution API. + link: https://developer.cisco.com/docs/dna-center/#!trigger-software-image-distribution +notes: + - SDK Method used are + software_image_management_swim.SoftwareImageManagementSwim.trigger_software_image_distribution, + + - Paths used are + post /dna/intent/api/v1/image/distribution, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.swim_trigger_distribution: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + payload: + - deviceUuid: string + imageUuid: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/syslog_config_create.py b/ansible_collections/cisco/dnac/plugins/modules/syslog_config_create.py new file mode 100644 index 000000000..d9058d44e --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/syslog_config_create.py @@ -0,0 +1,87 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: syslog_config_create +short_description: Resource module for Syslog Config Create +description: +- Manage operation create of the resource Syslog Config Create. +- Create Syslog Destination. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + configId: + description: Required only for update syslog configuration. + type: str + description: + description: Description. + type: str + host: + description: Host. + type: str + name: + description: Name. + type: str + port: + description: Port. + type: str + protocol: + description: Protocol. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management CreateSyslogDestination + description: Complete reference of the CreateSyslogDestination API. + link: https://developer.cisco.com/docs/dna-center/#!create-syslog-destination +notes: + - SDK Method used are + event_management.EventManagement.create_syslog_destination, + + - Paths used are + post /dna/intent/api/v1/event/syslogConfig, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.syslog_config_create: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + configId: string + description: string + host: string + name: string + port: string + protocol: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "errorMessage": { + "errors": [ + "string" + ] + }, + "apiStatus": "string", + "statusMessage": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/syslog_config_update.py b/ansible_collections/cisco/dnac/plugins/modules/syslog_config_update.py new file mode 100644 index 000000000..79d319fea --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/syslog_config_update.py @@ -0,0 +1,87 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: syslog_config_update +short_description: Resource module for Syslog Config Update +description: +- Manage operation update of the resource Syslog Config Update. +- Update Syslog Destination. +version_added: '6.0.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + configId: + description: Required only for update syslog configuration. + type: str + description: + description: Description. + type: str + host: + description: Host. + type: str + name: + description: Name. + type: str + port: + description: Port. + type: str + protocol: + description: Protocol. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Event Management UpdateSyslogDestination + description: Complete reference of the UpdateSyslogDestination API. + link: https://developer.cisco.com/docs/dna-center/#!update-syslog-destination +notes: + - SDK Method used are + event_management.EventManagement.update_syslog_destination, + + - Paths used are + put /dna/intent/api/v1/event/syslogConfig, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.syslog_config_update: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + configId: string + description: string + host: string + name: string + port: string + protocol: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "errorMessage": { + "errors": [ + "string" + ] + }, + "apiStatus": "string", + "statusMessage": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/system_health_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/system_health_count_info.py new file mode 100644 index 000000000..b8e6b135c --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/system_health_count_info.py @@ -0,0 +1,76 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: system_health_count_info +short_description: Information module for System Health Count +description: +- Get all System Health Count. +- This API gives the count of the latest system events. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + domain: + description: + - > + Domain query parameter. Fetch system events with this domain. Possible values of domain are listed here + /dna/platform/app/consumer-portal/developer-toolkit/events. + type: str + subdomain: + description: + - > + Subdomain query parameter. Fetch system events with this subdomain. Possible values of subdomain are listed + here /dna/platform/app/consumer-portal/developer-toolkit/events. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Health and Performance SystemHealthCountAPI + description: Complete reference of the SystemHealthCountAPI API. + link: https://developer.cisco.com/docs/dna-center/#!system-health-count-api +notes: + - SDK Method used are + health_and_performance.HealthAndPerformance.system_health_count, + + - Paths used are + get /dna/intent/api/v1/diagnostics/system/health/count, + +""" + +EXAMPLES = r""" +- name: Get all System Health Count + cisco.dnac.system_health_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + domain: string + subdomain: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "count": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/system_health_info.py b/ansible_collections/cisco/dnac/plugins/modules/system_health_info.py new file mode 100644 index 000000000..c0d2ea881 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/system_health_info.py @@ -0,0 +1,108 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: system_health_info +short_description: Information module for System Health +description: +- Get all System Health. +- This API retrieves the latest system events. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + summary: + description: + - Summary query parameter. Fetch the latest high severity event. + type: bool + domain: + description: + - > + Domain query parameter. Fetch system events with this domain. Possible values of domain are listed here + /dna/platform/app/consumer-portal/developer-toolkit/events. + type: str + subdomain: + description: + - > + Subdomain query parameter. Fetch system events with this subdomain. Possible values of subdomain are listed + here /dna/platform/app/consumer-portal/developer-toolkit/events. + type: str + limit: + description: + - Limit query parameter. + type: int + offset: + description: + - Offset query parameter. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Health and Performance SystemHealthAPI + description: Complete reference of the SystemHealthAPI API. + link: https://developer.cisco.com/docs/dna-center/#!system-health-api +notes: + - SDK Method used are + health_and_performance.HealthAndPerformance.system_health, + + - Paths used are + get /dna/intent/api/v1/diagnostics/system/health, + +""" + +EXAMPLES = r""" +- name: Get all System Health + cisco.dnac.system_health_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + summary: True + domain: string + subdomain: string + limit: 0 + offset: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "healthEvents": [ + { + "severity": "string", + "hostname": "string", + "instance": "string", + "subDomain": "string", + "domain": "string", + "description": "string", + "state": "string", + "timestamp": "string", + "status": "string" + } + ], + "version": "string", + "hostName": "string", + "cimcaddress": [ + "string" + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/system_performance_historical_info.py b/ansible_collections/cisco/dnac/plugins/modules/system_performance_historical_info.py new file mode 100644 index 000000000..9cdbef7d6 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/system_performance_historical_info.py @@ -0,0 +1,103 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: system_performance_historical_info +short_description: Information module for System Performance Historical +description: +- Get all System Performance Historical. +- This API retrieves the historical performance indicators. The data can be retrieved for the last 3 months. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + kpi: + description: + - Kpi query parameter. Fetch historical data for this kpi. Valid values cpu,memory,network. + type: str + startTime: + description: + - > + StartTime query parameter. This is the epoch start time in milliseconds from which performance indicator + need to be fetched. + type: int + endTime: + description: + - > + EndTime query parameter. This is the epoch end time in milliseconds upto which performance indicator need to + be fetched. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Health and Performance SystemPerformanceHistoricalAPI + description: Complete reference of the SystemPerformanceHistoricalAPI API. + link: https://developer.cisco.com/docs/dna-center/#!system-performance-historical-api +notes: + - SDK Method used are + health_and_performance.HealthAndPerformance.system_performance_historical, + + - Paths used are + get /dna/intent/api/v1/diagnostics/system/performance/history, + +""" + +EXAMPLES = r""" +- name: Get all System Performance Historical + cisco.dnac.system_performance_historical_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + kpi: string + startTime: 0 + endTime: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "hostName": "string", + "version": "string", + "kpis": { + "legends": { + "cpu": { + "units": "string" + }, + "memory": { + "units": "string" + }, + "network tx_rate": { + "units": "string" + }, + "network rx_rate": { + "units": "string" + } + }, + "data": { + "t1": [ + "string" + ] + } + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/system_performance_info.py b/ansible_collections/cisco/dnac/plugins/modules/system_performance_info.py new file mode 100644 index 000000000..8460d7265 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/system_performance_info.py @@ -0,0 +1,105 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: system_performance_info +short_description: Information module for System Performance +description: +- Get all System Performance. +- This API gives the aggregated performance indicators. The data can be retrieved for the last 3 months. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + kpi: + description: + - Kpi query parameter. Valid values cpu,memory,network. + type: str + function: + description: + - Function query parameter. Valid values sum,average,max. + type: str + startTime: + description: + - > + StartTime query parameter. This is the epoch start time in milliseconds from which performance indicator + need to be fetched. + type: int + endTime: + description: + - > + EndTime query parameter. This is the epoch end time in milliseconds upto which performance indicator need to + be fetched. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Health and Performance SystemPerformanceAPI + description: Complete reference of the SystemPerformanceAPI API. + link: https://developer.cisco.com/docs/dna-center/#!system-performance-api +notes: + - SDK Method used are + health_and_performance.HealthAndPerformance.system_performance, + + - Paths used are + get /dna/intent/api/v1/diagnostics/system/performance, + +""" + +EXAMPLES = r""" +- name: Get all System Performance + cisco.dnac.system_performance_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + kpi: string + function: string + startTime: 0 + endTime: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "hostName": "string", + "version": "string", + "kpis": { + "cpu": { + "units": "string", + "utilization": "string" + }, + "memory": { + "units": "string", + "utilization": "string" + }, + "network tx_rate": { + "units": "string", + "utilization": "string" + }, + "network rx_rate": { + "units": "string", + "utilization": "string" + } + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/tag.py b/ansible_collections/cisco/dnac/plugins/modules/tag.py new file mode 100644 index 000000000..7630c2e61 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/tag.py @@ -0,0 +1,170 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: tag +short_description: Resource module for Tag +description: +- Manage operations create, update and delete of the resource Tag. +- Creates tag with specified tag attributes. +- Deletes a tag specified by id. +- Updates a tag specified by id. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + description: + description: Tag's description. + type: str + dynamicRules: + description: Tag's dynamicRules. + elements: dict + suboptions: + memberType: + description: Tag's memberType. + type: str + rules: + description: Tag's rules. + suboptions: + items: + description: Tag's items. + elements: str + type: list + name: + description: Tag's name. + type: str + operation: + description: Tag's operation. + type: str + value: + description: Tag's value. + type: str + values: + description: Tag's values. + elements: str + type: list + type: dict + type: list + id: + description: Tag's id. + type: str + instanceTenantId: + description: Tag's instanceTenantId. + type: str + name: + description: Tag's name. + type: str + systemTag: + description: SystemTag flag. + type: bool +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Tag CreateTag + description: Complete reference of the CreateTag API. + link: https://developer.cisco.com/docs/dna-center/#!create-tag +- name: Cisco DNA Center documentation for Tag DeleteTag + description: Complete reference of the DeleteTag API. + link: https://developer.cisco.com/docs/dna-center/#!delete-tag +- name: Cisco DNA Center documentation for Tag UpdateTag + description: Complete reference of the UpdateTag API. + link: https://developer.cisco.com/docs/dna-center/#!update-tag +notes: + - SDK Method used are + tag.Tag.create_tag, + tag.Tag.delete_tag, + tag.Tag.update_tag, + + - Paths used are + post /dna/intent/api/v1/tag, + delete /dna/intent/api/v1/tag/{id}, + put /dna/intent/api/v1/tag, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.tag: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + description: string + dynamicRules: + - memberType: string + rules: + items: + - string + name: string + operation: string + value: string + values: + - string + id: string + instanceTenantId: string + name: string + systemTag: true + +- name: Create + cisco.dnac.tag: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + description: string + dynamicRules: + - memberType: string + rules: + items: string + name: string + operation: string + value: string + values: + - string + id: string + instanceTenantId: string + name: string + systemTag: true + +- name: Delete by id + cisco.dnac.tag: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + id: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": { + "taskId": "string", + "url": "string" + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/tag_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/tag_count_info.py new file mode 100644 index 000000000..4624d65ed --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/tag_count_info.py @@ -0,0 +1,93 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: tag_count_info +short_description: Information module for Tag Count +description: +- Get all Tag Count. +- Returns tag count. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + name: + description: + - Name query parameter. + type: str + nameSpace: + description: + - NameSpace query parameter. + type: str + attributeName: + description: + - AttributeName query parameter. + type: str + level: + description: + - Level query parameter. + type: str + size: + description: + - Size query parameter. Size in kilobytes(KB). + type: str + systemTag: + description: + - SystemTag query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Tag GetTagCount + description: Complete reference of the GetTagCount API. + link: https://developer.cisco.com/docs/dna-center/#!get-tag-count +notes: + - SDK Method used are + tag.Tag.get_tag_count, + + - Paths used are + get /dna/intent/api/v1/tag/count, + +""" + +EXAMPLES = r""" +- name: Get all Tag Count + cisco.dnac.tag_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + name: string + nameSpace: string + attributeName: string + level: string + size: string + systemTag: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/tag_info.py b/ansible_collections/cisco/dnac/plugins/modules/tag_info.py new file mode 100644 index 000000000..bc09f0ba5 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/tag_info.py @@ -0,0 +1,164 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: tag_info +short_description: Information module for Tag +description: +- Get all Tag. +- Get Tag by id. +- Returns tag specified by Id. +- Returns the tags for given filter criteria. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + name: + description: + - Name query parameter. Tag name is mandatory when filter operation is used. + type: str + additionalInfo_nameSpace: + description: + - AdditionalInfo.nameSpace query parameter. + type: str + additionalInfo_attributes: + description: + - AdditionalInfo.attributes query parameter. + type: str + level: + description: + - Level query parameter. + type: str + offset: + description: + - Offset query parameter. + type: int + limit: + description: + - Limit query parameter. + type: int + size: + description: + - Size query parameter. Size in kilobytes(KB). + type: str + field: + description: + - > + Field query parameter. Available field names are + 'name,id,parentId,type,additionalInfo.nameSpace,additionalInfo.attributes'. + type: str + sortBy: + description: + - SortBy query parameter. Only supported attribute is name. SortyBy is mandatory when order is used. + type: str + order: + description: + - Order query parameter. Available values are asc and des. + type: str + systemTag: + description: + - SystemTag query parameter. + type: str + id: + description: + - Id path parameter. Tag ID. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Tag GetTag + description: Complete reference of the GetTag API. + link: https://developer.cisco.com/docs/dna-center/#!get-tag +- name: Cisco DNA Center documentation for Tag GetTagById + description: Complete reference of the GetTagById API. + link: https://developer.cisco.com/docs/dna-center/#!get-tag-by-id +notes: + - SDK Method used are + tag.Tag.get_tag, + tag.Tag.get_tag_by_id, + + - Paths used are + get /dna/intent/api/v1/tag, + get /dna/intent/api/v1/tag/{id}, + +""" + +EXAMPLES = r""" +- name: Get all Tag + cisco.dnac.tag_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + name: string + additionalInfo_nameSpace: string + additionalInfo_attributes: string + level: string + offset: 0 + limit: 0 + size: string + field: string + sortBy: string + order: string + systemTag: string + register: result + +- name: Get Tag by id + cisco.dnac.tag_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": { + "systemTag": true, + "description": "string", + "dynamicRules": [ + { + "memberType": "string", + "rules": { + "values": [ + "string" + ], + "items": "string", + "operation": "string", + "name": "string", + "value": "string" + } + } + ], + "name": "string", + "id": "string", + "instanceTenantId": "string" + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/tag_member.py b/ansible_collections/cisco/dnac/plugins/modules/tag_member.py new file mode 100644 index 000000000..528caf301 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/tag_member.py @@ -0,0 +1,98 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: tag_member +short_description: Resource module for Tag Member +description: +- Manage operations create and delete of the resource Tag Member. +- Adds members to the tag specified by id. +- Removes Tag member from the tag specified by id. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + id: + description: Id path parameter. Tag ID. + type: str + memberId: + description: MemberId path parameter. TagMember id to be removed from tag. + type: str + object: + description: Object. + type: str + payload: + description: Map of member type and member ids. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Tag AddMembersToTheTag + description: Complete reference of the AddMembersToTheTag API. + link: https://developer.cisco.com/docs/dna-center/#!add-members-to-the-tag +- name: Cisco DNA Center documentation for Tag RemoveTagMember + description: Complete reference of the RemoveTagMember API. + link: https://developer.cisco.com/docs/dna-center/#!remove-tag-member +notes: + - SDK Method used are + tag.Tag.add_members_to_the_tag, + tag.Tag.remove_tag_member, + + - Paths used are + post /dna/intent/api/v1/tag/{id}/member, + delete /dna/intent/api/v1/tag/{id}/member/{memberId}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.tag_member: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + id: string + object: string + payload: + networkinterface: + - string + +- name: Delete by id + cisco.dnac.tag_member: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + id: string + memberId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": { + "taskId": "string", + "url": "string" + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/tag_member_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/tag_member_count_info.py new file mode 100644 index 000000000..13bfd2c4c --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/tag_member_count_info.py @@ -0,0 +1,83 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: tag_member_count_info +short_description: Information module for Tag Member Count +description: +- Get all Tag Member Count. +- Returns the number of members in a given tag. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + id: + description: + - Id path parameter. Tag ID. + type: str + memberType: + description: + - MemberType query parameter. + type: str + memberAssociationType: + description: + - MemberAssociationType query parameter. + type: str + level: + description: + - Level query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Tag GetTagMemberCount + description: Complete reference of the GetTagMemberCount API. + link: https://developer.cisco.com/docs/dna-center/#!get-tag-member-count +notes: + - SDK Method used are + tag.Tag.get_tag_member_count, + + - Paths used are + get /dna/intent/api/v1/tag/{id}/member/count, + +""" + +EXAMPLES = r""" +- name: Get all Tag Member Count + cisco.dnac.tag_member_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + memberType: string + memberAssociationType: string + level: string + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": 0 + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/tag_member_info.py b/ansible_collections/cisco/dnac/plugins/modules/tag_member_info.py new file mode 100644 index 000000000..077114139 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/tag_member_info.py @@ -0,0 +1,103 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: tag_member_info +short_description: Information module for Tag Member +description: +- Get all Tag Member. +- Returns tag members specified by id. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + id: + description: + - Id path parameter. Tag ID. + type: str + memberType: + description: + - > + MemberType query parameter. Entity type of the member. Possible values can be retrieved by using + /tag/member/type API. + type: str + offset: + description: + - Offset query parameter. Used for pagination. It indicates the starting row number out of available member records. + type: str + limit: + description: + - Limit query parameter. Used to Number of maximum members to return in the result. + type: str + memberAssociationType: + description: + - > + MemberAssociationType query parameter. Indicates how the member is associated with the tag. Possible values + and description. 1) DYNAMIC The member is associated to the tag through rules. 2) STATIC – The member is + associated to the tag manually. 3) MIXED – The member is associated manually and also satisfies the rule + defined for the tag. + type: str + level: + description: + - Level query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Tag GetTagMembersById + description: Complete reference of the GetTagMembersById API. + link: https://developer.cisco.com/docs/dna-center/#!get-tag-members-by-id +notes: + - SDK Method used are + tag.Tag.get_tag_members_by_id, + + - Paths used are + get /dna/intent/api/v1/tag/{id}/member, + +""" + +EXAMPLES = r""" +- name: Get all Tag Member + cisco.dnac.tag_member_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + memberType: string + offset: string + limit: string + memberAssociationType: string + level: string + id: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": [ + { + "instanceUuid": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/tag_member_type_info.py b/ansible_collections/cisco/dnac/plugins/modules/tag_member_type_info.py new file mode 100644 index 000000000..4fcb8ca42 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/tag_member_type_info.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: tag_member_type_info +short_description: Information module for Tag Member Type +description: +- Get all Tag Member Type. +- Returns list of supported resource types. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Tag GetTagResourceTypes + description: Complete reference of the GetTagResourceTypes API. + link: https://developer.cisco.com/docs/dna-center/#!get-tag-resource-types +notes: + - SDK Method used are + tag.Tag.get_tag_resource_types, + + - Paths used are + get /dna/intent/api/v1/tag/member/type, + +""" + +EXAMPLES = r""" +- name: Get all Tag Member Type + cisco.dnac.tag_member_type_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": [ + "string" + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/tag_membership.py b/ansible_collections/cisco/dnac/plugins/modules/tag_membership.py new file mode 100644 index 000000000..e7516549e --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/tag_membership.py @@ -0,0 +1,80 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: tag_membership +short_description: Resource module for Tag Membership +description: +- Manage operation update of the resource Tag Membership. +- > + Updates tag membership. As part of the request payload through this API, only the specified members are added / + retained to the given input tags. Possible values of memberType attribute in the request payload can be queried by + using the /tag/member/type API. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + memberToTags: + description: Tag Membership's memberToTags. + elements: dict + suboptions: + key: + description: Tag Membership's key. + elements: str + type: list + type: list + memberType: + description: Tag Membership's memberType. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Tag UpdatesTagMembership + description: Complete reference of the UpdatesTagMembership API. + link: https://developer.cisco.com/docs/dna-center/#!updates-tag-membership +notes: + - SDK Method used are + tag.Tag.updates_tag_membership, + + - Paths used are + put /dna/intent/api/v1/tag/member, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.tag_membership: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + memberToTags: + - key: + - string + memberType: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": { + "taskId": "string", + "url": "string" + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/task_count_info.py b/ansible_collections/cisco/dnac/plugins/modules/task_count_info.py new file mode 100644 index 000000000..bb95a22fc --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/task_count_info.py @@ -0,0 +1,113 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: task_count_info +short_description: Information module for Task Count +description: +- Get all Task Count. +- Returns Task count. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + startTime: + description: + - StartTime query parameter. This is the epoch start time from which tasks need to be fetched. + type: str + endTime: + description: + - EndTime query parameter. This is the epoch end time upto which audit records need to be fetched. + type: str + data: + description: + - Data query parameter. Fetch tasks that contains this data. + type: str + errorCode: + description: + - ErrorCode query parameter. Fetch tasks that have this error code. + type: str + serviceType: + description: + - ServiceType query parameter. Fetch tasks with this service type. + type: str + username: + description: + - Username query parameter. Fetch tasks with this username. + type: str + progress: + description: + - Progress query parameter. Fetch tasks that contains this progress. + type: str + isError: + description: + - IsError query parameter. Fetch tasks ended as success or failure. Valid values true, false. + type: str + failureReason: + description: + - FailureReason query parameter. Fetch tasks that contains this failure reason. + type: str + parentId: + description: + - ParentId query parameter. Fetch tasks that have this parent Id. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Task GetTaskCount + description: Complete reference of the GetTaskCount API. + link: https://developer.cisco.com/docs/dna-center/#!get-task-count +notes: + - SDK Method used are + task.Task.get_task_count, + + - Paths used are + get /dna/intent/api/v1/task/count, + +""" + +EXAMPLES = r""" +- name: Get all Task Count + cisco.dnac.task_count_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + startTime: string + endTime: string + data: string + errorCode: string + serviceType: string + username: string + progress: string + isError: string + failureReason: string + parentId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/task_info.py b/ansible_collections/cisco/dnac/plugins/modules/task_info.py new file mode 100644 index 000000000..9b2b19b01 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/task_info.py @@ -0,0 +1,176 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: task_info +short_description: Information module for Task +description: +- Get all Task. +- Get Task by id. +- Returns a task by specified id. +- Returns tasks based on filter criteria. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + startTime: + description: + - StartTime query parameter. This is the epoch start time from which tasks need to be fetched. + type: str + endTime: + description: + - EndTime query parameter. This is the epoch end time upto which audit records need to be fetched. + type: str + data: + description: + - Data query parameter. Fetch tasks that contains this data. + type: str + errorCode: + description: + - ErrorCode query parameter. Fetch tasks that have this error code. + type: str + serviceType: + description: + - ServiceType query parameter. Fetch tasks with this service type. + type: str + username: + description: + - Username query parameter. Fetch tasks with this username. + type: str + progress: + description: + - Progress query parameter. Fetch tasks that contains this progress. + type: str + isError: + description: + - IsError query parameter. Fetch tasks ended as success or failure. Valid values true, false. + type: str + failureReason: + description: + - FailureReason query parameter. Fetch tasks that contains this failure reason. + type: str + parentId: + description: + - ParentId query parameter. Fetch tasks that have this parent Id. + type: str + offset: + description: + - Offset query parameter. + type: int + limit: + description: + - Limit query parameter. + type: int + sortBy: + description: + - SortBy query parameter. Sort results by this field. + type: str + order: + description: + - Order query parameter. Sort order - asc or dsc. + type: str + taskId: + description: + - TaskId path parameter. UUID of the Task. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Task GetTaskById + description: Complete reference of the GetTaskById API. + link: https://developer.cisco.com/docs/dna-center/#!get-task-by-id +- name: Cisco DNA Center documentation for Task GetTasks + description: Complete reference of the GetTasks API. + link: https://developer.cisco.com/docs/dna-center/#!get-tasks +notes: + - SDK Method used are + task.Task.get_task_by_id, + task.Task.get_tasks, + + - Paths used are + get /dna/intent/api/v1/task, + get /dna/intent/api/v1/task/{taskId}, + +""" + +EXAMPLES = r""" +- name: Get all Task + cisco.dnac.task_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + startTime: string + endTime: string + data: string + errorCode: string + serviceType: string + username: string + progress: string + isError: string + failureReason: string + parentId: string + offset: 0 + limit: 0 + sortBy: string + order: string + register: result + +- name: Get Task by id + cisco.dnac.task_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + taskId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "additionalStatusURL": "string", + "data": "string", + "endTime": 0, + "errorCode": "string", + "errorKey": "string", + "failureReason": "string", + "id": "string", + "instanceTenantId": "string", + "isError": true, + "lastUpdate": 0, + "operationIdList": {}, + "parentId": "string", + "progress": "string", + "rootId": "string", + "serviceType": "string", + "startTime": 0, + "username": "string", + "version": 0 + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/task_operation_info.py b/ansible_collections/cisco/dnac/plugins/modules/task_operation_info.py new file mode 100644 index 000000000..f5578940c --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/task_operation_info.py @@ -0,0 +1,101 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: task_operation_info +short_description: Information module for Task Operation +description: +- Get Task Operation by id. +- Returns root tasks associated with an Operationid. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + operationId: + description: + - OperationId path parameter. + type: str + offset: + description: + - Offset path parameter. Index, minimum value is 0. + type: int + limit: + description: + - > + Limit path parameter. The maximum value of {limit} supported is 500. Base 1 indexing for {limit}, minimum + value is 1. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Task GetTaskByOperationId + description: Complete reference of the GetTaskByOperationId API. + link: https://developer.cisco.com/docs/dna-center/#!get-task-by-operation-id +notes: + - SDK Method used are + task.Task.get_task_by_operationid, + + - Paths used are + get /dna/intent/api/v1/task/operation/{operationId}/{offset}/{limit}, + +""" + +EXAMPLES = r""" +- name: Get Task Operation by id + cisco.dnac.task_operation_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + operationId: string + offset: 0 + limit: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "additionalStatusURL": "string", + "data": "string", + "endTime": "string", + "errorCode": "string", + "errorKey": "string", + "failureReason": "string", + "id": "string", + "instanceTenantId": "string", + "isError": true, + "lastUpdate": "string", + "operationIdList": {}, + "parentId": "string", + "progress": "string", + "rootId": "string", + "serviceType": "string", + "startTime": "string", + "username": "string", + "version": 0 + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/task_tree_info.py b/ansible_collections/cisco/dnac/plugins/modules/task_tree_info.py new file mode 100644 index 000000000..bda7d8c51 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/task_tree_info.py @@ -0,0 +1,89 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: task_tree_info +short_description: Information module for Task Tree +description: +- Get all Task Tree. +- Returns a task with its children tasks by based on their id. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + taskId: + description: + - TaskId path parameter. UUID of the Task. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Task GetTaskTree + description: Complete reference of the GetTaskTree API. + link: https://developer.cisco.com/docs/dna-center/#!get-task-tree +notes: + - SDK Method used are + task.Task.get_task_tree, + + - Paths used are + get /dna/intent/api/v1/task/{taskId}/tree, + +""" + +EXAMPLES = r""" +- name: Get all Task Tree + cisco.dnac.task_tree_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + taskId: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "additionalStatusURL": "string", + "data": "string", + "endTime": "string", + "errorCode": "string", + "errorKey": "string", + "failureReason": "string", + "id": "string", + "instanceTenantId": "string", + "isError": true, + "lastUpdate": "string", + "operationIdList": {}, + "parentId": "string", + "progress": "string", + "rootId": "string", + "serviceType": "string", + "startTime": "string", + "username": "string", + "version": 0 + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/template_intent.py b/ansible_collections/cisco/dnac/plugins/modules/template_intent.py new file mode 100644 index 000000000..8a42f9271 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/template_intent.py @@ -0,0 +1,1061 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2022, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +__author__ = ("Madhan Sankaranarayanan, Rishita Chowdhary") + +DOCUMENTATION = r""" +--- +module: template_intent +short_description: Resource module for Template functions +description: +- Manage operations create, update and delete of the resource Configuration Template. +- API to create a template by project name and template name. +- API to update a template by template name and project name. +- API to delete a template by template name and project name. +version_added: '6.6.0' +extends_documentation_fragment: + - cisco.dnac.intent_params +author: Madhan Sankaranarayanan (@madhansansel) + Rishita Chowdhary (@rishitachowdhary) +options: + state: + description: The state of DNAC after module completion. + type: str + choices: [ merged, deleted ] + default: merged + config: + description: + - List of details of templates being managed. + type: list + elements: dict + required: true + suboptions: + author: + description: Author of template. + type: str + composite: + description: Is it composite template. + type: bool + containingTemplates: + description: Configuration Template Create's containingTemplates. + suboptions: + composite: + description: Is it composite template. + type: bool + description: + description: Description of template. + type: str + deviceTypes: + description: Configuration Template Create's deviceTypes. + type: list + elements: dict + suboptions: + productFamily: + description: Device family. + type: str + productSeries: + description: Device series. + type: str + productType: + description: Device type. + type: str + id: + description: UUID of template. + type: str + language: + description: Template language + choices: + - JINJA + - VELOCITY + type: str + name: + description: Name of template. + type: str + projectName: + description: Project name. + type: str + rollbackTemplateParams: + description: Configuration Template Create's rollbackTemplateParams. + type: list + elements: dict + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template Create's range. + type: list + elements: dict + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + required: + description: Is param required. + type: bool + selection: + description: Configuration Template Create's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + tags: + description: Configuration Template Create's tags. + suboptions: + id: + description: UUID of tag. + type: str + name: + description: Name of tag. + type: str + type: list + elements: dict + templateContent: + description: Template content. + type: str + templateParams: + description: Configuration Template Create's templateParams. + elements: dict + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template Create's range. + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + elements: dict + required: + description: Is param required. + type: bool + selection: + description: Configuration Template Create's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + version: + description: Current version of template. + type: str + type: list + elements: dict + createTime: + description: Create time of template. + type: int + customParamsOrder: + description: Custom Params Order. + type: bool + template_description: + description: Description of template. + type: str + deviceTypes: + description: Configuration Template Create's deviceTypes. + suboptions: + productFamily: + description: Device family. + type: str + productSeries: + description: Device series. + type: str + productType: + description: Device type. + type: str + type: list + elements: dict + failurePolicy: + description: Define failure policy if template provisioning fails. + type: str + language: + description: Template language + choices: + - JINJA + - VELOCITY + type: str + lastUpdateTime: + description: Update time of template. + type: int + latestVersionTime: + description: Latest versioned template time. + type: int + templateName: + description: Name of template. + type: str + parentTemplateId: + description: Parent templateID. + type: str + projectId: + description: Project UUID. + type: str + projectName: + description: Project name. + type: str + rollbackTemplateContent: + description: Rollback template content. + type: str + rollbackTemplateParams: + description: Configuration Template Create's rollbackTemplateParams. + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template Create's range. + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + elements: dict + required: + description: Is param required. + type: bool + selection: + description: Configuration Template Create's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + elements: dict + softwareType: + description: Applicable device software type. + type: str + softwareVariant: + description: Applicable device software variant. + type: str + softwareVersion: + description: Applicable device software version. + type: str + template_tag: + description: Configuration Template Create's tags. + suboptions: + id: + description: UUID of tag. + type: str + name: + description: Name of tag. + type: str + type: list + elements: dict + templateContent: + description: Template content. + type: str + templateParams: + description: Configuration Template Create's templateParams. + suboptions: + binding: + description: Bind to source. + type: str + customOrder: + description: CustomOrder of template param. + type: int + dataType: + description: Datatype of template param. + type: str + defaultValue: + description: Default value of template param. + type: str + description: + description: Description of template param. + type: str + displayName: + description: Display name of param. + type: str + group: + description: Group. + type: str + id: + description: UUID of template param. + type: str + instructionText: + description: Instruction text for param. + type: str + key: + description: Key. + type: str + notParam: + description: Is it not a variable. + type: bool + order: + description: Order of template param. + type: int + paramArray: + description: Is it an array. + type: bool + parameterName: + description: Name of template param. + type: str + provider: + description: Provider. + type: str + range: + description: Configuration Template Create's range. + suboptions: + id: + description: UUID of range. + type: str + maxValue: + description: Max value of range. + type: int + minValue: + description: Min value of range. + type: int + type: list + elements: dict + required: + description: Is param required. + type: bool + selection: + description: Configuration Template Create's selection. + suboptions: + defaultSelectedValues: + description: Default selection values. + elements: str + type: list + id: + description: UUID of selection. + type: str + selectionType: + description: Type of selection(SINGLE_SELECT or MULTI_SELECT). + type: str + selectionValues: + description: Selection values. + type: dict + type: dict + type: list + elements: dict + validationErrors: + description: Configuration Template Create's validationErrors. + suboptions: + rollbackTemplateErrors: + description: Validation or design conflicts errors of rollback template. + elements: dict + type: list + templateErrors: + description: Validation or design conflicts errors. + elements: dict + type: list + templateId: + description: UUID of template. + type: str + templateVersion: + description: Current version of template. + type: str + type: dict + version: + description: Current version of template. + type: str + versionDescription: + description: Template version comments. + type: str +requirements: +- dnacentersdk == 2.4.5 +- python >= 3.5 +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.create_template, + configuration_templates.ConfigurationTemplates.deletes_the_template, + configuration_templates.ConfigurationTemplates.update_template, + + - Paths used are + post /dna/intent/api/v1/template-programmer/project/{projectId}/template, + delete /dna/intent/api/v1/template-programmer/template/{templateId}, + put /dna/intent/api/v1/template-programmer/template, + +""" + +EXAMPLES = r""" +- name: Create a new template + cisco.dnac.template_intent: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + dnac_log: True + state: merged + config: + author: string + composite: true + createTime: 0 + customParamsOrder: true + description: string + deviceTypes: + - productFamily: string + productSeries: string + productType: string + failurePolicy: string + id: string + language: string + lastUpdateTime: 0 + latestVersionTime: 0 + name: string + parentTemplateId: string + projectId: string + projectName: string + rollbackTemplateContent: string + softwareType: string + softwareVariant: string + softwareVersion: string + tags: + - id: string + name: string + templateContent: string + validationErrors: + rollbackTemplateErrors: + - {} + templateErrors: + - {} + templateId: string + templateVersion: string + version: string + +""" + +RETURN = r""" +#Case_1: Successful creation/updation/deletion of template +response_1: + description: A dictionary with versioning details of the template as returned by the DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "endTime": 0, + "version": 0, + "data": String, + "startTime": 0, + "username": String, + "progress": String, + "serviceType": String, "rootId": String, + "isError": bool, + "instanceTenantId": String, + "id": String + "version": 0 + }, + "msg": String + } + +#Case_2: Error while deleting a template or when given project is not found +response_2: + description: A list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + sample: > + { + "response": [], + "msg": String + } + +#Case_3: Given template already exists and requires no udpate +response_3: + description: A dictionary with the exisiting template deatails as returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": {}, + "msg": String + } +""" + +import copy +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DNACSDK, + validate_list_of_dicts, + log, + get_dict_result, + dnac_compare_equality, +) +from ansible.module_utils.basic import AnsibleModule + + +class DnacTemplate: + + def __init__(self, module): + self.module = module + self.params = module.params + self.config = copy.deepcopy(module.params.get("config")) + self.have_create = {} + self.want_create = {} + self.validated = [] + dnac_params = self.get_dnac_params(self.params) + log(str(dnac_params)) + self.dnac = DNACSDK(params=dnac_params) + self.log = dnac_params.get("dnac_log") + + self.result = dict(changed=False, diff=[], response=[], warnings=[]) + + def get_state(self): + return self.params.get("state") + + def validate_input(self): + temp_spec = 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", elements='dict'), + 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(required=True, 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"), + templateName=dict(required=True, type='str'), + validationErrors=dict(type="dict"), + version=dict(type="str"), + versionDescription=dict(type='str'), + ) + + if self.config: + msg = None + # Validate template params + valid_temp, invalid_params = validate_list_of_dicts( + self.config, temp_spec + ) + + if invalid_params: + msg = "Invalid parameters in playbook: {0}".format( + "\n".join(invalid_params) + ) + self.module.fail_json(msg=msg) + + self.validated = valid_temp + + if self.log: + log(str(valid_temp)) + log(str(self.validated)) + + if self.params.get("state") == "merged": + for temp in self.validated: + if not temp.get("language") or not temp.get("deviceTypes") \ + or not temp.get("softwareType"): + msg = "missing required arguments: language or deviceTypes or softwareType" + self.module.fail_json(msg=msg) + if not (temp.get("language").lower() == "velocity" or + temp.get("language").lower() == "jinja"): + msg = "Invalid parameters in playbook: {0} : Invalid choice provided".format( + "".join(temp.get("language"))) + self.module.fail_json(msg=msg) + + def get_dnac_params(self, params): + dnac_params = dict( + dnac_host=params.get("dnac_host"), + dnac_port=params.get("dnac_port"), + dnac_username=params.get("dnac_username"), + dnac_password=params.get("dnac_password"), + dnac_verify=params.get("dnac_verify"), + dnac_debug=params.get("dnac_debug"), + dnac_log=params.get("dnac_log") + ) + return dnac_params + + def get_template_params(self, params): + temp_params = dict( + tags=params.get("template_tag"), + author=params.get("author"), + composite=params.get("composite"), + containingTemplates=params.get("containingTemplates"), + createTime=params.get("createTime"), + customParamsOrder=params.get("customParamsOrder"), + description=params.get("template_description"), + deviceTypes=params.get("deviceTypes"), + failurePolicy=params.get("failurePolicy"), + id=params.get("templateId"), + language=params.get("language").upper(), + lastUpdateTime=params.get("lastUpdateTime"), + latestVersionTime=params.get("latestVersionTime"), + name=params.get("templateName"), + 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 temp_params + + def get_template(self): + result = None + + for temp in self.validated: + items = self.dnac._exec( + family="configuration_templates", + function="get_template_details", + params={"template_id": temp.get("templateId")} + ) + + if items: + result = items + + if self.log: + log(str(items)) + + self.result['response'] = items + return result + + def get_have(self): + prev_template = None + template_exists = False + have_create = {} + + # Get available templates. Filter templates based on provided projectName + for temp in self.validated: + template_list = self.dnac._exec( + family="configuration_templates", + function='gets_the_templates_available', + params={"project_names": temp.get("projectName")}, + ) + # API execution error returns a dict + if template_list and isinstance(template_list, list): + template_details = get_dict_result(template_list, 'name', temp.get("templateName")) + + if template_details: + temp["templateId"] = template_details.get("templateId") + have_create["templateId"] = template_details.get("templateId") + prev_template = self.get_template() + + if self.log: + log(str(prev_template)) + + template_exists = prev_template is not None and isinstance(prev_template, dict) + else: + self.module.fail_json(msg="Project Not Found", response=[]) + + have_create['template'] = prev_template + have_create['template_found'] = template_exists + self.have_create = have_create + + def get_want(self): + want_create = {} + + for temp in self.validated: + template_params = self.get_template_params(temp) + version_comments = temp.get("versionDescription") + + if self.params.get("state") == "merged" and \ + not self.have_create.get("template_found"): + # ProjectId is required for creating a new template. + # Store it with other template parameters. + items = self.dnac._exec( + family="configuration_templates", + function='get_projects', + params={"name": temp.get("projectName")}, + ) + template_params["projectId"] = items[0].get("id") + template_params["project_id"] = items[0].get("id") + + want_create["template_params"] = template_params + want_create["comments"] = version_comments + + self.want_create = want_create + + def requires_update(self): + current_obj = self.have_create.get("template") + requested_obj = self.want_create.get("template_params") + obj_params = [ + ("tags", "tags", ""), + ("author", "author", ""), + ("composite", "composite", False), + ("containingTemplates", "containingTemplates", []), + ("createTime", "createTime", ""), + ("customParamsOrder", "customParamsOrder", False), + ("description", "description", ""), + ("deviceTypes", "deviceTypes", []), + ("failurePolicy", "failurePolicy", ""), + ("id", "id", ""), + ("language", "language", "VELOCITY"), + ("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", ""), + ] + + return any(not dnac_compare_equality(current_obj.get(dnac_param, default), + requested_obj.get(ansible_param)) + for (dnac_param, ansible_param, default) in obj_params) + + def get_task_details(self, id): + result = None + response = self.dnac._exec( + family="task", + function='get_task_by_id', + params={"task_id": id}, + ) + + if self.log: + log(str(response)) + + if isinstance(response, dict): + result = response.get("response") + + return result + + def get_diff_merge(self): + template_id = None + template_ceated = False + template_updated = False + template_exists = self.have_create.get("template_found") + + if template_exists: + if self.requires_update(): + response = self.dnac._exec( + family="configuration_templates", + function="update_template", + params=self.want_create.get("template_params"), + op_modifies=True, + ) + template_updated = True + template_id = self.have_create.get("templateId") + + if self.log: + log("Updating Existing Template") + else: + # Template does not need update + self.result['response'] = self.have_create.get("template") + self.result['msg'] = "Template does not need update" + self.module.exit_json(**self.result) + else: + response = self.dnac._exec( + family="configuration_templates", + function='create_template', + op_modifies=True, + params=self.want_create.get("template_params"), + ) + + if self.log: + log("Template created. Get template_id for versioning") + if isinstance(response, dict): + create_error = False + task_details = {} + task_id = response.get("response").get("taskId") + + if task_id: + while (True): + task_details = self.get_task_details(task_id) + if task_details and task_details.get("isError"): + create_error = True + break + + if task_details and ("Successfully created template" in task_details.get("progress")): + break + if not create_error: + template_id = task_details.get("data") + if template_id: + template_created = True + + if template_updated or template_created: + # Template needs to be versioned + version_params = dict( + comments=self.want_create.get("comments"), + templateId=template_id + ) + response = self.dnac._exec( + family="configuration_templates", + function='version_template', + op_modifies=True, + params=version_params + ) + task_details = {} + task_id = response.get("response").get("taskId") + + if task_id: + task_details = self.get_task_details(task_id) + self.result['changed'] = True + self.result['msg'] = task_details.get('progress') + self.result['diff'] = self.validated + if self.log: + log(str(task_details)) + self.result['response'] = task_details if task_details else response + + if not self.result.get('msg'): + self.result['msg'] = "Error while versioning the template" + + def get_diff_delete(self): + template_exists = self.have_create.get("template_found") + + if template_exists: + response = self.dnac._exec( + family="configuration_templates", + function="deletes_the_template", + params={"template_id": self.have_create.get("templateId")}, + ) + task_details = {} + task_id = response.get("response").get("taskId") + + if task_id: + task_details = self.get_task_details(task_id) + self.result['changed'] = True + self.result['msg'] = task_details.get('progress') + self.result['diff'] = self.validated + + if self.log: + log(str(task_details)) + + self.result['response'] = task_details if task_details else response + + if not self.result['msg']: + self.result['msg'] = "Error while deleting template" + else: + self.module.fail_json(msg="Template not found", response=[]) + + +def main(): + """ main entry point for module execution + """ + + element_spec = dict( + dnac_host=dict(required=True, type='str'), + dnac_port=dict(type='str', default='443'), + dnac_username=dict(type='str', default='admin', aliases=["user"]), + dnac_password=dict(type='str', no_log=True), + dnac_verify=dict(type='bool', default='True'), + dnac_version=dict(type="str", default="2.2.3.3"), + dnac_debug=dict(type='bool', default=False), + dnac_log=dict(type='bool', default=False), + validate_response_schema=dict(type="bool", default=True), + config=dict(required=True, type='list', elements='dict'), + state=dict( + default='merged', + choices=['merged', 'deleted']), + ) + module = AnsibleModule(argument_spec=element_spec, + supports_check_mode=False) + dnac_template = DnacTemplate(module) + dnac_template.validate_input() + state = dnac_template.get_state() + dnac_template.get_have() + dnac_template.get_want() + + if state == "merged": + dnac_template.get_diff_merge() + + elif state == "deleted": + dnac_template.get_diff_delete() + + module.exit_json(**dnac_template.result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/cisco/dnac/plugins/modules/template_preview.py b/ansible_collections/cisco/dnac/plugins/modules/template_preview.py new file mode 100644 index 000000000..bcd466a54 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/template_preview.py @@ -0,0 +1,76 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: template_preview +short_description: Resource module for Template Preview +description: +- Manage operation update of the resource Template Preview. +- API to preview a template. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + deviceId: + description: UUID of device to get template preview. + type: str + params: + description: Params to render preview. + type: dict + resourceParams: + description: Resource params to render preview. + type: dict + templateId: + description: UUID of template to get template preview. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Templates PreviewTemplate + description: Complete reference of the PreviewTemplate API. + link: https://developer.cisco.com/docs/dna-center/#!preview-template +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.preview_template, + + - Paths used are + put /dna/intent/api/v1/template-programmer/template/preview, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.template_preview: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + deviceId: string + params: {} + resourceParams: {} + templateId: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "cliPreview": "string", + "deviceId": "string", + "templateId": "string", + "validationErrors": {} + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/templates_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/templates_details_info.py new file mode 100644 index 000000000..d8d2b0704 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/templates_details_info.py @@ -0,0 +1,362 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: templates_details_info +short_description: Information module for Templates Details +description: +- Get all Templates Details. +- Get templates details. +version_added: '4.0.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + id: + description: + - Id query parameter. Id of template to be searched. + type: str + name: + description: + - Name query parameter. Name of template to be searched. + type: str + projectId: + description: + - ProjectId query parameter. Filter template(s) based on project id. + type: str + projectName: + description: + - ProjectName query parameter. Filter template(s) based on project name. + type: str + softwareType: + description: + - SoftwareType query parameter. Filter template(s) based software type. + type: str + softwareVersion: + description: + - SoftwareVersion query parameter. Filter template(s) based softwareVersion. + type: str + productFamily: + description: + - ProductFamily query parameter. Filter template(s) based on device family. + type: str + productSeries: + description: + - ProductSeries query parameter. Filter template(s) based on device series. + type: str + productType: + description: + - ProductType query parameter. Filter template(s) based on device type. + type: str + filterConflictingTemplates: + description: + - FilterConflictingTemplates query parameter. Filter template(s) based on confliting templates. + type: bool + tags: + description: + - Tags query parameter. Filter template(s) based on tags. + elements: str + type: list + unCommitted: + description: + - UnCommitted query parameter. Return uncommitted template. + type: bool + sortOrder: + description: + - SortOrder query parameter. Sort Order Ascending (asc) or Descending (dsc). + type: str + allTemplateAttributes: + description: + - AllTemplateAttributes query parameter. Return all template attributes. + type: bool + includeVersionDetails: + description: + - IncludeVersionDetails query parameter. Include template version details. + type: bool + offset: + description: + - Offset query parameter. Index of first result. + type: int + limit: + description: + - Limit query parameter. Limits number of results. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Configuration Templates GetTemplatesDetails + description: Complete reference of the GetTemplatesDetails API. + link: https://developer.cisco.com/docs/dna-center/#!get-template-s-details +notes: + - SDK Method used are + configuration_templates.ConfigurationTemplates.get_templates_details, + + - Paths used are + get /dna/intent/api/v2/template-programmer/template, + +""" + +EXAMPLES = r""" +- name: Get all Templates Details + cisco.dnac.templates_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + id: string + name: string + projectId: string + projectName: string + softwareType: string + softwareVersion: string + productFamily: string + productSeries: string + productType: string + filterConflictingTemplates: True + tags: [] + unCommitted: True + sortOrder: string + allTemplateAttributes: True + includeVersionDetails: True + offset: 0 + limit: 0 + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "author": "string", + "composite": true, + "containingTemplates": [ + { + "composite": true, + "description": "string", + "deviceTypes": [ + { + "productFamily": "string", + "productSeries": "string", + "productType": "string" + } + ], + "id": "string", + "language": "string", + "name": "string", + "projectName": "string", + "rollbackTemplateParams": [ + { + "binding": "string", + "customOrder": 0, + "dataType": "string", + "defaultValue": "string", + "description": "string", + "displayName": "string", + "group": "string", + "id": "string", + "instructionText": "string", + "key": "string", + "notParam": true, + "order": 0, + "paramArray": true, + "parameterName": "string", + "provider": "string", + "range": [ + { + "id": "string", + "maxValue": 0, + "minValue": 0 + } + ], + "required": true, + "selection": { + "defaultSelectedValues": [ + "string" + ], + "id": "string", + "selectionType": "string", + "selectionValues": {} + } + } + ], + "tags": [ + { + "id": "string", + "name": "string" + } + ], + "templateContent": "string", + "templateParams": [ + { + "binding": "string", + "customOrder": 0, + "dataType": "string", + "defaultValue": "string", + "description": "string", + "displayName": "string", + "group": "string", + "id": "string", + "instructionText": "string", + "key": "string", + "notParam": true, + "order": 0, + "paramArray": true, + "parameterName": "string", + "provider": "string", + "range": [ + { + "id": "string", + "maxValue": 0, + "minValue": 0 + } + ], + "required": true, + "selection": { + "defaultSelectedValues": [ + "string" + ], + "id": "string", + "selectionType": "string", + "selectionValues": {} + } + } + ], + "version": "string" + } + ], + "createTime": 0, + "customParamsOrder": true, + "description": "string", + "deviceTypes": [ + { + "productFamily": "string", + "productSeries": "string", + "productType": "string" + } + ], + "failurePolicy": "string", + "id": "string", + "language": "string", + "lastUpdateTime": 0, + "latestVersionTime": 0, + "name": "string", + "parentTemplateId": "string", + "projectAssociated": true, + "projectId": "string", + "projectName": "string", + "rollbackTemplateContent": "string", + "rollbackTemplateParams": [ + { + "binding": "string", + "customOrder": 0, + "dataType": "string", + "defaultValue": "string", + "description": "string", + "displayName": "string", + "group": "string", + "id": "string", + "instructionText": "string", + "key": "string", + "notParam": true, + "order": 0, + "paramArray": true, + "parameterName": "string", + "provider": "string", + "range": [ + { + "id": "string", + "maxValue": 0, + "minValue": 0 + } + ], + "required": true, + "selection": { + "defaultSelectedValues": [ + "string" + ], + "id": "string", + "selectionType": "string", + "selectionValues": {} + } + } + ], + "softwareType": "string", + "softwareVariant": "string", + "softwareVersion": "string", + "tags": [ + { + "id": "string", + "name": "string" + } + ], + "templateContent": "string", + "templateParams": [ + { + "binding": "string", + "customOrder": 0, + "dataType": "string", + "defaultValue": "string", + "description": "string", + "displayName": "string", + "group": "string", + "id": "string", + "instructionText": "string", + "key": "string", + "notParam": true, + "order": 0, + "paramArray": true, + "parameterName": "string", + "provider": "string", + "range": [ + { + "id": "string", + "maxValue": 0, + "minValue": 0 + } + ], + "required": true, + "selection": { + "defaultSelectedValues": [ + "string" + ], + "id": "string", + "selectionType": "string", + "selectionValues": {} + } + } + ], + "validationErrors": { + "rollbackTemplateErrors": {}, + "templateErrors": {}, + "templateId": "string", + "templateVersion": "string" + }, + "version": "string", + "versionsInfo": [ + { + "author": "string", + "description": "string", + "id": "string", + "version": "string", + "versionComment": "string", + "versionTime": 0 + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/threat_detail.py b/ansible_collections/cisco/dnac/plugins/modules/threat_detail.py new file mode 100644 index 000000000..685b60b15 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/threat_detail.py @@ -0,0 +1,104 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: threat_detail +short_description: Resource module for Threat Detail +description: +- Manage operation create of the resource Threat Detail. +- The details for the Rogue and aWIPS threats. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + endTime: + description: End Time. + type: int + isNewThreat: + description: Is New Threat. + type: bool + limit: + description: Limit. + type: int + offset: + description: Offset. + type: int + siteId: + description: Site Id. + elements: str + type: list + startTime: + description: Start Time. + type: int + threatLevel: + description: Threat Level. + elements: str + type: list + threatType: + description: Threat Type. + elements: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +notes: + - SDK Method used are + devices.Devices.threat_details, + + - Paths used are + post /dna/intent/api/v1/security/threats/details, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.threat_detail: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + endTime: 0 + isNewThreat: true + limit: 0 + offset: 0 + siteId: + - string + startTime: 0 + threatLevel: + - string + threatType: + - string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "macAddress": "string", + "updatedTime": 0, + "vendor": "string", + "threatType": "string", + "threatLevel": "string", + "apName": "string", + "ssid": "string", + "siteNameHierarchy": "string" + } + ], + "totalCount": 0, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/threat_detail_count.py b/ansible_collections/cisco/dnac/plugins/modules/threat_detail_count.py new file mode 100644 index 000000000..fab706a16 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/threat_detail_count.py @@ -0,0 +1,92 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: threat_detail_count +short_description: Resource module for Threat Detail Count +description: +- Manage operation create of the resource Threat Detail Count. +- The details count for the Rogue and aWIPS threats. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + endTime: + description: End Time. + type: int + isNewThreat: + description: Is New Threat. + type: bool + limit: + description: Limit. + type: int + offset: + description: Offset. + type: int + siteId: + description: Site Id. + elements: str + type: list + startTime: + description: Start Time. + type: int + threatLevel: + description: Threat Level. + elements: str + type: list + threatType: + description: Threat Type. + elements: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +notes: + - SDK Method used are + devices.Devices.threat_detail_count, + + - Paths used are + post /dna/intent/api/v1/security/threats/details/count, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.threat_detail_count: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + endTime: 0 + isNewThreat: true + limit: 0 + offset: 0 + siteId: + - string + startTime: 0 + threatLevel: + - string + threatType: + - string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": 0, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/threat_summary.py b/ansible_collections/cisco/dnac/plugins/modules/threat_summary.py new file mode 100644 index 000000000..e3f3742bb --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/threat_summary.py @@ -0,0 +1,91 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: threat_summary +short_description: Resource module for Threat Summary +description: +- Manage operation create of the resource Threat Summary. +- The Threat Summary for the Rogues and aWIPS. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + endTime: + description: End Time. + type: int + siteId: + description: Site Id. + elements: str + type: list + startTime: + description: Start Time. + type: int + threatLevel: + description: Threat Level. + elements: str + type: list + threatType: + description: Threat Type. + elements: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +notes: + - SDK Method used are + devices.Devices.threat_summary, + + - Paths used are + post /dna/intent/api/v1/security/threats/summary, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.threat_summary: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + endTime: 0 + siteId: + - string + startTime: 0 + threatLevel: + - string + threatType: + - string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + { + "timestamp": 0, + "threatData": [ + { + "threatType": "string", + "threatLevel": "string", + "threatCount": 0 + } + ] + } + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/topology_layer_2_info.py b/ansible_collections/cisco/dnac/plugins/modules/topology_layer_2_info.py new file mode 100644 index 000000000..2d9324000 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/topology_layer_2_info.py @@ -0,0 +1,128 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: topology_layer_2_info +short_description: Information module for Topology Layer 2 +description: +- Get Topology Layer 2 by id. +- Returns Layer 2 network topology by specified VLAN ID. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + vlanID: + description: + - VlanID path parameter. Vlan Name for e.g Vlan1, Vlan23 etc. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Topology GetTopologyDetails + description: Complete reference of the GetTopologyDetails API. + link: https://developer.cisco.com/docs/dna-center/#!get-topology-details +notes: + - SDK Method used are + topology.Topology.get_topology_details, + + - Paths used are + get /dna/intent/api/v1/topology/l2/{vlanID}, + +""" + +EXAMPLES = r""" +- name: Get Topology Layer 2 by id + cisco.dnac.topology_layer_2_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + vlanID: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "id": "string", + "links": [ + { + "additionalInfo": {}, + "endPortID": "string", + "endPortIpv4Address": "string", + "endPortIpv4Mask": "string", + "endPortName": "string", + "endPortSpeed": "string", + "greyOut": true, + "id": "string", + "linkStatus": "string", + "source": "string", + "startPortID": "string", + "startPortIpv4Address": "string", + "startPortIpv4Mask": "string", + "startPortName": "string", + "startPortSpeed": "string", + "tag": "string", + "target": "string" + } + ], + "nodes": [ + { + "aclApplied": true, + "additionalInfo": {}, + "customParam": { + "id": "string", + "label": "string", + "parentNodeId": "string", + "x": 0, + "y": 0 + }, + "dataPathId": "string", + "deviceType": "string", + "family": "string", + "fixed": true, + "greyOut": true, + "id": "string", + "ip": "string", + "label": "string", + "networkType": "string", + "nodeType": "string", + "order": 0, + "osType": "string", + "platformId": "string", + "role": "string", + "roleSource": "string", + "softwareVersion": "string", + "tags": [ + "string" + ], + "upperNode": "string", + "userId": "string", + "vlanId": "string", + "x": 0, + "y": 0 + } + ] + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/topology_layer_3_info.py b/ansible_collections/cisco/dnac/plugins/modules/topology_layer_3_info.py new file mode 100644 index 000000000..fc09e3f56 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/topology_layer_3_info.py @@ -0,0 +1,128 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: topology_layer_3_info +short_description: Information module for Topology Layer 3 +description: +- Get Topology Layer 3 by id. +- Returns the Layer 3 network topology by routing protocol. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + topologyType: + description: + - TopologyType path parameter. Type of topology(OSPF,ISIS,etc). + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Topology GetL3TopologyDetails + description: Complete reference of the GetL3TopologyDetails API. + link: https://developer.cisco.com/docs/dna-center/#!get-l-3-topology-details +notes: + - SDK Method used are + topology.Topology.get_l3_topology_details, + + - Paths used are + get /dna/intent/api/v1/topology/l3/{topologyType}, + +""" + +EXAMPLES = r""" +- name: Get Topology Layer 3 by id + cisco.dnac.topology_layer_3_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + topologyType: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "id": "string", + "links": [ + { + "additionalInfo": {}, + "endPortID": "string", + "endPortIpv4Address": "string", + "endPortIpv4Mask": "string", + "endPortName": "string", + "endPortSpeed": "string", + "greyOut": true, + "id": "string", + "linkStatus": "string", + "source": "string", + "startPortID": "string", + "startPortIpv4Address": "string", + "startPortIpv4Mask": "string", + "startPortName": "string", + "startPortSpeed": "string", + "tag": "string", + "target": "string" + } + ], + "nodes": [ + { + "aclApplied": true, + "additionalInfo": {}, + "customParam": { + "id": "string", + "label": "string", + "parentNodeId": "string", + "x": 0, + "y": 0 + }, + "dataPathId": "string", + "deviceType": "string", + "family": "string", + "fixed": true, + "greyOut": true, + "id": "string", + "ip": "string", + "label": "string", + "networkType": "string", + "nodeType": "string", + "order": 0, + "osType": "string", + "platformId": "string", + "role": "string", + "roleSource": "string", + "softwareVersion": "string", + "tags": [ + "string" + ], + "upperNode": "string", + "userId": "string", + "vlanId": "string", + "x": 0, + "y": 0 + } + ] + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/topology_network_health_info.py b/ansible_collections/cisco/dnac/plugins/modules/topology_network_health_info.py new file mode 100644 index 000000000..907a87c5f --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/topology_network_health_info.py @@ -0,0 +1,107 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: topology_network_health_info +short_description: Information module for Topology Network Health +description: +- Get all Topology Network Health. +- > + Returns Overall Network Health information by Device category Access, Distribution, Core, Router, Wireless for any + given point of time. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + timestamp: + description: + - Timestamp query parameter. Epoch time(in milliseconds) when the Network health data is required. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Topology GetOverallNetworkHealth + description: Complete reference of the GetOverallNetworkHealth API. + link: https://developer.cisco.com/docs/dna-center/#!get-overall-network-health +notes: + - SDK Method used are + topology.Topology.get_overall_network_health, + + - Paths used are + get /dna/intent/api/v1/network-health, + +""" + +EXAMPLES = r""" +- name: Get all Topology Network Health + cisco.dnac.topology_network_health_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + timestamp: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "version": "string", + "response": [ + { + "time": "string", + "healthScore": 0, + "totalCount": 0, + "goodCount": 0, + "unmonCount": 0, + "fairCount": 0, + "badCount": 0, + "entity": {}, + "timeinMillis": 0 + } + ], + "measuredBy": "string", + "latestMeasuredByEntity": {}, + "latestHealthScore": 0, + "monitoredDevices": 0, + "monitoredHealthyDevices": 0, + "monitoredUnHealthyDevices": 0, + "unMonitoredDevices": 0, + "healthDistirubution": [ + { + "category": "string", + "totalCount": 0, + "healthScore": 0, + "goodPercentage": 0, + "badPercentage": 0, + "fairPercentage": 0, + "unmonPercentage": 0, + "goodCount": 0, + "badCount": 0, + "fairCount": 0, + "unmonCount": 0, + "kpiMetrics": [ + {} + ] + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/topology_physical_info.py b/ansible_collections/cisco/dnac/plugins/modules/topology_physical_info.py new file mode 100644 index 000000000..89afc87f2 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/topology_physical_info.py @@ -0,0 +1,128 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: topology_physical_info +short_description: Information module for Topology Physical +description: +- Get all Topology Physical. +- Returns the raw physical topology by specified criteria of nodeType. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + nodeType: + description: + - NodeType query parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Topology GetPhysicalTopology + description: Complete reference of the GetPhysicalTopology API. + link: https://developer.cisco.com/docs/dna-center/#!get-physical-topology +notes: + - SDK Method used are + topology.Topology.get_physical_topology, + + - Paths used are + get /dna/intent/api/v1/topology/physical-topology, + +""" + +EXAMPLES = r""" +- name: Get all Topology Physical + cisco.dnac.topology_physical_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + nodeType: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "id": "string", + "links": [ + { + "additionalInfo": {}, + "endPortID": "string", + "endPortIpv4Address": "string", + "endPortIpv4Mask": "string", + "endPortName": "string", + "endPortSpeed": "string", + "greyOut": true, + "id": "string", + "linkStatus": "string", + "source": "string", + "startPortID": "string", + "startPortIpv4Address": "string", + "startPortIpv4Mask": "string", + "startPortName": "string", + "startPortSpeed": "string", + "tag": "string", + "target": "string" + } + ], + "nodes": [ + { + "aclApplied": true, + "additionalInfo": {}, + "customParam": { + "id": "string", + "label": "string", + "parentNodeId": "string", + "x": 0, + "y": 0 + }, + "dataPathId": "string", + "deviceType": "string", + "family": "string", + "fixed": true, + "greyOut": true, + "id": "string", + "ip": "string", + "label": "string", + "networkType": "string", + "nodeType": "string", + "order": 0, + "osType": "string", + "platformId": "string", + "role": "string", + "roleSource": "string", + "softwareVersion": "string", + "tags": [ + "string" + ], + "upperNode": "string", + "userId": "string", + "vlanId": "string", + "x": 0, + "y": 0 + } + ] + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/topology_site_info.py b/ansible_collections/cisco/dnac/plugins/modules/topology_site_info.py new file mode 100644 index 000000000..034c84c96 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/topology_site_info.py @@ -0,0 +1,78 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: topology_site_info +short_description: Information module for Topology Site +description: +- Get all Topology Site. +- Returns site topology. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Topology GetSiteTopology + description: Complete reference of the GetSiteTopology API. + link: https://developer.cisco.com/docs/dna-center/#!get-site-topology +notes: + - SDK Method used are + topology.Topology.get_site_topology, + + - Paths used are + get /dna/intent/api/v1/topology/site-topology, + +""" + +EXAMPLES = r""" +- name: Get all Topology Site + cisco.dnac.topology_site_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "sites": [ + { + "displayName": "string", + "groupNameHierarchy": "string", + "id": "string", + "latitude": "string", + "locationAddress": "string", + "locationCountry": "string", + "locationType": "string", + "longitude": "string", + "name": "string", + "parentId": "string" + } + ] + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/topology_vlan_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/topology_vlan_details_info.py new file mode 100644 index 000000000..c8585d26a --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/topology_vlan_details_info.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: topology_vlan_details_info +short_description: Information module for Topology Vlan Details +description: +- Get all Topology Vlan Details. +- Returns the list of VLAN names. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Topology GetVLANDetails + description: Complete reference of the GetVLANDetails API. + link: https://developer.cisco.com/docs/dna-center/#!get-vlan-details +notes: + - SDK Method used are + topology.Topology.get_vlan_details, + + - Paths used are + get /dna/intent/api/v1/topology/vlan/vlan-names, + +""" + +EXAMPLES = r""" +- name: Get all Topology Vlan Details + cisco.dnac.topology_vlan_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": [ + "string" + ], + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/transit_peer_network.py b/ansible_collections/cisco/dnac/plugins/modules/transit_peer_network.py new file mode 100644 index 000000000..29c9889c1 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/transit_peer_network.py @@ -0,0 +1,121 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: transit_peer_network +short_description: Resource module for Transit Peer Network +description: +- Manage operations create and delete of the resource Transit Peer Network. +- Add Transit Peer Network in SD-Access. +- Delete Transit Peer Network from SD-Access. +version_added: '6.5.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + ipTransitSettings: + description: Transit Peer Network's ipTransitSettings. + suboptions: + autonomousSystemNumber: + description: Autonomous System Number (e.g.,1-65535). + type: str + routingProtocolName: + description: Routing Protocol Name. + type: str + type: dict + sdaTransitSettings: + description: Transit Peer Network's sdaTransitSettings. + suboptions: + transitControlPlaneSettings: + description: Transit Peer Network's transitControlPlaneSettings. + elements: dict + suboptions: + deviceManagementIpAddress: + description: Device Management Ip Address of provisioned device. + type: str + siteNameHierarchy: + description: Site Name Hierarchy where device is provisioned. + type: str + type: list + type: dict + transitPeerNetworkName: + description: TransitPeerNetworkName query parameter. Transit Peer Network Name. + type: str + transitPeerNetworkType: + description: Transit Peer Network Type. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for AddTransitPeerNetwork + description: Complete reference of the AddTransitPeerNetwork API. + link: https://developer.cisco.com/docs/dna-center/#!add-transit-peer-network +- name: Cisco DNA Center documentation for DeleteTransitPeerNetwork + description: Complete reference of the DeleteTransitPeerNetwork API. + link: https://developer.cisco.com/docs/dna-center/#!delete-transit-peer-network +notes: + - SDK Method used are + ..add_transit_peer_network, + ..delete_transit_peer_network, + + - Paths used are + post /dna/intent/api/v1/business/sda/transit-peer-network, + delete /dna/intent/api/v1/business/sda/transit-peer-network, + +""" + +EXAMPLES = r""" +- name: Delete all + cisco.dnac.transit_peer_network: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + transitPeerNetworkName: string + +- name: Create + cisco.dnac.transit_peer_network: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + ipTransitSettings: + autonomousSystemNumber: string + routingProtocolName: string + sdaTransitSettings: + transitControlPlaneSettings: + - deviceManagementIpAddress: string + siteNameHierarchy: string + transitPeerNetworkName: string + transitPeerNetworkType: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "status": "string", + "description": "string", + "taskId": "string", + "taskStatusUrl": "string", + "executionStatusUrl": "string", + "executionId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/transit_peer_network_info.py b/ansible_collections/cisco/dnac/plugins/modules/transit_peer_network_info.py new file mode 100644 index 000000000..ef9ecac22 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/transit_peer_network_info.py @@ -0,0 +1,82 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: transit_peer_network_info +short_description: Information module for Transit Peer Network +description: +- Get all Transit Peer Network. +- Get Transit Peer Network Info from SD-Access. +version_added: '6.5.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + transitPeerNetworkName: + description: + - TransitPeerNetworkName query parameter. Transit or Peer Network Name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for GetTransitPeerNetworkInfo + description: Complete reference of the GetTransitPeerNetworkInfo API. + link: https://developer.cisco.com/docs/dna-center/#!get-transit-peer-network-info +notes: + - SDK Method used are + ..get_transit_peer_network_info, + + - Paths used are + get /dna/intent/api/v1/business/sda/transit-peer-network, + +""" + +EXAMPLES = r""" +- name: Get all Transit Peer Network + cisco.dnac.transit_peer_network_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + transitPeerNetworkName: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "transitPeerNetworkName": "string", + "transitPeerNetworkType": "string", + "ipTransitSettings": { + "routingProtocolName": "string", + "autonomousSystemNumber": "string" + }, + "sdaTransitSettings": { + "transitControlPlaneSettings": [ + { + "siteNameHierarchy": "string", + "deviceManagementIpAddress": "string" + } + ] + }, + "status": "string", + "description": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/user.py b/ansible_collections/cisco/dnac/plugins/modules/user.py new file mode 100644 index 000000000..5bfdc9ced --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/user.py @@ -0,0 +1,112 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: user +short_description: Resource module for User +description: +- Manage operations create and update of the resource User. +- Add a new user for Cisco DNA Center system. +- Update a user for Cisco DNA Center system. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + email: + description: Email. + type: str + firstName: + description: First Name. + type: str + lastName: + description: Last Name. + type: str + password: + description: Password. + type: str + roleList: + description: Role id list. + elements: str + type: list + userId: + description: User Id. + type: str + username: + description: Username. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for User and Roles AddUserAPI + description: Complete reference of the AddUserAPI API. + link: https://developer.cisco.com/docs/dna-center/#!add-user-api +- name: Cisco DNA Center documentation for User and Roles UpdateUserAPI + description: Complete reference of the UpdateUserAPI API. + link: https://developer.cisco.com/docs/dna-center/#!update-user-api +notes: + - SDK Method used are + userand_roles.UserandRoles.add_user_ap_i, + userand_roles.UserandRoles.update_user_ap_i, + + - Paths used are + post /dna/system/api/v1/user, + put /dna/system/api/v1/user, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.user: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + email: string + firstName: string + lastName: string + password: string + roleList: + - string + username: string + +- name: Update all + cisco.dnac.user: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + email: string + firstName: string + lastName: string + roleList: + - string + userId: string + username: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "message": "string", + "userId": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/user_enrichment_details_info.py b/ansible_collections/cisco/dnac/plugins/modules/user_enrichment_details_info.py new file mode 100644 index 000000000..246dd7a83 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/user_enrichment_details_info.py @@ -0,0 +1,174 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: user_enrichment_details_info +short_description: Information module for User Enrichment Details +description: +- Get all User Enrichment Details. +- > + Enriches a given network End User context a network user-id or end user's device Mac Address with details about + the user and devices that the user is connected to. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Users GetUserEnrichmentDetails + description: Complete reference of the GetUserEnrichmentDetails API. + link: https://developer.cisco.com/docs/dna-center/#!get-user-enrichment-details +notes: + - SDK Method used are + users.Users.get_user_enrichment_details, + + - Paths used are + get /dna/intent/api/v1/user-enrichment-details, + +""" + +EXAMPLES = r""" +- name: Get all User Enrichment Details + cisco.dnac.user_enrichment_details_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "userDetails": { + "id": "string", + "connectionStatus": "string", + "hostType": "string", + "userId": {}, + "hostName": {}, + "hostOs": {}, + "hostVersion": {}, + "subType": "string", + "lastUpdated": 0, + "healthScore": [ + { + "healthType": "string", + "reason": "string", + "score": 0 + } + ], + "hostMac": "string", + "hostIpV4": "string", + "hostIpV6": [ + {} + ], + "authType": {}, + "vlanId": "string", + "ssid": {}, + "frequency": {}, + "channel": {}, + "apGroup": {}, + "location": {}, + "clientConnection": "string", + "connectedDevice": [ + {} + ], + "issueCount": 0, + "rssi": {}, + "avgRssi": {}, + "snr": {}, + "avgSnr": {}, + "dataRate": {}, + "txBytes": {}, + "rxBytes": {}, + "dnsSuccess": {}, + "dnsFailure": {}, + "onboarding": { + "averageRunDuration": {}, + "maxRunDuration": {}, + "averageAssocDuration": {}, + "maxAssocDuration": {}, + "averageAuthDuration": {}, + "maxAuthDuration": {}, + "averageDhcpDuration": {}, + "maxDhcpDuration": {}, + "aaaServerIp": {}, + "dhcpServerIp": {} + }, + "onboardingTime": {}, + "port": {} + }, + "connectedDevice": [ + { + "deviceDetails": { + "family": "string", + "type": "string", + "location": {}, + "errorCode": {}, + "macAddress": "string", + "role": "string", + "apManagerInterfaceIp": "string", + "associatedWlcIp": "string", + "bootDateTime": "string", + "collectionStatus": "string", + "interfaceCount": "string", + "lineCardCount": "string", + "lineCardId": "string", + "managementIpAddress": "string", + "memorySize": "string", + "platformId": "string", + "reachabilityFailureReason": "string", + "reachabilityStatus": "string", + "snmpContact": "string", + "snmpLocation": "string", + "tunnelUdpPort": {}, + "waasDeviceMode": {}, + "series": "string", + "inventoryStatusDetail": "string", + "collectionInterval": "string", + "serialNumber": "string", + "softwareVersion": "string", + "roleSource": "string", + "hostname": "string", + "upTime": "string", + "lastUpdateTime": 0, + "errorDescription": {}, + "locationName": {}, + "tagCount": "string", + "lastUpdated": "string", + "instanceUuid": "string", + "id": "string", + "neighborTopology": [ + { + "errorCode": 0, + "message": "string", + "detail": "string" + } + ] + } + } + ] + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/user_info.py b/ansible_collections/cisco/dnac/plugins/modules/user_info.py new file mode 100644 index 000000000..bb25c6659 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/user_info.py @@ -0,0 +1,80 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: user_info +short_description: Information module for User +description: +- Get all User. +- Get all users for the Cisco DNA Center system. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + invokeSource: + description: + - InvokeSource query parameter. The source that invokes this API. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for User and Roles GetUsersAPI + description: Complete reference of the GetUsersAPI API. + link: https://developer.cisco.com/docs/dna-center/#!get-users-api +notes: + - SDK Method used are + userand_roles.UserandRoles.get_users_ap_i, + + - Paths used are + get /dna/system/api/v1/user, + +""" + +EXAMPLES = r""" +- name: Get all User + cisco.dnac.user_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + invokeSource: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "users": [ + { + "firstName": "string", + "lastName": "string", + "authSource": "string", + "passphraseUpdateTime": "string", + "roleList": [ + "string" + ], + "userId": "string", + "email": "string", + "username": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/users_external_servers_info.py b/ansible_collections/cisco/dnac/plugins/modules/users_external_servers_info.py new file mode 100644 index 000000000..2360060ad --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/users_external_servers_info.py @@ -0,0 +1,80 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: users_external_servers_info +short_description: Information module for Users External Servers +description: +- Get all Users External Servers. +- Get external users authentication servers. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + invokeSource: + description: + - InvokeSource query parameter. The source that invokes this API. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for User and Roles GetExternalAuthenticationServersAPI + description: Complete reference of the GetExternalAuthenticationServersAPI API. + link: https://developer.cisco.com/docs/dna-center/#!get-external-authentication-servers-api +notes: + - SDK Method used are + userand_roles.UserandRoles.get_external_authentication_servers_ap_i, + + - Paths used are + get /dna/system/api/v1/users/external-servers, + +""" + +EXAMPLES = r""" +- name: Get all Users External Servers + cisco.dnac.users_external_servers_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + invokeSource: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "aaa-servers": [ + { + "accountingPort": 0, + "retries": 0, + "protocol": "string", + "socketTimeout": 0, + "serverIp": "string", + "sharedSecret": "string", + "serverId": "string", + "authenticationPort": 0, + "aaaAttribute": "string", + "role": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/wireless_accespoint_configuration.py b/ansible_collections/cisco/dnac/plugins/modules/wireless_accespoint_configuration.py new file mode 100644 index 000000000..94dee6c5d --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/wireless_accespoint_configuration.py @@ -0,0 +1,338 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: wireless_accespoint_configuration +short_description: Resource module for Wireless Accespoint Configuration +description: +- Manage operation create of the resource Wireless Accespoint Configuration. +- User can configure multiple access points with required options using this intent API. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + adminStatus: + description: Configure the access point's admin status. Set this parameter's value + to "true" to enable it and "false" to disable it. + type: bool + apHeight: + description: Configure the height of the access point by setting a value between + 3 and height of the floor. + type: int + apList: + description: Wireless Accespoint Configuration's apList. + elements: dict + suboptions: + apName: + description: The current host name of the access point. + type: str + apNameNew: + description: The modified hostname of the access point. + type: str + macAddress: + description: The ethernet MAC address of the access point. + type: str + type: list + apMode: + description: Configure the access point's mode for local/flexconnect mode, set "0"; + for monitor mode, set "1"; for sniffer mode, set "4"; and for bridge/flex+bridge + mode, set "5". + type: int + configureAdminStatus: + description: To change the access point's admin status, set this parameter's value + to "true". + type: bool + configureApHeight: + description: To change the access point's height, set this parameter's value to + "true". + type: bool + configureApMode: + description: To change the access point's mode, set this parameter's value to "true". + type: bool + configureFailoverPriority: + description: To change the access point's failover priority, set this parameter's + value to "true". + type: bool + configureHAController: + description: To change the access point's HA controller, set this parameter's value + to "true". + type: bool + configureLedBrightnessLevel: + description: To change the access point's LED brightness level, set this parameter's + value to "true". + type: bool + configureLedStatus: + description: To change the access point's LED status, set this parameter's value + to "true". + type: bool + configureLocation: + description: To change the access point's location, set this parameter's value to + "true". + type: bool + failoverPriority: + description: Configure the acess point's failover priority for low, set "1"; for + medium, set "2"; for high, set "3"; and for critical, set "4". + type: int + ledBrightnessLevel: + description: Configure the access point's LED brightness level by setting a value + between 1 and 8. + type: int + ledStatus: + description: Configure the access point's LED status. Set "true" to enable its status + and "false" to disable it. + type: bool + location: + description: Configure the access point's location. + type: str + primaryControllerName: + description: Configure the hostname for an access point's primary controller. + type: str + primaryIpAddress: + description: Wireless Accespoint Configuration's primaryIpAddress. + suboptions: + address: + description: Configure the IP address for an access point's primary controller. + type: str + type: dict + radioConfigurations: + description: Wireless Accespoint Configuration's radioConfigurations. + elements: dict + suboptions: + adminStatus: + description: Configure the admin status on the specified radio for an access + point. Set this parameter's value to "true" to enable it and "false" to disable + it. + type: bool + antennaCableName: + description: Configure the antenna cable name on the specified radio for an + access point. If cable loss needs to be configured, set this parameter's value + to "other". + type: str + antennaDegree: + description: Configure the antenna degree on the specified radio for an access + point. + type: int + antennaElevAngleDegree: + description: Configure the antenna elevation angle on the specified radio for + an access point. + type: int + antennaElevAngleSign: + description: Configure the antenna elevation angle direction on the specified + radio for an access point for up, set "1"; for down, set "-1". + type: int + antennaGain: + description: Configure the antenna gain on the specified radio for an access + point by setting a decimal value (in dBi). + type: int + antennaPatternName: + description: Configure the antenna pattern name on the specified radio for an + access point. If antenna gain needs to be configured, set this parameter's + value to "other". + type: str + cableLoss: + description: Configure the cable loss on the specified radio for an access point + by setting a decimal value (in dBi). + type: int + channelAssignmentMode: + description: Configure the channel assignment mode on the specified radio for + an access point for global mode, set "1"; and for custom mode, set "2". + type: int + channelNumber: + description: Configure the channel number on the specified radio for an access + point. + type: int + channelWidth: + description: Configure the channel width on the specified radio for an access + point for 20 MHz, set "3"; for 40 MHz, set "4"; for 80 MHz, set "5"; and for + 160 MHz, set "6". + type: int + cleanAirSI: + description: Configure CleanAir or Spectrum Intelligence on the specified radio + for an access point. Set this parameter's value to "0" to disable the feature + or "1" to enable it. + type: int + configureAdminStatus: + description: To change the admin status on the specified radio for an access + point, set this parameter's value to "true". + type: bool + configureAntennaCable: + description: To change the antenna cable name on the specified radio for an + access point, set this parameter's value to "true". + type: bool + configureAntennaDegree: + description: To change the antenna degree on the specified radio for an access + point, set this parameter's value to "true". + type: bool + configureAntennaPatternName: + description: To change the antenna pattern name on the specified radio for an + access point, set the value for this parameter to "true". + type: bool + configureChannel: + description: To change the channel on the specified radio for an access point, + set this parameter's value to "true". + type: bool + configureChannelWidth: + description: To change the channel width on the specified radio for an access + point, set this parameter's value to "true". + type: bool + configureCleanAirSI: + description: To enable or disable either CleanAir or Spectrum Intelligence on + the specified radio for an access point, set this parameter's value to "true". + type: bool + configureElevAngleDegree: + description: To change the elevation angle degree on the specified radio for + an access point, set this parameter's value to "true". + type: bool + configurePower: + description: To change the power assignment mode on the specified radio for + an access point, set this parameter's value to "true". + type: bool + configureRadioRoleAssignment: + description: To change the radio role on the specified radio for an access point, + set this parameter's value to "true". + type: bool + powerAssignmentMode: + description: Configure the power assignment mode on the specified radio for + an access point for global mode, set "1"; and for custom mode, set "2". + type: int + powerlevel: + description: Configure the power level on the specified radio for an access + point by setting a value between 1 and 8. + type: int + radioBand: + description: Configure the band on the specified radio for an access point for + 2.4 GHz, set "RADIO24"; for 5 GHz, set "RADIO5". + type: str + radioRoleAssignment: + description: Configure one of the following roles on the specified radio for + an access point "auto", "serving", or "monitor". + type: str + radioType: + description: Configure an access point's radio band for 2.4 GHz, set "1"; for + 5 GHz, set "2"; for XOR, set "3"; and for 6 GHz, set "6". + type: int + type: list + secondaryControllerName: + description: Configure the hostname for an access point's secondary controller. + type: str + secondaryIpAddress: + description: Wireless Accespoint Configuration's secondaryIpAddress. + suboptions: + address: + description: Configure the IP address for an access point's secondary controller. + type: str + type: dict + tertiaryControllerName: + description: Configure the hostname for an access point's tertiary controller. + type: str + tertiaryIpAddress: + description: Wireless Accespoint Configuration's tertiaryIpAddress. + suboptions: + address: + description: Configure the IP address for an access point's tertiary controller. + type: str + type: dict +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless ConfigureAccessPoints + description: Complete reference of the ConfigureAccessPoints API. + link: https://developer.cisco.com/docs/dna-center/#!configure-access-points +notes: + - SDK Method used are + wireless.Wireless.configure_access_points, + + - Paths used are + post /dna/intent/api/v1/wireless/accesspoint-configuration, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.wireless_accespoint_configuration: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + adminStatus: true + apHeight: 0 + apList: + - apName: string + apNameNew: string + macAddress: string + apMode: 0 + configureAdminStatus: true + configureApHeight: true + configureApMode: true + configureFailoverPriority: true + configureHAController: true + configureLedBrightnessLevel: true + configureLedStatus: true + configureLocation: true + failoverPriority: 0 + ledBrightnessLevel: 0 + ledStatus: true + location: string + primaryControllerName: string + primaryIpAddress: + address: string + radioConfigurations: + - adminStatus: true + antennaCableName: string + antennaDegree: 0 + antennaElevAngleDegree: 0 + antennaElevAngleSign: 0 + antennaGain: 0 + antennaPatternName: string + cableLoss: 0 + channelAssignmentMode: 0 + channelNumber: 0 + channelWidth: 0 + cleanAirSI: 0 + configureAdminStatus: true + configureAntennaCable: true + configureAntennaDegree: true + configureAntennaPatternName: true + configureChannel: true + configureChannelWidth: true + configureCleanAirSI: true + configureElevAngleDegree: true + configurePower: true + configureRadioRoleAssignment: true + powerAssignmentMode: 0 + powerlevel: 0 + radioBand: string + radioRoleAssignment: string + radioType: 0 + secondaryControllerName: string + secondaryIpAddress: + address: string + tertiaryControllerName: string + tertiaryIpAddress: + address: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "response": { + "taskId": "string", + "url": "string" + }, + "version": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/wireless_accesspoint_configuration_summary_info.py b/ansible_collections/cisco/dnac/plugins/modules/wireless_accesspoint_configuration_summary_info.py new file mode 100644 index 000000000..3c2130868 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/wireless_accesspoint_configuration_summary_info.py @@ -0,0 +1,152 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: wireless_accesspoint_configuration_summary_info +short_description: Information module for Wireless Accesspoint Configuration Summary +description: +- Get all Wireless Accesspoint Configuration Summary. +- Users can query the access point configuration information per device using the ethernet MAC address. +version_added: '6.7.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + key: + description: + - Key query parameter. The ethernet MAC address of Access point. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless GetAccessPointConfiguration + description: Complete reference of the GetAccessPointConfiguration API. + link: https://developer.cisco.com/docs/dna-center/#!get-access-point-configuration +notes: + - SDK Method used are + wireless.Wireless.get_access_point_configuration, + + - Paths used are + get /dna/intent/api/v1/wireless/accesspoint-configuration/summary, + +""" + +EXAMPLES = r""" +- name: Get all Wireless Accesspoint Configuration Summary + cisco.dnac.wireless_accesspoint_configuration_summary_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + key: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "instanceUuid": {}, + "instanceId": 0, + "authEntityId": {}, + "displayName": "string", + "authEntityClass": {}, + "instanceTenantId": "string", + "_orderedListOEIndex": 0, + "_orderedListOEAssocName": {}, + "_creationOrderIndex": 0, + "_isBeingChanged": true, + "deployPending": "string", + "instanceCreatedOn": {}, + "instanceUpdatedOn": {}, + "changeLogList": {}, + "instanceOrigin": {}, + "lazyLoadedEntities": {}, + "instanceVersion": 0, + "adminStatus": "string", + "apHeight": 0, + "apMode": "string", + "apName": "string", + "ethMac": "string", + "failoverPriority": "string", + "ledBrightnessLevel": 0, + "ledStatus": "string", + "location": "string", + "macAddress": "string", + "primaryControllerName": "string", + "primaryIpAddress": "string", + "secondaryControllerName": "string", + "secondaryIpAddress": "string", + "tertiaryControllerName": "string", + "tertiaryIpAddress": "string", + "meshDTOs": [ + {} + ], + "radioDTOs": [ + { + "instanceUuid": {}, + "instanceId": 0, + "authEntityId": {}, + "displayName": "string", + "authEntityClass": {}, + "instanceTenantId": "string", + "_orderedListOEIndex": 0, + "_orderedListOEAssocName": {}, + "_creationOrderIndex": 0, + "_isBeingChanged": true, + "deployPending": "string", + "instanceCreatedOn": {}, + "instanceUpdatedOn": {}, + "changeLogList": {}, + "instanceOrigin": {}, + "lazyLoadedEntities": {}, + "instanceVersion": 0, + "adminStatus": "string", + "antennaAngle": 0, + "antennaElevAngle": 0, + "antennaGain": 0, + "antennaPatternName": "string", + "channelAssignmentMode": "string", + "channelNumber": 0, + "channelWidth": "string", + "cleanAirSI": "string", + "ifType": 0, + "ifTypeValue": "string", + "macAddress": "string", + "powerAssignmentMode": "string", + "powerlevel": 0, + "radioBand": {}, + "radioRoleAssignment": {}, + "slotId": 0, + "internalKey": { + "type": "string", + "id": 0, + "longType": "string", + "url": "string" + } + } + ], + "internalKey": { + "type": "string", + "id": 0, + "longType": "string", + "url": "string" + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/wireless_dynamic_interface.py b/ansible_collections/cisco/dnac/plugins/modules/wireless_dynamic_interface.py new file mode 100644 index 000000000..ea48c7970 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/wireless_dynamic_interface.py @@ -0,0 +1,93 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: wireless_dynamic_interface +short_description: Resource module for Wireless Dynamic Interface +description: +- Manage operations create and delete of the resource Wireless Dynamic Interface. +- API to create or update an dynamic interface. +- Delete a dynamic interface. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + interfaceName: + description: Dynamic-interface name. + type: str + vlanId: + description: Vlan Id. + type: int +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless CreateUpdateDynamicInterface + description: Complete reference of the CreateUpdateDynamicInterface API. + link: https://developer.cisco.com/docs/dna-center/#!create-update-dynamic-interface +- name: Cisco DNA Center documentation for Wireless DeleteDynamicInterface + description: Complete reference of the DeleteDynamicInterface API. + link: https://developer.cisco.com/docs/dna-center/#!delete-dynamic-interface +notes: + - SDK Method used are + wireless.Wireless.create_update_dynamic_interface, + wireless.Wireless.delete_dynamic_interface, + + - Paths used are + post /dna/intent/api/v1/wireless/dynamic-interface, + delete /dna/intent/api/v1/wireless/dynamic-interface/{interfaceName}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.wireless_dynamic_interface: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + headers: '{{my_headers | from_json}}' + interfaceName: string + vlanId: 0 + +- name: Delete by name + cisco.dnac.wireless_dynamic_interface: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + headers: '{{my_headers | from_json}}' + interfaceName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + sample: > + [ + { + "executionId": "string", + "executionUrl": "string", + "message": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/wireless_dynamic_interface_info.py b/ansible_collections/cisco/dnac/plugins/modules/wireless_dynamic_interface_info.py new file mode 100644 index 000000000..d1736fb20 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/wireless_dynamic_interface_info.py @@ -0,0 +1,73 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: wireless_dynamic_interface_info +short_description: Information module for Wireless Dynamic Interface +description: +- Get all Wireless Dynamic Interface. +- Get one or all dynamic interfaces. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + interface_name: + description: + - > + Interface-name query parameter. Dynamic-interface name, if not specified all the existing dynamic interfaces + will be retrieved. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless GetDynamicInterface + description: Complete reference of the GetDynamicInterface API. + link: https://developer.cisco.com/docs/dna-center/#!get-dynamic-interface +notes: + - SDK Method used are + wireless.Wireless.get_dynamic_interface, + + - Paths used are + get /dna/intent/api/v1/wireless/dynamic-interface, + +""" + +EXAMPLES = r""" +- name: Get all Wireless Dynamic Interface + cisco.dnac.wireless_dynamic_interface_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + interface_name: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "interfaceName": "string", + "vlanId": 0 + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/wireless_enterprise_ssid.py b/ansible_collections/cisco/dnac/plugins/modules/wireless_enterprise_ssid.py new file mode 100644 index 000000000..eb8790381 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/wireless_enterprise_ssid.py @@ -0,0 +1,197 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: wireless_enterprise_ssid +short_description: Resource module for Wireless Enterprise Ssid +description: +- Manage operations create, update and delete of the resource Wireless Enterprise Ssid. +- Creates enterprise SSID. +- Deletes given enterprise SSID. +- Update enterprise SSID. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + basicServiceSetClientIdleTimeout: + description: Basic Service Set Client Idle Timeout. + type: int + clientExclusionTimeout: + description: Client Exclusion Timeout. + type: int + enableBasicServiceSetMaxIdle: + description: Enable Basic Service Set Max Idle. + type: bool + enableBroadcastSSID: + description: Enable Broadcase SSID. + type: bool + enableClientExclusion: + description: Enable Client Exclusion. + type: bool + enableDirectedMulticastService: + description: Enable Directed Multicast Service. + type: bool + enableFastLane: + description: Enable FastLane. + type: bool + enableMACFiltering: + description: Enable MAC Filtering. + type: bool + enableNeighborList: + description: Enable Neighbor List. + type: bool + enableSessionTimeOut: + description: Enable Session Timeout. + type: bool + fastTransition: + description: Fast Transition. + type: str + mfpClientProtection: + description: Management Frame Protection Client. + type: str + name: + description: SSID NAME. + type: str + nasOptions: + description: Nas Options. + elements: str + type: list + passphrase: + description: Passphrase. + type: str + radioPolicy: + description: Radio Policy Enum (enum Triple band operation (2.4GHz, 5GHz and 6GHz), + Triple band operation with band select, 5GHz only, 2.4GHz only, 6GHz only). + type: str + securityLevel: + description: Security Level. + type: str + sessionTimeOut: + description: Session Time Out. + type: int + ssidName: + description: SsidName path parameter. Enter the SSID name to be deleted. + type: str + trafficType: + description: Traffic Type Enum (voicedata or data ). + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless CreateEnterpriseSSID + description: Complete reference of the CreateEnterpriseSSID API. + link: https://developer.cisco.com/docs/dna-center/#!create-enterprise-ssid +- name: Cisco DNA Center documentation for Wireless DeleteEnterpriseSSID + description: Complete reference of the DeleteEnterpriseSSID API. + link: https://developer.cisco.com/docs/dna-center/#!delete-enterprise-ssid +- name: Cisco DNA Center documentation for Wireless UpdateEnterpriseSSID + description: Complete reference of the UpdateEnterpriseSSID API. + link: https://developer.cisco.com/docs/dna-center/#!update-enterprise-ssid +notes: + - SDK Method used are + wireless.Wireless.create_enterprise_ssid, + wireless.Wireless.delete_enterprise_ssid, + wireless.Wireless.update_enterprise_ssid, + + - Paths used are + post /dna/intent/api/v1/enterprise-ssid, + delete /dna/intent/api/v1/enterprise-ssid/{ssidName}, + put /dna/intent/api/v1/enterprise-ssid, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.wireless_enterprise_ssid: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + basicServiceSetClientIdleTimeout: 0 + clientExclusionTimeout: 0 + enableBasicServiceSetMaxIdle: true + enableBroadcastSSID: true + enableClientExclusion: true + enableDirectedMulticastService: true + enableFastLane: true + enableMACFiltering: true + enableNeighborList: true + enableSessionTimeOut: true + fastTransition: string + mfpClientProtection: string + name: string + nasOptions: + - string + passphrase: string + radioPolicy: string + securityLevel: string + sessionTimeOut: 0 + trafficType: string + +- name: Update all + cisco.dnac.wireless_enterprise_ssid: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + basicServiceSetClientIdleTimeout: 0 + clientExclusionTimeout: 0 + enableBasicServiceSetMaxIdle: true + enableBroadcastSSID: true + enableClientExclusion: true + enableDirectedMulticastService: true + enableFastLane: true + enableMACFiltering: true + enableNeighborList: true + enableSessionTimeOut: true + fastTransition: string + mfpClientProtection: string + name: string + nasOptions: + - string + passphrase: string + radioPolicy: string + securityLevel: string + sessionTimeOut: 0 + trafficType: string + +- name: Delete by name + cisco.dnac.wireless_enterprise_ssid: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + ssidName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/wireless_enterprise_ssid_info.py b/ansible_collections/cisco/dnac/plugins/modules/wireless_enterprise_ssid_info.py new file mode 100644 index 000000000..8abacd832 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/wireless_enterprise_ssid_info.py @@ -0,0 +1,107 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: wireless_enterprise_ssid_info +short_description: Information module for Wireless Enterprise Ssid +description: +- Get all Wireless Enterprise Ssid. +- Gets either one or all the enterprise SSID. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + ssidName: + description: + - > + SsidName query parameter. Enter the enterprise SSID name that needs to be retrieved. If not entered, all the + enterprise SSIDs will be retrieved. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless GetEnterpriseSSID + description: Complete reference of the GetEnterpriseSSID API. + link: https://developer.cisco.com/docs/dna-center/#!get-enterprise-ssid +notes: + - SDK Method used are + wireless.Wireless.get_enterprise_ssid, + + - Paths used are + get /dna/intent/api/v1/enterprise-ssid, + +""" + +EXAMPLES = r""" +- name: Get all Wireless Enterprise Ssid + cisco.dnac.wireless_enterprise_ssid_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + ssidName: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "instanceUuid": "string", + "version": 0, + "ssidDetails": [ + { + "name": "string", + "wlanType": "string", + "enableFastLane": true, + "securityLevel": "string", + "authServer": "string", + "passphrase": "string", + "trafficType": "string", + "enableMACFiltering": true, + "isEnabled": true, + "isFabric": true, + "fastTransition": "string", + "radioPolicy": "string", + "enableBroadcastSSID": true, + "nasOptions": [ + "string" + ], + "aaaOverride": true, + "coverageHoleDetectionEnable": true, + "protectedManagementFrame": "string", + "multiPSKSettings": [ + { + "priority": 0, + "passphraseType": "string", + "passphrase": "string" + } + ], + "clientRateLimit": 0 + } + ], + "groupUuid": "string", + "inheritedGroupUuid": "string", + "inheritedGroupName": "string" + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/wireless_profile.py b/ansible_collections/cisco/dnac/plugins/modules/wireless_profile.py new file mode 100644 index 000000000..4c696f0d6 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/wireless_profile.py @@ -0,0 +1,172 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: wireless_profile +short_description: Resource module for Wireless Profile +description: +- Manage operations create, update and delete of the resource Wireless Profile. +- Creates Wireless Network Profile on Cisco DNA Center and associates sites and SSIDs to it. +- Delete the Wireless Profile from Cisco DNA Center whose name is provided. +- > + Updates the wireless Network Profile with updated details provided. All sites to be present in the network profile + should be provided. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + profileDetails: + description: Wireless Profile's profileDetails. + suboptions: + name: + description: Profile Name. + type: str + sites: + description: Array of site name hierarchies(eg "Global/aaa/zzz", "Global/aaa/zzz"). + elements: str + type: list + ssidDetails: + description: Wireless Profile's ssidDetails. + elements: dict + suboptions: + enableFabric: + description: True if ssid is fabric else false. + type: bool + flexConnect: + description: Wireless Profile's flexConnect. + suboptions: + enableFlexConnect: + description: True if flex connect is enabled else false. + type: bool + localToVlan: + description: Local To Vlan Id. + type: int + type: dict + interfaceName: + description: Interface Name. + type: str + name: + description: Ssid Name. + type: str + policyProfileName: + description: Policy Profile Name. + type: str + type: + description: Ssid Type(enum Enterprise/Guest). + type: str + wlanProfileName: + description: WLAN Profile Name. + type: str + type: list + type: dict + wirelessProfileName: + description: WirelessProfileName path parameter. Wireless Profile Name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless CreateWirelessProfile + description: Complete reference of the CreateWirelessProfile API. + link: https://developer.cisco.com/docs/dna-center/#!create-wireless-profile +- name: Cisco DNA Center documentation for Wireless DeleteWirelessProfile + description: Complete reference of the DeleteWirelessProfile API. + link: https://developer.cisco.com/docs/dna-center/#!delete-wireless-profile +- name: Cisco DNA Center documentation for Wireless UpdateWirelessProfile + description: Complete reference of the UpdateWirelessProfile API. + link: https://developer.cisco.com/docs/dna-center/#!update-wireless-profile +notes: + - SDK Method used are + wireless.Wireless.create_wireless_profile, + wireless.Wireless.delete_wireless_profile, + wireless.Wireless.update_wireless_profile, + + - Paths used are + post /dna/intent/api/v1/wireless/profile, + delete /dna/intent/api/v1/wireless-profile/{wirelessProfileName}, + put /dna/intent/api/v1/wireless/profile, + +""" + +EXAMPLES = r""" +- name: Delete by name + cisco.dnac.wireless_profile: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + wirelessProfileName: string + +- name: Update all + cisco.dnac.wireless_profile: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + profileDetails: + name: string + sites: + - string + ssidDetails: + - enableFabric: true + flexConnect: + enableFlexConnect: true + localToVlan: 0 + interfaceName: string + name: string + policyProfileName: string + type: string + wlanProfileName: string + +- name: Create + cisco.dnac.wireless_profile: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + profileDetails: + name: string + sites: + - string + ssidDetails: + - enableFabric: true + flexConnect: + enableFlexConnect: true + localToVlan: 0 + interfaceName: string + name: string + policyProfileName: string + type: string + wlanProfileName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/wireless_profile_info.py b/ansible_collections/cisco/dnac/plugins/modules/wireless_profile_info.py new file mode 100644 index 000000000..f88760c14 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/wireless_profile_info.py @@ -0,0 +1,87 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: wireless_profile_info +short_description: Information module for Wireless Profile +description: +- Get all Wireless Profile. +- Gets either one or all the wireless network profiles if no name is provided for network-profile. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + profileName: + description: + - ProfileName query parameter. Wireless Network Profile Name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless GetWirelessProfile + description: Complete reference of the GetWirelessProfile API. + link: https://developer.cisco.com/docs/dna-center/#!get-wireless-profile +notes: + - SDK Method used are + wireless.Wireless.get_wireless_profile, + + - Paths used are + get /dna/intent/api/v1/wireless/profile, + +""" + +EXAMPLES = r""" +- name: Get all Wireless Profile + cisco.dnac.wireless_profile_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + profileName: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "profileDetails": { + "name": "string", + "sites": [ + "string" + ], + "ssidDetails": [ + { + "name": "string", + "type": "string", + "enableFabric": true, + "flexConnect": { + "enableFlexConnect": true, + "localToVlan": 0 + }, + "interfaceName": "string" + } + ] + } + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/wireless_provision_access_point.py b/ansible_collections/cisco/dnac/plugins/modules/wireless_provision_access_point.py new file mode 100644 index 000000000..f8db0233c --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/wireless_provision_access_point.py @@ -0,0 +1,98 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: wireless_provision_access_point +short_description: Resource module for Wireless Provision Access Point +description: +- Manage operation create of the resource Wireless Provision Access Point. +- Access Point Provision and ReProvision. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + payload: + description: Wireless Provision Access Point's payload. + elements: dict + suboptions: + customApGroupName: + description: Custom AP group name. + type: str + customFlexGroupName: + description: '"Custom flex group name".' + elements: str + type: list + deviceName: + description: Device name. + type: str + rfProfile: + description: Radio frequency profile name. + type: str + siteId: + description: Site name hierarchy(ex Global/...). + type: str + siteNameHierarchy: + description: Site name hierarchy(ex Global/...). + type: str + type: + description: ApWirelessConfiguration. + type: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless APProvision + description: Complete reference of the APProvision API. + link: https://developer.cisco.com/docs/dna-center/#!a-p-provision +notes: + - SDK Method used are + wireless.Wireless.ap_provision, + + - Paths used are + post /dna/intent/api/v1/wireless/ap-provision, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.wireless_provision_access_point: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: '{{my_headers | from_json}}' + payload: + - customApGroupName: string + customFlexGroupName: + - string + deviceName: string + rfProfile: string + siteId: string + siteNameHierarchy: string + type: string + +""" +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/wireless_provision_device_create.py b/ansible_collections/cisco/dnac/plugins/modules/wireless_provision_device_create.py new file mode 100644 index 000000000..d626052a7 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/wireless_provision_device_create.py @@ -0,0 +1,116 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: wireless_provision_device_create +short_description: Resource module for Wireless Provision Device Create +description: +- Manage operation create of the resource Wireless Provision Device Create. +- Provision wireless devices. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + payload: + description: Wireless Provision Device Create's payload. + elements: dict + suboptions: + deviceName: + description: Controller Name. + type: str + dynamicInterfaces: + description: Wireless Provision Device Create's dynamicInterfaces. + elements: dict + suboptions: + interfaceGateway: + description: Interface Gateway. + type: str + interfaceIPAddress: + description: Interface IP Address. + type: str + interfaceName: + description: Interface Name. + type: str + interfaceNetmaskInCIDR: + description: Interface Netmask In CIDR. + type: int + lagOrPortNumber: + description: Lag Or Port Number. + type: int + vlanId: + description: VLAN ID. + type: int + type: list + managedAPLocations: + description: List of managed AP locations (Site Hierarchies). + elements: str + type: list + site: + description: Full Site Hierarchy where device has to be assigned. + type: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless Provision + description: Complete reference of the Provision API. + link: https://developer.cisco.com/docs/dna-center/#!provision +notes: + - SDK Method used are + wireless.Wireless.provision, + + - Paths used are + post /dna/intent/api/v1/wireless/provision, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.wireless_provision_device_create: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + payload: + - deviceName: string + dynamicInterfaces: + - interfaceGateway: string + interfaceIPAddress: string + interfaceName: string + interfaceNetmaskInCIDR: 0 + lagOrPortNumber: 0 + vlanId: 0 + managedAPLocations: + - string + site: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionUrl": "string", + "provisioningTasks": { + "success": [ + "string" + ], + "failed": [ + "string" + ] + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/wireless_provision_device_update.py b/ansible_collections/cisco/dnac/plugins/modules/wireless_provision_device_update.py new file mode 100644 index 000000000..07e983f30 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/wireless_provision_device_update.py @@ -0,0 +1,116 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: wireless_provision_device_update +short_description: Resource module for Wireless Provision Device Update +description: +- Manage operation update of the resource Wireless Provision Device Update. +- Updates wireless provisioning. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + payload: + description: Wireless Provision Device Update's payload. + elements: dict + suboptions: + deviceName: + description: Device Name. + type: str + dynamicInterfaces: + description: Wireless Provision Device Update's dynamicInterfaces. + elements: dict + suboptions: + interfaceGateway: + description: Interface Gateway. + type: str + interfaceIPAddress: + description: Interface IPAddress. + type: str + interfaceName: + description: Interface Name. + type: str + interfaceNetmaskInCIDR: + description: Interface Netmask In CIDR. + type: int + lagOrPortNumber: + description: Lag Or Port Number. + type: int + vlanId: + description: Vlan Id. + type: int + type: list + managedAPLocations: + description: Managed APLocations. + elements: str + type: list + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless ProvisionUpdate + description: Complete reference of the ProvisionUpdate API. + link: https://developer.cisco.com/docs/dna-center/#!provision-update +notes: + - SDK Method used are + wireless.Wireless.provision_update, + + - Paths used are + put /dna/intent/api/v1/wireless/provision, + +""" + +EXAMPLES = r""" +- name: Update all + cisco.dnac.wireless_provision_device_update: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: '{{my_headers | from_json}}' + payload: + - deviceName: string + dynamicInterfaces: + - interfaceGateway: string + interfaceIPAddress: string + interfaceName: string + interfaceNetmaskInCIDR: 0 + lagOrPortNumber: 0 + vlanId: 0 + managedAPLocations: + - string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionUrl": "string", + "provisioningTasks": { + "success": [ + "string" + ], + "failed": [ + "string" + ] + } + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/wireless_provision_ssid_create_provision.py b/ansible_collections/cisco/dnac/plugins/modules/wireless_provision_ssid_create_provision.py new file mode 100644 index 000000000..5a7322ea9 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/wireless_provision_ssid_create_provision.py @@ -0,0 +1,139 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: wireless_provision_ssid_create_provision +short_description: Resource module for Wireless Provision Ssid Create Provision +description: +- Manage operation create of the resource Wireless Provision Ssid Create Provision. +- > + Creates SSID, updates the SSID to the corresponding site profiles and provision it to the devices matching the + given sites. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + enableFabric: + description: Enable SSID for Fabric. + type: bool + flexConnect: + description: Wireless Provision Ssid Create Provision's flexConnect. + suboptions: + enableFlexConnect: + description: Enable Flex Connect. + type: bool + localToVlan: + description: Local To Vlan (range is 1 to 4094). + type: int + type: dict + headers: + description: Additional headers. + type: dict + managedAPLocations: + description: Managed AP Locations (Enter entire Site(s) hierarchy). + elements: str + type: list + ssidDetails: + description: Wireless Provision Ssid Create Provision's ssidDetails. + suboptions: + enableBroadcastSSID: + description: Enable Broadcast SSID. + type: bool + enableFastLane: + description: Enable Fast Lane. + type: bool + enableMACFiltering: + description: Enable MAC Filtering. + type: bool + fastTransition: + description: Fast Transition. + type: str + name: + description: SSID Name. + type: str + passphrase: + description: Pass Phrase ( Only applicable for SSID with PERSONAL auth type + ). + type: str + radioPolicy: + description: Radio Policy. + type: str + securityLevel: + description: Security Level(For guest SSID OPEN/WEB_AUTH, For Enterprise SSID + ENTERPRISE/PERSONAL/OPEN). + type: str + trafficType: + description: Traffic Type. + type: str + webAuthURL: + description: Web Auth URL. + type: str + type: dict + ssidType: + description: SSID Type. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless CreateAndProvisionSSID + description: Complete reference of the CreateAndProvisionSSID API. + link: https://developer.cisco.com/docs/dna-center/#!create-and-provision-ssid +notes: + - SDK Method used are + wireless.Wireless.create_and_provision_ssid, + + - Paths used are + post /dna/intent/api/v1/business/ssid, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.wireless_provision_ssid_create_provision: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + enableFabric: true + flexConnect: + enableFlexConnect: true + localToVlan: 0 + headers: '{{my_headers | from_json}}' + managedAPLocations: + - string + ssidDetails: + enableBroadcastSSID: true + enableFastLane: true + enableMACFiltering: true + fastTransition: string + name: string + passphrase: string + radioPolicy: string + securityLevel: string + trafficType: string + webAuthURL: string + ssidType: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/wireless_provision_ssid_delete_reprovision.py b/ansible_collections/cisco/dnac/plugins/modules/wireless_provision_ssid_delete_reprovision.py new file mode 100644 index 000000000..fed3cb2ca --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/wireless_provision_ssid_delete_reprovision.py @@ -0,0 +1,71 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: wireless_provision_ssid_delete_reprovision +short_description: Resource module for Wireless Provision Ssid Delete Reprovision +description: +- Manage operation delete of the resource Wireless Provision Ssid Delete Reprovision. +- Removes SSID or WLAN from the network profile, reprovision the devices and deletes the SSID or WLAN from DNA Center. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + managedAPLocations: + description: ManagedAPLocations path parameter. + type: str + ssidName: + description: SsidName path parameter. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless DeleteSSIDAndProvisionItToDevices + description: Complete reference of the DeleteSSIDAndProvisionItToDevices API. + link: https://developer.cisco.com/docs/dna-center/#!delete-ssid-and-provision-it-to-devices +notes: + - SDK Method used are + wireless.Wireless.delete_ssid_and_provision_it_to_devices, + + - Paths used are + delete /dna/intent/api/v1/business/ssid/{ssidName}/{managedAPLocations}, + +""" + +EXAMPLES = r""" +- name: Delete by id + cisco.dnac.wireless_provision_ssid_delete_reprovision: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: '{{my_headers | from_json}}' + managedAPLocations: string + ssidName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/wireless_psk_override.py b/ansible_collections/cisco/dnac/plugins/modules/wireless_psk_override.py new file mode 100644 index 000000000..0afada7c5 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/wireless_psk_override.py @@ -0,0 +1,81 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: wireless_psk_override +short_description: Resource module for Wireless Psk Override +description: +- Manage operation create of the resource Wireless Psk Override. +- Update/override pass phrase of enterprise SSID. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + payload: + description: Wireless Psk Override's payload. + elements: dict + suboptions: + passPhrase: + description: Pass phrase (create/update). + type: str + site: + description: Site name hierarchy (ex Global/aaa/zzz/...). + type: str + ssid: + description: Enterprise ssid name(already created/present). + type: str + wlanProfileName: + description: WLAN Profile Name. + type: str + type: list +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless PSKOverride + description: Complete reference of the PSKOverride API. + link: https://developer.cisco.com/docs/dna-center/#!p-sk-override +notes: + - SDK Method used are + wireless.Wireless.psk_override, + + - Paths used are + post /dna/intent/api/v1/wireless/psk-override, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.wireless_psk_override: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + payload: + - passPhrase: string + site: string + ssid: string + wlanProfileName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionStatusUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/wireless_rf_profile.py b/ansible_collections/cisco/dnac/plugins/modules/wireless_rf_profile.py new file mode 100644 index 000000000..4aa97f651 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/wireless_rf_profile.py @@ -0,0 +1,225 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: wireless_rf_profile +short_description: Resource module for Wireless Rf Profile +description: +- Manage operations create and delete of the resource Wireless Rf Profile. +- Create or Update RF profile. +- Delete RF profiles. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module +author: Rafael Campos (@racampos) +options: + channelWidth: + description: Channel Width. + type: str + defaultRfProfile: + description: Is Default Rf Profile. + type: bool + enableBrownField: + description: Enable Brown Field. + type: bool + enableCustom: + description: Enable Custom. + type: bool + enableRadioTypeA: + description: Enable Radio Type A. + type: bool + enableRadioTypeB: + description: Enable Radio Type B. + type: bool + enableRadioTypeC: + description: Enable Radio Type C (6GHz). + type: bool + name: + description: RF Profile Name. + type: str + radioTypeAProperties: + description: Wireless Rf Profile's radioTypeAProperties. + suboptions: + dataRates: + description: Data Rates. + type: str + mandatoryDataRates: + description: Mandatory Data Rates. + type: str + maxPowerLevel: + description: Max Power Level. + type: int + minPowerLevel: + description: Rx Sop Threshold. + type: int + parentProfile: + description: Parent Profile. + type: str + powerThresholdV1: + description: Power Threshold V1. + type: int + radioChannels: + description: Radio Channels. + type: str + rxSopThreshold: + description: Rx Sop Threshold. + type: str + type: dict + radioTypeBProperties: + description: Wireless Rf Profile's radioTypeBProperties. + suboptions: + dataRates: + description: Data Rates. + type: str + mandatoryDataRates: + description: Mandatory Data Rates. + type: str + maxPowerLevel: + description: Max Power Level. + type: int + minPowerLevel: + description: Min Power Level. + type: int + parentProfile: + description: Parent Profile. + type: str + powerThresholdV1: + description: Power Threshold V1. + type: int + radioChannels: + description: Radio Channels. + type: str + rxSopThreshold: + description: Rx Sop Threshold. + type: str + type: dict + radioTypeCProperties: + description: Wireless Rf Profile's radioTypeCProperties. + suboptions: + dataRates: + description: Data Rates. + type: str + mandatoryDataRates: + description: Mandatory Data Rates. + type: str + maxPowerLevel: + description: Max Power Level. + type: int + minPowerLevel: + description: Min Power Level. + type: int + parentProfile: + description: Parent Profile. + type: str + powerThresholdV1: + description: Power Threshold V1. + type: int + radioChannels: + description: Radio Channels. + type: str + rxSopThreshold: + description: Rx Sop Threshold. + type: str + type: dict + rfProfileName: + description: RfProfileName path parameter. RF profile name to be deleted(required) + *non-custom RF profile cannot be deleted. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless CreateOrUpdateRFProfile + description: Complete reference of the CreateOrUpdateRFProfile API. + link: https://developer.cisco.com/docs/dna-center/#!create-or-update-rf-profile +- name: Cisco DNA Center documentation for Wireless DeleteRFProfiles + description: Complete reference of the DeleteRFProfiles API. + link: https://developer.cisco.com/docs/dna-center/#!delete-rf-profiles +notes: + - SDK Method used are + wireless.Wireless.create_or_update_rf_profile, + wireless.Wireless.delete_rf_profiles, + + - Paths used are + post /dna/intent/api/v1/wireless/rf-profile, + delete /dna/intent/api/v1/wireless/rf-profile/{rfProfileName}, + +""" + +EXAMPLES = r""" +- name: Create + cisco.dnac.wireless_rf_profile: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: present + channelWidth: string + defaultRfProfile: true + enableBrownField: true + enableCustom: true + enableRadioTypeA: true + enableRadioTypeB: true + enableRadioTypeC: true + name: string + radioTypeAProperties: + dataRates: string + mandatoryDataRates: string + maxPowerLevel: 0 + minPowerLevel: 0 + parentProfile: string + powerThresholdV1: 0 + radioChannels: string + rxSopThreshold: string + radioTypeBProperties: + dataRates: string + mandatoryDataRates: string + maxPowerLevel: 0 + minPowerLevel: 0 + parentProfile: string + powerThresholdV1: 0 + radioChannels: string + rxSopThreshold: string + radioTypeCProperties: + dataRates: string + mandatoryDataRates: string + maxPowerLevel: 0 + minPowerLevel: 0 + parentProfile: string + powerThresholdV1: 0 + radioChannels: string + rxSopThreshold: string + +- name: Delete by name + cisco.dnac.wireless_rf_profile: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + state: absent + rfProfileName: string + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "executionId": "string", + "executionUrl": "string", + "message": "string" + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/wireless_rf_profile_info.py b/ansible_collections/cisco/dnac/plugins/modules/wireless_rf_profile_info.py new file mode 100644 index 000000000..722ddfc40 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/wireless_rf_profile_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: wireless_rf_profile_info +short_description: Information module for Wireless Rf Profile +description: +- Get all Wireless Rf Profile. +- Retrieve all RF profiles. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + rf_profile_name: + description: + - Rf-profile-name query parameter. RF Profile Name. + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless RetrieveRFProfiles + description: Complete reference of the RetrieveRFProfiles API. + link: https://developer.cisco.com/docs/dna-center/#!retrieve-rf-profiles +notes: + - SDK Method used are + wireless.Wireless.retrieve_rf_profiles, + + - Paths used are + get /dna/intent/api/v1/wireless/rf-profile, + +""" + +EXAMPLES = r""" +- name: Get all Wireless Rf Profile + cisco.dnac.wireless_rf_profile_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + rf_profile_name: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: list + elements: dict + sample: > + [ + { + "name": "string", + "parentProfileA": "string", + "parentProfileB": "string", + "enableARadioType": true, + "enableBRadioType": true, + "enableCRadioType": true, + "channelWidth": "string", + "aRadioChannels": "string", + "bRadioChannels": "string", + "cRadioChannels": "string", + "dataRatesA": "string", + "dataRatesB": "string", + "dataRatesC": "string", + "mandatoryDataRatesA": "string", + "mandatoryDataRatesB": "string", + "mandatoryDataRatesC": "string", + "enableCustom": true, + "minPowerLevelA": "string", + "minPowerLevelB": "string", + "minPowerLevelC": "string", + "maxPowerLevelA": "string", + "maxPowerLevelB": "string", + "powerThresholdV1A": 0, + "powerThresholdV1B": 0, + "powerThresholdV1C": 0, + "rxSopThresholdA": "string", + "rxSopThresholdB": "string", + "rxSopThresholdC": "string", + "defaultRfProfile": true, + "enableBrownField": true + } + ] +""" diff --git a/ansible_collections/cisco/dnac/plugins/modules/wireless_sensor_test_results_info.py b/ansible_collections/cisco/dnac/plugins/modules/wireless_sensor_test_results_info.py new file mode 100644 index 000000000..41d727dd5 --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/modules/wireless_sensor_test_results_info.py @@ -0,0 +1,148 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +module: wireless_sensor_test_results_info +short_description: Information module for Wireless Sensor Test Results +description: +- Get all Wireless Sensor Test Results. +- Intent API to get SENSOR test result summary. +version_added: '3.1.0' +extends_documentation_fragment: + - cisco.dnac.module_info +author: Rafael Campos (@racampos) +options: + headers: + description: Additional headers. + type: dict + siteId: + description: + - SiteId query parameter. Assurance site UUID. + type: str + startTime: + description: + - StartTime query parameter. The epoch time in milliseconds. + type: int + endTime: + description: + - EndTime query parameter. The epoch time in milliseconds. + type: int + testFailureBy: + description: + - TestFailureBy query parameter. Obtain failure statistics group by "area", "building", or "floor". + type: str +requirements: +- dnacentersdk >= 2.5.5 +- python >= 3.5 +seealso: +- name: Cisco DNA Center documentation for Wireless SensorTestResults + description: Complete reference of the SensorTestResults API. + link: https://developer.cisco.com/docs/dna-center/#!sensor-test-results +notes: + - SDK Method used are + wireless.Wireless.sensor_test_results, + + - Paths used are + get /dna/intent/api/v1/AssuranceGetSensorTestResults, + +""" + +EXAMPLES = r""" +- name: Get all Wireless Sensor Test Results + cisco.dnac.wireless_sensor_test_results_info: + dnac_host: "{{dnac_host}}" + dnac_username: "{{dnac_username}}" + dnac_password: "{{dnac_password}}" + dnac_verify: "{{dnac_verify}}" + dnac_port: "{{dnac_port}}" + dnac_version: "{{dnac_version}}" + dnac_debug: "{{dnac_debug}}" + headers: "{{my_headers | from_json}}" + siteId: string + startTime: 0 + endTime: 0 + testFailureBy: string + register: result + +""" + +RETURN = r""" +dnac_response: + description: A dictionary or list with the response returned by the Cisco DNAC Python SDK + returned: always + type: dict + sample: > + { + "summary": { + "totalTestCount": 0, + "ONBOARDING": { + "AUTH": { + "passCount": 0, + "failCount": 0 + }, + "DHCP": { + "passCount": 0, + "failCount": 0 + }, + "ASSOC": { + "passCount": 0, + "failCount": 0 + } + }, + "PERFORMANCE": { + "IPSLASENDER": { + "passCount": 0, + "failCount": 0 + } + }, + "NETWORK_SERVICES": { + "DNS": { + "passCount": 0, + "failCount": 0 + } + }, + "APP_CONNECTIVITY": { + "HOST_REACHABILITY": { + "passCount": 0, + "failCount": 0 + }, + "WEBSERVER": { + "passCount": 0, + "failCount": 0 + }, + "FILETRANSFER": { + "passCount": 0, + "failCount": 0 + } + }, + "RF_ASSESSMENT": { + "DATA_RATE": { + "passCount": 0, + "failCount": 0 + }, + "SNR": { + "passCount": 0, + "failCount": 0 + } + }, + "EMAIL": { + "MAILSERVER": { + "passCount": 0, + "failCount": 0 + } + } + }, + "failureStats": [ + { + "errorCode": 0, + "errorTitle": "string", + "testType": "string", + "testCategory": "string" + } + ] + } +""" diff --git a/ansible_collections/cisco/dnac/plugins/plugin_utils/__init__.py b/ansible_collections/cisco/dnac/plugins/plugin_utils/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/ansible_collections/cisco/dnac/plugins/plugin_utils/dnac.py b/ansible_collections/cisco/dnac/plugins/plugin_utils/dnac.py new file mode 100644 index 000000000..80afbe39a --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/plugin_utils/dnac.py @@ -0,0 +1,267 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import (absolute_import, division, print_function) + +__metaclass__ = type +try: + from dnacentersdk import api, exceptions +except ImportError: + DNAC_SDK_IS_INSTALLED = False +else: + DNAC_SDK_IS_INSTALLED = True +from ansible.module_utils.basic import env_fallback +from ansible.module_utils._text import to_native +try: + from ansible.errors import AnsibleActionFail +except ImportError: + ANSIBLE_ERRORS_INSTALLED = False +else: + ANSIBLE_ERRORS_INSTALLED = True +try: + import logging +except ImportError: + LOGGING_IN_STANDARD = False +else: + LOGGING_IN_STANDARD = True +import os.path + + +def is_list_complex(x): + return isinstance(x[0], dict) or isinstance(x[0], list) + + +def has_diff_elem(ls1, ls2): + return any((elem not in ls1 for elem in ls2)) + + +def compare_list(list1, list2): + len_list1 = len(list1) + len_list2 = len(list2) + if len_list1 != len_list2: + return False + + if len_list1 == 0: + return True + + attempt_std_cmp = list1 == list2 + if attempt_std_cmp: + return True + + if not is_list_complex(list1) and not is_list_complex(list2): + return set(list1) == set(list2) + + # Compare normally if it exceeds expected size * 2 (len_list1==len_list2) + MAX_SIZE_CMP = 100 + # Fail fast if elem not in list, thanks to any and generators + if len_list1 > MAX_SIZE_CMP: + return attempt_std_cmp + else: + # not changes 'has diff elem' to list1 != list2 ':lists are not equal' + has_diff_1 = has_diff_elem(list1, list2) + has_diff_2 = has_diff_elem(list2, list1) + return not has_diff_1 or not has_diff_2 + + +def fn_comp_key(k, dict1, dict2): + return dnac_compare_equality(dict1.get(k), dict2.get(k)) + + +def dnac_compare_equality(current_value, requested_value): + # print("dnac_compare_equality", current_value, requested_value) + if requested_value is None: + return True + if current_value is None: + return True + if isinstance(current_value, dict) and isinstance(requested_value, dict): + all_dict_params = list(current_value.keys()) + list(requested_value.keys()) + return not any((not fn_comp_key(param, current_value, requested_value) for param in all_dict_params)) + elif isinstance(current_value, list) and isinstance(requested_value, list): + return compare_list(current_value, requested_value) + else: + return current_value == requested_value + + +def fn_comp_key2(k, dict1, dict2): + return dnac_compare_equality2(dict1.get(k), dict2.get(k)) + + +def dnac_compare_equality2(current_value, requested_value, is_query_param=False): + if is_query_param: + return True + if requested_value is None and current_value is None: + return True + if requested_value is None: + return False + if current_value is None: + return False + if isinstance(current_value, dict) and isinstance(requested_value, dict): + all_dict_params = list(current_value.keys()) + list(requested_value.keys()) + return not any((not fn_comp_key2(param, current_value, requested_value) for param in all_dict_params)) + elif isinstance(current_value, list) and isinstance(requested_value, list): + return compare_list(current_value, requested_value) + else: + return current_value == requested_value + + +def simple_cmp(obj1, obj2): + return obj1 == obj2 + + +def get_dict_result(result, key, value, cmp_fn=simple_cmp): + if isinstance(result, list): + if len(result) == 1: + if isinstance(result[0], dict): + result = result[0] + if result.get(key) is not None and result.get(key) != value: + result = None + else: + result = None + else: + for item in result: + if isinstance(item, dict) and (item.get(key) is None or item.get(key) == value): + result = item + return result + result = None + elif not isinstance(result, dict): + result = None + elif result.get(key) is not None and result.get(key) != value: + result = None + return result + + +def dnac_argument_spec(): + argument_spec = dict( + dnac_host=dict(type="str", fallback=(env_fallback, ['DNAC_HOST']), required=True), + dnac_port=dict(type="int", fallback=(env_fallback, ['DNAC_PORT']), required=False, default=443), + dnac_username=dict(type="str", fallback=(env_fallback, ['DNAC_USERNAME']), default="admin", aliases=["user"]), + dnac_password=dict(type="str", fallback=(env_fallback, ['DNAC_PASSWORD']), no_log=True), + dnac_verify=dict(type="bool", fallback=(env_fallback, ['DNAC_VERIFY']), default=True), + dnac_version=dict(type="str", fallback=(env_fallback, ['DNAC_VERSION']), default="2.3.5.3"), + dnac_debug=dict(type="bool", fallback=(env_fallback, ['DNAC_DEBUG']), default=False), + validate_response_schema=dict(type="bool", fallback=(env_fallback, ['VALIDATE_RESPONSE_SCHEMA']), default=True), + ) + return argument_spec + + +class DNACSDK(object): + def __init__(self, params): + self.result = dict(changed=False, result="") + self.validate_response_schema = params.get("validate_response_schema") + if DNAC_SDK_IS_INSTALLED: + self.api = api.DNACenterAPI( + username=params.get("dnac_username"), + password=params.get("dnac_password"), + base_url="https://{dnac_host}:{dnac_port}".format( + dnac_host=params.get("dnac_host"), dnac_port=params.get("dnac_port") + ), + version=params.get("dnac_version"), + verify=params.get("dnac_verify"), + debug=params.get("dnac_debug"), + ) + if params.get("dnac_debug") and LOGGING_IN_STANDARD: + logging.getLogger('dnacentersdk').addHandler(logging.StreamHandler()) + else: + self.fail_json(msg="DNA Center Python SDK is not installed. Execute 'pip install dnacentersdk'") + + def changed(self): + self.result["changed"] = True + + def object_created(self): + self.changed() + self.result["result"] = "Object created" + + def object_updated(self): + self.changed() + self.result["result"] = "Object updated" + + def object_deleted(self): + self.changed() + self.result["result"] = "Object deleted" + + def object_already_absent(self): + self.result["result"] = "Object already absent" + + def object_already_present(self): + self.result["result"] = "Object already present" + + def object_present_and_different(self): + self.result["result"] = "Object already present, but it has different values to the requested" + + def object_modify_result(self, changed=None, result=None): + if result is not None: + self.result["result"] = result + if changed: + self.changed() + + def is_file(self, file_path): + return os.path.isfile(file_path) + + def extract_file_name(self, file_path): + return os.path.basename(file_path) + + def exec(self, family, function, params=None, op_modifies=False, **kwargs): + try: + family = getattr(self.api, family) + func = getattr(family, function) + except Exception as e: + self.fail_json(msg=e) + + try: + if params: + file_paths_params = kwargs.get('file_paths', []) + # This substitution is for the import file operation + if file_paths_params and isinstance(file_paths_params, list): + multipart_fields = {} + for (key, value) in file_paths_params: + if isinstance(params.get(key), str) and self.is_file(params[key]): + file_name = self.extract_file_name(params[key]) + file_path = params[key] + multipart_fields[value] = (file_name, open(file_path, 'rb')) + + params.setdefault("multipart_fields", multipart_fields) + params.setdefault("multipart_monitor_callback", None) + + if not self.validate_response_schema and op_modifies: + params["active_validation"] = False + + response = func(**params) + else: + response = func() + except exceptions.dnacentersdkException as e: + self.fail_json( + msg=( + "An error occured when executing operation." + " The error was: {error}" + ).format(error=to_native(e)) + ) + return response + + def fail_json(self, msg, **kwargs): + self.result.update(**kwargs) + raise AnsibleActionFail(msg, kwargs) + + def exit_json(self): + return self.result + + def verify_array(self, verify_interface, **kwargs): + if type(verify_interface) is None: + return list() + + if isinstance(verify_interface, list): + if len(verify_interface) == 0: + return list() + if verify_interface[0] is None: + return list() + return verify_interface + + +def main(): + pass + + +if __name__ == "__main__": + main() diff --git a/ansible_collections/cisco/dnac/plugins/plugin_utils/exceptions.py b/ansible_collections/cisco/dnac/plugins/plugin_utils/exceptions.py new file mode 100644 index 000000000..0ed417bed --- /dev/null +++ b/ansible_collections/cisco/dnac/plugins/plugin_utils/exceptions.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright (c) 2021, Cisco Systems +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +class AnsibleDNACException(Exception): + """Base class for all Ansible DNAC package exceptions.""" + pass + + +class InconsistentParameters(AnsibleDNACException): + """Provided parameters are not consistent.""" + pass + + +class AnsibleSDAException(Exception): + def __init__(self, response): + self._response = response -- cgit v1.2.3