Skip to content

Instantly share code, notes, and snippets.

@trisharia
Last active September 15, 2022 23:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save trisharia/9b50f0d8509dbf3346ed6a1b3c54bc54 to your computer and use it in GitHub Desktop.
Save trisharia/9b50f0d8509dbf3346ed6a1b3c54bc54 to your computer and use it in GitHub Desktop.
Create a temporary text-based file on the vRO server, which can then be copied elsewhere like a guest vCenter VM
// VMware vRealize Orchestrator action sample
//
// Create a temporary text-based file, in a temporary directory, on the vRO server
// Sample usage would be to later copy the file to a guest vCenter VM
//
// For vRO 6.0+
//
// Action Inputs:
// vroTempFileName - string - Name of the file to create
// fileContents - string - Contents of the file
//
// Return type: string - Full path of the file on the vRO server
var tempDir = System.getTempDirectory();
vroTempFileFullPath = tempDir + "/" + vroTempFileName;
var writer;
try {
writer = new FileWriter(vroTempFileFullPath);
} catch (e) {
throw "Failed to create temp file in vRO server: " + vroTempFileFullPath + " :: " + e;
}
try {
writer.open();
} catch (e) {
throw "Failed to open temp file for editing in vRO server: " + vroTempFileFullPath + " :: " + e;
}
try {
writer.write(fileContents);
} catch (e) {
throw "Failed to write contents to temp file in vRO server: " + vroTempFileFullPath + " :: " + e;
}
try {
writer.close();
System.debug("Contents written to vRO temp file " + vroTempFileFullPath + " successfully.");
} catch (e) {
throw "Failed to close temp file after editing in vRO server: " + vroTempFileFullPath + " :: " + e;
}
return vroTempFileFullPath;
@imtrinity94
Copy link

Works in vRO 8.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment