@@ -68,6 +68,8 @@ type nsxtClients struct {
68
68
Host string
69
69
PolicyEnforcementPoint string
70
70
PolicyGlobalManager bool
71
+ ProjectID string
72
+ VPCID string
71
73
}
72
74
73
75
// Provider for VMWare NSX-T
@@ -241,6 +243,7 @@ func Provider() *schema.Provider {
241
243
Description : "Avoid initializing NSX connection on startup" ,
242
244
DefaultFunc : schema .EnvDefaultFunc ("NSXT_ON_DEMAND_CONNECTION" , false ),
243
245
},
246
+ "context" : getContextSchema (false , false , true ),
244
247
},
245
248
246
249
DataSourcesMap : map [string ]* schema.Resource {
@@ -782,6 +785,7 @@ func configurePolicyConnectorData(d *schema.ResourceData, clients *nsxtClients)
782
785
clientAuthDefined := (len (clientAuthCertFile ) > 0 ) || (len (clientAuthCert ) > 0 )
783
786
policyEnforcementPoint := d .Get ("enforcement_point" ).(string )
784
787
policyGlobalManager := d .Get ("global_manager" ).(bool )
788
+ projectID , vpcID := getContextDataFromSchema (d , clients )
785
789
vmcInfo := getVmcAuthInfo (d )
786
790
787
791
isVMC := false
@@ -827,6 +831,8 @@ func configurePolicyConnectorData(d *schema.ResourceData, clients *nsxtClients)
827
831
clients .Host = host
828
832
clients .PolicyEnforcementPoint = policyEnforcementPoint
829
833
clients .PolicyGlobalManager = policyGlobalManager
834
+ clients .ProjectID = projectID
835
+ clients .VPCID = vpcID
830
836
831
837
if onDemandConn {
832
838
// version init will happen on demand
@@ -1209,7 +1215,7 @@ func getGlobalPolicyEnforcementPointPath(m interface{}, sitePath *string) string
1209
1215
return fmt .Sprintf ("%s/enforcement-points/%s" , * sitePath , getPolicyEnforcementPoint (m ))
1210
1216
}
1211
1217
1212
- func getContextDataFromSchema (d * schema.ResourceData ) (string , string ) {
1218
+ func getContextDataFromSchema (d * schema.ResourceData , m interface {} ) (string , string ) {
1213
1219
ctxPtr := d .Get ("context" )
1214
1220
if ctxPtr != nil {
1215
1221
contexts := ctxPtr .([]interface {})
@@ -1223,12 +1229,12 @@ func getContextDataFromSchema(d *schema.ResourceData) (string, string) {
1223
1229
return data ["project_id" ].(string ), vpcID
1224
1230
}
1225
1231
}
1226
- return "" , ""
1232
+ return m .( nsxtClients ). ProjectID , m .( nsxtClients ). VPCID
1227
1233
}
1228
1234
1229
1235
func getSessionContext (d * schema.ResourceData , m interface {}) tf_api.SessionContext {
1230
1236
var clientType tf_api.ClientType
1231
- projectID , vpcID := getContextDataFromSchema (d )
1237
+ projectID , vpcID := getContextDataFromSchema (d , m )
1232
1238
if projectID != "" {
1233
1239
clientType = tf_api .Multitenancy
1234
1240
if vpcID != "" {
0 commit comments