vRealize Orchestrator Appliance – Guest File Operations Part 1 – (Copying a file to guest VM)

One of the things you will often find you need to do with vRO is to get a file to a guest VM, or just run a file from inside the VM. Now for Windows you can use Powershell remote features in many cases, but what if your server isn’t on the network yet? Until version 5.1 we had to rely on VIX as a way to do this, but now VMware has added a number of new workflows under “Guest Operations” which are much more reliable.

vCO Guest Operations

vRO Guest Operations

“Copy file from vCO to guest” is the one I’m going to be using in this example.

First of all copy the workflow into a sandbox area. This way you can move a bunch of the inputs to attributes and not have to key them in each time (e.g. The local administrator username, password, and test VM).

In my example, I’m going to create a text file called test.txt in a new folder under /opt called “vcofiles”.

My target machine is a Windows 2008 R2 server, where I will copy the file and place it in the C:\temp\ folder with the name “testcopy.txt”

If you run the workflow then these are my input parameters:

GuestFileOperations-Run

The problem is that if you run this you will get an error similar to this:

“No permissions on the file for the attempted operation (Workflow: Copying files from vCO appliance to guest/Scriptable task…”

GuestFileFailure

GuestFileFailure

In order to fix this you first need to give the correct rights to the folder and file on your vCO Appliance.

1. Login as root onto the appliance
2. Give Read/Write/Execution rights to the new folder

FolderRights

3. Give Read/Write rights to the Text file you made

Filerights

Unfortunately we aren’t quite done yet. You also need to tell orchestrator which locations it can read/write/execute from. This involves editing the “js-io-rights.conf” file located in “/opt/vmo/app-server/server/vmo/conf”

Java-FolderRights-2

Add the line “+rwx /opt/vcofiles/” as shown above.

If anyone isn’t too sure on the linux commands to do this:

  • Type “cd /opt/vmo/app-server/server/vmo/conf” and press enter.
  • Type “vi js-io.rights.conf” and press enter.
  • Use the arrow keys to move the cursor where you want and press the insert key
  • Press Enter and type in the line “+rwx /opt/vcofiles”
  • Press ESC
  • Type “:wq” and press enter.

4. Now, there’s one more thing. You need to restart the vCO service for this to take effect.

Login to the vCO configuration manager, go to startup, and click restart service.

ServiceRestarted

5. Now run your workflow and see if your text file copied across.

Success

You can see a quick video demo of this on youtube. (apologies for the mouse pointer issue..)

Thanks for reading. Let me know if you have any questions.

 

Share

5 comments

  1. Hi Nick, hi Amy.
    Thanks to you we’re now able to upload files (even binary ones) from VRO to guest VM.
    The next step will be… transferring a (binary, maybe quite large) file *from* my desktop *to* VRO appliance.
    Created a simple workflow taking an input parameter “localFile” (type string), with a “scriptable task” built like this

    System.log(“localFile: ” + localFile);
    var mimeAttachment = new MimeAttachment(localFile);
    System.log(mimeAttachment.mimeType);
    mimeAttachment.write(“”, “mybeautifulfile.iso”);

    The workflow fails with these log entries:

    [2016-10-03 16:16:08.031] [I] localFile: h:\iso\MARIADB-GALERA.ISO
    [2016-10-03 16:16:08.041] [I] application/octet-stream
    [2016-10-03 16:16:08.046] [E] Permission denied on directory ‘/var/lib/vco/app-server/bin’

    I’d rather avoid giving rwx permissions on /var/lib/vco/app-server/bin directory, so I created /var/lib/vco/app-server/bin/uploads directory, gave it rwx permissions, added it to js-io-rights.conf, restarted both VRO services and modified the script this way:

    If the first parameter of the mimeAttachment.write function is “something else” (I tried with “uploads”, “uploads/”, “/uploads”, “/uploads/”) then my workflow fails with

    [2016-10-03 17:13:00.791] [I] localFile: h:\iso\MARIADB-GALERA.ISO
    [2016-10-03 17:13:00.831] [I] application/octet-stream
    [2016-10-03 17:13:00.836] [E] Error in (Workflow:Copy of copyFileToGuest / Scriptable task (item1)#4) Wrapped java.lang.NullPointerException

    Given that the API explorer for mimeattachment.write is quite cryptic (at least for me), what am I doing wrong?
    Of course I tried to reference the previously created /vcofiles directory (that has the correct permissions and references in js-io-rights.conf) but I keep getting NullPointerException.

    Thanks in advance
    Best regards
    A confused italian

      1. Hello Nick, it turned out that was my fault… again. 🙁
        Now it’s working, I modified the workflow this way:

        Input PARAMETERS:
        localFile (MimeAttachment) – let the user choose the file inside his PC
        vroFileName (string) – let the user choose the file name on VRO
        Input ATTRIBUTES:
        vroPath (string) – taken from a Configuration Item on the Orchestrator
        vroFile (MimeAttachment)

        Scriptable Action:

        var vroFile = localFile;
        vroFile.write(vroPath,vroFileName);

          1. Of course (sigh), my solution comes with two caveats:
            – first of all, file size limit for uploads from the desktop to the Orchestrator appliance is 2Mb. Yes, Mb.
            – And you cannot invoke this VRO workflow as a Resource Action from VRA, because there is no field type “mime attachment” in VRA yet.

            Best regards

Leave a Reply

Your email address will not be published. Required fields are marked *