Skip to content

Commit 26b654a

Browse files
authored
Merge branch 'stable-2.2.0' into 499-security-account-locked
2 parents 6f631cd + 974c84a commit 26b654a

File tree

9 files changed

+171
-144
lines changed

9 files changed

+171
-144
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ DOCUMENTATION:
77
BUG FIXES:
88

99
- **netapp-ontap_security_account**: unable to unlock existing `security_account` resource ([#499](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/499))
10+
- **netapp-ontap_port**: fixed error when importing VLANs in multi-node clusters ([#479](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/479))
11+
- **netapp-ontap_san_igroup**: fixed issue with adding initiators to new igroup ([#274](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/274))
1012

1113
# 2.2.0 (2025-05-01)
1214

docs/data-sources/network_ethernet_port.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ data "netapp-ontap_port" "physical" {
2222
# required to know which system to interface with
2323
cx_profile_name = "cluster4"
2424
name = "e0a"
25+
node = {
26+
name = "netapp_single-01"
27+
}
2528
}
2629
```
2730

@@ -30,6 +33,9 @@ data "netapp-ontap_port" "lag" {
3033
# required to know which system to interface with
3134
cx_profile_name = "cluster4"
3235
name = "a0a"
36+
node = {
37+
name = "netapp_single-01"
38+
}
3339
}
3440
```
3541

@@ -38,6 +44,9 @@ data "netapp-ontap_port" "vlan" {
3844
# required to know which system to interface with
3945
cx_profile_name = "cluster4"
4046
name = "e0a-100"
47+
node = {
48+
name = "netapp_single-01"
49+
}
4150
}
4251
```
4352

@@ -49,6 +58,7 @@ data "netapp-ontap_port" "vlan" {
4958

5059
- `cx_profile_name` (String) Connection profile name
5160
- `name` (String) Portname, such as e0a, e1b-100 (VLAN on Ethernet), a0c (LAG/ifgrp), a0d-200 (VLAN on LAG/ifgrp), e0a.pv1 (p-VLAN, in select environments only)
61+
- `node` (Attributes) (see [below for nested schema](#nestedatt--node))
5262

5363
### Read-Only
5464

@@ -58,7 +68,6 @@ data "netapp-ontap_port" "vlan" {
5868
- `lag` (Attributes) (see [below for nested schema](#nestedatt--lag))
5969
- `mac_address` (String) Port MAC address
6070
- `mtu` (Number) MTU of the port in bytes
61-
- `node` (Attributes) (see [below for nested schema](#nestedatt--node))
6271
- `rdma_protocols` (Set of String) Supported RDMA offload protocols
6372
- `reachability` (String) Reachability status of the port
6473
- `speed` (Number) Link speed in Mbps
@@ -92,9 +101,12 @@ Read-Only:
92101

93102
### Nested Schema for `node`
94103

95-
Read-Only:
104+
Required:
96105

97106
- `name` (String) Name of the node on which the port is located
107+
108+
Read-Only:
109+
98110
- `id` (String) Node UUID
99111

100112
<a id="nestedatt--vlan"></a>

docs/resources/network_ethernet_port.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,15 @@ Required:
143143
## Import
144144

145145
This Resource supports import, which allows you to import existing ethernet port into the state of this resoruce.
146-
Import require a unique ID composed of the cx_profile_name and port name, separated by a comma.
147-
id = `cx_profile_name`,`name`
146+
Import require a unique ID composed of the port name, node name, and cx_profile_name, separated by a comma.
147+
id = `name`,`node`,`cx_profile_name`
148148

149149
### Terraform Import
150150

151151
For example
152152

153153
```shell
154-
terraform import netapp-ontap_port.example cluster4,e0a-300
154+
terraform import netapp-ontap_port.example e0a-300,netapp_single-01,cluster4
155155
```
156156

157157
!> The terraform import CLI command can only import resources into the state. Importing via the CLI does not generate configuration. If you want to generate the accompanying configuration for imported resources, use the import block instead.
@@ -165,7 +165,7 @@ First create the block
165165
```terraform
166166
import {
167167
to = netapp-ontap_port.vlan_import
168-
id = "cluster4,e0a-300"
168+
id = "e0a-300,netapp_single-01,cluster4"
169169
}
170170
```
171171

@@ -180,7 +180,7 @@ This will generate a file called generated.tf, which will contain the configurat
180180
```terraform
181181
# __generated__ by Terraform
182182
# Please review these resources and move them into your main configuration files.
183-
# __generated__ by Terraform from "cluster4,e0a-300"
183+
# __generated__ by Terraform from "e0a-300,netapp_single-01,cluster4"
184184
resource "netapp-ontap_port" "vlan_import" {
185185
cx_profile_name = "cluster4"
186186
type = "vlan"

examples/data-sources/netapp-ontap_port/data-source.tf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,25 @@ data "netapp-ontap_port" "physical" {
22
# required to know which system to interface with
33
cx_profile_name = "cluster4"
44
name = "e0a"
5+
node = {
6+
name = "netapp_single-01"
7+
}
58
}
69

710
data "netapp-ontap_port" "lag" {
811
# required to know which system to interface with
912
cx_profile_name = "cluster4"
1013
name = "a0a"
14+
node = {
15+
name = "netapp_single-01"
16+
}
1117
}
1218

1319
data "netapp-ontap_port" "vlan" {
1420
# required to know which system to interface with
1521
cx_profile_name = "cluster4"
16-
name = "e0a-100"
22+
name = "e0a-101"
23+
node = {
24+
name = "netapp_single-01"
25+
}
1726
}

internal/interfaces/network_ethernet_port.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,10 @@ func GetEthernetPort(errorHandler *utils.ErrorHandler, r restclient.RestClient,
151151

152152
// Retrieve ethernet port details
153153
// https://docs.netapp.com/us-en/ontap-restapi/ontap/get-network-ethernet-ports.html
154-
func GetEthernetPortByName(errorHandler *utils.ErrorHandler, r restclient.RestClient, name string) (*EthernetPortGetDataModelONTAP, error) {
154+
func GetEthernetPortByName(errorHandler *utils.ErrorHandler, r restclient.RestClient, node, name string) (*EthernetPortGetDataModelONTAP, error) {
155155
api := "/network/ethernet/ports/"
156156
query := r.NewQuery()
157+
query.Set("node.name", node)
157158
query.Set("name", name)
158159
query.Fields([]string{
159160
"broadcast_domain",

internal/provider/networking/network_ethernet_port_data_source.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,15 @@ func (d *EthernetPortDataSource) Schema(ctx context.Context, req datasource.Sche
160160
Attributes: map[string]schema.Attribute{
161161
"name": schema.StringAttribute{
162162
MarkdownDescription: "Name of the node on which the port is located",
163-
Computed: true,
163+
Required: true,
164164
},
165165
"id": schema.StringAttribute{
166166
MarkdownDescription: "Node UUID",
167167
Computed: true,
168168
},
169169
},
170170
MarkdownDescription: "Node properties",
171-
Computed: true,
171+
Required: true,
172172
},
173173
"rdma_protocols": schema.SetAttribute{
174174
MarkdownDescription: "Supported RDMA offload protocols",
@@ -257,6 +257,7 @@ func (d *EthernetPortDataSource) Read(ctx context.Context, req datasource.ReadRe
257257
restInfo, err := interfaces.GetEthernetPortByName(
258258
errorHandler,
259259
*client,
260+
data.Node.Name.ValueString(),
260261
data.Name.ValueString(),
261262
)
262263
if err != nil {

internal/provider/networking/network_ethernet_port_resource.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ func (r *EthernetPortResource) Read(ctx context.Context, req resource.ReadReques
281281
restInfo, err = interfaces.GetEthernetPortByName(
282282
errorHandler,
283283
*client,
284+
data.Node.Name.ValueString(),
284285
data.Name.ValueString(),
285286
)
286287
if err != nil {
@@ -641,16 +642,17 @@ func (r *EthernetPortResource) ImportState(ctx context.Context, req resource.Imp
641642

642643
// Extract ethernet_port info from import identifier
643644
idParts := strings.Split(req.ID, ",")
644-
if len(idParts) != 2 || idParts[0] == "" || idParts[1] == "" {
645+
if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" {
645646
resp.Diagnostics.AddError(
646647
"Unexpected Import Identifier",
647-
fmt.Sprintf("Expected import identifier with format: cx_profile_name,name, got: %q.", req.ID),
648+
fmt.Sprintf("Expected import identifier with format: name,node,cx_profile_name, got: %q.", req.ID),
648649
)
649650

650651
return
651652
}
652653

653654
// Save ethernet_port info to attributes
654-
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("cx_profile_name"), idParts[0])...)
655-
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("name"), idParts[1])...)
655+
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("name"), idParts[0])...)
656+
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("node").AtName("name"), idParts[1])...)
657+
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("cx_profile_name"), idParts[2])...)
656658
}

0 commit comments

Comments
 (0)