VMware Cloud Community
dtracey
Expert
Expert

Copy file from vRO to Guest

Hi chaps,

Is it possible to execute a workflow that copies a file (e.g. .exe or .zip) from a vRO Resource Element to a guest?

I am using the script from "Copy file from vCO to Guest, but have amended the vcoPath variable from a string to a ResourceElement, uploaded the file as a new resource element and have tried granting additional Edit and Admin rights to the vRO service account. 

I see the error "No permissions on the file for the attempted operation (Workflow:Copy file from vRO to guest / Scriptable task (item1)#12)"

************************************

var host = vm.sdkConnection;

var guestOperationsManager = host.guestOperationsManager;

var guestAuth = new VcNamePasswordAuthentication();

guestAuth.username = vmUsername;

guestAuth.password = vmPassword;

var fileManager = guestOperationsManager.fileManager;

result = false;

var attr = new VcGuestFileAttributes();

var srcFile = new File(vcoPath);

var uri = fileManager.initiateFileTransferToGuest(vm , guestAuth ,guestFilePath, attr, srcFile.length, overwrite);

result = fileManager.putFile(vcoPath, uri);

******************************88

Thanks,


Dan

vRO v6.0.3

Tags (1)
1 Reply
iiliev
VMware Employee
VMware Employee

Hi,

On the line

    var srcFile = new File(vcoPath);

are you trying to create File object passing ResourceElement as an argument? I don't think this will work.

What I'd recommend to try is to create a new temporary file, dump the content of the resource element object to the file using ResourceElement's writeContentToFile(....) scripting method, and then create the srcFile object by using the name/path of this temporary file.

Also, don't forget to check that you have granted enough file access permissions in /etc/vco/app-server/js-io-rights.conf file.