Skip to content

Commit

Permalink
Merge pull request #485 from terraform-providers/f-data-source-firmware
Browse files Browse the repository at this point in the history
r/virtual_machine: Add `firmware` attribute to VM data source
  • Loading branch information
bill-rich authored Apr 24, 2018
2 parents 3be4437 + f6424c0 commit 2a1c2bf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions vsphere/data_source_vsphere_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func dataSourceVSphereVirtualMachine() *schema.Resource {
Description: "The guest ID of the virtual machine.",
Computed: true,
},
"firmware": {
Type: schema.TypeString,
Description: "The firmware type for this virtual machine.",
Computed: true,
},
"alternate_guest_name": {
Type: schema.TypeString,
Description: "The alternate guest name of the virtual machine when guest_id is a non-specific operating system, like otherGuest.",
Expand Down Expand Up @@ -108,6 +113,7 @@ func dataSourceVSphereVirtualMachineRead(d *schema.ResourceData, meta interface{
d.Set("guest_id", props.Config.GuestId)
d.Set("alternate_guest_name", props.Config.AlternateGuestName)
d.Set("scsi_type", virtualdevice.ReadSCSIBusState(object.VirtualDeviceList(props.Config.Hardware.Device), d.Get("scsi_controller_scan_count").(int)))
d.Set("firmware", props.Config.Firmware)
disks, err := virtualdevice.ReadDiskAttrsForDataSource(object.VirtualDeviceList(props.Config.Hardware.Device), d.Get("scsi_controller_scan_count").(int))
if err != nil {
return fmt.Errorf("error reading disk sizes: %s", err)
Expand Down
2 changes: 2 additions & 0 deletions vsphere/data_source_vsphere_virtual_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestAccDataSourceVSphereVirtualMachine_basic(t *testing.T) {
resource.TestCheckResourceAttrSet("data.vsphere_virtual_machine.template", "disks.0.eagerly_scrub"),
resource.TestCheckResourceAttrSet("data.vsphere_virtual_machine.template", "disks.0.thin_provisioned"),
resource.TestCheckResourceAttrSet("data.vsphere_virtual_machine.template", "network_interface_types.#"),
resource.TestCheckResourceAttrSet("data.vsphere_virtual_machine.template", "firmware"),
),
},
},
Expand Down Expand Up @@ -59,6 +60,7 @@ func TestAccDataSourceVSphereVirtualMachine_noDatacenterAndAbsolutePath(t *testi
resource.TestCheckResourceAttrSet("data.vsphere_virtual_machine.template", "disks.0.eagerly_scrub"),
resource.TestCheckResourceAttrSet("data.vsphere_virtual_machine.template", "disks.0.thin_provisioned"),
resource.TestCheckResourceAttrSet("data.vsphere_virtual_machine.template", "network_interface_types.#"),
resource.TestCheckResourceAttrSet("data.vsphere_virtual_machine.template", "firmware"),
),
},
},
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/virtual_machine.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ The following attributes are exported:
* `network_interface_types` - The network interface types for each network
interface found on the virtual machine, in device bus order. Will be one of
`e1000`, `e1000e`, `pcnet32`, `sriov`, `vmxnet2`, or `vmxnet3`.
* `firmware` - The firmware type for this virtual machine. Can be `bios` or `efi`.

~> **NOTE:** Keep in mind when using the results of `scsi_type` and
`network_interface_types`, that the `vsphere_virtual_machine` resource only
Expand Down

0 comments on commit 2a1c2bf

Please # to comment.