Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 2.3.0

DOCUMENTATION:

- **netapp-ontap_lun**: updated documentation, added attribute validation ([#498](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/498))

ENHANCEMENTS:

- **netapp-ontap_lun**: added `space.scsi_thin_provisioning_support_enabled` option. ([#496](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/496))
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/lun.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ data "netapp-ontap_lun" "storage_lun" {
- `id` (String) Lun uuid
- `os_type` (String) OS type for lun
- `qos_policy` (Attributes) (see [below for nested schema](#nestedatt--qos_policy))
- `serial_number` (String) Serial number for lun
- `space` (Attributes) (see [below for nested schema](#nestedatt--space))

<a id="nestedatt--location"></a>
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/luns.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Read-Only:
- `name` (String) StorageLun name
- `os_type` (String) OS type for lun
- `qos_policy` (Attributes) (see [below for nested schema](#nestedatt--storage_luns--qos_policy))
- `serial_number` (String) Serial number for lun
- `space` (Attributes) (see [below for nested schema](#nestedatt--storage_luns--space))
- `svm_name` (String) StorageLun svm name

Expand Down
24 changes: 13 additions & 11 deletions docs/resources/lun.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ Create/Modify/Delete a lun resource
resource "netapp-ontap_lun" "storage_lun" {
# required to know which system to interface with
cx_profile_name = "cluster4"
name = "ACC-import-lun"
name = "/vol/vol1/lun1"
logical_unit = "lun1"
svm_name = "carchi-test"
volume_name = "lunTest"
volume_name = "vol1"
os_type = "linux"
size = 1048576
}

```

<!-- schema generated by tfplugindocs -->
Expand All @@ -44,21 +44,23 @@ resource "netapp-ontap_lun" "storage_lun" {
### Required

- `cx_profile_name` (String) Connection profile name
- `name` (String) Lun name or location.logical_unit
- `os_type` (String) OS type
- `size` (Number) Size of the lun in byte if size_unit is not provided, otherwise size in the specified `size_unit`
- `svm_name` (String) SVM name
- `volume_name` (String) Volume name
- `os_type` (String) The operating system type of the LUN
- `size` (Number) Size of the lun in byte if size_unit is not provided, otherwise size in the specified unit
- `svm_name` (String) The name of the SVM in which the LUN is located
- `volume_name` (String) The volume in which the LUN is located

### Optional

- `logical_unit` (String) The base name component of the LUN
- `name` (String) Path for the LUN you want to create or modify. Example of correct LUN path: /vol/vol1/lun1. At least one of `name` or `logical_unit` must be provided.
- `qos_policy_name` (String) QoS policy name
- `scsi_thin_provisioning_support_enabled` (Boolean) Specifies the value for the space allocation attribute, which determines if the LUN supports the SCSI Thin Provisioning features
- `size_unit` (String) The unit used to interpret the size parameter

### Read-Only

- `id` (String) StorageLun UUID
- `serial_number` (String) Serial number for lun

## Import

Expand Down Expand Up @@ -102,14 +104,14 @@ This will generate a file called generated.tf, which will contain the configurat
# __generated__ by Terraform
# Please review these resources and move them into your main configuration files.

# __generated__ by Terraform from "ACC-import-lun,lunTest,carchi-test,cluster4"
# __generated__ by Terraform from "ACC-import-lun,vol1,carchi-test,cluster4"
resource "netapp-ontap_lun" "lun_import" {
cx_profile_name = "cluster4"
name = "ACC-import-lun"
name = "/vol/vol1/ACC-import-lun"
os_type = "linux"
qos_policy_name = null
size = 1048576
svm_name = "carchi-test"
volume_name = "lunTest"
volume_name = "vol1"
}
```
21 changes: 16 additions & 5 deletions internal/provider/storage/storage_lun_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/netapp/terraform-provider-netapp-ontap/internal/interfaces"
"github.com/netapp/terraform-provider-netapp-ontap/internal/utils"
Expand Down Expand Up @@ -79,31 +80,31 @@ func (r *StorageLunResource) Schema(ctx context.Context, req resource.SchemaRequ
Required: true,
},
"name": schema.StringAttribute{
MarkdownDescription: "Lun name",
MarkdownDescription: "Path for the LUN you want to create or modify. Example of correct LUN path: /vol/vol1/lun1",
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"logical_unit": schema.StringAttribute{
MarkdownDescription: "Logical unit for lun",
MarkdownDescription: "The base name component of the LUN",
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"svm_name": schema.StringAttribute{
MarkdownDescription: "SVM name",
MarkdownDescription: "The name of the SVM in which the LUN is located",
Required: true,
},
"volume_name": schema.StringAttribute{
MarkdownDescription: "Volume name",
MarkdownDescription: "The volume in which the LUN is located",
Required: true,
},
"os_type": schema.StringAttribute{
MarkdownDescription: "OS type",
MarkdownDescription: "The operating system type of the LUN",
Required: true,
},
"size": schema.Int64Attribute{
Expand Down Expand Up @@ -160,6 +161,16 @@ func (r *StorageLunResource) Configure(ctx context.Context, req resource.Configu
r.config.ProviderConfig = config
}

// ConfigValidators validates entire resource configurations
func (d *StorageLunResource) ConfigValidators(ctx context.Context) []resource.ConfigValidator {
return []resource.ConfigValidator{
resourcevalidator.AtLeastOneOf(
path.MatchRoot("name"),
path.MatchRoot("logical_unit"),
),
}
}

// Read refreshes the Terraform state with the latest data.
func (r *StorageLunResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
var data StorageLunResourceModel
Expand Down
Loading