Skip to content

Commit e5e0a08

Browse files
authored
Merge branch 'master' into version-check
2 parents f3bb78c + cf1ee62 commit e5e0a08

15 files changed

+265
-44
lines changed

api/infra/policy_context_profile.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,16 @@ func (c PolicyContextProfileClientContext) Delete(contextProfileIdParam string,
159159
return err
160160
}
161161

162-
func (c PolicyContextProfileClientContext) List(cursorParam *string, includeMarkForDeleteObjectsParam *bool, includedFieldsParam *string, pageSizeParam *int64, sortAscendingParam *bool, sortByParam *string) (model0.PolicyContextProfileListResult, error) {
162+
func (c PolicyContextProfileClientContext) List(cursorParam *string, hasUnsupportedAppIdsParam *bool, includeMarkForDeleteObjectsParam *bool, includedFieldsParam *string, pageSizeParam *int64, sortAscendingParam *bool, sortByParam *string) (model0.PolicyContextProfileListResult, error) {
163163
var err error
164164
var obj model0.PolicyContextProfileListResult
165165

166166
switch c.ClientType {
167167

168168
case utl.Local:
169169
client := c.Client.(client0.ContextProfilesClient)
170-
obj, err = client.List(cursorParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam)
170+
171+
obj, err = client.List(cursorParam, hasUnsupportedAppIdsParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam)
171172

172173
case utl.Global:
173174
client := c.Client.(client1.ContextProfilesClient)
@@ -183,7 +184,7 @@ func (c PolicyContextProfileClientContext) List(cursorParam *string, includeMark
183184

184185
case utl.Multitenancy:
185186
client := c.Client.(client2.ContextProfilesClient)
186-
obj, err = client.List(utl.DefaultOrgID, c.ProjectID, cursorParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam)
187+
obj, err = client.List(utl.DefaultOrgID, c.ProjectID, cursorParam, hasUnsupportedAppIdsParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam)
187188

188189
default:
189190
err = errors.New("invalid infrastructure for model")

docs/resources/policy_edge_transport_node.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ The following arguments are supported:
127127
* `server` - (Required) Server IP or fqdn.
128128
* `credentials` - (Optional) Username and password settings for the node.
129129
* `audit_password` - (Optional) Node audit user password.
130-
* `audit_username` - (Optional) CLI "audit" username.
130+
* `audit_username` - (Optional) CLI "audit" username. Defaults to `audit` when `audit_password` is set.
131131
* `cli_password` - (Required) Node cli password.
132132
* `cli_username` - (Optional) CLI "admin" username.
133133
* `root_password` - (Required) Node root user password.

docs/resources/policy_project.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ The following arguments are supported:
4545
* `default_span_path` - (Optional) Policy path of the Cluster based default Span object of type NetworkSpan. Available since NSX 9.1.0.
4646
* `non_default_span_paths` - (Optional) List of non default policy paths of the Span objects of type NetworkSpan.
4747
* `zone_external_ids` - (Optional) An array of Zone object's external IDs.
48+
* `id_suffix` - (Optional) A suffix appended to the IDs of the project's default objects. This attribute is supported only in NSX 9.1.0 and later, and cannot be modified after creation.
4849

4950
## Attributes Reference
5051

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/vmware/go-vmware-nsxt v0.0.0-20220328155605-f49a14c1ef5f
1414
github.com/vmware/vsphere-automation-sdk-go/lib v0.8.0
1515
github.com/vmware/vsphere-automation-sdk-go/runtime v0.8.0
16-
github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.12.1-0.20250805134840-91d7e047bd3a
16+
github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.12.1-0.20251021071509-9526add9a400
1717
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.9.1-0.20241118070726-666c7cd6e466
1818
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.6.1-0.20241118070726-666c7cd6e466
1919
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ github.com/vmware/vsphere-automation-sdk-go/lib v0.8.0 h1:u1SXOTM6D4Ygb3jeidj2Rd
166166
github.com/vmware/vsphere-automation-sdk-go/lib v0.8.0/go.mod h1:8d5JTwjpM/Z03n/IZb0fwmXkJNWvWwuLXBqoakqYio4=
167167
github.com/vmware/vsphere-automation-sdk-go/runtime v0.8.0 h1:KnDIX9LY0nru7iMQTg0sy9vChhyorPo5OdASM2MaAcI=
168168
github.com/vmware/vsphere-automation-sdk-go/runtime v0.8.0/go.mod h1:DzLetYAmw1+vj7bqElRWEpuy40WYE/woL3alsymYa/c=
169-
github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.12.1-0.20250805134840-91d7e047bd3a h1:LvSpakrRj+dxYzWf/ETNbtvhlinEOsMpn89a/LXPb8I=
170-
github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.12.1-0.20250805134840-91d7e047bd3a/go.mod h1:C3JVOHRVLrGBQ8kTWAiGYlRz5UQC5qAcTdt3tvA+5P0=
169+
github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.12.1-0.20251021071509-9526add9a400 h1:tCIBk/7y1rtWDcQQyR1jQCKz1SPNRL2i/2vL0CwAsDw=
170+
github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.12.1-0.20251021071509-9526add9a400/go.mod h1:C3JVOHRVLrGBQ8kTWAiGYlRz5UQC5qAcTdt3tvA+5P0=
171171
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.9.1-0.20241118070726-666c7cd6e466 h1:SYBECpviZBcp/cUHKTDPQP7CSQb0lUfPPOClpGOFH44=
172172
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.9.1-0.20241118070726-666c7cd6e466/go.mod h1:gcEvyczWPFMZX2gkBiBVpOwvUGSNXSpxU19Sx9aiouY=
173173
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.6.1-0.20241118070726-666c7cd6e466 h1:yXUKHP/XDGp7Wrcbfl5BHV1VreCNPHRLUj2RQ5qDEmE=

nsxt/policy_errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func logVapiErrorData(message string, vapiMessages []std.LocalizableMessage, vap
104104
if len(apiError.RelatedErrors) > 0 {
105105
details += "\nRelated errors:\n"
106106
for _, relatedErr := range apiError.RelatedErrors {
107-
details += fmt.Sprintf("%s ", printRelatedAPIError(relatedErr))
107+
details += fmt.Sprintf("%s\n", printRelatedAPIError(relatedErr))
108108
}
109109
}
110110
log.Printf("[ERROR]: %s", details)

nsxt/provider.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ type nsxtClients struct {
6969
Host string
7070
PolicyEnforcementPoint string
7171
PolicyGlobalManager bool
72+
DefaultSpanPath string
7273
}
7374

7475
// Provider for VMWare NSX-T
@@ -1168,6 +1169,13 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
11681169
if err != nil {
11691170
return nil, err
11701171
}
1172+
connector := getPolicyConnector(clients)
1173+
if util.NsxVersionHigherOrEqual("9.1.0") {
1174+
clients.DefaultSpanPath, err = getDefaultSpan(connector)
1175+
if err != nil {
1176+
return nil, err
1177+
}
1178+
}
11711179

11721180
return clients, nil
11731181
}

nsxt/resource_nsxt_policy_dhcp_relay.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func resourceNsxtPolicyDhcpRelayConfig() *schema.Resource {
3737
"tag": getTagsSchema(),
3838
"context": getContextSchema(false, false, false),
3939
"server_addresses": {
40-
Type: schema.TypeList,
40+
Type: schema.TypeSet,
4141
Required: true,
4242
Elem: &schema.Schema{
4343
Type: schema.TypeString,
@@ -82,7 +82,7 @@ func resourceNsxtPolicyDhcpRelayConfigCreate(d *schema.ResourceData, m interface
8282
displayName := d.Get("display_name").(string)
8383
description := d.Get("description").(string)
8484
tags := getPolicyTagsFromSchema(d)
85-
serverAddresses := getStringListFromSchemaList(d, "server_addresses")
85+
serverAddresses := getStringListFromSchemaSet(d, "server_addresses")
8686

8787
obj := model.DhcpRelayConfig{
8888
DisplayName: &displayName,
@@ -151,7 +151,7 @@ func resourceNsxtPolicyDhcpRelayConfigUpdate(d *schema.ResourceData, m interface
151151
tags := getPolicyTagsFromSchema(d)
152152
revision := int64(d.Get("revision").(int))
153153

154-
serverAddresses := getStringListFromSchemaList(d, "server_addresses")
154+
serverAddresses := getStringListFromSchemaSet(d, "server_addresses")
155155

156156
obj := model.DhcpRelayConfig{
157157
DisplayName: &displayName,

nsxt/resource_nsxt_policy_edge_transport_node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,8 @@ func resourceNsxtPolicyEdgeTransportNode() *schema.Resource {
434434
"audit_username": {
435435
Type: schema.TypeString,
436436
Optional: true,
437-
Default: "audit",
438437
Description: "CLI \"audit\" username",
438+
Computed: true,
439439
},
440440
"cli_password": {
441441
Type: schema.TypeString,

nsxt/resource_nsxt_policy_project.go

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
package nsxt
66

77
import (
8+
"context"
89
"fmt"
910
"log"
1011

1112
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
13+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
1214
"github.com/vmware/terraform-provider-nsxt/nsxt/util"
1315
"github.com/vmware/vsphere-automation-sdk-go/runtime/protocol/client"
1416
infra2 "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/infra"
@@ -27,6 +29,19 @@ func resourceNsxtPolicyProject() *schema.Resource {
2729
State: schema.ImportStatePassthrough,
2830
},
2931

32+
CustomizeDiff: func(ctx context.Context, d *schema.ResourceDiff, m interface{}) error {
33+
if util.NsxVersionHigherOrEqual("9.1.0") {
34+
c := m.(nsxtClients)
35+
raw := d.GetRawConfig()
36+
newAttr := raw.GetAttr("default_span_path")
37+
38+
if newAttr.IsNull() {
39+
d.SetNew("default_span_path", c.DefaultSpanPath)
40+
return nil
41+
}
42+
}
43+
return nil
44+
},
3045
Schema: map[string]*schema.Schema{
3146
"nsx_id": getNsxIDSchema(),
3247
"path": getPathSchema(),
@@ -136,6 +151,12 @@ func resourceNsxtPolicyProject() *schema.Resource {
136151
Type: schema.TypeString,
137152
},
138153
},
154+
"id_suffix": {
155+
Type: schema.TypeString,
156+
Description: "Suffix to be appended to the IDs of the project's default objects.",
157+
Optional: true,
158+
ValidateFunc: validation.StringLenBetween(0, 246),
159+
},
139160
},
140161
}
141162
}
@@ -211,22 +232,17 @@ func resourceNsxtPolicyProjectPatch(connector client.Connector, d *schema.Resour
211232
}
212233

213234
if util.NsxVersionHigherOrEqual("9.1.0") {
214-
// There should be just one object here
215235
var spanReferences []model.SpanReference
216-
defaultSpanPathinterface, isDefaultSet := d.GetOkExists("default_span_path")
236+
237+
isDefault := true
238+
defaultSpanPathInterface, isDefaultSet := d.GetOkExists("default_span_path")
217239
var defaultSpanPath string
218-
if !isDefaultSet {
219-
var err error
220-
defaultSpanPath, err = getDefaultSpan(connector)
221-
if err != nil {
222-
return err
223-
}
240+
if isDefaultSet {
241+
defaultSpanPath = defaultSpanPathInterface.(string)
224242
} else {
225-
defaultSpanPath = defaultSpanPathinterface.(string)
243+
defaultSpanPath = m.(nsxtClients).DefaultSpanPath
226244
}
227-
// default_span_path will never be empty, since it has a default value and the validator will make sure that
228-
// user will not assign an empty string or such.
229-
isDefault := true
245+
230246
spanReferences = append(spanReferences, model.SpanReference{
231247
SpanPath: &defaultSpanPath,
232248
IsDefault: &isDefault,
@@ -248,6 +264,11 @@ func resourceNsxtPolicyProjectPatch(connector client.Connector, d *schema.Resour
248264
ZoneExternalIds: zoneExternalIds,
249265
}
250266
obj.VpcDeploymentScope = &vpcDeploymentScope
267+
268+
// Set id_suffix if provided
269+
if idSuffix := d.Get("id_suffix").(string); idSuffix != "" {
270+
obj.IdSuffix = &idSuffix
271+
}
251272
}
252273

253274
log.Printf("[INFO] Patching Project with ID %s", id)
@@ -410,20 +431,24 @@ func resourceNsxtPolicyProjectRead(d *schema.ResourceData, m interface{}) error
410431
d.Set("quotas", obj.Limits)
411432
}
412433

413-
if util.NsxVersionHigherOrEqual("9.1.0") && obj.VpcDeploymentScope != nil {
414-
var nonDefaultSpanPaths []interface{}
415-
var defaultSpanRefs *string
416-
for _, spanRef := range obj.VpcDeploymentScope.SpanReferences {
417-
if *spanRef.IsDefault {
418-
defaultSpanRefs = spanRef.SpanPath
419-
} else {
420-
nonDefaultSpanPaths = append(nonDefaultSpanPaths, *spanRef.SpanPath)
434+
if util.NsxVersionHigherOrEqual("9.1.0") {
435+
// Set id_suffix if available
436+
d.Set("id_suffix", obj.IdSuffix)
437+
438+
if obj.VpcDeploymentScope != nil {
439+
var nonDefaultSpanPaths []interface{}
440+
var defaultSpanRefs *string
441+
for _, spanRef := range obj.VpcDeploymentScope.SpanReferences {
442+
if *spanRef.IsDefault {
443+
defaultSpanRefs = spanRef.SpanPath
444+
} else {
445+
nonDefaultSpanPaths = append(nonDefaultSpanPaths, *spanRef.SpanPath)
446+
}
421447
}
448+
d.Set("default_span_path", defaultSpanRefs)
449+
d.Set("non_default_span_paths", nonDefaultSpanPaths)
450+
d.Set("zone_external_ids", stringList2Interface(obj.VpcDeploymentScope.ZoneExternalIds))
422451
}
423-
d.Set("default_span_path", defaultSpanRefs)
424-
d.Set("non_default_span_paths", nonDefaultSpanPaths)
425-
d.Set("zone_external_ids", stringList2Interface(obj.VpcDeploymentScope.ZoneExternalIds))
426-
427452
}
428453
return nil
429454
}

0 commit comments

Comments
 (0)