forked from vmware/terraform-provider-vcd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NSX-T Segment Profile Template support (vmware#1120)
- Loading branch information
Showing
43 changed files
with
4,064 additions
and
281 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 @@ | ||
* Resource `vcd_org_vdc` deprecates `edge_cluster_id` in favor of new resource | ||
`vcd_org_vdc_nsxt_network_profile` that can configure NSX-T Edge Clusters and default Segment | ||
Profile Templates for NSX-T VDCs [GH-1120] |
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,13 @@ | ||
* **New Data Source:** `vcd_nsxt_segment_ip_discovery_profile` to read NSX-T IP Discovery Segment Profiles [GH-1120] | ||
* **New Data Source:** `vcd_nsxt_segment_mac_discovery_profile` to read NSX-T MAC Discovery Segment Profiles [GH-1120] | ||
* **New Data Source:** `vcd_nsxt_segment_spoof_guard_profile` to read NSX-T Spoof Guard Profiles [GH-1120] | ||
* **New Data Source:** `vcd_nsxt_segment_qos_profile` to read NSX-T QoS Profiles [GH-1120] | ||
* **New Data Source:** `vcd_nsxt_segment_security_profile` to read NSX-T Segment Security Profiles [GH-1120] | ||
* **New Resource:** `vcd_nsxt_segment_profile_template` to manage NSX-T Segment Profile Templates [GH-1120] | ||
* **New Data Source:** `vcd_nsxt_segment_profile_template` to read NSX-T Segment Profile Templates [GH-1120] | ||
* **New Resource:** `vcd_nsxt_global_default_segment_profile_template` to manage NSX-T Global Default Segment Profile Templates [GH-1120] | ||
* **New Data Source:** `vcd_nsxt_global_default_segment_profile_template` to read NSX-T Global Default Segment Profile Templates [GH-1120] | ||
* **New Resource:** `vcd_org_vdc_nsxt_network_profile` to manage default Segment Profile Templates for NSX-T VDCs [GH-1120] | ||
* **New Data Source:** `vcd_org_vdc_nsxt_network_profile` to read default Segment Profile Templates for NSX-T VDCs [GH-1120] | ||
* **New Resource:** `vcd_nsxt_network_segment_profile` to manage individual Segment Profiles or Segment Profile Templates for NSX-T Org VDC Networks [GH-1120] | ||
* **New Data Source:** `vcd_nsxt_network_segment_profile` to read individual Segment Profiles or Segment Profile Templates for NSX-T Org VDC Networks [GH-1120] |
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
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
23 changes: 23 additions & 0 deletions
23
vcd/datasource_vcd_nsxt_global_default_segment_profile_template.go
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,23 @@ | ||
package vcd | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func datasourceVcdGlobalDefaultSegmentProfileTemplate() *schema.Resource { | ||
return &schema.Resource{ | ||
ReadContext: resourceDataSourceVcdGlobalDefaultSegmentProfileTemplateRead, | ||
Schema: map[string]*schema.Schema{ | ||
"vdc_networks_default_segment_profile_template_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "Global default NSX-T Segment Profile for Org VDC networks", | ||
}, | ||
"vapp_networks_default_segment_profile_template_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "Global default NSX-T Segment Profile for vApp networks", | ||
}, | ||
}, | ||
} | ||
} |
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,69 @@ | ||
package vcd | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func datasourceVcdNsxtOrgVdcNetworkSegmentProfileTemplate() *schema.Resource { | ||
return &schema.Resource{ | ||
ReadContext: dataSourceVcdNsxtOrgVdcNetworkSegmentProfileRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"org": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ForceNew: true, | ||
Description: "The name of organization to use, optional if defined at provider " + | ||
"level. Useful when connected as sysadmin working across different organizations", | ||
}, | ||
"org_network_id": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "ID of the Organization Network that uses the Segment Profile Template", | ||
}, | ||
"segment_profile_template_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "Segment Profile Template ID", | ||
}, | ||
"segment_profile_template_name": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "Segment Profile Template Name", | ||
}, | ||
// Individual Segment Profiles | ||
"ip_discovery_profile_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "NSX-T IP Discovery Profile", | ||
}, | ||
"mac_discovery_profile_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "NSX-T Mac Discovery Profile", | ||
}, | ||
"spoof_guard_profile_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "NSX-T Spoof Guard Profile", | ||
}, | ||
"qos_profile_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "NSX-T QoS Profile", | ||
}, | ||
"segment_security_profile_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "NSX-T Segment Security Profile", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceVcdNsxtOrgVdcNetworkSegmentProfileRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { | ||
return resourceDataSourceVcdNsxtOrgVdcNetworkSegmentProfileRead(ctx, d, meta, "datasource") | ||
} |
152 changes: 152 additions & 0 deletions
152
vcd/datasource_vcd_nsxt_segment_ip_discovery_profile.go
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,152 @@ | ||
package vcd | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/url" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func datasourceVcdNsxtSegmentIpDiscoveryProfile() *schema.Resource { | ||
return &schema.Resource{ | ||
ReadContext: datasourceNsxtSegmentIpDiscoveryProfileRead, | ||
Schema: map[string]*schema.Schema{ | ||
"name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "Name of Segment IP Discovery Profile", | ||
}, | ||
"nsxt_manager_id": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ExactlyOneOf: []string{"nsxt_manager_id", "vdc_id", "vdc_group_id"}, | ||
Description: "ID of NSX-T Manager", | ||
}, | ||
"vdc_id": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ExactlyOneOf: []string{"nsxt_manager_id", "vdc_id", "vdc_group_id"}, | ||
Description: "ID of VDC", | ||
}, | ||
"vdc_group_id": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ExactlyOneOf: []string{"nsxt_manager_id", "vdc_id", "vdc_group_id"}, | ||
Description: "ID of VDC Group", | ||
}, | ||
"description": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "Description of Segment IP Discovery Profile", | ||
}, | ||
"arp_binding_limit": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
Description: "Indicates the number of ARP snooped IP addresses to be remembered per logical port", | ||
}, | ||
"arp_binding_timeout": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
Description: "Indicates ARP and ND cache timeout (in minutes)", | ||
}, | ||
"is_arp_snooping_enabled": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
Description: "Defines whether ARP snooping is enabled", | ||
}, | ||
"is_dhcp_snooping_v4_enabled": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
Description: "Defines whether DHCP snooping for IPv4 is enabled", | ||
}, | ||
"is_dhcp_snooping_v6_enabled": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
Description: "Defines whether DHCP snooping for IPv6 is enabled", | ||
}, | ||
"is_duplicate_ip_detection_enabled": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
Description: "Indicates whether duplicate IP detection is enabled", | ||
}, | ||
"is_nd_snooping_enabled": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
Description: "Indicates whether neighbor discovery (ND) snooping is enabled", | ||
}, | ||
"is_tofu_enabled": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
Description: "Defines whether 'Trust on First Use (TOFU)' paradigm is enabled", | ||
}, | ||
"is_vmtools_v4_enabled": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
Description: "Indicates whether fetching IPv4 address using vm-tools is enabled", | ||
}, | ||
"is_vmtools_v6_enabled": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
Description: "Indicates whether fetching IPv6 address using vm-tools is enabled", | ||
}, | ||
"nd_snooping_limit": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
Description: "Maximum number of Neighbor Discovery (ND) snooped IPv6 addresses", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func datasourceNsxtSegmentIpDiscoveryProfileRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { | ||
vcdClient := meta.(*VCDClient) | ||
profileName := d.Get("name").(string) | ||
|
||
contextFilterField, contextUrn, err := getContextFilterField(d) | ||
if err != nil { | ||
return diag.FromErr(err) | ||
} | ||
|
||
queryFilter := url.Values{} | ||
queryFilter.Add("filter", fmt.Sprintf("%s==%s", contextFilterField, contextUrn)) | ||
|
||
ipDiscoveryProfile, err := vcdClient.GetIpDiscoveryProfileByName(profileName, queryFilter) | ||
if err != nil { | ||
return diag.Errorf("could not find IP Discovery Profile by name '%s': %s", profileName, err) | ||
} | ||
|
||
dSet(d, "description", ipDiscoveryProfile.Description) | ||
dSet(d, "arp_binding_limit", ipDiscoveryProfile.ArpBindingLimit) | ||
dSet(d, "arp_binding_timeout", ipDiscoveryProfile.ArpNdBindingTimeout) | ||
dSet(d, "is_arp_snooping_enabled", ipDiscoveryProfile.IsArpSnoopingEnabled) | ||
dSet(d, "is_dhcp_snooping_v4_enabled", ipDiscoveryProfile.IsDhcpSnoopingV4Enabled) | ||
dSet(d, "is_dhcp_snooping_v6_enabled", ipDiscoveryProfile.IsDhcpSnoopingV6Enabled) | ||
dSet(d, "is_duplicate_ip_detection_enabled", ipDiscoveryProfile.IsDuplicateIPDetectionEnabled) | ||
dSet(d, "is_nd_snooping_enabled", ipDiscoveryProfile.IsNdSnoopingEnabled) | ||
dSet(d, "is_tofu_enabled", ipDiscoveryProfile.IsTofuEnabled) | ||
dSet(d, "is_vmtools_v4_enabled", ipDiscoveryProfile.IsVMToolsV4Enabled) | ||
dSet(d, "is_vmtools_v6_enabled", ipDiscoveryProfile.IsVMToolsV6Enabled) | ||
dSet(d, "nd_snooping_limit", ipDiscoveryProfile.NdSnoopingLimit) | ||
|
||
d.SetId(ipDiscoveryProfile.ID) | ||
|
||
return nil | ||
} | ||
|
||
// getContextFilterField determines which field should be used for filtering | ||
func getContextFilterField(d *schema.ResourceData) (string, string, error) { | ||
switch { | ||
case d.Get("nsxt_manager_id").(string) != "": | ||
return "nsxTManagerRef.id", d.Get("nsxt_manager_id").(string), nil | ||
case d.Get("vdc_id").(string) != "": | ||
return "orgVdcId", d.Get("vdc_id").(string), nil | ||
case d.Get("vdc_group_id").(string) != "": | ||
return "vdcGroupId", d.Get("vdc_group_id").(string), nil | ||
|
||
} | ||
|
||
return "", "", fmt.Errorf("unknown filtering field") | ||
} |
Oops, something went wrong.