Create DNS records

Let's create a DNS record upon VM provisioning.

Create a new workflow

  1. Select the Workshop folder
  2. Click the button New workflow
  3. Enter workflow name Create DNS record
  4. Click the Ok button

Add input

  1. Select Inputs tab
  2. Add one input
    name = vm
    type = vCloud:VM

Add scriptable task

  1. In the Generic section, Select Scriptable task 
  2. Drag the Scriptable task element onto the Schema between the two existing elements on the canvas

The green arrow represents the Start workflow element and the one to the far right is the End workflow element.
These 2 elements are mandatory, and must be present for the workflow to run.

Add powershell workflow

  1. Select Schema tab
  2. Navigate to Library > Powershell > Invoke a PowerShell script
  3. Drag and drop the element after the Scriptable task

Setup workflow

  1. Click the Setup... button
  2. Select Value
  3. Select Local variable
  4. Click Promote

Configure host attribute

  1. Select General tab
  2. Click Not set for host attribute
  3. Expand PowerShell and select DNS Server
  4. Click the Select button

Set scriptable task IN

  1. Select Schema tab and select Scriptable task in the schema (not shown)
  2. Select IN tab
  3. Click the button
  4. Check the checkbox for vm parameter
  5. Click the Select button

Set scriptable task OUT

  1. Select OUT tab
  2. Click the button
  3. Check the checkbox for script attribute
  4. Click the Select button

Set Script

  1. Enter the following script:
script = "Add-DnsServerResourceRecordA -Name \""+ vm.name +"\" \
-ZoneName \"corp.local\" \
-IPv4Address \""+ vm.getNetworkCards()[0].ipAddress +"\"";
  1. Click the Save and close button

Edit "Update VM Name" workflow

  1. Select the workflow created previously "Update VM name"
  2. Click the Edit button

Add Create DNS record workflow

  1. Select Schema tab
  2. Navigate to Workshop > Create DNS record
  3. Drag and Drop the workflow at the end in the schema

Setup the workflow

  1. Click the Setup... button
  2. Click the Promote button

Save and close

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-dns
  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-dns

Resolve the machine name

  1. Look at the VM name
  2. Open a command prompt
  3. Type nslookup myvm123

Check if the name is resolved by the DNS server