Skip to content
Snippets Groups Projects
Commit 73e4ca73 authored by Thomas Jürges's avatar Thomas Jürges
Browse files

SW-595: Read DB credentials and port from SAS gateway config files

The credentials have the following keys:
- SASGateway.OTDBusername
- SASGateway.OTDBpassword
- SASGateway.OTDBport
parent 68329be1
No related branches found
No related tags found
No related merge requests found
......@@ -59,8 +59,10 @@ SASGateway::SASGateway(const string& myName) :
itsDPservice (0),
itsSASservice(0),
itsTimerPort (0),
dbPort(0U),
itsPICtreeID (0),
itsQueryID (0)
{
LOG_DEBUG_STR("SASGateway(" << myName << ")");
LOG_INFO(Version::getInfo<CURTDBDaemonsVersion>("SASGateway"));
......@@ -74,7 +76,14 @@ SASGateway::SASGateway(const string& myName) :
itsSASdbname = globalParameterSet()->getString("SASGateway.OTDBdatabase");
itsSAShostname= globalParameterSet()->getString("SASGateway.OTDBhostname");
itsSASservice = new OTDBconnection("paulus", "boskabouter", itsSASdbname, itsSAShostname);
const std::string dbUsername(
globalParameterSet()->getString("SASGateway.OTDBusername"));
const std::string dbPassword(
globalParameterSet()->getString("SASGateway.OTDBpassword"));
const std::string dbPort(
globalParameterSet()->getString("SASGateway.OTDBport"));
itsSASservice = new OTDBconnection(dbUsername, dbPassword, itsSASdbname,
itsSAShostname, dbPort);
ASSERTSTR(itsSASservice, "Can't allocate connection to SAS");
itsTimerPort = new GCFTimerPort(*this, "timerPort");
......@@ -87,8 +96,8 @@ SASGateway::SASGateway(const string& myName) :
SASGateway::~SASGateway()
{
LOG_DEBUG_STR("~SASGateway()");
if (itsTimerPort) {
if (itsTimerPort) {
delete itsTimerPort;
}
if (itsDPservice) {
......@@ -120,7 +129,7 @@ GCFEvent::TResult SASGateway::connect2SAS(GCFEvent& event, GCFPortInterface& por
case F_INIT:
case F_TIMER: {
// Connect to the SAS database
LOG_INFO(formatString("Trying to connect to SAS database %s@%s",
LOG_INFO(formatString("Trying to connect to SAS database %s@%s",
itsSASdbname.c_str(), itsSAShostname.c_str()));
itsSASservice->connect();
if (!itsSASservice->isConnected()) {
......@@ -133,12 +142,12 @@ GCFEvent::TResult SASGateway::connect2SAS(GCFEvent& event, GCFPortInterface& por
LOG_INFO("Connection to SAS database succesfull, getting info about instrument");
ClassifConv CTconv(itsSASservice);
TreeTypeConv TTconv(itsSASservice);
vector<OTDBtree> treeList =
vector<OTDBtree> treeList =
itsSASservice->getTreeList(TTconv.get("hardware"), CTconv.get("operational"));
ASSERTSTR(treeList.size() == 1, "Expected 1 hardware tree in SAS, database error="
ASSERTSTR(treeList.size() == 1, "Expected 1 hardware tree in SAS, database error="
<< itsSASservice->errorMsg());
itsPICtreeID = treeList[0].treeID();
LOG_INFO(formatString("Using PICtree %d (%s)",
LOG_INFO(formatString("Using PICtree %d (%s)",
itsPICtreeID, to_simple_string(treeList[0].starttime).c_str()));
// SAS part seems OK, continue with PVSS part.
......@@ -217,7 +226,7 @@ GCFEvent::TResult SASGateway::connect2PVSS(GCFEvent& event, GCFPortInterface& po
//
// operational(event, port)
//
GCFEvent::TResult SASGateway::operational(GCFEvent& event,
GCFEvent::TResult SASGateway::operational(GCFEvent& event,
GCFPortInterface& port)
{
LOG_DEBUG_STR("operational:" << eventName(event) << "@" << port.getName());
......@@ -255,7 +264,7 @@ void SASGateway::_handleQueryEvent(GCFEvent& event)
if (!itsQueryID) {
itsQueryID = DPevent.QryID;
}
if (DPevent.result != PVSS::SA_NO_ERROR) {
LOG_ERROR_STR("PVSS reported error " << DPevent.result << " for query " << itsQueryID);
return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment