vCO – Many new workflows in Release 4.2.1

If you are using and older version of vCO you probably have not noticed that VMware has put a lot of work into new workflows. In my eyes VMware has learned their lesson. In vSphere 4 and vSphere 4.1 VMware had not released any workflows for their premium functions like Distributed Virtual Switches and Host Profiles, not even vmxnet3 virtual network adapters were included. They were not lacking behind they were basically ignoring it. Which seems silly since vCO is more addressing enterprise customers that would more likely use those enterprise plus versions. Now in vCO release 4.2.1 which comes with vCenter 5.0.1 they have included the new featured like storage drs but also caught up on the features that were new to vSphere 4.

All workflows are documented in the document from VMware Using “VMware vCenter Orchestrator Plug-Ins vCenter Orchestrator 4.2.1”

Click to access vcenter-orchestrator-421-using-plugins-guide.pdf

Using the vCenter Server 5.0.1 Plug-In – vCenter Server Plug-In Workflow Library Page 17.

Here is the list of workflows so you get an idea what vCenter Orchestrator is capable of doing out of the box. For more detail also on other libraries I recommend read the VMware document.

Cluster and Compute Resource Workflows

  • Add DRS virtual machine
  • Add virtual machines to DRS group
  • Create cluster
  • Delete cluster
  • Disable DRS on cluster
  • Disable HA on cluster
  • Enable DRS on cluster
  • Enable HA on cluster
  • Remove virtual machine DRS group from cluster
  • Remove virtual machines from DRS group
  • Rename cluster

Custom Attributes Workflows

  • Add custom attribute to a virtual machine
  • Add custom attribute to multiple virtual machines
  • Get custom attribute

Datacenter Workflows

  • Create datacenter
  • Delete datacenter
  • Reload datacenter
  • Rename datacenter
  • Rescan datacenter HBAs

Datastore and Files Workflows

  • Delete all files
  • Delete all unused datastore files
  • Export unused datastore files
  • Find unused files in datastores
  • Get all configuration, template, and disk files from virtual machines
  • Log all datastore files
  • Log unused datastore files

Datacenter Folder Management Workflows

  • Create datacenter folder
  • Delete datacenter folder
  • Rename datacenter folder

Host Folder Management Workflows

  • Create host folder
  • Delete host folder
  • Rename host folder

Virtual Machine Folder Management Workflows

  • Create virtual machine folder
  • Delete virtual machine folder
  • Rename virtual machine folder

Basic Host Management Workflows

  • Enter maintenance mode
  • Exit maintenance mode
  • Move host into cluster
  • Move host to folder
  • Reload host

Power Host Management Workflows

  • Reboot host
  • Shut down host

Host Management Registration Workflows

  • Add host to cluster
  • Add standalone host
  • Disconnect host
  • Reconnect host
  • Reconnect host with all information
  • Remove host

Networking Workflows

  • Add port group to distributed virtual switch
  • Attach host system to distributed virtual switch
  • Create distributed virtual switch with port group

Distributed Virtual Port Group Workflows

  • Connect virtual machine NIC number to distributed virtual port group
  • Delete distributed virtual port group
  • Set teaming options
  • Update distributed virtual port group

Distributed Virtual Switch Workflows

  • Create distributed virtual switch
  • Create private VLAN
  • Delete distributed virtual switch
  • Delete private VLAN
  • Update distributed virtual switch

Standard Virtual Switch Workflows

  • Add port group in standard virtual switch
  • Create standard virtual switch
  • Delete port group from standard virtual switch
  • Delete standard virtual switch
  • Retrieve all standard virtual switches
  • Update port group in standard virtual switch
  • Update standard virtual switch
  • Update VNIC for port group in standard virtual switch

Resource Pool Workflows

  • Create resource pool
  • Create resource pool with specified values
  • Delete resource pool
  • Get resource pool information
  • Reconfigure resource pool
  • Rename resource pool

Storage Workflows

  • Add datastore on iSCSI/FC/local SCSI
  • Add datastore on NFS
  • Add iSCSI target
  • Create VMFS for all available disks
  • Delete datastore
  • Delete iSCSI target
  • Disable iSCSI adapter
  • Display all datastores and disks
  • Enable iSCSI adapter
  • List all storage adapters

Storage DRS Workflows

  • Add datastore to cluster
  • Change Storage DRS per virtual machine configuration
  • Configure datastore cluster
  • Create simple datastore cluster
  • Create Storage DRS scheduled task
  • Create virtual machine anti-affinity rule
  • Create VMDK anti-affinity rule
  • Remove datastore cluster
  • Remove datastore from cluster
  • Remove Storage DRS scheduled task
  • Remove virtual machine anti-affinity rule
  • Remove VMDK anti-affinity rule

Basic Virtual Machine Management Workflows

  • Create custom virtual machine
  • Create simple dvPortGroup virtual machine
  • Create simple virtual machine
  • Delete virtual machine
  • Mark as template
  • Mark as virtual machine
  • Move virtual machine to folder
  • Move virtual machine to resource pool
  • Move virtual machines to folder
  • Move virtual machines to resource pool
  • Register virtual machine
  • Reload virtual machine
  • Rename virtual machine
  • Set virtual machine performance
  • Unregister virtual machine
  • Upgrade VM Hardware (force if required)
  • Upgrade virtual machine
  • Wait for task and answer virtual machine question

Clone Workflows

  • Clone virtual machine from properties
  • Clone virtual machine, no customization
  • Customize virtual machine from properties

Linked Clone Workflows

  • Restore virtual machine from linked clone
  • Set up virtual machine for linked clone
  • Linked clone, Linux with multiple NICs
  • Linked clone, Linux with single NIC
  • Linked clone, Windows with multiple NICs and credential
  • Linked clone, Windows with single NIC and credential
  • Linked clone, no customization

Linux Customization Clone Workflows

  • Clone, Linux with multiple NICs
  • Clone, Linux with single NIC

Tools Clone Workflows

  • Get Linux customization
  • Get NIC setting map
  • Get Windows customization, Sysprep with Unattended.txt
  • Get Windows customization, Sysprep with credentials
  • Get Windows customization for Sysprep
  • Get a VirtualEthernetCard to change the network
  • Get multiple VirtualEthernetCard device changes

Windows Customization Clone Workflows

  • Customize, Windows with single NIC and credential
  • Clone thin provisioned, Windows with single NIC and credential
  • Clone, Windows Sysprep with single NIC and credential
  • Clone, Windows with multiple NICs and credential
  • Clone, Windows with single NIC
  • Clone, Windows with single NIC and credential

Device Management Workflows

  • Add CD-ROM
  • Add disk
  • Change RAM
  • Convert disks to thin provisioning
  • Convert independent disks
  • Disconnect all detachable devices from a running virtual machine
  • Mount floppy disk drive

Move and Migrate Workflows

  • Mass migrate virtual machines with storage vMotion
  • Mass migrate virtual machines with vMotion
  • Migrate virtual machine with vMotion
  • Move virtual machine to another vCenter Server
  • Quick migrate multiple virtual machines
  • Quick migration of virtual machine
  • Relocate virtual machine disks

Other Workflows

  • Disable FT
  • Enable FT
  • Extract virtual machine information
  • Find orphaned virtual machines

Power Management Workflows

  • Power off virtual machine and wait
  • Reboot guest OS
  • Reset virtual machine and wait
  • Resume virtual machine and wait
  • Set guest OS to standby
  • Shut down and delete virtual machine
  • Shut down guest OS and wait
  • Start virtual machine and wait
  • Suspend virtual machine and wait

Snapshot Workflows

  • Create a snapshot
  • Create snapshots of all virtual machines in a resource pool
  • Remove all snapshots
  • Remove excess snapshots
  • Remove old snapshots
  • Remove snapshots of a given size
  • Revert to current snapshot
  • Revert to snapshot and wait

VMware Tools Workflows

  • Mount tools installer
  • Set console screen resolution
  • Turn on time synchronization
  • Unmount tools installer
  • Upgrade tools
  • Upgrade tools at next reboot

vCO – Create Distributed Virtual Port Group

Here is the code for creating a distributed virtual port group. Input is of type VC:VmwareDistributedVirtualSwitch

//New port group basics like name and port numbers
var dvPortgroupConfigSpec = new Array();
dvPortgroupConfigSpec[0] = new VcDVPortgroupConfigSpec();
dvPortgroupConfigSpec[0].name = "vMotion";
dvPortgroupConfigSpec[0].numPorts = 32;
//Supported in vSphere 4.1: earlyBinding, ephemeral, lateBinding
dvPortgroupConfigSpec[0].type = "earlyBinding";

//Create vlan id
dvPortgroupConfigSpec[0].defaultPortConfig = new VcVMwareDVSPortSetting();
dvPortgroupConfigSpec[0].defaultPortConfig.vlan = new VcVmwareDistributedVirtualSwitchVlanIdSpec();
dvPortgroupConfigSpec[0].defaultPortConfig.vlan.inherited = false;
dvPortgroupConfigSpec[0].defaultPortConfig.vlan.vlanId = 0;

//Create Load Balancing Policy
dvPortgroupConfigSpec[0].defaultPortConfig.uplinkTeamingPolicy = new VcVmwareUplinkPortTeamingPolicy();
dvPortgroupConfigSpec[0].defaultPortConfig.uplinkTeamingPolicy.policy = new VcStringPolicy();
//Supported in vSphere 4.1: loadbalance_ip, loadbalance_loadbased, loadbalanced_srcid, loadbalanced_srcmac
dvPortgroupConfigSpec[0].defaultPortConfig.uplinkTeamingPolicy.policy.value = "loadbalance_loadbased";

//Security Policy all to reject
var reject = new VcBoolPolicy();
reject.value = false;
dvPortgroupConfigSpec[0].defaultPortConfig.securityPolicy = new VcDVSSecurityPolicy();
dvPortgroupConfigSpec[0].defaultPortConfig.securityPolicy.allowPromiscuous = reject;
dvPortgroupConfigSpec[0].defaultPortConfig.securityPolicy.forgedTransmits = reject;
dvPortgroupConfigSpec[0].defaultPortConfig.securityPolicy.macChanges = reject;
dvPortgroupConfigSpec[0].defaultPortConfig.securityPolicy.inherited = false;

//myDVS is input parameter of type VC:VmwareDistributedVirtualSwitch
task = myDVS.addDVPortgroup_Task(dvPortgroupConfigSpec);

vCO – Create Distributed Virtual Switch (DVS)

Here is the code for creating a distributed virtual switch. Input is sdkConnection. The code assumes you have only the root network folder.

//sdkConnection is an input parameter of type VC:SdkConnection
var allNetFolder = sdkConnection.getAllNetworkFolders();

//Assuming you have no network folder but the root folder
var netFolder = allNetFolder[0];

var dvsCreateSpec = new VcDVSCreateSpec();
var uplinkNames = new Array();
dvsCreateSpec.productInfo = new VcDistributedVirtualSwitchProductSpec();
//The Version of the DVS
dvsCreateSpec.productInfo.version = "4.1.0";  
dvsCreateSpec.configSpec = new VcVMwareDVSConfigSpec();
//The name of the DVS = "DVSwitch_Backup";
dvsCreateSpec.configSpec.uplinkPortPolicy = new VcDVSNameArrayUplinkPortPolicy;
dvsCreateSpec.configSpec.uplinkPortPolicy.uplinkPortName = uplinkNames;

dvsCreateSpec.configSpec.maxMtu = 9000;
dvsCreateSpec.configSpec.maxPorts = 20000;

task = netFolder.createDVS_Task(dvsCreateSpec);

vCO – Send email attachment

There are maybe times when you want to send an email attachment. A csv file for example. It is actually quit easy to achieve.

Just create a duplicate of the existing workflow “Send notification” and add a few lines.

Add following lines:

//Create Attachment
var fileAttachment = new MimeAttachment(); = attachmentName;
fileAttachment.content = attachment;
message.addMimePart(fileAttachment,"text/html; charset=UTF-8");

attachmentName is an input parameter of the type string with the file name of the attachment.
attachment is an input parameter of the type string with the data you want to attach. (“\n” will be a carriage return).

This will be the full code including the existing code from VMware.

var message = new EmailMessage();

// Override default settings if and only if input parameter is set
if ( smtpHost != null && smtpHost.length > 0 ){
	message.smtpHost = smtpHost;
if ( smtpPort != null && smtpPort > 0 ){
	message.smtpPort = smtpPort;
if ( username !=null && username.length > 0){
	message.username = username;
if ( password != null && password.length > 0){
	message.password = password;
if ( fromName != null && fromName.length > 0){
	message.fromName = fromName;
if ( fromAddress != null && fromAddress.length > 0){
	message.fromAddress = fromAddress;
message.toAddress = toAddress;
message.subject = subject;
message.addMimePart(content,"text/html; charset=UTF-8");

//Create Attachment
var fileAttachment = new MimeAttachment(); = attachmentName;
fileAttachment.content = attachment;
message.addMimePart(fileAttachment,"text/html; charset=UTF-8");

System.log( "sending mail to host: " + message.smtpHost + ":" + message.smtpPort + " with user:" + message.username + ", from:" + message.fromAddress + ", to:" + message.toAddress );


vCO getting started – Videos from VMwareTV

VMware has published some demo videos on how to develop vCenter Orchestrator (vCO) workflows. The first time I ever worked with vCO before I actually were clueless on what to do with it. In case you feel the same way right now these three youtube videos might give you a good start.

Developing Your First VMware vCO Workflow (part 1)

Developing Your First VMware vCO Workflow (part 2)

Developing Your First VMware vCO Workflow (part 3)

And if you are interested in more demos from VMware check out VMwareTV on youtube

VMwareTV on youtube

vCO – Another way of getting Distributed Virtual Switches

Well this is my very first blog ever.  Actually  this is a reply to a blog on the mighty virtualization blog from   on

Blogspot for some reason did not let me post this code as a reply but I thought I do not want to leave my talent wasted (cough!) and post it as a new blog.  Maybe a start for something great.  Well here it is, another code for VMware vCenter Orchestrator on how to get all Distributed Virtual Switches.  In this case the name of it.

dc by the way is a VcDatacenter object.  An input parameter if you will

var dcNetworkFolder = VcPlugin.convertToVimManagedObject( dc, dc.networkFolder.childEntity );
for each (var netItem in dcNetworkFolder)
	if (netItem instanceof VcVmwareDistributedVirtualSwitch)
		System.log( "DVS Name: " +;

Today I actually noticed that you could create a network folder put a dvs switch in there and the code above then would not find it as it only runs through the root network folder. So if you are actually using network folders then you need to run through all network folders. But I don’t leave you alone with that. Below you find a code that does that. However you will get all dvs switches and not just the ones that belong to a specific datacenter.

var allNetFolder = sdkConnection.getAllNetworkFolders();
for each (var netFolder in allNetFolder)
	var dcNetworkFolder = VcPlugin.convertToVimManagedObject( netFolder, netFolder.childEntity );
	for each (var netItem in dcNetworkFolder)
		if (netItem instanceof VcVmwareDistributedVirtualSwitch)
			System.log( "DVS Name: " +;