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 filesystem snapshot datasource #127

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 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
173 changes: 173 additions & 0 deletions docs/data-sources/filesystem_snapshot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
---
# Copyright (c) 2025 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_snapshot data source"
linkTitle: "powerstore_filesystem_snapshot"
page_title: "powerstore_filesystem_snapshot Data Source - powerstore"
subcategory: ""
description: |-
This datasource is used to query the existing File System Snapshot from PowerStore array. The information fetched from this datasource can be used for getting the details for further processing in resource block.
---

# powerstore_filesystem_snapshot (Data Source)

This datasource is used to query the existing File System Snapshot from PowerStore array. The information fetched from this datasource can be used for getting the details for further processing in resource block.

> **Note:** Only one of `name` or `id` or `filesystem_id` can be provided at a time.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description seems outdated. Same in file_system daatasource.


## Example Usage

```terraform
/*
Copyright (c) 2025 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 apply --auto-approve
# This datasource reads hosts either by id or name where user can provide a value to any one of them
# If it is a empty datsource block , then it will read all the filesystem
# If id or name is provided then it reads a particular file system snapshot with that id or name
# If filesystem_id is provided then it will read all the filesystem snapshots within filesystem
# Only one of the attribute can be provided among id or name or filesystem_id


// create filesystem
resource "powerstore_filesystem" "test" {
name = "test_fs"
description = "testing file system"
size = 3
nas_server_id = "<nas_server_id>"
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"
}

// create snapshot from filesystem
resource "powerstore_filesystem_snapshot" "test" {
name = "tf_fs_snap"
description = "Test File System Snapshot Resource"
filesystem_id = resource.powerstore_filesystem.test.id
expiration_timestamp = "2035-05-06T09:01:47Z"
access_type = "Snapshot"
}

data "powerstore_filesystem_snapshot" "test1" {
name = resource.powerstore_filesystem_snapshot.test.name
Copy link
Contributor

@rounak-adhikary rounak-adhikary Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datasource examples are not given with resource prereqs since users will probably never write any code like this. Datasource examples can have datasource prereqs (eg. filesystem datasource prereq for filesystem_snapshot daatsource).
Only resource examples use resource or datasource prereqs, covering probable common scenarios.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, better give an example with nas_server_id

# id = resource.powerstore_filesystem_snapshot.test.id
# filesystem_id= resource.powerstore_filesystem.test.id
}


output "fileSystemSnapshotResult" {
value = data.powerstore_filesystem_snapshot.test1.filesystem_snapshots
}
```
After the successful execution of above said block, We can see the output by executing `terraform output` command. Also, we can fetch information via the variable: `data.powerstore_filesystem_snapshot.test1` where name is the attribute which user wants to fetch.

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

### Optional

- `filesystem_id` (String) File System ID of the Snapshot. Conflicts with `id` and `nas_server_id`.
- `id` (String) Unique identifier of the File System Snapshot. Conflicts with `name` and `filesystem_id`.
- `name` (String) File System Snapshot name. Conflicts with `id`.
- `nas_server_id` (String) Nas Server ID of the Snapshot. Conflicts with `id` and `filesystem_id`.

### Read-Only

- `filesystem_snapshots` (Attributes List) List of File System Snapshots. (see [below for nested schema](#nestedatt--filesystem_snapshots))

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

Read-Only:

- `access_policy` (String) Access Policy of the File System
- `access_type` (String) Access Type of the File System
- `config_type` (String) Config Type of the File System
- `creation_timestamp` (String) Creation Timestamp of the File System
- `creator_type` (String) Creator Type of the File System
- `default_hard_limit` (Number) Default Hard Limit of the File System
- `default_soft_limit` (Number) Default Soft Limit of the File System
- `description` (String) Description of the File System
- `expiration_timestamp` (String) Expiration Timestamp of the File System
- `filesystem_type` (String) Filesystem Type of the File System
- `flr_attributes` (Attributes) Flr Attributes of the File System (see [below for nested schema](#nestedatt--filesystem_snapshots--flr_attributes))
- `folder_rename_policy` (String) Folder Rename Policy of the File System
- `grace_period` (Number) Grace Period of the File System
- `id` (String) ID of the File System
- `is_async_m_time_enabled` (Boolean) Is Async MTime Enabled of the File System
- `is_modified` (Boolean) Is Modified of the File System
- `is_quota_enabled` (Boolean) Is Quota Enabled of the File System
- `is_smb_no_notify_enabled` (Boolean) Is Smb No Notify Enabled of the File System
- `is_smb_notify_on_access_enabled` (Boolean) Is Smb Notify On Access Enabled of the File System
- `is_smb_notify_on_write_enabled` (Boolean) Is Smb Notify On Write Enabled of the File System
- `is_smb_op_locks_enabled` (Boolean) Is Smb Op Locks Enabled of the File System
- `is_smb_sync_writes_enabled` (Boolean) Is Smb Sync Writes Enabled of the File System
- `last_refresh_timestamp` (String) Last Refresh Timestamp of the File System
- `last_writable_timestamp` (String) Last Writable Timestamp of the File System
- `locking_policy` (String) Locking Policy of the File System
- `name` (String) Name of the File System
- `nas_server_id` (String) Nas Server ID of the File System
- `parent_id` (String) Parent ID of the File System
- `protection_policy_id` (String) Protection Policy ID of the File System
- `size_total` (Number) Size Total of the File System
- `size_used` (Number) Size Used of the File System
- `smb_notify_on_change_dir_depth` (Number) Smb Notify On Change Dir Depth of the File System

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

Read-Only:

- `auto_delete` (Boolean) Auto Delete of the File System
- `auto_lock` (Boolean) Auto Lock of the File System
- `clock_time` (String) Clock Time of the File System
- `default_retention` (String) Default Retention of the File System
- `has_protected_files` (Boolean) Has Protected Files of the File System
- `maximum_retention` (String) Maximum Retention of the File System
- `maximum_retention_date` (String) Maximum Retention Date of the File System
- `minimum_retention` (String) Minimum Retention of the File System
- `mode` (String) Mode of the File System
- `policy_interval` (Number) Policy Interval of the File System
10 changes: 5 additions & 5 deletions docs/resources/filesystem_snapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ limitations under the License.
# To check which attributes of the file system snapshot resource can be updated, please refer Product Guide in the documentation

resource "powerstore_filesystem_snapshot" "test1" {
name = "tf_fs_snap"
description = "Test File System Snapshot Resource"
filesystem_id="67608dc7-b69c-b762-0522-42848bc63a0b"
expiration_timestamp="2035-05-06T09:01:47Z"
access_type = "Snapshot"
name = "tf_fs_snap"
description = "Test File System Snapshot Resource"
filesystem_id = "67608dc7-b69c-b762-0522-42848bc63a0b"
expiration_timestamp = "2035-05-06T09:01:47Z"
access_type = "Snapshot"
}
```

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Copyright (c) 2025 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 apply --auto-approve
# This datasource reads hosts either by id or name where user can provide a value to any one of them
# If it is a empty datsource block , then it will read all the filesystem
# If id or name is provided then it reads a particular file system snapshot with that id or name
# If filesystem_id is provided then it will read all the filesystem snapshots within filesystem
# Only one of the attribute can be provided among id or name or filesystem_id


// create filesystem
resource "powerstore_filesystem" "test" {
name = "test_fs"
description = "testing file system"
size = 3
nas_server_id = "<nas_server_id>"
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"
}

// create snapshot from filesystem
resource "powerstore_filesystem_snapshot" "test" {
name = "tf_fs_snap"
description = "Test File System Snapshot Resource"
filesystem_id = resource.powerstore_filesystem.test.id
expiration_timestamp = "2035-05-06T09:01:47Z"
access_type = "Snapshot"
}

data "powerstore_filesystem_snapshot" "test1" {
name = resource.powerstore_filesystem_snapshot.test.name
Krishnan-Priyanshu marked this conversation as resolved.
Show resolved Hide resolved
# id = resource.powerstore_filesystem_snapshot.test.id
# filesystem_id= resource.powerstore_filesystem.test.id
}


output "fileSystemSnapshotResult" {
value = data.powerstore_filesystem_snapshot.test1.filesystem_snapshots
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright (c) 2025 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
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright (c) 2025 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: 5 additions & 5 deletions examples/resources/powerstore_filesystem_snapshot/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ limitations under the License.
# To check which attributes of the file system snapshot resource can be updated, please refer Product Guide in the documentation

resource "powerstore_filesystem_snapshot" "test1" {
name = "tf_fs_snap"
description = "Test File System Snapshot Resource"
filesystem_id="67608dc7-b69c-b762-0522-42848bc63a0b"
expiration_timestamp="2035-05-06T09:01:47Z"
access_type = "Snapshot"
name = "tf_fs_snap"
description = "Test File System Snapshot Resource"
filesystem_id = "67608dc7-b69c-b762-0522-42848bc63a0b"
expiration_timestamp = "2035-05-06T09:01:47Z"
access_type = "Snapshot"
}
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.23
toolchain go1.23.2

require (
github.com/dell/gopowerstore v1.16.1-0.20250107063650-9ec041ed54dc
github.com/dell/gopowerstore v1.17.1-0.20250110112425-426c7c96a018
Krishnan-Priyanshu marked this conversation as resolved.
Show resolved Hide resolved
github.com/hashicorp/terraform-plugin-docs v0.20.1
github.com/hashicorp/terraform-plugin-framework v1.13.0
github.com/hashicorp/terraform-plugin-framework-validators v0.15.0
Expand Down Expand Up @@ -90,10 +90,10 @@ require (
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/zclconf/go-cty v1.15.0 // indirect
go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect
go.mongodb.org/mongo-driver v1.17.1 // indirect
go.mongodb.org/mongo-driver v1.17.2 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/tools v0.22.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
Expand Down
Loading
Loading