-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement host transport node profile data source
Signed-off-by: Kobi Samoray <[email protected]>
- Loading branch information
Showing
5 changed files
with
174 additions
and
67 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
nsxt/data_source_nsxt_policy_host_transport_node_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,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
41
nsxt/data_source_nsxt_policy_host_transport_node_profile_test.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,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) | ||
} |
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
31 changes: 31 additions & 0 deletions
31
website/docs/d/policy_host_transport_node_profile.html.markdown
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,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. |