PortableServer::POAManager_var pman = root_poa->the_POAManager();
PortableServer::POA_var my_poa;
+ _orb = CORBA::ORB::_duplicate(orb) ;
CORBA::PolicyList policies;
policies.length(1);
PortableServer::ThreadPolicy_var threadPol =
{
MESSAGE("Shutdown");
ShutdownContainers();
+ _orb->shutdown(0);
+ _NS->Destroy_Name(_ContainerManagerNameInNS);
PortableServer::ObjectId_var oid = _default_POA()->servant_to_id(this);
_default_POA()->deactivate_object(oid);
_remove_ref();
void SALOME_ContainerManager::ShutdownContainers()
{
MESSAGE("ShutdownContainers");
- _NS->Change_Directory("/Containers");
- vector<string> vec = _NS->list_directory_recurs();
- list<string> lstCont;
- for(vector<string>::iterator iter = vec.begin();iter!=vec.end();iter++)
- {
+ bool isOK;
+ isOK = _NS->Change_Directory("/Containers");
+ if( isOK ){
+ vector<string> vec = _NS->list_directory_recurs();
+ list<string> lstCont;
+ for(vector<string>::iterator iter = vec.begin();iter!=vec.end();iter++){
SCRUTE((*iter));
CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
Engines::Container_var cont=Engines::Container::_narrow(obj);
- if(!CORBA::is_nil(cont))
- {
- lstCont.push_back((*iter));
- }
+ if(!CORBA::is_nil(cont)){
+ lstCont.push_back((*iter));
+ }
}
- MESSAGE("Container list: ");
- for(list<string>::iterator iter=lstCont.begin();iter!=lstCont.end();iter++)
- {
+ MESSAGE("Container list: ");
+ for(list<string>::iterator iter=lstCont.begin();iter!=lstCont.end();iter++){
SCRUTE((*iter));
}
- for(list<string>::iterator iter=lstCont.begin();iter!=lstCont.end();iter++)
- {
+ for(list<string>::iterator iter=lstCont.begin();iter!=lstCont.end();iter++){
SCRUTE((*iter));
CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
Engines::Container_var cont=Engines::Container::_narrow(obj);
- if(!CORBA::is_nil(cont))
- {
- MESSAGE("ShutdownContainers: " << (*iter));
- cont->Shutdown();
- }
+ if(!CORBA::is_nil(cont)){
+ MESSAGE("ShutdownContainers: " << (*iter));
+ cont->Shutdown();
+ }
else MESSAGE("ShutdownContainers: no container ref for " << (*iter));
}
+ }
}
//=============================================================================
void SALOME_ResourcesManager::CopyFileNamesToExecute(const std::string& machine,
const std::string& DirForTmpFiles ,
const std::string& PathFileNameToExecute ,
- const Engines::FilesToExportList& filesToExport) {
+ const Engines::FilesToExportList& filesToExport) throw(SALOME_Exception)
+{
BEGIN_OF("SALOME_ResourcesManager::CopyFileNamesToExecute");
const ParserResourcesType& resInfo = _resourcesList[machine];
string command;
+ int status;
if (resInfo.Protocol == rsh)
command = "rsh ";
command += " \"mkdir -p ";
command += DirForTmpFiles ;
command += "\"" ;
- system(command.c_str());
+ SCRUTE(command.c_str());
+ status = system(command.c_str());
+ if(status)
+ throw SALOME_Exception("Error of connection on remote host");
if (resInfo.Protocol == rsh)
command = "rcp ";
command += resInfo.Alias;
command += ":";
command += DirForTmpFiles ;
- system(command.c_str());
+ SCRUTE(command.c_str());
+ status = system(command.c_str());
+ if(status)
+ throw SALOME_Exception("Error of connection on remote host");
int i ;
for ( i = 0 ; i < filesToExport.length() ; i++ ) {
command += resInfo.Alias;
command += ":";
command += DirForTmpFiles ;
- system(command.c_str());
+ SCRUTE(command.c_str());
+ status = system(command.c_str());
+ if(status)
+ throw SALOME_Exception("Error of connection on remote host");
}
END_OF("SALOME_ResourcesManager::CopyFileNamesToExecute");
std::string SALOME_ResourcesManager::BuildCmdrunSalomeBatch(
const std::string& machine,
const std::string& DirForTmpFiles ,
- const std::string& FileNameToExecute ) {
+ const std::string& FileNameToExecute ) throw(SALOME_Exception)
+{
BEGIN_OF("SALOME_ResourcesManager::BuildCmdrunSalomeBatch");
+ int status;
_TmpFileName = BuildTemporaryFileName();
ofstream tempOutputFile;
tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
tempOutputFile << " sleep 1" << endl ;
tempOutputFile << " ./runSession waitContainers.py $arglist" << endl ;
tempOutputFile << " ./runSession python ~/" << DirForTmpFiles << "/" << FileNameToExecute << ".py" << endl;
+ tempOutputFile << " ./runSession shutdownSalome.py" << endl;
tempOutputFile << "else" << endl ;
tempOutputFile << " sleep 1" << endl ;
tempOutputFile << " ./runSession waitNS.py" << endl ;
command += "/runSalome_" ;
command += FileNameToExecute ;
command += "_Batch.sh" ;
- system(command.c_str());
+ SCRUTE(command.c_str());
+ status = system(command.c_str());
+ if(status)
+ throw SALOME_Exception("Error of connection on remote host");
RmTmpFile();
END_OF("SALOME_ResourcesManager::BuildCmdrunSalomeBatch");
const std::string& machine,
const long NumberOfProcessors,
const std::string& DirForTmpFiles ,
- const std::string& FileNameToExecute ) {
+ const std::string& FileNameToExecute ) throw(SALOME_Exception)
+{
BEGIN_OF("SALOME_ResourcesManager::BuildCmdFileNameToExecute_Batch");
+ int status;
_TmpFileName = BuildTemporaryFileName();
ofstream tempOutputFile;
tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
command += "/" ;
command += FileNameToExecute ;
command += "_Batch.sh" ;
- system(command.c_str());
+ SCRUTE(command.c_str());
+ status = system(command.c_str());
+ if(status)
+ throw SALOME_Exception("Error of connection on remote host");
RmTmpFile();
END_OF("SALOME_ResourcesManager::BuildCmdFileNameToExecute_Batch");
std::string SALOME_ResourcesManager::BuildCmdFileNameToExecute_bsub(
const std::string& machine,
const std::string& DirForTmpFiles ,
- const std::string& FileNameToExecute ) {
+ const std::string& FileNameToExecute ) throw(SALOME_Exception)
+{
BEGIN_OF("SALOME_ResourcesManager::BuildCmdFileNameToExecute_bsub");
_TmpFileName = BuildTemporaryFileName();
+ int status;
ofstream tempOutputFile;
tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
const ParserResourcesType& resInfo = _resourcesList[machine];
command += "/" ;
command += FileNameToExecute ;
command += "_bsub.sh" ;
- system(command.c_str());
+ SCRUTE(command.c_str());
+ status = system(command.c_str());
+ if(status)
+ throw SALOME_Exception("Error of connection on remote host");
+
RmTmpFile();
END_OF("SALOME_ResourcesManager::BuildCmdFileNameToExecute_bsub");
std::string SALOME_ResourcesManager::CmdToExecute_bsub(
const std::string& machine,
const std::string& DirForTmpFiles ,
- const std::string& FileNameToExecute ) {
+ const std::string& FileNameToExecute ) throw(SALOME_Exception)
+{
BEGIN_OF("SALOME_ResourcesManager::CmdToExecute_bsub");
const ParserResourcesType& resInfo = _resourcesList[machine];
string command;
- resInfo.Print() ;
+ resInfo.Print();
+ int status;
if (resInfo.Protocol == rsh)
command = "rsh " ;
command += "/" ;
command += FileNameToExecute ;
command += "_bsub.sh\"" ;
- system(command.c_str());
+ SCRUTE(command.c_str());
+ status = system(command.c_str());
+ if(status)
+ throw SALOME_Exception("Error of connection on remote host");
+
END_OF("SALOME_ResourcesManager::CmdToExecute_bsub");
return command;
string
SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer
(const string& machine,
- const Engines::MachineParameters& params)
+ const Engines::MachineParameters& params) throw(SALOME_Exception)
{
+ int status;
+
_TmpFileName = BuildTemporaryFileName();
ofstream tempOutputFile;
tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
commandRcp += machine;
commandRcp += ":";
commandRcp += _TmpFileName;
- system(commandRcp.c_str());
+ status = system(commandRcp.c_str());
}
else if (resInfo.Protocol == ssh)
commandRcp += machine;
commandRcp += ":";
commandRcp += _TmpFileName;
- system(commandRcp.c_str());
+ status = system(commandRcp.c_str());
}
else
throw SALOME_Exception("Unknown protocol");
+ if(status)
+ throw SALOME_Exception("Error of connection on remote host");
+
command += machine;
_CommandForRemAccess = command;
command += " ";
void CopyFileNamesToExecute(const std::string& machine,
const std::string& DirForTmpFiles ,
const std::string& PathFileNameToExecute ,
- const Engines::FilesToExportList& filesToExport) ;
+ const Engines::FilesToExportList& filesToExport) throw(SALOME_Exception);
std::string BuildCmdrunSalomeBatch(const std::string& machine,
const std::string& DirForTmpFiles ,
- const std::string& FileNameToExecute ) ;
+ const std::string& FileNameToExecute ) throw(SALOME_Exception);
std::string BuildCmdFileNameToExecute_Batch(const std::string& machine,
const long NumberOfProcessors,
const std::string& DirForTmpFiles ,
- const std::string& FileNameToExecute ) ;
+ const std::string& FileNameToExecute ) throw(SALOME_Exception);
std::string BuildCmdFileNameToExecute_bsub(const std::string& machine,
const std::string& DirForTmpFiles ,
- const std::string& FileNameToExecute ) ;
+ const std::string& FileNameToExecute ) throw(SALOME_Exception);
std::string CmdToExecute_bsub(const std::string& machine,
const std::string& DirForTmpFiles ,
- const std::string& FileNameToExecute ) ;
+ const std::string& FileNameToExecute ) throw(SALOME_Exception);
std::string BuildCommandToLaunchLocalContainer
(const Engines::MachineParameters& params, const long id);
std::string BuildTempFileToLaunchRemoteContainer
(const std::string& machine,
- const Engines::MachineParameters& params);
+ const Engines::MachineParameters& params) throw(SALOME_Exception);
void SelectOnlyResourcesWithOS(std::vector<std::string>& hosts,
const char *OS) const