#include "SALOME_ContainerManager.hxx"
#include "SALOME_Component_i.hxx"
#include "SALOME_NamingService.hxx"
+#include "SALOME_FileTransferCORBA.hxx"
using namespace std;
{
params.container_name = "";
params.hostname = "";
+ params.alias = "";
+ params.protocol = "";
+ params.username = "";
+ params.applipath = "";
params.OS = "";
params.mem_mb = 0;
params.cpu_clock = 0;
params.nb_proc_per_node = 0;
params.nb_node = 0;
params.isMPI = false;
-
+ params.mpiImpl="";
+ params.batch="";
+ params.workingdir = "";
params.parallelLib = "";
params.nb_component_nodes = 0;
}
return myInstance._retn();
}
+/*! \brief copy a file from a source host to a destination host
+ * \param hostSrc the source host
+ * \param fileSrc the file to copy from the source host to the destination host
+ * \param hostDest the destination host
+ * \param fileDest the destination file
+ */
+void SALOME_LifeCycleCORBA::copyFile(const char* hostSrc, const char* fileSrc, const char* hostDest, const char* fileDest)
+{
+ if(strcmp(hostDest,"localhost") == 0)
+ {
+ //if localhost use a shortcut
+ SALOME_FileTransferCORBA transfer(hostSrc,fileSrc);
+ transfer.getLocalFile(fileDest);
+ return;
+ }
+
+ Engines::ContainerManager_var contManager = getContainerManager();
+
+ Engines::MachineParameters params;
+ preSet(params);
+
+ Engines::MachineList listOfMachines;
+ listOfMachines.length(1);
+
+ params.hostname = hostDest;
+ listOfMachines[0] = hostDest;
+ Engines::Container_var containerDest = contManager->FindOrStartContainer(params, listOfMachines);
+
+ params.hostname = hostSrc;
+ listOfMachines[0] = hostSrc;
+ Engines::Container_var containerSrc = contManager->FindOrStartContainer(params, listOfMachines);
+
+ containerDest->copyFile(containerSrc,fileSrc,fileDest);
+}
+
%feature("autodoc", "1");
%include <std_except.i>
+%include "std_string.i"
// ----------------------------------------------------------------------------
#define PY_SSIZE_T_MIN INT_MIN
#endif
- using namespace std;
+using namespace std;
//--- from omniORBpy.h (not present on Debian Sarge packages)
struct omniORBpyAPI {
PyObject* (*cxxObjRefToPyObjRef)(const CORBA::Object_ptr cxx_obj,
- CORBA::Boolean hold_lock);
+ CORBA::Boolean hold_lock);
// Convert a C++ object reference to a Python object reference.
// If <hold_lock> is true, caller holds the Python interpreter lock.
CORBA::Object_ptr (*pyObjRefToCxxObjRef)(PyObject* py_obj,
- CORBA::Boolean hold_lock);
+ CORBA::Boolean hold_lock);
// Convert a Python object reference to a C++ object reference.
// Raises BAD_PARAM if the Python object is not an object reference.
// If <hold_lock> is true, caller holds the Python interpreter lock.
// Constructor for the singleton. Sets up the function pointers.
};
- omniORBpyAPI* api;
+omniORBpyAPI* api;
%}
PyObject* omnipy = PyImport_ImportModule((char*)"_omnipy");
if (!omnipy)
{
- PyErr_SetString(PyExc_ImportError,
- (char*)"Cannot import _omnipy");
+ PyErr_SetString(PyExc_ImportError, (char*)"Cannot import _omnipy");
return;
}
PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API");
// ----------------------------------------------------------------------------
+using namespace std;
-%typemap(python,out) Engines::Container_ptr, Engines::Component_ptr, Engines::fileRef_ptr
+
+%typemap(out) Engines::Container_ptr, Engines::Component_ptr, Engines::fileRef_ptr,
+ Engines::ContainerManager_ptr, Engines::ResourcesManager_ptr
{
MESSAGE("typemap out on CORBA object ptr");
SCRUTE($1);
SCRUTE($result);
}
-%typemap(python,in) Engines::fileRef_ptr aFileRef
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) Engines::fileRef_ptr
+{
+ $1=PyObject_HasAttrString($input, "__omni_obj");
+}
+
+%typemap(in) Engines::fileRef_ptr aFileRef
{
MESSAGE("typemap in on CORBA object ptr");
try {
}
}
-
-%typemap(python,out) std::string,
- string
-{
- MESSAGE("typemap out on std::string");
- SCRUTE($1);
- $result = PyString_FromString($1.c_str());
-}
-
-%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) Engines::MachineParameters const &
-{
- $1 = PyDict_Check($input)? 1 : 0;
-}
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) const Engines::MachineParameters &
{
$1 = PyDict_Check($input)? 1 : 0;
}
-%typemap(typecheck) std::string,
- string
-{
- $1 = PyString_Check($input);
-}
-
-%typemap(python,in) std::string,
- string
-{
- MESSAGE("typemap in on std::string");
- std::string str;
- if (PyString_Check($input) == 1)
- {
- char* value = PyString_AsString($input);
- str = value;
- $1 = str;
- }
- else
- {
- MESSAGE("Not a string");
- PyErr_SetString(PyExc_TypeError,"Must Be a Python string");
- return NULL;
- }
-}
-
-
-%typemap(python,in) const Engines::MachineParameters &
+%typemap(in) const Engines::MachineParameters &
{
//printf("typemap in on Engines::MachineParameters\n");
MESSAGE("typemap in on Engines::MachineParameters");
if (PyDict_Check($input) == 1)
{
Engines::MachineParameters *param = new Engines::MachineParameters ;
- param->container_name = CORBA::string_dup("");
- param->hostname = CORBA::string_dup("");
- param->OS = CORBA::string_dup("");
- param->mem_mb = 0;
- param->cpu_clock = 0;
- param->nb_proc_per_node = 0;
- param->nb_node = 0;
- param->isMPI = false;
- param->parallelLib = CORBA::string_dup("");
- param->nb_component_nodes = 0;
+ SALOME_LifeCycleCORBA::preSet(*param);
+
PyObject *key, *value;
Py_ssize_t pos = 0;
while (PyDict_Next($input, &pos, &key, &value))
- {
- char* keystr = PyString_AsString(key);
- printf("key: %s\n", keystr);
- if (strcmp(keystr,"container_name")==0)
- {
- param->container_name = CORBA::string_dup(PyString_AsString(value));
- }
- else if (strcmp(keystr,"hostname")==0)
- {
- param->hostname = CORBA::string_dup(PyString_AsString(value));
- }
- else if (strcmp(keystr,"OS")==0)
- {
- param->OS = CORBA::string_dup(PyString_AsString(value));
- }
- else if (strcmp(keystr,"mem_mb")==0)
- {
- param->mem_mb = PyLong_AsLong(value);
- }
- else if (strcmp(keystr,"cpu_clock")==0)
- {
- param->cpu_clock = PyLong_AsLong(value);
- }
- else if (strcmp(keystr,"nb_proc_per_node")==0)
- {
- param->nb_proc_per_node = PyLong_AsLong(value);
- }
- else if (strcmp(keystr,"nb_node")==0)
- {
- param->nb_node = PyLong_AsLong(value);
- }
- else if (strcmp(keystr,"isMPI")==0)
- {
- param->isMPI = PyLong_AsLong(value);
- }
- else if (strcmp(keystr,"parallelLib")==0)
- {
- param->parallelLib = CORBA::string_dup(PyString_AsString(value));
- }
- else if (strcmp(keystr,"nb_component_nodes")==0)
- {
- param->nb_component_nodes = PyLong_AsLong(value);
- }
- }
+ {
+ char* keystr = PyString_AsString(key);
+ if (strcmp(keystr,"container_name")==0)
+ {
+ param->container_name = CORBA::string_dup(PyString_AsString(value));
+ }
+ else if (strcmp(keystr,"hostname")==0)
+ {
+ param->hostname = CORBA::string_dup(PyString_AsString(value));
+ }
+ else if (strcmp(keystr,"alias")==0)
+ param->alias = CORBA::string_dup(PyString_AsString(value));
+ else if (strcmp(keystr,"protocol")==0)
+ param->protocol = CORBA::string_dup(PyString_AsString(value));
+ else if (strcmp(keystr,"username")==0)
+ param->username = CORBA::string_dup(PyString_AsString(value));
+ else if (strcmp(keystr,"applipath")==0)
+ param->applipath = CORBA::string_dup(PyString_AsString(value));
+ else if (strcmp(keystr,"OS")==0)
+ {
+ param->OS = CORBA::string_dup(PyString_AsString(value));
+ }
+ else if (strcmp(keystr,"mem_mb")==0)
+ {
+ param->mem_mb = PyLong_AsLong(value);
+ }
+ else if (strcmp(keystr,"cpu_clock")==0)
+ {
+ param->cpu_clock = PyLong_AsLong(value);
+ }
+ else if (strcmp(keystr,"nb_proc_per_node")==0)
+ {
+ param->nb_proc_per_node = PyLong_AsLong(value);
+ }
+ else if (strcmp(keystr,"nb_node")==0)
+ {
+ param->nb_node = PyLong_AsLong(value);
+ }
+ else if (strcmp(keystr,"isMPI")==0)
+ {
+ param->isMPI = PyLong_AsLong(value);
+ }
+ else if (strcmp(keystr,"mpiImpl")==0)
+ param->mpiImpl = CORBA::string_dup(PyString_AsString(value));
+ else if (strcmp(keystr,"batch")==0)
+ param->batch = CORBA::string_dup(PyString_AsString(value));
+ else if (strcmp(keystr,"workingdir")==0)
+ param->workingdir = CORBA::string_dup(PyString_AsString(value));
+ else if (strcmp(keystr,"parallelLib")==0)
+ {
+ param->parallelLib = CORBA::string_dup(PyString_AsString(value));
+ }
+ else if (strcmp(keystr,"nb_component_nodes")==0)
+ {
+ param->nb_component_nodes = PyLong_AsLong(value);
+ }
+ }
$1 = param;
}
else
}
-%typemap(python,freearg) const Engines::MachineParameters &
+%typemap(freearg) const Engines::MachineParameters &
{
MESSAGE("delete $1");
delete $1;