VMware Cloud Community
miladmeh8
Hot Shot
Hot Shot
Jump to solution

How to export workflow log to an external resource like ftp or smb server?

Hi all,

Recently i wrote an workflow to get all storage path status, but i need to save all of the result into an external resource like ftp or smb servers.

Can anyone suggest me the best practice?

Thank you

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
eoinbyrne
Expert
Expert
Jump to solution

SMB would probably require providing Command access which is a security risk so FTP is safer & vRO has an FTP client class

pastedImage_0.png

You can use it to either

- send content to a remote file

this one is simple

var content = "some content";

ftpClient.putContent(content, "remotefile.txt");

- create a local file on the vRO appliance and upload that.

You will need to have the capability to create a local file on the vRO appliance but you can the following to create a temp file and write your content to it, then upload to the remote with the desired name.

// assume your file content is in this var

var fileContent = "whatever the content should be";

var localFile = System.createTempFile(".txt"); // create a temp file with the given suffix

FileWriter fw = new FileWriter(localFile);

fw.open();

fw.write(fileContent);

fw.close();

var localFileFullName = localFile.path + "\" + localFile.name

// do the FTP upload here

ftpClient.putFile(localFileFullName, "whatever the name at the remote should be");

View solution in original post

3 Replies
eoinbyrne
Expert
Expert
Jump to solution

SMB would probably require providing Command access which is a security risk so FTP is safer & vRO has an FTP client class

pastedImage_0.png

You can use it to either

- send content to a remote file

this one is simple

var content = "some content";

ftpClient.putContent(content, "remotefile.txt");

- create a local file on the vRO appliance and upload that.

You will need to have the capability to create a local file on the vRO appliance but you can the following to create a temp file and write your content to it, then upload to the remote with the desired name.

// assume your file content is in this var

var fileContent = "whatever the content should be";

var localFile = System.createTempFile(".txt"); // create a temp file with the given suffix

FileWriter fw = new FileWriter(localFile);

fw.open();

fw.write(fileContent);

fw.close();

var localFileFullName = localFile.path + "\" + localFile.name

// do the FTP upload here

ftpClient.putFile(localFileFullName, "whatever the name at the remote should be");

miladmeh8
Hot Shot
Hot Shot
Jump to solution

Thank you for your response

But where should i define my ftp server address and credentials?

0 Kudos
miladmeh8
Hot Shot
Hot Shot
Jump to solution

  1. var ftp = new FTPClient(); 
  2. ftp.connect("10.20.123.135", "21");  // sample ip, port 
  3. ftp.login("user", "pass");  // sample username, password 
  4. System.log("cwd -> " + ftp.cwd); // print current directory 
  5. ftp.makeRemoteDirectory("/tmp6");  // create a new directory 
  6. ftp.cwd = "/tmp6";  // changes current directory to the newly created one 
  7. System.log("cwd -> " + ftp.cwd);  // print the new current directory 
  8. ftp.disconnect(); 
0 Kudos