1 |
|
|
/*************************************** |
2 |
|
|
Auteur : Pierre Aubert |
3 |
|
|
Mail : pierre.aubert@lapp.in2p3.fr |
4 |
|
|
Licence : CeCILL-C |
5 |
|
|
****************************************/ |
6 |
|
|
|
7 |
|
|
#include "string_utils.h" |
8 |
|
|
#include "backend_getFileName.h" |
9 |
|
|
#include "backend_rsync.h" |
10 |
|
|
#include "backend_scp.h" |
11 |
|
|
#include "backend_push.h" |
12 |
|
|
|
13 |
|
|
///Get the status of the given scene |
14 |
|
|
/** @param scene : Scene we want the status |
15 |
|
|
* @return true on success, false otherwise |
16 |
|
|
*/ |
17 |
|
|
bool backend_scenePush(const RenderProject & renderProject, const Scene & scene){ |
18 |
|
|
std::cout << termCyan() << "Push Scene"<<termDefault()<<" : '"<<scene.getName()<<"'" << std::endl; |
19 |
|
|
if(!backend_rsyncHostToComputingCenter(renderProject, scene)){return false;} |
20 |
|
|
//Let's submit the job |
21 |
|
|
std::string remoteWorkingDir(renderProject.getComputingCenter().getRemoteWorkingDirectory()); |
22 |
|
|
std::string command(renderProject.getSshExecutable() + " " + renderProject.getComputingCenter().getComputingCenterConnection() + " " ); |
23 |
|
|
command += remoteWorkingDir + "/" + getFileName(renderProject.getSourceProjectDir()) + "/" + scene.getWorkingDirectory(); |
24 |
|
|
command += "/.condor/call_" + backend_getSceneBaseFileName(scene) + ".sh"; |
25 |
|
|
return phoenix_popen(scene.getWorkingDirectory() + "/.condor/ssh_submit_scene_"+scene.getName()+".log", command, true); |
26 |
|
|
} |
27 |
|
|
|
28 |
|
|
///Push scenes to render them on the Computing Center |
29 |
|
|
/** @param[out] isSuccess : true if push was a success |
30 |
|
|
* @param renderProject : render project to be used |
31 |
|
|
* @param wantPush : true if we want to push scenes |
32 |
|
|
* @param vecPushScene : vector of scene names to be rendered on the Computing Center (Push all scenes if empty) |
33 |
|
|
* @return true if the function was called |
34 |
|
|
*/ |
35 |
|
|
bool backend_push(bool & isSuccess, const RenderProject & renderProject, bool wantPush, const std::vector<std::string> & vecPushScene){ |
36 |
|
|
if(!wantPush){return false;} |
37 |
|
|
const std::map<std::string, Scene> & mapScene = renderProject.getMapScene(); |
38 |
|
|
if(vecPushScene.size() == 0lu){ |
39 |
|
|
std::cout << termCyan() << "Push Full Project"<<termDefault() << std::endl; |
40 |
|
|
// isSuccess = backend_rsyncHostToComputingCenter(renderProject); |
41 |
|
|
for(std::map<std::string, Scene>::const_iterator it(mapScene.begin()); it != mapScene.end(); ++it){ |
42 |
|
|
isSuccess &= backend_scenePush(renderProject, it->second); |
43 |
|
|
} |
44 |
|
|
}else{ |
45 |
|
|
for(std::vector<std::string>::const_iterator it(vecPushScene.begin()); it != vecPushScene.end(); ++it){ |
46 |
|
|
std::map<std::string, Scene>::const_iterator itFind(mapScene.find(*it)); |
47 |
|
|
if(itFind != mapScene.end()){ |
48 |
|
|
isSuccess &= backend_scenePush(renderProject, itFind->second); |
49 |
|
|
} |
50 |
|
|
} |
51 |
|
|
} |
52 |
|
|
return true; |
53 |
|
|
} |
54 |
|
|
|
55 |
|
|
|