Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changes/v1.0.0/18-features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- **New Resource:** `vcfa_org_regional_networking` to manage Org Regional Networking Settings [GH-18]
- **New Data Source:** `vcfa_org_regional_networking` to read Org Regional Networking Settings [GH-18]
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@ require (
google.golang.org/protobuf v1.35.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/vmware/go-vcloud-director/v3 => github.com/Didainius/go-vcloud-director/v3 v3.0.0-alpha.4.0.20250128170706-627f2de0fcba
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
github.com/Didainius/go-vcloud-director/v3 v3.0.0-alpha.4.0.20250128170706-627f2de0fcba h1:B9lUGpJ/FpeHa2YwbdW7tVpT0e1pqhWNGhKIist9cw8=
github.com/Didainius/go-vcloud-director/v3 v3.0.0-alpha.4.0.20250128170706-627f2de0fcba/go.mod h1:68KHsVns52dsq/w5JQYzauaU/+NAi1FmCxhBrFc/VoQ=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg=
Expand Down Expand Up @@ -149,8 +151,6 @@ github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IU
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
github.com/vmware/go-vcloud-director/v3 v3.0.0-alpha.21 h1:iBuyJ9Vq8ydyHaFiD3eUnEz7OkbqhDv5OXWI/fOCtPs=
github.com/vmware/go-vcloud-director/v3 v3.0.0-alpha.21/go.mod h1:68KHsVns52dsq/w5JQYzauaU/+NAi1FmCxhBrFc/VoQ=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
Expand Down
1 change: 1 addition & 0 deletions vcfa/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ type TestConfig struct {
NsxManagerUrl string `json:"nsxManagerUrl"`
NsxEdgeCluster string `json:"nsxEdgeCluster"`
NsxTier0Gateway string `json:"nsxTier0Gateway"`
ProviderGateway string `json:"providerGateway"`

CreateVcenter bool `json:"createVcenter"`
VcenterUsername string `json:"vcenterUsername"`
Expand Down
65 changes: 65 additions & 0 deletions vcfa/datasource_vcfa_org_regional_networking.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package vcfa

import (
"context"
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/vmware/go-vcloud-director/v3/govcd"
"github.com/vmware/go-vcloud-director/v3/types/v56"
)

func datasourceVcfaOrgRegionalNetworking() *schema.Resource {
return &schema.Resource{
ReadContext: datasourceVcfaOrgRegionalNetworkingRead,

Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
Description: fmt.Sprintf("Name of %s", labelVcfaRegionalNetworkingSetting),
},
"org_id": {
Type: schema.TypeString,
Required: true,
Description: fmt.Sprintf("Parent %s ID for %s", labelVcfaOrg, labelVcfaRegionalNetworkingSetting),
},
"provider_gateway_id": {
Type: schema.TypeString,
Computed: true,
Description: fmt.Sprintf("Parent %s ID for %s", labelVcfaProviderGateway, labelVcfaRegionalNetworkingSetting),
},
"region_id": {
Type: schema.TypeString,
Computed: true,
Description: fmt.Sprintf("Parent %s ID for %s", labelVcfaRegion, labelVcfaRegionalNetworkingSetting),
},
"edge_cluster_id": {
Type: schema.TypeString,
Computed: true,
Description: fmt.Sprintf("Backing %s ID for %s. Will be autoselected if not specified.", labelVcfaEdgeCluster, labelVcfaRegionalNetworkingSetting),
},
"status": {
Type: schema.TypeString,
Computed: true,
Description: fmt.Sprintf("Status of %s", labelVcfaRegionalNetworkingSetting),
},
},
}
}

func datasourceVcfaOrgRegionalNetworkingRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
vcfaClient := meta.(*VCDClient)

getTmRegionalNetworkingSettingByName := func(name string) (*govcd.TmRegionalNetworkingSetting, error) {
return vcfaClient.GetTmRegionalNetworkingSettingByNameAndOrgId(name, d.Get("org_id").(string))
}

c := dsReadConfig[*govcd.TmRegionalNetworkingSetting, types.TmRegionalNetworkingSetting]{
entityLabel: labelVcfaRegionalNetworkingSetting,
getEntityFunc: getTmRegionalNetworkingSettingByName,
stateStoreFunc: setTmRegionalNetworkingSettingData,
}
return readDatasource(ctx, d, meta, c)
}
72 changes: 37 additions & 35 deletions vcfa/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,46 @@ func Resources(nameRegexp string, includeDeprecated bool) (map[string]*schema.Re
}

var globalDataSourceMap = map[string]*schema.Resource{
"vcfa_tm_version": datasourceVcfaTmVersion(), // 1.0
"vcfa_vcenter": datasourceVcfaVcenter(), // 1.0
"vcfa_org": datasourceVcfaOrg(), // 1.0
"vcfa_nsx_manager": datasourceVcfaNsxManager(), // 1.0
"vcfa_supervisor": datasourceVcfaSupervisor(), // 1.0
"vcfa_supervisor_zone": datasourceVcfaSupervisorZone(), // 1.0
"vcfa_region": datasourceVcfaRegion(), // 1.0
"vcfa_ip_space": datasourceVcfaIpSpace(), // 1.0
"vcfa_region_zone": datasourceVcfaRegionZone(), // 1.0
"vcfa_org_vdc": datasourceVcfaOrgVdc(), // 1.0
"vcfa_region_storage_policy": datasourceVcfaRegionStoragePolicy(), // 1.0
"vcfa_storage_class": datasourceVcfaStorageClass(), // 1.0
"vcfa_content_library": datasourceVcfaContentLibrary(), // 1.0
"vcfa_content_library_item": datasourceVcfaContentLibraryItem(), // 1.0
"vcfa_tier0_gateway": datasourceVcfaTier0Gateway(), // 1.0
"vcfa_provider_gateway": datasourceVcfaProviderGateway(), // 1.0
"vcfa_edge_cluster": datasourceVcfaEdgeCluster(), // 1.0
"vcfa_edge_cluster_qos": datasourceVcfaEdgeClusterQos(), // 1.0
"vcfa_org_oidc": datasourceVcfaOrgOidc(), // 1.0
"vcfa_org_networking": datasourceVcfaOrgNetworking(), // 1.0
"vcfa_right": datasourceVcfaRight(), // 1.0
"vcfa_rights_bundle": datasourceVcfaRightsBundle(), // 1.0
"vcfa_tm_version": datasourceVcfaTmVersion(), // 1.0
"vcfa_vcenter": datasourceVcfaVcenter(), // 1.0
"vcfa_org": datasourceVcfaOrg(), // 1.0
"vcfa_nsx_manager": datasourceVcfaNsxManager(), // 1.0
"vcfa_supervisor": datasourceVcfaSupervisor(), // 1.0
"vcfa_supervisor_zone": datasourceVcfaSupervisorZone(), // 1.0
"vcfa_region": datasourceVcfaRegion(), // 1.0
"vcfa_ip_space": datasourceVcfaIpSpace(), // 1.0
"vcfa_region_zone": datasourceVcfaRegionZone(), // 1.0
"vcfa_org_vdc": datasourceVcfaOrgVdc(), // 1.0
"vcfa_region_storage_policy": datasourceVcfaRegionStoragePolicy(), // 1.0
"vcfa_storage_class": datasourceVcfaStorageClass(), // 1.0
"vcfa_content_library": datasourceVcfaContentLibrary(), // 1.0
"vcfa_content_library_item": datasourceVcfaContentLibraryItem(), // 1.0
"vcfa_tier0_gateway": datasourceVcfaTier0Gateway(), // 1.0
"vcfa_provider_gateway": datasourceVcfaProviderGateway(), // 1.0
"vcfa_edge_cluster": datasourceVcfaEdgeCluster(), // 1.0
"vcfa_edge_cluster_qos": datasourceVcfaEdgeClusterQos(), // 1.0
"vcfa_org_networking": datasourceVcfaOrgNetworking(), // 1.0
"vcfa_org_regional_networking": datasourceVcfaOrgRegionalNetworking(), // 1.0
"vcfa_org_oidc": datasourceVcfaOrgOidc(), // 1.0
"vcfa_right": datasourceVcfaRight(), // 1.0
"vcfa_rights_bundle": datasourceVcfaRightsBundle(), // 1.0
}

var globalResourceMap = map[string]*schema.Resource{
"vcfa_vcenter": resourceVcfaVcenter(), // 1.0
"vcfa_org": resourceVcfaOrg(), // 1.0
"vcfa_nsx_manager": resourceVcfaNsxManager(), // 1.0
"vcfa_region": resourceVcfaRegion(), // 1.0
"vcfa_ip_space": resourceVcfaIpSpace(), // 1.0
"vcfa_org_vdc": resourceVcfaOrgVdc(), // 1.0
"vcfa_content_library": resourceVcfaContentLibrary(), // 1.0
"vcfa_content_library_item": resourceVcfaContentLibraryItem(), // 1.0
"vcfa_provider_gateway": resourceVcfaProviderGateway(), // 1.0
"vcfa_edge_cluster_qos": resourceVcfaEdgeClusterQos(), // 1.0
"vcfa_org_oidc": resourceVcfaOrgOidc(), // 1.0
"vcfa_org_networking": resourceVcfaOrgNetworking(), // 1.0
"vcfa_rights_bundle": resourceVcfaRightsBundle(), // 1.0
"vcfa_vcenter": resourceVcfaVcenter(), // 1.0
"vcfa_org": resourceVcfaOrg(), // 1.0
"vcfa_nsx_manager": resourceVcfaNsxManager(), // 1.0
"vcfa_region": resourceVcfaRegion(), // 1.0
"vcfa_ip_space": resourceVcfaIpSpace(), // 1.0
"vcfa_org_vdc": resourceVcfaOrgVdc(), // 1.0
"vcfa_content_library": resourceVcfaContentLibrary(), // 1.0
"vcfa_content_library_item": resourceVcfaContentLibraryItem(), // 1.0
"vcfa_provider_gateway": resourceVcfaProviderGateway(), // 1.0
"vcfa_edge_cluster_qos": resourceVcfaEdgeClusterQos(), // 1.0
"vcfa_org_networking": resourceVcfaOrgNetworking(), // 1.0
"vcfa_org_regional_networking": resourceVcfaOrgRegionalNetworking(), // 1.0
"vcfa_org_oidc": resourceVcfaOrgOidc(), // 1.0
"vcfa_rights_bundle": resourceVcfaRightsBundle(), // 1.0
}

// Provider returns a terraform.ResourceProvider.
Expand Down
28 changes: 28 additions & 0 deletions vcfa/remove_leftovers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ type entityList []entityDef
// doNotDelete contains a list of entities that should not be deleted,
// despite having a name that starts with `Test` or `test`
var doNotDelete = entityList{
{Type: "vcfa_org", Name: "System", Comment: "Built-in admin Org"},
{Type: "vcfa_org", Name: "tenant1", Comment: "tenant loaded with provisioning"},
{Type: "vcfa_org", Name: "system-classic-tenant", Comment: "tenant loaded with provisioning"},
{Type: "vcfa_org", Name: "tenant1classic", Comment: "classic tenant loaded with provisioning"},
}

Expand All @@ -43,13 +45,39 @@ var isTest = regexp.MustCompile(`^[Tt]est`)
var alwaysShow = []string{
"vcfa_vcenter",
"vcfa_org",
"vcfa_ip_space",
"vcfa_org_regional_networking",
"vcfa_edge_cluster_qos",
"vcfa_content_library",
"vcfa_region",
"vcfa_nsx_manager",
}

func removeLeftovers(govcdClient *govcd.VCDClient, verbose bool) error {
if verbose {
fmt.Printf("Start leftovers removal\n")
}

// --------------------------------------------------------------
// Org Regional Network Configuration
// --------------------------------------------------------------
if govcdClient.Client.IsSysAdmin {
all, err := govcdClient.GetAllTmRegionalNetworkingSettings(nil)
if err != nil {
return fmt.Errorf("error retrieving All Regional Networking Settings: %s", err)
}
for _, one := range all {
toBeDeleted := shouldDeleteEntity(alsoDelete, doNotDelete, one.TmRegionalNetworkingSetting.Name, "vcfa_org_regional_networking", 3, verbose)
if toBeDeleted {
fmt.Printf("\t REMOVING All %s Settings %s\n", labelVcfaRegionalNetworkingSetting, one.TmRegionalNetworkingSetting.Name)
err := one.Delete()
if err != nil {
return fmt.Errorf("error deleting %s Settings '%s': %s", labelVcfaRegionalNetworkingSetting, one.TmRegionalNetworkingSetting.Name, err)
}
}
}
}

// --------------------------------------------------------------
// Edge Cluster QoS (Edge Clusters themselves are read-only)
// --------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion vcfa/resource_vcfa_content_library_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func resourceVcfaContentLibraryItemImport(_ context.Context, d *schema.ResourceD

id := strings.Split(d.Id(), ImportSeparator)
if len(id) != 2 {
return nil, fmt.Errorf("ID syntax should be <%s name>%s<%s name>", labelVcfaContentLibrary, labelVcfaContentLibraryItem, ImportSeparator)
return nil, fmt.Errorf("ID syntax should be <%s name>%s<%s name>", labelVcfaContentLibrary, ImportSeparator, labelVcfaContentLibraryItem)
}

// TODO: TM: Tenant Context should not be nil and depend on the configured owner_org_id
Expand Down
Loading