VMware Cloud Community
Pilu1978
Enthusiast
Enthusiast

Saving output to a csv file

Hi,

I am new to vRO. My requirement is to save the VM details (like Name, cpu, RAM etc) to a csv file and save it in shared location.

Please help.

0 Kudos
2 Replies
iiliev
VMware Employee
VMware Employee

Hi,

Check the scripting classes FileWriter and File - their methods provide a way to create/write files.

As for CSV data to write to file - you'll need to iterate over your VM objects, and for each VM prepare a CSV string which is simple a sequence of VM attribute values, separated by comma characters. For example, if you have VM object in a variable vm, then you can do something like:

var csvLine = vm.name = "," + vm.cpu + "," + vm.memory; // add other VM values as needed

and then write csvLine to the file using FileWriter#writeLine() method.

0 Kudos
Pilu1978
Enthusiast
Enthusiast

Thanks for your reply.

How do I save it in shared location like "\\server\Share\vmdetails.csv"

0 Kudos