vCenterVMWarevRO

Create a vCenter tag via VAPI

//VMware vRO action sample
//
// Create a vCenter tag via VAPI
// If description is empty, sets the description as the Tag name by default.
//
// For vRO7.0+
//
// Action Inputs:
// endpoint – VAPIEndpoint – VAPI Endpoint
// name – string – Name of the Tag
// categoryId – string – ID of the Tag Category
// description – string – Optional description of the Tag
//
// Return type: string – ID of the tag

var tagClient = endpoint.client();
var tagService = new com_vmware_cis_tagging_tag(tagClient);
var tagCreateSpec = createTagSpec(name,categoryId,description);
tagId = tagService.create(tagCreateSpec);

return tagId;

function createTagSpec(name,categoryId,description) {
var spec = new com_vmware_cis_tagging_tag_create__spec() ;
spec.category_id = categoryId;
spec.name = name;
spec.description = (Set(description)) ? description : name;
return spec;
}

function Set(s) {
return s != null && s != “”;
}

Tags

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Close