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

updated storage_pool #9229

Merged
merged 17 commits into from
Nov 21, 2023
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
28 changes: 28 additions & 0 deletions mmv1/products/netapp/product.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2018 Google Inc.
# Licensed under the Apache 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://www.apache.org/licenses/LICENSE-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.
--- !ruby/object:Api::Product
name: Netapp
display_name: Netapp
versions:
- !ruby/object:Api::Product::Version
name: ga
base_url: https://netapp.googleapis.com/v1/
- !ruby/object:Api::Product::Version
name: beta
base_url: https://netapp.googleapis.com/v1beta1/
scopes:
- https://www.googleapis.com/auth/cloud-platform
apis_required:
- !ruby/object:Api::Product::ApiReference
name: Cloud Volume API
url: https://console.cloud.google.com/apis/library/cloudvolumesgcp-api.netapp.com
133 changes: 133 additions & 0 deletions mmv1/products/netapp/storagePool.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Copyright 2023 Google Inc.
# Licensed under the Apache 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://www.apache.org/licenses/LICENSE-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.

--- !ruby/object:Api::Resource
name: 'storagePool'
description: |
Storage pools act as containers for volumes. All volumes in a storage pool share the following information:
* Location
* Service level
* Virtual Private Cloud (VPC) network
* Active Directory policy
* LDAP use for NFS volumes, if applicable
* Customer-managed encryption key (CMEK) policy

The capacity of the pool can be split up and assigned to volumes within the pool. Storage pools are a billable component of NetApp Volumes. Billing is based on the location, service level, and capacity allocated to a pool independent of consumption at the volume level.
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'QUICKSTART_TITLE': 'https://cloud.google.com/netapp/volumes/docs/get-started/quickstarts/create-storage-pool'
api: 'https://cloud.google.com/netapp/volumes/docs/reference/rest/v1/projects.locations.storagePools'
base_url: projects/{{project}}/locations/{{location}}/storagePools
self_link: projects/{{project}}/locations/{{location}}/storagePools/{{name}}
create_url: projects/{{project}}/locations/{{location}}/storagePools?storagePoolId={{name}}
update_url: projects/{{project}}/locations/{{location}}/storagePools/{{name}}
update_verb: :PATCH
update_mask: true
delete_url: projects/{{project}}/locations/{{location}}/storagePools/{{name}}
autogen_async: true
async: !ruby/object:Api::OpAsync
operation: !ruby/object:Api::OpAsync::Operation
base_url: '{{op_id}}'
id_format: 'projects/{{project}}/locations/{{location}}/storagePools/{{name}}'
import_format: ['projects/{{project}}/locations/{{location}}/storagePools/{{name}}']
parameters:
- !ruby/object:Api::Type::String
name: 'location'
required: true
immutable: true
url_param_only: true
description: |
Name of the location. Usually a region name, expect for some STANDARD service level pools which require a zone name.
- !ruby/object:Api::Type::String
name: 'name'
description:
The resource name of the storage pool. Needs to be unique per location.
required: true
immutable: true
url_param_only: true
examples:
- !ruby/object:Provider::Terraform::Examples
name: 'Storage_pool_create'
primary_resource_id: 'test_pool'
vars:
pool_name: 'test-pool'
network_name: 'test-network'
global_name: 'test-address'
properties:
# Fields go here
- !ruby/object:Api::Type::Enum
name: 'serviceLevel'
G-NamanGupta marked this conversation as resolved.
Show resolved Hide resolved
description: |
Service level of the storage pool.
values:
- :PREMIUM
- :EXTREME
- :STANDARD
required: true
immutable: true
- !ruby/object:Api::Type::String
name: 'capacityGib'
G-NamanGupta marked this conversation as resolved.
Show resolved Hide resolved
description: |
Capacity of the storage pool (in GiB).
required: true
- !ruby/object:Api::Type::String
name: 'volumeCapacityGib'
description: |
Size allocated to volumes in the storage pool (in GiB).
output: true
- !ruby/object:Api::Type::Integer
name: 'volumeCount'
description: |
Number of volume in the storage pool.
output: true
- !ruby/object:Api::Type::String
name: 'description'
description: |
An optional description of this resource.
- !ruby/object:Api::Type::KeyValueLabels
name: labels
description: |
Labels as key value pairs. Example: `{ "owner": "Bob", "department": "finance", "purpose": "testing" }`.
- !ruby/object:Api::Type::String
name: 'network'
G-NamanGupta marked this conversation as resolved.
Show resolved Hide resolved
description: |
VPC network name with format: `projects/{{project}}/global/networks/{{network}}`
required: true
immutable: true
diff_suppress_func: tpgresource.ProjectNumberDiffSuppress
shuyama1 marked this conversation as resolved.
Show resolved Hide resolved
- !ruby/object:Api::Type::String
name: 'activeDirectory'
description: |
Specifies the Active Directory policy to be used. Format: `projects/{{project}}/locations/{{location}}/activeDirectories/{{name}}`.
The policy needs to be in the same location as the storage pool.
- !ruby/object:Api::Type::String
name: 'kmsConfig'
description: |
Specifies the CMEK policy to be used for volume encryption. Format: `projects/{{project}}/locations/{{location}}/kmsConfigs/{{name}}`.
The policy needs to be in the same location as the storage pool.
immutable: true
- !ruby/object:Api::Type::Boolean
name: 'ldapEnabled'
description: |
When enabled, the volumes uses Active Directory as LDAP name service for UID/GID lookups. Required to enable extended group support for NFSv3,
using security identifiers for NFSv4.1 or principal names for kerberized NFSv4.1.
immutable: true
- !ruby/object:Api::Type::Enum
name: 'encryptionType'
description: |
Reports if volumes in the pool are encrypted using a Google-managed encryption key or CMEK.
values:
- :ENCRYPTION_TYPE_UNSPECIFIED
- :SERVICE_MANAGED
- :CLOUD_KMS
output: true
28 changes: 28 additions & 0 deletions mmv1/templates/terraform/examples/Storage_pool_create.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

resource "google_compute_network" "peering_network" {
name = "<%= ctx[:vars]['network_name'] %>"
}

# Create an IP address
resource "google_compute_global_address" "private_ip_alloc" {
name = "<%= ctx[:vars]['global_name'] %>"
purpose = "VPC_PEERING"
address_type = "INTERNAL"
prefix_length = 16
network = google_compute_network.peering_network.id
}

# Create a private connection
resource "google_service_networking_connection" "default" {
network = google_compute_network.peering_network.id
service = "netapp.servicenetworking.goog"
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
}

resource "google_netapp_storage_pool" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]['pool_name'] %>"
location = "us-central1"
service_level = "PREMIUM"
capacity_gib = "2048"
network = google_compute_network.peering_network.id
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------

package netapp_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-provider-google/google/acctest"
)

func TestAccNetappstoragePool_storagePoolCreateExample_update(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccNetappstoragePool_storagePoolCreateExample_full(context),
},
{
ResourceName: "google_netapp_storage_pool.test_pool",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location", "name", "labels", "terraform_labels"},
},
{
Config: testAccNetappstoragePool_storagePoolCreateExample_update(context),
},
{
ResourceName: "google_netapp_storage_pool.test_pool",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location", "name", "labels", "terraform_labels"},
},
},
})
}

func testAccNetappstoragePool_storagePoolCreateExample_full(context map[string]interface{}) string {
return acctest.Nprintf(`

resource "google_compute_network" "peering_network" {
name = "tf-test-network%{random_suffix}"
}

# Create an IP address
resource "google_compute_global_address" "private_ip_alloc" {
name = "tf-test-address%{random_suffix}"
purpose = "VPC_PEERING"
address_type = "INTERNAL"
prefix_length = 16
network = google_compute_network.peering_network.id
}

# Create a private connection
resource "google_service_networking_connection" "default" {
network = google_compute_network.peering_network.id
service = "netapp.servicenetworking.goog"
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
}

resource "google_netapp_storage_pool" "test_pool" {
name = "tf-test-pool%{random_suffix}"
location = "us-central1"
service_level = "PREMIUM"
capacity_gib = "2048"
network = google_compute_network.peering_network.id
active_directory = ""
description = "this is a test description"
kms_config = ""
labels = {
key= "test"
value= "pool"
}
ldap_enabled = false
shuyama1 marked this conversation as resolved.
Show resolved Hide resolved

}
`, context)
}

func testAccNetappstoragePool_storagePoolCreateExample_update(context map[string]interface{}) string {
return acctest.Nprintf(`

resource "google_compute_network" "peering_network" {
name = "tf-test-network%{random_suffix}"
}

# Create an IP address
resource "google_compute_global_address" "private_ip_alloc" {
name = "tf-test-address%{random_suffix}"
purpose = "VPC_PEERING"
address_type = "INTERNAL"
prefix_length = 16
network = google_compute_network.peering_network.id
}

# Create a private connection
resource "google_service_networking_connection" "default" {
network = google_compute_network.peering_network.id
service = "netapp.servicenetworking.goog"
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
}

resource "google_netapp_storage_pool" "test_pool" {
name = "tf-test-pool%{random_suffix}"
location = "us-central1"
service_level = "PREMIUM"
Copy link
Member

Choose a reason for hiding this comment

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

Let's change the values of the fields to be different from what's in testAccNetappstoragePool_storagePoolCreateExample_full to test the update of these fields. If any of the fields can be updated, we'll need to mark them as immutable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've marked immutable: true to the fields which I believe are not updatable as best of my knowledge as it's not mentioned in the API documentation about which fields are immutable or not. Please have a look at it and let me know if there is any other change I'm supposed to do here.

capacity_gib = "4096"
network = google_compute_network.peering_network.id
active_directory = ""
description = "this is test"
kms_config = ""
labels = {
key= "test"
value= "pool"
}
ldap_enabled = false

}
`, context)
}