Loading src/Configuration.h +67 −41 Original line number Diff line number Diff line Loading @@ -19,12 +19,16 @@ private: //------------------------------------------------------------------------------ // [Private] Constructor destructor deleter //------------------------------------------------------------------------------ Configuration(std::string address, unsigned int port, unsigned int workerNumber, bool enableSSL, std::string certificateFile, std::string privateKeyFile, std::string dHTempFile) : m_address(address), m_port(port), m_workerNumber(workerNumber), m_enableSSL(enableSSL), Configuration(std::string certificateFile, std::string privateKeyFile, std::string dHTempFile, std::string localHost, unsigned int localPort, unsigned int workerNumber, std::string databaseHost, unsigned int databasePort, std::string databaseUsername, std::string databasePassword) : m_certificateFile(certificateFile), m_privateKeyFile(privateKeyFile), m_dHTempFile(dHTempFile) {} m_dHTempFile(dHTempFile), m_localHost(localHost), m_localPort(localPort), m_workerNumber(workerNumber), m_databaseHost(databaseHost), m_databasePort(databasePort), m_databaseUsername(databaseUsername), m_databasePassword(databasePassword) {} virtual ~Configuration() {} class Deleter; Loading @@ -39,41 +43,36 @@ public: //------------------------------------------------------------------------------ // [Public] User methods //------------------------------------------------------------------------------ static Configuration::SP create(std::string address, unsigned int port, unsigned int workerNumber, bool enableSSL, std::string certificateFile, std::string privateKeyFile, std::string dHTempFile) static Configuration::SP create(std::string certificateFile, std::string privateKeyFile, std::string dHTempFile, std::string localHost, unsigned int localPort, unsigned int workerNumber, std::string databaseHost, unsigned int databasePort, std::string databaseUsername, std::string databasePassword) { Configuration::SP c_sp(new Configuration(address, port, workerNumber, enableSSL, certificateFile, privateKeyFile, dHTempFile), Configuration::SP c_sp(new Configuration(certificateFile, privateKeyFile, dHTempFile, localHost, localPort, workerNumber, databaseHost, databasePort, databaseUsername, databasePassword), Configuration::Deleter()); return c_sp; } std::string getAddress() const { return m_address; } unsigned int getPort() const { return m_port; } unsigned short getWorkerNumber() const { return m_workerNumber; } bool isSSLEnbled() const { return m_enableSSL; } std::string getCertificateFile() const { return m_certificateFile; } std::string getPrivateKeyFile() const { return m_privateKeyFile; } std::string getDHTempFile() const { return m_dHTempFile; } std::string getCertificateFile() const { return m_certificateFile; }; std::string getPrivateKeyFile() const { return m_privateKeyFile; }; std::string getDHTempFile() const { return m_dHTempFile; }; std::string getLocalHost() const { return m_localHost; }; unsigned int getLocalPort() const { return m_localPort; }; unsigned int getWorkerNumber() const { return m_workerNumber; }; std::string getDatabaseHost() const { return m_databaseHost; }; unsigned int getDatabasePort() const { return m_databasePort; }; std::string getDatabaseUsername() const { return m_databaseUsername; }; std::string getDatabasePassword() const { return m_databasePassword; }; private: //------------------------------------------------------------------------------ // [Private] class variables //------------------------------------------------------------------------------ //Address used for wait incoming connection const std::string m_address; //Port used for wait incoming connection const unsigned int m_port; //Number of threads that call io service run methods const unsigned short m_workerNumber; //Enable or disable SSL connections const bool m_enableSSL; //Absolute path to certificate chain file const std::string m_certificateFile; Loading @@ -83,6 +82,33 @@ private: //Absolute path to Diffie Hellman temporary file const std::string m_dHTempFile; //Local host address for incoming connection const std::string m_localHost; //Local port for wait incoming connection const unsigned int m_localPort; //Number of threads that call io service run methods const unsigned int m_workerNumber; //Metadata database host const std::string m_databaseHost; //Metadata database port const unsigned int m_databasePort; //Metadata database login username const std::string m_databaseUsername; //Metadata database login password const std::string m_databasePassword; //TODO: Tables exporter from database: one table per row std::vector<std::string> m_exportedTables; //TODO: Authorised user list: one user per row std::vector<std::string> m_authorisedUsers; }; } //End of namespace Loading src/MetadataExporter.cpp +120 −24 Original line number Diff line number Diff line Loading @@ -152,8 +152,9 @@ void MetadataExporter::init_device() if(get_state() != Tango::FAULT) { Configuration::SP configuration_sp = Configuration::create(address, port, workerNumber, enableSSL, certificateFile, privateKeyFile, dHTempFile); Configuration::SP configuration_sp = Configuration::create(certificateFile, privateKeyFile, dHTempFile, localHost, localPort, workerNumber, databaseHost, databasePort, databaseUsername, databasePassword); try { Loading Loading @@ -199,10 +200,16 @@ void MetadataExporter::get_device_property() dev_prop.push_back(Tango::DbDatum("CertificateFile")); dev_prop.push_back(Tango::DbDatum("PrivateKeyFile")); dev_prop.push_back(Tango::DbDatum("DHTempFile")); dev_prop.push_back(Tango::DbDatum("Address")); dev_prop.push_back(Tango::DbDatum("Port")); dev_prop.push_back(Tango::DbDatum("LocalHost")); dev_prop.push_back(Tango::DbDatum("LocalPort")); dev_prop.push_back(Tango::DbDatum("WorkerNumber")); dev_prop.push_back(Tango::DbDatum("EnableSSL")); dev_prop.push_back(Tango::DbDatum("DatabaseHost")); dev_prop.push_back(Tango::DbDatum("DatabasePort")); dev_prop.push_back(Tango::DbDatum("DatabaseUsername")); dev_prop.push_back(Tango::DbDatum("DatabasePassword")); dev_prop.push_back(Tango::DbDatum("ExportedTables")); dev_prop.push_back(Tango::DbDatum("AuthorisedUsers")); // is there at least one property to be read ? if (dev_prop.size()>0) Loading Loading @@ -250,27 +257,27 @@ void MetadataExporter::get_device_property() // And try to extract DHTempFile value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> dHTempFile; // Try to initialize Address from class property // Try to initialize LocalHost from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> address; if (cl_prop.is_empty()==false) cl_prop >> localHost; else { // Try to initialize Address from default device value // Try to initialize LocalHost from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> address; if (def_prop.is_empty()==false) def_prop >> localHost; } // And try to extract Address value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> address; // And try to extract LocalHost value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> localHost; // Try to initialize Port from class property // Try to initialize LocalPort from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> port; if (cl_prop.is_empty()==false) cl_prop >> localPort; else { // Try to initialize Port from default device value // Try to initialize LocalPort from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> port; if (def_prop.is_empty()==false) def_prop >> localPort; } // And try to extract Port value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> port; // And try to extract LocalPort value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> localPort; // Try to initialize WorkerNumber from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); Loading @@ -294,19 +301,85 @@ void MetadataExporter::get_device_property() // And try to extract EnableSSL value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> enableSSL; // Try to initialize DatabaseHost from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> databaseHost; else { // Try to initialize DatabaseHost from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> databaseHost; } // And try to extract DatabaseHost value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> databaseHost; // Try to initialize DatabasePort from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> databasePort; else { // Try to initialize DatabasePort from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> databasePort; } // And try to extract DatabasePort value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> databasePort; // Try to initialize DatabaseUsername from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> databaseUsername; else { // Try to initialize DatabaseUsername from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> databaseUsername; } // And try to extract DatabaseUsername value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> databaseUsername; // Try to initialize DatabasePassword from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> databasePassword; else { // Try to initialize DatabasePassword from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> databasePassword; } // And try to extract DatabasePassword value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> databasePassword; // Try to initialize ExportedTables from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> exportedTables; else { // Try to initialize ExportedTables from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> exportedTables; } // And try to extract ExportedTables value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> exportedTables; // Try to initialize AuthorisedUsers from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> authorisedUsers; else { // Try to initialize AuthorisedUsers from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> authorisedUsers; } // And try to extract AuthorisedUsers value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> authorisedUsers; } /*----- PROTECTED REGION ID(MetadataExporter::get_device_property_after) ENABLED START -----*/ try { if(address.empty()) throw(invalid_argument("Address property is empty or not defined")); if(localHost.empty()) throw(invalid_argument("LocalHost property is empty or not defined")); if(port<1 || port>MAX_DMDB_PORT) throw(invalid_argument("Port property out of range or not defined")); if(localPort<1 || localPort>MAX_LOCAL_PORT) throw(invalid_argument("LocalPort property out of range or not defined")); if(workerNumber<MIN_WORKER_NUMBER || workerNumber>MAX_WORKER_NUMBER) if(workerNumber<1 || workerNumber>MAX_WORKER_NUMBER) throw(invalid_argument("WorkerNumber property out of range or not defined")); if(enableSSL) Loading @@ -320,12 +393,30 @@ void MetadataExporter::get_device_property() if(dHTempFile.empty()) throw(invalid_argument("DHTempFile property is empty or not defined")); } if(databaseHost.empty()) throw(invalid_argument("DatabaseHost property is empty or not defined")); if(databasePort<1 || databasePort>MAX_DB_PORT) throw(invalid_argument("DatabasePort property is empty or not defined")); if(databaseUsername.empty()) throw(invalid_argument("DatabaseUsername property is empty or not defined")); if(databasePassword.empty()) throw(invalid_argument("DatabasePassword property is empty or not defined")); if(exportedTables.empty()) throw(invalid_argument("ExportedTables property is empty or not defined")); if(authorisedUsers.empty()) throw(invalid_argument("AuthorisedUsers property is empty or not defined")); } catch(invalid_argument& ex) { set_state(Tango::FAULT); stringstream error_stream; error_stream << "FitsImporter::get_device_property() " << ex.what() << endl; error_stream << "MetadataExporter::get_device_property() " << ex.what() << endl; set_status(error_stream.str()); } Loading @@ -340,12 +431,17 @@ void MetadataExporter::get_device_property() //-------------------------------------------------------- void MetadataExporter::always_executed_hook() { DEBUG_STREAM << "MetadataExporter::always_executed_hook() " << device_name << endl; INFO_STREAM << "MetadataExporter::always_executed_hook() " << device_name << endl; /*----- PROTECTED REGION ID(MetadataExporter::always_executed_hook) ENABLED START -----*/ if(get_state() != Tango::FAULT) { //TODO: state and status if(m_server_sp) { set_state(m_server_sp->readState()); set_status(m_server_sp->readStatus()); } } /*----- PROTECTED REGION END -----*/ // MetadataExporter::always_executed_hook Loading src/MetadataExporter.h +33 −10 Original line number Diff line number Diff line Loading @@ -42,6 +42,8 @@ #include <tango.h> #include <map> /*----- PROTECTED REGION END -----*/ // MetadataExporter.h /** Loading @@ -65,17 +67,24 @@ class MetadataExporter : public TANGO_BASE_CLASS //------------------------------------------------------------------------------ // [Private] Class variables //------------------------------------------------------------------------------ //Server base class shared pointer Server::SP m_server_sp; //Max port number allowed value static const unsigned int MAX_DMDB_PORT = 65535; //Min number of worker thread allowed static const unsigned int MIN_WORKER_NUMBER = 1; //Max local port number allowed value static const unsigned int MAX_LOCAL_PORT = 65535; //Max number of worker thread allowed static const unsigned int MAX_WORKER_NUMBER = 100; //Max database port number allowed value static const unsigned int MAX_DB_PORT = 65535; //Exported tables map std::map<std::string, std::string> m_exportedTableMap; //Authorised user password map std::map<std::string, std::string> m_authorisedUserMap; /*----- PROTECTED REGION END -----*/ // MetadataExporter::Data Members // Device property data members Loading @@ -86,14 +95,28 @@ public: string privateKeyFile; // DHTempFile: Absolute path to Diffie Hellman temporary file string dHTempFile; // Address: Address used for wait incoming connection string address; // Port: Port used for wait incoming connection Tango::DevULong port; // LocalHost: Local host address for incoming connection string localHost; // LocalPort: Local port for wait incoming connection Tango::DevULong localPort; // WorkerNumber: Number of threads that call io service run methods Tango::DevUShort workerNumber; // EnableSSL: Enable or disable SSL connections Tango::DevBoolean enableSSL; // DatabaseHost: Metadata database host string databaseHost; // DatabasePort: Metadata database port Tango::DevULong databasePort; // DatabaseUsername: Metadata database login username string databaseUsername; // DatabasePassword: Metadata database login password string databasePassword; // ExportedTables: Tables exporter from database: one table per row // [schema table] vector<string> exportedTables; // AuthorisedUsers: Authorised user list: one user per row // [username password] vector<string> authorisedUsers; // Constructors and destructors Loading src/MetadataExporter.xmi +34 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,14 @@ <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </classProperties> <classProperties name="ExportedTables" description="Tables exporter from database: one table per row
[schema table]"> <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </classProperties> <classProperties name="AuthorisedUsers" description="Authorised user list: one user per row
[username password]"> <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </classProperties> <deviceProperties name="CertificateFile" description="Absolute path to certificate chain file"> <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> Loading @@ -29,11 +37,11 @@ <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <deviceProperties name="Address" description="Address used for wait incoming connection"> <deviceProperties name="LocalHost" description="Local host address for incoming connection"> <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <deviceProperties name="Port" description="Port used for wait incoming connection"> <deviceProperties name="LocalPort" description="Local port for wait incoming connection"> <type xsi:type="pogoDsl:UIntType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> Loading @@ -47,6 +55,30 @@ <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <DefaultPropValue>0</DefaultPropValue> </deviceProperties> <deviceProperties name="DatabaseHost" description="Metadata database host"> <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <deviceProperties name="DatabasePort" description="Metadata database port"> <type xsi:type="pogoDsl:UIntType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <deviceProperties name="DatabaseUsername" description="Metadata database login username"> <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <deviceProperties name="DatabasePassword" description="Metadata database login password"> <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <deviceProperties name="ExportedTables" description="Tables exporter from database: one table per row
[schema table]"> <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <deviceProperties name="AuthorisedUsers" description="Authorised user list: one user per row
[username password]"> <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0"> <argin description="none"> <type xsi:type="pogoDsl:VoidType"/> Loading src/MetadataExporterClass.cpp +134 −4 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
src/Configuration.h +67 −41 Original line number Diff line number Diff line Loading @@ -19,12 +19,16 @@ private: //------------------------------------------------------------------------------ // [Private] Constructor destructor deleter //------------------------------------------------------------------------------ Configuration(std::string address, unsigned int port, unsigned int workerNumber, bool enableSSL, std::string certificateFile, std::string privateKeyFile, std::string dHTempFile) : m_address(address), m_port(port), m_workerNumber(workerNumber), m_enableSSL(enableSSL), Configuration(std::string certificateFile, std::string privateKeyFile, std::string dHTempFile, std::string localHost, unsigned int localPort, unsigned int workerNumber, std::string databaseHost, unsigned int databasePort, std::string databaseUsername, std::string databasePassword) : m_certificateFile(certificateFile), m_privateKeyFile(privateKeyFile), m_dHTempFile(dHTempFile) {} m_dHTempFile(dHTempFile), m_localHost(localHost), m_localPort(localPort), m_workerNumber(workerNumber), m_databaseHost(databaseHost), m_databasePort(databasePort), m_databaseUsername(databaseUsername), m_databasePassword(databasePassword) {} virtual ~Configuration() {} class Deleter; Loading @@ -39,41 +43,36 @@ public: //------------------------------------------------------------------------------ // [Public] User methods //------------------------------------------------------------------------------ static Configuration::SP create(std::string address, unsigned int port, unsigned int workerNumber, bool enableSSL, std::string certificateFile, std::string privateKeyFile, std::string dHTempFile) static Configuration::SP create(std::string certificateFile, std::string privateKeyFile, std::string dHTempFile, std::string localHost, unsigned int localPort, unsigned int workerNumber, std::string databaseHost, unsigned int databasePort, std::string databaseUsername, std::string databasePassword) { Configuration::SP c_sp(new Configuration(address, port, workerNumber, enableSSL, certificateFile, privateKeyFile, dHTempFile), Configuration::SP c_sp(new Configuration(certificateFile, privateKeyFile, dHTempFile, localHost, localPort, workerNumber, databaseHost, databasePort, databaseUsername, databasePassword), Configuration::Deleter()); return c_sp; } std::string getAddress() const { return m_address; } unsigned int getPort() const { return m_port; } unsigned short getWorkerNumber() const { return m_workerNumber; } bool isSSLEnbled() const { return m_enableSSL; } std::string getCertificateFile() const { return m_certificateFile; } std::string getPrivateKeyFile() const { return m_privateKeyFile; } std::string getDHTempFile() const { return m_dHTempFile; } std::string getCertificateFile() const { return m_certificateFile; }; std::string getPrivateKeyFile() const { return m_privateKeyFile; }; std::string getDHTempFile() const { return m_dHTempFile; }; std::string getLocalHost() const { return m_localHost; }; unsigned int getLocalPort() const { return m_localPort; }; unsigned int getWorkerNumber() const { return m_workerNumber; }; std::string getDatabaseHost() const { return m_databaseHost; }; unsigned int getDatabasePort() const { return m_databasePort; }; std::string getDatabaseUsername() const { return m_databaseUsername; }; std::string getDatabasePassword() const { return m_databasePassword; }; private: //------------------------------------------------------------------------------ // [Private] class variables //------------------------------------------------------------------------------ //Address used for wait incoming connection const std::string m_address; //Port used for wait incoming connection const unsigned int m_port; //Number of threads that call io service run methods const unsigned short m_workerNumber; //Enable or disable SSL connections const bool m_enableSSL; //Absolute path to certificate chain file const std::string m_certificateFile; Loading @@ -83,6 +82,33 @@ private: //Absolute path to Diffie Hellman temporary file const std::string m_dHTempFile; //Local host address for incoming connection const std::string m_localHost; //Local port for wait incoming connection const unsigned int m_localPort; //Number of threads that call io service run methods const unsigned int m_workerNumber; //Metadata database host const std::string m_databaseHost; //Metadata database port const unsigned int m_databasePort; //Metadata database login username const std::string m_databaseUsername; //Metadata database login password const std::string m_databasePassword; //TODO: Tables exporter from database: one table per row std::vector<std::string> m_exportedTables; //TODO: Authorised user list: one user per row std::vector<std::string> m_authorisedUsers; }; } //End of namespace Loading
src/MetadataExporter.cpp +120 −24 Original line number Diff line number Diff line Loading @@ -152,8 +152,9 @@ void MetadataExporter::init_device() if(get_state() != Tango::FAULT) { Configuration::SP configuration_sp = Configuration::create(address, port, workerNumber, enableSSL, certificateFile, privateKeyFile, dHTempFile); Configuration::SP configuration_sp = Configuration::create(certificateFile, privateKeyFile, dHTempFile, localHost, localPort, workerNumber, databaseHost, databasePort, databaseUsername, databasePassword); try { Loading Loading @@ -199,10 +200,16 @@ void MetadataExporter::get_device_property() dev_prop.push_back(Tango::DbDatum("CertificateFile")); dev_prop.push_back(Tango::DbDatum("PrivateKeyFile")); dev_prop.push_back(Tango::DbDatum("DHTempFile")); dev_prop.push_back(Tango::DbDatum("Address")); dev_prop.push_back(Tango::DbDatum("Port")); dev_prop.push_back(Tango::DbDatum("LocalHost")); dev_prop.push_back(Tango::DbDatum("LocalPort")); dev_prop.push_back(Tango::DbDatum("WorkerNumber")); dev_prop.push_back(Tango::DbDatum("EnableSSL")); dev_prop.push_back(Tango::DbDatum("DatabaseHost")); dev_prop.push_back(Tango::DbDatum("DatabasePort")); dev_prop.push_back(Tango::DbDatum("DatabaseUsername")); dev_prop.push_back(Tango::DbDatum("DatabasePassword")); dev_prop.push_back(Tango::DbDatum("ExportedTables")); dev_prop.push_back(Tango::DbDatum("AuthorisedUsers")); // is there at least one property to be read ? if (dev_prop.size()>0) Loading Loading @@ -250,27 +257,27 @@ void MetadataExporter::get_device_property() // And try to extract DHTempFile value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> dHTempFile; // Try to initialize Address from class property // Try to initialize LocalHost from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> address; if (cl_prop.is_empty()==false) cl_prop >> localHost; else { // Try to initialize Address from default device value // Try to initialize LocalHost from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> address; if (def_prop.is_empty()==false) def_prop >> localHost; } // And try to extract Address value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> address; // And try to extract LocalHost value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> localHost; // Try to initialize Port from class property // Try to initialize LocalPort from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> port; if (cl_prop.is_empty()==false) cl_prop >> localPort; else { // Try to initialize Port from default device value // Try to initialize LocalPort from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> port; if (def_prop.is_empty()==false) def_prop >> localPort; } // And try to extract Port value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> port; // And try to extract LocalPort value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> localPort; // Try to initialize WorkerNumber from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); Loading @@ -294,19 +301,85 @@ void MetadataExporter::get_device_property() // And try to extract EnableSSL value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> enableSSL; // Try to initialize DatabaseHost from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> databaseHost; else { // Try to initialize DatabaseHost from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> databaseHost; } // And try to extract DatabaseHost value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> databaseHost; // Try to initialize DatabasePort from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> databasePort; else { // Try to initialize DatabasePort from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> databasePort; } // And try to extract DatabasePort value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> databasePort; // Try to initialize DatabaseUsername from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> databaseUsername; else { // Try to initialize DatabaseUsername from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> databaseUsername; } // And try to extract DatabaseUsername value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> databaseUsername; // Try to initialize DatabasePassword from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> databasePassword; else { // Try to initialize DatabasePassword from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> databasePassword; } // And try to extract DatabasePassword value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> databasePassword; // Try to initialize ExportedTables from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> exportedTables; else { // Try to initialize ExportedTables from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> exportedTables; } // And try to extract ExportedTables value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> exportedTables; // Try to initialize AuthorisedUsers from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> authorisedUsers; else { // Try to initialize AuthorisedUsers from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> authorisedUsers; } // And try to extract AuthorisedUsers value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> authorisedUsers; } /*----- PROTECTED REGION ID(MetadataExporter::get_device_property_after) ENABLED START -----*/ try { if(address.empty()) throw(invalid_argument("Address property is empty or not defined")); if(localHost.empty()) throw(invalid_argument("LocalHost property is empty or not defined")); if(port<1 || port>MAX_DMDB_PORT) throw(invalid_argument("Port property out of range or not defined")); if(localPort<1 || localPort>MAX_LOCAL_PORT) throw(invalid_argument("LocalPort property out of range or not defined")); if(workerNumber<MIN_WORKER_NUMBER || workerNumber>MAX_WORKER_NUMBER) if(workerNumber<1 || workerNumber>MAX_WORKER_NUMBER) throw(invalid_argument("WorkerNumber property out of range or not defined")); if(enableSSL) Loading @@ -320,12 +393,30 @@ void MetadataExporter::get_device_property() if(dHTempFile.empty()) throw(invalid_argument("DHTempFile property is empty or not defined")); } if(databaseHost.empty()) throw(invalid_argument("DatabaseHost property is empty or not defined")); if(databasePort<1 || databasePort>MAX_DB_PORT) throw(invalid_argument("DatabasePort property is empty or not defined")); if(databaseUsername.empty()) throw(invalid_argument("DatabaseUsername property is empty or not defined")); if(databasePassword.empty()) throw(invalid_argument("DatabasePassword property is empty or not defined")); if(exportedTables.empty()) throw(invalid_argument("ExportedTables property is empty or not defined")); if(authorisedUsers.empty()) throw(invalid_argument("AuthorisedUsers property is empty or not defined")); } catch(invalid_argument& ex) { set_state(Tango::FAULT); stringstream error_stream; error_stream << "FitsImporter::get_device_property() " << ex.what() << endl; error_stream << "MetadataExporter::get_device_property() " << ex.what() << endl; set_status(error_stream.str()); } Loading @@ -340,12 +431,17 @@ void MetadataExporter::get_device_property() //-------------------------------------------------------- void MetadataExporter::always_executed_hook() { DEBUG_STREAM << "MetadataExporter::always_executed_hook() " << device_name << endl; INFO_STREAM << "MetadataExporter::always_executed_hook() " << device_name << endl; /*----- PROTECTED REGION ID(MetadataExporter::always_executed_hook) ENABLED START -----*/ if(get_state() != Tango::FAULT) { //TODO: state and status if(m_server_sp) { set_state(m_server_sp->readState()); set_status(m_server_sp->readStatus()); } } /*----- PROTECTED REGION END -----*/ // MetadataExporter::always_executed_hook Loading
src/MetadataExporter.h +33 −10 Original line number Diff line number Diff line Loading @@ -42,6 +42,8 @@ #include <tango.h> #include <map> /*----- PROTECTED REGION END -----*/ // MetadataExporter.h /** Loading @@ -65,17 +67,24 @@ class MetadataExporter : public TANGO_BASE_CLASS //------------------------------------------------------------------------------ // [Private] Class variables //------------------------------------------------------------------------------ //Server base class shared pointer Server::SP m_server_sp; //Max port number allowed value static const unsigned int MAX_DMDB_PORT = 65535; //Min number of worker thread allowed static const unsigned int MIN_WORKER_NUMBER = 1; //Max local port number allowed value static const unsigned int MAX_LOCAL_PORT = 65535; //Max number of worker thread allowed static const unsigned int MAX_WORKER_NUMBER = 100; //Max database port number allowed value static const unsigned int MAX_DB_PORT = 65535; //Exported tables map std::map<std::string, std::string> m_exportedTableMap; //Authorised user password map std::map<std::string, std::string> m_authorisedUserMap; /*----- PROTECTED REGION END -----*/ // MetadataExporter::Data Members // Device property data members Loading @@ -86,14 +95,28 @@ public: string privateKeyFile; // DHTempFile: Absolute path to Diffie Hellman temporary file string dHTempFile; // Address: Address used for wait incoming connection string address; // Port: Port used for wait incoming connection Tango::DevULong port; // LocalHost: Local host address for incoming connection string localHost; // LocalPort: Local port for wait incoming connection Tango::DevULong localPort; // WorkerNumber: Number of threads that call io service run methods Tango::DevUShort workerNumber; // EnableSSL: Enable or disable SSL connections Tango::DevBoolean enableSSL; // DatabaseHost: Metadata database host string databaseHost; // DatabasePort: Metadata database port Tango::DevULong databasePort; // DatabaseUsername: Metadata database login username string databaseUsername; // DatabasePassword: Metadata database login password string databasePassword; // ExportedTables: Tables exporter from database: one table per row // [schema table] vector<string> exportedTables; // AuthorisedUsers: Authorised user list: one user per row // [username password] vector<string> authorisedUsers; // Constructors and destructors Loading
src/MetadataExporter.xmi +34 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,14 @@ <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </classProperties> <classProperties name="ExportedTables" description="Tables exporter from database: one table per row
[schema table]"> <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </classProperties> <classProperties name="AuthorisedUsers" description="Authorised user list: one user per row
[username password]"> <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </classProperties> <deviceProperties name="CertificateFile" description="Absolute path to certificate chain file"> <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> Loading @@ -29,11 +37,11 @@ <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <deviceProperties name="Address" description="Address used for wait incoming connection"> <deviceProperties name="LocalHost" description="Local host address for incoming connection"> <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <deviceProperties name="Port" description="Port used for wait incoming connection"> <deviceProperties name="LocalPort" description="Local port for wait incoming connection"> <type xsi:type="pogoDsl:UIntType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> Loading @@ -47,6 +55,30 @@ <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <DefaultPropValue>0</DefaultPropValue> </deviceProperties> <deviceProperties name="DatabaseHost" description="Metadata database host"> <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <deviceProperties name="DatabasePort" description="Metadata database port"> <type xsi:type="pogoDsl:UIntType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <deviceProperties name="DatabaseUsername" description="Metadata database login username"> <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <deviceProperties name="DatabasePassword" description="Metadata database login password"> <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <deviceProperties name="ExportedTables" description="Tables exporter from database: one table per row
[schema table]"> <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <deviceProperties name="AuthorisedUsers" description="Authorised user list: one user per row
[username password]"> <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> <commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0"> <argin description="none"> <type xsi:type="pogoDsl:VoidType"/> Loading
src/MetadataExporterClass.cpp +134 −4 File changed.Preview size limit exceeded, changes collapsed. Show changes