Skip to content

Commit

Permalink
Merge pull request #1470 from evenh/ds-policy-vm-tags
Browse files Browse the repository at this point in the history
data.nsxt_policy_vm: exports tags
  • Loading branch information
annakhm authored Dec 11, 2024
2 parents e126f93 + 42fcd84 commit 556be59
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions nsxt/data_source_nsxt_policy_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func dataSourceNsxtPolicyVM() *schema.Resource {
"external_id": getDataSourceStringSchema("External ID of the Virtual Machine"),
"bios_id": getDataSourceStringSchema("BIOS UUID of the Virtual Machine"),
"instance_id": getDataSourceStringSchema("Instance UUID of the Virtual Machine"),
"tag": getTagsSchema(),
"context": getContextSchema(false, false, false),
},
}
Expand All @@ -47,6 +48,7 @@ func dataSourceNsxtPolicyVMIDRead(d *schema.ResourceData, m interface{}) error {

objID := getNsxtPolicyVMIDFromSchema(d)
context := getSessionContext(d, m)

if objID != "" {
vmObj, err := findNsxtPolicyVMByID(context, connector, objID, m)
if err != nil {
Expand Down Expand Up @@ -85,5 +87,7 @@ func dataSourceNsxtPolicyVMIDRead(d *schema.ResourceData, m interface{}) error {
d.Set("external_id", *vmModel.ExternalId)
d.Set("bios_id", computeIDMap[nsxtPolicyBiosUUIDKey])
d.Set("instance_id", computeIDMap[nsxtPolicyInstanceUUIDKey])
setPolicyTagsInSchema(d, vmModel.Tags)

return nil
}
2 changes: 2 additions & 0 deletions nsxt/data_source_nsxt_policy_vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func testAccDataSourceNsxtPolicyVMBasic(t *testing.T, withContext bool, preCheck
resource.TestCheckResourceAttrSet(testResourceName, "bios_id"),
resource.TestCheckResourceAttrSet(testResourceName, "external_id"),
resource.TestCheckResourceAttrSet(testResourceName, "instance_id"),
resource.TestCheckResourceAttrSet(testResourceName, "tag.#"),
),
},
{
Expand All @@ -52,6 +53,7 @@ func testAccDataSourceNsxtPolicyVMBasic(t *testing.T, withContext bool, preCheck
resource.TestCheckResourceAttrSet(testResourceName, "bios_id"),
resource.TestCheckResourceAttrSet(testResourceName, "external_id"),
resource.TestCheckResourceAttrSet(testResourceName, "instance_id"),
resource.TestCheckResourceAttrSet(testResourceName, "tag.#"),
),
},
},
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/policy_vm.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ data "nsxt_policy_vm" "nsxt_vm1" {
In addition to arguments listed above, the following attributes are exported:

* `description` - The description of the Virtual Machine.
* `tag` - A list of scope + tag pairs associated with this Virtual Machine.

0 comments on commit 556be59

Please sign in to comment.