Skip to content

Commit a70078b

Browse files
authored
add a new resource HostGroup netapp (#15404)
1 parent 604bcbe commit a70078b

File tree

3 files changed

+192
-0
lines changed

3 files changed

+192
-0
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Copyright 2025 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: 'HostGroup'
16+
description: |
17+
Hostgroups define the hosts (aka initiators) that can access the specific Google Cloud Netapp Volumes.
18+
Hostgroup is a regional resource and independent of the volumes or any other resource
19+
references:
20+
guides:
21+
'Documentation': ''
22+
api: ''
23+
docs:
24+
id_format: 'projects/{{project}}/locations/{{location}}/hostGroups/{{name}}'
25+
base_url: 'projects/{{project}}/locations/{{location}}/hostGroups'
26+
self_link: 'projects/{{project}}/locations/{{location}}/hostGroups/{{name}}'
27+
create_url: 'projects/{{project}}/locations/{{location}}/hostGroups?hostGroupId={{name}}'
28+
update_url: 'projects/{{project}}/locations/{{location}}/hostGroups/{{name}}'
29+
update_verb: 'PATCH'
30+
update_mask: true
31+
delete_url: 'projects/{{project}}/locations/{{location}}/hostGroups/{{name}}'
32+
import_format:
33+
- 'projects/{{project}}/locations/{{location}}/hostGroups/{{name}}'
34+
timeouts:
35+
insert_minutes: 10
36+
update_minutes: 10
37+
delete_minutes: 30
38+
autogen_async: true
39+
async:
40+
actions: ['create', 'delete', 'update']
41+
type: 'OpAsync'
42+
operation:
43+
base_url: '{{op_id}}'
44+
result:
45+
resource_inside_response: false
46+
custom_code:
47+
# Skipping the sweeper since we need to sweep multiple regions
48+
exclude_sweeper: true
49+
examples:
50+
- name: 'netapp_host_group'
51+
primary_resource_id: 'test_host_group'
52+
vars:
53+
host_group_name: 'test-host-group'
54+
parameters:
55+
- name: 'location'
56+
type: String
57+
description: |
58+
Location (region) of the Host Group.
59+
url_param_only: true
60+
required: true
61+
immutable: true
62+
- name: 'name'
63+
type: String
64+
description: |
65+
The resource name of the Host Group. Needs to be unique per location.
66+
url_param_only: true
67+
required: true
68+
immutable: true
69+
properties:
70+
- name: 'state'
71+
type: String
72+
description: |
73+
The state of the Host Group.
74+
output: true
75+
- name: 'createTime'
76+
type: String
77+
description: |
78+
Create time of the host group. A timestamp in RFC3339 UTC "Zulu" format. Examples: "2023-06-22T09:13:01.617Z".
79+
output: true
80+
- name: 'description'
81+
type: String
82+
description: |
83+
An optional description of this resource.
84+
required: false
85+
- name: 'labels'
86+
type: KeyValueLabels
87+
description: |
88+
Labels as key value pairs. Example: `{ "owner": "Bob", "department": "finance", "purpose": "testing" }`.
89+
required: false
90+
- name: 'type'
91+
type: Enum
92+
description: |
93+
Type of the host group.
94+
required: true
95+
immutable: true
96+
enum_values:
97+
- 'ISCSI_INITIATOR'
98+
- name: 'hosts'
99+
type: Array
100+
description: |
101+
The list of hosts associated with the host group
102+
required: true
103+
item_type:
104+
type: String
105+
- name: 'osType'
106+
type: Enum
107+
description: |
108+
The OS type of the host group. It indicates the type of operating system
109+
used by all of the hosts in the HostGroup. All hosts in a HostGroup must be
110+
of the same OS type. This can be set only when creating a HostGroup.
111+
immutable: true
112+
enum_values:
113+
- 'LINUX'
114+
- 'WINDOWS'
115+
- 'ESXI'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resource "google_netapp_host_group" "{{$.PrimaryResourceId}}" {
2+
name = "{{index $.Vars "host_group_name"}}"
3+
location = "us-central1"
4+
os_type = "LINUX"
5+
type = "ISCSI_INITIATOR"
6+
hosts = ["iqn.1994-05.com.redhat:8518f79d5366"]
7+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package netapp_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
7+
8+
"github.com/hashicorp/terraform-provider-google/google/acctest"
9+
)
10+
11+
func TestAccNetappHostGroup_HostGroupCreateExample_Update(t *testing.T) {
12+
t.Parallel()
13+
14+
context := map[string]interface{}{
15+
"random_suffix": acctest.RandString(t, 10),
16+
}
17+
18+
acctest.VcrTest(t, resource.TestCase{
19+
PreCheck: func() { acctest.AccTestPreCheck(t) },
20+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
21+
Steps: []resource.TestStep{
22+
{
23+
Config: testAccNetappHostGroup_HostGroupCreateExample_Full(context),
24+
},
25+
{
26+
ResourceName: "google_netapp_host_group.test_host_group",
27+
ImportState: true,
28+
ImportStateVerify: true,
29+
ImportStateVerifyIgnore: []string{"location", "name", "labels", "terraform_labels"},
30+
},
31+
{
32+
Config: testAccNetappHostGroup_HostGroupCreateExample_Update(context),
33+
},
34+
{
35+
ResourceName: "google_netapp_host_group.test_host_group",
36+
ImportState: true,
37+
ImportStateVerify: true,
38+
ImportStateVerifyIgnore: []string{"location", "name", "labels", "terraform_labels"},
39+
},
40+
},
41+
})
42+
}
43+
44+
func testAccNetappHostGroup_HostGroupCreateExample_Full(context map[string]interface{}) string {
45+
return acctest.Nprintf(`
46+
resource "google_netapp_host_group" "test_host_group" {
47+
name = "tf-test-test-host-group%{random_suffix}"
48+
location = "us-central1"
49+
os_type = "LINUX"
50+
type = "ISCSI_INITIATOR"
51+
hosts = ["iqn.1994-05.com.redhat:8518f79d5366"]
52+
}
53+
`, context)
54+
}
55+
56+
func testAccNetappHostGroup_HostGroupCreateExample_Update(context map[string]interface{}) string {
57+
return acctest.Nprintf(`
58+
resource "google_netapp_host_group" "test_host_group" {
59+
name = "tf-test-test-host-group%{random_suffix}"
60+
location = "us-central1"
61+
os_type = "LINUX"
62+
type = "ISCSI_INITIATOR"
63+
hosts = ["iqn.1994-05.com.redhat:8518f79d5366", "iqn.1993-08.org.debian:01:10ddd07f338"]
64+
description = "Terraform created host group"
65+
labels = {
66+
"creator": "terraform"
67+
}
68+
}
69+
`, context)
70+
}

0 commit comments

Comments
 (0)