VMware Cloud Community
Sirry
Enthusiast
Enthusiast
Jump to solution

Reading / Writing to Network Shares using vCO

I'm sorry for the question, but I have perused the this forum and am still failing to set up how to read and write files to a network share.

Can someone give me more explicit instructions? I have tried using the File object, but I'm not sure how to instantiate it in the first place, I believe my syntax is wrong.

I am using vCO Appliance. Thanks for the help in advance.

1 Solution

Accepted Solutions
Burke-
VMware Employee
VMware Employee
Jump to solution

This question came up again while I am away from my office... So I'm sitting in my hotel room after a nice long day of teaching vCO and seeing an e-mail come in about this same topic so I figure why not be productive Smiley Wink Here is is almost 1 a.m. and I've just completed testing and documenting the necessary steps. See my article here:

How to allow the vCO Appliance to write files to a Windows CIFS share

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter

View solution in original post

0 Kudos
17 Replies
tschoergez
Leadership
Leadership
Jump to solution

Hi,

if I remember right, you can find an example in our training package for the videos on http://www.vmwarelearning.com/orchestrator you can get from here: http://communities.vmware.com/docs/DOC-21582

The Workflow is called "Save Datacenter Report to html file".

In short:

var myFile = new File(fullPathAndFilename);

myFile.write(something);

Cheers,

Joerg

0 Kudos
Sirry
Enthusiast
Enthusiast
Jump to solution

Thanks for the help. I am able to get the above working for local files, but I cannot get it working for remote files.

I understand that I need the proper permissions to get the files working, but I have opened up the remote file share to be fully controlled by everyone.

my syntax is something like:

var test = new FileReader("//192.168.10.120/Shares/test.txt");

I am getting an error: Permission denied on file '/172.16.167.33/ConfigShares/testes.txt' , read not allowed

Flipping the slashes gives me File Not Found.

I have tried to open the shares on other  (Windows) computers and all open up the path just fine without credentials.... any idea what the issue might be?

0 Kudos
tschoergez
Leadership
Leadership
Jump to solution

If you want to use backslashes, be aware that they are special characters in Javascript, so you have to escape them, giving something like "\\\\192.168.10.120\\Shares\\test.txt".

I don't know if the forward slashes work with network shares.

Can you try to map the share with a drive letter, as a workaround?

Cheers,

Joerg

Sirry
Enthusiast
Enthusiast
Jump to solution

Is there a way to do this if vCenter Orchestrator is on the Linux Appliance VM? Mapping seems to require installation of some things.

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

There is no need to map shares to drives.

First, make sure that you have given read permissions to the file you intend to read. In configuration file 'js-io-rights.conf' (located in <vco-dir>\app-server\server\vmo\conf\ directory), you need to have a line similar to

+r \\192.168.10.120\Shares\test.txt

Then, in your workflow you can use something like

var file = new FileReader("\\\\192.168.10.120\\Shares\\test.txt");

file.open();

var s = file.readAll();

System.log("file content read => " + s);

file.close();

Hope this helps.

iiliev
VMware Employee
VMware Employee
Jump to solution

Forgot to mention, the sample permissions in my previous post is for read only mode. If you need not only read, but also write/execute permissions, you should replace '+r' with '+rwx'

0 Kudos
Sirry
Enthusiast
Enthusiast
Jump to solution

Thank you for the help... I seem to have made progress following your instructions verbatim, but I am having the oddest issue at the moment...

I can read and write to "a" file I specified ("\\\\172.16.167.33\\vCOShares\\simple.txt")

However, it does not seem to affect the file system at all! No file is read/written to at that location, yet I know the data is persistent since I can write in a workflow and then read it back in another....

0 Kudos
Sirry
Enthusiast
Enthusiast
Jump to solution

If i were to allow a full directory instead of a file, do I just type in:

  1. +r \\192.168.10.120\Shares\


Update: Added some debugging lines... perhaps someone who sees this can find something I didn't.... it does alarm me that Orchestrator thinks it is a local file:


[2013-07-09 17:41:15.942] [I] Dumping File Information for: '/tmp/xFiles/test.log'

[2013-07-09 17:41:15.944] [I]   Dir: /tmp/xFiles/

[2013-07-09 17:41:15.945] [I]   Exist: true

[2013-07-09 17:41:15.946] [I]   Hostname: localhost

[2013-07-09 17:41:15.948] [I]   isDir: false

[2013-07-09 17:41:15.949] [I]   length: 117

[2013-07-09 17:41:15.951] [I]   ext: log

[2013-07-09 17:41:15.953] [I]   isLocal: true

[2013-07-09 17:41:15.954] [I]   name: test.log

[2013-07-09 17:41:15.955] [I]   path: /tmp/xFiles/test.log

[2013-07-09 17:41:15.957] [I]   canRead: true

[2013-07-09 17:41:15.959] [I]   canWrite: true

[2013-07-09 17:41:15.961] [I] Dumping File Information for: '\\172.16.167.33\vCOShares\simple.tmp'

[2013-07-09 17:41:15.962] [I]   Dir: //172.16.167.33/vCOShares/

[2013-07-09 17:41:15.963] [I]   Exist: true

[2013-07-09 17:41:15.965] [I]   Hostname: localhost

[2013-07-09 17:41:15.966] [I]   isDir: false

[2013-07-09 17:41:15.968] [I]   length: 117

[2013-07-09 17:41:15.970] [I]   ext: tmp

[2013-07-09 17:41:15.971] [I]   isLocal: true

[2013-07-09 17:41:15.972] [I]   name: simple.tmp

[2013-07-09 17:41:15.974] [I]   path: \\172.16.167.33\vCOShares\simple.tmp

[2013-07-09 17:41:15.975] [I]   canRead: true

[2013-07-09 17:41:15.977] [I]   canWrite: true

function for that (and the two lines that call it) are as follows:

function writeToFile(filename)

{

  var testFile = new File(filename);

  System.log("Dumping File Information for: '" + filename + "'");

  System.log("  Dir: " + testFile.directory);

  System.log("  Exist: " + testFile.exists);

  System.log("  Hostname: " + testFile.hostname);

  System.log("  isDir: " + testFile.isDir);

  System.log("  length: " + testFile.length);

  System.log("  ext: " + testFile.extension);

  System.log("  isLocal: " + testFile.isLocal);

  System.log("  name: " + testFile.name);

  System.log("  path: " + testFile.path);

  System.log("  canRead: " + testFile.canRead());

  System.log("  canWrite: " + testFile.canWrite());

  testFile.write("doesn't really matter");

}

writeToFile("/tmp/xFiles/test.log");

writeToFile("\\\\172.16.167.33\\vCOShares\\simple.tmp");

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Yes, this is the syntax for directories.

Briefly looked at the source; it seems that hostname property is not initialized automatically based on the file name and is always localhost (unless you set it explicitly using its setter method).

0 Kudos
Sirry
Enthusiast
Enthusiast
Jump to solution

I am displeased to announce that I am finding a file called "\\172.16.167.33\vCOShares\simple.txt" in my /opt/vmo/app-server/bin directory.

running the command "find / -name '*\\simple.txt*'" returns

/opt/vmo/app-server/bin/\\172.16.167.33\vCOShares\simple.txt

any ideas?

0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

Rather than using a Windows style UNC path for your linux appliance, create a mount point and save to the mount point. Similar applies to vCO on Windows: Don't try to write to UNC path, map a drive and write to the mapped location. Adjust js-io-rights.conf for appropriate permissions to the mount point, not the UNC path.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos
Sirry
Enthusiast
Enthusiast
Jump to solution

I have been trying to do that as well Burke, but I am getting mounting issues.

mount -t cifs //172.16.167.33/vCOShares /mnt/vCOShares

gives me the error:

mount: wrong fs type, bad option, bad superblock on //172.16.167.33/vCOShares, ( ... etc)

I've tried several other variations (-o, trying /sbin/mount.nfs, etc), but cannot seem to get it to work without installing anything.

Can you help me with this syntax?

0 Kudos
Sirry
Enthusiast
Enthusiast
Jump to solution

Any updates on how to mount network shares using vCO appliance? My only option at the moment seems to be to access files on a Windows VM with the desired network drive mounted on it.

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Cifs mount type (samba) is not available in the appliance. Could you try with a similar mount command with nfs or nfs4 mount type?

0 Kudos
Sirry
Enthusiast
Enthusiast
Jump to solution

We are committed to cifs. I think my current options are to mount a Windows VM /w the shared drive mapped or switch to Windows vCO.

Are there any other options?

0 Kudos
tschoergez
Leadership
Leadership
Jump to solution

Well, you can always use the SSH Plugin as alternative:

Install an SSH server on a windows system, and use the SSH workflow to either call scripts there, or transfer files via SCP (examples are in the library).

Cheers,

Joerg

0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

This question came up again while I am away from my office... So I'm sitting in my hotel room after a nice long day of teaching vCO and seeing an e-mail come in about this same topic so I figure why not be productive Smiley Wink Here is is almost 1 a.m. and I've just completed testing and documenting the necessary steps. See my article here:

How to allow the vCO Appliance to write files to a Windows CIFS share

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos