GetVirtualMachine

The vsphere..VirtualMachine data source can be used to find the UUID of an existing virtual machine or template. Its most relevant purpose is for finding the UUID of a template to be used as the source for cloning into a new vsphere..VirtualMachine resource. It also reads the guest ID so that can be supplied as well.

Example Usage

using Pulumi;
using VSphere = Pulumi.VSphere;

class MyStack : Stack
{
    public MyStack()
    {
        var datacenter = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
        {
            Name = "dc1",
        }));
        var template = datacenter.Apply(datacenter => Output.Create(VSphere.GetVirtualMachine.InvokeAsync(new VSphere.GetVirtualMachineArgs
        {
            DatacenterId = datacenter.Id,
            Name = "test-vm-template",
        })));
    }

}

Coming soon!

import pulumi
import pulumi_vsphere as vsphere

datacenter = vsphere.get_datacenter(name="dc1")
template = vsphere.get_virtual_machine(datacenter_id=datacenter.id,
    name="test-vm-template")
import * as pulumi from "@pulumi/pulumi";
import * as vsphere from "@pulumi/vsphere";

const datacenter = pulumi.output(vsphere.getDatacenter({
    name: "dc1",
}, { async: true }));
const template = datacenter.apply(datacenter => vsphere.getVirtualMachine({
    datacenterId: datacenter.id,
    name: "test-vm-template",
}, { async: true }));

Using GetVirtualMachine

function getVirtualMachine(args: GetVirtualMachineArgs, opts?: InvokeOptions): Promise<GetVirtualMachineResult>
function  get_virtual_machine(datacenter_id=None, ide_controller_scan_count=None, name=None, sata_controller_scan_count=None, scsi_controller_scan_count=None, opts=None)
func LookupVirtualMachine(ctx *Context, args *LookupVirtualMachineArgs, opts ...InvokeOption) (*LookupVirtualMachineResult, error)

Note: This function is named LookupVirtualMachine in the Go SDK.

public static class GetVirtualMachine {
    public static Task<GetVirtualMachineResult> InvokeAsync(GetVirtualMachineArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

Name string

The name of the virtual machine. This can be a name or path.

DatacenterId string

The managed object reference ID of the datacenter the virtual machine is located in. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere..Datacenter data source.

IdeControllerScanCount int
SataControllerScanCount int
ScsiControllerScanCount int

The number of SCSI controllers to scan for disk attributes and controller types on. Default: 1.

Name string

The name of the virtual machine. This can be a name or path.

DatacenterId string

The managed object reference ID of the datacenter the virtual machine is located in. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere..Datacenter data source.

IdeControllerScanCount int
SataControllerScanCount int
ScsiControllerScanCount int

The number of SCSI controllers to scan for disk attributes and controller types on. Default: 1.

name string

The name of the virtual machine. This can be a name or path.

datacenterId string

The managed object reference ID of the datacenter the virtual machine is located in. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere..Datacenter data source.

ideControllerScanCount number
sataControllerScanCount number
scsiControllerScanCount number

The number of SCSI controllers to scan for disk attributes and controller types on. Default: 1.

name str

The name of the virtual machine. This can be a name or path.

datacenter_id str

The managed object reference ID of the datacenter the virtual machine is located in. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere..Datacenter data source.

ide_controller_scan_count float
sata_controller_scan_count float
scsi_controller_scan_count float

The number of SCSI controllers to scan for disk attributes and controller types on. Default: 1.

GetVirtualMachine Result

The following output properties are available:

AlternateGuestName string

The alternate guest name of the virtual machine when guest_id is a non-specific operating system, like otherGuest.

Disks List<Pulumi.VSphere.Outputs.GetVirtualMachineDisk>

Information about each of the disks on this virtual machine or template. These are sorted by bus and unit number so that they can be applied to a vsphere..VirtualMachine resource in the order the resource expects while cloning. This is useful for discovering certain disk settings while performing a linked clone, as all settings that are output by this data source must be the same on the destination virtual machine as the source. Only the first number of controllers defined by scsi_controller_scan_count are scanned for disks. The sub-attributes are:

Firmware string

The firmware type for this virtual machine. Can be bios or efi.

GuestId string

The guest ID of the virtual machine or template.

GuestIpAddresses List<string>

A list of IP addresses as reported by VMWare tools.

Id string

The provider-assigned unique ID for this managed resource.

Name string
NetworkInterfaceTypes List<string>

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.

ScsiBusSharing string

Mode for sharing the SCSI bus. The modes are physicalSharing, virtualSharing, and noSharing. Only the first number of controllers defined by scsi_controller_scan_count are scanned.

ScsiType string

The common type of all SCSI controllers on this virtual machine. Will be one of lsilogic (LSI Logic Parallel), lsilogic-sas (LSI Logic SAS), pvscsi (VMware Paravirtual), buslogic (BusLogic), or mixed when there are multiple controller types. Only the first number of controllers defined by scsi_controller_scan_count are scanned.

DatacenterId string
IdeControllerScanCount int
SataControllerScanCount int
ScsiControllerScanCount int
AlternateGuestName string

The alternate guest name of the virtual machine when guest_id is a non-specific operating system, like otherGuest.

Disks []GetVirtualMachineDisk

Information about each of the disks on this virtual machine or template. These are sorted by bus and unit number so that they can be applied to a vsphere..VirtualMachine resource in the order the resource expects while cloning. This is useful for discovering certain disk settings while performing a linked clone, as all settings that are output by this data source must be the same on the destination virtual machine as the source. Only the first number of controllers defined by scsi_controller_scan_count are scanned for disks. The sub-attributes are:

Firmware string

The firmware type for this virtual machine. Can be bios or efi.

GuestId string

The guest ID of the virtual machine or template.

GuestIpAddresses []string

A list of IP addresses as reported by VMWare tools.

Id string

The provider-assigned unique ID for this managed resource.

Name string
NetworkInterfaceTypes []string

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.

ScsiBusSharing string

Mode for sharing the SCSI bus. The modes are physicalSharing, virtualSharing, and noSharing. Only the first number of controllers defined by scsi_controller_scan_count are scanned.

ScsiType string

The common type of all SCSI controllers on this virtual machine. Will be one of lsilogic (LSI Logic Parallel), lsilogic-sas (LSI Logic SAS), pvscsi (VMware Paravirtual), buslogic (BusLogic), or mixed when there are multiple controller types. Only the first number of controllers defined by scsi_controller_scan_count are scanned.

DatacenterId string
IdeControllerScanCount int
SataControllerScanCount int
ScsiControllerScanCount int
alternateGuestName string

The alternate guest name of the virtual machine when guest_id is a non-specific operating system, like otherGuest.

disks GetVirtualMachineDisk[]

Information about each of the disks on this virtual machine or template. These are sorted by bus and unit number so that they can be applied to a vsphere..VirtualMachine resource in the order the resource expects while cloning. This is useful for discovering certain disk settings while performing a linked clone, as all settings that are output by this data source must be the same on the destination virtual machine as the source. Only the first number of controllers defined by scsi_controller_scan_count are scanned for disks. The sub-attributes are:

firmware string

The firmware type for this virtual machine. Can be bios or efi.

guestId string

The guest ID of the virtual machine or template.

guestIpAddresses string[]

A list of IP addresses as reported by VMWare tools.

id string

The provider-assigned unique ID for this managed resource.

name string
networkInterfaceTypes string[]

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.

scsiBusSharing string

Mode for sharing the SCSI bus. The modes are physicalSharing, virtualSharing, and noSharing. Only the first number of controllers defined by scsi_controller_scan_count are scanned.

scsiType string

The common type of all SCSI controllers on this virtual machine. Will be one of lsilogic (LSI Logic Parallel), lsilogic-sas (LSI Logic SAS), pvscsi (VMware Paravirtual), buslogic (BusLogic), or mixed when there are multiple controller types. Only the first number of controllers defined by scsi_controller_scan_count are scanned.

datacenterId string
ideControllerScanCount number
sataControllerScanCount number
scsiControllerScanCount number
alternate_guest_name str

The alternate guest name of the virtual machine when guest_id is a non-specific operating system, like otherGuest.

disks List[GetVirtualMachineDisk]

Information about each of the disks on this virtual machine or template. These are sorted by bus and unit number so that they can be applied to a vsphere..VirtualMachine resource in the order the resource expects while cloning. This is useful for discovering certain disk settings while performing a linked clone, as all settings that are output by this data source must be the same on the destination virtual machine as the source. Only the first number of controllers defined by scsi_controller_scan_count are scanned for disks. The sub-attributes are:

firmware str

The firmware type for this virtual machine. Can be bios or efi.

guest_id str

The guest ID of the virtual machine or template.

guest_ip_addresses List[str]

A list of IP addresses as reported by VMWare tools.

id str

The provider-assigned unique ID for this managed resource.

name str
network_interface_types List[str]

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.

scsi_bus_sharing str

Mode for sharing the SCSI bus. The modes are physicalSharing, virtualSharing, and noSharing. Only the first number of controllers defined by scsi_controller_scan_count are scanned.

scsi_type str

The common type of all SCSI controllers on this virtual machine. Will be one of lsilogic (LSI Logic Parallel), lsilogic-sas (LSI Logic SAS), pvscsi (VMware Paravirtual), buslogic (BusLogic), or mixed when there are multiple controller types. Only the first number of controllers defined by scsi_controller_scan_count are scanned.

datacenter_id str
ide_controller_scan_count float
sata_controller_scan_count float
scsi_controller_scan_count float

Supporting Types

GetVirtualMachineDisk

See the output API doc for this type.

See the output API doc for this type.

See the output API doc for this type.

EagerlyScrub bool

Set to true if the disk has been eager zeroed.

Size int

The size of the disk, in GIB.

ThinProvisioned bool

Set to true if the disk has been thin provisioned.

EagerlyScrub bool

Set to true if the disk has been eager zeroed.

Size int

The size of the disk, in GIB.

ThinProvisioned bool

Set to true if the disk has been thin provisioned.

eagerlyScrub boolean

Set to true if the disk has been eager zeroed.

size number

The size of the disk, in GIB.

thinProvisioned boolean

Set to true if the disk has been thin provisioned.

eagerlyScrub bool

Set to true if the disk has been eager zeroed.

size float

The size of the disk, in GIB.

thinProvisioned bool

Set to true if the disk has been thin provisioned.

Package Details

Repository
https://github.com/pulumi/pulumi-vsphere
License
Apache-2.0
Notes
This Pulumi package is based on the vsphere Terraform Provider.