FieldsDict get_os_environment();
+ void execute_python_code( in string code ) raises(SALOME::SALOME_Exception);
+
/*! \brief Loads a new component class (dynamic library).
\param componentName like COMPONENT, (Python or C++ implementation)
void SetOverrideEnvForContainers(in KeyValDict env);
KeyValDict GetOverrideEnvForContainers();
+
+ void SetCodeOnContainerStartUp(in string code);
} ;
};
#include <time.h>
#include <sys/types.h>
#include <memory>
+#include <vector>
#ifndef WIN32
#include <sys/time.h>
#include <dlfcn.h>
#include "SALOME_Embedded_NamingService.hxx"
#include "Basics_Utils.hxx"
#include "PythonCppUtils.hxx"
+#include "Utils_CorbaException.hxx"
#ifdef _XOPEN_SOURCE
#undef _XOPEN_SOURCE
return ret.release();
}
+void Abstract_Engines_Container_i::execute_python_code(const char *code)
+{
+ AutoGIL gstate;
+ if( PyRun_SimpleString( code ) != 0 )
+ {
+ std::string error = parseException();
+ THROW_SALOME_CORBA_EXCEPTION(error.c_str(),SALOME::INTERNAL_ERROR);
+ }
+}
+
//=============================================================================
//! Create a new component instance with environment variables specified
/*!
CORBA::PolicyList policies;
policies.length(0);
//
- char *argv[4] = {"Container","FactoryServer","toto",nullptr};
+ constexpr int ARGC = 4;
+ constexpr const char *ARGV[ARGC] = {"Container","FactoryServer","toto",nullptr};
+ std::unique_ptr<char*[]> argv( new char *[ARGC+1] );
+ std::vector< std::unique_ptr<char[]> > argvv(ARGC);
+ argv[ARGC] = nullptr;
+ for(int i = 0 ; i < ARGC ; ++i)
+ {
+ if(ARGV[i])
+ {
+ argvv[i].reset( new char[strlen(ARGV[i])+1] );
+ strcpy(argvv[i].get(),ARGV[i]);
+ argv[i] = argvv[i].get();
+ }
+ else
+ argv[i] = nullptr;
+ }
SALOME_Fake_NamingService ns;
- _container_singleton_ssl = new Engines_Container_SSL_i(orb,poa,"FactoryServer",2,argv,&ns,false);
+ _container_singleton_ssl = new Engines_Container_SSL_i(orb,poa,(char *)"FactoryServer",2,argv.get(),&ns,false);
PortableServer::ObjectId * cont_id = _container_singleton_ssl->getCORBAId();
//
CORBA::Object_var zeRef = poa->id_to_reference(*cont_id);
return ret.release();
}
+void SALOME_ContainerManager::SetCodeOnContainerStartUp(const char *code)
+{
+ _code_to_exe_on_startup = code;
+}
+
//=============================================================================
//! Give a suitable Container given constraints
/*! CORBA Method:
}
}
cont->override_environment_python( envCorba );
+ if( !_code_to_exe_on_startup.empty() )
+ cont->execute_python_code( _code_to_exe_on_startup.c_str() );
return cont._retn();
}
else
Engines::KeyValDict *GetOverrideEnvForContainers() override;
+ void SetCodeOnContainerStartUp(const char *code) override;
+
// C++ Methods
void Shutdown();
std::vector< std::pair<std::string, std::string> > _override_env;
int _time_out_in_second;
int _delta_time_ns_lookup_in_ms;
+ std::string _code_to_exe_on_startup;
};
#endif
void override_environment( const Engines::FieldsDict& env ) override;
Engines::FieldsDict *get_os_environment() override;
+
+ void execute_python_code(const char *code) override;
virtual Engines::EngineComponent_ptr
create_component_instance_env(const char *componentName,
contRes = CreateContainerResource(hostname=k,applipath=os.environ["APPLI"],protocol=protocol,nbOfNodes=v)
rmcpp.AddResourceInCatalog(contRes)
+def GetRequestForGiveContainer(hostname, contName):
+ import Engines
+ import os
+ rp=Engines.ResourceParameters(name=hostname,
+ hostname=hostname,
+ can_launch_batch_jobs=False,
+ can_run_containers=True,
+ OS="Linux",
+ componentList=[],
+ nb_proc=1,
+ mem_mb=1000,
+ cpu_clock=1000,
+ nb_node=1,
+ nb_proc_per_node=1,
+ policy="first",
+ resList=[])
+
+ cp=Engines.ContainerParameters(container_name=contName,
+ mode="start",
+ workingdir=os.path.expanduser("~"),
+ nb_proc=1,
+ isMPI=False,
+ parallelLib="",
+ resource_params=rp)
+ return cp
+
ResourceDefinition_cpp.repr = ResourceDefinition_cpp_repr
ResourceDefinition_cpp.__repr__ = ResourceDefinition_cpp_repr
ResourcesManager_cpp.GetList = ResourcesManager_cpp_GetList