Skip to content

Commit

Permalink
Implement host transport node profile data source
Browse files Browse the repository at this point in the history
Signed-off-by: Kobi Samoray <[email protected]>
  • Loading branch information
ksamoray committed Nov 17, 2023
1 parent 18e6e5a commit d488e26
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 67 deletions.
30 changes: 30 additions & 0 deletions nsxt/data_source_nsxt_policy_host_transport_node_profile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Copyright © 2023 VMware, Inc. All Rights Reserved.
SPDX-License-Identifier: MPL-2.0 */

package nsxt

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceNsxtPolicyHostTransportNodeProfile() *schema.Resource {
return &schema.Resource{
Read: dataSourceNsxtPolicyHostTransportNodeProfileRead,

Schema: map[string]*schema.Schema{
"id": getDataSourceIDSchema(),
"display_name": getDataSourceDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
},
}
}

func dataSourceNsxtPolicyHostTransportNodeProfileRead(d *schema.ResourceData, m interface{}) error {
_, err := policyDataSourceResourceRead(d, getPolicyConnector(m), getSessionContext(d, m), "PolicyHostTransportNodeProfile", nil)
if err != nil {
return err
}

return nil
}
41 changes: 41 additions & 0 deletions nsxt/data_source_nsxt_policy_host_transport_node_profile_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* Copyright © 2023 VMware, Inc. All Rights Reserved.
SPDX-License-Identifier: MPL-2.0 */

package nsxt

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccDataSourceNsxtPolicyHostTransportNodeProfile_basic(t *testing.T) {
htnpName := getHostTransportNodeProfileName()
testResourceName := "data.nsxt_policy_host_transport_node_profile.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
testAccOnlyLocalManager(t)
testAccPreCheck(t)
testAccEnvDefined(t, "NSXT_TEST_HOST_TRANSPORT_NODE_PROFILE")
},
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccNSXHostTransportNodeProfileReadTemplate(htnpName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(testResourceName, "display_name", htnpName),
resource.TestCheckResourceAttrSet(testResourceName, "id"),
),
},
},
})
}

func testAccNSXHostTransportNodeProfileReadTemplate(name string) string {
return fmt.Sprintf(`
data "nsxt_policy_host_transport_node_profile" "test" {
display_name = "%s"
}`, name)
}
135 changes: 68 additions & 67 deletions nsxt/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,73 +225,74 @@ func Provider() *schema.Provider {
},

DataSourcesMap: map[string]*schema.Resource{
"nsxt_provider_info": dataSourceNsxtProviderInfo(),
"nsxt_transport_zone": dataSourceNsxtTransportZone(),
"nsxt_switching_profile": dataSourceNsxtSwitchingProfile(),
"nsxt_logical_tier0_router": dataSourceNsxtLogicalTier0Router(),
"nsxt_logical_tier1_router": dataSourceNsxtLogicalTier1Router(),
"nsxt_mac_pool": dataSourceNsxtMacPool(),
"nsxt_ns_group": dataSourceNsxtNsGroup(),
"nsxt_ns_groups": dataSourceNsxtNsGroups(),
"nsxt_ns_service": dataSourceNsxtNsService(),
"nsxt_ns_services": dataSourceNsxtNsServices(),
"nsxt_edge_cluster": dataSourceNsxtEdgeCluster(),
"nsxt_certificate": dataSourceNsxtCertificate(),
"nsxt_ip_pool": dataSourceNsxtIPPool(),
"nsxt_firewall_section": dataSourceNsxtFirewallSection(),
"nsxt_management_cluster": dataSourceNsxtManagementCluster(),
"nsxt_policy_edge_cluster": dataSourceNsxtPolicyEdgeCluster(),
"nsxt_policy_edge_node": dataSourceNsxtPolicyEdgeNode(),
"nsxt_policy_tier0_gateway": dataSourceNsxtPolicyTier0Gateway(),
"nsxt_policy_tier1_gateway": dataSourceNsxtPolicyTier1Gateway(),
"nsxt_policy_service": dataSourceNsxtPolicyService(),
"nsxt_policy_realization_info": dataSourceNsxtPolicyRealizationInfo(),
"nsxt_policy_segment_realization": dataSourceNsxtPolicySegmentRealization(),
"nsxt_policy_transport_zone": dataSourceNsxtPolicyTransportZone(),
"nsxt_policy_ip_discovery_profile": dataSourceNsxtPolicyIPDiscoveryProfile(),
"nsxt_policy_spoofguard_profile": dataSourceNsxtPolicySpoofGuardProfile(),
"nsxt_policy_qos_profile": dataSourceNsxtPolicyQosProfile(),
"nsxt_policy_ipv6_ndra_profile": dataSourceNsxtPolicyIpv6NdraProfile(),
"nsxt_policy_ipv6_dad_profile": dataSourceNsxtPolicyIpv6DadProfile(),
"nsxt_policy_gateway_qos_profile": dataSourceNsxtPolicyGatewayQosProfile(),
"nsxt_policy_segment_security_profile": dataSourceNsxtPolicySegmentSecurityProfile(),
"nsxt_policy_mac_discovery_profile": dataSourceNsxtPolicyMacDiscoveryProfile(),
"nsxt_policy_vm": dataSourceNsxtPolicyVM(),
"nsxt_policy_vms": dataSourceNsxtPolicyVMs(),
"nsxt_policy_lb_app_profile": dataSourceNsxtPolicyLBAppProfile(),
"nsxt_policy_lb_client_ssl_profile": dataSourceNsxtPolicyLBClientSslProfile(),
"nsxt_policy_lb_server_ssl_profile": dataSourceNsxtPolicyLBServerSslProfile(),
"nsxt_policy_lb_monitor": dataSourceNsxtPolicyLBMonitor(),
"nsxt_policy_certificate": dataSourceNsxtPolicyCertificate(),
"nsxt_policy_lb_persistence_profile": dataSourceNsxtPolicyLbPersistenceProfile(),
"nsxt_policy_vni_pool": dataSourceNsxtPolicyVniPool(),
"nsxt_policy_ip_block": dataSourceNsxtPolicyIPBlock(),
"nsxt_policy_ip_pool": dataSourceNsxtPolicyIPPool(),
"nsxt_policy_site": dataSourceNsxtPolicySite(),
"nsxt_policy_gateway_policy": dataSourceNsxtPolicyGatewayPolicy(),
"nsxt_policy_security_policy": dataSourceNsxtPolicySecurityPolicy(),
"nsxt_policy_group": dataSourceNsxtPolicyGroup(),
"nsxt_policy_context_profile": dataSourceNsxtPolicyContextProfile(),
"nsxt_policy_dhcp_server": dataSourceNsxtPolicyDhcpServer(),
"nsxt_policy_bfd_profile": dataSourceNsxtPolicyBfdProfile(),
"nsxt_policy_intrusion_service_profile": dataSourceNsxtPolicyIntrusionServiceProfile(),
"nsxt_policy_lb_service": dataSourceNsxtPolicyLbService(),
"nsxt_policy_gateway_locale_service": dataSourceNsxtPolicyGatewayLocaleService(),
"nsxt_policy_bridge_profile": dataSourceNsxtPolicyBridgeProfile(),
"nsxt_policy_ipsec_vpn_local_endpoint": dataSourceNsxtPolicyIPSecVpnLocalEndpoint(),
"nsxt_policy_ipsec_vpn_service": dataSourceNsxtPolicyIPSecVpnService(),
"nsxt_policy_l2_vpn_service": dataSourceNsxtPolicyL2VpnService(),
"nsxt_policy_segment": dataSourceNsxtPolicySegment(),
"nsxt_policy_project": dataSourceNsxtPolicyProject(),
"nsxt_policy_gateway_prefix_list": dataSourceNsxtPolicyGatewayPrefixList(),
"nsxt_policy_gateway_route_map": dataSourceNsxtPolicyGatewayRouteMap(),
"nsxt_policy_uplink_host_switch_profile": dataSourceNsxtUplinkHostSwitchProfile(),
"nsxt_compute_manager": dataSourceNsxtComputeManager(),
"nsxt_transport_node_realization": dataSourceNsxtTransportNodeRealization(),
"nsxt_failure_domain": dataSourceNsxtFailureDomain(),
"nsxt_compute_collection": dataSourceNsxtComputeCollection(),
"nsxt_compute_manager_realization": dataSourceNsxtComputeManagerRealization(),
"nsxt_policy_host_transport_node": dataSourceNsxtPolicyHostTransportNode(),
"nsxt_provider_info": dataSourceNsxtProviderInfo(),
"nsxt_transport_zone": dataSourceNsxtTransportZone(),
"nsxt_switching_profile": dataSourceNsxtSwitchingProfile(),
"nsxt_logical_tier0_router": dataSourceNsxtLogicalTier0Router(),
"nsxt_logical_tier1_router": dataSourceNsxtLogicalTier1Router(),
"nsxt_mac_pool": dataSourceNsxtMacPool(),
"nsxt_ns_group": dataSourceNsxtNsGroup(),
"nsxt_ns_groups": dataSourceNsxtNsGroups(),
"nsxt_ns_service": dataSourceNsxtNsService(),
"nsxt_ns_services": dataSourceNsxtNsServices(),
"nsxt_edge_cluster": dataSourceNsxtEdgeCluster(),
"nsxt_certificate": dataSourceNsxtCertificate(),
"nsxt_ip_pool": dataSourceNsxtIPPool(),
"nsxt_firewall_section": dataSourceNsxtFirewallSection(),
"nsxt_management_cluster": dataSourceNsxtManagementCluster(),
"nsxt_policy_edge_cluster": dataSourceNsxtPolicyEdgeCluster(),
"nsxt_policy_edge_node": dataSourceNsxtPolicyEdgeNode(),
"nsxt_policy_tier0_gateway": dataSourceNsxtPolicyTier0Gateway(),
"nsxt_policy_tier1_gateway": dataSourceNsxtPolicyTier1Gateway(),
"nsxt_policy_service": dataSourceNsxtPolicyService(),
"nsxt_policy_realization_info": dataSourceNsxtPolicyRealizationInfo(),
"nsxt_policy_segment_realization": dataSourceNsxtPolicySegmentRealization(),
"nsxt_policy_transport_zone": dataSourceNsxtPolicyTransportZone(),
"nsxt_policy_ip_discovery_profile": dataSourceNsxtPolicyIPDiscoveryProfile(),
"nsxt_policy_spoofguard_profile": dataSourceNsxtPolicySpoofGuardProfile(),
"nsxt_policy_qos_profile": dataSourceNsxtPolicyQosProfile(),
"nsxt_policy_ipv6_ndra_profile": dataSourceNsxtPolicyIpv6NdraProfile(),
"nsxt_policy_ipv6_dad_profile": dataSourceNsxtPolicyIpv6DadProfile(),
"nsxt_policy_gateway_qos_profile": dataSourceNsxtPolicyGatewayQosProfile(),
"nsxt_policy_segment_security_profile": dataSourceNsxtPolicySegmentSecurityProfile(),
"nsxt_policy_mac_discovery_profile": dataSourceNsxtPolicyMacDiscoveryProfile(),
"nsxt_policy_vm": dataSourceNsxtPolicyVM(),
"nsxt_policy_vms": dataSourceNsxtPolicyVMs(),
"nsxt_policy_lb_app_profile": dataSourceNsxtPolicyLBAppProfile(),
"nsxt_policy_lb_client_ssl_profile": dataSourceNsxtPolicyLBClientSslProfile(),
"nsxt_policy_lb_server_ssl_profile": dataSourceNsxtPolicyLBServerSslProfile(),
"nsxt_policy_lb_monitor": dataSourceNsxtPolicyLBMonitor(),
"nsxt_policy_certificate": dataSourceNsxtPolicyCertificate(),
"nsxt_policy_lb_persistence_profile": dataSourceNsxtPolicyLbPersistenceProfile(),
"nsxt_policy_vni_pool": dataSourceNsxtPolicyVniPool(),
"nsxt_policy_ip_block": dataSourceNsxtPolicyIPBlock(),
"nsxt_policy_ip_pool": dataSourceNsxtPolicyIPPool(),
"nsxt_policy_site": dataSourceNsxtPolicySite(),
"nsxt_policy_gateway_policy": dataSourceNsxtPolicyGatewayPolicy(),
"nsxt_policy_security_policy": dataSourceNsxtPolicySecurityPolicy(),
"nsxt_policy_group": dataSourceNsxtPolicyGroup(),
"nsxt_policy_context_profile": dataSourceNsxtPolicyContextProfile(),
"nsxt_policy_dhcp_server": dataSourceNsxtPolicyDhcpServer(),
"nsxt_policy_bfd_profile": dataSourceNsxtPolicyBfdProfile(),
"nsxt_policy_intrusion_service_profile": dataSourceNsxtPolicyIntrusionServiceProfile(),
"nsxt_policy_lb_service": dataSourceNsxtPolicyLbService(),
"nsxt_policy_gateway_locale_service": dataSourceNsxtPolicyGatewayLocaleService(),
"nsxt_policy_bridge_profile": dataSourceNsxtPolicyBridgeProfile(),
"nsxt_policy_ipsec_vpn_local_endpoint": dataSourceNsxtPolicyIPSecVpnLocalEndpoint(),
"nsxt_policy_ipsec_vpn_service": dataSourceNsxtPolicyIPSecVpnService(),
"nsxt_policy_l2_vpn_service": dataSourceNsxtPolicyL2VpnService(),
"nsxt_policy_segment": dataSourceNsxtPolicySegment(),
"nsxt_policy_project": dataSourceNsxtPolicyProject(),
"nsxt_policy_gateway_prefix_list": dataSourceNsxtPolicyGatewayPrefixList(),
"nsxt_policy_gateway_route_map": dataSourceNsxtPolicyGatewayRouteMap(),
"nsxt_policy_uplink_host_switch_profile": dataSourceNsxtUplinkHostSwitchProfile(),
"nsxt_compute_manager": dataSourceNsxtComputeManager(),
"nsxt_transport_node_realization": dataSourceNsxtTransportNodeRealization(),
"nsxt_failure_domain": dataSourceNsxtFailureDomain(),
"nsxt_compute_collection": dataSourceNsxtComputeCollection(),
"nsxt_compute_manager_realization": dataSourceNsxtComputeManagerRealization(),
"nsxt_policy_host_transport_node": dataSourceNsxtPolicyHostTransportNode(),
"nsxt_policy_host_transport_node_profile": dataSourceNsxtPolicyHostTransportNodeProfile(),
},

ResourcesMap: map[string]*schema.Resource{
Expand Down
4 changes: 4 additions & 0 deletions nsxt/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ func getHostTransportNodeName() string {
return os.Getenv("NSXT_TEST_HOST_TRANSPORT_NODE")
}

func getHostTransportNodeProfileName() string {
return os.Getenv("NSXT_TEST_HOST_TRANSPORT_NODE_PROFILE")
}

func getVlanTransportZoneName() string {
name := os.Getenv("NSXT_TEST_VLAN_TRANSPORT_ZONE")
if name == "" {
Expand Down
31 changes: 31 additions & 0 deletions website/docs/d/policy_host_transport_node_profile.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
subcategory: "Beta"
layout: "nsxt"
page_title: "NSXT: nsxt_policy_host_transport_node_profile"
description: A host transport node profile data source.
---

# nsxt_policy_host_transport_node_profile

This data source provides information about host transport node profiles configured on NSX.
This data source is applicable to NSX Policy Manager.

## Example Usage

```hcl
data "nsxt_policy_host_transport_node_profile" "host_transport_node_profile" {
display_name = "host_transport_node_profile1"
}
```

## Argument Reference

* `id` - (Optional) The ID of host transport node profile to retrieve.
* `display_name` - (Optional) The Display Name prefix of the host transport node profile to retrieve.

## Attributes Reference

In addition to arguments listed above, the following attributes are exported:

* `description` - The description of the resource.
* `path` - The NSX path of the policy resource.

0 comments on commit d488e26

Please sign in to comment.