Change VM name upon creation

Let's develop a workflow with the following specification:

INPUT: vCloud:VM object
Process:
- Rename VM
- Change Guest OS Name

Create a new workflow

Create a new workflow

Add a workflow element

  1. Add workflow Library > vCloud Director > vApp > VM > Rename VM

Setup parameters

  1. Make sure the workflow element is selected, Click the Setup... button
  2. Select Value for newName parameter
  3. Click the Promote button

Add workflow element

  1. Add workflow Library > vCloud Director > vApp > VM > Guest Customization > Change computer name

Setup parameters

  1. Make sure the workflow element is selected, Click the Setup... button
  2. Select newName from the dropdown list for the second parameter
  3. Select Local variable for the Output Parameter vmOut
  4. Click the Promote button

Add Scriptable task

  1. Add a scriptable task at the beginning of the workflow

Add Scripting

  1. Bind the attribute newName as OUT (not shown)
  2. Enter the following code: (to generate a new name for the machine)
newName = "myvm" + Math.floor(Math.random() * 999);
  1. Click the Save and close button

Create a new notification subscription

Configure a notification subscription

  1. Navigate to vCloud Director Notifications  > Configuration > Create a vCloud Director notification subscription
  2. Click the Start Workflow... button

Start subscription listener

Testing

Login to tenant T1

  1. Launch Chrome in incognito mode
  2. Select the bookmark vCloud Director > Site A - Tenant T1 - H5 UI
  3. Enter credentials
    user: t1admin
    password: VMware1!
  4. Click the LOGIN button

Search a vApp Template

  1. Click the menu button
  2. Select Libraries
  3. Select vApp Templates

Create vApp

  1. Click on the 3 dots menu for vApp Template tc-linux
  2. Select Create vApp

Select Name

  1. Enter a vApp Name: test-vapp-naming
  2. Click the NEXT button

Configure Resource

  1. Select the Org vDC T1-OVDC
  2. Click the NEXT button

Configure Networking

  1. Select T1-OrgNet-Rtd for the network connected to NIC 0 of the vm linux-base
  2. Click the NEXT button

Customize Hardware

  1. Click the NEXT button

Review and Finish

  1. Click the FINISH button

Find the vApp

  1. Click the menu button
  2. Select Datacenters
  3. Click the organization vDC T1-OVDC

Find the VM name

  1. Select vApps
  2. Click the DETAILS menu for the vApp test-vapp-naming

Observe the new machine name

  1. Look at the VM name