VMware Host - List registered VMs

Declaration

<AMVMWAREVM ACTIVITY="list_registeredvms" RESULTDATASET="text" SESSION="VMSession2" />

Related Topics   

Description

Retrieves information in regards to all registered virtual machines and populates a dataset with the results. Ample information can be gathered, such as path, display name, power state, allocated memory, CPU count and much more.

Practical Usage

Ideally used as a means to manage multiple registered VMs (added to inventory).

Parameters

Connection

Property

Type

Required

Default

Markup

Description

Connection

---

---

---

---

Indicates where this activity's connection properties should originate from. Different parameters become active depending on the option selected. This is a visual parameter used only during design-time, therefore, contains no properties or markups. The available options are:

  • Host (Default) - A custom set of credentials will be entered for this activity. This option is normally selected if only a single activity is needed to perform an operation.

  • Session - Credentials derive from a session created in a previous step with the use of the Connect activity. This allows several activities to be linked to a single session, eliminating redundancy. Multiple sessions can exist in a single task.

Session

Text

Yes if Connection set to Session

VMOpsSession1

SESSION="VMO101"

The name of the VM session (created in a previous step) in which to link this activity. This parameter is active only if the Connection parameter is set to Session.

Host type

Text (options)

Yes if Connection set to Host

VIServer

 

  1. HOSTTYPE="Server"

  2. HOSTTYPE="Workstation"

  3. HOSTTYPE="VIServer"

  4. HOSTTYPE="Player"

The type of VM host to establish a connection with. This parameter is active only if the Connection parameter is set to Host. The available options are:

  • VMware Server (1.0x)

  • VMware Workstation

  • VMware VI Server (ESX/ESXi, vCenter, VMware Server 2.0)(Default)

  • VMware Player

Host name

Text

Yes

(Empty)

SERVER="host.server.com"

The hostname or IP address of the computer where the virtual machine is located. This parameter is active only if the Host type parameter is set to VMware Server or VMware VI Server.

Username

Text

No

(Empty)

USERNAME="MsPacman"

The username identifying a valid user account on the machine. This parameter is active only if the Host type parameter is set to VMware Server or VMware VI Server.

Password

Text

No

(Empty)

PASSWORD="encrypted"

The password identifying a valid user account on the machine. This parameter is active only if the Host type parameter is set to VMware Server or VMware VI Server.

Connection timeout

Number

No

60

CONNECTIONTIMEOUT="50"

The maximum time period in seconds during which a connection must be established between the guest and host, otherwise, the step times out. The default value is 60 seconds.

Virtual Machine

Property

Type

Required

Default

Markup

Description

Create and populate dataset with VM information

Text

Yes

(Empty)

RESULTDATASET="theDataset"

The name of the dataset in which to populate with information in regards to the registered virtual machines. More details regarding the fields that this dataset creates can be found below under Datasets.

 

Description

Error Causes

On Error

Additional Notes

Datasets

A dataset is a multiple column, multiple row container object. This activity creates and populates a dataset containing a specific set of fields in addition to the standard dataset fields. The table below describes these fields (assuming the dataset assigned is named theDataset).

Name

Type

Return Value

theDataset.CPUCount

Number

Returns the number of processors.

theDataset.IsPaused

True/False

Returns whether the registered VM is paused. True if it paused, false if it is not paused.

theDataset.IsRecording

True/False

Returns true if the registered VM is recording, false if it is not.

theDataset.IsReplaying

True/False

Returns true if the registered VM is replaying, otherwise returns false.

theDataset.IsRunning

True/False

Returns true if the registered VM is running, false if it is not.

theDataset.IsSuspended

True/False

Returns true if the registered VM is suspended, false if it is not.

theDataset.MemorySize

Number

Returns the total memory size allocated to the registered VM.

theDataset.PathName

Text

Returns the path of the registered VM. (Example: [HPvd01_001] WinServer2008x64_1/WinServer2008x64.vmx)

theDataset.PowerState

Number

Returns the power state of the registered VM.

theDataset.Description

Text

Returns a description of the registered VM.

theDataset.DisplayName

Text

Returns the display name associated to the registered VM.

theDataset.IsReplayable

True/False

Returns true if the registered VM is re-playable, false if not.

theDataset.Path

Text

Returns the path of the registered VM.

Example

NOTE: The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.

Description

This sample task creates a VM session and powers on a VM image. It then retrieves a list of registered VMs and stores them into a dataset. A loop is performed on the dataset. During each iteration, a message box displays information about the current VM on the list.

 

<!-- Create virtual machine connection of host type "Workstation" / Create and start session named "VMOpsSession1" -->

<AMVMWAREVM ACTIVITY="connect" HOSTTYPE="Workstation" SESSION="VMOpsSession1" />

<!-- Power on virtual OS image -->

<AMVMWAREVM SESSION="VMOpsSession1" VMPATH="F:\Virtual Machines\Windows Server 2003Enterprise x64\Windows Server 2003 Enterprise x64 Edition.vmx" LAUNCHGUI="YES" />

<!-- List registered VMs -->

<AMVMWAREVM ACTIVITY="list_registeredvms" SESSION="VMOpsSession1" RESULTDATASET="registeredVMs" />

<AMLOOP ACTIVITY="dataset" DATASET="registeredVMs">

   <AMSHOWDIALOG WINDOWTITLE="Registered VM information">VM display name - %registeredVMs.DisplayName%

VM path - %registeredVMs.path%

VM memory size - %registeredVMs.MemorySize%

VM number of processors - %registeredVMs.CPUCount%</AMSHOWDIALOG>

</AMLOOP>

<!-- Power off virtual machine -->

<AMVMWAREVM ACTIVITY="poweroff_vm" SESSION="VMOpsSession1" VMPATH="F:\Virtual Machines\Windows7 x86\Windows 7.vmx" TIMEOUT="3" OPENVMTIMEOUT="3" SOFT="YES" TOOLSTIMEOUT="3" />

<!-- Disconnect virtual machine connection / End session -->

<AMVMWAREVM ACTIVITY="disconnect" SESSION="VMOpsSession1" />