Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added file system resource #123

Merged
merged 12 commits into from
Jan 6, 2025
157 changes: 157 additions & 0 deletions docs/resources/filesystem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
---
# Copyright (c) 2024 Dell Inc., or its subsidiaries. All Rights Reserved.
#
# Licensed under the Mozilla Public License Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://mozilla.org/MPL/2.0/
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

title: "powerstore_filesystem resource"
linkTitle: "powerstore_filesystem"
page_title: "powerstore_filesystem Resource - powerstore"
subcategory: ""
description: |-
This resource is used to manage the file system entity of PowerStore Array. We can Create, Update and Delete the file system using this resource. We can also import an existing file system from PowerStore array.
---

# powerstore_filesystem (Resource)

This resource is used to manage the file system entity of PowerStore Array. We can Create, Update and Delete the file system using this resource. We can also import an existing file system from PowerStore array.

## Example Usage

```terraform
/*
Copyright (c) 2024 Dell Inc., or its subsidiaries. All Rights Reserved.

Licensed under the Mozilla Public License Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://mozilla.org/MPL/2.0/


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

# Commands to run this tf file : terraform init && terraform plan && terraform apply
# Create, Update, Delete and Import is supported for this resource


resource "powerstore_filesystem" "test" {
name = "test_fs"
description = "testing file system"
size = 3
nas_server_id = "654b2182-f674-f39a-66fc-52518d324736"
flr_attributes = {
mode = "Enterprise"
minimum_retention = "1D"
default_retention = "1D"
maximum_retention = "infinite"
}
config_type = "General"
access_policy = "UNIX"
locking_policy = "Advisory"
folder_rename_policy = "All_Allowed"
is_smb_sync_writes_enabled = true
is_smb_no_notify_enabled = true
is_smb_op_locks_enabled = false
is_smb_notify_on_access_enabled = true
is_smb_notify_on_write_enabled = false
smb_notify_on_change_dir_depth = 12
is_async_mtime_enabled = true
file_events_publishing_mode = "All"
}
```

After the execution of above resource block replication rule would have been created on the PowerStore array. For more information, Please check the terraform state file.

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

### Required

- `name` (String) Name of the file system.
- `nas_server_id` (String) Unique identifier of the NAS Server on which the file system is mounted.
- `size` (Number) Size that the file system presents to the host or end user.

### Optional

- `access_policy` (String) File system security access policies.
- `capacity_unit` (String) The Capacity Unit corresponding to the size.
- `config_type` (String) File system security access policies.
- `description` (String) File system description.
- `file_events_publishing_mode` (String) State of the event notification services for all file systems of the NAS server.
- `flr_attributes` (Attributes) Type of filesystem: normal or snapshot. (see [below for nested schema](#nestedatt--flr_attributes))
- `folder_rename_policy` (String) File system folder rename policies for the file system with multiprotocol access enabled.
- `host_io_size` (String) Typical size of writes from the server or other computer using the VMware file system to the storage system.
- `is_async_mtime_enabled` (Boolean) Indicates whether asynchronous MTIME is enabled on the file system or protocol snaps that are mounted writeable.
- `is_smb_no_notify_enabled` (Boolean) Indicates whether notifications of changes to directory file structure are enabled.
- `is_smb_notify_on_access_enabled` (Boolean) Indicates whether file access notifications are enabled on the file system.
- `is_smb_notify_on_write_enabled` (Boolean) Indicates whether file writes notifications are enabled on the file system.
- `is_smb_op_locks_enabled` (Boolean) Indicates whether opportunistic file locking is enabled on the file system.
- `is_smb_sync_writes_enabled` (Boolean) Indicates whether the synchronous writes option is enabled on the file system.
- `locking_policy` (String) File system locking policies.
- `protection_policy_id` (String) Unique identifier of the protection policy applied to the file system.
- `smb_notify_on_change_dir_depth` (Number) Lowest directory level to which the enabled notifications apply, if any.

### Read-Only

- `file_system_type` (String) Type of filesystem: normal or snapshot.
- `id` (String) Unique identifier of the file system.
- `parent_id` (String) Unique identifier of the parent filesystem.

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

Optional:

- `default_retention` (String) The FLR type of the file system.
- `maximum_retention` (String) The FLR type of the file system.
- `minimum_retention` (String) The FLR type of the file system.
- `mode` (String) The FLR type of the file system.

## Import

Import is supported using the following syntax:

```shell
#Copyright (c) 2024 Dell Inc., or its subsidiaries. All Rights Reserved.
#
#Licensed under the Mozilla Public License Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://mozilla.org/MPL/2.0/
#
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.


# Below are the steps to import file system :
# Step 1 - To import a file system , we need the id of that file system
# Step 2 - To check the id of the file system we can make use of file system datasource to read required/all file system ids. Alternatively, we can make GET request to file system endpoint. eg. https://10.0.0.1/api/rest/file_system which will return list of all file system ids.
# Step 3 - Add empty resource block in tf file.
# eg.
# resource "powerstore_filesystem" "resource_block_name" {
# (resource arguments)
# }
# Step 4 - Execute the command: terraform import "powerstore_filesystem.resource_block_name" "id_of_the_file_system" (resource_block_name must be taken from step 3 and id must be taken from step 2)
# Step 5 - After successful execution of the command , check the state file
```
26 changes: 26 additions & 0 deletions examples/resources/powerstore_filesystem/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#Copyright (c) 2024 Dell Inc., or its subsidiaries. All Rights Reserved.
#
#Licensed under the Mozilla Public License Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://mozilla.org/MPL/2.0/
#
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.


# Below are the steps to import file system :
# Step 1 - To import a file system , we need the id of that file system
# Step 2 - To check the id of the file system we can make use of file system datasource to read required/all file system ids. Alternatively, we can make GET request to file system endpoint. eg. https://10.0.0.1/api/rest/file_system which will return list of all file system ids.
# Step 3 - Add empty resource block in tf file.
# eg.
# resource "powerstore_filesystem" "resource_block_name" {
# (resource arguments)
# }
# Step 4 - Execute the command: terraform import "powerstore_filesystem.resource_block_name" "id_of_the_file_system" (resource_block_name must be taken from step 3 and id must be taken from step 2)
# Step 5 - After successful execution of the command , check the state file
33 changes: 33 additions & 0 deletions examples/resources/powerstore_filesystem/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright (c) 2024 Dell Inc., or its subsidiaries. All Rights Reserved.

Licensed under the Mozilla Public License Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://mozilla.org/MPL/2.0/


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

terraform {
required_providers {
powerstore = {
version = "1.2.0"
source = "registry.terraform.io/dell/powerstore"
}
}
}

provider "powerstore" {
username = var.username
password = var.password
endpoint = var.endpoint
insecure = true
timeout = var.timeout
}
45 changes: 45 additions & 0 deletions examples/resources/powerstore_filesystem/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Copyright (c) 2024 Dell Inc., or its subsidiaries. All Rights Reserved.

Licensed under the Mozilla Public License Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://mozilla.org/MPL/2.0/


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

# Commands to run this tf file : terraform init && terraform plan && terraform apply
# Create, Update, Delete and Import is supported for this resource


resource "powerstore_filesystem" "test" {
AnikaAgiwal2711 marked this conversation as resolved.
Show resolved Hide resolved
name = "test_fs"
description = "testing file system"
size = 3
nas_server_id = "654b2182-f674-f39a-66fc-52518d324736"
flr_attributes = {
mode = "Enterprise"
minimum_retention = "1D"
default_retention = "1D"
maximum_retention = "infinite"
}
config_type = "General"
access_policy = "UNIX"
locking_policy = "Advisory"
folder_rename_policy = "All_Allowed"
is_smb_sync_writes_enabled = true
is_smb_no_notify_enabled = true
is_smb_op_locks_enabled = false
is_smb_notify_on_access_enabled = true
is_smb_notify_on_write_enabled = false
smb_notify_on_change_dir_depth = 12
is_async_mtime_enabled = true
file_events_publishing_mode = "All"
}
36 changes: 36 additions & 0 deletions examples/resources/powerstore_filesystem/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright (c) 2024 Dell Inc., or its subsidiaries. All Rights Reserved.

Licensed under the Mozilla Public License Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://mozilla.org/MPL/2.0/


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

variable "username" {
type = string
description = "Stores the username of PowerStore host."
}

variable "password" {
type = string
description = "Stores the password of PowerStore host."
}

variable "timeout" {
type = string
description = "Stores the timeout of PowerStore host."
}

variable "endpoint" {
type = string
description = "Stores the endpoint of PowerStore host. eg: https://10.1.1.1/api/rest"
}
10 changes: 0 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxG
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dell/gopowerstore v1.16.1-0.20241218051810-2f3352b68230 h1:T/pCaREYwYdmpL9ElM+8IeiT8F1GiZwOLDoRVGqgP3s=
github.com/dell/gopowerstore v1.16.1-0.20241218051810-2f3352b68230/go.mod h1:RYodZ8GgJG5p85AviydL43Mt8ldcTqr5a+Cv+vqWacE=
github.com/dell/gopowerstore v1.16.1-0.20241224121918-f1dfbb3bd1da h1:xiNLqNC3IeX2QbAlNKKN57PMJzANMx0/FLXI2+h6lhA=
github.com/dell/gopowerstore v1.16.1-0.20241224121918-f1dfbb3bd1da/go.mod h1:RYodZ8GgJG5p85AviydL43Mt8ldcTqr5a+Cv+vqWacE=
github.com/dell/gopowerstore v1.16.1-0.20241226114322-4a6a9478d375 h1:7jFPZEjy3UtYXGTYxoFp6TZe01469CqRkfBOZdPkjxc=
github.com/dell/gopowerstore v1.16.1-0.20241226114322-4a6a9478d375/go.mod h1:RYodZ8GgJG5p85AviydL43Mt8ldcTqr5a+Cv+vqWacE=
github.com/dell/gopowerstore v1.16.1-0.20241226120050-f4c219edd2e1 h1:2y13ugJIpIRJx9mAn963ZRh1EK8am95VgRKiUNcpMRs=
github.com/dell/gopowerstore v1.16.1-0.20241226120050-f4c219edd2e1/go.mod h1:RYodZ8GgJG5p85AviydL43Mt8ldcTqr5a+Cv+vqWacE=
github.com/dell/gopowerstore v1.16.1-0.20241227064011-3c3808a39067 h1:FcRAYtZkdr+p2NQjngNlhZNiz2I50X9AgsxGCW0l6/4=
github.com/dell/gopowerstore v1.16.1-0.20241227064011-3c3808a39067/go.mod h1:RYodZ8GgJG5p85AviydL43Mt8ldcTqr5a+Cv+vqWacE=
github.com/dell/gopowerstore v1.16.1-0.20241227083619-36c4ea66275f h1:wr07YuRpeBb5sEgBahBGPWMZKomPC2TfbpBjMWMqwVE=
github.com/dell/gopowerstore v1.16.1-0.20241227083619-36c4ea66275f/go.mod h1:RYodZ8GgJG5p85AviydL43Mt8ldcTqr5a+Cv+vqWacE=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
Expand Down
55 changes: 55 additions & 0 deletions models/filesystem.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
Copyright (c) 2024 Dell Inc., or its subsidiaries. All Rights Reserved.

Licensed under the Mozilla Public License Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://mozilla.org/MPL/2.0/


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package models

import "github.com/hashicorp/terraform-plugin-framework/types"

// FileSystem - file system properties
type FileSystem struct {
ID types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
Size types.Float64 `tfsdk:"size"`
CapacityUnit types.String `tfsdk:"capacity_unit"`
Description types.String `tfsdk:"description"`
NASServerID types.String `tfsdk:"nas_server_id"`
ConfigType types.String `tfsdk:"config_type"`
AccessPolicy types.String `tfsdk:"access_policy"`
LockingPolicy types.String `tfsdk:"locking_policy"`
FolderRenamePolicy types.String `tfsdk:"folder_rename_policy"`
IsAsyncMTimeEnabled types.Bool `tfsdk:"is_async_mtime_enabled"`
ProtectionPolicyID types.String `tfsdk:"protection_policy_id"`
FileEventsPublishingMode types.String `tfsdk:"file_events_publishing_mode"`
HostIOSize types.String `tfsdk:"host_io_size"`
IsSmbSyncWritesEnabled types.Bool `tfsdk:"is_smb_sync_writes_enabled"`
IsSmbNoNotifyEnabled types.Bool `tfsdk:"is_smb_no_notify_enabled"`
IsSmbOpLocksEnabled types.Bool `tfsdk:"is_smb_op_locks_enabled"`
IsSmbNotifyOnAccessEnabled types.Bool `tfsdk:"is_smb_notify_on_access_enabled"`
IsSmbNotifyOnWriteEnabled types.Bool `tfsdk:"is_smb_notify_on_write_enabled"`
SmbNotifyOnChangeDirDepth types.Int32 `tfsdk:"smb_notify_on_change_dir_depth"`
FilesystemType types.String `tfsdk:"file_system_type"`
ParentID types.String `tfsdk:"parent_id"`
FlrAttributes types.Object `tfsdk:"flr_attributes"`
}

// FlrAttributes - struct for flr attributes
type FlrAttributes struct {
AnikaAgiwal2711 marked this conversation as resolved.
Show resolved Hide resolved
Mode types.String `tfsdk:"mode"`
MinimumRetention types.String `tfsdk:"minimum_retention"`
DefaultRetention types.String `tfsdk:"default_retention"`
MaximumRetention types.String `tfsdk:"maximum_retention"`
}
1 change: 1 addition & 0 deletions powerstore/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func (p *Pstoreprovider) Resources(ctx context.Context) []func() resource.Resour
newHostGroupResource,
newVGSnapshotResource,
newVolumeSnapshotResource,
newFileSystemResource,
newFileSystemSnapshotResource,
newReplicationRuleResource,
}
Expand Down
1 change: 1 addition & 0 deletions powerstore/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ var volumeGroupSnapshotName = setDefault(os.Getenv("VOLUME_GROUP_SNAPSHOT_NAME")
var volumeGroupSnapshotID = setDefault(os.Getenv("VOLUME_GROUP_SNAPSHOT_ID"), "tfacc_volume_group_snapshot_id")
var volumeSnapshotID = setDefault(os.Getenv("VOLUME_SNAPSHOT_ID"), "tfacc_volume_snapshot_id")
var volumeSnapshotName = setDefault(os.Getenv("VOLUME_SNAPSHOT_NAME"), "tfacc_volume_snapshot_name")
var nasServerID = setDefault(os.Getenv("NAS_SERVER_ID"), "tfacc_nas_server_id")
var fileSystemID = setDefault(os.Getenv("FILESYSTEM_ID"), "tfacc_filesystem_id")
var remoteSystemID = setDefault(os.Getenv("REMOTE_SYSTEM_ID"), "")

Expand Down
Loading
Loading