Custom File Transfer Script

You can write a custom file transfer script to use with your customized DRM system. This lets you specify how you want to transfer simulation input and output data when it is not possible to have a file system identified by fiper.file.fs.simshared that is accessible by both your download/upload host and the compute host.

Add the following property in the SMAExeServer.properties file to specify your custom file transfer script:

fiper.station.sim.stageFileScript=</path/filename>

For example:

fiper.station.sim.stageFileScript=/r/cluster_software/scripts/opendrm/rsync.pl

This property, and the script it names, are used by the simulation physics apps that invoke the remote execution process: Structural Validation, Structural Scenario Creation, Mechanical Scenario Creation, Fluid Scenario Creation, etc. The property and script are also used by the Functional Generative Design app.

Your script is passed three arguments by the process/workflow being executed:

arg1
Host name of the detached controller host station that performs the file checkout to the fiper.file.fs.simshared directory. The detached controller host configuration is described in Configuring a Detached Controller Host for Remote Postprocessing.
arg2
Name of the work item ID directory within the fiper.file.fs.simshared directory.
arg3
The string 'PUSH' or 'PULL' indicating whether your file transfer script should pull the input files from fiper.file.fs.simshared/arg2/ or should push the output files back to fiper.file.fs.simshared/arg2/ so that the detached controller host can then complete the workflow by importing the output to the 3DEXPERIENCE platform.

An example file transfer script using Perl and the rsync utility is shown below.

#!/usr/bin/env perl
use strict;
use Cwd;

my $rsync = "/usr/bin/rsync -avz";
my $controllerHost = $ARGV[0];                # Windows detached controller host
my $activityDir = $ARGV[1];                   # value of activity directory in fiper.file.fs.simshared on Windows controller host
my $mode = $ARGV[2];                          # either PUSH or PULL
my $winSimshared = "/e4all_fs/vdevpril989am/home/WORKING/stagescript";   #fiper.file.fs.simshared relative to Linux transfer host
my $transferHost = "lsfportal2";
my $cwd = cwd();
my $sig = "TRANSFER SCRIPT";

die "$sig ERROR: missing controller host argument.\n" if ($controllerHost eq "");
die "$sig ERROR: missing activityDir argument.\n" if ($activityDir eq "");
die "$sig ERROR: missing script mode argument.\n" if ($mode eq "");
die "$sig ERROR: This script is not supported on Windows\n" if ($^O =~ /MSWin/);

print "$sig INFO: controller host - $controllerHost\n";
print "$sig INFO: activityDir - $activityDir\n";
print "$sig INFO: mode - $mode\n";
print "$sig Executing copy...\n";

if ($mode eq "PULL") {
   print "$sig INFO: running $rsync ${transferHost}:$winSimshared/$activityDir . (working dir: $cwd)\n";
   if ( system("$rsync ${transferHost}:$winSimshared/$activityDir/* .") ) {
       die "$sig ERROR: file transfer pull failed.\n";
   }
} elsif ($mode eq "PUSH") {
   print "$sig INFO: running $rsync ./* ${transferHost}:$winSimshared/$activityDir (working dir: $cwd)\n";
   if ( system("$rsync ./* ${transferHost}:$winSimshared/$activityDir") ) {
      die "$sig ERROR: file transfer push failed.\n";
   }
} else {
   die "$sig ERROR: unhandled mode specified.\n";
}
print "$sig done\n";
exit 0;

Another example file transfer script using the scp utility is shown below.

#!/usr/bin/env perl
use strict;
use Cwd;

my $scp = "/usr/bin/scp -rp";
my $controllerHost = $ARGV[0];  # Windows detached controller host
my $activityDir    = $ARGV[1];  # value of activity directory in fiper.file.fs.simshared on Windows controller host
my $mode           = $ARGV[2];  # either PUSH or PULL
my $winSimshared   = "/e4all_fs/vdevpril989am/home/WORKING/stagescript";  #fiper.file.fs.simshared relative to Linux transfer host
my $transferHost   = "lsfportal2";
my $cwd            = cwd();
my $sig            = "TRANSFER SCRIPT";

die "$sig ERROR: missing controller host argument.\n"       if ($controllerHost eq "");
die "$sig ERROR: missing activityDir argument.\n"           if ($activityDir eq "");
die "$sig ERROR: missing script mode argument.\n"           if ($mode eq "");
die "$sig ERROR: This script is not supported on Windows\n" if ($^O =~ /MSWin/);

print "$sig INFO: controller host - $controllerHost\n";
print "$sig INFO: activityDir     - $activityDir\n";
print "$sig INFO: mode            - $mode\n";

print "$sig Executing copy...\n";

if ($mode eq "PULL") {
   print "$sig INFO: running $scp ${transferHost}:$winSimshared/$activityDir . (working dir: $cwd)\n";
   if ( system("$scp ${transferHost}:$winSimshared/$activityDir .") ) {
        die "$sig ERROR: file transfer pull failed.\n";
   } else {
        system("mv ./$activityDir/* .");
   }
} elsif ($mode eq "PUSH") {
   system("mv * ./$activityDir");  #mv to avoid doubling disk space, but toscaResults.zip must remain in activityDir
   system("cp ./$activityDir/toscaResults.zip ."); #hack, otherwise results generation fails. Rsync avoids this.
   print "$sig INFO: running $scp ./$activityDir ${transferHost}:$winSimshared (working dir: $cwd)\n";
   if ( system("$scp ./$activityDir ${transferHost}:$winSimshared ") ) {
        die "$sig ERROR: file transfer push failed.\n";
   }
} else {
   die "$sig ERROR: unhandled mode specified.\n";
}

print "$sig done\n";
exit 0;