From e2bfe5b5ff0c096fcd5e3d4479af7549dc6939a1 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Wed, 14 Apr 2021 22:28:14 +0200 Subject: [PATCH] ContainerManager est dispo en mode SSL --- src/Container/SALOME_ContainerManager.cxx | 14 ++-- src/Container/SALOME_ContainerManager.hxx | 8 +-- src/KERNEL_PY/__init__.py | 4 +- src/Launcher/SALOME_Launcher.cxx | 4 +- src/Launcher/SALOME_Launcher.hxx | 2 - .../SALOME_Fake_NamingService.cxx | 5 ++ .../SALOME_Fake_NamingService.hxx | 1 + src/NamingService/SALOME_NamingService.cxx | 64 ------------------- src/NamingService/SALOME_NamingService.hxx | 6 +- .../SALOME_NamingService_Abstract.cxx | 60 +++++++++++++++++ .../SALOME_NamingService_Abstract.hxx | 7 +- .../SALOME_ResourcesManager.cxx | 4 +- .../SALOME_ResourcesManager.hxx | 8 +-- .../SALOME_ResourcesManager_Client.cxx | 3 +- .../SALOME_ResourcesManager_Client.hxx | 4 +- 15 files changed, 101 insertions(+), 93 deletions(-) diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 4129ea512..dd86a4925 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -81,7 +81,7 @@ Utils_Mutex SALOME_ContainerManager::_systemMutex; */ //============================================================================= -SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns) +SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *ns) : _nbprocUsed(1) { MESSAGE("constructor"); @@ -951,11 +951,15 @@ void SALOME_ContainerManager::AddOmninamesParams(std::ostream& fileStream) const */ //============================================================================= -void SALOME_ContainerManager::AddOmninamesParams(std::ostream& fileStream, SALOME_NamingService *ns) +void SALOME_ContainerManager::AddOmninamesParams(std::ostream& fileStream, SALOME_NamingService_Abstract *ns) { - CORBA::String_var iorstr(ns->getIORaddr()); - fileStream << "ORBInitRef NameService="; - fileStream << iorstr; + SALOME_NamingService *nsTrad(dynamic_cast(ns)); + if(ns) + { + CORBA::String_var iorstr(nsTrad->getIORaddr()); + fileStream << "ORBInitRef NameService="; + fileStream << iorstr; + } } void SALOME_ContainerManager::MakeTheCommandToBeLaunchedASync(std::string& command) diff --git a/src/Container/SALOME_ContainerManager.hxx b/src/Container/SALOME_ContainerManager.hxx index 946b6c8d4..0a5fd143f 100644 --- a/src/Container/SALOME_ContainerManager.hxx +++ b/src/Container/SALOME_ContainerManager.hxx @@ -35,14 +35,14 @@ #include #include -class SALOME_NamingService; +class SALOME_NamingService_Abstract; class SALOME_ResourcesManager_Client; class CONTAINER_EXPORT SALOME_ContainerManager : public POA_Engines::ContainerManager { public: - SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns); + SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *ns); ~SALOME_ContainerManager(); // Corba Methods @@ -106,7 +106,7 @@ protected: PortableServer::POA_var _poa; SALOME_ResourcesManager_Client *_resManager; - SALOME_NamingService *_NS; + SALOME_NamingService_Abstract *_NS; //! different behaviour if $APPLI exists (SALOME Application) bool _isAppliSalomeDefined; @@ -163,7 +163,7 @@ public: static std::string GetenvThreadSafeAsString(const char *name); static int SystemThreadSafe(const char *command); static long SystemWithPIDThreadSafe(const std::vector& command); - static void AddOmninamesParams(std::ostream& fileStream, SALOME_NamingService *ns); + static void AddOmninamesParams(std::ostream& fileStream, SALOME_NamingService_Abstract *ns); static void MakeTheCommandToBeLaunchedASync(std::string& command); static int GetTimeOutToLoaunchServer(); static void SleepInSecond(int ellapseTimeInSecond); diff --git a/src/KERNEL_PY/__init__.py b/src/KERNEL_PY/__init__.py index 5952cc924..bbdd1a73d 100644 --- a/src/KERNEL_PY/__init__.py +++ b/src/KERNEL_PY/__init__.py @@ -190,7 +190,7 @@ class StandAloneLifecyle: #raise RuntimeError("Undealed situation cont = {} module = {}".format(contName,moduleName)) def salome_init_without_session(): - global lcc,myStudy,orb,modulcat,sg + global lcc,myStudy,orb,modulcat,sg,cm lcc = StandAloneLifecyle() import KernelDS myStudy = KernelDS.myStudy() @@ -200,6 +200,8 @@ def salome_init_without_session(): import SALOME_ModuleCatalog from salome_kernel import list_of_catalogs_regarding_environement modulcat = KernelModuleCatalog.myModuleCatalog( list_of_catalogs_regarding_environement() ) + import KernelLauncher + cm = KernelLauncher.myContainerManager() # activate poaManager to accept co-localized CORBA calls. poa = orb.resolve_initial_references("RootPOA") poaManager = poa._get_the_POAManager() diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index 6001ca944..e17bca3cd 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -73,9 +73,9 @@ SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa void SALOME_Launcher::init(CORBA::ORB_ptr orb, PortableServer::POA_var poa) { - _ResManager = new SALOME_ResourcesManager(orb,poa,tradNS()); + _ResManager = new SALOME_ResourcesManager(orb,poa,_NS); _l.SetResourcesManager(_ResManager->GetImpl()); - _ContManager = new SALOME_ContainerManager(orb,poa,tradNS()); + _ContManager = new SALOME_ContainerManager(orb,poa,_NS); _ResManager->_remove_ref(); _ContManager->_remove_ref(); diff --git a/src/Launcher/SALOME_Launcher.hxx b/src/Launcher/SALOME_Launcher.hxx index cd72c7a16..2e9b97569 100644 --- a/src/Launcher/SALOME_Launcher.hxx +++ b/src/Launcher/SALOME_Launcher.hxx @@ -86,8 +86,6 @@ public: static Engines::JobParameters_var JobParameters_CPP2CORBA(const JobParameters_cpp& job_parameters); - SALOME_NamingService *tradNS() { return SALOME_NamingService::GetTraditionalNS(_NS); } - protected: // Internal methods virtual void notifyObservers(const std::string & event_name, const std::string & event_data); diff --git a/src/NamingService/SALOME_Fake_NamingService.cxx b/src/NamingService/SALOME_Fake_NamingService.cxx index f521034a2..658058c61 100644 --- a/src/NamingService/SALOME_Fake_NamingService.cxx +++ b/src/NamingService/SALOME_Fake_NamingService.cxx @@ -65,6 +65,11 @@ std::vector SALOME_Fake_NamingService::list_directory() return std::vector(); } +std::vector SALOME_Fake_NamingService::list_directory_recurs() +{ + return std::vector(); +} + CORBA::Object_ptr SALOME_Fake_NamingService::Resolve(const char* Path) { std::string pathCpp(Path); diff --git a/src/NamingService/SALOME_Fake_NamingService.hxx b/src/NamingService/SALOME_Fake_NamingService.hxx index f60e1480e..32ae31d3e 100644 --- a/src/NamingService/SALOME_Fake_NamingService.hxx +++ b/src/NamingService/SALOME_Fake_NamingService.hxx @@ -42,6 +42,7 @@ public: bool Change_Directory(const char* Path) override; std::vector list_subdirs() override; std::vector list_directory() override; + std::vector list_directory_recurs() override; SALOME_NamingService_Abstract *clone() override; CORBA::Object_ptr ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc=0) override; private: diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index 47be7be07..8e4b40517 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -92,12 +92,6 @@ SALOME_NamingService::~SALOME_NamingService() //MESSAGE("SALOME_NamingService destruction"); } -SALOME_NamingService *SALOME_NamingService::GetTraditionalNS(SALOME_NamingService_Abstract *ns) -{ - SALOME_NamingService *nsc(dynamic_cast(ns)); - return nsc; -} - // ============================================================================ /*! \brief initializes ORB reference and naming service root context. * @@ -559,64 +553,6 @@ SALOME_NamingService::ResolveComponent(const char* hostname, } } -// ============================================================================ -/*! \brief build a container name, given a ContainerParameters struct. - * - * Build a container name with a ContainerParameters struct. In case of multi - * processor machine, container name is suffixed with number of processors. - * \param params struct from which we get container name (may be empty) and - * number of processors. - * \return a container name without the path. - * \sa BuildContainerNameForNS(const Engines::ContainerParameters& params, - * const char *hostname) - */ -// ============================================================================ - -std::string SALOME_NamingService::ContainerName(const Engines::ContainerParameters& params) -{ - int nbproc; - - if ( !params.isMPI ) - nbproc = 0; - else if ( params.nb_proc <= 0 ) - nbproc = 1; - else - nbproc = params.nb_proc; - - std::string ret(SALOME_NamingService_Abstract::ContainerName(params.container_name)); - - if ( nbproc >= 1 ) - { - std::ostringstream suffix; - suffix << "_" << nbproc; - ret += suffix.str(); - } - - return ret; -} - -// ============================================================================ -/*! \brief build a string representing a container in Naming Service. - * - * Build a string representing the absolute pathname of a container in - * SALOME_NamingService. - * \param params used as it is, or replaced by FactoryServer if empty. - * \param hostname name of the host of the container, without domain names. - * \return the path under the form /Containers/hostname/containerName - * \sa ContainerName(const char *containerName) - */ -// ============================================================================ - -std::string SALOME_NamingService::BuildContainerNameForNS(const Engines::ContainerParameters& params, const char *hostname) -{ - std::string ret("/Containers/"); - ret += hostname; - ret += "/"; - ret += ContainerName(params); - - return ret; -} - // ============================================================================ /*! \brief search a name in current directory. * diff --git a/src/NamingService/SALOME_NamingService.hxx b/src/NamingService/SALOME_NamingService.hxx index 6599e99c8..14380e96f 100644 --- a/src/NamingService/SALOME_NamingService.hxx +++ b/src/NamingService/SALOME_NamingService.hxx @@ -51,8 +51,6 @@ public: SALOME_NamingService(CORBA::ORB_ptr orb); virtual ~SALOME_NamingService(); - - static SALOME_NamingService *GetTraditionalNS(SALOME_NamingService_Abstract *ns); void init_orb(CORBA::ORB_ptr orb=0) override; void Register(CORBA::Object_ptr ObjRef, const char* Path) override; @@ -62,8 +60,6 @@ public: const char* containerName, const char* componentName, const int nbproc=0) override; - std::string ContainerName(const Engines::ContainerParameters& params); - std::string BuildContainerNameForNS(const Engines::ContainerParameters& params, const char *hostname); int Find(const char* name) ; bool Create_Directory(const char* Path) ; @@ -72,7 +68,7 @@ public: void list() ; std::vector list_directory() override; std::vector list_subdirs() override; - std::vector list_directory_recurs() ; + std::vector list_directory_recurs() override ; void Destroy_Name(const char* Path) override; void Destroy_Directory(const char* Path) override; void Destroy_FullDirectory(const char* Path) override; diff --git a/src/NamingService/SALOME_NamingService_Abstract.cxx b/src/NamingService/SALOME_NamingService_Abstract.cxx index 4469dfed1..ff2561b14 100644 --- a/src/NamingService/SALOME_NamingService_Abstract.cxx +++ b/src/NamingService/SALOME_NamingService_Abstract.cxx @@ -19,6 +19,8 @@ #include "SALOME_NamingService_Abstract.hxx" +#include + // ============================================================================ /*! \brief provide a default container name if empty. * @@ -65,3 +67,61 @@ std::string SALOME_NamingService_Abstract::BuildContainerNameForNS(const char *c return ret; } + +// ============================================================================ +/*! \brief build a container name, given a ContainerParameters struct. + * + * Build a container name with a ContainerParameters struct. In case of multi + * processor machine, container name is suffixed with number of processors. + * \param params struct from which we get container name (may be empty) and + * number of processors. + * \return a container name without the path. + * \sa BuildContainerNameForNS(const Engines::ContainerParameters& params, + * const char *hostname) + */ +// ============================================================================ + +std::string SALOME_NamingService_Abstract::ContainerName(const Engines::ContainerParameters& params) +{ + int nbproc; + + if ( !params.isMPI ) + nbproc = 0; + else if ( params.nb_proc <= 0 ) + nbproc = 1; + else + nbproc = params.nb_proc; + + std::string ret(SALOME_NamingService_Abstract::ContainerName(params.container_name)); + + if ( nbproc >= 1 ) + { + std::ostringstream suffix; + suffix << "_" << nbproc; + ret += suffix.str(); + } + + return ret; +} + +// ============================================================================ +/*! \brief build a string representing a container in Naming Service. + * + * Build a string representing the absolute pathname of a container in + * SALOME_NamingService. + * \param params used as it is, or replaced by FactoryServer if empty. + * \param hostname name of the host of the container, without domain names. + * \return the path under the form /Containers/hostname/containerName + * \sa ContainerName(const char *containerName) + */ +// ============================================================================ + +std::string SALOME_NamingService_Abstract::BuildContainerNameForNS(const Engines::ContainerParameters& params, const char *hostname) +{ + std::string ret("/Containers/"); + ret += hostname; + ret += "/"; + ret += ContainerName(params); + + return ret; +} diff --git a/src/NamingService/SALOME_NamingService_Abstract.hxx b/src/NamingService/SALOME_NamingService_Abstract.hxx index ce7301c79..ebf584c3c 100644 --- a/src/NamingService/SALOME_NamingService_Abstract.hxx +++ b/src/NamingService/SALOME_NamingService_Abstract.hxx @@ -21,7 +21,9 @@ #include "SALOME_NamingService_defs.hxx" -#include "omniORB4/CORBA.h" +#include +#include CORBA_CLIENT_HEADER(SALOME_ContainerManager) +#include CORBA_CLIENT_HEADER(SALOME_Component) #include #include @@ -39,9 +41,12 @@ public: virtual bool Change_Directory(const char* Path) = 0; virtual std::vector list_subdirs() = 0; virtual std::vector list_directory() = 0; + virtual std::vector list_directory_recurs() = 0; virtual SALOME_NamingService_Abstract *clone() = 0; virtual CORBA::Object_ptr ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc=0) = 0; virtual ~SALOME_NamingService_Abstract() { } + static std::string ContainerName(const Engines::ContainerParameters& params); static std::string ContainerName(const char *ContainerName); static std::string BuildContainerNameForNS(const char *ContainerName, const char *hostname); + static std::string BuildContainerNameForNS(const Engines::ContainerParameters& params, const char *hostname); }; diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index 1a57e5faf..5b168e265 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -58,7 +58,7 @@ const char *SALOME_ResourcesManager::_ResourcesManagerNameInNS = "/ResourcesMana SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, - SALOME_NamingService *ns, + SALOME_NamingService_Abstract *ns, const char *xmlFilePath) : _rm(new ResourcesManager_cpp(xmlFilePath)) { @@ -94,7 +94,7 @@ SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb, SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, - SALOME_NamingService *ns) : _rm(new ResourcesManager_cpp()) + SALOME_NamingService_Abstract *ns) : _rm(new ResourcesManager_cpp()) { MESSAGE("SALOME_ResourcesManager constructor"); _NS = ns; diff --git a/src/ResourcesManager/SALOME_ResourcesManager.hxx b/src/ResourcesManager/SALOME_ResourcesManager.hxx index e0e362280..e309a3cbf 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.hxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.hxx @@ -26,7 +26,7 @@ #include "Utils_SALOME_Exception.hxx" #include "utilities.h" #include -#include "SALOME_NamingService.hxx" +#include "SALOME_NamingService_Abstract.hxx" #include CORBA_CLIENT_HEADER(SALOME_ContainerManager) #include #include @@ -53,8 +53,8 @@ class SALOMERESOURCESMANAGER_EXPORT SALOME_ResourcesManager: public: - SALOME_ResourcesManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns, const char *xmlFilePath); - SALOME_ResourcesManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns); + SALOME_ResourcesManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *ns, const char *xmlFilePath); + SALOME_ResourcesManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *ns); ~SALOME_ResourcesManager(); @@ -82,7 +82,7 @@ class SALOMERESOURCESMANAGER_EXPORT SALOME_ResourcesManager: static const char *_ResourcesManagerNameInNS; protected: - SALOME_NamingService *_NS; + SALOME_NamingService_Abstract *_NS; CORBA::ORB_var _orb; PortableServer::POA_var _poa; std::shared_ptr _rm; diff --git a/src/ResourcesManager/SALOME_ResourcesManager_Client.cxx b/src/ResourcesManager/SALOME_ResourcesManager_Client.cxx index 63467c13f..e13aeb3f0 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager_Client.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager_Client.cxx @@ -22,10 +22,11 @@ #include "SALOME_ResourcesManager_Client.hxx" #include "SALOME_ResourcesManager.hxx" +#include "SALOME_NamingService_Abstract.hxx" using namespace std; -SALOME_ResourcesManager_Client::SALOME_ResourcesManager_Client(SALOME_NamingService *ns) +SALOME_ResourcesManager_Client::SALOME_ResourcesManager_Client(SALOME_NamingService_Abstract *ns) : _rm(Engines::ResourcesManager::_nil()) { CORBA::Object_var objRM = ns->Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS); diff --git a/src/ResourcesManager/SALOME_ResourcesManager_Client.hxx b/src/ResourcesManager/SALOME_ResourcesManager_Client.hxx index b81fe8b49..792709ade 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager_Client.hxx +++ b/src/ResourcesManager/SALOME_ResourcesManager_Client.hxx @@ -25,7 +25,7 @@ #include "SALOME_ResourcesManager_Common.hxx" -class SALOME_NamingService; +class SALOME_NamingService_Abstract; // This class is fully thread-safe because the ResourcesManager CORBA object // runs in a single-thread POA. @@ -33,7 +33,7 @@ class SALOMERESOURCESMANAGER_EXPORT SALOME_ResourcesManager_Client { public: - SALOME_ResourcesManager_Client(SALOME_NamingService *ns); + SALOME_ResourcesManager_Client(SALOME_NamingService_Abstract *ns); ~SALOME_ResourcesManager_Client(); std::vector GetFittingResources(const resourceParams& params); -- 2.39.2