-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
785 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* **New Resource:** `vcd_tm_provider_gateway` to manage TM Provider Gateways [GH-1361] | ||
* **New Data Source:** `vcd_tm_provider_gateway` to read IP Spaces [GH-1361] | ||
* **New Data Source:** `vcd_tm_tier0_gateway` to read available Tier 0 Gateways in NSX-T [GH-1361] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package vcd | ||
|
||
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 datasourceVcdTmProviderGateway() *schema.Resource { | ||
return &schema.Resource{ | ||
ReadContext: datasourceVcdTmProviderGatewayRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: fmt.Sprintf("Name of %s", labelTmProviderGateway), | ||
}, | ||
"region_id": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: fmt.Sprintf("Parent %s of %s", labelTmRegion, labelTmProviderGateway), | ||
}, | ||
"description": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: fmt.Sprintf("Description of %s", labelTmProviderGateway), | ||
}, | ||
"nsxt_tier0_gateway_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: fmt.Sprintf("Parent %s of %s", labelTmTier0Gateway, labelTmProviderGateway), | ||
}, | ||
"ip_space_ids": { | ||
Type: schema.TypeSet, | ||
Computed: true, | ||
Description: fmt.Sprintf("A set of supervisor IDs used in this %s", labelTmRegion), | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
}, | ||
}, | ||
"status": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: fmt.Sprintf("Status of %s", labelTmProviderGateway), | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func datasourceVcdTmProviderGatewayRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { | ||
vcdClient := meta.(*VCDClient) | ||
getProviderGateway := func(name string) (*govcd.TmProviderGateway, error) { | ||
return vcdClient.GetTmProviderGatewayByNameAndRegionId(name, d.Get("region_id").(string)) | ||
} | ||
c := dsReadConfig[*govcd.TmProviderGateway, types.TmProviderGateway]{ | ||
entityLabel: labelTmProviderGateway, | ||
getEntityFunc: getProviderGateway, | ||
stateStoreFunc: setTmProviderGatewayData, | ||
} | ||
return readDatasource(ctx, d, meta, c) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package vcd | ||
|
||
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" | ||
) | ||
|
||
const labelTmTier0Gateway = "TM Tier 0 Gateway" | ||
|
||
func datasourceVcdTmTier0Gateway() *schema.Resource { | ||
return &schema.Resource{ | ||
ReadContext: datasourceVcdTmTier0GatewayRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: fmt.Sprintf("Display Name of %s", labelTmTier0Gateway), | ||
}, | ||
"region_id": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: fmt.Sprintf("Parent %s ID", labelTmRegion), | ||
}, | ||
"description": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: fmt.Sprintf("Description of %s", labelTmTier0Gateway), | ||
}, | ||
"parent_tier_0_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: fmt.Sprintf("Parent Tier 0 Gateway of %s", labelTmTier0Gateway), | ||
}, | ||
"already_imported": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
Description: fmt.Sprintf("Defines if the T0 is already imported of %s", labelTmTier0Gateway), | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func datasourceVcdTmTier0GatewayRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { | ||
vcdClient := meta.(*VCDClient) | ||
getT0ByName := func(name string) (*govcd.TmTier0Gateway, error) { | ||
return vcdClient.GetTmTier0GatewayWithContextByName(name, d.Get("region_id").(string), true) | ||
} | ||
|
||
c := dsReadConfig[*govcd.TmTier0Gateway, types.TmTier0Gateway]{ | ||
entityLabel: labelTmTier0Gateway, | ||
getEntityFunc: getT0ByName, | ||
stateStoreFunc: setTmTier0GatewayData, | ||
} | ||
return readDatasource(ctx, d, meta, c) | ||
} | ||
|
||
func setTmTier0GatewayData(_ *VCDClient, d *schema.ResourceData, t *govcd.TmTier0Gateway) error { | ||
d.SetId(t.TmTier0Gateway.ID) // So far the API returns plain UUID (not URN) | ||
dSet(d, "name", t.TmTier0Gateway.DisplayName) | ||
dSet(d, "description", t.TmTier0Gateway.Description) | ||
dSet(d, "parent_tier_0_id", t.TmTier0Gateway.ParentTier0ID) | ||
dSet(d, "already_imported", t.TmTier0Gateway.AlreadyImported) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.