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

ACL Settings Resource Implementation #123

Merged
merged 1 commit into from
Feb 8, 2024
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
129 changes: 129 additions & 0 deletions docs/resources/aclsettings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
# Copyright (c) 2023 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: "powerscale_aclsettings resource"
linkTitle: "powerscale_aclsettings"
page_title: "powerscale_aclsettings Resource - terraform-provider-powerscale"
subcategory: ""
description: |-
This resource is used to manage the ACL Settings entity of PowerScale Array. We can Create, Update and Delete the ACL Settings using this resource. We can also import the existing ACL Settings from PowerScale array. Note that, ACL Settings is the native functionality of PowerScale. When creating the resource, we actually load ACL Settings from PowerScale to the resource state.
---

# powerscale_aclsettings (Resource)

This resource is used to manage the ACL Settings entity of PowerScale Array. We can Create, Update and Delete the ACL Settings using this resource. We can also import the existing ACL Settings from PowerScale array. Note that, ACL Settings is the native functionality of PowerScale. When creating the resource, we actually load ACL Settings from PowerScale to the resource state.


## Example Usage

```terraform
/*
Copyright (c) 2023 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.
*/

# Available actions: Create, Update, Delete and Import.
# If resource arguments are omitted, `terraform apply` will load ACL Settings from PowerScale, and save to terraform state file.
# If any resource arguments are specified, `terraform apply` will try to load ACL Settings (if not loaded) and update the settings.
# `terraform destroy` will delete the resource from terraform state file rather than deleting ACL Settings from PowerScale.
# For more information, Please check the terraform state file.

# PowerScale ACL Settings allow you to manage file and directory permissions, referred to as access rights.
resource "powerscale_aclsettings" "example_acl_settings" {
# Optional fields both for creating and updating
# Please check the acceptable inputs for each setting in the documentation
# access = "windows"
# calcmode = "approx"
# calcmode_group = "group_aces"
# calcmode_owner = "owner_aces"
# calcmode_traverse = "ignore"
# chmod = "merge"
# chmod_007 = "default"
# chmod_inheritable = "no"
# chown = "owner_group_and_acl"
# create_over_smb = "allow"
# dos_attr = "deny_smb"
# group_owner_inheritance = "creator"
# rwx = "retain"
# synthetic_denies = "remove"
# utimes = "only_owner"
}

# After the execution of above resource block, ACL Settings would have been cached in terraform state file, or
# ACL Settings would have been updated on PowerScale.
# For more information, Please check the terraform state file.
```

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

### Optional

- `access` (String) Access checks (chmod, chown). Options: unix, windows
- `calcmode` (String) Displayed mode bits. Options: approx, 777
- `calcmode_group` (String) Approximate group mode bits when ACL exists. Options: group_aces, group_only
- `calcmode_owner` (String) Approximate owner mode bits when ACL exists. Options: owner_aces, owner_only
- `calcmode_traverse` (String) Require traverse rights in order to traverse directories with existing ACLs. Options: require, ignore
- `chmod` (String) chmod on files with existing ACLs. Options: remove, replace, replace_users_and_groups, merge_with_ugo_priority, merge, deny, ignore
- `chmod_007` (String) chmod (007) on files with existing ACLs. Options: default, remove
- `chmod_inheritable` (String) ACLs created on directories by UNIX chmod. Options: yes, no
- `chown` (String) chown/chgrp on files with existing ACLs. Options: owner_group_and_acl, owner_group_only, ignore
- `create_over_smb` (String) ACL creation over SMB. Options: allow, disallow
- `dos_attr` (String) Read only DOS attribute. Options: deny_smb, deny_smb_and_nfs
- `group_owner_inheritance` (String) Group owner inheritance. Options: native, parent, creator
- `rwx` (String) Treatment of 'rwx' permissions. Options: retain, full_control
- `synthetic_denies` (String) Synthetic 'deny' ACEs. Options: none, remove
- `utimes` (String) Access check (utimes). Options: only_owner, owner_and_write

## Import

Import is supported using the following syntax:

```shell
# Copyright (c) 2023 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.

# The command is
# terraform import powerscale_aclsettings.example_acl_settings <anyString>
# Example:
terraform import powerscale_aclsettings.example_acl_settings anyString
# after running this command, populate the name field and other required parameters in the config file to start managing this resource.
# Note: running "terraform show" after importing shows the current config/state of the resource. You can copy/paste that config to make it easier to manage the resource.
```
4 changes: 2 additions & 2 deletions docs/resources/ntpserver.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ limitations under the License.
# PowerScale NTP Server allows you to synchronize the system time
resource "powerscale_ntpserver" "ntp_server_test" {
# Required
# Name should be a qualified name of an existing NTP Server
# Name should be a qualified name of an existing NTP Server and cannot be updated
name = "ntp_server_example"

# Optional parameters
# Optional parameters for updating
key = "ntp_server_key_example"
}

Expand Down
21 changes: 21 additions & 0 deletions examples/resources/powerscale_aclsettings/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2023 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.

# The command is
# terraform import powerscale_aclsettings.example_acl_settings <anyString>
# Example:
terraform import powerscale_aclsettings.example_acl_settings anyString
# after running this command, populate the name field and other required parameters in the config file to start managing this resource.
# Note: running "terraform show" after importing shows the current config/state of the resource. You can copy/paste that config to make it easier to manage the resource.
30 changes: 30 additions & 0 deletions examples/resources/powerscale_aclsettings/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright (c) 2023 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 {
powerscale = {
source = "registry.terraform.io/dell/powerscale"
}
}
}

provider "powerscale" {
username = var.username
password = var.password
endpoint = var.endpoint
insecure = var.insecure
}
47 changes: 47 additions & 0 deletions examples/resources/powerscale_aclsettings/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Copyright (c) 2023 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.
*/

# Available actions: Create, Update, Delete and Import.
# If resource arguments are omitted, `terraform apply` will load ACL Settings from PowerScale, and save to terraform state file.
# If any resource arguments are specified, `terraform apply` will try to load ACL Settings (if not loaded) and update the settings.
# `terraform destroy` will delete the resource from terraform state file rather than deleting ACL Settings from PowerScale.
# For more information, Please check the terraform state file.

# PowerScale ACL Settings allow you to manage file and directory permissions, referred to as access rights.
resource "powerscale_aclsettings" "example_acl_settings" {
# Optional fields both for creating and updating
# Please check the acceptable inputs for each setting in the documentation
# access = "windows"
# calcmode = "approx"
# calcmode_group = "group_aces"
# calcmode_owner = "owner_aces"
# calcmode_traverse = "ignore"
# chmod = "merge"
# chmod_007 = "default"
# chmod_inheritable = "no"
# chown = "owner_group_and_acl"
# create_over_smb = "allow"
# dos_attr = "deny_smb"
# group_owner_inheritance = "creator"
# rwx = "retain"
# synthetic_denies = "remove"
# utimes = "only_owner"
}

# After the execution of above resource block, ACL Settings would have been cached in terraform state file, or
# ACL Settings would have been updated on PowerScale.
# For more information, Please check the terraform state file.
4 changes: 2 additions & 2 deletions examples/resources/powerscale_ntpserver/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ limitations under the License.
# PowerScale NTP Server allows you to synchronize the system time
resource "powerscale_ntpserver" "ntp_server_test" {
# Required
# Name should be a qualified name of an existing NTP Server
# Name should be a qualified name of an existing NTP Server and cannot be updated
name = "ntp_server_example"

# Optional parameters
# Optional parameters for updating
key = "ntp_server_key_example"
}

Expand Down
9 changes: 9 additions & 0 deletions powerscale/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ const (
// UpdateNtpSettingsErrorMsg specifies error details occurred while updating NTP Settings.
UpdateNtpSettingsErrorMsg = "Could not update ntp settings "

// ReadACLSettingsErrorMsg specifies error details occurred while reading ACL Settings.
ReadACLSettingsErrorMsg = "Could not read acl settings "

// CreateACLSettingsErrorMsg specifies error details occurred while creating ACL Settings.
CreateACLSettingsErrorMsg = "Could not create acl settings "

// UpdateACLSettingsErrorMsg specifies error details occurred while updating ACL Settings.
UpdateACLSettingsErrorMsg = "Could not update acl settings "

// ReadUserErrorMsg specifies error details occurred while reading Users.
ReadUserErrorMsg = "Could not read users "

Expand Down
38 changes: 38 additions & 0 deletions powerscale/helper/acl_settings_helper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Copyright (c) 2023 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 helper

import (
"context"
powerscale "dell/powerscale-go-client"
"terraform-provider-powerscale/client"
)

// GetACLSettings retrieve ACL Settings information.
func GetACLSettings(ctx context.Context, client *client.Client) (*powerscale.V11SettingsAcls, error) {
queryParam := client.PscaleOpenAPIClient.AuthApi.GetAuthv11SettingsAcls(ctx)
aclSettingsRes, _, err := queryParam.Execute()
return aclSettingsRes, err
}

// UpdateACLSettings Update ACL Settings.
func UpdateACLSettings(ctx context.Context, client *client.Client, aclSettingsToUpdate powerscale.V11SettingsAclsAclPolicySettings) error {
updateParam := client.PscaleOpenAPIClient.AuthApi.UpdateAuthv11SettingsAcls(ctx)
_, err := updateParam.V11SettingsAcls(aclSettingsToUpdate).Execute()
return err
}
4 changes: 2 additions & 2 deletions powerscale/helper/cluster_email_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (
"terraform-provider-powerscale/client"
)

// GetClusterEmail retrieve cluster email
// GetClusterEmail retrieve cluster email.
func GetClusterEmail(ctx context.Context, client *client.Client) (*powerscale.V1ClusterEmail, error) {
clusterEmail, _, err := client.PscaleOpenAPIClient.ClusterApi.GetClusterv1ClusterEmail(ctx).Execute()
return clusterEmail, err
}

// UpdateClusterEmail update cluster email
// UpdateClusterEmail update cluster email.
func UpdateClusterEmail(ctx context.Context, client *client.Client, v1ClusterEmail powerscale.V1ClusterEmailExtended) error {
_, err := client.PscaleOpenAPIClient.ClusterApi.UpdateClusterv1ClusterEmail(ctx).V1ClusterEmail(v1ClusterEmail).Execute()
return err
Expand Down
54 changes: 54 additions & 0 deletions powerscale/models/acl_settings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
Copyright (c) 2023 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"

// ACLSettingsResourceModel describes the resource data model.
type ACLSettingsResourceModel struct {
// Access checks (chmod, chown).
Access types.String `tfsdk:"access"`
// Displayed mode bits.
Calcmode types.String `tfsdk:"calcmode"`
// Approximate group mode bits when ACL exists.
CalcmodeGroup types.String `tfsdk:"calcmode_group"`
// Approximate owner mode bits when ACL exists.
CalcmodeOwner types.String `tfsdk:"calcmode_owner"`
// Require traverse rights in order to traverse directories with existing ACLs.
CalcmodeTraverse types.String `tfsdk:"calcmode_traverse"`
// chmod on files with existing ACLs.
Chmod types.String `tfsdk:"chmod"`
// chmod (007) on files with existing ACLs.
Chmod007 types.String `tfsdk:"chmod_007"`
// ACLs created on directories by UNIX chmod.
ChmodInheritable types.String `tfsdk:"chmod_inheritable"`
// chown/chgrp on files with existing ACLs.
Chown types.String `tfsdk:"chown"`
// ACL creation over SMB.
CreateOverSmb types.String `tfsdk:"create_over_smb"`
// Read only DOS attribute.
DosAttr types.String `tfsdk:"dos_attr"`
// Group owner inheritance.
GroupOwnerInheritance types.String `tfsdk:"group_owner_inheritance"`
// Treatment of 'rwx' permissions.
Rwx types.String `tfsdk:"rwx"`
// Synthetic 'deny' ACEs.
SyntheticDenies types.String `tfsdk:"synthetic_denies"`
// Access check (utimes)
Utimes types.String `tfsdk:"utimes"`
}
Loading
Loading