-
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.
Merge pull request #1201 from ksamoray/ds-nsx-version
Manager info data source
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 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,37 @@ | ||
/* Copyright © 2024 Broadcom, Inc. All Rights Reserved. | ||
SPDX-License-Identifier: MPL-2.0 */ | ||
|
||
package nsxt | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
const nsxVersionID = "nsxversion" | ||
|
||
func dataSourceNsxtManagerInfo() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceNsxtManagerInfoRead, | ||
Schema: map[string]*schema.Schema{ | ||
"version": { | ||
Type: schema.TypeString, | ||
Description: "Version of NSXT manager", | ||
Computed: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceNsxtManagerInfoRead(d *schema.ResourceData, m interface{}) error { | ||
connector := getPolicyConnector(m) | ||
version, err := getNSXVersion(connector) | ||
if err != nil { | ||
return fmt.Errorf("failed to retrieve NSX version: %v", err) | ||
} | ||
d.Set("version", version) | ||
d.SetId(nsxVersionID) | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* Copyright © 2024 Broadcom, Inc. All Rights Reserved. | ||
SPDX-License-Identifier: MPL-2.0 */ | ||
|
||
package nsxt | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccDataSourceNsxtManagerInfo_basic(t *testing.T) { | ||
testResourceName := "data.nsxt_manager_info.test" | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: ` | ||
data "nsxt_manager_info" "test" { | ||
}`, | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(testResourceName, "version"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} |
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,20 @@ | ||
--- | ||
subcategory: "Manager" | ||
layout: "nsxt" | ||
page_title: "nsxt_manager_info" | ||
description: A NSX-T manager information data source. | ||
--- | ||
|
||
# nsxt_manager_info | ||
|
||
This data source provides various information about the NSX-T manager. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
data "nsxt_manager_info" "cluster" {} | ||
``` | ||
|
||
## Attributes Reference | ||
|
||
* `version` - The software version of the NSX-T manager node. |