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 resource #121

Merged
merged 12 commits into from
Dec 30, 2024
2 changes: 1 addition & 1 deletion docs/data-sources/volumegroup_snapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ limitations under the License.
# Only one of the attribute can be provided among id and name

data "powerstore_volumegroup_snapshot" "test1" {
# name = "test_volumegroup_snap"
# name = "test_volumegroup_snap"
}

output "volumeGroupSnapshotResult" {
Expand Down
119 changes: 119 additions & 0 deletions docs/resources/filesystem_snapshot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
---
# 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_snapshot resource"
linkTitle: "powerstore_filesystem_snapshot"
page_title: "powerstore_filesystem_snapshot Resource - powerstore"
subcategory: ""
description: |-
This resource is used to manage the filesystem snapshot entity of PowerStore Array. We can Create, Update and Delete the filesystem snapshot using this resource. We can also import an existing filesystem snapshot from PowerStore array.
---

# powerstore_filesystem_snapshot (Resource)

This resource is used to manage the filesystem snapshot entity of PowerStore Array. We can Create, Update and Delete the filesystem snapshot using this resource. We can also import an existing filesystem snapshot 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 is supported for this resource
# To import , check powerstore_filesystem_snapshot/import.tf for more info
# filesystem_id is the required attribute to create file system snapshot.
# name, expiration_timestamp, access_type and description are the optional attributes
# if name is present in the config it cannot be blank("").
# During create operation, if expiration_timestamp is not specified or set to blank(""), snapshot will be created with infinite retention.
# During modify operation, to set infinite retention, expiration_timestamp can be set to blank("").
# 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"
}
```

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

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

### Required

- `filesystem_id` (String) ID of the filesystem to take snapshot. Cannot be updated.

### Optional

- `access_type` (String) Access type of the filesystem snapshot. Access type can be 'Snapshot' or 'Protocol'. Cannot be updated.
- `description` (String) Description of the filesystem snapshot.
- `expiration_timestamp` (String) Expiration Timestamp of the filesystem snapshot, if not provided there will no expiration for the snapshot.Only UTC (+Z) format is allowed eg: 2023-05-06T09:01:47Z
- `name` (String) Name of the filesystem snapshot.The default name of the filesystem snapshot is the date and time when the snapshot is taken.

### Read-Only

- `id` (String) The unique identifier of the filesystem snapshot.

## 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 snapshot :
# Step 1 - To import a filesystem snapshot , we need the id of that filesystem snapshot
# Step 2 - To check the id of the filesystem snapshot we can make Get request to filesystem snapshot endpoint. eg. https://10.0.0.1/api/rest/file_system and 'filesystem_type: Snapshot' which will return list of all filesystem snapshots ids.
# Step 3 - Add empty resource block in tf file.
# eg.
# resource "powerstore_filesystem_snapshot" "resource_block_name" {
# (resource arguments)
# }
# Step 4 - Execute the command: terraform import "powerstore_filesystem_snapshot.resource_block_name" "id_of_the_snapshot" (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
```
2 changes: 1 addition & 1 deletion docs/resources/host.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ resource "powerstore_host" "test" {
os_type = "Linux"
description = "Creating host"
host_connectivity = "Local_Only"
initiators = [{ port_name = "iqn.1994-05.com.redhat:88cb605"}]
initiators = [{ port_name = "iqn.1994-05.com.redhat:88cb605" }]
}
```

Expand Down
2 changes: 1 addition & 1 deletion examples/data-sources/powerstore_hostgroup/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ terraform {
required_providers {
powerstore = {
version = "1.1.0"
source = "registry.terraform.io/dell/powerstore"
source = "registry.terraform.io/dell/powerstore"
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions examples/data-sources/powerstore_hostgroup/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ limitations under the License.
*/

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

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

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

variable "endpoint" {
type=string
type = string
description = "Stores the endpoint of PowerStore host. eg: https://10.1.1.1/api/rest"
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ limitations under the License.
# Only one of the attribute can be provided among id and name

data "powerstore_volumegroup_snapshot" "test1" {
# name = "test_volumegroup_snap"
# name = "test_volumegroup_snap"
}

output "volumeGroupSnapshotResult" {
Expand Down
26 changes: 26 additions & 0 deletions examples/resources/powerstore_filesystem_snapshot/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 snapshot :
# Step 1 - To import a filesystem snapshot , we need the id of that filesystem snapshot
# Step 2 - To check the id of the filesystem snapshot we can make Get request to filesystem snapshot endpoint. eg. https://10.0.0.1/api/rest/file_system and 'filesystem_type: Snapshot' which will return list of all filesystem snapshots ids.
# Step 3 - Add empty resource block in tf file.
# eg.
# resource "powerstore_filesystem_snapshot" "resource_block_name" {
# (resource arguments)
# }
# Step 4 - Execute the command: terraform import "powerstore_filesystem_snapshot.resource_block_name" "id_of_the_snapshot" (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_snapshot/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
}
34 changes: 34 additions & 0 deletions examples/resources/powerstore_filesystem_snapshot/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
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 is supported for this resource
# To import , check powerstore_filesystem_snapshot/import.tf for more info
# filesystem_id is the required attribute to create file system snapshot.
# name, expiration_timestamp, access_type and description are the optional attributes
# if name is present in the config it cannot be blank("").
# During create operation, if expiration_timestamp is not specified or set to blank(""), snapshot will be created with infinite retention.
# During modify operation, to set infinite retention, expiration_timestamp can be set to blank("").
# 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"
}
36 changes: 36 additions & 0 deletions examples/resources/powerstore_filesystem_snapshot/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/"
}
2 changes: 1 addition & 1 deletion examples/resources/powerstore_host/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ resource "powerstore_host" "test" {
os_type = "Linux"
description = "Creating host"
host_connectivity = "Local_Only"
initiators = [{ port_name = "iqn.1994-05.com.redhat:88cb605"}]
initiators = [{ port_name = "iqn.1994-05.com.redhat:88cb605" }]
}
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ go 1.23
toolchain go1.23.2

require (
github.com/dell/gopowerstore v1.16.1-0.20241218051810-2f3352b68230
github.com/dell/gopowerstore v1.16.1-0.20241227083619-36c4ea66275f
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
github.com/hashicorp/terraform-plugin-go v0.25.0
github.com/hashicorp/terraform-plugin-log v0.9.0
Krishnan-Priyanshu marked this conversation as resolved.
Show resolved Hide resolved
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0
github.com/stretchr/testify v1.10.0
)
Expand Down Expand Up @@ -50,7 +51,6 @@ require (
github.com/fatih/color v1.16.0 // indirect
github.com/go-openapi/errors v0.22.0 // indirect
github.com/go-openapi/strfmt v0.23.0 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.6.0 // indirect
Expand All @@ -69,7 +69,6 @@ require (
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.21.0 // indirect
github.com/hashicorp/terraform-json v0.23.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
Expand Down
Loading
Loading