Skip to content

Commit

Permalink
Merge pull request #234 from NetApp/136-new-resource-storagequotarules
Browse files Browse the repository at this point in the history
new resource quota rules
  • Loading branch information
suhasbshekar authored Jul 18, 2024
2 parents 67378db + 47d2b0f commit ed72bd0
Show file tree
Hide file tree
Showing 13 changed files with 917 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

FEATURES:
* **New Data Source:** `netapp-ontap_volumes_files` ([#8](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/8))
* **New Resource:** `netapp-ontap_quota_rules` ([#136](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/136))

ENHANCEMENTS:
* **netapp-ontap_lun**: added `size_unit` option. ([#227](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/227))
Expand Down
7 changes: 2 additions & 5 deletions docs/resources/storage_lun_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ resource "netapp-ontap_lun" "storage_lun" {
- `id` (String) StorageLun UUID

## Import
This Resource supports import, which allows you to import existing aggregates into the state of this resoruce.
This Resource supports import, which allows you to import existing lun into the state of this resoruce.
Import require a unique ID composed of the lun name, volume name, svm name, and cx_profile_name, separated by a comma.

id = `name`,`volume_name`, `svm_name`, `cx_profile_name`
Expand Down Expand Up @@ -103,7 +103,4 @@ resource "netapp-ontap_lun" "lun_import" {
svm_name = "carchi-test"
volume_name = "lunTest"
}
}
```

```
171 changes: 171 additions & 0 deletions docs/resources/storage_quota_rules_resource.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "netapp-ontap_quota_rules Resource - terraform-provider-netapp-ontap"
subcategory: "Storage"
description: |-
StorageQuotaRules resource
---

# Resource Quota Rules

Create/Modify/Delete a quota rules resource

### Related ONTAP commands
```commandline
* quota policy rule create
* quota policy rule modify
* quota policy rule delete
```

## Supported Platforms
* On-perm ONTAP system 9.6 or higher

## Example Usage

```terraform
resource "netapp-ontap_quota_rules" "storage_quota_rules" {
# required to know which system to interface with
cx_profile_name = "cluster2"
volume = {
name = "lunTest"
}
svm = {
name = "test"
}
type = "tree"
qtree = {
name = "test"
}
files = {
hard_limit = 100
soft_limit = 70
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `cx_profile_name` (String) Connection profile name
- `qtree` (Attributes) Qtree for which to create the rule. For default tree rules, the qtree name must be specified as "" (see [below for nested schema](#nestedatt--qtree))
- `svm` (Attributes) Existing SVM in which to create the qtree (see [below for nested schema](#nestedatt--svm))
- `type` (String) Quota type for the rule. This type can be user, group, or tree
- `volume` (Attributes) Existing volume in which to create the qtree (see [below for nested schema](#nestedatt--volume))

### Optional

- `files` (Attributes) (see [below for nested schema](#nestedatt--files))
- `group` (Attributes) If the quota type is group, this property takes the group name. For default group quota rules, the group name must be specified as "" (see [below for nested schema](#nestedatt--group))
- `users` (Attributes Set) If the quota type is user, this property takes the user name. For default user quota rules, the user name must be specified as "" (see [below for nested schema](#nestedatt--users))

### Read-Only

- `id` (String) The ID of this resource.

<a id="nestedatt--qtree"></a>
### Nested Schema for `qtree`

Required:

- `name` (String) name of the qtree


<a id="nestedatt--svm"></a>
### Nested Schema for `svm`

Required:

- `name` (String) name of the SVM


<a id="nestedatt--volume"></a>
### Nested Schema for `volume`

Required:

- `name` (String) name of the volume


<a id="nestedatt--files"></a>
### Nested Schema for `files`

Optional:

- `hard_limit` (Number) Specifies the hard limit for files
- `soft_limit` (Number) Specifies the soft limit for files


<a id="nestedatt--group"></a>
### Nested Schema for `group`

Required:

- `name` (String) name of the group


<a id="nestedatt--users"></a>
### Nested Schema for `users`

Optional:

- `name` (String) name of the user

## Import
This Resource supports import, which allows you to import existing quota rules into the state of this resoruce.
Import require a unique ID composed of the volume name, svm name, type, qtree and cx_profile_name, separated by a comma.

id = `name`,`volume_name`, `svm_name`, `cx_profile_name`

### Terraform Import

For example
```shell
terraform import netapp-ontap_quota_rules.example vol,svm,tree,test,cluster4
```

!> The terraform import CLI command can only import resources into the state. Importing via the CLI does not generate configuration. If you want to generate the accompanying configuration for imported resources, use the import block instead.

### Terraform Import Block
This requires Terraform 1.5 or higher, and will auto create the configuration for you

First create the block
```terraform
import {
to = netapp-ontap_quota_rules.lun_import
id = "vol,svm,tree,test,cluster4"
}
```
Next run, this will auto create the configuration for you
```shell
terraform plan -generate-config-out=generated.tf
```
This will generate a file called generated.tf, which will contain the configuration for the imported resource
```terraform
# __generated__ by Terraform
# Please review these resources and move them into your main configuration files.
# __generated__ by Terraform from "vol,svm,tree,test,cluster4"
resource "netapp-ontap_quota_rules" "storage_quota_rules" {
cx_profile_name = "cluster4"
files = {
hard_limit = 100
soft_limit = 80
}
group = null
id = "abcd"
qtree = {
name = "testacc"
}
svm = {
name = "carchi-test"
}
type = "tree"
users = null
volume = {
name = "lunTest"
}
}
```
21 changes: 21 additions & 0 deletions examples/resources/netapp-ontap_storage_quota_rules/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
resource "netapp-ontap_quota_rules" "storage_quota_rules" {
# required to know which system to interface with
cx_profile_name = "cluster2"
volume = {
name = "lunTest"
}
svm = {
name = "carchi-test"
}
type = "tree"
qtree = {
name = ""
}
users = [{
name = ""
}]
files = {
hard_limit = 100
soft_limit = 80
}
}
Loading

0 comments on commit ed72bd0

Please sign in to comment.