Skip to content

Commit

Permalink
Merge pull request #41 from cisco-open/hh-vm-props
Browse files Browse the repository at this point in the history
Support Name and Description fields for Inventory VMs
  • Loading branch information
hughwphamill authored Dec 3, 2024
2 parents 27b52e0 + eb93575 commit fb37c7f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ This Terraform provider allows you to manage Topologies, Networks, VMs, and Hard
```sh
$ go install
```
1. Install the provider locally for Terraform using the Makefile:
```sh
$ make install
```

## Using the provider

Expand Down
2 changes: 2 additions & 0 deletions docs/data-sources/inventory_vms.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ Read-Only:

- `cpu_qty` (Number)
- `datacenter` (String)
- `description` (String)
- `id` (String)
- `memory_mb` (Number)
- `name` (String)
- `network_interfaces` (List of Object) (see [below for nested schema](#nestedobjatt--inventory_vms--network_interfaces))
- `original_description` (String)
- `original_name` (String)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/cisco-open/terraform-provider-dcloud
go 1.18

require (
github.com/cisco-open/dcloud-tb-go-client v1.0.4
github.com/cisco-open/dcloud-tb-go-client v1.0.5
github.com/hashicorp/terraform-plugin-docs v0.13.0
github.com/hashicorp/terraform-plugin-log v0.7.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgI
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/cisco-open/dcloud-tb-go-client v1.0.4 h1:RPi+7DWf7dqaGQYY12ttF7ljCDH4PfpEA1wKC67FRkc=
github.com/cisco-open/dcloud-tb-go-client v1.0.4/go.mod h1:nswounfrrUZqPfRZ4fF1BpmnTXcJIM37RaSGUNbZlpg=
github.com/cisco-open/dcloud-tb-go-client v1.0.5 h1:01q4gzNfEMUXFCUV6zbYsrLkfkGY+WielACnCPAbIJc=
github.com/cisco-open/dcloud-tb-go-client v1.0.5/go.mod h1:nswounfrrUZqPfRZ4fF1BpmnTXcJIM37RaSGUNbZlpg=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down
20 changes: 20 additions & 0 deletions internal/dcloud/data_source_inventory_vms.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ func dataSourceInventoryVms() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"description": {
Type: schema.TypeString,
Computed: true,
},
"original_name": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -146,6 +154,18 @@ func convertInventoryVmToDataResource(inventoryVm tbclient.InventoryVm) map[stri
resource["cpu_qty"] = inventoryVm.CpuQty
resource["memory_mb"] = inventoryVm.MemoryMb

name := inventoryVm.Name
if name == "" {
name = inventoryVm.OriginalName
}
resource["name"] = name

description := inventoryVm.Description
if description == "" {
description = inventoryVm.OriginalDescription
}
resource["description"] = description

if remoteAccess := inventoryVm.RemoteAccess; remoteAccess != nil {
resource["remote_access_rdp_auto_login"] = remoteAccess.RdpAutoLogin
resource["remote_access_rdp_enabled"] = remoteAccess.RdpAutoLogin
Expand Down

0 comments on commit fb37c7f

Please sign in to comment.