diff --git a/CHANGELOG.md b/CHANGELOG.md index 98ac9e77..84161010 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -143,10 +143,11 @@ ENHANCEMENTS: DOC FIXES: * **netapp-ontap_storage_flexcache_resource**: Fixed Page display issue ([[#271](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/271)]) * **netapp-ontap_networking_ip_interface_resource**: Include min version for metrics ([[#265](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/265)]) +* Fix the documentation: snapmirror and the description of other data source and resource ([[#330](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/330)]) BUG FIXES: -* **netapp-ontap_cluster_data_source: fix on nodes to show multiple elements ([#264](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/264)) -* **netapp-ontap_protocols_nfs_export_policy_resource: fix id error during the creation ([[#290](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/290)]) +* **netapp-ontap_cluster_data_source**: fix on nodes to show multiple elements ([#264](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/264)) +* **netapp-ontap_protocols_nfs_export_policy_resource**: fix id error during the creation ([[#290](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/290)]) ## 1.1.3 (2024-08-08) @@ -166,7 +167,7 @@ BUG FIXES: * corrected typos in the CHANGELOG. BUG FIXES: -* netapp-ontap_storage_flexcache_resource: Fixed junction_path bug ([#223](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/223)) +* **netapp-ontap_storage_flexcache_resource**: Fixed junction_path bug ([#223](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/223)) ## 1.1.1 (2024-05-15) @@ -252,9 +253,9 @@ BUG FIXES: ## 1.0.1 (2023-11-17) BUG FIXES: -* netapp-ontap_name_services_dns_resource: Fixed and Documented Import ([#63](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/63)) -* netapp-ontap_cluster_data_source, netapp-ontap_snapmirrors_data_source, netapp-ontap_networking_ip_route_resource and netapp-ontap_sotrage_volume_resource: Fix documentation ([#70](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/70)) -* netapp-ontap_name_services_ldap_resource: Fixed and Document with the version check and workflow ([#163](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/163)) +* **netapp-ontap_name_services_dns_resource**: Fixed and Documented Import ([#63](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/63)) +* **netapp-ontap_cluster_data_source**, **netapp-ontap_snapmirrors_data_source**, **netapp-ontap_networking_ip_route_resource** and **netapp-ontap_sotrage_volume_resource**: Fix documentation ([#70](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/70)) +* **netapp-ontap_name_services_ldap_resource**: Fixed and Document with the version check and workflow ([#163](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/163)) ## 1.0.0 (2023-11-06) diff --git a/docs/data-sources/cluster.md b/docs/data-sources/cluster.md index 11644de8..0538fd9b 100644 --- a/docs/data-sources/cluster.md +++ b/docs/data-sources/cluster.md @@ -6,8 +6,7 @@ description: |- Cluster data source --- -# netapp-ontap_cluster (Data Source) - +# Data Source cluster Retrieve the details of a cluster data source ### Related ONTAP commands diff --git a/docs/data-sources/cluster_licensing_license_data_source.md b/docs/data-sources/cluster_licensing_license_data_source.md index 31a8de3d..307b1653 100644 --- a/docs/data-sources/cluster_licensing_license_data_source.md +++ b/docs/data-sources/cluster_licensing_license_data_source.md @@ -5,13 +5,14 @@ description: |- ClusterLicensingLicense data source --- -# Netapp Ontap Cluster Licensing License Data Source +# Data Source cluster licensing license +Retrieves Cluster Licensing License ## Supported Platforms * On-perm ONTAP system 9.6 or higher * Amazon FSx for NetApp ONTAP -ClusterLicensingLicense data source + ## Example Usage ```terraform data "netapp-ontap_cluster_licensing_license" "cluster_licensing_license" { diff --git a/docs/data-sources/cluster_licensing_licenses_data_source.md b/docs/data-sources/cluster_licensing_licenses_data_source.md index 4a27dedd..8e37c5e6 100644 --- a/docs/data-sources/cluster_licensing_licenses_data_source.md +++ b/docs/data-sources/cluster_licensing_licenses_data_source.md @@ -5,13 +5,13 @@ description: |- ClusterLicensingLicenses data source --- -# Netapp Ontap Cluster Licensing Licenses Data Source +# Data Source cluster licensing licenses +Retrieves Cluster Licensing Licenses ## Supported Platforms * On-perm ONTAP system 9.6 or higher * Amazon FSx for NetApp ONTAP -ClusterLicensingLicenses data source ## Example Usage ```terraform data "netapp-ontap_cluster_licensing_licenses" "cluster_licensing_licenses" { diff --git a/docs/data-sources/cluster_peer_data_source.md b/docs/data-sources/cluster_peer_data_source.md index 023ca24f..9bcc68c7 100644 --- a/docs/data-sources/cluster_peer_data_source.md +++ b/docs/data-sources/cluster_peer_data_source.md @@ -6,8 +6,7 @@ description: |- ClusterPeer data source --- -# Data Source cluster_peer - +# Data Source cluster peer Retrieves an existing cluster_peer ## Supported Platforms diff --git a/docs/data-sources/cluster_peers_data_source.md b/docs/data-sources/cluster_peers_data_source.md index 0fc0c549..4000a22a 100644 --- a/docs/data-sources/cluster_peers_data_source.md +++ b/docs/data-sources/cluster_peers_data_source.md @@ -6,8 +6,7 @@ description: |- ClusterPeers data source --- -# Data Source cluster_peers - +# Data Source cluster peers Retrieves existing cluster_peers ## Supported Platforms diff --git a/docs/data-sources/cluster_schedule_data_source.md b/docs/data-sources/cluster_schedule_data_source.md index d235d884..40036dae 100644 --- a/docs/data-sources/cluster_schedule_data_source.md +++ b/docs/data-sources/cluster_schedule_data_source.md @@ -6,8 +6,7 @@ description: |- Retrieves Cluster Schedule configuration of SVMs. --- -# Data Source cluster_schedule - +# Data Source cluster schedule Retrieves Cluster Schedule configuration of SVMs. ## Supported Platforms diff --git a/docs/data-sources/cluster_schedules_data_source.md b/docs/data-sources/cluster_schedules_data_source.md index b66d3dbc..d98270d9 100644 --- a/docs/data-sources/cluster_schedules_data_source.md +++ b/docs/data-sources/cluster_schedules_data_source.md @@ -6,8 +6,7 @@ description: |- Retrieves list of Cluster Schedules configuration of SVMs. --- -# Data Source cluster_schedules - +# Data Source cluster schedules Retrieves list of Cluster Schedules configuration of SVMs. ## Supported Platforms diff --git a/docs/data-sources/name_services_dns_data_source.md b/docs/data-sources/name_services_dns_data_source.md index 2e37693a..c3718c46 100644 --- a/docs/data-sources/name_services_dns_data_source.md +++ b/docs/data-sources/name_services_dns_data_source.md @@ -5,8 +5,7 @@ description: |- Retrieves the DNS Configuration of an SVM. --- -# Data Source dns - +# Data Source DNS Retrieves the DNS Configuration of an SVM. ## Supported Platforms diff --git a/docs/data-sources/name_services_dnss_data_source.md b/docs/data-sources/name_services_dnss_data_source.md index 381fce6c..7ff1d8aa 100644 --- a/docs/data-sources/name_services_dnss_data_source.md +++ b/docs/data-sources/name_services_dnss_data_source.md @@ -5,8 +5,7 @@ description: |- Retrieves the DNSs Configuration of SVMs. --- -# Data Source dnss - +# Data Source DNSs Retrieves the DNSs Configuration of an SVMs. ## Supported Platforms diff --git a/docs/data-sources/name_services_ldap_data_source.md b/docs/data-sources/name_services_ldap_data_source.md index a92d12c8..6fcfe85b 100644 --- a/docs/data-sources/name_services_ldap_data_source.md +++ b/docs/data-sources/name_services_ldap_data_source.md @@ -6,9 +6,8 @@ description: |- Retrieve LDAP data source of a SVM --- -# Data source netapp-ontap_name_services_ldap - -Retrieve LDAP data source of a SVM +# Data Source name_services_ldap +Retrieves LDAP data source of a SVM ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/name_services_ldaps_data_source.md b/docs/data-sources/name_services_ldaps_data_source.md index 4bd72cda..11455ae6 100644 --- a/docs/data-sources/name_services_ldaps_data_source.md +++ b/docs/data-sources/name_services_ldaps_data_source.md @@ -6,9 +6,8 @@ description: |- Retrieve LDAP data source of SVMs --- -# netapp-ontap_name_services_ldaps (Data Source) - -Retrieve LDAP data source of SVMs +# Data Source name_services_ldaps +Retrieves LDAP data source of SVMs ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/networking_ip_interface_data_source.md b/docs/data-sources/networking_ip_interface_data_source.md index d958a66c..25f0da0c 100644 --- a/docs/data-sources/networking_ip_interface_data_source.md +++ b/docs/data-sources/networking_ip_interface_data_source.md @@ -7,7 +7,6 @@ description: |- --- # Data Source ip_interface - Retrieves the details of IP interface of SVMs. ## Supported Platforms diff --git a/docs/data-sources/networking_ip_interfaces_data_source.md b/docs/data-sources/networking_ip_interfaces_data_source.md index 92826fa2..7c7bf7a2 100644 --- a/docs/data-sources/networking_ip_interfaces_data_source.md +++ b/docs/data-sources/networking_ip_interfaces_data_source.md @@ -6,8 +6,7 @@ description: |- Retrieves the details of IP interfaces of SVMs. --- -# Data Source ip_interfaces - +# Data Source network_ip_interfaces Retrieves the details of IP interfaces of SVMs. ## Supported Platforms diff --git a/docs/data-sources/networking_ip_route_data_source.md b/docs/data-sources/networking_ip_route_data_source.md index 55faf5bc..08a582c3 100644 --- a/docs/data-sources/networking_ip_route_data_source.md +++ b/docs/data-sources/networking_ip_route_data_source.md @@ -6,8 +6,7 @@ description: |- Retrieves the IP route of SVMs. --- -# Data Source ip_route - +# Data Source network_ip_route Retrieves the IP route of SVMs. ## Supported Platforms diff --git a/docs/data-sources/networking_ip_routes_data_source.md b/docs/data-sources/networking_ip_routes_data_source.md index 072e1abf..28975bb3 100644 --- a/docs/data-sources/networking_ip_routes_data_source.md +++ b/docs/data-sources/networking_ip_routes_data_source.md @@ -6,8 +6,7 @@ description: |- Retrieves the IP routes of SVMs. --- -# Data Source ip_routes - +# Data Source network_ip_routes Retrieves the IP routes of SVMs. ## Supported Platforms diff --git a/docs/data-sources/protocols_cifs_local_group_data_source.md b/docs/data-sources/protocols_cifs_local_group_data_source.md index feeb7d50..df07a574 100644 --- a/docs/data-sources/protocols_cifs_local_group_data_source.md +++ b/docs/data-sources/protocols_cifs_local_group_data_source.md @@ -6,9 +6,8 @@ description: |- Retrieve CifsLocalGroup data source --- -# Data Source ontap_cifs_local_group - -Retrieves protocols cifs local group configuration +# Data Source cifs_local_group +Retrieves cifs local group configuration ## Supported Platforms * On-perm ONTAP system 9.10 or higher diff --git a/docs/data-sources/protocols_cifs_local_group_member_data_source.md b/docs/data-sources/protocols_cifs_local_group_member_data_source.md index 67db5334..ff39641c 100644 --- a/docs/data-sources/protocols_cifs_local_group_member_data_source.md +++ b/docs/data-sources/protocols_cifs_local_group_member_data_source.md @@ -6,9 +6,8 @@ description: |- Retrieve CifsLocalGroupMember data source --- -# Data source netapp-ontap_cifs_local_group_member - -Retreives protocols cifs local group member configuration +# Data Source cifs_local_group_member +Retreives cifs local group member configuration ## Supported Platforms * On-perm ONTAP system 9.10 or higher diff --git a/docs/data-sources/protocols_cifs_local_group_members_data_source.md b/docs/data-sources/protocols_cifs_local_group_members_data_source.md index 9e52c013..9ef9df55 100644 --- a/docs/data-sources/protocols_cifs_local_group_members_data_source.md +++ b/docs/data-sources/protocols_cifs_local_group_members_data_source.md @@ -6,9 +6,8 @@ description: |- Retrieve CifsLocalGroupMembers data source --- -# Data source netapp-ontap_cifs_local_group_members - -Retreives protocols cifs local group members configuration +# Data Source cifs_local_group_members +Retreives cifs local group members configuration ## Supported Platforms * On-perm ONTAP system 9.10 or higher diff --git a/docs/data-sources/protocols_cifs_local_groups_data_source.md b/docs/data-sources/protocols_cifs_local_groups_data_source.md index 975894ee..eb2c5d44 100644 --- a/docs/data-sources/protocols_cifs_local_groups_data_source.md +++ b/docs/data-sources/protocols_cifs_local_groups_data_source.md @@ -6,9 +6,8 @@ description: |- Retrieves list of Cifs Local Groups. --- -# Data Source protocols_cifs_local_groups - -Retrieves list of Cifs Local Groups. +# Data Source cifs_local_groups +Retrieves list of Cifs Local Groups ## Supported Platforms * On-perm ONTAP system 9.10 or higher diff --git a/docs/data-sources/protocols_cifs_local_user_data_source.md b/docs/data-sources/protocols_cifs_local_user_data_source.md index b9c2ebf5..51398221 100644 --- a/docs/data-sources/protocols_cifs_local_user_data_source.md +++ b/docs/data-sources/protocols_cifs_local_user_data_source.md @@ -6,9 +6,8 @@ description: |- Retrieve CifsLocalUser data source --- -# Data Source netapp-ontap_cifs_local_user - -Retreives protocols cifs local user configuration +# Data Source cifs_local_user +Retreives cifs local user configuration ## Supported Platforms * On-perm ONTAP system 9.10 or higher diff --git a/docs/data-sources/protocols_cifs_local_users_data_source.md b/docs/data-sources/protocols_cifs_local_users_data_source.md index d4330390..1e4250ad 100644 --- a/docs/data-sources/protocols_cifs_local_users_data_source.md +++ b/docs/data-sources/protocols_cifs_local_users_data_source.md @@ -6,9 +6,8 @@ description: |- Retrieves list of Cifs Local Users. --- -# Data Source protocols_cifs_local_users - -Retrieves a list of Cifs Local Users. +# Data Source cifs_local_users +Retrieves a list of Cifs Local Users ## Supported Platforms * On-perm ONTAP system 9.10 or higher diff --git a/docs/data-sources/protocols_cifs_service_data_source.md b/docs/data-sources/protocols_cifs_service_data_source.md index 8c002ae3..7211c69e 100644 --- a/docs/data-sources/protocols_cifs_service_data_source.md +++ b/docs/data-sources/protocols_cifs_service_data_source.md @@ -6,9 +6,8 @@ description: |- Retrieve Cifs Service data source --- -# Data Source netapp-ontap_cifs_service - -Retrieves protocols cifs service data source +# Data Source cifs_service +Retrieves cifs service data ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/protocols_cifs_services_data_source.md b/docs/data-sources/protocols_cifs_services_data_source.md index c873fa7b..5c511fdf 100644 --- a/docs/data-sources/protocols_cifs_services_data_source.md +++ b/docs/data-sources/protocols_cifs_services_data_source.md @@ -6,9 +6,8 @@ description: |- Retrieve Cifs Services data source --- -# Data Source netapp-ontap_cifs_services - -Retrieve Cifs Services data source +# Data Source cifs_services +Retrieve Cifs Services data ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/protocols_cifs_share_data_source.md b/docs/data-sources/protocols_cifs_share_data_source.md index 4b9e589f..800cc12d 100644 --- a/docs/data-sources/protocols_cifs_share_data_source.md +++ b/docs/data-sources/protocols_cifs_share_data_source.md @@ -6,8 +6,7 @@ description: |- ProtocolsCIFSShare data source --- -# netapp-ontap_cifs_share (Data Source) - +# Data Source cifs_share Retrieves the details of a cifs share ### Related ONTAP commands diff --git a/docs/data-sources/protocols_cifs_shares_data_source.md b/docs/data-sources/protocols_cifs_shares_data_source.md index 436fd134..d9a9d857 100644 --- a/docs/data-sources/protocols_cifs_shares_data_source.md +++ b/docs/data-sources/protocols_cifs_shares_data_source.md @@ -6,8 +6,7 @@ description: |- ProtocolsCIFSShares data source --- -# netapp-ontap_cifs_shares (Data Source) - +# Data Source cifs_shares Retrieves the details of one or more cifs shares by filter ### Related ONTAP commands diff --git a/docs/data-sources/protocols_cifs_user_group_privilege_data_source.md b/docs/data-sources/protocols_cifs_user_group_privilege_data_source.md index 6a4659ff..fd87cd30 100644 --- a/docs/data-sources/protocols_cifs_user_group_privilege_data_source.md +++ b/docs/data-sources/protocols_cifs_user_group_privilege_data_source.md @@ -6,9 +6,8 @@ description: |- Retrieve CifsUserGroupPrivilege data source --- -# Data Source netapp-ontap_cifs_user_group_privilege - -Retrieve Protocol Cifs User or Group Privilege data source +# Data Source cifs_user_group_privilege +Retrieves Protocol Cifs User or Group Privilege data source ## Supported Platforms * On-perm ONTAP system 9.10.1 or higher diff --git a/docs/data-sources/protocols_cifs_user_group_privileges_data_source.md b/docs/data-sources/protocols_cifs_user_group_privileges_data_source.md index a767d9cc..d443bf55 100644 --- a/docs/data-sources/protocols_cifs_user_group_privileges_data_source.md +++ b/docs/data-sources/protocols_cifs_user_group_privileges_data_source.md @@ -6,9 +6,8 @@ description: |- Retrieve CifsUserGroupPrivileges data source --- -# Data Source netapp-ontap_cifs_user_group_privileges () - -Retrieve Protocol Cifs User or Group Privileges data source +# Data Source cifs_user_group_privileges +Retrieves Cifs User or Group Privileges data source ## Supported Platforms * On-perm ONTAP system 9.10.1 or higher diff --git a/docs/data-sources/protocols_nfs_export_policies_data_source.md b/docs/data-sources/protocols_nfs_export_policies_data_source.md index be7f1992..7630121c 100644 --- a/docs/data-sources/protocols_nfs_export_policies_data_source.md +++ b/docs/data-sources/protocols_nfs_export_policies_data_source.md @@ -6,8 +6,7 @@ description: |- --- # Data source NFS Export Policies - -ExportPolicies data source +Retrieves nfs export policies ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/protocols_nfs_export_policy_data_source.md b/docs/data-sources/protocols_nfs_export_policy_data_source.md index 1f8abee7..52fab711 100644 --- a/docs/data-sources/protocols_nfs_export_policy_data_source.md +++ b/docs/data-sources/protocols_nfs_export_policy_data_source.md @@ -5,9 +5,8 @@ description: |- NFS Export Policy Data source --- -# Data source NFS Export Policy - -NFS Export Policy Data source +# Data Source NFS Export Policy +Retrieves NFS Export Policy Data source ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/protocols_nfs_export_policy_rule_data_source.md b/docs/data-sources/protocols_nfs_export_policy_rule_data_source.md index 9268a41d..d7ffcee6 100644 --- a/docs/data-sources/protocols_nfs_export_policy_rule_data_source.md +++ b/docs/data-sources/protocols_nfs_export_policy_rule_data_source.md @@ -6,8 +6,7 @@ description: |- Retrieves an export policy rule of SVMs --- -# Data Source protocols_nfs_export_policy_rule - +# Data Source nfs_export_policy_rule Retrieves an export policy rule of SVMs ## Supported Platforms diff --git a/docs/data-sources/protocols_nfs_export_policy_rules_data_source.md b/docs/data-sources/protocols_nfs_export_policy_rules_data_source.md index b2eb078e..0e7ee144 100644 --- a/docs/data-sources/protocols_nfs_export_policy_rules_data_source.md +++ b/docs/data-sources/protocols_nfs_export_policy_rules_data_source.md @@ -6,8 +6,7 @@ description: |- Retrieves an export policy rules of SVMs --- -# Data Source protocols_nfs_export_policy_rules - +# Data Source nfs_export_policy_rules Retrieves an export policy rules of SVMs ## Supported Platforms diff --git a/docs/data-sources/protocols_nfs_service_data_source.md b/docs/data-sources/protocols_nfs_service_data_source.md index 0088e171..00fd2cc9 100644 --- a/docs/data-sources/protocols_nfs_service_data_source.md +++ b/docs/data-sources/protocols_nfs_service_data_source.md @@ -6,7 +6,6 @@ description: |- --- # Data Source nfs_service - Retrieves the NFS configuration of SVMs. ## Supported Platforms diff --git a/docs/data-sources/protocols_nfs_services_data_source.md b/docs/data-sources/protocols_nfs_services_data_source.md index fe979b22..16c4de44 100644 --- a/docs/data-sources/protocols_nfs_services_data_source.md +++ b/docs/data-sources/protocols_nfs_services_data_source.md @@ -5,8 +5,7 @@ description: |- Retrieves list of NFSs configuration of SVMs. --- -# netapp-ontap_nfs_services (Data Source) - +# Data Source nfs_services Retrieves list of NFSs configuration of SVMs. ## Supported Platforms diff --git a/docs/data-sources/protocols_san_igroup_data_source.md b/docs/data-sources/protocols_san_igroup_data_source.md index 65714f9e..4f5cf521 100644 --- a/docs/data-sources/protocols_san_igroup_data_source.md +++ b/docs/data-sources/protocols_san_igroup_data_source.md @@ -7,8 +7,7 @@ description: |- --- # Data Source Protocols San Igroup - -Igroup data source +Retrieves Igroup data source ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/protocols_san_igroups_data_source.md b/docs/data-sources/protocols_san_igroups_data_source.md index a77cd467..d46d62a1 100644 --- a/docs/data-sources/protocols_san_igroups_data_source.md +++ b/docs/data-sources/protocols_san_igroups_data_source.md @@ -6,9 +6,8 @@ description: |- ProtocolsSanIgroups data source --- -# Data Source Protocols San Igroups - -Igroups data source +# Data Source San Igroups +Retrieves Igroups data source ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/protocols_san_lun-map_data_source.md b/docs/data-sources/protocols_san_lun-map_data_source.md index 9df3cdcf..9e187628 100644 --- a/docs/data-sources/protocols_san_lun-map_data_source.md +++ b/docs/data-sources/protocols_san_lun-map_data_source.md @@ -6,10 +6,8 @@ description: |- ProtocolsSanLunMap data source --- -# netapp-ontap_san_lun-map (Data Source) - -ProtocolsSanLunMap data source - +# Data Source san_lun-map +Retrieves Protocols San Lun Map data source ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/protocols_san_lun-maps_data_source.md b/docs/data-sources/protocols_san_lun-maps_data_source.md index 76274f99..7c0270f4 100644 --- a/docs/data-sources/protocols_san_lun-maps_data_source.md +++ b/docs/data-sources/protocols_san_lun-maps_data_source.md @@ -6,10 +6,8 @@ description: |- ProtocolsSanLunMaps data source --- -# netapp-ontap_san_lun-maps (Data Source) - -ProtocolsSanLunMaps data source - +# Data Source san_lun-maps +Retrieves San Lun Maps data source ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/security_account_data_source.md b/docs/data-sources/security_account_data_source.md index 0e17d171..6472d314 100644 --- a/docs/data-sources/security_account_data_source.md +++ b/docs/data-sources/security_account_data_source.md @@ -7,7 +7,6 @@ description: |- --- # Data Source Security_Account - Retrieves a ONTAP User ## Supported Platforms diff --git a/docs/data-sources/security_accounts_data_source.md b/docs/data-sources/security_accounts_data_source.md index 9374d3cd..50c95244 100644 --- a/docs/data-sources/security_accounts_data_source.md +++ b/docs/data-sources/security_accounts_data_source.md @@ -7,7 +7,6 @@ description: |- --- # Data Source Security Accounts - Retrieves the configuration of multiple user accounts ## Supported Platforms diff --git a/docs/data-sources/security_certificate.md b/docs/data-sources/security_certificate.md index 4dfa78bf..441dbe41 100644 --- a/docs/data-sources/security_certificate.md +++ b/docs/data-sources/security_certificate.md @@ -6,9 +6,8 @@ description: |- Retrieve Security Certificate data source --- -# netapp-ontap_security_certificate (Data Source) - -Retrieve Security Certificate data source +# Data Source security_certificate +Retrieves Security Certificate data source ### Related ONTAP commands * security certificate show diff --git a/docs/data-sources/security_certificates.md b/docs/data-sources/security_certificates.md index eb45e364..165f02d6 100644 --- a/docs/data-sources/security_certificates.md +++ b/docs/data-sources/security_certificates.md @@ -6,9 +6,8 @@ description: |- Retrieve Security Certificates data source --- -# netapp-ontap_security_certificates (Data Source) - -Retrieve Security Certificates data source +# Data Source security_certificates +Retrieves Security Certificates data source ### Related ONTAP commands * security certificate show diff --git a/docs/data-sources/security_login_message.md b/docs/data-sources/security_login_message.md index ceb711d4..8df1d358 100644 --- a/docs/data-sources/security_login_message.md +++ b/docs/data-sources/security_login_message.md @@ -6,8 +6,7 @@ description: |- Retrieve Security Login Message data source --- -# netapp-ontap_security_login_message (Data Source) - +# Data Source security_login_message Retrieve Security Login Message data source ## Supported Platforms diff --git a/docs/data-sources/security_login_messages.md b/docs/data-sources/security_login_messages.md index 76281538..70d3c9a6 100644 --- a/docs/data-sources/security_login_messages.md +++ b/docs/data-sources/security_login_messages.md @@ -6,9 +6,8 @@ description: |- Retrieve Security Login Messages data source --- -# netapp-ontap_security_login_messages (Data Source) - -Retrieve Security Login Messages data source +# Data Source security_login_messages +Retrieves Security Login Messages data source ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/security_role.md b/docs/data-sources/security_role.md index 07ff0e61..4cd5c4ef 100644 --- a/docs/data-sources/security_role.md +++ b/docs/data-sources/security_role.md @@ -6,9 +6,8 @@ description: |- SecurityRole data source --- -# netapp-ontap_security_role (Data Source) - -Retrieve a security role +# Data Source security_role +Retrieves a security role ### Related ONTAP commands ```commandline diff --git a/docs/data-sources/security_roles.md b/docs/data-sources/security_roles.md index 7f469ab0..badeba1f 100644 --- a/docs/data-sources/security_roles.md +++ b/docs/data-sources/security_roles.md @@ -6,9 +6,8 @@ description: |- SecurityRules data source --- -# netapp-ontap_security_roles (Data Source) - -Retreive one or more security roles by filter +# Data Source security_roles +Retreives one or more security roles by filter ### Related ONTAP commands ```commandline diff --git a/docs/data-sources/snapmirror_data_source.md b/docs/data-sources/snapmirror_data_source.md index 857e2076..93b9f84d 100644 --- a/docs/data-sources/snapmirror_data_source.md +++ b/docs/data-sources/snapmirror_data_source.md @@ -6,7 +6,6 @@ description: |- --- # Data Source snapmirror - Retrieves the snapmirror details ## Supported Platforms diff --git a/docs/data-sources/snapmirror_policies_data_source.md b/docs/data-sources/snapmirror_policies_data_source.md index 7007b427..beec9da0 100644 --- a/docs/data-sources/snapmirror_policies_data_source.md +++ b/docs/data-sources/snapmirror_policies_data_source.md @@ -6,7 +6,6 @@ description: |- --- # Data Source snapmirror_policies - Retrieves SnapMirror policies of SVMs. ## Supported Platforms diff --git a/docs/data-sources/snapmirror_policy_data_source.md b/docs/data-sources/snapmirror_policy_data_source.md index 24093177..d34079f8 100644 --- a/docs/data-sources/snapmirror_policy_data_source.md +++ b/docs/data-sources/snapmirror_policy_data_source.md @@ -6,7 +6,6 @@ description: |- --- # Data Source snapmirror_policy - Retrieves SnapMirror policy of SVMs. ## Supported Platforms diff --git a/docs/data-sources/snapmirrors_data_source.md b/docs/data-sources/snapmirrors_data_source.md index b439b6d6..f19c28ce 100644 --- a/docs/data-sources/snapmirrors_data_source.md +++ b/docs/data-sources/snapmirrors_data_source.md @@ -6,7 +6,6 @@ description: |- --- # Data Source snapmirrors - Retrieves list of the snapmirrors ## Supported Platforms diff --git a/docs/data-sources/storage_aggregate_data_source.md b/docs/data-sources/storage_aggregate_data_source.md index 0a486440..fd24e0b2 100644 --- a/docs/data-sources/storage_aggregate_data_source.md +++ b/docs/data-sources/storage_aggregate_data_source.md @@ -6,7 +6,6 @@ description: |- --- # Data Sources storage_aggregate - Retrieves the storage aggregation details of SVMs. ## Supported Platforms diff --git a/docs/data-sources/storage_aggregates_data_source.md b/docs/data-sources/storage_aggregates_data_source.md index af6f1bb8..e10169d8 100644 --- a/docs/data-sources/storage_aggregates_data_source.md +++ b/docs/data-sources/storage_aggregates_data_source.md @@ -6,7 +6,6 @@ description: |- --- # Data Sources storage_aggregates - Retrieves the storage aggregations details of SVMs. ## Supported Platforms diff --git a/docs/data-sources/storage_flexcache_data_source.md b/docs/data-sources/storage_flexcache_data_source.md index 7c6ff16c..8a73d565 100644 --- a/docs/data-sources/storage_flexcache_data_source.md +++ b/docs/data-sources/storage_flexcache_data_source.md @@ -6,8 +6,7 @@ description: |- Flexcache data source --- -# netapp-ontap_flexcache (Data Source) - +# Data Source flexcache Retrieves the details of a flexcache. ### Related ONTAP commands diff --git a/docs/data-sources/storage_flexcaches_data_source.md b/docs/data-sources/storage_flexcaches_data_source.md index ce8d73ce..b246d6f0 100644 --- a/docs/data-sources/storage_flexcaches_data_source.md +++ b/docs/data-sources/storage_flexcaches_data_source.md @@ -6,8 +6,7 @@ description: |- Flexcaches data source --- -# netapp-ontap_flexcaches (Data Source) - +# Data Source flexcaches Retrieves the details of one or more flexcaches by filter. ### Related ONTAP commands diff --git a/docs/data-sources/storage_lun_data_source.md b/docs/data-sources/storage_lun_data_source.md index 44f6db71..e2ec4bf7 100644 --- a/docs/data-sources/storage_lun_data_source.md +++ b/docs/data-sources/storage_lun_data_source.md @@ -7,7 +7,6 @@ description: |- --- # Data Source storage_lun - Retrieves existing single lun data ## Supported Platforms diff --git a/docs/data-sources/storage_luns_data_source.md b/docs/data-sources/storage_luns_data_source.md index 11d712be..d2e95c56 100644 --- a/docs/data-sources/storage_luns_data_source.md +++ b/docs/data-sources/storage_luns_data_source.md @@ -7,7 +7,6 @@ description: |- --- # Data Source Storage Luns - Retrieves existing Luns data ## Supported Platforms diff --git a/docs/data-sources/storage_qos_policies_data_source.md b/docs/data-sources/storage_qos_policies_data_source.md index 88cb9385..6754ef54 100644 --- a/docs/data-sources/storage_qos_policies_data_source.md +++ b/docs/data-sources/storage_qos_policies_data_source.md @@ -6,9 +6,8 @@ description: |- QOSPolicies data source --- -# netapp-ontap_qos_policies (Data Source) - -QOSPolicies data source +# Data Source qos_policies +Retrieves QOSPolicies data source ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/storage_qos_policy_data_source.md b/docs/data-sources/storage_qos_policy_data_source.md index 619e6249..b963632b 100644 --- a/docs/data-sources/storage_qos_policy_data_source.md +++ b/docs/data-sources/storage_qos_policy_data_source.md @@ -6,9 +6,8 @@ description: |- QOSPolicy data source --- -# netapp-ontap_qos_policy (Data Source) - -QOSPolicy data source +# Data Source qos_policy +Retrieves QOSPolicy data source ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/storage_qtree.md b/docs/data-sources/storage_qtree.md index 437064aa..a57c0aee 100644 --- a/docs/data-sources/storage_qtree.md +++ b/docs/data-sources/storage_qtree.md @@ -6,9 +6,8 @@ description: |- StorageQtree data source --- -# netapp-ontap_qtree (Data Source) - -Retreive a qtree +# Data Source qtree +Retreives a qtree ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/storage_qtrees.md b/docs/data-sources/storage_qtrees.md index db97e2df..5adb639b 100644 --- a/docs/data-sources/storage_qtrees.md +++ b/docs/data-sources/storage_qtrees.md @@ -6,9 +6,8 @@ description: |- StorageQtrees data source --- -# netapp-ontap_qtrees (Data Source) - -Retreive one or more qtrees by filter +# Data Source qtrees +Retreives one or more qtrees by filter ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/storage_quota_rule_data_source.md b/docs/data-sources/storage_quota_rule_data_source.md index 93a259b3..de16d436 100644 --- a/docs/data-sources/storage_quota_rule_data_source.md +++ b/docs/data-sources/storage_quota_rule_data_source.md @@ -6,9 +6,8 @@ description: |- QuotaRule data source --- -# netapp-ontap_quota_rule (Data Source) - -QuotaRule data source +# Data Source quota_rule +Retrieves QuotaRule data ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/storage_quota_rules_data_source.md b/docs/data-sources/storage_quota_rules_data_source.md index 415d9ede..51c73162 100644 --- a/docs/data-sources/storage_quota_rules_data_source.md +++ b/docs/data-sources/storage_quota_rules_data_source.md @@ -6,9 +6,8 @@ description: |- QuotaRules data source --- -# netapp-ontap_quota_rules (Data Source) - -QuotaRules data source +# Data Source quota_rules +Retrieves QuotaRules data ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/storage_snapshot_policies_data_source.md b/docs/data-sources/storage_snapshot_policies_data_source.md index 49db919e..bbad468c 100644 --- a/docs/data-sources/storage_snapshot_policies_data_source.md +++ b/docs/data-sources/storage_snapshot_policies_data_source.md @@ -5,9 +5,8 @@ description: |- Retrieves Snapshot Policies information --- -# NetApp Ontap snapshot policies data source - -Snapshot Policies data source +# Data Source snapshot policies +Retrieves Snapshot Policies data ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/storage_snapshot_policy_data_source.md b/docs/data-sources/storage_snapshot_policy_data_source.md index dcf6067e..2bfa86e4 100644 --- a/docs/data-sources/storage_snapshot_policy_data_source.md +++ b/docs/data-sources/storage_snapshot_policy_data_source.md @@ -5,9 +5,8 @@ description: |- Retrieves Snapshot Policy information --- -# NetApp Ontap snapshot policy data source - -Snapshot Policy data source +# Data Source snapshot policy +Retrieves Snapshot Policy data source ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/storage_volume_data_source.md b/docs/data-sources/storage_volume_data_source.md index 009ef37d..b3143112 100644 --- a/docs/data-sources/storage_volume_data_source.md +++ b/docs/data-sources/storage_volume_data_source.md @@ -7,7 +7,6 @@ description: |- --- # Data Source storage_volume - Retrieves an existing storage_volume ## Supported Platforms diff --git a/docs/data-sources/storage_volume_efficiency_policies.md b/docs/data-sources/storage_volume_efficiency_policies.md index 8f5e9bf0..c137275f 100644 --- a/docs/data-sources/storage_volume_efficiency_policies.md +++ b/docs/data-sources/storage_volume_efficiency_policies.md @@ -6,9 +6,8 @@ description: |- VolumeEfficiencyPolicies data source --- -# netapp-ontap_volume_efficiency_policies (Data Source) - -VolumeEfficiencyPolicies data source +# Data Source volume_efficiency_policies +Retrieves Volume Efficiency Policies data ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/storage_volume_efficiency_policy.md b/docs/data-sources/storage_volume_efficiency_policy.md index a9c4fd28..1feab509 100644 --- a/docs/data-sources/storage_volume_efficiency_policy.md +++ b/docs/data-sources/storage_volume_efficiency_policy.md @@ -6,9 +6,8 @@ description: |- VolumeEfficiencyPolicy data source --- -# netapp-ontap_volume_efficiency_policy (Data Source) - -VolumeEfficiencyPolicy data source +# Data Source volume_efficiency_policy +Retrieves Volume EfficiencyP olicy data ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/storage_volume_files_data_source.md b/docs/data-sources/storage_volume_files_data_source.md index 3fc94ea1..a9b435b5 100644 --- a/docs/data-sources/storage_volume_files_data_source.md +++ b/docs/data-sources/storage_volume_files_data_source.md @@ -6,8 +6,7 @@ description: |- Storage Volume Files data source --- -# netapp-ontap_volume_files (Data Source) - +# Data Source nvolume_files Retrieves an existing storage volume files ## Supported Platforms diff --git a/docs/data-sources/storage_volume_snapshot_data_source.md b/docs/data-sources/storage_volume_snapshot_data_source.md index a84c4fce..684f8ef8 100644 --- a/docs/data-sources/storage_volume_snapshot_data_source.md +++ b/docs/data-sources/storage_volume_snapshot_data_source.md @@ -6,8 +6,7 @@ description: |- Retrieves details of a specific volume Snapshot copy --- -# # Data Source snapshot - +# Data Source snapshot Retrieves details of a specific volume Snapshot copy ## Supported Platforms diff --git a/docs/data-sources/storage_volume_snapshots_data_source.md b/docs/data-sources/storage_volume_snapshots_data_source.md index c4a89577..db5f1dd4 100644 --- a/docs/data-sources/storage_volume_snapshots_data_source.md +++ b/docs/data-sources/storage_volume_snapshots_data_source.md @@ -7,7 +7,6 @@ description: |- --- # Data Source snapshots - Retrieves a collection of volume Snapshot copies ## Supported Platforms diff --git a/docs/data-sources/storage_volumes_data_source.md b/docs/data-sources/storage_volumes_data_source.md index 975e2212..5e5d6c98 100644 --- a/docs/data-sources/storage_volumes_data_source.md +++ b/docs/data-sources/storage_volumes_data_source.md @@ -6,8 +6,7 @@ description: |- StorageVolumes data source --- -# Data Source storage_volumes - +# Data Source volumes Retrieves existing storage_volumes ## Supported Platforms diff --git a/docs/data-sources/svm_data_source.md b/docs/data-sources/svm_data_source.md index 44f79f4c..c94f2212 100644 --- a/docs/data-sources/svm_data_source.md +++ b/docs/data-sources/svm_data_source.md @@ -7,8 +7,7 @@ description: |- --- # Data Source svm - -Retrieves the configuration of SVM. +Retrieves the configuration of SVM ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/svm_peer_data_source.md b/docs/data-sources/svm_peer_data_source.md index 1df8330b..3310233d 100644 --- a/docs/data-sources/svm_peer_data_source.md +++ b/docs/data-sources/svm_peer_data_source.md @@ -7,8 +7,7 @@ description: |- --- # Data Source svm peer - -Retrieves the configuration of SVM Peer. +Retrieves the configuration of SVM Peer ## Supported Platforms * On-perm ONTAP system 9.6 or higher diff --git a/docs/data-sources/svm_peers_data_source.md b/docs/data-sources/svm_peers_data_source.md index 9c43e487..d449ec74 100644 --- a/docs/data-sources/svm_peers_data_source.md +++ b/docs/data-sources/svm_peers_data_source.md @@ -7,7 +7,6 @@ description: |- --- # Data Source svm peer - Retrieves the configuration of SVM Peers. ## Supported Platforms diff --git a/docs/data-sources/svms_data_source.md b/docs/data-sources/svms_data_source.md index 8008ce21..236b89d2 100644 --- a/docs/data-sources/svms_data_source.md +++ b/docs/data-sources/svms_data_source.md @@ -7,7 +7,6 @@ description: |- --- # Data Source svms - Retrieves the configuration of SVMs. ## Supported Platforms diff --git a/docs/resources/cluster_licensing_license_resource.md b/docs/resources/cluster_licensing_license_resource.md index f1bc3461..557dd753 100644 --- a/docs/resources/cluster_licensing_license_resource.md +++ b/docs/resources/cluster_licensing_license_resource.md @@ -7,7 +7,6 @@ description: |- --- # Resource licensing_license - Add/Remove License from ONTAP ### Related ONTAP commands diff --git a/docs/resources/cluster_peer_resource.md b/docs/resources/cluster_peer_resource.md index db3769c8..3bfc3db2 100644 --- a/docs/resources/cluster_peer_resource.md +++ b/docs/resources/cluster_peer_resource.md @@ -6,7 +6,6 @@ description: |- --- # Resource Cluster Peer - Create/Modify/Delete a cluster peer. ### Related ONTAP commands diff --git a/docs/resources/cluster_resource.md b/docs/resources/cluster_resource.md index 0eef64da..dd47928d 100644 --- a/docs/resources/cluster_resource.md +++ b/docs/resources/cluster_resource.md @@ -6,8 +6,7 @@ description: |- cluster resource --- -# netapp-ontap_cluster (Resource) - +# Resource cluster Create/Update a Cluster resource ### Related ONTAP commands diff --git a/docs/resources/cluster_schedule_resource.md b/docs/resources/cluster_schedule_resource.md index bb413e79..63a05053 100644 --- a/docs/resources/cluster_schedule_resource.md +++ b/docs/resources/cluster_schedule_resource.md @@ -6,8 +6,7 @@ description: |- --- # Resource Cluster Schedule - -Create/Modify/Delete a job schedule in a cluster. +Create/Modify/Delete a job schedule in a cluster ### Related ONTAP commands ```commandline diff --git a/docs/resources/name_services_dns_resource.md b/docs/resources/name_services_dns_resource.md index 798c43e4..0a845173 100644 --- a/docs/resources/name_services_dns_resource.md +++ b/docs/resources/name_services_dns_resource.md @@ -7,7 +7,6 @@ description: |- --- # Resource DNS - Create/Modify/Delete and Import a name services DNS resource ### Related ONTAP commands diff --git a/docs/resources/name_services_ldap_resource.md b/docs/resources/name_services_ldap_resource.md index 4b623c4f..68feeb0e 100644 --- a/docs/resources/name_services_ldap_resource.md +++ b/docs/resources/name_services_ldap_resource.md @@ -7,7 +7,6 @@ description: |- --- # Resource name services LDAP - Create/Modify/Delete an LDAP configuration for an SVM ### Related ONTAP commands diff --git a/docs/resources/network_ip_interface_resource.md b/docs/resources/network_ip_interface_resource.md index b81a8864..b9e6aaaf 100644 --- a/docs/resources/network_ip_interface_resource.md +++ b/docs/resources/network_ip_interface_resource.md @@ -7,7 +7,6 @@ description: |- --- # Resource IP Interface - Create/Update/Delete an IPInterface resource ### Related ONTAP commands diff --git a/docs/resources/network_ip_route_resource.md b/docs/resources/network_ip_route_resource.md index 0aa83fad..8a23caf8 100644 --- a/docs/resources/network_ip_route_resource.md +++ b/docs/resources/network_ip_route_resource.md @@ -7,7 +7,6 @@ description: |- --- # Resource IP Route - Create/Delete an IP Route resource ### Related ONTAP commands diff --git a/docs/resources/protocols_cifs_local_group_members_resource.md b/docs/resources/protocols_cifs_local_group_members_resource.md index 3d61285a..251ddd93 100644 --- a/docs/resources/protocols_cifs_local_group_members_resource.md +++ b/docs/resources/protocols_cifs_local_group_members_resource.md @@ -7,7 +7,6 @@ description: |- --- # Resource Protocols Cifs Local Group Mmembers - Create/Read/Delete one or more members in a local group resource ~> **NOTE:** This module does not support members modification diff --git a/docs/resources/protocols_cifs_local_group_resource.md b/docs/resources/protocols_cifs_local_group_resource.md index a7aded79..5e04c98c 100644 --- a/docs/resources/protocols_cifs_local_group_resource.md +++ b/docs/resources/protocols_cifs_local_group_resource.md @@ -7,7 +7,6 @@ description: |- --- # Resource Local Group - Create/Modify/Delete a Local Group resource ### Related ONTAP commands diff --git a/docs/resources/protocols_cifs_local_user_resource.md b/docs/resources/protocols_cifs_local_user_resource.md index f9b41070..d91fde94 100644 --- a/docs/resources/protocols_cifs_local_user_resource.md +++ b/docs/resources/protocols_cifs_local_user_resource.md @@ -7,7 +7,6 @@ description: |- --- # Resource Local User - Create/Modify/Delete a Local User resource ### Related ONTAP commands diff --git a/docs/resources/protocols_cifs_service_resource.md b/docs/resources/protocols_cifs_service_resource.md index 0b5b896a..430508db 100644 --- a/docs/resources/protocols_cifs_service_resource.md +++ b/docs/resources/protocols_cifs_service_resource.md @@ -6,8 +6,7 @@ description: |- CifsService resource --- -# netapp-ontap_cifs_service (Resource) - +# Resource cifs_service Create/Modify/Delete a CIFS service resource ### Related ONTAP commands diff --git a/docs/resources/protocols_cifs_share_resource.md b/docs/resources/protocols_cifs_share_resource.md index cec9044f..d7cac64a 100644 --- a/docs/resources/protocols_cifs_share_resource.md +++ b/docs/resources/protocols_cifs_share_resource.md @@ -6,8 +6,7 @@ description: |- ProtocolsCIFSShare resource --- -# netapp-ontap_cifs_share (Resource) - +# Resource cifs_share Create/Modify/Delete a protocols cifs share resource ### Related ONTAP commands diff --git a/docs/resources/protocols_nfs_export_policy_resource.md b/docs/resources/protocols_nfs_export_policy_resource.md index 60b1cba7..d466138e 100644 --- a/docs/resources/protocols_nfs_export_policy_resource.md +++ b/docs/resources/protocols_nfs_export_policy_resource.md @@ -5,7 +5,6 @@ description: |- Export policy resource --- # Protocols NFS Export Policy Resource - Create/Modify/Delete an Export policy resource ### Related ONTAP commands diff --git a/docs/resources/protocols_nfs_export_policy_rule_resource.md b/docs/resources/protocols_nfs_export_policy_rule_resource.md index 1d267841..728f59c8 100644 --- a/docs/resources/protocols_nfs_export_policy_rule_resource.md +++ b/docs/resources/protocols_nfs_export_policy_rule_resource.md @@ -6,8 +6,7 @@ description: |- --- # Protocols NFS Export Policy Rule Resource - -Export policy rule resource +Create/modify/delete an export policy rule ### Related ONTAP commands ```commandline diff --git a/docs/resources/protocols_nfs_service_resource.md b/docs/resources/protocols_nfs_service_resource.md index e17e0e8f..eeb5019a 100644 --- a/docs/resources/protocols_nfs_service_resource.md +++ b/docs/resources/protocols_nfs_service_resource.md @@ -6,7 +6,6 @@ description: |- --- # Resource NFS Service - Create/Modify/Delete an NFS Configuration of a SVM. ### Related ONTAP commands diff --git a/docs/resources/protocols_san_igroup_resource.md b/docs/resources/protocols_san_igroup_resource.md index 180986ba..81d17125 100644 --- a/docs/resources/protocols_san_igroup_resource.md +++ b/docs/resources/protocols_san_igroup_resource.md @@ -6,8 +6,7 @@ description: |- ProtocolsSanIgroup resource --- -# netapp-ontap_san_igroup (Resource) - +# Resource san_igroup Create/Modify/Delete a protocols_san_igroup resource ### Related ONTAP commands diff --git a/docs/resources/protocols_san_lun-map_resource.md b/docs/resources/protocols_san_lun-map_resource.md index 71a74684..b0205d80 100644 --- a/docs/resources/protocols_san_lun-map_resource.md +++ b/docs/resources/protocols_san_lun-map_resource.md @@ -6,8 +6,7 @@ description: |- ProtocolsSanLunMap resource --- -# netapp-ontap_san_lun-map (Resource) - +# Resource san_lun-map Create/Delete a protocols_san_lun-map resource ### Related ONTAP commands diff --git a/docs/resources/security_account_resource.md b/docs/resources/security_account_resource.md index 396c378a..f70b1dc4 100644 --- a/docs/resources/security_account_resource.md +++ b/docs/resources/security_account_resource.md @@ -7,7 +7,6 @@ description: |- --- # Resource Security Account - Create/Modify/Delete a ONTAP user account ### Related ONTAP commands diff --git a/docs/resources/security_login_message.md b/docs/resources/security_login_message.md index cfd3b47c..930615f5 100644 --- a/docs/resources/security_login_message.md +++ b/docs/resources/security_login_message.md @@ -7,7 +7,6 @@ description: |- --- # Resource security login message - Update/Import Security Login Message The `security_login_message` resource does not support creation or deletion operations. Users must first import the existing resource and then perform updates as needed. diff --git a/docs/resources/security_roles.md b/docs/resources/security_roles.md index 1d10a450..6d37ada7 100644 --- a/docs/resources/security_roles.md +++ b/docs/resources/security_roles.md @@ -6,8 +6,7 @@ description: |- SecurityRoles resource --- -# netapp-ontap_security_roles (Resource) - +# Resource security_roles Create/Modify/Delete a Security role ## Supported Platforms diff --git a/docs/resources/snapmirror_policy_resource.md b/docs/resources/snapmirror_policy_resource.md index a4f3104f..819f163f 100644 --- a/docs/resources/snapmirror_policy_resource.md +++ b/docs/resources/snapmirror_policy_resource.md @@ -7,7 +7,6 @@ description: |- --- # Resource Snapmirror Policy - Create/Modify/Delete a snapmirror policy resource ### Related ONTAP commands diff --git a/docs/resources/snapmirror_resource.md b/docs/resources/snapmirror_resource.md index c1135672..4f5bb3ec 100644 --- a/docs/resources/snapmirror_resource.md +++ b/docs/resources/snapmirror_resource.md @@ -7,7 +7,6 @@ description: |- --- # Resource Snapmirror - Create/Modify/Delete a snapmirror resource ### Related ONTAP commands @@ -21,8 +20,6 @@ Create/Modify/Delete a snapmirror resource * On-perm ONTAP system 9.6 or higher * Amazon FSx for NetApp ONTAP -~> **NOTE:** Amazon FSx for NetApp ONTAP is not supported - ## Example Usage ``` # Create a snapmirror diff --git a/docs/resources/storage_aggregate_resource.md b/docs/resources/storage_aggregate_resource.md index cb961f1f..3b9bc10b 100644 --- a/docs/resources/storage_aggregate_resource.md +++ b/docs/resources/storage_aggregate_resource.md @@ -6,7 +6,6 @@ description: |- --- # Resource Storage Aggregate - Create/Modify/Delete an aggregate resource ### Related ONTAP commands diff --git a/docs/resources/storage_flexcache_resource.md b/docs/resources/storage_flexcache_resource.md index 02fca32c..b1e0f3d4 100644 --- a/docs/resources/storage_flexcache_resource.md +++ b/docs/resources/storage_flexcache_resource.md @@ -6,9 +6,8 @@ description: |- Flexcache resource --- -# netapp-ontap_flexcache (Resource) - -Flexcache resource +# Resource flexcache +Create/Delete Flexcache resource ### Related ONTAP commands ```commandline diff --git a/docs/resources/storage_lun_resource.md b/docs/resources/storage_lun_resource.md index 21fb077a..f03008a5 100644 --- a/docs/resources/storage_lun_resource.md +++ b/docs/resources/storage_lun_resource.md @@ -7,7 +7,6 @@ description: |- --- # Resource Storage Lun - Create/Modify/Delete a lun resource ### Related ONTAP commands diff --git a/docs/resources/storage_qos_policy_resource.md b/docs/resources/storage_qos_policy_resource.md index 831aa42a..e208eeb3 100644 --- a/docs/resources/storage_qos_policy_resource.md +++ b/docs/resources/storage_qos_policy_resource.md @@ -6,8 +6,7 @@ description: |- QOSPolicy resource --- -# netapp-ontap_qos_policy (Resource) - +# Resource qos_policy Create/Modify/Delete a QOSPolicy resource ### Related ONTAP commands diff --git a/docs/resources/storage_qtree.md b/docs/resources/storage_qtree.md index e0078ccc..a9b331d0 100644 --- a/docs/resources/storage_qtree.md +++ b/docs/resources/storage_qtree.md @@ -6,8 +6,7 @@ description: |- Qtree resource --- -# netapp-ontap_qtree (Resource) - +# Resource qtree Create/modify/delete a storage qtree ### Related ONTAP commands diff --git a/docs/resources/storage_quota_rule_resource.md b/docs/resources/storage_quota_rule_resource.md index efe4e52c..96771ba0 100644 --- a/docs/resources/storage_quota_rule_resource.md +++ b/docs/resources/storage_quota_rule_resource.md @@ -7,7 +7,6 @@ description: |- --- # Resource Quota Rule - Create/Modify/Delete a quota rule resource ### Related ONTAP commands diff --git a/docs/resources/storage_snapshot_policy_resource.md b/docs/resources/storage_snapshot_policy_resource.md index 84ec7142..7e4d2950 100644 --- a/docs/resources/storage_snapshot_policy_resource.md +++ b/docs/resources/storage_snapshot_policy_resource.md @@ -6,7 +6,6 @@ description: |- --- # Resource Snapshot Policy - Create/Modify/Delete a SnapshotPolicy resource ### Related ONTAP commands diff --git a/docs/resources/storage_volume_efficiency_policy.md b/docs/resources/storage_volume_efficiency_policy.md index f005defd..c4c14859 100644 --- a/docs/resources/storage_volume_efficiency_policy.md +++ b/docs/resources/storage_volume_efficiency_policy.md @@ -6,8 +6,7 @@ description: |- VolumeEfficiencyPolicy resource --- -# netapp-ontap_volume_efficiency_policy (Resource) - +# Resource volume_efficiency_policy Create/Modify/Delete a VolumeEfficiencyPolicy resource ### Related ONTAP commands diff --git a/docs/resources/storage_volume_file_resource.md b/docs/resources/storage_volume_file_resource.md index 2569004a..bbb73df0 100644 --- a/docs/resources/storage_volume_file_resource.md +++ b/docs/resources/storage_volume_file_resource.md @@ -6,8 +6,7 @@ description: |- VolumeFile resource --- -# netapp-ontap_volume_file (Resource) - +# Resource volume_file Create/Modify/Delete a VolumeFile resource ## Supported Platforms diff --git a/docs/resources/storage_volume_resource.md b/docs/resources/storage_volume_resource.md index cf716ef8..0382b6cc 100644 --- a/docs/resources/storage_volume_resource.md +++ b/docs/resources/storage_volume_resource.md @@ -6,8 +6,7 @@ description: |- Volume resource --- -# netapp-ontap_volume (Resource) - +# Resource volume Create/modify/delete a Volume resource ### Related ONTAP commands @@ -21,8 +20,6 @@ Create/modify/delete a Volume resource * On-perm ONTAP system 9.6 or higher * Amazon FSx for NetApp ONTAP -[comment]: <> (TODO: Add support for Amazon FSx for NetApp ONTAP ) - ## Example Usage ```terraform diff --git a/docs/resources/storage_volume_snapshot_resource.md b/docs/resources/storage_volume_snapshot_resource.md index e4372f2c..ea12e1c0 100644 --- a/docs/resources/storage_volume_snapshot_resource.md +++ b/docs/resources/storage_volume_snapshot_resource.md @@ -7,7 +7,6 @@ description: |- --- # Resource Volume Snapshot - Create/Modify/Delete a Snapshot resource ### Related ONTAP commands diff --git a/docs/resources/svm_peer_resource.md b/docs/resources/svm_peer_resource.md index dfaa795d..bc58bc9d 100644 --- a/docs/resources/svm_peer_resource.md +++ b/docs/resources/svm_peer_resource.md @@ -7,7 +7,6 @@ description: |- --- # Resource SVMPeer - Create/Modify/Delete a SVMPeer ### Related ONTAP commands diff --git a/docs/resources/svm_resource.md b/docs/resources/svm_resource.md index 0955ee53..215469f0 100644 --- a/docs/resources/svm_resource.md +++ b/docs/resources/svm_resource.md @@ -7,7 +7,6 @@ description: |- --- # Resource SVM - Create/Modify/Delete a SVM ### Related ONTAP commands diff --git a/internal/provider/cluster/cluster_data_source.go b/internal/provider/cluster/cluster_data_source.go index 95a28e34..eab034dc 100644 --- a/internal/provider/cluster/cluster_data_source.go +++ b/internal/provider/cluster/cluster_data_source.go @@ -28,6 +28,15 @@ func NewClusterDataSource() datasource.DataSource { } } +// NewClusterDataSourceAlias is a helper function to simplify the provider implementation. +func NewClusterDataSourceAlias() datasource.DataSource { + return &ClusterDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "cluster_data_source", + }, + } +} + // ClusterDataSource defines the data source implementation. // //nolint:golint diff --git a/internal/provider/cluster/cluster_licensing_license_alias_test.go b/internal/provider/cluster/cluster_licensing_license_alias_test.go new file mode 100644 index 00000000..d9ce73db --- /dev/null +++ b/internal/provider/cluster/cluster_licensing_license_alias_test.go @@ -0,0 +1,69 @@ +package cluster_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" +) + +func TestLicensingLicenseResouceAlias(t *testing.T) { + testLicense := os.Getenv("TF_ACC_NETAPP_LICENSE") + name := "FCP" + credName := "cluster4" + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccLicensingLicenseResourceConfigAlias("testme"), + ExpectError: regexp.MustCompile("1115159"), + }, + { + Config: testAccLicensingLicenseResourceConfigAlias(testLicense), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_cluster_licensing_license_resource.cluster_licensing_license", "name", "insight_balance")), + }, + // Test importing a resource + { + ResourceName: "netapp-ontap_cluster_licensing_license_resource.cluster_licensing_license", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s", name, credName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_cluster_licensing_license_resource.cluster_licensing_license", "name", "insight_balance")), + }, + }, + }) +} + +func testAccLicensingLicenseResourceConfigAlias(key string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_cluster_licensing_license_resource" "cluster_licensing_license" { + # required to know which system to interface with + cx_profile_name = "cluster4" + keys = ["%s"] +} +`, host, admin, password, key) +} diff --git a/internal/provider/cluster/cluster_licensing_license_data_source.go b/internal/provider/cluster/cluster_licensing_license_data_source.go index dac83263..69c4f273 100644 --- a/internal/provider/cluster/cluster_licensing_license_data_source.go +++ b/internal/provider/cluster/cluster_licensing_license_data_source.go @@ -3,6 +3,7 @@ package cluster import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewClusterLicensingLicenseDataSource() datasource.DataSource { } } +// NewClusterLicensingLicenseDataSourceAlias is a helper function to simplify the provider implementation. +func NewClusterLicensingLicenseDataSourceAlias() datasource.DataSource { + return &ClusterLicensingLicenseDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "cluster_licensing_license_data_source", + }, + } +} + // ClusterLicensingLicenseDataSource defines the data source implementation. type ClusterLicensingLicenseDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/cluster/cluster_licensing_license_resource.go b/internal/provider/cluster/cluster_licensing_license_resource.go index dc2e89bf..b2a9f57f 100644 --- a/internal/provider/cluster/cluster_licensing_license_resource.go +++ b/internal/provider/cluster/cluster_licensing_license_resource.go @@ -3,9 +3,10 @@ package cluster import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strings" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" @@ -29,6 +30,15 @@ func NewClusterLicensingLicenseResource() resource.Resource { } } +// NewClusterLicensingLicenseResourceAlias is a helper function to simplify the provider implementation. +func NewClusterLicensingLicenseResourceAlias() resource.Resource { + return &ClusterLicensingLicenseResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "cluster_licensing_license_resource", + }, + } +} + // ClusterLicensingLicenseResource defines the resource implementation. type ClusterLicensingLicenseResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/cluster/cluster_licensing_license_test.go b/internal/provider/cluster/cluster_licensing_license_test.go index d665e292..59b0cc6a 100644 --- a/internal/provider/cluster/cluster_licensing_license_test.go +++ b/internal/provider/cluster/cluster_licensing_license_test.go @@ -2,11 +2,12 @@ package cluster_test import ( "fmt" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" "os" "regexp" "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" ) func TestLicensingLicenseResouce(t *testing.T) { diff --git a/internal/provider/cluster/cluster_licensing_licenses_data_source.go b/internal/provider/cluster/cluster_licensing_licenses_data_source.go index fcb51df2..6f9d7a02 100644 --- a/internal/provider/cluster/cluster_licensing_licenses_data_source.go +++ b/internal/provider/cluster/cluster_licensing_licenses_data_source.go @@ -3,6 +3,7 @@ package cluster import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewClusterLicensingLicensesDataSource() datasource.DataSource { } } +// NewClusterLicensingLicensesDataSourceAlias is a helper function to simplify the provider implementation. +func NewClusterLicensingLicensesDataSourceAlias() datasource.DataSource { + return &ClusterLicensingLicensesDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "cluster_licensing_licenses_data_source", + }, + } +} + // ClusterLicensingLicensesDataSource defines the data source implementation. type ClusterLicensingLicensesDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/cluster/cluster_peer_data_source.go b/internal/provider/cluster/cluster_peer_data_source.go index a20d4bd4..9d63271c 100644 --- a/internal/provider/cluster/cluster_peer_data_source.go +++ b/internal/provider/cluster/cluster_peer_data_source.go @@ -3,6 +3,7 @@ package cluster import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewClusterPeerDataSource() datasource.DataSource { } } +// NewClusterPeerDataSourceAlias is a helper function to simplify the provider implementation. +func NewClusterPeerDataSourceAlias() datasource.DataSource { + return &ClusterPeerDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "cluster_peer_data_source", + }, + } +} + // ClusterPeerDataSource defines the data source implementation. type ClusterPeerDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/cluster/cluster_peer_resource.go b/internal/provider/cluster/cluster_peer_resource.go index 5733d22e..c82a031e 100644 --- a/internal/provider/cluster/cluster_peer_resource.go +++ b/internal/provider/cluster/cluster_peer_resource.go @@ -34,6 +34,15 @@ func NewClusterPeerResource() resource.Resource { } } +// NewClusterPeerResourceAlias is a helper function to simplify the provider implementation. +func NewClusterPeerResourceAlias() resource.Resource { + return &ClusterPeersResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "cluster_peers_resource", + }, + } +} + // ClusterPeersResource defines the resource implementation. type ClusterPeersResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/cluster/cluster_peer_resource_alias_test.go b/internal/provider/cluster/cluster_peer_resource_alias_test.go new file mode 100644 index 00000000..337374a9 --- /dev/null +++ b/internal/provider/cluster/cluster_peer_resource_alias_test.go @@ -0,0 +1,86 @@ +package cluster_test + +import ( + "fmt" + "os" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccClusterPeerResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create svm peer and read + { + Config: testAccClusterPeerResourceConfigAlias("10.193.180.110", "10.193.176.189"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_cluster_peers_resource.example", "remote.ip_addresses.0", "10.193.180.110"), + ), + }, + // Update applications + { + Config: testAccClusterPeerResourceConfigAlias("10.193.180.109", "10.193.176.189"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_cluster_peers_resource.example", "remote.ip_addresses.0", "10.193.180.109"), + ), + }, + // Import and read + { + ResourceName: "netapp-ontap_cluster_peers_resource.example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s", "acc_test_cluster2", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_cluster_peers_resource.example", "name", "acc_test_cluster2"), + ), + }, + }, + }) +} +func testAccClusterPeerResourceConfigAlias(remotIP, sourceIP string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST2") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + password2 := os.Getenv("TF_ACC_NETAPP_PASS2") + host2 := os.Getenv("TF_ACC_NETAPP_HOST") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST2, TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, TF_ACC_NETAPP_PASS and TF_ACC_NETAPP_PASS2 must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + { + name = "cluster3" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_cluster_peers_resource" "example" { + cx_profile_name = "cluster4" + remote = { + ip_addresses = ["%s"] + } + source_details = { + ip_addresses = ["%s"] + } + peer_cx_profile_name = "cluster3" + passphrase = "12345678" + peer_applications = ["snapmirror"] +}`, host, admin, password2, host2, admin, password, remotIP, sourceIP) +} diff --git a/internal/provider/cluster/cluster_peers_data_source.go b/internal/provider/cluster/cluster_peers_data_source.go index 72ad3974..f874b2aa 100644 --- a/internal/provider/cluster/cluster_peers_data_source.go +++ b/internal/provider/cluster/cluster_peers_data_source.go @@ -3,6 +3,7 @@ package cluster import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewClusterPeersDataSource() datasource.DataSource { } } +// NewClusterPeersDataSourceAlias is a helper function to simplify the provider implementation. +func NewClusterPeersDataSourceAlias() datasource.DataSource { + return &ClusterPeersDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "cluster_peers_data_source", + }, + } +} + // ClusterPeersDataSource defines the data source implementation. type ClusterPeersDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/cluster/cluster_resource.go b/internal/provider/cluster/cluster_resource.go index 15d7e1d7..03d1d2b0 100644 --- a/internal/provider/cluster/cluster_resource.go +++ b/internal/provider/cluster/cluster_resource.go @@ -3,10 +3,11 @@ package cluster import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "log" "strings" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" @@ -35,6 +36,15 @@ func NewClusterResource() resource.Resource { } } +// NewClusterResourceAlias is a helper function to simplify the provider implementation. +func NewClusterResourceAlias() resource.Resource { + return &ClusterResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "cluster_resource", + }, + } +} + // ClusterResource defines the resource implementation. type ClusterResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/cluster/cluster_schedule_data_source.go b/internal/provider/cluster/cluster_schedule_data_source.go index e5ab6d57..6f9e8484 100644 --- a/internal/provider/cluster/cluster_schedule_data_source.go +++ b/internal/provider/cluster/cluster_schedule_data_source.go @@ -3,6 +3,7 @@ package cluster import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewClusterScheduleDataSource() datasource.DataSource { } } +// NewClusterScheduleDataSourceAlias is a helper function to simplify the provider implementation. +func NewClusterScheduleDataSourceAlias() datasource.DataSource { + return &ClusterScheduleDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "cluster_schedule_data_source", + }, + } +} + // ClusterScheduleDataSource defines the data source implementation. type ClusterScheduleDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/cluster/cluster_schedule_resource.go b/internal/provider/cluster/cluster_schedule_resource.go index caaa05e4..c8b97955 100644 --- a/internal/provider/cluster/cluster_schedule_resource.go +++ b/internal/provider/cluster/cluster_schedule_resource.go @@ -3,9 +3,10 @@ package cluster import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strings" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" @@ -33,6 +34,15 @@ func NewClusterScheduleResource() resource.Resource { } } +// NewClusterScheduleResourceAlias is a helper function to simplify the provider implementation. +func NewClusterScheduleResourceAlias() resource.Resource { + return &ClusterScheduleResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "cluster_schedule_resource", + }, + } +} + // ClusterScheduleResource defines the resource implementation. type ClusterScheduleResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/cluster/cluster_schedule_resource_alias_test.go b/internal/provider/cluster/cluster_schedule_resource_alias_test.go new file mode 100644 index 00000000..c1caff08 --- /dev/null +++ b/internal/provider/cluster/cluster_schedule_resource_alias_test.go @@ -0,0 +1,176 @@ +package cluster_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccClusterScheduleResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Test create interval schedule error + { + Config: testAccClusterScheduleResourceIntervalConfigAlias("non-existant", "wrongvalue"), + ExpectError: regexp.MustCompile("error creating cluster_schedule"), + }, + // Create interval and read + { + Config: testAccClusterScheduleResourceIntervalConfigAlias("tf-interval-schedule-test", "PT8M30S"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_cluster_schedule_resource.example", "name", "tf-interval-schedule-test"), + resource.TestCheckResourceAttr("netapp-ontap_cluster_schedule_resource.example", "interval", "PT8M30S"), + ), + }, + // update and read + { + Config: testAccClusterScheduleResourceIntervalConfigAlias("tf-interval-schedule-test", "PT8M20S"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_cluster_schedule_resource.example", "name", "tf-interval-schedule-test"), + resource.TestCheckResourceAttr("netapp-ontap_cluster_schedule_resource.example", "interval", "PT8M20S"), + ), + }, + // Test importing a interval job schedule resource + { + ResourceName: "netapp-ontap_cluster_schedule_resource.example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s", "tf-interval-schedule-test", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_cluster_schedule_resource.example", "name", "tf-interval-schedule-test"), + resource.TestCheckResourceAttr("netapp-ontap_cluster_schedule_resource.example", "interval", "PT8M20S"), + ), + }, + // Create cron schedule and read + { + Config: testAccClusterScheduleCreateResourceCronConfigAlias("tf-cron-schedule-test"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_cluster_schedule_resource.cron-example", "name", "tf-cron-schedule-test"), + ), + }, + // Update cron schedule and read + { + Config: testAccClusterScheduleUpdateResourceCronConfigAlias("tf-cron-schedule-test"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_cluster_schedule_resource.cron-example", "name", "tf-cron-schedule-test"), + ), + }, + // Test importing a cron job schedule resource + { + ResourceName: "netapp-ontap_cluster_schedule_resource.cron-example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s", "tf-cron-schedule-test", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_cluster_schedule_resource.cron-example", "name", "tf-cron-schedule-test"), + resource.TestCheckResourceAttr("netapp-ontap_cluster_schedule_resource.cron-example", "cron.days.0", "2"), + resource.TestCheckResourceAttr("netapp-ontap_cluster_schedule_resource.cron-example", "cron.weekdays.2", "4"), + ), + }, + }, + }) +} + +func testAccClusterScheduleResourceIntervalConfigAlias(name string, interval string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_cluster_schedule_resource" "example" { + # required to know which system to interface with + cx_profile_name = "cluster4" + name = "%s" + interval = "%s" +}`, host, admin, password, name, interval) +} + +func testAccClusterScheduleCreateResourceCronConfigAlias(name string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_cluster_schedule_resource" "cron-example" { + # required to know which system to interface with + cx_profile_name = "cluster4" + name = "%s" + cron = { + minutes = [1, 2, 3, 4] + hours = [10] + days = [1, 2] + months = [6, 7] + weekdays = [1, 3, 4] + } +}`, host, admin, password, name) +} + +func testAccClusterScheduleUpdateResourceCronConfigAlias(name string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_cluster_schedule_resource" "cron-example" { + # required to know which system to interface with + cx_profile_name = "cluster4" + name = "%s" + cron = { + minutes = [4, 5, 6] + hours = [2, 3] + days = [2] + months = [1, 6, 7] + weekdays = [3, 4, 5] + } +}`, host, admin, password, name) +} diff --git a/internal/provider/cluster/cluster_schedules_data_source.go b/internal/provider/cluster/cluster_schedules_data_source.go index 94d3a51c..cc2ae641 100644 --- a/internal/provider/cluster/cluster_schedules_data_source.go +++ b/internal/provider/cluster/cluster_schedules_data_source.go @@ -3,6 +3,7 @@ package cluster import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewClusterSchedulesDataSource() datasource.DataSource { } } +// NewClusterSchedulesDataSourceAlias is a helper function to simplify the provider implementation. +func NewClusterSchedulesDataSourceAlias() datasource.DataSource { + return &ClusterSchedulesDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "cluster_schedules_data_source", + }, + } +} + // ClusterSchedulesDataSource defines the data source implementation. type ClusterSchedulesDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/name_services/name_services_dns_data_source.go b/internal/provider/name_services/name_services_dns_data_source.go index d9e82856..ed80eff6 100644 --- a/internal/provider/name_services/name_services_dns_data_source.go +++ b/internal/provider/name_services/name_services_dns_data_source.go @@ -26,6 +26,15 @@ func NewNameServicesDNSDataSource() datasource.DataSource { } } +// NewNameServicesDNSDataSourceAlias is a helper function to simplify the provider implementation. +func NewNameServicesDNSDataSourceAlias() datasource.DataSource { + return &NameServicesDNSDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "name_services_dns_data_source", + }, + } +} + // NameServicesDNSDataSource defines the data source implementation. type NameServicesDNSDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/name_services/name_services_dns_resource.go b/internal/provider/name_services/name_services_dns_resource.go index 42b154f1..77ff79a6 100644 --- a/internal/provider/name_services/name_services_dns_resource.go +++ b/internal/provider/name_services/name_services_dns_resource.go @@ -32,6 +32,15 @@ func NewNameServicesDNSResource() resource.Resource { } } +// NewNameServicesDNSResourceAlias is a helper function to simplify the provider implementation. +func NewNameServicesDNSResourceAlias() resource.Resource { + return &NameServicesDNSResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "name_services_dns_resource", + }, + } +} + // NameServicesDNSResource defines the resource implementation. type NameServicesDNSResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/name_services/name_services_dns_resource_alias_test.go b/internal/provider/name_services/name_services_dns_resource_alias_test.go new file mode 100644 index 00000000..d2dd03e0 --- /dev/null +++ b/internal/provider/name_services/name_services_dns_resource_alias_test.go @@ -0,0 +1,75 @@ +package name_services_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" +) + +func TestAccNameServicesDNSResourceAlias(t *testing.T) { + svmName := "ansibleSVM" + credName := "cluster4" + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // non-existant SVM return code 2621462. Must happen before create/read + { + Config: testAccNameServicesDNSResourceConfigAlias("non-existant"), + ExpectError: regexp.MustCompile("2621462"), + }, + { + Config: testAccNameServicesDNSResourceConfigAlias("svm5"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_name_services_dns_resource.dns", "svm_name", "svm5"), + ), + }, + // Test importing a resource + { + ResourceName: "netapp-ontap_name_services_dns_resource.dns", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s", svmName, credName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_name_services_dns_resource.dns", "svm_name", "ansibleSVM"), + resource.TestCheckResourceAttr("netapp-ontap_name_services_dns_resource.dns", "name_servers.0", "netappad.com"), + ), + }, + }, + }) +} + +func testAccNameServicesDNSResourceConfigAlias(svmName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_name_services_dns_resource" "dns" { + # required to know which system to interface with + cx_profile_name = "cluster4" + svm_name = "%s" + name_servers = ["1.1.1.1", "2.2.2.2"] + dns_domains = ["foo.bar.com", "boo.bar.com"] + skip_config_validation = true +} +`, host, admin, password, svmName) +} diff --git a/internal/provider/name_services/name_services_dnss_data_source.go b/internal/provider/name_services/name_services_dnss_data_source.go index d9ce9748..2bf6a54d 100644 --- a/internal/provider/name_services/name_services_dnss_data_source.go +++ b/internal/provider/name_services/name_services_dnss_data_source.go @@ -26,6 +26,15 @@ func NewNameServicesDNSsDataSource() datasource.DataSource { } } +// NewNameServicesDNSsDataSourceAlias is a helper function to simplify the provider implementation. +func NewNameServicesDNSsDataSourceAlias() datasource.DataSource { + return &NameServicesDNSsDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "name_services_dnss_data_source", + }, + } +} + // NameServicesDNSsDataSource defines the data source implementation. type NameServicesDNSsDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/name_services/name_services_ldap_data_source.go b/internal/provider/name_services/name_services_ldap_data_source.go index 4f7e9f60..2dccb7e2 100644 --- a/internal/provider/name_services/name_services_ldap_data_source.go +++ b/internal/provider/name_services/name_services_ldap_data_source.go @@ -3,6 +3,7 @@ package name_services import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewNameServicesLDAPDataSource() datasource.DataSource { } } +// NewNameServicesLDAPDataSourceAlias is a helper function to simplify the provider implementation. +func NewNameServicesLDAPDataSourceAlias() datasource.DataSource { + return &NameServicesLDAPDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "name_services_ldap_data_source", + }, + } +} + // NameServicesLDAPDataSource defines the data source implementation. type NameServicesLDAPDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/name_services/name_services_ldap_resource.go b/internal/provider/name_services/name_services_ldap_resource.go index b5e75398..d3c23136 100644 --- a/internal/provider/name_services/name_services_ldap_resource.go +++ b/internal/provider/name_services/name_services_ldap_resource.go @@ -35,6 +35,15 @@ func NewNameServicesLDAPResource() resource.Resource { } } +// NewNameServicesLDAPResourceAlias is a helper function to simplify the provider implementation. +func NewNameServicesLDAPResourceAlias() resource.Resource { + return &NameServicesLDAPResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "name_services_ldap_resource", + }, + } +} + // NameServicesLDAPResource defines the resource implementation. type NameServicesLDAPResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/name_services/name_services_ldap_resource_alias_test.go b/internal/provider/name_services/name_services_ldap_resource_alias_test.go new file mode 100644 index 00000000..be26cdf5 --- /dev/null +++ b/internal/provider/name_services/name_services_ldap_resource_alias_test.go @@ -0,0 +1,86 @@ +package name_services_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccNameServicesLDAPResourceAlias(t *testing.T) { + svmName := "accsvm" + credName := "cluster4" + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // non-existant SVM return code 2621462. Must happen before create/read + { + Config: testAccNameServicesLDAPResourceConfigAlias("non-existant", "subtree"), + ExpectError: regexp.MustCompile("2621462"), + }, + // Test create + { + Config: testAccNameServicesLDAPResourceConfigAlias("svm1", "subtree"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_name_services_ldap_resource.name_services_ldap", "svm_name", "svm1"), + resource.TestCheckResourceAttr("netapp-ontap_name_services_ldap_resource.name_services_ldap", "servers.0", "1.1.1.1"), + ), + }, + // Test update + { + Config: testAccNameServicesLDAPResourceConfigAlias("svm1", "base"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_name_services_ldap_resource.name_services_ldap", "svm_name", "svm1"), + resource.TestCheckResourceAttr("netapp-ontap_name_services_ldap_resource.name_services_ldap", "base_scope", "base"), + ), + }, + // Test importing a resource + { + ResourceName: "netapp-ontap_name_services_ldap_resource.name_services_ldap", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s", svmName, credName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_name_services_ldap_resource.name_services_ldap", "svm_name", svmName), + resource.TestCheckResourceAttr("netapp-ontap_name_services_ldap_resource.name_services_ldap", "servers.0", "acc1.test.com"), + ), + }, + }, + }) +} + +func testAccNameServicesLDAPResourceConfigAlias(svmName string, baseScope string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_name_services_ldap_resource" "name_services_ldap" { + # required to know which system to interface with + cx_profile_name = "cluster4" + svm_name = "%s" + servers = ["1.1.1.1", "2.2.2.2"] + base_scope = "%s" + skip_config_validation = true +} +`, host, admin, password, svmName, baseScope) +} diff --git a/internal/provider/name_services/name_services_ldaps_data_source.go b/internal/provider/name_services/name_services_ldaps_data_source.go index 279d7950..4a47bd66 100644 --- a/internal/provider/name_services/name_services_ldaps_data_source.go +++ b/internal/provider/name_services/name_services_ldaps_data_source.go @@ -3,6 +3,7 @@ package name_services import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewNameServicesLDAPsDataSource() datasource.DataSource { } } +// NewNameServicesLDAPsDataSourceAlias is a helper function to simplify the provider implementation. +func NewNameServicesLDAPsDataSourceAlias() datasource.DataSource { + return &NameServicesLDAPsDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "name_services_ldaps_data_source", + }, + } +} + // NameServicesLDAPsDataSource defines the data source implementation. type NameServicesLDAPsDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/networking/network_ip_interface_data_source.go b/internal/provider/networking/network_ip_interface_data_source.go index 95c93b3b..ac9460be 100644 --- a/internal/provider/networking/network_ip_interface_data_source.go +++ b/internal/provider/networking/network_ip_interface_data_source.go @@ -27,6 +27,15 @@ func NewIPInterfaceDataSource() datasource.DataSource { } } +// NewIPInterfaceDataSourceAlias is a helper function to simplify the provider implementation. +func NewIPInterfaceDataSourceAlias() datasource.DataSource { + return &IPInterfaceDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "networking_ip_interface_data_source", + }, + } +} + // IPInterfaceDataSource defines the data source implementation. type IPInterfaceDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/networking/network_ip_interface_resource.go b/internal/provider/networking/network_ip_interface_resource.go index 907cef08..5755f342 100644 --- a/internal/provider/networking/network_ip_interface_resource.go +++ b/internal/provider/networking/network_ip_interface_resource.go @@ -32,6 +32,15 @@ func NewIPInterfaceResource() resource.Resource { } } +// NewIPInterfaceResourceAlias is a helper function to simplify the provider implementation. +func NewIPInterfaceResourceAlias() resource.Resource { + return &IPInterfaceResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "networking_ip_interface_resource", + }, + } +} + // IPInterfaceResource defines the resource implementation. type IPInterfaceResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/networking/network_ip_interface_resource_alias_test.go b/internal/provider/networking/network_ip_interface_resource_alias_test.go new file mode 100644 index 00000000..797e220c --- /dev/null +++ b/internal/provider/networking/network_ip_interface_resource_alias_test.go @@ -0,0 +1,94 @@ +package networking_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccNetworkIpInterfaceResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // non-existant SVM return code 2621462. Must happen before create/read + { + Config: testAccNetworkIPInterfaceResourceConfigAlias("non-existant", "10.10.10.10", "ontap_cluster_1-01"), + ExpectError: regexp.MustCompile("2621462"), + }, + // non-existant home node + { + Config: testAccNetworkIPInterfaceResourceConfigAlias("svm0", "10.10.10.10", "non-existant_home_node"), + ExpectError: regexp.MustCompile("393271"), + }, + // Create and Read + { + Config: testAccNetworkIPInterfaceResourceConfigAlias("svm0", "10.10.10.10", "ontap_cluster_1-01"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_networking_ip_interface_resource.example", "name", "test-interface"), + resource.TestCheckResourceAttr("netapp-ontap_networking_ip_interface_resource.example", "svm_name", "svm0"), + ), + }, + // Update and Read + { + Config: testAccNetworkIPInterfaceResourceConfigAlias("svm0", "10.10.10.20", "ontap_cluster_1-01"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_networking_ip_interface_resource.example", "name", "test-interface"), + resource.TestCheckResourceAttr("netapp-ontap_networking_ip_interface_resource.example", "ip.address", "10.10.10.20"), + ), + }, + // Test importing a resource + { + ResourceName: "netapp-ontap_networking_ip_interface_resource.example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s,%s", "test-interface", "svm0", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_networking_ip_interface_resource.example", "name", "test-interface"), + resource.TestCheckResourceAttr("netapp-ontap_networking_ip_interface_resource.example", "ip.address", "10.10.10.20"), + ), + }, + }, + }) +} + +func testAccNetworkIPInterfaceResourceConfigAlias(svmName, address, homeNode string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_networking_ip_interface_resource" "example" { + cx_profile_name = "cluster4" + name = "test-interface" + svm_name = "%s" + ip = { + address = "%s" + netmask = 18 + } + location = { + home_port = "e0d" + home_node = "%s" + } +} +`, host, admin, password, svmName, address, homeNode) +} diff --git a/internal/provider/networking/network_ip_interfaces_data_source.go b/internal/provider/networking/network_ip_interfaces_data_source.go index 2ad3e291..09eb4402 100644 --- a/internal/provider/networking/network_ip_interfaces_data_source.go +++ b/internal/provider/networking/network_ip_interfaces_data_source.go @@ -27,6 +27,15 @@ func NewIPInterfacesDataSource() datasource.DataSource { } } +// NewIPInterfacesDataSourceAlias is a helper function to simplify the provider implementation. +func NewIPInterfacesDataSourceAlias() datasource.DataSource { + return &IPInterfacesDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "networking_ip_interfaces_data_source", + }, + } +} + // IPInterfacesDataSource defines the data source implementation. type IPInterfacesDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/networking/network_ip_route_data_source.go b/internal/provider/networking/network_ip_route_data_source.go index 9e1ea554..0968d68a 100644 --- a/internal/provider/networking/network_ip_route_data_source.go +++ b/internal/provider/networking/network_ip_route_data_source.go @@ -26,6 +26,15 @@ func NewIPRouteDataSource() datasource.DataSource { } } +// NewIPRouteDataSourceAlias is a helper function to simplify the provider implementation. +func NewIPRouteDataSourceAlias() datasource.DataSource { + return &IPRouteDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "networking_ip_route_data_source", + }, + } +} + // IPRouteDataSource defines the data source implementation. type IPRouteDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/networking/network_ip_route_resource.go b/internal/provider/networking/network_ip_route_resource.go index 3e4da86e..99b18196 100644 --- a/internal/provider/networking/network_ip_route_resource.go +++ b/internal/provider/networking/network_ip_route_resource.go @@ -38,6 +38,15 @@ func NewIPRouteResource() resource.Resource { } } +// NewIPRouteResourceAlias is a helper function to simplify the provider implementation. +func NewIPRouteResourceAlias() resource.Resource { + return &IPRouteResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "networking_ip_route_resource", + }, + } +} + // IPRouteResource defines the resource implementation. type IPRouteResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/networking/network_ip_route_resource_alias_test.go b/internal/provider/networking/network_ip_route_resource_alias_test.go new file mode 100644 index 00000000..0c82b5d2 --- /dev/null +++ b/internal/provider/networking/network_ip_route_resource_alias_test.go @@ -0,0 +1,148 @@ +package networking_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccNetworkIpRouteResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing Required argument + { + Config: testAccNetworkIPIRouteResourceConfigAliasMissingVars("non-existent"), + ExpectError: regexp.MustCompile("Missing required argument"), + }, + // Non existent SVM + { + Config: testAccNetworkIPIRouteResourceConfigAlias("non-existent"), + ExpectError: regexp.MustCompile("2621462"), + }, + // Test create with no gateway + { + Config: testAccNetworkIPIRouteResourceConfigAlias("ansibleSVM"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_networking_ip_route_resource.example", "svm_name", "ansibleSVM"), + resource.TestCheckResourceAttr("netapp-ontap_networking_ip_route_resource.example", "destination.address", "0.0.0.0"), + resource.TestCheckResourceAttr("netapp-ontap_networking_ip_route_resource.example", "destination.netmask", "0"), + ), + }, + // test create with a gateway + { + Config: testAccNetworkIPIRouteResourceWithGatewayConfigAlias("ansibleSVM", "10.10.10.254", 20), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_networking_ip_route_resource.example", "svm_name", "ansibleSVM"), + resource.TestCheckResourceAttr("netapp-ontap_networking_ip_route_resource.example", "destination.address", "10.10.10.254"), + resource.TestCheckResourceAttr("netapp-ontap_networking_ip_route_resource.example", "destination.netmask", "20"), + ), + }, + // Import and read + { + ResourceName: "netapp-ontap_networking_ip_route_resource.example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s,%s", "carchi-test", "10.10.10.254", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_networking_ip_route_resource.example", "svm_name", "carchi-test"), + ), + }, + }, + }) +} + +func testAccNetworkIPIRouteResourceConfigAlias(svmName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_networking_ip_route_resource" "example" { + cx_profile_name = "cluster4" + svm_name = "%s" + gateway = "10.10.10.1" +} +`, host, admin, password, svmName) +} + +func testAccNetworkIPIRouteResourceWithGatewayConfigAlias(svmName string, address string, netmask int) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_networking_ip_route_resource" "example" { + cx_profile_name = "cluster4" + svm_name = "%s" + gateway = "10.10.10.1" + destination = { + address = "%s" + netmask = %d + } +} +`, host, admin, password, svmName, address, netmask) +} + +func testAccNetworkIPIRouteResourceConfigAliasMissingVars(svmName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_networking_ip_route_resource" "example" { + cx_profile_name = "cluster4" + svm_name = "%s" +} +`, host, admin, password, svmName) +} diff --git a/internal/provider/networking/network_ip_routes_data_source.go b/internal/provider/networking/network_ip_routes_data_source.go index 5f3dcdc4..d8741fc7 100644 --- a/internal/provider/networking/network_ip_routes_data_source.go +++ b/internal/provider/networking/network_ip_routes_data_source.go @@ -26,6 +26,15 @@ func NewIPRoutesDataSource() datasource.DataSource { } } +// NewIPRoutesDataSourceAlias is a helper function to simplify the provider implementation. +func NewIPRoutesDataSourceAlias() datasource.DataSource { + return &IPRoutesDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "networking_ip_routes_data_source", + }, + } +} + // IPRoutesDataSource defines the data source implementation. type IPRoutesDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_local_group_data_source.go b/internal/provider/protocols/protocols_cifs_local_group_data_source.go index d3126d71..660a4ee5 100644 --- a/internal/provider/protocols/protocols_cifs_local_group_data_source.go +++ b/internal/provider/protocols/protocols_cifs_local_group_data_source.go @@ -3,6 +3,7 @@ package protocols import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewCifsLocalGroupDataSource() datasource.DataSource { } } +// NewCifsLocalGroupDataSourceAlias is a helper function to simplify the provider implementation. +func NewCifsLocalGroupDataSourceAlias() datasource.DataSource { + return &CifsLocalGroupDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_cifs_local_group_data_source", + }, + } +} + // CifsLocalGroupDataSource defines the data source implementation. type CifsLocalGroupDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_local_group_member_data_source.go b/internal/provider/protocols/protocols_cifs_local_group_member_data_source.go index 2b12f7c4..e7fa3a7d 100644 --- a/internal/provider/protocols/protocols_cifs_local_group_member_data_source.go +++ b/internal/provider/protocols/protocols_cifs_local_group_member_data_source.go @@ -3,6 +3,7 @@ package protocols import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewCifsLocalGroupMemberDataSource() datasource.DataSource { } } +// NewCifsLocalGroupMemberDataSourceAlias is a helper function to simplify the provider implementation. +func NewCifsLocalGroupMemberDataSourceAlias() datasource.DataSource { + return &CifsLocalGroupMemberDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_cifs_local_group_member_data_source", + }, + } +} + // CifsLocalGroupMemberDataSource defines the data source implementation. type CifsLocalGroupMemberDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_local_group_members_data_source.go b/internal/provider/protocols/protocols_cifs_local_group_members_data_source.go index 471484af..9b402525 100644 --- a/internal/provider/protocols/protocols_cifs_local_group_members_data_source.go +++ b/internal/provider/protocols/protocols_cifs_local_group_members_data_source.go @@ -3,6 +3,7 @@ package protocols import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewCifsLocalGroupMembersDataSource() datasource.DataSource { } } +// NewCifsLocalGroupMembersDataSourceAlias is a helper function to simplify the provider implementation. +func NewCifsLocalGroupMembersDataSourceAlias() datasource.DataSource { + return &CifsLocalGroupMembersDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_cifs_local_group_members_data_source", + }, + } +} + // CifsLocalGroupMembersDataSource defines the data source implementation. type CifsLocalGroupMembersDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_local_group_members_resource.go b/internal/provider/protocols/protocols_cifs_local_group_members_resource.go index 8c79214c..12eaae3b 100644 --- a/internal/provider/protocols/protocols_cifs_local_group_members_resource.go +++ b/internal/provider/protocols/protocols_cifs_local_group_members_resource.go @@ -34,6 +34,15 @@ func NewCifsLocalGroupMembersResource() resource.Resource { } } +// NewCifsLocalGroupMembersResourceAlias is a helper function to simplify the provider implementation. +func NewCifsLocalGroupMembersResourceAlias() resource.Resource { + return &CifsLocalGroupMemberResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_cifs_local_group_member_resource", + }, + } +} + // CifsLocalGroupMemberResource defines the resource implementation. type CifsLocalGroupMemberResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_local_group_members_resource_alias_test.go b/internal/provider/protocols/protocols_cifs_local_group_members_resource_alias_test.go new file mode 100644 index 00000000..3292ea85 --- /dev/null +++ b/internal/provider/protocols/protocols_cifs_local_group_members_resource_alias_test.go @@ -0,0 +1,92 @@ +package protocols_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccCifsLocalGroupMembersResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccCifsLocalGroupMembersResourceConfigAliasMissingVars("non-existant"), + ExpectError: regexp.MustCompile("Missing required argument"), + }, + // create with basic argument on a local group member + { + // configuration of group name and memmber name have to be double \ otherwise it will be treated as escape character + Config: testAccCifsLocalGroupMembersResourceConfigAlias("svm3", "SVM3_SERVER\\\\accgroup1", "SVM3_SERVER\\\\accuser3"), + Check: resource.ComposeTestCheckFunc( + // check member + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_local_group_member_resource.example1", "member", "SVM3_SERVER\\accuser3"), + // check group_name + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_local_group_member_resource.example1", "group_name", "SVM3_SERVER\\accgroup1"), + // check svm_name + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_local_group_member_resource.example1", "svm_name", "svm3"), + // check ID + resource.TestCheckResourceAttrSet("netapp-ontap_protocols_cifs_local_group_member_resource.example1", "id"), + ), + }, + // Test importing a resource + { + ResourceName: "netapp-ontap_protocols_cifs_local_group_member_resource.example1", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s,%s,%s", "SVM3_SERVER\\accuser3", "SVM3_SERVER\\accgroup1", "svm3", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_local_group_member_resource.example1", "svm_name", "svm3"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_local_group_member_resource.example1", "group_name", "SVM3_SERVER\\accgroup1"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_local_group_member_resource.example1", "member", "SVM3_SERVER\\accuser3"), + // check id + resource.TestCheckResourceAttrSet("netapp-ontap_protocols_cifs_local_group_member_resource.example1", "id"), + ), + }, + }, + }) +} + +func testAccCifsLocalGroupMembersResourceConfigAliasMissingVars(svmName string) string { + return fmt.Sprintf(` +resource "netapp-ontap_protocols_cifs_local_group_member_resource" "example1" { + svm_name = "%s" + group_name = "SVM3_SERVER\\accgroup1" + member = "SVM3_SERVER\\accuser3" +} +`, svmName) +} + +func testAccCifsLocalGroupMembersResourceConfigAlias(svmName, groupName, member string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] + } +resource "netapp-ontap_protocols_cifs_local_group_member_resource" "example1" { + cx_profile_name = "cluster4" + svm_name = "%s" + group_name = "%s" + member = "%s" +} +`, host, admin, password, svmName, groupName, member) +} diff --git a/internal/provider/protocols/protocols_cifs_local_group_resource.go b/internal/provider/protocols/protocols_cifs_local_group_resource.go index f947a21f..740d85ba 100644 --- a/internal/provider/protocols/protocols_cifs_local_group_resource.go +++ b/internal/provider/protocols/protocols_cifs_local_group_resource.go @@ -3,9 +3,10 @@ package protocols import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strings" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -32,6 +33,15 @@ func NewCifsLocalGroupResource() resource.Resource { } } +// NewCifsLocalGroupResourceAlias is a helper function to simplify the provider implementation. +func NewCifsLocalGroupResourceAlias() resource.Resource { + return &CifsLocalGroupResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_cifs_local_group_resource", + }, + } +} + // CifsLocalGroupResource defines the resource implementation. type CifsLocalGroupResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_local_group_resource_alias_test.go b/internal/provider/protocols/protocols_cifs_local_group_resource_alias_test.go new file mode 100644 index 00000000..edc52551 --- /dev/null +++ b/internal/provider/protocols/protocols_cifs_local_group_resource_alias_test.go @@ -0,0 +1,115 @@ +package protocols_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccCifsLocalGroupResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccCifsLocalGroupResourceConfigAliasMissingVars("non-existant"), + ExpectError: regexp.MustCompile("Missing required argument"), + }, + // create with basic argument + { + Config: testAccCifsLocalGroupResourceConfigAlias("ansibleSVM", "group1"), + Check: resource.ComposeTestCheckFunc( + // check name + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_local_group_resource.example1", "name", "group1"), + // check svm_name + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_local_group_resource.example1", "svm_name", "ansibleSVM"), + // check ID + resource.TestCheckResourceAttrSet("netapp-ontap_protocols_cifs_local_group_resource.example1", "id"), + ), + }, + // update test + { + Config: testAccCifsLocalGroupResourceConfigAlias("ansibleSVM", "newgroup"), + Check: resource.ComposeTestCheckFunc( + // check renamed group name + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_local_group_resource.example1", "name", "newgroup"), + // check id + resource.TestCheckResourceAttrSet("netapp-ontap_protocols_cifs_local_group_resource.example1", "id")), + }, + // Test importing a resource + { + ResourceName: "netapp-ontap_protocols_cifs_local_group_resource.example1", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s,%s", "Administrators", "ansibleSVM", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_local_group_resource.example1", "svm_name", "ansibleSVM"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_local_group_resource.example1", "name", "Administrators"), + resource.TestMatchResourceAttr("netapp-ontap_protocols_nfs_export_policy_rule.example1", "description", regexp.MustCompile(`Built-in Administrators`)), + // check id + resource.TestCheckResourceAttrSet("netapp-ontap_protocols_cifs_local_group_resource.example1", "id"), + ), + }, + }, + }) +} + +func testAccCifsLocalGroupResourceConfigAliasMissingVars(svmName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_protocols_cifs_local_group_resource" "example1" { + cx_profile_name = "cluster4" + svm_name = "%s" +} +`, host, admin, password, svmName) +} + +func testAccCifsLocalGroupResourceConfigAlias(svmName string, groupName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} +resource "netapp-ontap_protocols_cifs_local_group_resource" "example1" { + cx_profile_name = "cluster4" + svm_name = "%s" + name = "%s" +} +`, host, admin, password, svmName, groupName) +} diff --git a/internal/provider/protocols/protocols_cifs_local_groups_data_source.go b/internal/provider/protocols/protocols_cifs_local_groups_data_source.go index d6739d42..2e06dda2 100644 --- a/internal/provider/protocols/protocols_cifs_local_groups_data_source.go +++ b/internal/provider/protocols/protocols_cifs_local_groups_data_source.go @@ -3,6 +3,7 @@ package protocols import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewCifsLocalGroupsDataSource() datasource.DataSource { } } +// NewCifsLocalGroupsDataSourceAlias is a helper function to simplify the provider implementation. +func NewCifsLocalGroupsDataSourceAlias() datasource.DataSource { + return &CifsLocalGroupsDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_cifs_local_groups_data_source", + }, + } +} + // CifsLocalGroupsDataSource defines the data source implementation. type CifsLocalGroupsDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_local_user_data_source.go b/internal/provider/protocols/protocols_cifs_local_user_data_source.go index 1d8328cc..1e5bdafd 100644 --- a/internal/provider/protocols/protocols_cifs_local_user_data_source.go +++ b/internal/provider/protocols/protocols_cifs_local_user_data_source.go @@ -25,6 +25,15 @@ func NewCifsLocalUserDataSource() datasource.DataSource { } } +// NewCifsLocalUserDataSourceAlias is a helper function to simplify the provider implementation. +func NewCifsLocalUserDataSourceAlias() datasource.DataSource { + return &CifsLocalUserDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_cifs_local_user_data_source", + }, + } +} + // CifsLocalUserDataSource defines the data source implementation. type CifsLocalUserDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_local_user_resource.go b/internal/provider/protocols/protocols_cifs_local_user_resource.go index 478c77c2..e53f2326 100644 --- a/internal/provider/protocols/protocols_cifs_local_user_resource.go +++ b/internal/provider/protocols/protocols_cifs_local_user_resource.go @@ -3,9 +3,10 @@ package protocols import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strings" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -33,6 +34,15 @@ func NewCifsLocalUserResource() resource.Resource { } } +// NewCifsLocalUserResourcAlias is a helper function to simplify the provider implementation. +func NewCifsLocalUserResourcAlias() resource.Resource { + return &CifsLocalUserResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_cifs_local_user_resource", + }, + } +} + // CifsLocalUserResource defines the resource implementation. type CifsLocalUserResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_local_user_resource_alias_test.go b/internal/provider/protocols/protocols_cifs_local_user_resource_alias_test.go new file mode 100644 index 00000000..4164618f --- /dev/null +++ b/internal/provider/protocols/protocols_cifs_local_user_resource_alias_test.go @@ -0,0 +1,117 @@ +package protocols_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccCifsLocalUserResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccCifsLocalUserResourceConfigAliasMissingVars("non-existant"), + ExpectError: regexp.MustCompile("Missing required argument"), + }, + // create with basic argument + { + Config: testAccCifsLocalUserResourceConfigAlias("ansibleSVM", "user1"), + Check: resource.ComposeTestCheckFunc( + // check name + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_local_user_resource.example1", "name", "user1"), + // check svm_name + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_local_user_resource.example1", "svm_name", "ansibleSVM"), + // check ID + resource.TestCheckResourceAttrSet("netapp-ontap_protocols_cifs_local_user_resource.example1", "id"), + ), + }, + // update test + { + Config: testAccCifsLocalUserResourceConfigAlias("ansibleSVM", "newuser"), + Check: resource.ComposeTestCheckFunc( + // check renamed user name + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_local_user_resource.example1", "name", "newuser"), + // check id + resource.TestCheckResourceAttrSet("netapp-ontap_protocols_cifs_local_user_resource.example1", "id")), + }, + // Test importing a resource + { + ResourceName: "netapp-ontap_protocols_cifs_local_user_resource.example1", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s,%s", "Administrator", "ansibleSVM", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_local_user_resource.example1", "svm_name", "ansibleSVM"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_local_user_resource.example1", "name", "Administrator"), + resource.TestMatchResourceAttr("netapp-ontap_protocols_nfs_export_policy_rule.example1", "description", regexp.MustCompile(`Built-in administrator account`)), + resource.TestCheckTypeSetElemAttr("netapp-ontap_protocols_nfs_export_policy_rule.example1", "membership.*", "Administrators"), + // check id + resource.TestCheckResourceAttrSet("netapp-ontap_protocols_cifs_local_user_resource.example1", "id"), + ), + }, + }, + }) +} + +func testAccCifsLocalUserResourceConfigAliasMissingVars(svmName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_protocols_cifs_local_user_resource" "example1" { + cx_profile_name = "cluster4" + svm_name = "%s" +} +`, host, admin, password, svmName) +} + +func testAccCifsLocalUserResourceConfigAlias(svmName string, userName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} +resource "netapp-ontap_protocols_cifs_local_user_resource" "example1" { + cx_profile_name = "cluster4" + svm_name = "%s" + name = "%s" + password = "password!!!" +} +`, host, admin, password, svmName, userName) +} diff --git a/internal/provider/protocols/protocols_cifs_local_users_data_source.go b/internal/provider/protocols/protocols_cifs_local_users_data_source.go index 73a094e7..64e3446c 100644 --- a/internal/provider/protocols/protocols_cifs_local_users_data_source.go +++ b/internal/provider/protocols/protocols_cifs_local_users_data_source.go @@ -3,6 +3,7 @@ package protocols import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewCifsLocalUsersDataSource() datasource.DataSource { } } +// NewCifsLocalUsersDataSourceAlias is a helper function to simplify the provider implementation. +func NewCifsLocalUsersDataSourceAlias() datasource.DataSource { + return &CifsLocalUsersDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_cifs_local_users_data_source", + }, + } +} + // CifsLocalUsersDataSource defines the data source implementation. type CifsLocalUsersDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_service_data_source.go b/internal/provider/protocols/protocols_cifs_service_data_source.go index 89ec3903..dc55b028 100644 --- a/internal/provider/protocols/protocols_cifs_service_data_source.go +++ b/internal/provider/protocols/protocols_cifs_service_data_source.go @@ -25,6 +25,15 @@ func NewCifsServiceDataSource() datasource.DataSource { } } +// NewCifsServiceDataSourceAlias is a helper function to simplify the provider implementation. +func NewCifsServiceDataSourceAlias() datasource.DataSource { + return &CifsServiceDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_cifs_service_data_source", + }, + } +} + // CifsServiceDataSource defines the data source implementation. type CifsServiceDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_service_resource.go b/internal/provider/protocols/protocols_cifs_service_resource.go index de40f031..d95e571d 100644 --- a/internal/provider/protocols/protocols_cifs_service_resource.go +++ b/internal/provider/protocols/protocols_cifs_service_resource.go @@ -3,9 +3,10 @@ package protocols import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strings" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" @@ -40,6 +41,15 @@ func NewCifsServiceResource() resource.Resource { } } +// NewCifsServiceResourceAlias is a helper function to simplify the provider implementation. +func NewCifsServiceResourceAlias() resource.Resource { + return &CifsServiceResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_cifs_service_resource", + }, + } +} + // CifsServiceResource defines the resource implementation. type CifsServiceResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_service_resource_alias_test.go b/internal/provider/protocols/protocols_cifs_service_resource_alias_test.go new file mode 100644 index 00000000..711f868b --- /dev/null +++ b/internal/provider/protocols/protocols_cifs_service_resource_alias_test.go @@ -0,0 +1,132 @@ +package protocols_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccCifsServiceResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Test error + { + Config: testAccCifsServiceResourceConfigAliasMissingVars("non-existant"), + ExpectError: regexp.MustCompile("Missing required argument"), + }, + // Create and read + { + Config: testAccCifsServiceResourceConfigAlias("tftestcifs", "testSVM"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_service_resource.example", "svm_name", "testSVM"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_service_resource.example", "name", "tftestcifs"), + ), + }, + // update and read + { + Config: testAccCifsServiceResourceUpdateConfigAlias("tftestcifs", "testSVM"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_service_resource.example", "svm_name", "testSVM"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_service_resource.example", "name", "tftestcifs"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_service_resource.example", "security.lm_compatibility_level", "ntlm_ntlmv2_krb"), + ), + }, + // Import and read + { + ResourceName: "netapp-ontap_protocols_cifs_service_resource.example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s,%s,%s,%s", "TFCIFS", "tfsvm", "clustercifs", "cifstest", os.Getenv("TF_ACC_NETAPP_CIFS_ADDOMAIN_PASS")), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_service_resource.example", "name", "TFCIFS"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_service_resource.example", "svm_name", "tfsvm"), + ), + }, + }, + }) +} + +func testAccCifsServiceResourceConfigAliasMissingVars(svmName string) string { + return fmt.Sprintf(` + resource "netapp-ontap_protocols_cifs_service_resource" "example1" { + svm_name = "%s" + } + `, svmName) +} + +func testAccCifsServiceResourceConfigAlias(name string, svmName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST_CIFS") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS_CIFS") + cifspassword := os.Getenv("TF_ACC_NETAPP_CIFS_ADDOMAIN_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST_CIFS, TF_ACC_NETAPP_USER, TF_ACC_NETAPP_PASS_CIFS and TF_ACC_NETAPP_CIFS_ADDOMAIN_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "clustercifs" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} +resource "netapp-ontap_protocols_cifs_service_resource" "example" { + cx_profile_name = "clustercifs" + svm_name = "%s" + name = "%s" + ad_domain = { + fqdn = "mytfdomain.com" + user = "cifstest" + password = "%s" + } +} +`, host, admin, password, svmName, name, cifspassword) +} + +func testAccCifsServiceResourceUpdateConfigAlias(name string, svmName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST_CIFS") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS_CIFS") + cifspassword := os.Getenv("TF_ACC_NETAPP_CIFS_ADDOMAIN_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST_CIFS, TF_ACC_NETAPP_USER, TF_ACC_NETAPP_PASS_CIFS and TF_ACC_NETAPP_CIFS_ADDOMAIN_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "clustercifs" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} +resource "netapp-ontap_protocols_cifs_service_resource" "example" { + cx_profile_name = "clustercifs" + svm_name = "%s" + name = "%s" + ad_domain = { + fqdn = "mytfdomain.com" + user = "cifstest" + password = "%s" + } + security = { + lm_compatibility_level = "ntlm_ntlmv2_krb" + } +} +`, host, admin, password, svmName, name, cifspassword) +} diff --git a/internal/provider/protocols/protocols_cifs_services_data_source.go b/internal/provider/protocols/protocols_cifs_services_data_source.go index 0dc71339..bc121107 100644 --- a/internal/provider/protocols/protocols_cifs_services_data_source.go +++ b/internal/provider/protocols/protocols_cifs_services_data_source.go @@ -3,6 +3,7 @@ package protocols import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewCifsServicesDataSource() datasource.DataSource { } } +// NewCifsServicesDataSource is a helper function to simplify the provider implementation. +func NewCifsServicesDataSourceAlias() datasource.DataSource { + return &CifsServicesDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_cifs_services_data_source", + }, + } +} + // CifsServicesDataSource defines the data source implementation. type CifsServicesDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_share_data_source.go b/internal/provider/protocols/protocols_cifs_share_data_source.go index 8ae613f8..4a17524b 100644 --- a/internal/provider/protocols/protocols_cifs_share_data_source.go +++ b/internal/provider/protocols/protocols_cifs_share_data_source.go @@ -3,6 +3,7 @@ package protocols import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" @@ -28,6 +29,15 @@ func NewProtocolsCIFSShareDataSource() datasource.DataSource { } } +// NewProtocolsCIFSShareDataSourceAlias is a helper function to simplify the provider implementation. +func NewProtocolsCIFSShareDataSourceAlias() datasource.DataSource { + return &ProtocolsCIFSShareDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_cifs_share_data_source", + }, + } +} + // ProtocolsCIFSShareDataSource defines the data source implementation. type ProtocolsCIFSShareDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_share_resource.go b/internal/provider/protocols/protocols_cifs_share_resource.go index e8b7ee62..e7141c8c 100644 --- a/internal/provider/protocols/protocols_cifs_share_resource.go +++ b/internal/provider/protocols/protocols_cifs_share_resource.go @@ -3,9 +3,10 @@ package protocols import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strings" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/path" @@ -35,6 +36,15 @@ func NewProtocolsCIFSShareResource() resource.Resource { } } +// NewProtocolsCIFSShareResourceAlias is a helper function to simplify the provider implementation. +func NewProtocolsCIFSShareResourceAlias() resource.Resource { + return &ProtocolsCIFSShareResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_cifs_share_resource", + }, + } +} + // ProtocolsCIFSShareResource defines the resource implementation. type ProtocolsCIFSShareResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_share_resource_alias_test.go b/internal/provider/protocols/protocols_cifs_share_resource_alias_test.go new file mode 100644 index 00000000..ccfd885f --- /dev/null +++ b/internal/provider/protocols/protocols_cifs_share_resource_alias_test.go @@ -0,0 +1,224 @@ +package protocols_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccProtocolsCIFSShareResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Test non existant SVM + { + Config: testAccProtocolsCIFSShareResourceConfigAlias("non-existant", "terraformTest4"), + ExpectError: regexp.MustCompile("2621462"), + }, + // Read testing + { + Config: testAccProtocolsCIFSShareResourceConfigAlias("tfsvm", "acc_test_cifs_share"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_share_resource.example", "name", "acc_test_cifs_share"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_share_resource.example", "comment", "this is a comment"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_share_resource.example", "continuously_available", "false"), + ), + }, + { + Config: testAccProtocolsCIFSShareResourceConfigAliasUpdate("tfsvm", "acc_test_cifs_share"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_share_resource.example", "name", "acc_test_cifs_share"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_share_resource.example", "comment", "update comment"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_share_resource.example", "continuously_available", "true"), + ), + }, + { + Config: testAccProtocolsCIFSShareResourceConfigAliasUpdateAddACL("tfsvm", "acc_test_cifs_share"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_share_resource.example", "name", "acc_test_cifs_share"), + ), + }, + { + Config: testAccProtocolsCIFSShareResourceConfigAliasUpdateDeleteACL("tfsvm", "acc_test_cifs_share"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_share_resource.example", "name", "acc_test_cifs_share"), + ), + }, + // Test importing a resource + { + ResourceName: "netapp-ontap_protocols_cifs_share_resource.example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s,%s", "acc_test_cifs_share_import", "tfsvm", "clustercifs"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_share_resource.example", "name", "acc_test_cifs_share_import"), + ), + }, + }, + }) +} + +func testAccProtocolsCIFSShareResourceConfigAlias(svm, shareName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST_CIFS") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS2") + + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST_CIFS, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "clustercifs" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_protocols_cifs_share_resource" "example" { + cx_profile_name = "clustercifs" + name = "%s" + svm_name = "%s" + path = "/acc_test_cifs_share_volume" + acls = [ + { + "permission": "read", + "type": "windows", + "user_or_group": "BUILTIN\\Administrators" + } + ] + comment = "this is a comment" +}`, host, admin, password, shareName, svm) +} + +func testAccProtocolsCIFSShareResourceConfigAliasUpdate(svm, volName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST_CIFS") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS2") + + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST_CIFS, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "clustercifs" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_protocols_cifs_share_resource" "example" { + cx_profile_name = "clustercifs" + name = "%s" + svm_name = "%s" + path = "/acc_test_cifs_share_volume" + acls = [ + { + "permission": "full_control", + "type": "windows", + "user_or_group": "BUILTIN\\Administrators" + } + ] + comment = "update comment" + continuously_available = true +}`, host, admin, password, volName, svm) +} + +func testAccProtocolsCIFSShareResourceConfigAliasUpdateAddACL(svm, volName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST_CIFS") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS2") + + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST_CIFS, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "clustercifs" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_protocols_cifs_share_resource" "example" { + cx_profile_name = "clustercifs" + name = "%s" + svm_name = "%s" + path = "/acc_test_cifs_share_volume" + acls = [ + { + "permission": "read", + "type": "windows", + "user_or_group": "Everyone" + }, + { + "permission": "full_control", + "type": "windows", + "user_or_group": "BUILTIN\\Administrators" + } + ] + comment = "update comment" + continuously_available = true +}`, host, admin, password, volName, svm) +} + +func testAccProtocolsCIFSShareResourceConfigAliasUpdateDeleteACL(svm, volName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST_CIFS") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS2") + + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST_CIFS, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "clustercifs" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_protocols_cifs_share_resource" "example" { + cx_profile_name = "clustercifs" + name = "%s" + svm_name = "%s" + path = "/acc_test_cifs_share_volume" + acls = [ + { + "permission": "read", + "type": "windows", + "user_or_group": "Everyone" + } + ] + comment = "update comment" + continuously_available = true +}`, host, admin, password, volName, svm) +} diff --git a/internal/provider/protocols/protocols_cifs_shares_data_source.go b/internal/provider/protocols/protocols_cifs_shares_data_source.go index a81ca452..6c0bd702 100644 --- a/internal/provider/protocols/protocols_cifs_shares_data_source.go +++ b/internal/provider/protocols/protocols_cifs_shares_data_source.go @@ -3,9 +3,10 @@ package protocols import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "log" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -29,6 +30,15 @@ func NewProtocolsCIFSSharesDataSource() datasource.DataSource { } } +// NewProtocolsCIFSSharesDataSourceAlias is a helper function to simplify the provider implementation. +func NewProtocolsCIFSSharesDataSourceAlias() datasource.DataSource { + return &ProtocolsCIFSSharesDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_cifs_shares_data_source", + }, + } +} + // ProtocolsCIFSSharesDataSource defines the data source implementation. type ProtocolsCIFSSharesDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_user_group_privilege_data_source.go b/internal/provider/protocols/protocols_cifs_user_group_privilege_data_source.go index 7ac2d229..703b9aae 100644 --- a/internal/provider/protocols/protocols_cifs_user_group_privilege_data_source.go +++ b/internal/provider/protocols/protocols_cifs_user_group_privilege_data_source.go @@ -3,6 +3,7 @@ package protocols import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewCifsUserGroupPrivilegeDataSource() datasource.DataSource { } } +// NewCifsUserGroupPrivilegeDataSourceAlias is a helper function to simplify the provider implementation. +func NewCifsUserGroupPrivilegeDataSourceAlias() datasource.DataSource { + return &CifsUserGroupPrivilegeDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_cifs_user_group_privilege_data_source", + }, + } +} + // CifsUserGroupPrivilegeDataSource defines the data source implementation. type CifsUserGroupPrivilegeDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_user_group_privileges_data_source.go b/internal/provider/protocols/protocols_cifs_user_group_privileges_data_source.go index 87235c8a..f1830168 100644 --- a/internal/provider/protocols/protocols_cifs_user_group_privileges_data_source.go +++ b/internal/provider/protocols/protocols_cifs_user_group_privileges_data_source.go @@ -3,6 +3,7 @@ package protocols import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewCifsUserGroupPrivilegesDataSource() datasource.DataSource { } } +// NewCifsUserGroupPrivilegesDataSourceAlias is a helper function to simplify the provider implementation. +func NewCifsUserGroupPrivilegesDataSourceAlias() datasource.DataSource { + return &CifsUserGroupPrivilegesDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_cifs_user_group_privileges_data_source", + }, + } +} + // CifsUserGroupPrivilegesDataSource defines the data source implementation. type CifsUserGroupPrivilegesDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_user_group_privileges_resource.go b/internal/provider/protocols/protocols_cifs_user_group_privileges_resource.go index 8354ec79..c2cef7dd 100644 --- a/internal/provider/protocols/protocols_cifs_user_group_privileges_resource.go +++ b/internal/provider/protocols/protocols_cifs_user_group_privileges_resource.go @@ -35,6 +35,15 @@ func NewCifsUserGroupPrivilegeResource() resource.Resource { } } +// NewCifsUserGroupPrivilegeResourceAlias is a helper function to simplify the provider implementation. +func NewCifsUserGroupPrivilegeResourceAlias() resource.Resource { + return &CifsUserGroupPrivilegeResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_cifs_user_group_privilege_resource", + }, + } +} + // CifsUserGroupPrivilegeResource defines the resource implementation. type CifsUserGroupPrivilegeResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_cifs_user_group_privileges_resource_alias_test.go b/internal/provider/protocols/protocols_cifs_user_group_privileges_resource_alias_test.go new file mode 100644 index 00000000..5da602bb --- /dev/null +++ b/internal/provider/protocols/protocols_cifs_user_group_privileges_resource_alias_test.go @@ -0,0 +1,101 @@ +package protocols_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccCifsUserGroupPrivilegesResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccCifsUserGroupPrivilegesResourceConfigAliasMissingVars("non-existant"), + ExpectError: regexp.MustCompile("Missing required argument"), + }, + // create with basic argument on a local user + { + Config: testAccCifsUserGroupPrivilegesResourceConfigAlias("svm3", "accuser1", "sechangenotifyprivilege"), + Check: resource.ComposeTestCheckFunc( + // check name + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_user_group_privilege_resource.example1", "name", "accuser1"), + // check svm_name + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_user_group_privilege_resource.example1", "svm_name", "svm3"), + // check ID + resource.TestCheckResourceAttrSet("netapp-ontap_protocols_cifs_user_group_privilege_resource.example1", "id"), + // check privileges + resource.TestCheckTypeSetElemAttr("netapp-ontap_protocols_cifs_user_group_privilege_resource.example1", "privileges.*", "sechangenotifyprivilege"), + ), + }, + // update one privilege + { + Config: testAccCifsUserGroupPrivilegesResourceConfigAlias("svm3", "accuser1", "setakeownershipprivilege"), + Check: resource.ComposeTestCheckFunc( + // check user name + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_user_group_privilege_resource.example1", "name", "accuser1"), + // check id + resource.TestCheckResourceAttrSet("netapp-ontap_protocols_cifs_user_group_privilege_resource.example1", "id"), + // check updated privileges + resource.TestCheckTypeSetElemAttr("netapp-ontap_protocols_cifs_user_group_privilege_resource.example1", "privileges.*", "setakeownershipprivilege"), + ), + }, + // Test importing a resource + { + ResourceName: "netapp-ontap_protocols_cifs_user_group_privilege_resource.example1", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s,%s", "accuser1", "svm3", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_user_group_privilege_resource.example1", "svm_name", "svm3"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_cifs_user_group_privilege_resource.example1", "name", "accuser1"), + resource.TestCheckTypeSetElemAttr("netapp-ontap_protocols_cifs_user_group_privilege_resource.example1", "privileges.*", "sesecurityprivilege"), + // check id + resource.TestCheckResourceAttrSet("netapp-ontap_protocols_cifs_user_group_privilege_resource.example1", "id"), + ), + }, + }, + }) +} + +func testAccCifsUserGroupPrivilegesResourceConfigAliasMissingVars(svmName string) string { + return fmt.Sprintf(` + resource "netapp-ontap_protocols_cifs_user_group_privilege_resource" "example1" { + svm_name = "%s" + } + `, svmName) +} + +func testAccCifsUserGroupPrivilegesResourceConfigAlias(svmName string, name string, privilege string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_protocols_cifs_user_group_privilege_resource" "example1" { + cx_profile_name = "cluster4" + svm_name = "%s" + name = "%s" + privileges = ["%s", "sesecurityprivilege"] +}`, host, admin, password, svmName, name, privilege) +} diff --git a/internal/provider/protocols/protocols_nfs_export_policies_data_source.go b/internal/provider/protocols/protocols_nfs_export_policies_data_source.go index 0c88b946..2a2df763 100644 --- a/internal/provider/protocols/protocols_nfs_export_policies_data_source.go +++ b/internal/provider/protocols/protocols_nfs_export_policies_data_source.go @@ -25,6 +25,15 @@ func NewExportPoliciesDataSource() datasource.DataSource { } } +// NewExportPoliciesDataSourceAlias is a helper function to simplify the provider implementation. +func NewExportPoliciesDataSourceAlias() datasource.DataSource { + return &ExportPoliciesDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_nfs_export_policies_data_source", + }, + } +} + // ExportPoliciesDataSource defines the data source implementation. type ExportPoliciesDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_nfs_export_policy_data_source.go b/internal/provider/protocols/protocols_nfs_export_policy_data_source.go index 44ea13a4..29dc7c9c 100644 --- a/internal/provider/protocols/protocols_nfs_export_policy_data_source.go +++ b/internal/provider/protocols/protocols_nfs_export_policy_data_source.go @@ -3,9 +3,10 @@ package protocols import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strconv" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -27,6 +28,15 @@ func NewExportPolicyDataSource() datasource.DataSource { } } +// NewExportPolicyDataSourceAlias is a helper function to simplify the provider implementation. +func NewExportPolicyDataSourceAlias() datasource.DataSource { + return &ExportPolicyDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_nfs_export_policy_data_source", + }, + } +} + // ExportPolicyDataSource defines the source implementation. type ExportPolicyDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_nfs_export_policy_resource.go b/internal/provider/protocols/protocols_nfs_export_policy_resource.go index 1aee3bcf..ff80b6f4 100644 --- a/internal/provider/protocols/protocols_nfs_export_policy_resource.go +++ b/internal/provider/protocols/protocols_nfs_export_policy_resource.go @@ -33,6 +33,15 @@ func NewExportPolicyResource() resource.Resource { } } +// NewExportPolicyResourceAlias is a helper function to simplify the provider implementation. +func NewExportPolicyResourceAlias() resource.Resource { + return &ExportPolicyResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_nfs_export_policy_resource", + }, + } +} + // ExportPolicyResource defines the resource implementation. type ExportPolicyResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_nfs_export_policy_resource_alias_test.go b/internal/provider/protocols/protocols_nfs_export_policy_resource_alias_test.go new file mode 100644 index 00000000..4339d060 --- /dev/null +++ b/internal/provider/protocols/protocols_nfs_export_policy_resource_alias_test.go @@ -0,0 +1,70 @@ +package protocols_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccNFSExportPolicyResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccNFSExportPolicyResourceConfigAlias("non-existant"), + ExpectError: regexp.MustCompile("svm non-existant not found"), + }, + // Create and read testing + { + Config: testAccNFSExportPolicyResourceConfigAlias("carchi-test"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_nfs_export_policy_resource.example", "name", "acc_test"), + resource.TestCheckNoResourceAttr("netapp-ontap_protocols_nfs_export_policy_resource.example", "volname"), + ), + }, + // Test importing a resource + { + ResourceName: "netapp-ontap_protocols_nfs_export_policy_resource.example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s,%s", "acc_test", "carchi-test", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_nfs_export_policy_resource.example", "name", "acc_test"), + ), + }, + }, + }) +} + +func testAccNFSExportPolicyResourceConfigAlias(svm string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_protocols_nfs_export_policy_resource" "example" { + cx_profile_name = "cluster4" + svm_name = "%s" + name = "acc_test" +}`, host, admin, password, svm) +} diff --git a/internal/provider/protocols/protocols_nfs_export_policy_rule_data_source.go b/internal/provider/protocols/protocols_nfs_export_policy_rule_data_source.go index 06a3b03e..509bb10f 100644 --- a/internal/provider/protocols/protocols_nfs_export_policy_rule_data_source.go +++ b/internal/provider/protocols/protocols_nfs_export_policy_rule_data_source.go @@ -3,9 +3,10 @@ package protocols import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strconv" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -27,6 +28,15 @@ func NewExportPolicyRuleDataSource() datasource.DataSource { } } +// NewExportPolicyRuleDataSourceAlias is a helper function to simplify the provider implementation. +func NewExportPolicyRuleDataSourceAlias() datasource.DataSource { + return &ExportPolicyRuleDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_nfs_export_policy_rule_data_source", + }, + } +} + // ExportPolicyRuleDataSource defines the source implementation. type ExportPolicyRuleDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_nfs_export_policy_rule_resource.go b/internal/provider/protocols/protocols_nfs_export_policy_rule_resource.go index e0bbd774..a0316319 100644 --- a/internal/provider/protocols/protocols_nfs_export_policy_rule_resource.go +++ b/internal/provider/protocols/protocols_nfs_export_policy_rule_resource.go @@ -3,10 +3,11 @@ package protocols import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strconv" "strings" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" @@ -38,6 +39,15 @@ func NewExportPolicyRuleResource() resource.Resource { } } +// NewExportPolicyRuleResourceAlias is a helper function to simplify the provider implementation. +func NewExportPolicyRuleResourceAlias() resource.Resource { + return &ExportPolicyRuleResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_nfs_export_policy_rule_resource", + }, + } +} + // ExportPolicyRuleResource defines the resource implementation. type ExportPolicyRuleResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_nfs_export_policy_rule_resource_alias_test.go b/internal/provider/protocols/protocols_nfs_export_policy_rule_resource_alias_test.go new file mode 100644 index 00000000..b24e25ec --- /dev/null +++ b/internal/provider/protocols/protocols_nfs_export_policy_rule_resource_alias_test.go @@ -0,0 +1,159 @@ +package protocols_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccNFSExportPolicyRuleResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccNFSExportPolicyRuleResourceConfigAliasMissingVars("non-existant"), + ExpectError: regexp.MustCompile("Missing required argument"), + }, + // create with basic argument + { + Config: testAccNFSExportPolicyRuleResourceConfigAlias("carchi-test", "default"), + Check: resource.ComposeTestCheckFunc( + // check default values + resource.TestCheckResourceAttr("netapp-ontap_protocols_nfs_export_policy_rule_resource.example1", "allow_suid", "true"), + resource.TestCheckTypeSetElemAttr("netapp-ontap_protocols_nfs_export_policy_rule_resource.example1", "protocols.*", "any"), + // check id + resource.TestMatchResourceAttr("netapp-ontap_protocols_nfs_export_policy_rule_resource.example1", "id", regexp.MustCompile(`carchi-test_default_`)), + ), + }, + // update test + { + Config: testAccNFSExportPolicyRuleResourceConfigAliasUpdateProtocolsROrule("carchi-test", "default"), + Check: resource.ComposeTestCheckFunc( + // check default values + resource.TestCheckResourceAttr("netapp-ontap_protocols_nfs_export_policy_rule_resource.example1", "allow_suid", "true"), + // check if the modification successful + resource.TestCheckTypeSetElemAttr("netapp-ontap_protocols_nfs_export_policy_rule_resource.example1", "protocols.*", "nfs3"), + resource.TestCheckTypeSetElemAttr("netapp-ontap_protocols_nfs_export_policy_rule_resource.example1", "ro_rule.*", "krb5i"), + // check id + resource.TestMatchResourceAttr("netapp-ontap_protocols_nfs_export_policy_rule_resource.example1", "id", regexp.MustCompile(`carchi-test_default_`)), + ), + }, + // Test importing a resource + { + ResourceName: "netapp-ontap_protocols_nfs_export_policy_rule_resource.example1", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s,%s,%s", "1", "default", "carchi-test", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_nfs_export_policy_rule_resource.example1", "svm_name", "carchi-test"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_nfs_export_policy_rule_resource.example1", "export_policy_name", "default"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_nfs_export_policy_rule_resource.example1", "allow_suid", "true"), + resource.TestCheckTypeSetElemAttr("netapp-ontap_protocols_nfs_export_policy_rule_resource.example1", "protocols.*", "nfs3"), + resource.TestCheckTypeSetElemAttr("netapp-ontap_protocols_nfs_export_policy_rule_resource.example1", "ro_rule.*", "krb5i"), + resource.TestCheckTypeSetElemAttr("netapp-ontap_protocols_nfs_export_policy_rule_resource.example1", "rw_rule.*", "any"), + // check id + resource.TestMatchResourceAttr("netapp-ontap_protocols_nfs_export_policy_rule_resource.example1", "id", regexp.MustCompile(`carchi-test_default_`)), + ), + }, + }, + }) +} + +func testAccNFSExportPolicyRuleResourceConfigAliasMissingVars(svmName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_protocols_nfs_export_policy_rule_resource" "example" { + cx_profile_name = "cluster4" + svm_name = "%s" +} +`, host, admin, password, svmName) +} + +func testAccNFSExportPolicyRuleResourceConfigAlias(svmName string, exportPolicyName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_protocols_nfs_export_policy_rule_resource" "example1" { + cx_profile_name = "cluster4" + svm_name = "%s" + export_policy_name = "%s" + clients_match = ["0.0.0.0/0"] + ro_rule = ["any"] + rw_rule = ["any"] +} +`, host, admin, password, svmName, exportPolicyName) +} + +// update protocols and ro_rule +func testAccNFSExportPolicyRuleResourceConfigAliasUpdateProtocolsROrule(svmName string, exportPolicyName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_protocols_nfs_export_policy_rule_resource" "example1" { + cx_profile_name = "cluster4" + svm_name = "%s" + export_policy_name = "%s" + protocols = ["nfs3","nfs"] + clients_match = ["0.0.0.0/0"] + ro_rule = ["krb5","krb5i"] + rw_rule = ["any"] +} +`, host, admin, password, svmName, exportPolicyName) +} diff --git a/internal/provider/protocols/protocols_nfs_export_policy_rules_data_source.go b/internal/provider/protocols/protocols_nfs_export_policy_rules_data_source.go index 69fb870e..34a8893f 100644 --- a/internal/provider/protocols/protocols_nfs_export_policy_rules_data_source.go +++ b/internal/provider/protocols/protocols_nfs_export_policy_rules_data_source.go @@ -3,9 +3,10 @@ package protocols import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strconv" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -26,6 +27,15 @@ func NewExportPolicyRulesDataSource() datasource.DataSource { } } +// NewExportPolicyRulesDataSourceAlias is a helper function to simplify the provider implementation. +func NewExportPolicyRulesDataSourceAlias() datasource.DataSource { + return &ProtocolsNFSExportPolicyRulesDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_nfs_export_policy_rules_data_source", + }, + } +} + // ProtocolsNFSExportPolicyRulesDataSource defines the data source implementation. type ProtocolsNFSExportPolicyRulesDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_nfs_service_data_source.go b/internal/provider/protocols/protocols_nfs_service_data_source.go index 0056530d..649abd85 100644 --- a/internal/provider/protocols/protocols_nfs_service_data_source.go +++ b/internal/provider/protocols/protocols_nfs_service_data_source.go @@ -3,6 +3,7 @@ package protocols import ( "context" "fmt" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" @@ -25,6 +26,15 @@ func NewProtocolsNfsServiceDataSource() datasource.DataSource { } } +// NewProtocolsNfsServiceDataSourceAlias is a helper function to simplify the provider implementation. +func NewProtocolsNfsServiceDataSourceAlias() datasource.DataSource { + return &ProtocolsNfsServiceDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_nfs_service_data_source", + }, + } +} + // ProtocolsNfsServiceDataSource defines the data source implementation. type ProtocolsNfsServiceDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_nfs_service_resource.go b/internal/provider/protocols/protocols_nfs_service_resource.go index 4edf00fd..bf923909 100644 --- a/internal/provider/protocols/protocols_nfs_service_resource.go +++ b/internal/provider/protocols/protocols_nfs_service_resource.go @@ -40,6 +40,15 @@ func NewProtocolsNfsServiceResource() resource.Resource { } } +// NewProtocolsNfsServiceResourceAlias is a helper function to simplify the provider implementation. +func NewProtocolsNfsServiceResourceAlias() resource.Resource { + return &ProtocolsNfsServiceResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_nfs_service_resource", + }, + } +} + // ProtocolsNfsServiceResource defines the resource implementation. type ProtocolsNfsServiceResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_nfs_service_resource_alias_test.go b/internal/provider/protocols/protocols_nfs_service_resource_alias_test.go new file mode 100644 index 00000000..fd19e9fa --- /dev/null +++ b/internal/provider/protocols/protocols_nfs_service_resource_alias_test.go @@ -0,0 +1,90 @@ +package protocols_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccNfsServiceResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Test error + { + Config: testAccNfsServiceResourceConfigAlias("non-existant", "false"), + ExpectError: regexp.MustCompile("svm non-existant not found"), + }, + // Create and read + { + Config: testAccNfsServiceResourceConfigAlias("carchi-test", "false"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_nfs_service_resource.example", "svm_name", "carchi-test"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_nfs_service_resource.example", "protocol.v3_enabled", "false"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_nfs_service_resource.example", "protocol.v40_enabled", "true"), + ), + }, + // update and read + { + Config: testAccNfsServiceResourceConfigAlias("carchi-test", "true"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_nfs_service_resource.example", "svm_name", "carchi-test"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_nfs_service_resource.example", "protocol.v3_enabled", "true"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_nfs_service_resource.example", "protocol.v40_enabled", "true"), + ), + }, + // Import and read + { + ResourceName: "netapp-ontap_protocols_nfs_service_resource.example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s", "carchi-test", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_nfs_service_resource.example", "protocol.v3_enabled", "true"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_nfs_service_resource.example", "protocol.v40_enabled", "true"), + ), + }, + }, + }) +} + +func testAccNfsServiceResourceConfigAlias(svnName, enableV3 string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_protocols_nfs_service_resource" "example" { + # required to know which system to interface with + cx_profile_name = "cluster4" + svm_name = "%s" + enabled = true + protocol = { + v3_enabled = "%s" + v40_enabled = true + v40_features = { + acl_enabled = true + } + } +}`, host, admin, password, svnName, enableV3) +} diff --git a/internal/provider/protocols/protocols_nfs_services_data_source.go b/internal/provider/protocols/protocols_nfs_services_data_source.go index 6b263c14..bd1cd0cc 100644 --- a/internal/provider/protocols/protocols_nfs_services_data_source.go +++ b/internal/provider/protocols/protocols_nfs_services_data_source.go @@ -3,6 +3,7 @@ package protocols import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewProtocolsNfsServicesDataSource() datasource.DataSource { } } +// NewProtocolsNfsServicesDataSource is a helper function to simplify the provider implementation. +func NewProtocolsNfsServicesDataSourceAlias() datasource.DataSource { + return &ProtocolsNfsServicesDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_nfs_services_data_source", + }, + } +} + // ProtocolsNfsServicesDataSource defines the data source implementation. type ProtocolsNfsServicesDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_san_igroup_data_source.go b/internal/provider/protocols/protocols_san_igroup_data_source.go index a3553fac..b866213b 100644 --- a/internal/provider/protocols/protocols_san_igroup_data_source.go +++ b/internal/provider/protocols/protocols_san_igroup_data_source.go @@ -3,6 +3,7 @@ package protocols import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewProtocolsSanIgroupDataSource() datasource.DataSource { } } +// NewProtocolsSanIgroupDataSourceAlias is a helper function to simplify the provider implementation. +func NewProtocolsSanIgroupDataSourceAlias() datasource.DataSource { + return &ProtocolsSanIgroupDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_san_igroup_data_source", + }, + } +} + // ProtocolsSanIgroupDataSource defines the data source implementation. type ProtocolsSanIgroupDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_san_igroup_resource.go b/internal/provider/protocols/protocols_san_igroup_resource.go index 7085e65a..809b9cc1 100644 --- a/internal/provider/protocols/protocols_san_igroup_resource.go +++ b/internal/provider/protocols/protocols_san_igroup_resource.go @@ -37,6 +37,15 @@ func NewProtocolsSanIgroupResource() resource.Resource { } } +// NewProtocolsSanIgroupResourceAlias is a helper function to simplify the provider implementation. +func NewProtocolsSanIgroupResourceAlias() resource.Resource { + return &ProtocolsSanIgroupResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_san_igroup_resource", + }, + } +} + // ProtocolsSanIgroupResource defines the resource implementation. type ProtocolsSanIgroupResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_san_igroup_resource_alias_test.go b/internal/provider/protocols/protocols_san_igroup_resource_alias_test.go new file mode 100644 index 00000000..5b5b56be --- /dev/null +++ b/internal/provider/protocols/protocols_san_igroup_resource_alias_test.go @@ -0,0 +1,109 @@ +package protocols_test + +import ( + "fmt" + "os" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccProtocolsSanIgroupResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create protocols_san_igroup and read + { + Config: testAccProtocolsSanIgroupResourceBasicConfigAlias("acc_test2", "carchi-test"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_san_igroup_resource.example", "name", "acc_test2"), + ), + }, + // Update options and read + { + Config: testAccProtocolsSanIgroupResourceUpdateConfigAlias("acc_test2", "carchi-test", "windows", "test_acc"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_san_igroup_resource.example", "os_type", "windows"), + resource.TestCheckResourceAttr("netapp-ontap_protocols_san_igroup_resource.example", "name", "acc_test2"), + ), + }, + // Import and read + { + ResourceName: "netapp-ontap_protocols_san_igroup_resource.example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s,%s", "acc_test", "carchi-test", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_san_igroup_resource.example", "name", "acc_test"), + ), + }, + // Delete testing automatically occurs in TestCase + }, + }) +} + +func testAccProtocolsSanIgroupResourceBasicConfigAlias(name string, svmName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_protocols_san_igroup_resource" "example" { + cx_profile_name = "cluster4" + name = "%s" + svm = { + name = "%s" + } + os_type = "linux" + comment = "test" +}`, host, admin, password, name, svmName) +} + +func testAccProtocolsSanIgroupResourceUpdateConfigAlias(name string, svmName string, osType string, comment string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_protocols_san_igroup_resource" "example" { + cx_profile_name = "cluster4" + name = "%s" + svm = { + name = "%s" + } + os_type = "%s" + comment = "%s" +}`, host, admin, password, name, svmName, osType, comment) +} diff --git a/internal/provider/protocols/protocols_san_igroups_data_source.go b/internal/provider/protocols/protocols_san_igroups_data_source.go index 6c7bf161..27b0dd62 100644 --- a/internal/provider/protocols/protocols_san_igroups_data_source.go +++ b/internal/provider/protocols/protocols_san_igroups_data_source.go @@ -3,6 +3,7 @@ package protocols import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/interfaces" "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/netapp/terraform-provider-netapp-ontap/internal/utils" @@ -25,6 +26,15 @@ func NewProtocolsSanIgroupsDataSource() datasource.DataSource { } } +// NewProtocolsSanIgroupsDataSourceAlias is a helper function to simplify the provider implementation. +func NewProtocolsSanIgroupsDataSourceAlias() datasource.DataSource { + return &ProtocolsSanIgroupsDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_san_igroups_data_source", + }, + } +} + // ProtocolsSanIgroupsDataSource defines the data source implementation. type ProtocolsSanIgroupsDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_san_lun-map_data_source.go b/internal/provider/protocols/protocols_san_lun-map_data_source.go index f5cbfd24..aefc30ff 100644 --- a/internal/provider/protocols/protocols_san_lun-map_data_source.go +++ b/internal/provider/protocols/protocols_san_lun-map_data_source.go @@ -26,6 +26,15 @@ func NewProtocolsSanLunMapDataSource() datasource.DataSource { } } +// NewProtocolsSanLunMapDataSourceAlias is a helper function to simplify the provider implementation. +func NewProtocolsSanLunMapDataSourceAlias() datasource.DataSource { + return &ProtocolsSanLunMapDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_san_lun-map_data_source", + }, + } +} + // ProtocolsSanLunMapDataSource defines the data source implementation. type ProtocolsSanLunMapDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_san_lun-map_resource.go b/internal/provider/protocols/protocols_san_lun-map_resource.go index 4dad9766..2e8cdba3 100644 --- a/internal/provider/protocols/protocols_san_lun-map_resource.go +++ b/internal/provider/protocols/protocols_san_lun-map_resource.go @@ -33,6 +33,15 @@ func NewProtocolsSanLunMapResource() resource.Resource { } } +// NewProtocolsSanLunMapResourceAlias is a helper function to simplify the provider implementation. +func NewProtocolsSanLunMapResourceAlias() resource.Resource { + return &ProtocolsSanLunMapsResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_san_lun-maps_resource", + }, + } +} + // ProtocolsSanLunMapsResource defines the resource implementation. type ProtocolsSanLunMapsResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/protocols/protocols_san_lun-map_resource_alias_test.go b/internal/provider/protocols/protocols_san_lun-map_resource_alias_test.go new file mode 100644 index 00000000..b62ba521 --- /dev/null +++ b/internal/provider/protocols/protocols_san_lun-map_resource_alias_test.go @@ -0,0 +1,72 @@ +package protocols_test + +import ( + "fmt" + "os" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccProtocolsSanLunMapResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create protocols_san_lun-maps and read + { + Config: testAccProtocolsSanLunMapResourceBasicConfigAlias("/vol/lunTest/ACC-import-lun", "test", "carchi-test"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_san_lun-maps_resource.example", "svm.name", "carchi-test"), + ), + }, + // Import and read + { + ResourceName: "netapp-ontap_protocols_san_lun-maps_resource.example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s,%s,%s", "carchi-test", "acc_test", "/vol/lunTest/test", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_protocols_san_lun-maps_resource.example", "svm.name", "carchi-test"), + ), + }, + // Delete testing automatically occurs in TestCase + }, + }) +} + +func testAccProtocolsSanLunMapResourceBasicConfigAlias(lunName string, igroupName string, svmName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_protocols_san_lun-maps_resource" "example" { + cx_profile_name = "cluster4" + svm = { + name = "%s" + } + lun = { + name = "%s" + } + igroup = { + name = "%s" + } +}`, host, admin, password, svmName, lunName, igroupName) +} diff --git a/internal/provider/protocols/protocols_san_lun-maps_data_source.go b/internal/provider/protocols/protocols_san_lun-maps_data_source.go index 248fa9ac..026884df 100644 --- a/internal/provider/protocols/protocols_san_lun-maps_data_source.go +++ b/internal/provider/protocols/protocols_san_lun-maps_data_source.go @@ -3,6 +3,7 @@ package protocols import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/svm" @@ -26,6 +27,15 @@ func NewProtocolsSanLunMapsDataSource() datasource.DataSource { } } +// NewProtocolsSanLunMapsDataSourceAlias is a helper function to simplify the provider implementation. +func NewProtocolsSanLunMapsDataSourceAlias() datasource.DataSource { + return &ProtocolsSanLunMapsDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "protocols_san_lun-maps_data_source", + }, + } +} + // ProtocolsSanLunMapsDataSource defines the data source implementation. type ProtocolsSanLunMapsDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/provider.go b/internal/provider/provider.go index f654cfac..f8ce8ad2 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -214,81 +214,111 @@ func (p *ONTAPProvider) Configure(ctx context.Context, req provider.ConfigureReq // Resources defines the provider's resources. func (p *ONTAPProvider) Resources(ctx context.Context) []func() resource.Resource { return []func() resource.Resource{ - storage.NewAggregateResource, - protocols.NewCifsLocalGroupResource, - protocols.NewCifsLocalGroupMembersResource, - protocols.NewCifsLocalUserResource, - protocols.NewCifsServiceResource, - protocols.NewCifsUserGroupPrivilegeResource, - cluster.NewClusterResource, cluster.NewClusterLicensingLicenseResource, cluster.NewClusterPeerResource, + cluster.NewClusterResource, cluster.NewClusterScheduleResource, + name_services.NewNameServicesDNSResource, + name_services.NewNameServicesLDAPResource, + networking.NewIPInterfaceResource, + networking.NewIPRouteResource, NewExampleResource, + protocols.NewCifsLocalGroupMembersResource, + protocols.NewCifsLocalGroupResource, + protocols.NewCifsLocalUserResource, + protocols.NewCifsServiceResource, + protocols.NewCifsUserGroupPrivilegeResource, protocols.NewExportPolicyResource, protocols.NewExportPolicyRuleResource, - networking.NewIPInterfaceResource, - networking.NewIPRouteResource, - name_services.NewNameServicesDNSResource, - name_services.NewNameServicesLDAPResource, protocols.NewProtocolsCIFSShareResource, protocols.NewProtocolsNfsServiceResource, protocols.NewProtocolsSanIgroupResource, protocols.NewProtocolsSanLunMapResource, security.NewSecurityAccountResource, security.NewSecurityCertificateResource, - security.NewSecurityRoleResource, security.NewSecurityLoginMessageResource, - snapmirror.NewSnapmirrorResource, + security.NewSecurityRoleResource, snapmirror.NewSnapmirrorPolicyResource, + snapmirror.NewSnapmirrorResource, + storage.NewAggregateResource, storage.NewQOSPolicyResource, - storage.NewStorageLunResource, storage.NewSnapshotPolicyResource, - storage.NewStorageQuotaRuleResource, storage.NewStorageFlexcacheRsource, - storage.NewStorageVolumeResource, - storage.NewVolumeFileResource, + storage.NewStorageLunResource, + storage.NewStorageQuotaRuleResource, storage.NewStorageQtreeResource, storage.NewStorageVolumeEfficiencyPolicyResource, + storage.NewStorageVolumeResource, storage.NewStorageVolumeSnapshotResource, + storage.NewVolumeFileResource, svm.NewSVMPeerResource, svm.NewSvmResource, + // The following resources are Alias for the version 1 names + cluster.NewClusterLicensingLicenseResourceAlias, + cluster.NewClusterPeerResourceAlias, + cluster.NewClusterResourceAlias, + cluster.NewClusterScheduleResourceAlias, + name_services.NewNameServicesDNSResourceAlias, + name_services.NewNameServicesLDAPResourceAlias, + networking.NewIPInterfaceResourceAlias, + networking.NewIPRouteResourceAlias, + protocols.NewCifsLocalGroupMembersResourceAlias, + protocols.NewCifsLocalGroupResourceAlias, + protocols.NewCifsLocalUserResourcAlias, + protocols.NewCifsServiceResourceAlias, + protocols.NewProtocolsCIFSShareResourceAlias, + protocols.NewCifsUserGroupPrivilegeResourceAlias, + protocols.NewExportPolicyResourceAlias, + protocols.NewExportPolicyRuleResourceAlias, + protocols.NewProtocolsNfsServiceResourceAlias, + protocols.NewProtocolsSanIgroupResourceAlias, + protocols.NewProtocolsSanLunMapResourceAlias, + security.NewSecurityAccountResourceAlias, + snapmirror.NewSnapmirrorPolicyResourceAlias, + snapmirror.NewSnapmirrorResourceAlias, + storage.NewAggregateResourceAlias, + storage.NewStorageFlexcacheRsourceAlias, + storage.NewStorageLunResourceAlias, + storage.NewSnapshotPolicyResourceAlias, + storage.NewStorageVolumeResourceAlias, + storage.NewStorageVolumeSnapshotResourceAlias, + svm.NewSVMPeerResourceAlias, + svm.NewSvmResourceAlias, } } -// DataSources defines the provider's data sources. func (p *ONTAPProvider) DataSources(ctx context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ + cluster.NewClusterDataSource, + cluster.NewClusterLicensingLicenseDataSource, + cluster.NewClusterLicensingLicensesDataSource, + cluster.NewClusterPeerDataSource, + cluster.NewClusterPeersDataSource, + cluster.NewClusterScheduleDataSource, + cluster.NewClusterSchedulesDataSource, + name_services.NewNameServicesDNSDataSource, + name_services.NewNameServicesDNSsDataSource, + name_services.NewNameServicesLDAPDataSource, + name_services.NewNameServicesLDAPsDataSource, + networking.NewIPInterfaceDataSource, + networking.NewIPInterfacesDataSource, + networking.NewIPRouteDataSource, + networking.NewIPRoutesDataSource, + NewExampleDataSource, protocols.NewCifsLocalGroupDataSource, - protocols.NewCifsLocalGroupsDataSource, protocols.NewCifsLocalGroupMemberDataSource, protocols.NewCifsLocalGroupMembersDataSource, + protocols.NewCifsLocalGroupsDataSource, protocols.NewCifsLocalUserDataSource, protocols.NewCifsLocalUsersDataSource, protocols.NewCifsServiceDataSource, protocols.NewCifsServicesDataSource, protocols.NewCifsUserGroupPrivilegeDataSource, protocols.NewCifsUserGroupPrivilegesDataSource, - cluster.NewClusterDataSource, - cluster.NewClusterLicensingLicenseDataSource, - cluster.NewClusterLicensingLicensesDataSource, - cluster.NewClusterPeerDataSource, - cluster.NewClusterPeersDataSource, - cluster.NewClusterScheduleDataSource, - cluster.NewClusterSchedulesDataSource, - NewExampleDataSource, - protocols.NewExportPolicyDataSource, protocols.NewExportPoliciesDataSource, + protocols.NewExportPolicyDataSource, protocols.NewExportPolicyRuleDataSource, protocols.NewExportPolicyRulesDataSource, - networking.NewIPInterfaceDataSource, - networking.NewIPInterfacesDataSource, - networking.NewIPRouteDataSource, - networking.NewIPRoutesDataSource, - name_services.NewNameServicesDNSDataSource, - name_services.NewNameServicesDNSsDataSource, - name_services.NewNameServicesLDAPDataSource, - name_services.NewNameServicesLDAPsDataSource, protocols.NewProtocolsCIFSShareDataSource, protocols.NewProtocolsCIFSSharesDataSource, protocols.NewProtocolsNfsServiceDataSource, @@ -301,39 +331,99 @@ func (p *ONTAPProvider) DataSources(ctx context.Context) []func() datasource.Dat security.NewSecurityAccountsDataSource, security.NewSecurityCertificateDataSource, security.NewSecurityCertificatesDataSource, - security.NewSecurityRoleDataSource, - security.NewSecurityRolesDataSource, security.NewSecurityLoginMessageDataSource, security.NewSecurityLoginMessagesDataSource, + security.NewSecurityRoleDataSource, + security.NewSecurityRolesDataSource, snapmirror.NewSnapmirrorDataSource, + snapmirror.NewSnapmirrorPolicyDataSource, + snapmirror.NewSnapmirrorPoliciesDataSource, snapmirror.NewSnapmirrorsDataSource, storage.NewSnapshotPoliciesDataSource, storage.NewSnapshotPolicyDataSource, - snapmirror.NewSnapmirrorPolicyDataSource, - snapmirror.NewSnapmirrorPoliciesDataSource, storage.NewStorageAggregateDataSource, storage.NewStorageAggregatesDataSource, storage.NewStorageFlexcacheDataSource, storage.NewStorageFlexcachesDataSource, storage.NewStorageLunDataSource, storage.NewStorageLunsDataSource, - storage.NewStorageQOSPolicyDataSource, storage.NewStorageQOSPoliciesDataSource, + storage.NewStorageQOSPolicyDataSource, storage.NewStorageQuotaRuleDataSource, storage.NewStorageQuotaRulesDataSource, storage.NewStorageQtreeDataSource, storage.NewStorageQtreesDataSource, + storage.NewStorageVolumeDataSource, storage.NewStorageVolumeSnapshotDataSource, storage.NewStorageVolumeSnapshotsDataSource, - storage.NewVolumeEfficiencyPolicyDataSource, - storage.NewVolumeEfficiencyPoliciesDataSource, - storage.NewStorageVolumeDataSource, storage.NewStorageVolumesDataSource, storage.NewStorageVolumesFilesDataSource, - svm.NewSvmDataSource, - svm.NewSvmsDataSource, + storage.NewVolumeEfficiencyPoliciesDataSource, + storage.NewVolumeEfficiencyPolicyDataSource, svm.NewSVMPeerDataSource, svm.NewSVMPeersDataSource, + svm.NewSvmDataSource, + svm.NewSvmsDataSource, + // The following datasource are Alias for the version 1 names + cluster.NewClusterDataSourceAlias, + cluster.NewClusterLicensingLicensesDataSourceAlias, + cluster.NewClusterLicensingLicenseDataSourceAlias, + cluster.NewClusterPeerDataSourceAlias, + cluster.NewClusterPeersDataSourceAlias, + cluster.NewClusterScheduleDataSourceAlias, + cluster.NewClusterSchedulesDataSourceAlias, + name_services.NewNameServicesDNSDataSourceAlias, + name_services.NewNameServicesDNSsDataSourceAlias, + name_services.NewNameServicesLDAPDataSourceAlias, + name_services.NewNameServicesLDAPsDataSourceAlias, + networking.NewIPInterfaceDataSourceAlias, + networking.NewIPInterfacesDataSourceAlias, + networking.NewIPRouteDataSourceAlias, + networking.NewIPRoutesDataSourceAlias, + protocols.NewCifsLocalGroupDataSourceAlias, + protocols.NewCifsLocalGroupMemberDataSourceAlias, + protocols.NewCifsLocalGroupMembersDataSourceAlias, + protocols.NewCifsLocalGroupsDataSourceAlias, + protocols.NewCifsLocalUserDataSourceAlias, + protocols.NewCifsLocalUsersDataSourceAlias, + protocols.NewCifsServiceDataSourceAlias, + protocols.NewCifsServicesDataSourceAlias, + protocols.NewProtocolsCIFSShareDataSourceAlias, + protocols.NewProtocolsCIFSSharesDataSourceAlias, + protocols.NewCifsUserGroupPrivilegeDataSourceAlias, + protocols.NewCifsUserGroupPrivilegesDataSourceAlias, + protocols.NewExportPoliciesDataSourceAlias, + protocols.NewExportPolicyDataSourceAlias, + protocols.NewExportPolicyRuleDataSourceAlias, + protocols.NewExportPolicyRulesDataSourceAlias, + protocols.NewProtocolsNfsServiceDataSourceAlias, + protocols.NewProtocolsNfsServicesDataSourceAlias, + protocols.NewProtocolsSanIgroupDataSourceAlias, + protocols.NewProtocolsSanIgroupsDataSourceAlias, + protocols.NewProtocolsSanLunMapDataSourceAlias, + protocols.NewProtocolsSanLunMapsDataSourceAlias, + security.NewSecurityAccountDataSourceAlias, + security.NewSecurityAccountsDataSourceAlias, + snapmirror.NewSnapmirrorDataSourceAlias, + snapmirror.NewSnapmirrorPoliciesDataSourceAlias, + snapmirror.NewSnapmirrorPolicyDataSourceAlias, + snapmirror.NewSnapmirrorsDataSourceAlias, + storage.NewStorageAggregateDataSourceAlias, + storage.NewStorageAggregatesDataSourceAlias, + storage.NewStorageFlexcacheDataSourceAlias, + storage.NewStorageFlexcachesDataSourceAlias, + storage.NewStorageLunDataSourceAlias, + storage.NewStorageLunsDataSourceAlias, + storage.NewSnapshotPoliciesDataSourceAlias, + storage.NewSnapshotPolicyDataSourceAlias, + storage.NewStorageVolumeDataSourceAlias, + storage.NewStorageVolumeSnapshotDataSourceAlias, + storage.NewStorageVolumeSnapshotsDataSourceAlias, + storage.NewStorageVolumesDataSourceAlias, + svm.NewSvmDataSourceAlias, + svm.NewSVMPeerDataSourceAlias, + svm.NewSVMPeersDataSourceAlias, + svm.NewSvmsDataSourceAlias, } } diff --git a/internal/provider/security/security_account_data_source.go b/internal/provider/security/security_account_data_source.go index 8906dc9d..86af4cfc 100644 --- a/internal/provider/security/security_account_data_source.go +++ b/internal/provider/security/security_account_data_source.go @@ -3,6 +3,7 @@ package security import ( "context" "fmt" + "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -24,6 +25,15 @@ func NewSecurityAccountDataSource() datasource.DataSource { } } +// NewSecurityAccountDataSourceAlias is a helper function to simplify the provider implementation. +func NewSecurityAccountDataSourceAlias() datasource.DataSource { + return &SecurityAccountDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "security_account_data_source", + }, + } +} + // SecurityAccountDataSource defines the data source implementation. type SecurityAccountDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/security/security_account_resource.go b/internal/provider/security/security_account_resource.go index e337f631..65293f33 100644 --- a/internal/provider/security/security_account_resource.go +++ b/internal/provider/security/security_account_resource.go @@ -36,6 +36,15 @@ func NewSecurityAccountResource() resource.Resource { } } +// NewSecurityAccountResourceAlias is a helper function to simplify the provider implementation. +func NewSecurityAccountResourceAlias() resource.Resource { + return &SecurityAccountResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "security_account_resource", + }, + } +} + // SecurityAccountResource defines the resource implementation. type SecurityAccountResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/security/security_account_resource_alias_test.go b/internal/provider/security/security_account_resource_alias_test.go new file mode 100644 index 00000000..d3050f96 --- /dev/null +++ b/internal/provider/security/security_account_resource_alias_test.go @@ -0,0 +1,76 @@ +package security_test + +import ( + "fmt" + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" +) + +func TestAccSecurityAccountResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccSecurityAccountResourceConfigAlias("carchitest", "password"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_security_account_resource.security_account", "name", "carchitest"), + ), + }, + // Test updating a resource + { + Config: testAccSecurityAccountResourceConfigAlias("carchitest", "password123"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_security_account_resource.security_account", "name", "carchitest"), + resource.TestCheckResourceAttr("netapp-ontap_security_account_resource.security_account", "password", "password123"), + ), + }, + // Test importing a resource + { + ResourceName: "netapp-ontap_security_account_resource.security_account", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s", "acc_user", "cluster2"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_security_account_resource.security_account", "name", "acc_user"), + ), + }, + }, + }) +} + +func testAccSecurityAccountResourceConfigAlias(name string, accpassword string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST2") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS2") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster2" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_security_account_resource" "security_account" { + # required to know which system to interface with + cx_profile_name = "cluster2" + name = "%s" + applications = [{ + application = "http" + authentication_methods = ["password"] + }] + password = "%s" +} +`, host, admin, password, name, accpassword) +} diff --git a/internal/provider/security/security_accounts_data_source.go b/internal/provider/security/security_accounts_data_source.go index d15be234..7a6958ac 100644 --- a/internal/provider/security/security_accounts_data_source.go +++ b/internal/provider/security/security_accounts_data_source.go @@ -3,6 +3,7 @@ package security import ( "context" "fmt" + "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -24,6 +25,15 @@ func NewSecurityAccountsDataSource() datasource.DataSource { } } +// NewSecurityAccountsDataSourceAlias is a helper function to simplify the provider implementation. +func NewSecurityAccountsDataSourceAlias() datasource.DataSource { + return &SecurityAccountsDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "security_accounts_data_source", + }, + } +} + // SecurityAccountsDataSource defines the data source implementation. type SecurityAccountsDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/snapmirror/snapmirror_data_source.go b/internal/provider/snapmirror/snapmirror_data_source.go index 8c39baaf..4f4ec1be 100644 --- a/internal/provider/snapmirror/snapmirror_data_source.go +++ b/internal/provider/snapmirror/snapmirror_data_source.go @@ -3,6 +3,7 @@ package snapmirror import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewSnapmirrorDataSource() datasource.DataSource { } } +// NewSnapmirrorDataSourceAlias is a helper function to simplify the provider implementation. +func NewSnapmirrorDataSourceAlias() datasource.DataSource { + return &SnapmirrorDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "snapmirror_data_source", + }, + } +} + // SnapmirrorDataSource defines the data source implementation. type SnapmirrorDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/snapmirror/snapmirror_policies_data_source.go b/internal/provider/snapmirror/snapmirror_policies_data_source.go index 6900013a..ae922585 100644 --- a/internal/provider/snapmirror/snapmirror_policies_data_source.go +++ b/internal/provider/snapmirror/snapmirror_policies_data_source.go @@ -3,9 +3,10 @@ package snapmirror import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strconv" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -26,6 +27,15 @@ func NewSnapmirrorPoliciesDataSource() datasource.DataSource { } } +// NewSnapmirrorPoliciesDataSourceAlias is a helper function to simplify the provider implementation. +func NewSnapmirrorPoliciesDataSourceAlias() datasource.DataSource { + return &SnapmirrorPoliciesDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "snapmirror_policies_data_source", + }, + } +} + // SnapmirrorPoliciesDataSource defines the data source implementation. type SnapmirrorPoliciesDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/snapmirror/snapmirror_policy_data_source.go b/internal/provider/snapmirror/snapmirror_policy_data_source.go index ee6e60fc..b432c766 100644 --- a/internal/provider/snapmirror/snapmirror_policy_data_source.go +++ b/internal/provider/snapmirror/snapmirror_policy_data_source.go @@ -3,9 +3,10 @@ package snapmirror import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strconv" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -26,6 +27,15 @@ func NewSnapmirrorPolicyDataSource() datasource.DataSource { } } +// NewSnapmirrorPolicyDataSourceAlias is a helper function to simplify the provider implementation. +func NewSnapmirrorPolicyDataSourceAlias() datasource.DataSource { + return &SnapmirrorPolicyDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "snapmirror_policy_data_source", + }, + } +} + // SnapmirrorPolicyDataSource defines the data source implementation. type SnapmirrorPolicyDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/snapmirror/snapmirror_policy_resource.go b/internal/provider/snapmirror/snapmirror_policy_resource.go index 4c01e17a..0deecd96 100644 --- a/internal/provider/snapmirror/snapmirror_policy_resource.go +++ b/internal/provider/snapmirror/snapmirror_policy_resource.go @@ -3,10 +3,11 @@ package snapmirror import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strconv" "strings" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework-validators/boolvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" @@ -38,6 +39,15 @@ func NewSnapmirrorPolicyResource() resource.Resource { } } +// NewSnapmirrorPolicyResourceAlias is a helper function to simplify the provider implementation. +func NewSnapmirrorPolicyResourceAlias() resource.Resource { + return &SnapmirrorPolicyResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "snapmirror_policy_resource", + }, + } +} + // SnapmirrorPolicyResource defines the resource implementation. type SnapmirrorPolicyResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/snapmirror/snapmirror_policy_resource_alias_test.go b/internal/provider/snapmirror/snapmirror_policy_resource_alias_test.go new file mode 100644 index 00000000..668556b9 --- /dev/null +++ b/internal/provider/snapmirror/snapmirror_policy_resource_alias_test.go @@ -0,0 +1,414 @@ +package snapmirror_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccSnapmirrorPolicyResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Test snapmirror policy error + { + Config: testAccSnapmirrorPolicyResourceBasicConfigAlias("non-existant"), + ExpectError: regexp.MustCompile("2621462"), + }, + // Test create snapmirror policy basic + { + Config: testAccSnapmirrorPolicyResourceBasicConfigAlias("ansibleSVM"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "name", "carchitestme4"), + ), + }, + // Test adding transfer_schedule + { + Config: testAccSnapmirrorPolicyResourceAddTransferScheduleBasicConfigAlias("ansibleSVM", "weekly"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "name", "carchitestme4"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "transfer_schedule_name", "weekly"), + ), + }, + // Test update transfer_schedule + { + Config: testAccSnapmirrorPolicyResourceAddTransferScheduleBasicConfigAlias("ansibleSVM", "daily"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "name", "carchitestme4"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "transfer_schedule_name", "daily"), + ), + }, + // Test remove snapmirror policy transfer schedule + { + Config: testAccSnapmirrorPolicyResourceBasicConfigAlias("ansibleSVM"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "name", "carchitestme4"), + ), + }, + // Test add snapmirror policy with comment and identity_preservation + { + Config: testAccSnapmirrorPolicyResourceConfigAlias("ansibleSVM", "test comment", "full"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "name", "carchitestme4"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "comment", "test comment"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "identity_preservation", "full"), + ), + }, + // Test update snapmirror policy with comment and identity_preservation change + { + Config: testAccSnapmirrorPolicyResourceConfigAlias("ansibleSVM", "update comment", "exclude_network_config"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "name", "carchitestme4"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "comment", "update comment"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "identity_preservation", "exclude_network_config"), + ), + }, + // Test update snapmirror policy with adding two retention rules + { + Config: testAccSnapmirrorPolicyResourceAddTwoRetentionConfigAlias("ansibleSVM", "update comment", "exclude_network_config", "weekly", 5), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "name", "carchitestme4"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "comment", "update comment"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "identity_preservation", "exclude_network_config"), + // check number of reteion + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "retention.#", "2"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "retention.0.label", "hourly"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "retention.0.count", "7"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "retention.1.label", "weekly"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "retention.1.count", "5"), + ), + }, + // Test update snapmirror policy with removing one retention rule + { + Config: testAccSnapmirrorPolicyResourceRemoveOneRetentionConfigAlias("ansibleSVM", "update comment", "exclude_network_config"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "name", "carchitestme4"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "comment", "update comment"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "identity_preservation", "exclude_network_config"), + // check number of reteion + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "retention.#", "1"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "retention.0.label", "hourly"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.example", "retention.0.count", "7"), + ), + }, + // Test create sync type snapmirror policy + { + Config: testAccSnapmirrorPolicyResourceSyncBasicConfigAlias("ansibleSVM", "test sync"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.sync_example", "name", "test_sync"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.sync_example", "comment", "test sync"), + ), + }, + // Test update sync type snapmirror policy with changing comment + { + Config: testAccSnapmirrorPolicyResourceSyncBasicConfigAlias("ansibleSVM", "test update sync comment"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.sync_example", "name", "test_sync"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.sync_example", "comment", "test update sync comment"), + ), + }, + // Test update sync type snapmirror policy with adding a retention + { + Config: testAccSnapmirrorPolicyResourceSyncAddRetentionConfigAlias("ansibleSVM", "test add retenion in sync type"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.sync_example", "name", "test_sync"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.sync_example", "comment", "test add retenion in sync type"), + // check number of reteion + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.sync_example", "retention.#", "1"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.sync_example", "retention.0.label", "daily"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_policy_resource.sync_example", "retention.0.count", "1"), + ), + }, + // Test update sync type snapmirror policy with adding extra retention - max is 1 + { + Config: testAccSnapmirrorPolicyResourceSyncAddExtraRetentionConfigAlias("ansibleSVM", "test add extra retenion in sync type"), + ExpectError: regexp.MustCompile("error updating sync snapshot policies"), + }, + }, + }) +} + +func testAccSnapmirrorPolicyResourceBasicConfigAlias(svm string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_snapmirror_policy_resource" "example" { + cx_profile_name = "cluster4" + name = "carchitestme4" + svm_name = "%s" + type = "async" +}`, host, admin, password, svm) +} + +func testAccSnapmirrorPolicyResourceAddTransferScheduleBasicConfigAlias(svm string, transferScheduleName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_snapmirror_policy_resource" "example" { + cx_profile_name = "cluster4" + name = "carchitestme4" + svm_name = "%s" + type = "async" + transfer_schedule_name = "%s" +}`, host, admin, password, svm, transferScheduleName) +} + +func testAccSnapmirrorPolicyResourceConfigAlias(svm string, comment string, identityPreservation string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_snapmirror_policy_resource" "example" { + cx_profile_name = "cluster4" + name = "carchitestme4" + svm_name = "%s" + comment = "%s" + identity_preservation = "%s" + type = "async" +}`, host, admin, password, svm, comment, identityPreservation) +} + +func testAccSnapmirrorPolicyResourceAddTwoRetentionConfigAlias(svm string, comment string, identityPreservation string, label string, count int) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_snapmirror_policy_resource" "example" { + cx_profile_name = "cluster4" + name = "carchitestme4" + svm_name = "%s" + comment = "%s" + identity_preservation = "%s" + type = "async" + retention = [ + { + label = "hourly" + count = 7 + creation_schedule_name = "hourly" + }, + { + label = "%s" + count = %d + }, + ] +}`, host, admin, password, svm, comment, identityPreservation, label, count) +} + +func testAccSnapmirrorPolicyResourceRemoveOneRetentionConfigAlias(svm string, comment string, identityPreservation string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_snapmirror_policy_resource" "example" { + cx_profile_name = "cluster4" + name = "carchitestme4" + svm_name = "%s" + comment = "%s" + identity_preservation = "%s" + type = "async" + retention = [ + { + label = "hourly" + count = 7 + creation_schedule_name = "hourly" + } + ] +}`, host, admin, password, svm, comment, identityPreservation) +} + +func testAccSnapmirrorPolicyResourceSyncBasicConfigAlias(svm string, comment string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_snapmirror_policy_resource" "sync_example" { + cx_profile_name = "cluster4" + name = "test_sync" + svm_name = "%s" + type = "sync" + sync_type = "sync" + comment = "%s" +}`, host, admin, password, svm, comment) +} + +func testAccSnapmirrorPolicyResourceSyncAddRetentionConfigAlias(svm string, comment string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_snapmirror_policy_resource" "sync_example" { + cx_profile_name = "cluster4" + name = "test_sync" + svm_name = "%s" + type = "sync" + sync_type = "sync" + comment = "%s" + retention = [ + { + label = "daily" + count = 1 + } + ] +}`, host, admin, password, svm, comment) +} + +func testAccSnapmirrorPolicyResourceSyncAddExtraRetentionConfigAlias(svm string, comment string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_snapmirror_policy_resource" "sync_example" { + cx_profile_name = "cluster4" + name = "test_sync" + svm_name = "%s" + type = "sync" + sync_type = "sync" + comment = "%s" + retention = [ + { + label = "daily" + count = 1 + }, + { + label = "daily" + count = 1 + } + ] +}`, host, admin, password, svm, comment) +} diff --git a/internal/provider/snapmirror/snapmirror_resource.go b/internal/provider/snapmirror/snapmirror_resource.go index 5b2fc31e..42cc6430 100644 --- a/internal/provider/snapmirror/snapmirror_resource.go +++ b/internal/provider/snapmirror/snapmirror_resource.go @@ -3,10 +3,11 @@ package snapmirror import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strings" "time" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" @@ -34,6 +35,15 @@ func NewSnapmirrorResource() resource.Resource { } } +// NewSnapmirrorResourceAlias is a helper function to simplify the provider implementation. +func NewSnapmirrorResourceAlias() resource.Resource { + return &SnapmirrorResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "snapmirror_resource", + }, + } +} + // SnapmirrorResource defines the resource implementation. type SnapmirrorResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/snapmirror/snapmirror_resource_alias_test.go b/internal/provider/snapmirror/snapmirror_resource_alias_test.go new file mode 100644 index 00000000..052b4fed --- /dev/null +++ b/internal/provider/snapmirror/snapmirror_resource_alias_test.go @@ -0,0 +1,118 @@ +package snapmirror_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccSnapmirrorResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Test non existant Vol + { + Config: testAccSnapmirrorResourceBasicConfigAlias("tf_peer:testme", "terraform:testme"), + ExpectError: regexp.MustCompile("6619337"), + }, + // Create snapmirror and read + { + Config: testAccSnapmirrorResourceBasicConfigAlias("tf_peer:snap_source2", "terraform:snap_dest2"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_resource.example", "destination_endpoint.path", "terraform:snap_dest2"), + ), + }, + // Update a policy + { + Config: testAccSnapmirrorResourceUpdateConfigAlias("tf_peer:snap_source", "terraform:snap_dest", "MirrorAndVault"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_resource.example", "policy.name", "MirrorAndVault"), + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_resource.example", "destination_endpoint.path", "terraform:snap_dest"), + ), + }, + // Import and read + { + ResourceName: "netapp-ontap_snapmirror_resource.example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s", "terraform:snap_dest", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_snapmirror_resource.example", "destination_endpoint.path", "terraform:snap_dest"), + ), + }, + // Delete testing automatically occurs in TestCase + }, + }) +} + +func testAccSnapmirrorResourceBasicConfigAlias(sourceEndpoint string, destinationEndpoint string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST5") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS2") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST5, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_snapmirror_resource" "example" { + cx_profile_name = "cluster4" + source_endpoint = { + path = "%s" + } + destination_endpoint = { + path = "%s" + } +}`, host, admin, password, sourceEndpoint, destinationEndpoint) +} + +func testAccSnapmirrorResourceUpdateConfigAlias(sourceEndpoint string, destinationEndpoint string, policy string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST5") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS2") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST5, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_snapmirror_resource" "example" { + cx_profile_name = "cluster4" + source_endpoint = { + path = "%s" + } + destination_endpoint = { + path = "%s" + } + policy = { + name = "%s" + } +}`, host, admin, password, sourceEndpoint, destinationEndpoint, policy) +} diff --git a/internal/provider/snapmirror/snapmirrors_data_source.go b/internal/provider/snapmirror/snapmirrors_data_source.go index 4502195a..22601af7 100644 --- a/internal/provider/snapmirror/snapmirrors_data_source.go +++ b/internal/provider/snapmirror/snapmirrors_data_source.go @@ -3,6 +3,7 @@ package snapmirror import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewSnapmirrorsDataSource() datasource.DataSource { } } +// NewSnapmirrorsDataSourceAlias is a helper function to simplify the provider implementation. +func NewSnapmirrorsDataSourceAlias() datasource.DataSource { + return &SnapmirrorsDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "snapmirrors_data_source", + }, + } +} + // SnapmirrorsDataSource defines the data source implementation. type SnapmirrorsDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/storage/storage_aggregate_data_source.go b/internal/provider/storage/storage_aggregate_data_source.go index 4718fc72..79133a51 100644 --- a/internal/provider/storage/storage_aggregate_data_source.go +++ b/internal/provider/storage/storage_aggregate_data_source.go @@ -26,6 +26,15 @@ func NewStorageAggregateDataSource() datasource.DataSource { } } +// NewStorageAggregateDataSourceAlias is a helper function to simplify the provider implementation. +func NewStorageAggregateDataSourceAlias() datasource.DataSource { + return &StorageAggregateDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "storage_aggregate_data_source", + }, + } +} + // StorageAggregateDataSource defines the data source implementation. type StorageAggregateDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/storage/storage_aggregate_resource.go b/internal/provider/storage/storage_aggregate_resource.go index 88afb230..d623d85a 100644 --- a/internal/provider/storage/storage_aggregate_resource.go +++ b/internal/provider/storage/storage_aggregate_resource.go @@ -3,9 +3,10 @@ package storage import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strings" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/path" @@ -37,6 +38,15 @@ func NewAggregateResource() resource.Resource { } } +// NewAggregateResourceAlias is a helper function to simplify the provider implementation. +func NewAggregateResourceAlias() resource.Resource { + return &AggregateResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "storage_aggregate_resource", + }, + } +} + // AggregateResource defines the resource implementation. type AggregateResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/storage/storage_aggregate_resource_alias_test.go b/internal/provider/storage/storage_aggregate_resource_alias_test.go new file mode 100644 index 00000000..cc1cbcc6 --- /dev/null +++ b/internal/provider/storage/storage_aggregate_resource_alias_test.go @@ -0,0 +1,70 @@ +package storage_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccStorageAggregateResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccStorageAggregateResourceConfigAlias("non-existant"), + ExpectError: regexp.MustCompile("is an invalid value"), + }, + { + Config: testAccStorageAggregateResourceConfigAlias("swenjun-vsim2"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_aggregate_resource.example", "name", "acc_test_aggr"), + resource.TestCheckNoResourceAttr("netapp-ontap_storage_aggregate_resource.example", "vol"), + ), + }, + // Test importing a resource + { + ResourceName: "netapp-ontap_storage_aggregate_resource.example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s", "acc_test_aggr", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_aggregate_resource.example", "name", "acc_test_aggr"), + ), + }, + }, + }) +} + +func testAccStorageAggregateResourceConfigAlias(node string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST2") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS2") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST2, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_storage_aggregate_resource" "example" { + cx_profile_name = "cluster4" + node = "%s" + name = "acc_test_aggr" + disk_count = 5 +}`, host, admin, password, node) +} diff --git a/internal/provider/storage/storage_aggregates_data_source.go b/internal/provider/storage/storage_aggregates_data_source.go index 7e5244e1..7c9ea736 100644 --- a/internal/provider/storage/storage_aggregates_data_source.go +++ b/internal/provider/storage/storage_aggregates_data_source.go @@ -3,6 +3,7 @@ package storage import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewStorageAggregatesDataSource() datasource.DataSource { } } +// NewStorageAggregatesDataSourceAlias is a helper function to simplify the provider implementation. +func NewStorageAggregatesDataSourceAlias() datasource.DataSource { + return &StorageAggregatesDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "storage_aggregates_data_source", + }, + } +} + // StorageAggregatesDataSource defines the data source implementation. type StorageAggregatesDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/storage/storage_flexcache_data_source.go b/internal/provider/storage/storage_flexcache_data_source.go index ffb0e005..4af9bc85 100644 --- a/internal/provider/storage/storage_flexcache_data_source.go +++ b/internal/provider/storage/storage_flexcache_data_source.go @@ -3,6 +3,7 @@ package storage import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/attr" @@ -25,6 +26,15 @@ func NewStorageFlexcacheDataSource() datasource.DataSource { } } +// NewStorageFlexcacheDataSourceAlias is a helper function to simplify the provider implementation. +func NewStorageFlexcacheDataSourceAlias() datasource.DataSource { + return &StorageFlexcacheDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "storage_flexcache_data_source", + }, + } +} + // StorageFlexcacheDataSource implements the datasource interface and defines the data model for the resource. type StorageFlexcacheDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/storage/storage_flexcache_resource.go b/internal/provider/storage/storage_flexcache_resource.go index ffe3312d..e5abd961 100644 --- a/internal/provider/storage/storage_flexcache_resource.go +++ b/internal/provider/storage/storage_flexcache_resource.go @@ -3,10 +3,11 @@ package storage import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "log" "strings" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" @@ -33,6 +34,15 @@ func NewStorageFlexcacheRsource() resource.Resource { } } +// NewStorageFlexcacheRsourceAlias is a helper function to simplify the provider implementation. +func NewStorageFlexcacheRsourceAlias() resource.Resource { + return &StorageFlexcacheResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "storage_flexcache_resource", + }, + } +} + // StorageFlexcacheResource defines the resource implementation. type StorageFlexcacheResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/storage/storage_flexcache_resource_alias_test.go b/internal/provider/storage/storage_flexcache_resource_alias_test.go new file mode 100644 index 00000000..b9f981ad --- /dev/null +++ b/internal/provider/storage/storage_flexcache_resource_alias_test.go @@ -0,0 +1,159 @@ +package storage_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccStorageFlexcacheResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Test non existant SVM + { + Config: testAccStorageFlexcacheResourceConfigAlias("non-existant", "terraformTest4"), + ExpectError: regexp.MustCompile("2621462"), + }, + // test bad volume name + { + Config: testAccStorageFlexcacheResourceConfigAlias("non-existant", "name-cant-have-dashes"), + ExpectError: regexp.MustCompile("917888"), + }, + // Test create the resource + { + Config: testAccStorageFlexcacheResourceConfigAlias("acc_test", "accFlexcache"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_flexcache_resource.example", "name", "accFlexcache"), + resource.TestCheckNoResourceAttr("netapp-ontap_storage_flexcache_resource.example", "volname"), + ), + }, + // Test create the resource with junction path + { + Config: testAccStorageFlexcacheResourcePathConfigAlias("acc_test", "accFlexcacheJP", "/accFlexcachejp"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_flexcache_resource.jpexample", "name", "accFlexcacheJP"), + resource.TestCheckResourceAttr("netapp-ontap_storage_flexcache_resource.jpexample", "junction_path", "/accFlexcachejp"), + ), + }, + // Test importing a resource + { + ResourceName: "netapp-ontap_storage_flexcache_resource.jpexample", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s,%s", "accFlexcacheJP", "acc_test", "cluster5"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_flexcache_resource.jpexample", "name", "accFlexcache"), + ), + }, + }, + }) +} + +func testAccStorageFlexcacheResourceConfigAlias(svm, volName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST2") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS2") + + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster5" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_storage_flexcache_resource" "example" { + cx_profile_name = "cluster5" + name = "%s" + svm_name = "%s" + + origins = [ + { + volume = { + name = "acc_test_storage_flexcache_origin_volume" + }, + svm = { + name = "acc_test" + } + } + ] + size = 200 + size_unit = "mb" + guarantee = { + type = "none" + } + dr_cache = false + global_file_locking_enabled = false + aggregates = [ + { + name = "acc_test" + } + ] +}`, host, admin, password, volName, svm) +} + +func testAccStorageFlexcacheResourcePathConfigAlias(svm, volName string, junctionPath string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST2") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS2") + + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster5" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} +resource "netapp-ontap_storage_flexcache_resource" "jpexample" { + cx_profile_name = "cluster5" + name = "%s" + svm_name = "%s" + origins = [ + { + volume = { + name = "acc_test_storage_flexcache_origin_volume" + }, + svm = { + name = "acc_test" + } + } + ] + size = 200 + size_unit = "mb" + guarantee = { + type = "none" + } + dr_cache = false + junction_path = "%s" + global_file_locking_enabled = false + aggregates = [ + { + name = "acc_test" + } + ] +}`, host, admin, password, volName, svm, junctionPath) +} diff --git a/internal/provider/storage/storage_flexcaches_data_source.go b/internal/provider/storage/storage_flexcaches_data_source.go index 0f0644ab..281de987 100644 --- a/internal/provider/storage/storage_flexcaches_data_source.go +++ b/internal/provider/storage/storage_flexcaches_data_source.go @@ -3,9 +3,10 @@ package storage import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "log" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -27,6 +28,15 @@ func NewStorageFlexcachesDataSource() datasource.DataSource { } } +// NewStorageFlexcachesDataSourceAlias is a helper function to simplify the provider implementation. +func NewStorageFlexcachesDataSourceAlias() datasource.DataSource { + return &StorageFlexcachesDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "storage_flexcaches_data_source", + }, + } +} + // StorageFlexcachesDataSource defines the resource implementation. type StorageFlexcachesDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/storage/storage_lun_data_source.go b/internal/provider/storage/storage_lun_data_source.go index 27cffeb2..818afe76 100644 --- a/internal/provider/storage/storage_lun_data_source.go +++ b/internal/provider/storage/storage_lun_data_source.go @@ -25,6 +25,15 @@ func NewStorageLunDataSource() datasource.DataSource { } } +// NewStorageLunDataSourceAlias is a helper function to simplify the provider implementation. +func NewStorageLunDataSourceAlias() datasource.DataSource { + return &StorageLunDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "storage_lun_data_source", + }, + } +} + // StorageLunDataSource defines the data source implementation. type StorageLunDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/storage/storage_lun_resource.go b/internal/provider/storage/storage_lun_resource.go index cef10d7f..267d6b87 100644 --- a/internal/provider/storage/storage_lun_resource.go +++ b/internal/provider/storage/storage_lun_resource.go @@ -31,6 +31,15 @@ func NewStorageLunResource() resource.Resource { } } +// NewStorageLunResourceAlias is a helper function to simplify the provider implementation. +func NewStorageLunResourceAlias() resource.Resource { + return &StorageLunResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "storage_lun_resource", + }, + } +} + // StorageLunResource defines the resource implementation. type StorageLunResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/storage/storage_lun_resource_alias_test.go b/internal/provider/storage/storage_lun_resource_alias_test.go new file mode 100644 index 00000000..9ea171a2 --- /dev/null +++ b/internal/provider/storage/storage_lun_resource_alias_test.go @@ -0,0 +1,164 @@ +package storage_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" +) + +func TestAccStorageLunResouceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Test create storage lun svm not found + { + Config: testAccStorageLunResourceConfigAlias("ACC-lun", "unknownsvm", "lunTest", "linux", 1048576), + ExpectError: regexp.MustCompile("2621462"), + }, + // Test create storage lun volume not found + { + Config: testAccStorageLunResourceConfigAlias("ACC-lun", "carchi-test", "unnownsvm", "linux", 1048576), + ExpectError: regexp.MustCompile("917927"), + }, + // Create storage lun and read without size_unit + { + Config: testAccStorageLunResourceConfigAlias("ACC-lun", "carchi-test", "lunTest", "linux", 1048576), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example", "name", "/vol/lunTest/ACC-lun"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example", "svm_name", "carchi-test"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example", "volume_name", "lunTest"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example", "os_type", "linux"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example", "size", "1048576"), + ), + }, + // Update name + { + Config: testAccStorageLunResourceConfigAlias("ACC-lun2", "carchi-test", "lunTest", "linux", 1048576), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example", "logical_unit", "ACC-lun2"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example", "svm_name", "carchi-test"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example", "volume_name", "lunTest"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example", "os_type", "linux"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example", "size", "1048576"), + ), + }, + // Test importing a resource + { + ResourceName: "netapp-ontap_storage_lun_resource.example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s,%s,%s", "/vol/lunTest/ACC-import-lun", "lunTest", "carchi-test", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example", "name", "ACC-import-lun"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example", "os_type", "linux"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example", "size", "1048576"), + ), + }, + // create storage lun with size_unit + { + Config: testAccStorageLunResourceWithSizeUnitConfigAlias("ACC-lun-size", "carchi-test", "lunTest", "linux", 4, "kb"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example_size", "name", "/vol/lunTest/ACC-lun-size"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example_size", "svm_name", "carchi-test"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example_size", "volume_name", "lunTest"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example_size", "os_type", "linux"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example_size", "size", "4"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example_size", "size_unit", "kb"), + ), + }, + // update storage lun with size_unit + { + Config: testAccStorageLunResourceWithSizeUnitConfigAlias("ACC-lun-size", "carchi-test", "lunTest", "linux", 5, "kb"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example_size", "name", "/vol/lunTest/ACC-lun-size"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example_size", "svm_name", "carchi-test"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example_size", "volume_name", "lunTest"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example_size", "os_type", "linux"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example_size", "size", "5"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example_size", "size_unit", "kb"), + ), + }, + // update storage lun size_unit + { + Config: testAccStorageLunResourceWithSizeUnitConfigAlias("ACC-lun-size", "carchi-test", "lunTest", "linux", 5, "mb"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example_size", "name", "/vol/lunTest/ACC-lun-size"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example_size", "svm_name", "carchi-test"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example_size", "volume_name", "lunTest"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example_size", "os_type", "linux"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example_size", "size", "5"), + resource.TestCheckResourceAttr("netapp-ontap_storage_lun_resource.example_size", "size_unit", "mb"), + ), + }, + }, + }) +} + +func testAccStorageLunResourceConfigAlias(logicalUnit string, svmname string, volumeName string, osType string, size int64) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_storage_lun_resource" "example" { + # required to know which system to interface with + cx_profile_name = "cluster4" + logical_unit = "%s" + svm_name = "%s" + volume_name = "%s" + os_type = "%s" + size = "%d" +}`, host, admin, password, logicalUnit, svmname, volumeName, osType, size) +} + +func testAccStorageLunResourceWithSizeUnitConfigAlias(logicalUnit string, svmname string, volumeName string, osType string, size int64, size_unit string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_storage_lun_resource" "example_size" { + # required to know which system to interface with + cx_profile_name = "cluster4" + logical_unit = "%s" + svm_name = "%s" + volume_name = "%s" + os_type = "%s" + size = "%d" + size_unit = "%s" +}`, host, admin, password, logicalUnit, svmname, volumeName, osType, size, size_unit) +} diff --git a/internal/provider/storage/storage_luns_data_source.go b/internal/provider/storage/storage_luns_data_source.go index 4ec4251a..ba770a9d 100644 --- a/internal/provider/storage/storage_luns_data_source.go +++ b/internal/provider/storage/storage_luns_data_source.go @@ -25,6 +25,15 @@ func NewStorageLunsDataSource() datasource.DataSource { } } +// NewStorageLunsDataSourceAlias is a helper function to simplify the provider implementation. +func NewStorageLunsDataSourceAlias() datasource.DataSource { + return &StorageLunsDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "storage_luns_data_source", + }, + } +} + // StorageLunsDataSource defines the data source implementation. type StorageLunsDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/storage/storage_snapshot_policies_data_source.go b/internal/provider/storage/storage_snapshot_policies_data_source.go index cbd51c71..9d35be8c 100644 --- a/internal/provider/storage/storage_snapshot_policies_data_source.go +++ b/internal/provider/storage/storage_snapshot_policies_data_source.go @@ -3,6 +3,7 @@ package storage import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewSnapshotPoliciesDataSource() datasource.DataSource { } } +// NewSnapshotPoliciesDataSourceAlias is a helper function to simplify the provider implementation. +func NewSnapshotPoliciesDataSourceAlias() datasource.DataSource { + return &SnapshotPoliciesDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "storage_snapshot_policies_data_source", + }, + } +} + // SnapshotPoliciesDataSource defines the data source implementation. type SnapshotPoliciesDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/storage/storage_snapshot_policy_alias_test.go b/internal/provider/storage/storage_snapshot_policy_alias_test.go new file mode 100644 index 00000000..7119028b --- /dev/null +++ b/internal/provider/storage/storage_snapshot_policy_alias_test.go @@ -0,0 +1,92 @@ +package storage_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccStorageSnapshotPolicyResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Test create storage snapshot policy error + { + Config: testAccStorageSnapshotPolicyResourceConfigAlias("non-existant", "unknowsvm", "wrong case", false), + ExpectError: regexp.MustCompile("error creating storage_snapshot_policy"), + }, + // Create storage snapshot policy and read + { + Config: testAccStorageSnapshotPolicyResourceConfigAlias("tf-sn-policy", "carchi-test", "create a test snapshot policy", true), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_snapshot_policy_resource.example", "name", "tf-sn-policy"), + resource.TestCheckResourceAttr("netapp-ontap_storage_snapshot_policy_resource.example", "comment", "create a test snapshot policy"), + resource.TestCheckResourceAttr("netapp-ontap_storage_snapshot_policy_resource.example", "enabled", "true"), + ), + }, + // Update storage snapshot policy on comment and read + { + Config: testAccStorageSnapshotPolicyResourceConfigAlias("tf-sn-policy", "carchi-test", "Update the existing snapshot policy", true), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_snapshot_policy_resource.example", "name", "tf-sn-policy"), + resource.TestCheckResourceAttr("netapp-ontap_storage_snapshot_policy_resource.example", "comment", "Update the existing snapshot policy"), + resource.TestCheckResourceAttr("netapp-ontap_storage_snapshot_policy_resource.example", "enabled", "true"), + ), + }, + // Test importing a resource + { + ResourceName: "netapp-ontap_storage_snapshot_policy_resource.example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s,%s", "tfimportpolicy", "carchi-test", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_snapshot_policy_resource.example", "name", "tfimportpolicy"), + ), + }, + }, + }) +} + +func testAccStorageSnapshotPolicyResourceConfigAlias(name string, svmname string, comment string, enabled bool) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_storage_snapshot_policy_resource" "example" { + # required to know which system to interface with + cx_profile_name = "cluster4" + name = "%s" + svm_name = "%s" + comment = "%s" + enabled = "%t" + copies = [ + { + count = 3 + schedule = { + name = "daily" + } + }, + ] +}`, host, admin, password, name, svmname, comment, enabled) +} diff --git a/internal/provider/storage/storage_snapshot_policy_data_source.go b/internal/provider/storage/storage_snapshot_policy_data_source.go index 7449fdd4..22937b87 100644 --- a/internal/provider/storage/storage_snapshot_policy_data_source.go +++ b/internal/provider/storage/storage_snapshot_policy_data_source.go @@ -3,6 +3,7 @@ package storage import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewSnapshotPolicyDataSource() datasource.DataSource { } } +// NewSnapshotPolicyDataSourceAlias is a helper function to simplify the provider implementation. +func NewSnapshotPolicyDataSourceAlias() datasource.DataSource { + return &SnapshotPolicyDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "storage_snapshot_policy_data_source", + }, + } +} + // SnapshotPolicyDataSource defines the data source implementation. type SnapshotPolicyDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/storage/storage_snapshot_policy_resource.go b/internal/provider/storage/storage_snapshot_policy_resource.go index addf87b9..168a1e4f 100644 --- a/internal/provider/storage/storage_snapshot_policy_resource.go +++ b/internal/provider/storage/storage_snapshot_policy_resource.go @@ -3,9 +3,10 @@ package storage import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strings" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" @@ -36,6 +37,15 @@ func NewSnapshotPolicyResource() resource.Resource { } } +// NewSnapshotPolicyResource is a helper function to simplify the provider implementation. +func NewSnapshotPolicyResourceAlias() resource.Resource { + return &SnapshotPolicyResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "storage_snapshot_policy_resource", + }, + } +} + // SnapshotPolicyResource defines the resource implementation. type SnapshotPolicyResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/storage/storage_volume_data_source.go b/internal/provider/storage/storage_volume_data_source.go index d6d3ce33..c241ef16 100644 --- a/internal/provider/storage/storage_volume_data_source.go +++ b/internal/provider/storage/storage_volume_data_source.go @@ -24,6 +24,15 @@ func NewStorageVolumeDataSource() datasource.DataSource { } } +// NewStorageVolumeDataSourceAlias is a helper function to simplify the provider implementation. +func NewStorageVolumeDataSourceAlias() datasource.DataSource { + return &StorageVolumeDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "storage_volume_data_source", + }, + } +} + // StorageVolumeDataSource defines the data source implementation. type StorageVolumeDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/storage/storage_volume_resource.go b/internal/provider/storage/storage_volume_resource.go index cb6ef534..48ff3abb 100644 --- a/internal/provider/storage/storage_volume_resource.go +++ b/internal/provider/storage/storage_volume_resource.go @@ -38,6 +38,15 @@ func NewStorageVolumeResource() resource.Resource { } } +// NewStorageVolumeResourceAlias is a helper function to simplify the provider implementation. +func NewStorageVolumeResourceAlias() resource.Resource { + return &StorageVolumeResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "storage_volume_resource", + }, + } +} + // StorageVolumeResource defines the resource implementation. type StorageVolumeResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/storage/storage_volume_resource_alias_test.go b/internal/provider/storage/storage_volume_resource_alias_test.go new file mode 100644 index 00000000..fd80f18b --- /dev/null +++ b/internal/provider/storage/storage_volume_resource_alias_test.go @@ -0,0 +1,164 @@ +package storage_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccStorageVolumeResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Test non existant SVM + { + Config: testAccStorageVolumeResourceConfigAlias("non-existant", "terraformTest4"), + ExpectError: regexp.MustCompile("2621462"), + }, + // test bad volume name + { + Config: testAccStorageVolumeResourceConfigAlias("non-existant", "name-cant-have-dashes"), + ExpectError: regexp.MustCompile("917888"), + }, + // Read testing + { + Config: testAccStorageVolumeResourceConfigAlias("acc_test", "accVolume1"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_volume_resource.example", "name", "accVolume1"), + resource.TestCheckNoResourceAttr("netapp-ontap_storage_volume_resource.example", "volname"), + ), + }, + { + Config: testAccStorageVolumeResourceConfigAliasUpdate("automation", "accVolume1"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_volume_resource.example", "name", "accVolume1"), + resource.TestCheckResourceAttr("netapp-ontap_storage_volume_resource.example", "nas.group_id", "10"), + resource.TestCheckNoResourceAttr("netapp-ontap_storage_volume_resource.example", "volname"), + ), + }, + // Test importing a resource + { + ResourceName: "netapp-ontap_storage_volume_resource.example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s,%s", "acc_test_root", "acc_test", "cluster5"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_volume_resource.example", "name", "automation"), + ), + }, + }, + }) +} + +func testAccStorageVolumeResourceConfigAlias(svm, volName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST2") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS2") + + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster5" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_storage_volume_resource" "example" { + cx_profile_name = "cluster5" + name = "%s" + svm_name = "%s" + aggregates = [ + {name = "acc_test"} +] + space_guarantee = "none" + snapshot_policy = "default-1weekly" + space = { + size = 30 + size_unit = "mb" + percent_snapshot_space = 10 + logical_space = { + enforcement = true + reporting = true + } + } + tiering = { + policy_name = "all" + } + nas = { + export_policy_name = "test" + group_id = 1 + user_id = 2 + unix_permissions = "100" + security_style = "mixed" + junction_path = "/testacc" + } +}`, host, admin, password, volName, svm) +} + +func testAccStorageVolumeResourceConfigAliasUpdate(svm, volName string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST2") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS2") + + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS2 must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster5" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_storage_volume_resource" "example" { + cx_profile_name = "cluster5" + name = "%s" + svm_name = "%s" + aggregates = [ + {name = "acc_test"} +] + space_guarantee = "none" + snapshot_policy = "default-1weekly" + space = { + size = 30 + size_unit = "mb" + percent_snapshot_space = 20 + logical_space = { + enforcement = true + reporting = true + } + } + tiering = { + policy_name = "all" + } + nas = { + export_policy_name = "test" + group_id = 10 + user_id = 20 + unix_permissions = "755" + security_style = "mixed" + junction_path = "/testacc" + } +}`, host, admin, password, volName, svm) +} diff --git a/internal/provider/storage/storage_volume_snapshot_data_source.go b/internal/provider/storage/storage_volume_snapshot_data_source.go index 514923c6..b6f8e0e5 100644 --- a/internal/provider/storage/storage_volume_snapshot_data_source.go +++ b/internal/provider/storage/storage_volume_snapshot_data_source.go @@ -3,6 +3,7 @@ package storage import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewStorageVolumeSnapshotDataSource() datasource.DataSource { } } +// NewStorageVolumeSnapshotDataSourceAlias is a helper function to simplify the provider implementation. +func NewStorageVolumeSnapshotDataSourceAlias() datasource.DataSource { + return &StorageVolumeSnapshotDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "storage_volume_snapshot_data_source", + }, + } +} + // StorageVolumeSnapshotDataSource defines the data source implementation. type StorageVolumeSnapshotDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/storage/storage_volume_snapshot_resource.go b/internal/provider/storage/storage_volume_snapshot_resource.go index 974a307f..efb5cdb2 100644 --- a/internal/provider/storage/storage_volume_snapshot_resource.go +++ b/internal/provider/storage/storage_volume_snapshot_resource.go @@ -3,9 +3,10 @@ package storage import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strings" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" @@ -30,6 +31,15 @@ func NewStorageVolumeSnapshotResource() resource.Resource { } } +// NewStorageVolumeSnapshotResourceAlias is a helper function to simplify the provider implementation. +func NewStorageVolumeSnapshotResourceAlias() resource.Resource { + return &StorageVolumeSnapshotResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "storage_volume_snapshot_resource", + }, + } +} + // StorageVolumeSnapshotResource defines the resource implementation. type StorageVolumeSnapshotResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/storage/storage_volume_snapshot_resource_alias_test.go b/internal/provider/storage/storage_volume_snapshot_resource_alias_test.go new file mode 100644 index 00000000..aa00d7e6 --- /dev/null +++ b/internal/provider/storage/storage_volume_snapshot_resource_alias_test.go @@ -0,0 +1,85 @@ +package storage_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccStorageVolumeSnapshotResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // non-existant SVM return code 2621462. Must happen before create/read + { + Config: testAccStorageVolumeSnapshotResourceConfigAlias("non-existant", "my comment"), + ExpectError: regexp.MustCompile("svm non-existant not found"), + }, + // Create and read testing + { + Config: testAccStorageVolumeSnapshotResourceConfigAlias("carchi-test", "my comment"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_volume_snapshot_resource.example", "volume_name", "carchi_test_root"), + resource.TestCheckResourceAttr("netapp-ontap_storage_volume_snapshot_resource.example", "name", "snaptest"), + resource.TestCheckResourceAttr("netapp-ontap_storage_volume_snapshot_resource.example", "svm_name", "carchi-test"), + resource.TestCheckResourceAttr("netapp-ontap_storage_volume_snapshot_resource.example", "comment", "my comment"), + ), + }, + // Update and read testing + { + Config: testAccStorageVolumeSnapshotResourceConfigAlias("carchi-test", "new comment"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_volume_snapshot_resource.example", "volume_name", "carchi_test_root"), + resource.TestCheckResourceAttr("netapp-ontap_storage_volume_snapshot_resource.example", "name", "snaptest"), + resource.TestCheckResourceAttr("netapp-ontap_storage_volume_snapshot_resource.example", "svm_name", "carchi-test"), + resource.TestCheckResourceAttr("netapp-ontap_storage_volume_snapshot_resource.example", "comment", "new comment"), + ), + }, + // Test importing a resource + { + ResourceName: "netapp-ontap_storage_volume_snapshot_resource.example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s,%s,%s", "snaptest", "carchi_test_root", "carchi-test", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_storage_volume_snapshot_resource.example", "name", "snaptest"), + ), + }, + }, + }) +} + +func testAccStorageVolumeSnapshotResourceConfigAlias(svmName string, comment string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_storage_volume_snapshot_resource" "example" { + cx_profile_name = "cluster4" + name = "snaptest" + volume_name = "carchi_test_root" + svm_name = "%s" + comment = "%s" +}`, host, admin, password, svmName, comment) +} diff --git a/internal/provider/storage/storage_volume_snapshots_data_source.go b/internal/provider/storage/storage_volume_snapshots_data_source.go index e0888d40..b0d1ddf6 100644 --- a/internal/provider/storage/storage_volume_snapshots_data_source.go +++ b/internal/provider/storage/storage_volume_snapshots_data_source.go @@ -3,6 +3,7 @@ package storage import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewStorageVolumeSnapshotsDataSource() datasource.DataSource { } } +// NewStorageVolumeSnapshotsDataSourceAlias is a helper function to simplify the provider implementation. +func NewStorageVolumeSnapshotsDataSourceAlias() datasource.DataSource { + return &StorageVolumeSnapshotsDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "storage_volume_snapshots_data_source", + }, + } +} + // StorageVolumeSnapshotsDataSource defines the data source implementation. type StorageVolumeSnapshotsDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/storage/storage_volumes_data_source.go b/internal/provider/storage/storage_volumes_data_source.go index b88a46e8..706a610e 100644 --- a/internal/provider/storage/storage_volumes_data_source.go +++ b/internal/provider/storage/storage_volumes_data_source.go @@ -3,6 +3,7 @@ package storage import ( "context" "fmt" + "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -24,6 +25,15 @@ func NewStorageVolumesDataSource() datasource.DataSource { } } +// NewStorageVolumesDataSourceAlias is a helper function to simplify the provider implementation. +func NewStorageVolumesDataSourceAlias() datasource.DataSource { + return &StorageVolumesDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "storage_volumes_data_source", + }, + } +} + // StorageVolumesDataSource defines the data source implementation. type StorageVolumesDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/svm/svm_data_source.go b/internal/provider/svm/svm_data_source.go index a7c4eba9..9302d7d1 100644 --- a/internal/provider/svm/svm_data_source.go +++ b/internal/provider/svm/svm_data_source.go @@ -3,6 +3,7 @@ package svm import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewSvmDataSource() datasource.DataSource { } } +// NewSvmDataSourceAlias is a helper function to simplify the provider implementation. +func NewSvmDataSourceAlias() datasource.DataSource { + return &SvmDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "svm_data_source", + }, + } +} + // SvmDataSource defines the data source implementation. type SvmDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/svm/svm_peer_data_source.go b/internal/provider/svm/svm_peer_data_source.go index 7f6e2a9e..a1d5cc58 100644 --- a/internal/provider/svm/svm_peer_data_source.go +++ b/internal/provider/svm/svm_peer_data_source.go @@ -3,6 +3,7 @@ package svm import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/snapmirror" @@ -26,6 +27,15 @@ func NewSVMPeerDataSource() datasource.DataSource { } } +// NewSVMPeerDataSourceAlias is a helper function to simplify the provider implementation. +func NewSVMPeerDataSourceAlias() datasource.DataSource { + return &SVMPeerDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "svm_peer_data_source", + }, + } +} + // SVMPeerDataSource defines the data source implementation. type SVMPeerDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/svm/svm_peer_resource.go b/internal/provider/svm/svm_peer_resource.go index ac8e821e..7e80ecb5 100644 --- a/internal/provider/svm/svm_peer_resource.go +++ b/internal/provider/svm/svm_peer_resource.go @@ -33,6 +33,15 @@ func NewSVMPeerResource() resource.Resource { } } +// NewSVMPeerResourceAlias is a helper function to simplify the provider implementation. +func NewSVMPeerResourceAlias() resource.Resource { + return &SVMPeersResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "svm_peers_resource", + }, + } +} + // SVMPeersResource defines the resource implementation. type SVMPeersResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/svm/svm_peer_resource_alias_test.go b/internal/provider/svm/svm_peer_resource_alias_test.go new file mode 100644 index 00000000..f0d26d74 --- /dev/null +++ b/internal/provider/svm/svm_peer_resource_alias_test.go @@ -0,0 +1,98 @@ +package svm_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccSvmPeerResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Test cluster peer non existant to do svm peer + { + Config: testAccSvmPeerResourceConfigAlias("testme", "testme2", "abcd", "snapmirror"), + ExpectError: regexp.MustCompile("9895941"), + }, + // Testing in VSIM is failing to peer + // // Create svm peer and read + // { + // Config: testAccSvmPeersResourceConfig("acc_test_peer2", "acc_test2", "swenjuncluster-1", "snapmirror"), + // Check: resource.ComposeTestCheckFunc( + // resource.TestCheckResourceAttr("netapp-ontap_svm_peers_resources.example", "svm.name", "acc_test_peer2"), + // ), + // }, + // // Update applications + // { + // Config: testAccSvmPeersResourceConfig("acc_test_peer2", "acc_test2", "swenjuncluster-1", "flexcache"), + // Check: resource.ComposeTestCheckFunc( + // resource.TestCheckResourceAttr("netapp-ontap_svm_peers_resources.example", "applications.0", "flexcache"), + // resource.TestCheckResourceAttr("netapp-ontap_svm_peers_resources.example", "svm.name", "acc_test_peer2"), + // ), + // }, + // Import and read + { + ResourceName: "netapp-ontap_svm_peers_resource.example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s,%s,%s", "terraform", "tf_peer", "swenjuncluster-1", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_svm_peers_resource.example", "svm.name", "snapmirror_dest_dp"), + ), + }, + }, + }) +} +func testAccSvmPeerResourceConfigAlias(svm, peerSvm, peerCluster, applications string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST5") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + password2 := os.Getenv("TF_ACC_NETAPP_PASS2") + host2 := os.Getenv("TF_ACC_NETAPP_HOST2") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST2, TF_ACC_NETAPP_HOST5, TF_ACC_NETAPP_USER, TF_ACC_NETAPP_PASS2 and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + { + name = "cluster3" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_svm_peers_resource" "example" { + cx_profile_name = "cluster4" + svm = { + name = "%s" + } + peer = { + svm = { + name = "%s" + } + cluster = { + name = "%s" + } + peer_cx_profile_name = "cluster3" + } + applications = ["%s"] +}`, host, admin, password2, host2, admin, password2, svm, peerSvm, peerCluster, applications) +} diff --git a/internal/provider/svm/svm_peers_data_source.go b/internal/provider/svm/svm_peers_data_source.go index a6dfd593..7945241a 100644 --- a/internal/provider/svm/svm_peers_data_source.go +++ b/internal/provider/svm/svm_peers_data_source.go @@ -3,6 +3,7 @@ package svm import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/snapmirror" @@ -26,6 +27,15 @@ func NewSVMPeersDataSource() datasource.DataSource { } } +// NewSVMPeersDataSourceAlias is a helper function to simplify the provider implementation. +func NewSVMPeersDataSourceAlias() datasource.DataSource { + return &SVMPeersDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "svm_peers_data_source", + }, + } +} + // SVMPeersDataSource defines the data source implementation. type SVMPeersDataSource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/svm/svm_resource.go b/internal/provider/svm/svm_resource.go index 994ef3ab..f651431e 100644 --- a/internal/provider/svm/svm_resource.go +++ b/internal/provider/svm/svm_resource.go @@ -3,9 +3,10 @@ package svm import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strings" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" + "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" @@ -30,6 +31,15 @@ func NewSvmResource() resource.Resource { } } +// NewSvmResourceAlias is a helper function to simplify the provider implementation. +func NewSvmResourceAlias() resource.Resource { + return &SvmResource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "svm_resource", + }, + } +} + // SvmResource defines the resource implementation. type SvmResource struct { config connection.ResourceOrDataSourceConfig diff --git a/internal/provider/svm/svm_resource_alias_test.go b/internal/provider/svm/svm_resource_alias_test.go new file mode 100644 index 00000000..78eb29aa --- /dev/null +++ b/internal/provider/svm/svm_resource_alias_test.go @@ -0,0 +1,123 @@ +package svm_test + +import ( + "fmt" + "os" + "regexp" + "testing" + + ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccSvmResourceAlias(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { ntest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccSvmResourceConfigAlias("tfsvm4", "test", "default"), + Check: resource.ComposeTestCheckFunc( + // Check to see the svm name is correct, + resource.TestCheckResourceAttr("netapp-ontap_svm_resource.example", "name", "tfsvm4"), + // Check to see if Ipspace is set correctly + resource.TestCheckResourceAttr("netapp-ontap_svm_resource.example", "ipspace", "ansibleIpspace_newname"), + // Check that a ID has been set (we don't know what the vaule is as it changes + resource.TestCheckResourceAttrSet("netapp-ontap_svm_resource.example", "id"), + resource.TestCheckResourceAttr("netapp-ontap_svm_resource.example", "comment", "test")), + }, + // Update a comment + { + Config: testAccSvmResourceConfigAlias("tfsvm4", "carchi8py was here", "default"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_svm_resource.example", "comment", "carchi8py was here"), + resource.TestCheckResourceAttr("netapp-ontap_svm_resource.example", "name", "tfsvm4")), + }, + // Update a comment with an empty string + { + Config: testAccSvmResourceConfigAlias("tfsvm4", "", "default"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_svm_resource.example", "comment", ""), + resource.TestCheckResourceAttr("netapp-ontap_svm_resource.example", "name", "tfsvm4")), + }, + // Update snapshot policy default-1weekly and comment "carchi8py was here" + { + Config: testAccSvmResourceConfigAlias("tfsvm4", "carchi8py was here", "default-1weekly"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_svm_resource.example", "comment", "carchi8py was here"), + resource.TestCheckResourceAttr("netapp-ontap_svm_resource.example", "snapshot_policy", "default-1weekly"), + resource.TestCheckResourceAttr("netapp-ontap_svm_resource.example", "name", "tfsvm4")), + }, + // Update snapshot policy with empty string + { + Config: testAccSvmResourceConfigAlias("tfsvm4", "carchi8py was here", ""), + ExpectError: regexp.MustCompile("cannot be updated with empty string"), + }, + // change SVM name + { + Config: testAccSvmResourceConfigAlias("tfsvm3", "carchi8py was here", "default"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_svm_resource.example", "comment", "carchi8py was here"), + resource.TestCheckResourceAttr("netapp-ontap_svm_resource.example", "name", "tfsvm3")), + }, + // Fail if the name already exist + { + Config: testAccSvmResourceConfigAlias("svm5", "carchi8py was here", "default"), + ExpectError: regexp.MustCompile("13434908"), + }, + // Import and read + { + ResourceName: "netapp-ontap_svm_resource.example", + ImportState: true, + ImportStateId: fmt.Sprintf("%s,%s", "ansibleSVM", "cluster4"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("netapp-ontap_svm_resource.example", "name", "ansibleSVM"), + ), + }, + }, + }) +} +func testAccSvmResourceConfigAlias(svm, comment string, snapshotPolicy string) string { + host := os.Getenv("TF_ACC_NETAPP_HOST") + admin := os.Getenv("TF_ACC_NETAPP_USER") + password := os.Getenv("TF_ACC_NETAPP_PASS") + if host == "" || admin == "" || password == "" { + fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") + os.Exit(1) + } + return fmt.Sprintf(` +provider "netapp-ontap" { + connection_profiles = [ + { + name = "cluster4" + hostname = "%s" + username = "%s" + password = "%s" + validate_certs = false + }, + ] +} + +resource "netapp-ontap_svm_resource" "example" { + cx_profile_name = "cluster4" + name = "%s" + ipspace = "ansibleIpspace_newname" + comment = "%s" + snapshot_policy = "%s" + subtype = "default" + language = "en_us.utf_8" + aggregates = [ + { + name = "aggr1" + }, + { + name = "aggr2" + }, + { + name = "aggr3" + }, + ] + max_volumes = "unlimited" +}`, host, admin, password, svm, comment, snapshotPolicy) +} diff --git a/internal/provider/svm/svms_data_source.go b/internal/provider/svm/svms_data_source.go index 35066881..30323e8c 100644 --- a/internal/provider/svm/svms_data_source.go +++ b/internal/provider/svm/svms_data_source.go @@ -3,6 +3,7 @@ package svm import ( "context" "fmt" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -25,6 +26,15 @@ func NewSvmsDataSource() datasource.DataSource { } } +// NewSvmsDataSourceAlias is a helper function to simplify the provider implementation. +func NewSvmsDataSourceAlias() datasource.DataSource { + return &SvmsDataSource{ + config: connection.ResourceOrDataSourceConfig{ + Name: "svms_data_source", + }, + } +} + // SvmsDataSource defines the data source implementation. type SvmsDataSource struct { config connection.ResourceOrDataSourceConfig