int do_command_download_sandbox(void *arg, Stream*) { dprintf(D_ALWAYS, "FTGAHP: download sandbox\n"); Gahp_Args args; parse_gahp_command ((char*)arg, &args); // first two args: result id and sandbox id: std::string rid = args.argv[1]; std::string sid = args.argv[2]; // third arg: job ad ClassAd ad; classad::ClassAdParser my_parser; if (!(my_parser.ParseClassAd(args.argv[3], ad))) { // FAIL write_to_pipe( ChildErrorPipe, "Failed to parse job ad" ); return 1; } // first, create the directory that will be IWD. returns the // directory created. std::string iwd; bool success; success = create_sandbox_dir(sid, iwd); if (!success) { // FAIL write_to_pipe( ChildErrorPipe, "Failed to create sandbox" ); return 1; } // rewrite the IWD to the newly created sandbox dir ad.Assign(ATTR_JOB_IWD, iwd.c_str()); char ATTR_SANDBOX_ID[] = "SandboxId"; ad.Assign(ATTR_SANDBOX_ID, sid.c_str()); // directory was created, let's set up the FileTransfer object FileTransfer ft; if (!ft.Init(&ad)) { // FAIL write_to_pipe( ChildErrorPipe, "Failed to initialize FileTransfer" ); return 1; } // Set the Condor version of our peer, as given by the CONDOR_VERSION // command. // If we don't have a version, then assume it's pre-8.1.0. // In 8.1, the file transfer protocol changed and we added // the CONDOR_VERSION command. if ( !peer_condor_version.empty() ) { ft.setPeerVersion( peer_condor_version.c_str() ); } else { CondorVersionInfo ver( 8, 0, 0 ); ft.setPeerVersion( ver ); } if ( !sec_session_id.empty() ) { ft.setSecuritySession( sec_session_id.c_str() ); } dprintf(D_ALWAYS, "BOSCO: calling Download files\n"); // the "true" param to DownloadFiles here means blocking (i.e. "in the foreground") if (!ft.DownloadFiles(true)) { // FAIL write_to_pipe( ChildErrorPipe, ft.GetInfo().error_desc.Value() ); return 1; } // SUCCEED return 0; }
int do_command_download_sandbox(void *arg, Stream*) { dprintf(D_ALWAYS, "FTGAHP: download sandbox\n"); Gahp_Args args; parse_gahp_command ((char*)arg, &args); // first two args: result id and sandbox id: std::string rid = args.argv[1]; std::string sid = args.argv[2]; // third arg: job ad ClassAd ad; classad::ClassAdParser my_parser; if (!(my_parser.ParseClassAd(args.argv[3], ad))) { // FAIL write_to_pipe( ChildErrorPipe, "Failed to parse job ad" ); return 1; } // first, create the directory that will be IWD. returns the // directory created. std::string iwd; bool success; success = create_sandbox_dir(sid, iwd); if (!success) { // FAIL write_to_pipe( ChildErrorPipe, "Failed to create sandbox" ); return 1; } // rewrite the IWD to the newly created sandbox dir ad.Assign(ATTR_JOB_IWD, iwd.c_str()); char ATTR_SANDBOX_ID[] = "SandboxId"; ad.Assign(ATTR_SANDBOX_ID, sid.c_str()); // directory was created, let's set up the FileTransfer object FileTransfer ft; if (!ft.Init(&ad)) { // FAIL write_to_pipe( ChildErrorPipe, "Failed to initialize FileTransfer" ); return 1; } // lookup ATTR_VERSION and set it. this changes the wire // protocol and it is important that this happens before // calling DownloadFiles. char* peer_version = NULL; ad.LookupString(ATTR_VERSION, &peer_version); ft.setPeerVersion(peer_version); free (peer_version); dprintf(D_ALWAYS, "BOSCO: calling Download files\n"); // the "true" param to DownloadFiles here means blocking (i.e. "in the foreground") if (!ft.DownloadFiles(true)) { // FAIL write_to_pipe( ChildErrorPipe, ft.GetInfo().error_desc.Value() ); return 1; } // SUCCEED return 0; }