+ anEntry = dynamic_cast<TLDAPEntry*> (list->At(0));
+
+ if (!anEntry)
+ {
+ AliError("Unexpected! Global list does not contain a TLDAPEntry");
+ return 3;
+ }
+
+
+ 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("daqLbPasswd");
+ if (!anAttribute) {
+ AliError("Can't find daqLbPasswd attribute!");
+ return 4;
+ }
+ fDAQlbPass = 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("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("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 = ", fTriggerWait));
+ }
+ tmpStr = anAttribute->GetValue();
+ fTriggerWait = 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();
+ }
+
+ return 0;
+}
+
+//______________________________________________________________________________________________
+UInt_t AliShuttleConfig::SetSysConfig(TList* list)
+{
+ // Set the online FXS configuration (DAQ + DCS + HLT)
+
+ TLDAPEntry* anEntry = 0;
+ TLDAPAttribute* anAttribute = 0;
+
+ if (list->GetEntries() != 3)
+ {
+ 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;
+ }
+
+ 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("dbPasswd");
+ if (!anAttribute) {
+ AliError(Form ("Can't find dbPasswd attribute for %s!!",
+ AliShuttleInterface::GetSystemName(iSys)));
+ return 5;
+ }
+ fFXSdbPass[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("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 != 111) {
+ AliError(Form("Wrong system configuration! (code = %d)", count));
+ return 6;
+ }
+
+ 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;
+}
+
+
+//______________________________________________________________________________________________
+void AliShuttleConfig::Print(Option_t* option) const
+{
+// print configuration
+// options : "": print configuration for all detectors, aliases and DPs in compacted format
+// "uncompact": print configuration for all detectors, aliases and DPs in uncompacted format
+// "DET": print configuration for DET, aliases and DPs in compacted format
+// "DET, uncompact": print configuration for DET, aliases and DPs in uncompacted format
+