+//______________________________________________________________________________________________
+UInt_t AliShuttleConfig::SetGlobalConfig(TList* list)
+{
+ // Set the global configuration (DAQ Logbook + preprocessor monitoring settings)
+
+
+ TLDAPEntry* anEntry = 0;
+ TLDAPAttribute* anAttribute = 0;
+
+ if (list->GetEntries() == 0)
+ {
+ AliError("Global configuration not found!");
+ return 1;
+ }
+ else if (list->GetEntries() > 1)
+ {
+ AliError("More than one global configuration found!");
+ return 2;
+ }
+
+ anEntry = dynamic_cast<TLDAPEntry*> (list->At(0));
+
+ if (!anEntry)
+ {
+ AliError("Unexpected! Global list does not contain a TLDAPEntry");
+ return 3;
+ }
+
+
+ anAttribute = anEntry->GetAttribute("AlienPath");
+ if (!anAttribute) {
+ AliError("Can't find AlienPath attribute!");
+ return 4;
+ }
+ fAlienPath = anAttribute->GetValue();
+
+ anAttribute = anEntry->GetAttribute("daqLbHost");
+ if (!anAttribute) {
+ AliError("Can't find daqLbHost attribute!");
+ return 4;
+ }
+ fDAQlbHost = anAttribute->GetValue();
+
+ anAttribute = anEntry->GetAttribute("daqLbPort"); // MAY
+ if (anAttribute)
+ {
+ fDAQlbPort = ((TString) anAttribute->GetValue()).Atoi();
+ } else {
+ fDAQlbPort = 3306; // mysql
+ }
+
+ anAttribute = anEntry->GetAttribute("daqLbUser");
+ if (!anAttribute) {
+ AliError("Can't find daqLbUser attribute!");
+ return 4;
+ }
+ fDAQlbUser = anAttribute->GetValue();
+
+ anAttribute = anEntry->GetAttribute("daqLbDB");
+ if (!anAttribute) {
+ AliError("Can't find daqLbDB attribute!");
+ return 4;
+ }
+ fDAQlbDB = anAttribute->GetValue();
+
+ anAttribute = anEntry->GetAttribute("daqLbTable");
+ if (!anAttribute) {
+ AliError("Can't find daqLbTable attribute!");
+ return 4;
+ }
+ fDAQlbTable = anAttribute->GetValue();
+
+ anAttribute = anEntry->GetAttribute("shuttleLbTable");
+ if (!anAttribute) {
+ AliError("Can't find shuttleLbTable attribute!");
+ return 4;
+ }
+ fShuttlelbTable = anAttribute->GetValue();
+
+ anAttribute = anEntry->GetAttribute("runTypeLbTable");
+ if (!anAttribute) {
+ AliError("Can't find runTypeLbTable attribute!");
+ return 4;
+ }
+ fRunTypelbTable = anAttribute->GetValue();
+
+ anAttribute = anEntry->GetAttribute("ppmaxRetries");
+ if (!anAttribute) {
+ AliError("Can't find ppmaxRetries attribute!");
+ return 4;
+ }
+ TString tmpStr = anAttribute->GetValue();
+ fMaxRetries = tmpStr.Atoi();
+
+ anAttribute = anEntry->GetAttribute("terminateFilePath");
+ if (anAttribute) {
+ fTerminateFilePath = anAttribute->GetValue();
+ }
+
+ anAttribute = anEntry->GetAttribute("ppTimeOut");
+ if (!anAttribute) {
+ AliError("Can't find ppTimeOut attribute!");
+ return 4;
+ }
+ tmpStr = anAttribute->GetValue();
+ fPPTimeOut = tmpStr.Atoi();
+
+ anAttribute = anEntry->GetAttribute("dcsTimeOut");
+ if (!anAttribute) {
+ AliError("Can't find dcsTimeOut attribute!");
+ return 4;
+ }
+ tmpStr = anAttribute->GetValue();
+ fDCSTimeOut = tmpStr.Atoi();
+
+ anAttribute = anEntry->GetAttribute("nDCSretries");
+ if (!anAttribute) {
+ AliError("Can't find dcsTimeOut attribute!");
+ return 4;
+ }
+ tmpStr = anAttribute->GetValue();
+ fDCSRetries = tmpStr.Atoi();
+
+ anAttribute = anEntry->GetAttribute("DCSQueryOffset");
+ if (!anAttribute) {
+ AliError("Can't find DCSQueryOffset attribute!");
+ return 4;
+ }
+ tmpStr = anAttribute->GetValue();
+ fDCSQueryOffset = tmpStr.Atoi();
+
+ anAttribute = anEntry->GetAttribute("DCSDelay");
+ if (!anAttribute) {
+ AliError("Can't find DCSDelay attribute!");
+ return 4;
+ }
+ tmpStr = anAttribute->GetValue();
+ fDCSDelay = tmpStr.Atoi();
+
+ anAttribute = anEntry->GetAttribute("ppMaxMem");
+ if (!anAttribute) {
+ AliError("Can't find ppMaxMem attribute!");
+ return 4;
+ }
+ tmpStr = anAttribute->GetValue();
+ fPPMaxMem = tmpStr.Atoi();
+
+ anAttribute = anEntry->GetAttribute("monitorHost");
+ if (!anAttribute) {
+ AliError("Can't find monitorHost attribute!");
+ return 4;
+ }
+ fMonitorHost = anAttribute->GetValue();
+
+ anAttribute = anEntry->GetAttribute("monitorTable");
+ if (!anAttribute) {
+ AliError("Can't find monitorTable attribute!");
+ return 4;
+ }
+ fMonitorTable = anAttribute->GetValue();
+
+ anAttribute = anEntry->GetAttribute("triggerWait"); // MAY
+ if (!anAttribute) {
+ AliWarning(Form("triggerWait not set! default = %d", fTriggerWait));
+ }
+ tmpStr = anAttribute->GetValue();
+ fTriggerWait = tmpStr.Atoi();
+
+ anAttribute = anEntry->GetAttribute("ShuttleFileSystem");
+ if (!anAttribute) {
+ AliWarning(Form("ShuttleFileSystem not set! default = %s", fShuttleFileSystem.Data()));
+ }
+ fShuttleFileSystem = anAttribute->GetValue();
+
+ anAttribute = anEntry->GetAttribute("FreeDiskWarningThreshold"); // MAY
+ if (!anAttribute) {
+ AliWarning(Form("FreeDiskWarningThreshold not set! default = %d", fFreeDiskWarningThreshold));
+ }
+ tmpStr = anAttribute->GetValue();
+ fFreeDiskWarningThreshold = tmpStr.Atoi();
+
+ anAttribute = anEntry->GetAttribute("FreeDiskFatalThreshold"); // MAY
+ if (!anAttribute) {
+ AliWarning(Form("FreeDiskFatalThreshold not set! default = %d", fFreeDiskFatalThreshold));
+ }
+ tmpStr = anAttribute->GetValue();
+ fFreeDiskFatalThreshold = tmpStr.Atoi();
+
+ anAttribute = anEntry->GetAttribute("mode");
+ if (!anAttribute) {
+ AliWarning("Run mode not set! Running in test mode.");
+ } else {
+ tmpStr = anAttribute->GetValue();
+ if (tmpStr == "test")
+ {
+ fRunMode = kTest;
+ } else if (tmpStr == "prod") {
+ fRunMode = kProd;
+ } else {
+ AliWarning(Form("Not a valid run mode: %s", tmpStr.Data()));
+ AliWarning("Valid run modes are \"test\" and \"prod\". Running in test mode.");
+ }
+ }
+
+ anAttribute = anEntry->GetAttribute("keepDCSMap"); // MAY
+ if (!anAttribute)
+ {
+ AliWarning("keepDCSMap flag not set - default is FALSE");
+ } else {
+ TString keepDCSMapStr = anAttribute->GetValue();
+ if (!(keepDCSMapStr == "0" || keepDCSMapStr == "1"))
+ {
+ AliError("keepDCSMap flag must be 0 or 1!");
+ return 4;
+ }
+ fKeepDCSMap = (Bool_t) keepDCSMapStr.Atoi();
+ }
+
+ anAttribute = anEntry->GetAttribute("keepTempFolder"); // MAY
+ if (!anAttribute)
+ {
+ AliWarning("keepTempFolder flag not set - default is FALSE");
+ } else {
+ TString keepTempFolderStr = anAttribute->GetValue();
+ if (!(keepTempFolderStr == "0" || keepTempFolderStr == "1"))
+ {
+ AliError("keepTempFolder flag must be 0 or 1!");
+ return 4;
+ }
+ fKeepTempFolder = (Bool_t) keepTempFolderStr.Atoi();
+ }
+
+
+ anAttribute = anEntry->GetAttribute("shuttleAdmin"); // MAY
+ if (!anAttribute)
+ {
+ AliDebug(2, "Warning! No \"shuttleAdmin\" attribute!");
+ }
+ else
+ {
+ const char* anAdmin;
+ while ((anAdmin = anAttribute->GetValue()))
+ {
+ fAdmin[kGlobal]->AddLast(new TObjString(anAdmin));
+ }
+ }
+
+ anAttribute = anEntry->GetAttribute("amandaAdmin"); // MAY
+ if (!anAttribute)
+ {
+ AliDebug(2, "Warning! No \"amandaAdmin\" attribute!");
+ }
+ else
+ {
+ const char* anAdmin;
+ while ((anAdmin = anAttribute->GetValue()))
+ {
+ fAdmin[kAmanda]->AddLast(new TObjString(anAdmin));
+ }
+ }
+
+ anAttribute = anEntry->GetAttribute("sendMail"); // MAY
+ if (!anAttribute)
+ {
+ AliWarning("sendMail flag not set - default is FALSE");
+ } else {
+ TString sendMailStr = anAttribute->GetValue();
+ if (!(sendMailStr == "0" || sendMailStr == "1"))
+ {
+ AliError("sendMail flag must be 0 or 1!");
+ return 4;
+ }
+ fSendMail = (Bool_t) sendMailStr.Atoi();
+ }
+
+ anAttribute = anEntry->GetAttribute("passwdFilePath");
+ if (!anAttribute) {
+ AliError("Can't find Passwords File Path attribute!");
+ return 4;
+ }
+ fPasswdFilePath = anAttribute->GetValue();
+
+ return 0;
+}
+
+//______________________________________________________________________________________________
+UInt_t AliShuttleConfig::SetSysConfig(TList* list)
+{
+ // Set the online FXS configuration (DAQ + DCS + HLT + DQM)
+
+
+ TLDAPEntry* anEntry = 0;
+ TLDAPAttribute* anAttribute = 0;
+
+ if (list->GetEntries() != 4)
+ {
+ AliError(Form("Wrong number of online systems found: %d !", list->GetEntries()));
+ return 1;
+ }
+
+ TIter iter(list);
+ Int_t count = 0;
+ SystemCode iSys=kDAQ;
+
+ while ((anEntry = dynamic_cast<TLDAPEntry*> (iter.Next())))
+ {
+ anAttribute = anEntry->GetAttribute("system");
+ TString sysName = anAttribute->GetValue();
+
+ if (sysName == "DAQ")
+ {
+ iSys = kDAQ;
+ count += 1;
+ }
+ else if (sysName == "DCS")
+ {
+ iSys = kDCS;
+ count += 10;
+ }
+ else if (sysName == "HLT")
+ {
+ iSys = kHLT;
+ count += 100;
+ }
+ else if (sysName == "DQM")
+ {
+ iSys = kDQM;
+ count += 1000;
+ }
+
+ anAttribute = anEntry->GetAttribute("dbHost");
+ if (!anAttribute) {
+ AliError(Form ("Can't find dbHost attribute for %s!!",
+ AliShuttleInterface::GetSystemName(iSys)));
+ return 5;
+ }
+ fFXSdbHost[iSys] = anAttribute->GetValue();
+
+ anAttribute = anEntry->GetAttribute("dbPort"); // MAY
+ if (anAttribute)
+ {
+ fFXSdbPort[iSys] = ((TString) anAttribute->GetValue()).Atoi();
+ } else {
+ fFXSdbPort[iSys] = 3306; // mysql
+ }
+
+ anAttribute = anEntry->GetAttribute("dbUser");
+ if (!anAttribute) {
+ AliError(Form ("Can't find dbUser attribute for %s!!",
+ AliShuttleInterface::GetSystemName(iSys)));
+ return 5;
+ }
+ fFXSdbUser[iSys] = anAttribute->GetValue();
+
+ anAttribute = anEntry->GetAttribute("dbName");
+ if (!anAttribute) {
+ AliError(Form ("Can't find dbName attribute for %s!!",
+ AliShuttleInterface::GetSystemName(iSys)));
+ return 5;
+ }
+
+ fFXSdbName[iSys] = anAttribute->GetValue();
+ anAttribute = anEntry->GetAttribute("dbTable");
+ if (!anAttribute) {
+ AliError(Form ("Can't find dbTable attribute for %s!!",
+ AliShuttleInterface::GetSystemName(iSys)));
+ return 5;
+ }
+ fFXSdbTable[iSys] = anAttribute->GetValue();
+
+ anAttribute = anEntry->GetAttribute("fxsHost");
+ if (!anAttribute) {
+ AliError(Form ("Can't find fxsHost attribute for %s!!",
+ AliShuttleInterface::GetSystemName(iSys)));
+ return 5;
+ }
+ fFXSHost[iSys] = anAttribute->GetValue();
+
+ anAttribute = anEntry->GetAttribute("fxsPort"); // MAY
+ if (anAttribute)
+ {
+ fFXSPort[iSys] = ((TString) anAttribute->GetValue()).Atoi();
+ } else {
+ fFXSPort[iSys] = 22; // scp port number
+ }
+
+ anAttribute = anEntry->GetAttribute("fxsUser");
+ if (!anAttribute) {
+ AliError(Form ("Can't find fxsUser attribute for %s!!",
+ AliShuttleInterface::GetSystemName(iSys)));
+ return 5;
+ }
+ fFXSUser[iSys] = anAttribute->GetValue();
+
+ anAttribute = anEntry->GetAttribute("fxsPasswd");
+ if (anAttribute) fFXSPass[iSys] = anAttribute->GetValue();
+
+ anAttribute = anEntry->GetAttribute("fxsBaseFolder");
+ if (anAttribute) fFXSBaseFolder[iSys] = anAttribute->GetValue();
+
+ anAttribute = anEntry->GetAttribute("fxsAdmin"); // MAY
+ if (!anAttribute)
+ {
+ AliDebug(2, "Warning! No \"fxsAdmin\" attribute!");
+ }
+ else
+ {
+ const char* anAdmin;
+ while ((anAdmin = anAttribute->GetValue()))
+ {
+ fAdmin[iSys]->AddLast(new TObjString(anAdmin));
+ }
+ }
+
+ }
+
+ if(count != 1111) {
+ AliError(Form("Wrong system configuration! (code = %d)", count));
+ return 6;
+ }
+
+ return 0;
+}
+
+//______________________________________________________________________________________________
+UInt_t AliShuttleConfig::SetPasswords(){
+
+ AliInfo("Setting Passwords");
+
+ // Retrieving Passwords for DAQ lb, DAQ/DCS/HLT/DQM FXS
+
+ ifstream *inputfile = new ifstream(fPasswdFilePath.Data());
+ if (!*inputfile) {
+ AliError(Form("Error opening file %s !", fPasswdFilePath.Data()));
+ inputfile->close();
+ delete inputfile;
+ return 1;
+ }
+
+ TString line;
+ Int_t nPwd=0;
+ Int_t nPwdFake=0;
+ while (line.ReadLine(*inputfile)) {
+ TObjArray *tokens = line.Tokenize(" \t");
+ TString system = ((TObjString *)tokens->At(0))->String();
+ TString password = ((TObjString *)tokens->At(1))->String();
+ delete tokens;
+ if (system.Contains("DAQ_LB")){
+ fDAQlbPass=password;
+ nPwd++;
+ AliDebug(3,Form("DAQ_LB: Password %s for %s found", password.Data(), system.Data()));
+ }
+ else if (system.Contains("DAQ_DB")){
+ fFXSdbPass[0]=password;
+ nPwd++;
+ AliDebug(3,Form("DAQ_DB: Password %s for %s found", password.Data(), system.Data()));
+ }
+ else if (system.Contains("DCS_DB")){
+ fFXSdbPass[1]=password;
+ nPwd++;
+ AliDebug(3,Form("DCS_DB: Password %s for %s found", password.Data(), system.Data()));
+ }
+ else if (system.Contains("HLT_DB")){
+ fFXSdbPass[2]=password;
+ nPwd++;
+ AliDebug(3,Form("HLT_DB: Password %s for %s found", password.Data(), system.Data()));
+ }
+ else if (system.Contains("DQM_DB")){
+ fFXSdbPass[3]=password;
+ nPwd++;
+ AliDebug(3,Form("DQM_DB: Password %s for %s found", password.Data(), system.Data()));
+ }
+ else {
+ nPwdFake++;
+ AliDebug(3,Form("%i fake line(s) found in file %s", nPwdFake, fPasswdFilePath.Data()));
+ continue;
+ }
+ }
+
+ inputfile->close();
+ delete inputfile;
+
+ if (nPwd!=5){
+ AliError(Form("Wrong file for DAQ Logbook password found %s (some passwors missing), please Check!", fPasswdFilePath.Data()));
+ return 2;
+ }
+
+ return 0;
+
+}
+//______________________________________________________________________________________________
+UInt_t AliShuttleConfig::SetDetConfig(TList* detList, TList* dcsList)
+{
+ // Set the detector configuration (general settings + DCS amanda server and alias/DP lists)
+
+ TLDAPEntry* anEntry = 0;
+
+ TIter iter(detList);
+ while ((anEntry = dynamic_cast<TLDAPEntry*> (iter.Next())))
+ {
+
+ AliShuttleDetConfigHolder* detHolder = new AliShuttleDetConfigHolder(anEntry);
+
+ if (!detHolder->IsValid()) {
+ AliError("Detector configuration error!");
+ delete detHolder;
+ return 7;
+ }
+
+ TObjString* detStr = new TObjString(detHolder->GetDetector());
+
+ // Look for DCS Configuration
+ TIter dcsIter(dcsList);
+ TLDAPEntry *dcsEntry = 0;
+ while ((dcsEntry = dynamic_cast<TLDAPEntry*> (dcsIter.Next())))
+ {
+ TString dn = dcsEntry->GetDn();
+ if(dn.Contains(detStr->GetName())) {
+ AliDebug(2, Form("Found DCS configuration: dn = %s",dn.Data()));
+ AliShuttleDCSConfigHolder* dcsHolder = new AliShuttleDCSConfigHolder(dcsEntry);
+ if (!dcsHolder->IsValid()) {
+ AliError("DCS configuration error!");
+ delete detHolder;
+ delete dcsHolder;
+ return 7;
+ }
+ detHolder->AddDCSConfig(dcsHolder);
+ }
+ }
+
+
+ fDetectorMap.Add(detStr, detHolder);
+ fDetectorList.AddLast(detStr);
+ }
+
+ return 0;
+}
+
+//______________________________________________________________________________________________
+UInt_t AliShuttleConfig::SetHostConfig(TList* list)
+{
+ // Set the Shuttle machines configuration (which detectors processes each machine)
+
+ TLDAPEntry* anEntry = 0;
+ TLDAPAttribute* anAttribute = 0;
+
+ fShuttleInstanceHost = gSystem->HostName();
+
+ TIter iter(list);
+ while ((anEntry = dynamic_cast<TLDAPEntry*> (iter.Next())))
+ {
+
+ TString dn(anEntry->GetDn());
+ if (!dn.Contains(Form("shuttleHost=%s", fShuttleInstanceHost.Data()))) continue;
+
+ if (!fProcessAll)
+ {
+ anAttribute = anEntry->GetAttribute("detectors");
+ const char *detName;
+ while((detName = anAttribute->GetValue())){
+ TObjString *objDet= new TObjString(detName);
+ fProcessedDetectors.Add(objDet);
+ }
+ }
+ }
+
+ return 0;
+}
+
+