Inputs:-
folder String type (name of the ResourceElementCategory)
templateFile String type (name of the resource element)
vmName String type (name of the VM) (or the content needs to be replaced with)
//Get all resources from resources folder see in below snapshot we have resource element called DNS-script.txt
var resElems = Server.getResourceElementCategoryWithPath(folder);
System.log(resElems.name)
var elements = resElems.resourceElements
for each(resElem in elements){
System.log(resElem.name)
if(resElem.name == templateFile){
resource = resElem;
}
};//Resource to MimeAttachment
var mimeResource = resource.getContentAsMimeAttachment();
var content = mimeResource.content;
//System.log(content)
content = content.replace(“$vmName”, ‘“’+vmName+‘“’);
System.log(content)
script=content;
// Script contains updated content
// you can use this to send a email
folder String type (name of the ResourceElementCategory)
templateFile String type (name of the resource element)
vmName String type (name of the VM) (or the content needs to be replaced with)
//Get all resources from resources folder see in below snapshot we have resource element called DNS-script.txt
var resElems = Server.getResourceElementCategoryWithPath(folder);
System.log(resElems.name)
var elements = resElems.resourceElements
for each(resElem in elements){
System.log(resElem.name)
if(resElem.name == templateFile){
resource = resElem;
}
};//Resource to MimeAttachment
var mimeResource = resource.getContentAsMimeAttachment();
var content = mimeResource.content;
//System.log(content)
content = content.replace(“$vmName”, ‘“’+vmName+‘“’);
System.log(content)
script=content;
// Script contains updated content
// you can use this to send a email