VMware Cloud Community
Mnemonic
Enthusiast
Enthusiast
Jump to solution

Import file as a Resource Element

Hi,

I have a workflow that exports BIOS settings of a ESXi host. I need to put the file into a Resource Element to import this on other hosts.

I am dumping the config using SSH commands, and am able to copy the file to my vRO server (Appliance) but I cannot find any information about how to read the file from the local file system.

I would like to get it into a text or string, so I can save it as a Resource Element. For that I am going to use the following code:

----------------

var attachment = new MimeAttachment;

attachment.content = content;

attachment.mimeType = mimeType;

resourceElement.setContentFromMimeAttachment(attachment);

----------------

Can anyone help. I cannot find any documentation on this.

Best Regards

Brian

Reply
0 Kudos
1 Solution

Accepted Solutions
Hazenet
Enthusiast
Enthusiast
Jump to solution

Have a look at the Scripting Class, FileReader, either in the API Browser or in these examples:

https://pubs.vmware.com/vsphere-60/index.jsp#com.vmware.vrealize.orchestrator-dev.doc/GUID861E9D4E-B...

Remember to also have a look at the File System Access Rights vRO Workflows and Javascript has:

https://pubs.vmware.com/vsphere-60/index.jsp#com.vmware.vrealize.orchestrator-install-config.doc/GUI...

View solution in original post

Reply
0 Kudos
5 Replies
Hazenet
Enthusiast
Enthusiast
Jump to solution

Have a look at the Scripting Class, FileReader, either in the API Browser or in these examples:

https://pubs.vmware.com/vsphere-60/index.jsp#com.vmware.vrealize.orchestrator-dev.doc/GUID861E9D4E-B...

Remember to also have a look at the File System Access Rights vRO Workflows and Javascript has:

https://pubs.vmware.com/vsphere-60/index.jsp#com.vmware.vrealize.orchestrator-install-config.doc/GUI...

Reply
0 Kudos
Mnemonic
Enthusiast
Enthusiast
Jump to solution

Works perfectly!

The Code:

var fileReader = new FileReader(fileName) ;

fileReader.open() ;

var fileContentAsString = fileReader.readAll();

fileReader.close() ;

return fileContentAsString;

Do you also happen to know how to delete a local file on the vRO server appliance?

Best Regards

Brian.

Reply
0 Kudos
Hazenet
Enthusiast
Enthusiast
Jump to solution

I would think in your case you could do something like

var fileReader = new FileReader(fileName) ;

fileReader.open() ;

var fileContentAsString = fileReader.readAll();

fileReader.close() ;

return fileContentAsString;

var theFile = new File(fileName);

theFile.deleteFile()

Using the Scripting Class "File"

Reply
0 Kudos
Mnemonic
Enthusiast
Enthusiast
Jump to solution

Thanks.. It works.

Reply
0 Kudos
sureshmrdg
Contributor
Contributor
Jump to solution

How to move/save orchestrator resource element to vra appliance??

Reply
0 Kudos