Skip to content

Instantly share code, notes, and snippets.

@trisharia
Last active August 7, 2018 03:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trisharia/b1d3086f215810869721cc7e9324c011 to your computer and use it in GitHub Desktop.
Save trisharia/b1d3086f215810869721cc7e9324c011 to your computer and use it in GitHub Desktop.
Assign a vCenter tag to a VM via VAPI
// VMware vRealize Orchestrator action sample
//
// This sample assigns a vCenter Tag to a VM
//
// For vRO/VAPI 7.0+
//
// Action Inputs:
// endpoint - VAPIEndpoint - VAPI Endpoint
// tagId - string - ID of the vCenter Tag
// vm - VC:VirtualMachine - VM to which tag will be assigned
//
// Return type: void
//Prep VM VAPI reference object
var vapiVm = new com_vmware_vapi_std_dynamic__ID() ;
vapiVm.id = vm.id;
vapiVm.type = "VirtualMachine";
//Associate VM to tag:
var client = endpoint.client();
var assocService = new com_vmware_cis_tagging_tag__association(client);
assocService.attach(tagId , vapiVm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment