/
vdc_group.go
623 lines (522 loc) · 18.6 KB
/
vdc_group.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
/*
* Copyright 2021 VMware, Inc. All rights reserved. Licensed under the Apache v2 License.
*/
package govcd
import (
"fmt"
"net/url"
"strings"
"github.com/vmware/go-vcloud-director/v2/types/v56"
)
// VdcGroup is a structure defining a VdcGroup in Organization
type VdcGroup struct {
VdcGroup *types.VdcGroup
Href string
client *Client
parent organization
}
// CreateNsxtVdcGroup create NSX-T VDC group with provided VDC IDs.
// More generic creation method available also - CreateVdcGroup
func (adminOrg *AdminOrg) CreateNsxtVdcGroup(name, description, startingVdcId string, participatingVdcIds []string) (*VdcGroup, error) {
participatingVdcs, err := composeParticipatingOrgVdcs(adminOrg, startingVdcId, participatingVdcIds)
if err != nil {
return nil, err
}
vdcGroupConfig := &types.VdcGroup{}
vdcGroupConfig.OrgId = adminOrg.orgId()
vdcGroupConfig.Name = name
vdcGroupConfig.Description = description
vdcGroupConfig.ParticipatingOrgVdcs = participatingVdcs
vdcGroupConfig.LocalEgress = false
vdcGroupConfig.UniversalNetworkingEnabled = false
vdcGroupConfig.NetworkProviderType = "NSX_T"
vdcGroupConfig.Type = "LOCAL"
vdcGroupConfig.ParticipatingOrgVdcs = participatingVdcs
return adminOrg.CreateVdcGroup(vdcGroupConfig)
}
// composeParticipatingOrgVdcs converts fetched candidate VDCs to []types.ParticipatingOrgVdcs
// returns error also in case participatingVdcId not found as candidate VDC.
func composeParticipatingOrgVdcs(adminOrg *AdminOrg, startingVdcId string, participatingVdcIds []string) ([]types.ParticipatingOrgVdcs, error) {
candidateVdcs, err := adminOrg.GetAllNsxtVdcGroupCandidates(startingVdcId, nil)
if err != nil {
return nil, err
}
participatingVdcs := []types.ParticipatingOrgVdcs{}
var foundParticipatingVdcsIds []string
for _, candidateVdc := range candidateVdcs {
if contains(candidateVdc.Id, participatingVdcIds) {
participatingVdcs = append(participatingVdcs, types.ParticipatingOrgVdcs{
OrgRef: candidateVdc.OrgRef,
SiteRef: candidateVdc.SiteRef,
VdcRef: types.OpenApiReference{
ID: candidateVdc.Id,
},
FaultDomainTag: candidateVdc.FaultDomainTag,
NetworkProviderScope: candidateVdc.NetworkProviderScope,
})
foundParticipatingVdcsIds = append(foundParticipatingVdcsIds, candidateVdc.Id)
}
}
if len(participatingVdcs) != len(participatingVdcIds) {
var notFoundVdcs []string
for _, participatingVdcId := range participatingVdcIds {
if !contains(participatingVdcId, foundParticipatingVdcsIds) {
notFoundVdcs = append(notFoundVdcs, participatingVdcId)
}
}
return nil, fmt.Errorf("VDC IDs are not found as Candidate VDCs: %s", notFoundVdcs)
}
return participatingVdcs, nil
}
// contains tells whether slice of string contains item.
func contains(item string, slice []string) bool {
for _, n := range slice {
if item == n {
return true
}
}
return false
}
// CreateVdcGroup create VDC group with provided VDC ref.
// Only supports NSX-T VDCs.
func (adminOrg *AdminOrg) CreateVdcGroup(vdcGroup *types.VdcGroup) (*VdcGroup, error) {
tenantContext, err := adminOrg.getTenantContext()
if err != nil {
return nil, err
}
return createVdcGroup(adminOrg, vdcGroup, getTenantContextHeader(tenantContext))
}
// createVdcGroup create VDC group with provided VDC ref.
// Only supports NSX-T VDCs.
func createVdcGroup(adminOrg *AdminOrg, vdcGroup *types.VdcGroup,
additionalHeader map[string]string) (*VdcGroup, error) {
endpoint := types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointVdcGroups
apiVersion, err := adminOrg.client.checkOpenApiEndpointCompatibility(endpoint)
if err != nil {
return nil, err
}
urlRef, err := adminOrg.client.OpenApiBuildEndpoint(endpoint)
if err != nil {
return nil, err
}
typeResponse := &VdcGroup{
VdcGroup: &types.VdcGroup{},
client: adminOrg.client,
Href: urlRef.String(),
parent: adminOrg,
}
err = adminOrg.client.OpenApiPostItem(apiVersion, urlRef, nil,
vdcGroup, typeResponse.VdcGroup, additionalHeader)
if err != nil {
return nil, err
}
return typeResponse, nil
}
// GetAllNsxtVdcGroupCandidates returns NSXT candidate VDCs for VDC group
func (adminOrg *AdminOrg) GetAllNsxtVdcGroupCandidates(startingVdcId string, queryParameters url.Values) ([]*types.CandidateVdc, error) {
queryParams := copyOrNewUrlValues(queryParameters)
queryParams = queryParameterFilterAnd("_context==LOCAL", queryParams)
queryParams = queryParameterFilterAnd(fmt.Sprintf("_context==%s", startingVdcId), queryParams)
queryParams.Add("filterEncoded", "true")
queryParams.Add("links", "true")
return adminOrg.GetAllVdcGroupCandidates(queryParams)
}
// GetAllVdcGroupCandidates returns candidate VDCs for VDC group
func (adminOrg *AdminOrg) GetAllVdcGroupCandidates(queryParameters url.Values) ([]*types.CandidateVdc, error) {
tenantContext, err := adminOrg.getTenantContext()
if err != nil {
return nil, err
}
endpoint := types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointVdcGroupsCandidateVdcs
minimumApiVersion, err := adminOrg.client.checkOpenApiEndpointCompatibility(endpoint)
if err != nil {
return nil, err
}
urlRef, err := adminOrg.client.OpenApiBuildEndpoint(endpoint)
if err != nil {
return nil, err
}
responses := []*types.CandidateVdc{}
err = adminOrg.client.OpenApiGetAllItems(minimumApiVersion, urlRef, queryParameters, &responses, getTenantContextHeader(tenantContext))
if err != nil {
return nil, err
}
return responses, nil
}
// Delete deletes VDC group
func (vdcGroup *VdcGroup) Delete() error {
return vdcGroup.ForceDelete(false)
}
// ForceDelete deletes VDC group with force parameter if enabled
func (vdcGroup *VdcGroup) ForceDelete(force bool) error {
endpoint := types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointVdcGroups
minimumApiVersion, err := vdcGroup.client.checkOpenApiEndpointCompatibility(endpoint)
if err != nil {
return err
}
if vdcGroup.VdcGroup.Id == "" {
return fmt.Errorf("cannot delete VDC group without id")
}
urlRef, err := vdcGroup.client.OpenApiBuildEndpoint(endpoint, vdcGroup.VdcGroup.Id)
if err != nil {
return err
}
params := copyOrNewUrlValues(nil)
if force {
params.Add("force", "true")
}
err = vdcGroup.client.OpenApiDeleteItem(minimumApiVersion, urlRef, params, nil)
if err != nil {
return fmt.Errorf("error deleting VDC group (force %t): %s", force, err)
}
return nil
}
// GetAllVdcGroups retrieves all VDC groups. Query parameters can be supplied to perform additional filtering
func (adminOrg *AdminOrg) GetAllVdcGroups(queryParameters url.Values) ([]*VdcGroup, error) {
tenantContext, err := adminOrg.getTenantContext()
if err != nil {
return nil, err
}
endpoint := types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointVdcGroups
minimumApiVersion, err := adminOrg.client.checkOpenApiEndpointCompatibility(endpoint)
if err != nil {
return nil, err
}
urlRef, err := adminOrg.client.OpenApiBuildEndpoint(endpoint)
if err != nil {
return nil, err
}
responses := []*types.VdcGroup{}
err = adminOrg.client.OpenApiGetAllItems(minimumApiVersion, urlRef, queryParameters, &responses, getTenantContextHeader(tenantContext))
if err != nil {
return nil, err
}
var wrappedVdcGroups []*VdcGroup
for _, response := range responses {
urlRef, err := adminOrg.client.OpenApiBuildEndpoint(endpoint, response.Id)
if err != nil {
return nil, err
}
wrappedVdcGroup := &VdcGroup{
VdcGroup: response,
client: adminOrg.client,
Href: urlRef.String(),
parent: adminOrg,
}
wrappedVdcGroups = append(wrappedVdcGroups, wrappedVdcGroup)
}
return wrappedVdcGroups, nil
}
// GetVdcGroupByName retrieves VDC group by given name
// When the name contains commas, semicolons or asterisks, the encoding is rejected by the API in VCD.
// For this reason, when one or more commas, semicolons or asterisks are present we run the search brute force,
// by fetching all VDC groups and comparing the names.
// Also, url.QueryEscape as well as url.Values.Encode() both encode the space as a + character. So we use
// search brute force too. Reference to issue:
// https://github.com/golang/go/issues/4013
// https://github.com/czos/goamz/pull/11/files
func (adminOrg *AdminOrg) GetVdcGroupByName(name string) (*VdcGroup, error) {
slowSearch, params := shouldDoSlowSearch("name", name)
var foundVdcGroups []*VdcGroup
vdcGroups, err := adminOrg.GetAllVdcGroups(params)
if err != nil {
return nil, err
}
if len(vdcGroups) == 0 {
return nil, ErrorEntityNotFound
}
foundVdcGroups = append(foundVdcGroups, vdcGroups[0])
if slowSearch {
foundVdcGroups = nil
for _, vdcGroup := range vdcGroups {
if vdcGroup.VdcGroup.Name == name {
foundVdcGroups = append(foundVdcGroups, vdcGroup)
}
}
if len(foundVdcGroups) == 0 {
return nil, ErrorEntityNotFound
}
if len(foundVdcGroups) > 1 {
return nil, fmt.Errorf("more than one VDC group found with name '%s'", name)
}
}
if len(vdcGroups) > 1 && !slowSearch {
return nil, fmt.Errorf("more than one VDC group found with name '%s'", name)
}
return foundVdcGroups[0], nil
}
// GetVdcGroupById Returns VDC group using provided ID
func (adminOrg *AdminOrg) GetVdcGroupById(id string) (*VdcGroup, error) {
tenantContext, err := adminOrg.getTenantContext()
if err != nil {
return nil, err
}
endpoint := types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointVdcGroups
minimumApiVersion, err := adminOrg.client.checkOpenApiEndpointCompatibility(endpoint)
if err != nil {
return nil, err
}
if id == "" {
return nil, fmt.Errorf("empty VDC group ID")
}
urlRef, err := adminOrg.client.OpenApiBuildEndpoint(endpoint, id)
if err != nil {
return nil, err
}
vdcGroup := &VdcGroup{
VdcGroup: &types.VdcGroup{},
client: adminOrg.client,
Href: urlRef.String(),
parent: adminOrg,
}
err = adminOrg.client.OpenApiGetItem(minimumApiVersion, urlRef, nil, vdcGroup.VdcGroup, getTenantContextHeader(tenantContext))
if err != nil {
return nil, err
}
return vdcGroup, nil
}
// GetVdcGroupById Returns VDC group using provided ID
func (org *Org) GetVdcGroupById(id string) (*VdcGroup, error) {
if id == "" {
return nil, fmt.Errorf("empty VDC group ID")
}
tenantContext, err := org.getTenantContext()
if err != nil {
return nil, err
}
endpoint := types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointVdcGroups
minimumApiVersion, err := org.client.checkOpenApiEndpointCompatibility(endpoint)
if err != nil {
return nil, err
}
urlRef, err := org.client.OpenApiBuildEndpoint(endpoint, id)
if err != nil {
return nil, err
}
vdcGroup := &VdcGroup{
VdcGroup: &types.VdcGroup{},
client: org.client,
Href: urlRef.String(),
parent: org,
}
err = org.client.OpenApiGetItem(minimumApiVersion, urlRef, nil, vdcGroup.VdcGroup, getTenantContextHeader(tenantContext))
if err != nil {
return nil, err
}
return vdcGroup, nil
}
// Update updates existing Vdc group. Allows changing only name and description and participating VCDs
// Not restrictive update method also available - GenericUpdate
func (vdcGroup *VdcGroup) Update(name, description string, participatingOrgVddIs []string) (*VdcGroup, error) {
vdcGroup.VdcGroup.Name = name
vdcGroup.VdcGroup.Description = description
participatingOrgVdcs, err := composeParticipatingOrgVdcs(vdcGroup.parent.fullObject().(*AdminOrg), vdcGroup.VdcGroup.Id, participatingOrgVddIs)
if err != nil {
return nil, err
}
vdcGroup.VdcGroup.ParticipatingOrgVdcs = participatingOrgVdcs
return vdcGroup.GenericUpdate()
}
// GenericUpdate updates existing Vdc group. API allows changing only name and description and participating VCDs
func (vdcGroup *VdcGroup) GenericUpdate() (*VdcGroup, error) {
tenantContext, err := vdcGroup.getTenantContext()
if err != nil {
return nil, err
}
endpoint := types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointVdcGroups
minimumApiVersion, err := vdcGroup.client.checkOpenApiEndpointCompatibility(endpoint)
if err != nil {
return nil, err
}
if vdcGroup.VdcGroup.Id == "" {
return nil, fmt.Errorf("cannot update VDC group without id")
}
urlRef, err := vdcGroup.client.OpenApiBuildEndpoint(endpoint, vdcGroup.VdcGroup.Id)
if err != nil {
return nil, err
}
returnVdcGroup := &VdcGroup{
VdcGroup: &types.VdcGroup{},
client: vdcGroup.client,
Href: vdcGroup.Href,
parent: vdcGroup.parent,
}
err = vdcGroup.client.OpenApiPutItem(minimumApiVersion, urlRef, nil, vdcGroup.VdcGroup,
returnVdcGroup.VdcGroup, getTenantContextHeader(tenantContext))
if err != nil {
return nil, fmt.Errorf("error updating VDC group: %s", err)
}
return returnVdcGroup, nil
}
// UpdateDfwPolicies updates distributed firewall policies
func (vdcGroup *VdcGroup) UpdateDfwPolicies(dfwPolicies types.DfwPolicies) (*VdcGroup, error) {
tenantContext, err := vdcGroup.getTenantContext()
if err != nil {
return nil, err
}
endpoint := types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointVdcGroupsDfwPolicies
minimumApiVersion, err := vdcGroup.client.checkOpenApiEndpointCompatibility(endpoint)
if err != nil {
return nil, err
}
if vdcGroup.VdcGroup.Id == "" {
return nil, fmt.Errorf("cannot update VDC group Dfw policies without id")
}
urlRef, err := vdcGroup.client.OpenApiBuildEndpoint(fmt.Sprintf(endpoint, vdcGroup.VdcGroup.Id))
if err != nil {
return nil, err
}
err = vdcGroup.client.OpenApiPutItem(minimumApiVersion, urlRef, nil, dfwPolicies,
nil, getTenantContextHeader(tenantContext))
if err != nil {
return nil, fmt.Errorf("error updating VDC group Dfw policies: %s", err)
}
adminOrg := vdcGroup.parent.fullObject().(*AdminOrg)
return adminOrg.GetVdcGroupById(vdcGroup.VdcGroup.Id)
}
// UpdateDefaultDfwPolicies updates distributed firewall default policies
func (vdcGroup *VdcGroup) UpdateDefaultDfwPolicies(defaultDfwPolicies types.DefaultPolicy) (*VdcGroup, error) {
tenantContext, err := vdcGroup.getTenantContext()
if err != nil {
return nil, err
}
endpoint := types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointVdcGroupsDfwDefaultPolicies
minimumApiVersion, err := vdcGroup.client.checkOpenApiEndpointCompatibility(endpoint)
if err != nil {
return nil, err
}
if vdcGroup.VdcGroup.Id == "" {
return nil, fmt.Errorf("cannot update VDC group default DFW policies without id")
}
urlRef, err := vdcGroup.client.OpenApiBuildEndpoint(fmt.Sprintf(endpoint, vdcGroup.VdcGroup.Id))
if err != nil {
return nil, err
}
err = vdcGroup.client.OpenApiPutItem(minimumApiVersion, urlRef, nil, defaultDfwPolicies,
nil, getTenantContextHeader(tenantContext))
if err != nil {
return nil, fmt.Errorf("error updating VDC group default DFW policies: %s", err)
}
adminOrg := vdcGroup.parent.fullObject().(*AdminOrg)
return adminOrg.GetVdcGroupById(vdcGroup.VdcGroup.Id)
}
// ActivateDfw activates distributed firewall
func (vdcGroup *VdcGroup) ActivateDfw() (*VdcGroup, error) {
return vdcGroup.UpdateDfwPolicies(types.DfwPolicies{
Enabled: true,
})
}
// DeactivateDfw deactivates distributed firewall
func (vdcGroup *VdcGroup) DeactivateDfw() (*VdcGroup, error) {
return vdcGroup.UpdateDfwPolicies(types.DfwPolicies{
Enabled: false,
})
}
// GetDfwPolicies retrieves all distributed firewall policies
func (vdcGroup *VdcGroup) GetDfwPolicies() (*types.DfwPolicies, error) {
tenantContext, err := vdcGroup.getTenantContext()
if err != nil {
return nil, err
}
endpoint := types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointVdcGroupsDfwPolicies
minimumApiVersion, err := vdcGroup.client.checkOpenApiEndpointCompatibility(endpoint)
if err != nil {
return nil, err
}
urlRef, err := vdcGroup.client.OpenApiBuildEndpoint(fmt.Sprintf(endpoint, vdcGroup.VdcGroup.Id))
if err != nil {
return nil, err
}
response := types.DfwPolicies{}
err = vdcGroup.client.OpenApiGetItem(minimumApiVersion, urlRef, nil, &response, getTenantContextHeader(tenantContext))
if err != nil {
return nil, err
}
return &response, nil
}
// EnableDefaultPolicy activates default dfw policy
func (vdcGroup *VdcGroup) EnableDefaultPolicy() (*VdcGroup, error) {
dfwPolicies, err := vdcGroup.GetDfwPolicies()
if err != nil {
return nil, err
}
if dfwPolicies.DefaultPolicy == nil {
return nil, fmt.Errorf("DFW has to be enabled before changing Default policy")
}
dfwPolicies.DefaultPolicy.Enabled = addrOf(true)
return vdcGroup.UpdateDefaultDfwPolicies(*dfwPolicies.DefaultPolicy)
}
// DisableDefaultPolicy deactivates default dfw policy
func (vdcGroup *VdcGroup) DisableDefaultPolicy() (*VdcGroup, error) {
dfwPolicies, err := vdcGroup.GetDfwPolicies()
if err != nil {
return nil, err
}
if dfwPolicies.DefaultPolicy == nil {
return nil, fmt.Errorf("DFW has to be enabled before changing Default policy")
}
dfwPolicies.DefaultPolicy.Enabled = addrOf(false)
return vdcGroup.UpdateDefaultDfwPolicies(*dfwPolicies.DefaultPolicy)
}
func getOwnerTypeFromUrn(urn string) (string, error) {
if !isUrn(urn) {
return "", fmt.Errorf("supplied ID is not URN: %s", urn)
}
ss := strings.Split(urn, ":")
return ss[2], nil
}
// OwnerIsVdcGroup evaluates given URN and returns true if it is a VDC Group
func OwnerIsVdcGroup(urn string) bool {
ownerType, err := getOwnerTypeFromUrn(urn)
if err != nil {
return false
}
if strings.EqualFold(ownerType, types.UrnTypeVdcGroup) {
return true
}
return false
}
// OwnerIsVdc evaluates a given URN and returns true if it is a VDC
func OwnerIsVdc(urn string) bool {
ownerType, err := getOwnerTypeFromUrn(urn)
if err != nil {
return false
}
if strings.EqualFold(ownerType, types.UrnTypeVdc) {
return true
}
return false
}
// GetCapabilities allows to retrieve a list of VDC capabilities. It has a list of values. Some particularly useful are:
// * networkProvider - overlay stack responsible for providing network functionality. (NSX_V or NSX_T)
// * crossVdc - supports cross vDC network creation
func (vdcGroup *VdcGroup) GetCapabilities() ([]types.VdcCapability, error) {
if vdcGroup.VdcGroup.Id == "" {
return nil, fmt.Errorf("VDC ID must be set to get capabilities")
}
endpoint := types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointVdcCapabilities
minimumApiVersion, err := vdcGroup.client.checkOpenApiEndpointCompatibility(endpoint)
if err != nil {
return nil, err
}
urlRef, err := vdcGroup.client.OpenApiBuildEndpoint(fmt.Sprintf(endpoint, url.QueryEscape(vdcGroup.VdcGroup.Id)))
if err != nil {
return nil, err
}
capabilities := make([]types.VdcCapability, 0)
err = vdcGroup.client.OpenApiGetAllItems(minimumApiVersion, urlRef, nil, &capabilities, nil)
if err != nil {
return nil, err
}
return capabilities, nil
}
// IsNsxt is a convenience function to check if VDC is backed by NSX-T pVdc
// If error occurs - it returns false
func (vdcGroup *VdcGroup) IsNsxt() bool {
vdcCapabilities, err := vdcGroup.GetCapabilities()
if err != nil {
return false
}
networkProviderCapability := getCapabilityValue(vdcCapabilities, "networkProvider")
return networkProviderCapability == types.VdcCapabilityNetworkProviderNsxt
}